paraqeet.model.custom_hamiltonian.CustomHamiltonian#

class paraqeet.model.custom_hamiltonian.CustomHamiltonian(hamiltonian_function, parameters, gradient_functions=None, collapse_operators=None)#

Bases: DifferentiableHamiltonian

Custom Hamiltonian class to simulate systems using a user defined Hamitonian function..

Here we expect a Hamiltonian function of the form H(t, *params). Here params is a list of scalars (NOT `Quantity`).

But, parameters is a list of Quantity that would be optimized.

It is advised to make the Hamiltonian function vmap and jit compatible. Furthermore, it is advised to write the Hamiltonian function in a way such that it takes a single time point (scalar) as input and returns a jax array of dimensions [n, n].

Additionally, to optimize the parameters, one needs to pass a list of gradient functions corresponding to each parameter, in the same order as the parameter list.

To use open system simulation, provide a list of tuples of decay rates and corresponding collapse operators.

Parameters:
  • hamiltonian_function (Callable[[Array, Any], Array] | Callable[[float, Any], Array])

  • parameters (list[Quantity])

  • gradient_functions (list[Callable] | None)

  • collapse_operators (list[tuple[Array, Array]] | None)

__init__(hamiltonian_function, parameters, gradient_functions=None, collapse_operators=None)#
Parameters:
  • hamiltonian_function (Callable[[Array, Any], Array] | Callable[[float, Any], Array])

  • parameters (list[Quantity])

  • gradient_functions (list[Callable] | None)

  • collapse_operators (list[tuple[Array, Array]] | None)

Methods

__init__(hamiltonian_function, parameters[, ...])

dimension()

Return dimension of the Hilbert space.

get_collapseops()

Return collapse operators.

get_gradient_at_timestep(timestep)

Return the gradient as a function of time for a single time point.

get_parameters()

Return a list of optimizable parameters.

get_value(times)

Return Hamiltonian as a function of time for an array of time.

get_value_and_gradient(times)

Return Hamiltonian and its gradient as a function of time.

get_value_at_timestep(timestep)

Return Hamiltonian as a function of time for a single time point.

set_all_optimizable_parameters(all_params)

Set all optimizable parameters in the optimization.

set_optimizable_parameters(params)

Set which parameters associated with the object shall be considered during optimization.

value_and_get_gradient_at_timestep(time)

Return Hamiltonian and its gradient for one timestep.

Attributes

all_optimizable_parameters

Get the optimizable parameters

collapse_operators

Return collapse operators.

drives

Return the list of Drives of the system.

gradient_functions

Return gradient functions.

name

Get the name of the parameter.

optimizable_parameters

Get the optimizable parameters

property all_optimizable_parameters: list[Quantity]#

Get the optimizable parameters

Returns:

The list of all the optimizable parameters considered in the optimization

Return type:

list[Quantity]

property collapse_operators: list[tuple[Array, Array]] | None#

Return collapse operators.

dimension()#

Return dimension of the Hilbert space.

property drives: list[Drive]#

Return the list of Drives of the system.

Returns:

Returns a list of time-dependent drives of the system.

Return type:

list[Drive]

get_collapseops()#

Return collapse operators.

Return type:

list[tuple[Array, Array]]

get_gradient_at_timestep(timestep)#

Return the gradient as a function of time for a single time point.

Parameters:

timestep (float)

Return type:

Array

get_parameters()#

Return a list of optimizable parameters.

Return type:

list[Quantity]

get_value(times)#

Return Hamiltonian as a function of time for an array of time.

Parameters:

times (Array)

Return type:

Array

get_value_and_gradient(times)#

Return Hamiltonian and its gradient as a function of time.

Parameters:

times (Array)

Return type:

tuple[Array, Array]

get_value_at_timestep(timestep)#

Return Hamiltonian as a function of time for a single time point.

Parameters:

timestep (float)

Return type:

Array

property gradient_functions: list[Callable] | None#

Return gradient functions.

property name: str | None#

Get the name of the parameter.

Returns:

Name of the parameter.

Return type:

str | None

property optimizable_parameters: list[Quantity]#

Get the optimizable parameters

Returns:

The list of optimizable parameters associated with the object.

Return type:

list[Quantity]

set_all_optimizable_parameters(all_params)#

Set all optimizable parameters in the optimization.

Parameters:
  • params (List[Quantity]) – List of optimizable parameters to be set.

  • all_params (list[Quantity])

Return type:

None

set_optimizable_parameters(params)#

Set which parameters associated with the object shall be considered during optimization.

All quantities that are not in the response of get_parameters will be filtered out. This function is called by the optimizer before gradient based optimization to tell the layers which gradients to compute.

Parameters:

params (list[Quantity]) – List of optimizable parameters to be set.

Return type:

None

value_and_get_gradient_at_timestep(time)#

Return Hamiltonian and its gradient for one timestep.

Return type:

tuple[Array, Array] | tuple[float, Array]