mb_solve

class maxwellbloch.mb_solve.MBSolve(atom: dict | None = None, t_min: float = 0.0, t_max: float = 1.0, t_steps: int = 100, method: str = 'mesolve', opts: dict | None = None, savefile: str | None = None, z_min: float = 0.0, z_max: float = 1.0, z_steps: int = 10, z_steps_inner: int = 2, num_density_z_func: str | None = None, num_density_z_args: dict | None = None, interaction_strengths: list[float] | None = None, velocity_classes: dict | None = None)[source]

Bases: OBSolve

build_velocity_classes(velocity_classes: dict | None = None) tuple[ndarray, ndarray][source]

Build the velocity-class detuning grid and Boltzmann weights.

Parameters:

velocity_classes – dict of velocity-class parameters, or None for the no-Doppler-broadening case (single detuning class at 0).

Returns:

(thermal_delta_list, thermal_weights)

build_zlist(z_min: float, z_max: float, z_steps: int, z_steps_inner: int) ndarray[source]

Builds the space grid.

Parameters:
  • z_min – The front of the medium, in your chosen length unit.

  • z_max – The back of the medium.

  • z_steps – The number of even-spaced steps on which to solve and record the solution.

  • z_steps_inner – Between each z_step, make this many inner steps of the finite-difference solver (for numerical stability).

Notes

  • If the problem requires a lot of space steps for stability, but

    you don’t need to record the solution at such a high-level of resolution, increase z_steps_inner.

check() bool[source]

Validates the MBSolve object.

coherences(coupled_levels: list[list[int]]) ndarray[source]
Gets the sum of coherences (off-diagonals) in a list of coupled

level pairs.

Parameters:

coupled_levels – a list of pairs of level indexes

Returns:

np.array, shape (z_steps+1, t_steps+1), dtype=complex

Note

Unlike OBAtom.get_fields_sum_coherence, which operates on a single-z time series with per-field weighting factors, this method sums over the full (z, t) array with unit weights.

coherences_field(field_idx: int) ndarray[source]

Get the sum of coherences (off-diagonals) for the levels coupled by a field.

Parameters:

field_idx – index in the list of fields

Returns:

np.array, shape (z_steps+1, t_steps+1), dtype=complex

fields_area() ndarray[source]

Gets the integrated pulse area of each field.

Returns:

Integrated area of each field over time

Return type:

np.array [num_fields, num_z_steps]

get_json_dict() dict[source]

Return the full problem definition as a JSON-serialisable dict.

init_Omegas_zt() ndarray[source]

Inits the Rabi frequency array.

Omegas_zt shape: (num_fields, z_steps+1, t_steps+1) — field-first. states_zt shape: (z_steps+1, t_steps+1, num_states, num_states) — z-first. These are inconsistent; correcting either is a breaking API change, deferred to a future major version.

init_states_zt() ndarray[source]

Inits the system density matrices.

load_results() None[source]

Loads the solution from a QuTiP pickle file.

Raises:

ValueError – if the savefile was built from a different problem definition (hash mismatch).

Notes

  • The path from which the results will be loaded is taken from

    self.savefile.

  • Old savefiles without metadata are loaded without integrity

    checking, with a warning.

mbsolve(step: str = 'ab', rho0: Qobj | None = None, recalc: bool = True, progress: bool = True, progress_show_area: bool = False, check_counter_prop_depletion: bool = True, depletion_warn: float = 0.01, depletion_error: float = 0.1) tuple[ndarray, ndarray][source]

Solves the Maxwell-Bloch equations for the system.

Parameters:
  • step – ‘euler (for Euler method) or ‘ab’ (for Adams-Bashforth)

  • rho0 (Qobj) – the initial density matrix state

  • recalc (bool) – Recalculate the solution even if a savefile exists?

  • progress – Show a tqdm progress bar with elapsed time, ETA and current max field amplitude.

  • progress_show_area – Extend the progress bar with the pulse area ∫|Ω|dt for each field at the current z-step. Requires progress=True.

  • check_counter_prop_depletion – Run a post-solve depletion check on any counter-propagating fields. Set False to suppress.

  • depletion_warn – Depletion fraction that triggers a UserWarning.

  • depletion_error – Depletion fraction that raises CounterPropagatingDepletionError.

Returns:

The solved field complex Rabi frequency at each

point in space z and time t.

self.states_zt: The solved density matrix at each point in space z

and time t.

Return type:

self.Omegas_zt

mbsolve_ab(rho0: Qobj | None = None, recalc: bool = True, progress: bool = False, progress_show_area: bool = False) tuple[ndarray, ndarray][source]

Solves the Maxwell-Bloch equations using an Adams-Bashforth step.

Parameters:
  • rho0 (Qobj) – the initial density matrix state

  • recalc (bool) – Recalculate the solution even if a savefile exists?

  • progress – Show a tqdm progress bar.

  • progress_show_area – Add pulse area ∫|Ω|dt per field to the progress bar.

Returns:

The solved field complex Rabi frequency at each

point in space z and time t.

self.states_zt: The solved density matrix at each point in space z

and time t.

Return type:

self.Omegas_zt

mbsolve_euler(rho0: Qobj | None = None, recalc: bool = True, progress: bool = False, progress_show_area: bool = False) tuple[ndarray, ndarray][source]

Solves the Maxwell-Bloch equations using a Euler step.

Parameters:
  • rho0 (Qobj) – the initial density matrix state

  • recalc (bool) – Recalculate the solution even if a savefile exists?

  • progress – Show a tqdm progress bar.

  • progress_show_area – Add pulse area ∫|Ω|dt per field to the progress bar.

Returns:

The solved field complex Rabi frequency at each

point in space z and time t.

self.states_zt: The solved density matrix at each point in space z

and time t.

Return type:

self.Omegas_zt

populations(levels: list[int]) ndarray[source]

Gets the sum of populations in a list of levels.

Parameters:

levels – a list of level indexes]

Returns:

np.array, shape (z_steps+1, t_steps+1), dtype=np.real

populations_field(field_idx: int, upper: bool = True) ndarray[source]
Gets the sum of populations for the upper (excited) level coupled by

a field.

Parameters:

field_idx – index in the list of fields

Returns:

np.array, shape (z_steps+1, t_steps+1), dtype=np.real

Note

  • Casting upper to int so upper is 1, lower is 0.

save_results() None[source]

Saves the solution to a QuTiP pickle file.

Notes

  • The path to which the results will be saved is taken from

    self.savefile.

z_step() float[source]

Returns the distance from one space point to the next.

z_step_inner() float[source]

Returns the distance from one inner space point to the next.