struqture_py.fermions.FermionLindbladNoiseOperator

class struqture_py.fermions.FermionLindbladNoiseOperator

These are representations of noisy systems of fermions.

Returns:

The new FermionLindbladNoiseSystem.

Return type:

self

Examples

import numpy.testing as npt
import scipy.sparse as sp
from qoqo_calculator_pyo3 import CalculatorComplex
from struqture_py.fermions import FermionLindbladNoiseOperator, FermionProduct

slns = FermionLindbladNoiseOperator()
dp = FermionProduct([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 the current_number_modes input of self.

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.

from_json_struqture_1(input)

Convert a json corresponding to a struqture 1 object to the equivalent object in struqture 2.

get(key)

Get the coefficient corresponding to the key.

is_empty()

Return true if object contains no values.

jordan_wigner()

Transform the given fermionic object into a spin object using the Jordan Wigner mapping.

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.

remove(key)

Remove the value of the input object key.

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 the current_number_modes input of self.

Returns:

The number of modes in self.

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.

static from_json_struqture_1(input)

Convert a json corresponding to a struqture 1 object to the equivalent object in struqture 2.

Parameters:

input (Any) -- the json of the struqture 1 object to convert.

Returns:

the input object in struqture 2 form.

Return type:

Any

Raises:
  • ValueError -- Input could not be deserialised form json.

  • ValueError -- Struqture 1 object could not be converted to struqture 2.

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

jordan_wigner()

Transform the given fermionic object into a spin object using the Jordan Wigner mapping.

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

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.

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]