IMSRG.ode_solver

Module to solve the IMSRG equations via direct integration of flow equations.

Functions

flatten_hamiltonian(dim, e0, f, gamma)

Flattens Hamiltonian components into a single array for ODE integration

imsrg_rhs(s, packed, occs, delta, dim, ...)

Right-hand side function for IMSRG flow equations

norm(x)

Computes the Frobenius norm of a tensor

solve_imsrg2(occs, e0, f, gamma[, s_init, ...])

Solves IMSRG(2) flow equations in a single integration step

unflatten_hamiltonian(dim, packed)

Reconstructs Hamiltonian components from flattened array

write_op_1b(dim, op, fname)

Writes one-body operator matrix elements to file

write_op_2b(dim, op, fname)

Writes two-body operator matrix elements to file

IMSRG.ode_solver.flatten_hamiltonian(dim, e0, f, gamma)

Flattens Hamiltonian components into a single array for ODE integration

Packs the scalar energy, one-body operator, and two-body operator into a single one-dimensional array suitable for scipy ODE solvers

Parameters:
  • dim (int) – Dimension of the single-particle basis

  • e0 (float) – Zero-body (scalar) energy contribution

  • f (numpy array) – One-body operator matrix

  • gamma (numpy array) – Two-body operator tensor

Returns:

Flattened array containing all Hamiltonian components

Return type:

numpy array

IMSRG.ode_solver.unflatten_hamiltonian(dim, packed)

Reconstructs Hamiltonian components from flattened array

Unpacks a one-dimensional array back into scalar energy, one-body matrix, and two-body tensor components for IMSRG calculations

Parameters:
  • dim (int) – Dimension of the single-particle basis

  • packed (numpy array) – Flattened array containing Hamiltonian components

Returns:

Zero-body energy, one-body matrix, and two-body tensor

Return type:

float, numpy array, numpy array

IMSRG.ode_solver.write_op_1b(dim, op, fname)

Writes one-body operator matrix elements to file

Outputs non-zero matrix elements of a one-body operator to a text file in the format: index_p index_q matrix_element

Parameters:
  • dim (int) – Dimension of the operator matrix

  • op (numpy array) – One-body operator matrix

  • fname (str) – Output filename

IMSRG.ode_solver.write_op_2b(dim, op, fname)

Writes two-body operator matrix elements to file

Outputs non-zero matrix elements of a two-body operator to a text file in the format: index_p index_q index_r index_s matrix_element

Parameters:
  • dim (int) – Dimension of each operator index

  • op (numpy array) – Two-body operator tensor

  • fname (str) – Output filename

IMSRG.ode_solver.norm(x)

Computes the Frobenius norm of a tensor

Parameters:

x (numpy array) – Input tensor

Returns:

Frobenius norm (sum of squared elements)

Return type:

float

IMSRG.ode_solver.imsrg_rhs(s, packed, occs, delta, dim, data_tracking, eta_criterion=0.001)

Right-hand side function for IMSRG flow equations

Computes the derivatives dH/ds for the IMSRG flow equations using the commutator [eta, H] where eta is the arctan generator. This is not a strictly pure function; data_tracking is modified by the function to track integration data

Parameters:
  • s (float) – Flow parameter

  • packed (numpy array) – Flattened Hamiltonian components

  • occs (numpy array) – Occupation numbers for reference state

  • delta (float) – Energy shift parameter for generator denominators

  • dim (int) – Dimension of single-particle basis

  • data_tracking (list) – List for storing flow data during integration

  • eta_criterion (float) – Optional; Generator norm at which solution should truncate. Default = 1e-3

Returns:

Flattened derivatives for ODE integration

Return type:

numpy array

IMSRG.ode_solver.solve_imsrg2(occs, e0, f, gamma, s_init=0.0, s_max=40, delta=0.0, eta_criterion=0.001)

Solves IMSRG(2) flow equations in a single integration step

Integrates the IMSRG flow equations from initial to final flow parameter values, returning the converged energy (and flow data for possible further analysis)

Parameters:
  • occs (numpy array) – Occupation numbers for reference state

  • e0 (float) – Initial zero-body energy

  • f (numpy array) – Initial one-body operator

  • gamma (numpy array) – Initial two-body operator

  • s_init (float) – Optional; initial flow parameter value, default = 0.0

  • s_max (float) – Optional; final flow parameter value, default = 40.0

  • delta (float) – Optional; energy shift for generator denominators

  • eta_criterion (float) – Optional; Generator norm at which solution should truncate. Default = 1e-3

Returns:

Final IMSRG energy and flow tracking data

Return type:

float, list[tuple[float, float, float, float]]