fock_state

Graph.fock_state(dimension, level, offset=None, *, name=None)

Create a Fock state (or a batch of them).

You can create a Fock state for a single system by providing the dimension of the truncated Fock space, the occupied energy level, and the lowest represented level offset (optional) as integer parameters. You can create a batch of Fock states by passing a list of integers to level.

Alternatively, you can create a Fock state for a composite system. In this case, the dimension (and the optional offset) must be a list of integers, representing the size of the truncated space for each subsystem (and the respective offset). You can then set the occupied level for each subsystem as follows:

  • level is an integer, meaning all subsystems have the same occupied level.

  • level is a list of integers, meaning each element represents the occupied level for the corresponding subsystem.

  • level is a list of lists. The outer list defines a batch of states. Each inner list element is treated as in the above case.

Parameters
  • dimension (int or list[int]) – The size of the state representation in the truncated Fock space. A list of integers is interpreted as the sizes of subsystems, meaning the final Fock space has the same size as the product of these integers. By default, the Fock space is truncated as [0, dimension). If non-zero offset is passed, the space is then truncated at [offset, dimension + offset).

  • level (int or list[int] or list[list[int]]) – The level at which the Fock basis is occupied. If a list of integers (or a list of integers when constructed from subsystems) is passed, this function returns a batch of Fock states, where each element is a Fock state with the energy level specified in the list.

  • offset (int or list[int], optional) – The lowest level of Fock state in the representation. Defaults to None, meaning the lowest level is 0. If set, this parameter must have the same type as dimension.

  • name (str, optional) – The name of the node.

Returns

Fock states with energy level specified by level. 1D vector if there is no batch in level, otherwise a 2D tensor where the first axis is the batch dimension.

Return type

Tensor

See also

annihilation_operator()

Create an annihilation operator in the truncated Fock space.

coherent_state()

Create a coherent state (or a batch of them).

creation_operator()

Create a creation operator in the truncated Fock space.

number_operator()

Create a number operator in the truncated Fock space.

Examples

Create a Fock state for a single system.

>>> graph.fock_state(2, 0, name="direct")
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["direct"])
>>> result.output["direct"]["value"]
array([1.+0.j, 0.+0.j])

Create a batch of Fock states for a single system.

>>> graph.fock_state(2, [0, 1], name="direct_batch")
>>> result = qctrl.functions.calculate_graph(
...     graph=graph, output_node_names=["direct_batch"]
... )
>>> result.output["direct_batch"]["value"]
array([[1.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j]])

Create a batch of Fock states for a single system with an offset.

>>> graph.fock_state(3, [1, 2], offset=1,  name="direct_offset")
>>> result = qctrl.functions.calculate_graph(
...     graph=graph, output_node_names=["direct_offset"]
>>> )
>>> result.output["direct_offset"]["value"]
array([[1.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j, 0.+0.j]])

Create a Fock state from subsystems.

>>> graph.fock_state([2, 3], [1, 2], name="subsystems")
>>> result = qctrl.functions.calculate_graph(
...     graph=graph, output_node_names=["subsystems"]
... )
>>> result.output["subsystems"]["value"]
array([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j])

Create a batch of Fock states from subsystems.

>>> graph.fock_state([2, 3], [[0, 1], [1, 2]], name="batch")
>>> result = qctrl.functions.calculate_graph(
...     graph=graph, output_node_names=["batch"]
>>> )
>>> result.output["batch"]["value"]
array([[0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j]])

Create a batch of Fock states with offset from subsystems.

>>> graph.fock_state([2, 3], [[1, 4], [1, 3]], offset=[1, 2], name="offset")
>>> result = qctrl.functions.calculate_graph(
...     graph=graph, output_node_names=["offset"]
... )
>>> result.output["offset"]["value"]
array([[0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]])