Ingredients#

Ingredients are methods associated with model classes. A generic ingredient has the form:

def ingredient_name(model, constants, parameters, **kwargs):
    # Calculate var.
    var = None
    return var

For consistency we include all of the arguments even if the ingredient does not use them. An ingredient that generates the quantum Hamiltonian for a two-level system might look like this:

def two_level_system_h_q(model, constants, parameters, **kwargs):
    """
    Quantum Hamiltonian for a two-level system.

    Required Constants:
        - two_level_system_a: Energy of the first level.
        - two_level_system_b: Energy of the second level.
        - two_level_system_c: Real part of the coupling between levels.
        - two_level_system_d: Imaginary part of the coupling between levels.

    Keyword Arguments:
        - batch_size: (Optional) Number of batches for vectorized computation.
    """
    del model
    if kwargs.get("batch_size") is not None:
        batch_size = kwargs.get("batch_size")
    else:
        batch_size = len(parameters.seed)
    h_q = np.zeros((batch_size, 2, 2), dtype=complex)
    h_q[:, 0, 0] = constants.two_level_system_a
    h_q[:, 1, 1] = constants.two_level_system_b
    h_q[:, 0, 1] = constants.two_level_system_c + 1j * constants.two_level_system_d
    h_q[:, 1, 0] = constants.two_level_system_c - 1j * constants.two_level_system_d
    return h_q

When incorporated directly into the model class (for instance when writing a model class from scratch) one should replace model with self. See the Model Development section of the User Guide for a detailed example.

Below we list all of the ingredients available in the current version of QC Lab and group ingredients by the attribute of the model that they pertain to.

Quantum Hamiltonian#

This file contains ingredient functions for use in Model classes.

qc_lab.ingredients.nearest_neighbor_lattice_h_q(model, constants, parameters, **kwargs)#

Quantum Hamiltonian for a nearest-neighbor lattice.

Required Constants:
  • num_quantum_states: Number of quantum states (sites).

  • nearest_neighbor_lattice_hopping_energy: Hopping energy between sites.

  • nearest_neighbor_lattice_periodic_boundary: Boolean indicating periodic boundary conditions.

Keyword Arguments:
  • batch_size: (Optional) Number of batches for vectorized computation.

qc_lab.ingredients.two_level_system_h_q(model, constants, parameters, **kwargs)#

Quantum Hamiltonian for a two-level system.

Required Constants:
  • two_level_system_a: Energy of the first level.

  • two_level_system_b: Energy of the second level.

  • two_level_system_c: Real part of the coupling between levels.

  • two_level_system_d: Imaginary part of the coupling between levels.

Keyword Arguments:
  • batch_size: (Optional) Number of batches for vectorized computation.

Quantum-Classical Hamiltonian#

Ingredients that generate quantum-classical interaction terms.

This file contains ingredient functions for use in Model classes.

qc_lab.ingredients.diagonal_linear_dh_qc_dzc(model, constants, parameters, **kwargs)#

Gradient of the diagonal linear quantum-classical coupling Hamiltonian.

Required Constants:
  • num_quantum_states: Number of quantum states (sites).

  • num_classical_coordinates: Number of classical coordinates

  • diagonal_linear_coupling: Array of coupling constants (num_sites, num_classical_coordinates).

Keyword Arguments:
  • z: complex-valued classical coordinates.

  • batch_size: (Optional) Number of batches for vectorized computation.

qc_lab.ingredients.diagonal_linear_h_qc(model, constants, parameters, **kwargs)#

Diagonal linear quantum-classical coupling Hamiltonian.

Diagonal elements are given by

\(H_{ii} = \sum_{j} \gamma_{ij} (z_{j} + z_{j}^*)\)

Required Constants:
  • num_quantum_states: Number of quantum states (sites).

  • num_classical_coordinates: Number of classical coordinates.

  • diagonal_linear_coupling: Array of coupling constants (num_sites, num_classical_coordinates).

Keyword Arguments:
  • z: complex-valued classical coordinates.

  • batch_size: (Optional) Number of batches for vectorized computation.

Classical Hamiltonian#

Ingredients that generate classical Hamiltonians.

This file contains ingredient functions for use in Model classes.

qc_lab.ingredients.harmonic_oscillator_dh_c_dzc(model, constants, parameters, **kwargs)#

Derivative of the classical harmonic oscillator Hamiltonian with respect to the z coordinate.

Required Constants:
  • classical_coordinate_weight: Array of weights for classical coordinates.

  • harmonic_oscillator_frequency: Array of harmonic oscillator frequencies.

Keyword Arguments:
  • z: complex-valued classical coordinates.

  • batch_size: (Optional) Number of batches for vectorized computation.

qc_lab.ingredients.harmonic_oscillator_h_c(model, constants, parameters, **kwargs)#

Harmonic oscillator classical Hamiltonian function.

Required Constants:
  • classical_coordinate_weight: Array of weights for classical coordinates.

  • harmonic_oscillator_frequency: Array of harmonic oscillator frequencies.

  • classical_coordinate_mass: Array of masses for classical coordinates.

Keyword Arguments:
  • z: complex-valued classical coordinates.

  • batch_size: (Optional) Number of batches for vectorized computation.

Classical Initialization#

Ingredients that initialize the complex-valued classical coordinates.

This file contains ingredient functions for use in Model classes.

qc_lab.ingredients.harmonic_oscillator_boltzmann_init_classical(model, constants, parameters, **kwargs)#

Initialize classical coordinates according to Boltzmann statistics for the harmonic oscillator.

Required Constants:
  • kBT: Thermal quantum.

  • classical_coordinate_weight: Array of weights for classical coordinates.

  • harmonic_oscillator_frequency: Array of harmonic oscillator frequencies.

  • classical_coordinate_mass: Array of masses for classical coordinates.

Keyword Arguments:
  • seed: Array of random seeds for initialization.

qc_lab.ingredients.harmonic_oscillator_wigner_init_classical(model, constants, parameters, **kwargs)#

Initialize classical coordinates according to the Wigner distribution of the ground state of a harmonic oscillator.

Required Constants:
  • kBT: Thermal quantum.

  • classical_coordinate_weight: Array of weights for classical coordinates.

  • harmonic_oscillator_frequency: Array of harmonic oscillator frequencies.

  • classical_coordinate_mass: Array of masses for classical coordinates.

Keyword Arguments:
  • seed: Array of random seeds for initialization.