struqture_py.bosons.BosonLindbladNoiseSystem

class struqture_py.bosons.BosonLindbladNoiseSystem(number_bosons=None)

These are representations of noisy systems of bosons.

In a BosonLindbladNoiseSystem is characterized by a BosonLindbladNoiseOperator to represent the hamiltonian of the system, and an optional number of bosons.

Parameters:

number_bosons (Optional[int]) -- The number of bosons in the BosonLindbladNoiseSystem.

Returns:

The new BosonLindbladNoiseSystem with the input number of bosons.

Return type:

self

Examples

import numpy.testing as npt
import scipy.sparse as sp
from qoqo_calculator_pyo3 import CalculatorComplex
from struqture_py.bosons import BosonLindbladNoiseSystem, BosonProduct

slns = BosonLindbladNoiseSystem()
dp = BosonProduct([0], [1])
slns.add_operator_product((dp, dp), 2.0)
npt.assert_equal(slns.current_number_modes(), 2)
npt.assert_equal(slns.get((dp, dp)), CalculatorComplex(2))
__init__()

Methods

__init__()

add_operator_product(key, value)

Adds a new (key object, CalculatorComplex) pair to existing entries.

current_number_modes()

Return maximum index in object.

current_version()

Returns the current version of the struqture library .

empty_clone([capacity])

Return an instance of self that has no entries but clones all other properties, with the given capacity.

from_bincode(input)

Convert the bincode representation of the object to an instance using the [bincode] crate.

from_json(input)

Convert the json representation of the object to an instance.

get(key)

Get the coefficient corresponding to the key.

is_empty()

Return true if object contains no values.

json_schema()

Return the JsonSchema for the json serialisation of the class.

keys()

Return unsorted keys in self.

min_supported_version()

Return the minimum version of struqture that supports this object.

number_modes()

Return the number_modes input of self.

remove(key)

Remove the value of the input object key.

separate_into_n_terms(...)

Separate self into an operator with the terms of given number of creation and annihilation operators and an operator with the remaining operations.

set(key, value)

Overwrite an existing entry or set a new entry in self.

to_bincode()

Return the bincode representation of the object using the [bincode] crate.

to_json()

Return the json representation of the object.

truncate(threshold)

Truncate self by returning a copy without entries under a threshold.

values()

Return unsorted values in self.

add_operator_product(key, value)

Adds a new (key object, CalculatorComplex) pair to existing entries.

Parameters:
  • key (Tuple[Product type, Product type]) -- The key of the value to add.

  • value (CalculatorComplex) -- The value to add.

Raises:
  • TypeError -- Value is not CalculatorComplex or CalculatorFloat.

  • ValueError -- Left-hand product could not be constructed.

  • ValueError -- Right-hand product could not be constructed.

  • ValueError -- Error in add_operator_product function of self.

current_number_modes()

Return maximum index in object.

Returns:

Maximum index.

Return type:

int

static current_version()

Returns the current version of the struqture library .

Returns:

The current version of the library.

Return type:

str

empty_clone(capacity=None)

Return an instance of self that has no entries but clones all other properties, with the given capacity.

Parameters:

capacity -- The capacity of the object to create.

Returns:

An empty clone with the same properties as self, with the given capacity.

Return type:

self

static from_bincode(input)

Convert the bincode representation of the object to an instance using the [bincode] crate.

Parameters:

input (bytearray) -- The serialized object (in [bincode] form).

Returns:

The deserialized object.

Raises:
  • TypeError -- Input cannot be converted to byte array.

  • ValueError -- Input cannot be deserialized.

static from_json(input)

Convert the json representation of the object to an instance.

Parameters:

input (str) -- The serialized object in json form.

Returns:

The deserialized object.

Raises:

ValueError -- Input cannot be deserialized.

get(key)

Get the coefficient corresponding to the key.

Parameters:

key (Tuple[Product type, Product type]) -- Product to get the value of.

Returns:

Value at key (or 0.0).

Return type:

CalculatorComplex

Raises:
  • ValueError -- Left-hand product could not be constructed from key.

  • ValueError -- Right-hand product could not be constructed from key.

is_empty()

Return true if object contains no values.

Returns:

Whether self is empty or not.

Return type:

bool

static json_schema()

Return the JsonSchema for the json serialisation of the class.

Returns:

The json schema serialized to json

Return type:

str

keys()

Return unsorted keys in self.

Returns:

The sequence of keys of self.

Return type:

List[(OperatorProduct, OperatorProduct)]

min_supported_version()

Return the minimum version of struqture that supports this object.

Returns:

The minimum version of the struqture library to deserialize this object.

Return type:

str

number_modes()

Return the number_modes input of self.

Returns:

The number of modes in self.

Return type:

int

remove(key)

Remove the value of the input object key.

Parameters:

key (Tuple[Product type, Product type]) -- The key of the value to remove.

Returns:

Key existed if this is not None, and this is the value it had before it was removed.

Return type:

Optional[CalculatorComplex]

Raises:
  • ValueError -- Left-hand Product could not be constructed.

  • ValueError -- Right-hand Product could not be constructed.

separate_into_n_terms(number_creators_annihilators_left, number_creators_annihilators_right)

Separate self into an operator with the terms of given number of creation and annihilation operators and an operator with the remaining operations.

Parameters:
  • number_creators_annihilators_left (Tuple[int, int]) -- Number of creators and number of annihilators to filter for in the left term of the keys.

  • number_creators_annihilators_right (Tuple[int, int]) -- Number of creators and number of annihilators to filter for in the right term of the keys.

Returns:

Operator with the noise terms where the number of creation and annihilation operators matches the number of spins the operator product acts on and Operator with all other contributions.

Return type:

Tuple[BosonLindbladNoiseSystem, BosonLindbladNoiseSystem]

Raises:

ValueError -- Error in adding terms to return values.

set(key, value)

Overwrite an existing entry or set a new entry in self.

Parameters:
  • key (Tuple[Product type, Product type]) -- The key of the value to set.

  • value (CalculatorComplex) -- The value to set.

Returns:

Key existed if this is not None, and this is the value it had before it was overwritten.

Return type:

Optional[CalculatorComplex]

Raises:
  • ValueError -- Left-hand Product could not be constructed.

  • ValueError -- Right-hand Product could not be constructed.

to_bincode()

Return the bincode representation of the object using the [bincode] crate.

Returns:

The serialized object (in [bincode] form).

Return type:

bytearray

Raises:

ValueError -- Cannot serialize object to bytes.

to_json()

Return the json representation of the object.

Returns:

The serialized form of the object.

Return type:

str

Raises:

ValueError -- Cannot serialize object to json.

truncate(threshold)

Truncate self by returning a copy without entries under a threshold.

Parameters:

threshold -- The threshold for inclusion.

Returns:

The truncated version of self.

Return type:

self

values()

Return unsorted values in self.

Returns:

The sequence of values of self.

Return type:

List[CalculatorComplex]