qlinks.open_system package#
The open-system package provides Lindblad operators, Liouvillian solvers,
Monte-Carlo wavefunction sampling, random state helpers, and dark-state
diagnostics. Shared local-RDM and local-operator algebra is owned by
qlinks.local_structure; local_recycling contains the Lindblad-specific
selection and recycling workflow built on those primitives.
Submodules#
qlinks.open_system.backend module#
- class qlinks.open_system.backend.OpenSystemBackend(name, array_module, sparse_module, sparse_linalg_module, supports_expm_multiply)[source]#
Bases:
objectArray/sparse backend bundle for open-system solvers.
- name#
Backend name.
- Type:
Literal[‘scipy’, ‘cupy’]
- array_module#
Dense array module, such as NumPy or CuPy.
- Type:
Any
- sparse_module#
Sparse matrix module.
- Type:
Any
- sparse_linalg_module#
Sparse linear-algebra module, if available.
- Type:
Any | None
- __init__(name, array_module, sparse_module, sparse_linalg_module, supports_expm_multiply)#
- qlinks.open_system.backend.get_open_system_backend(backend)[source]#
Resolve an open-system backend name or backend object.
- Parameters:
backend (Literal['scipy', 'cupy'] | ~qlinks.open_system.backend.OpenSystemBackend) –
"scipy","cupy", or an existing backend object.- Returns:
Backend object used by open-system operators and solvers.
- Raises:
ImportError – If
backend="cupy"is requested but CuPy is not installed.ValueError – If the backend name is unknown.
- Return type:
- qlinks.open_system.backend.as_backend_sparse_matrix(matrix, *, backend, format='csr', dtype=<class 'numpy.complex128'>)[source]#
Convert a dense or sparse matrix to a backend sparse matrix.
- Parameters:
matrix (Any) – Input matrix in dense, SciPy sparse, or backend sparse form.
backend (OpenSystemBackend) – Target backend.
format (str) – Sparse format requested from the backend.
dtype – Complex dtype for the converted matrix.
- Returns:
Sparse matrix on the requested backend.
- qlinks.open_system.backend.as_backend_dense_array(matrix, *, backend, dtype=<class 'numpy.complex128'>)[source]#
Convert a dense or sparse matrix to a backend dense array.
- Parameters:
matrix (Any) – Input matrix in dense, SciPy sparse, or backend sparse form.
backend (OpenSystemBackend) – Target backend.
dtype – Complex dtype for the converted array.
- Returns:
Dense array on the requested backend.
qlinks.open_system.diagnostics module#
- class qlinks.open_system.diagnostics.EvolutionDiagnostics(trace_errors, hermiticity_errors, min_eigenvalues, purities, fidelities, lindblad_residuals, times=None, source='density_matrices', density_check_mode='full', trajectory_counts=None, state_norm_errors=None)[source]#
Bases:
objectDiagnostics for density-matrix or MCWF evolution output.
- trace_errors#
Absolute errors of
Tr(rho)from one.- Type:
- hermiticity_errors#
Frobenius norm of anti-Hermitian parts.
- Type:
- min_eigenvalues#
Smallest density-matrix eigenvalue at each time.
- Type:
- purities#
Tr(rho^2)values.- Type:
- fidelities#
Optional fidelity with a target state/density matrix.
- Type:
numpy.ndarray | None
- lindblad_residuals#
Optional norm of the Lindblad RHS at each time.
- Type:
numpy.ndarray | None
- times#
Optional time grid.
- Type:
numpy.ndarray | None
- trajectory_counts#
Optional number of trajectories per time point.
- Type:
numpy.ndarray | None
- state_norm_errors#
Optional norm errors for pure-state trajectories.
- Type:
numpy.ndarray | None
- __init__(trace_errors, hermiticity_errors, min_eigenvalues, purities, fidelities, lindblad_residuals, times=None, source='density_matrices', density_check_mode='full', trajectory_counts=None, state_norm_errors=None)#
- qlinks.open_system.diagnostics.target_manifold_projector(target_states, *, tolerance=1e-10)[source]#
Return the projector onto a target manifold.
target_statesmay be one target vector, a(dim, n_states)matrix, or an(n_states, dim)matrix. The columns/rows are orthonormalized before building the projector, so linearly dependent target vectors are harmless.
- qlinks.open_system.diagnostics.target_manifold_weight(density_matrix, *, target_states=None, target_basis=None, projector=None, tolerance=1e-10)[source]#
Return
Tr(P_target rho)for one density matrix.Pass either
target_states/target_basisor an explicitprojector. When a target basis is supplied, the computation usesTr(Q^dagger rho Q)and avoids materializing the full projector.
- qlinks.open_system.diagnostics.target_manifold_weight_series(*, density_matrices=None, evolution_result=None, ensemble_result=None, state_snapshots=None, target_states=None, target_basis=None, projector=None, tolerance=1e-10)[source]#
Return
Tr(P_target rho(t))for evolution or MCWF output.Exactly one data source must be supplied:
density_matrices, aLindbladEvolutionResultviaevolution_result, anEnsembleResultviaensemble_result, or MCWFstate_snapshots. For state snapshots, each snapshot is expected to be a(dim, n_trajectories)state matrix and the returned weight is the trajectory average of<psi|P_target|psi>.
- qlinks.open_system.diagnostics.target_manifold_density_matrix(density_matrix, *, target_states=None, target_basis=None, normalize=True, tolerance=1e-10)[source]#
Return the density matrix reduced to the target manifold basis.
The returned matrix is
Q^dagger rho Qwhere columns ofQare an orthonormal target basis. Whennormalize=Truethis is conditioned on being in the manifold by dividing byTr(Q^dagger rho Q). If the weight is numerically zero, the unnormalized zero matrix is returned.
- qlinks.open_system.diagnostics.target_manifold_density_matrix_series(*, density_matrices=None, evolution_result=None, ensemble_result=None, state_snapshots=None, target_states=None, target_basis=None, normalize=True, tolerance=1e-10)[source]#
Return
Q^dagger rho(t) Qfor a target manifold basis.The result has shape
(n_times, manifold_dimension, manifold_dimension). Withnormalize=Trueeach time slice is conditioned by its target-manifold weight, i.e. it is divided byTr(P_target rho(t))when the weight is nonzero.
- qlinks.open_system.diagnostics.target_manifold_populations_series(**kwargs)[source]#
Return diagonal populations of the target-manifold density matrices.
- qlinks.open_system.diagnostics.target_manifold_coherence_series(*, norm='fro', **kwargs)[source]#
Return off-diagonal coherence of target-manifold density matrices.
norm="fro"returns the Frobenius norm of off-diagonal entries, whilenorm="l1"returns their elementwise absolute sum.
- qlinks.open_system.diagnostics.target_manifold_purity_series(**kwargs)[source]#
Return
Tr(rho_target(t)^2)for target-manifold density matrices.
- qlinks.open_system.diagnostics.target_manifold_entropy_series(*, base=None, tolerance=1e-12, **kwargs)[source]#
Return von Neumann entropy of target-manifold density matrices.
The input density matrices are usually conditioned by leaving
normalize=Trueinkwargs. Eigenvalues belowtoleranceare ignored in the logarithm.
- qlinks.open_system.diagnostics.jump_activity(density_matrix, jumps)[source]#
Return total Lindblad jump activity
sum_mu Tr(J_mu^dag J_mu rho).
- qlinks.open_system.diagnostics.jump_activity_series(*, jumps, density_matrices=None, evolution_result=None, ensemble_result=None, state_snapshots=None)[source]#
Return total jump activity for each time point.
For density matrices this evaluates
sum_mu Tr(J_mu^dagger J_mu rho(t)). For MCWF state snapshots it returns the trajectory average ofsum_mu ||J_mu |psi(t)>||^2.
- class qlinks.open_system.diagnostics.JumpSpanDiagnostics(dim, n_jumps, span_rank, dependent_jump_count, compression_ratio, rank_tolerance, absolute_rank_threshold, gram_eigenvalues, effective_rank, participation_rank, total_jump_nnz, span_matrix_nnz, max_normalized_overlap, mean_normalized_overlap)[source]#
Bases:
objectHilbert-Schmidt span diagnostics for a Lindblad jump list.
- __init__(dim, n_jumps, span_rank, dependent_jump_count, compression_ratio, rank_tolerance, absolute_rank_threshold, gram_eigenvalues, effective_rank, participation_rank, total_jump_nnz, span_matrix_nnz, max_normalized_overlap, mean_normalized_overlap)#
- qlinks.open_system.diagnostics.diagnose_jump_span(jumps, *, rank_tolerance=1e-10)[source]#
Diagnose exact/near linear dependencies among jump operators.
The jump-operator span is measured in the Hilbert-Schmidt inner product,
<J_i, J_j> = Tr(J_i† J_j). The rank of this Gram matrix is the number of independent jump directions. If this rank is much smaller than the raw number of jumps, a future compression pass can rotate/drop jumps before MCWF sampling without changing the Lindblad dissipator.
- qlinks.open_system.diagnostics.analyze_lindblad_evolution(density_matrices=None, *, ensemble_result=None, state_snapshots=None, trajectories=None, times=None, target_state=None, hamiltonian=None, jumps=None, atol=1e-10, backend='scipy', density_check_mode='auto')[source]#
Analyze diagnostics along Lindblad or MCWF evolution output.
The function accepts dense density matrices directly, but it can also read MCWF ensemble outputs. When an ensemble stores low-rank state snapshots but not
rho_t, diagnostics can be computed without materializing dense density matrices unlessdensity_check_mode="full"is requested.- Parameters:
density_matrices (Sequence[Any] | None) – Optional sequence of density matrices.
ensemble_result (Any | None) – Optional MCWF ensemble result. The analyzer prefers populated
rho_t, thenstate_snapshots, then stored trajectories.state_snapshots (Sequence[Any] | None) – Optional sequence of matrices with shape
(dim, n_trajectories).trajectories (Sequence[Any] | None) – Optional trajectory results with stored states.
times (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional time grid.
target_state (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional pure state for fidelity diagnostics.
hamiltonian – Optional Hamiltonian for Lindblad residual diagnostics.
jumps – Optional jump operators for Lindblad residual diagnostics.
atol (float) – Numerical tolerance for density-matrix checks.
backend (Literal['scipy', 'cupy'] | ~qlinks.open_system.backend.OpenSystemBackend) – Open-system backend name or object.
density_check_mode (str) –
"auto","full", or"low_rank"."low_rank"avoids materializing density matrices from MCWF snapshots and reportsNaNfor minimum eigenvalues.
- Returns:
Evolution diagnostics arrays.
- Return type:
- class qlinks.open_system.diagnostics.DensityMatrixVerification(trace, trace_error, hermiticity_error, min_eigenvalue, purity, fidelity_with_target, is_hermitian, is_trace_one, is_positive_semidefinite, is_density_matrix)[source]#
Bases:
objectNumerical checks for a candidate density matrix.
- __init__(trace, trace_error, hermiticity_error, min_eigenvalue, purity, fidelity_with_target, is_hermitian, is_trace_one, is_positive_semidefinite, is_density_matrix)#
- qlinks.open_system.diagnostics.verify_density_matrix(rho, *, target_state=None, atol=1e-10)[source]#
Check whether an array is a valid density matrix.
- Parameters:
rho (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Candidate density matrix.
target_state (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional pure state used to compute
<psi|rho|psi>.atol (float) – Absolute tolerance for trace, Hermiticity, and positivity checks.
- Returns:
Verification record with scalar diagnostics and boolean flags.
- Raises:
ValueError – If
rhois not square ortarget_stateis invalid.- Return type:
- class qlinks.open_system.diagnostics.LindbladFinalStateVerification(density_matrix, lindblad_residual, relative_lindblad_residual)[source]#
Bases:
objectVerification of a final Lindblad density matrix.
- density_matrix#
Basic density-matrix validity diagnostics.
- density_matrix: DensityMatrixVerification#
- __init__(density_matrix, lindblad_residual, relative_lindblad_residual)#
- qlinks.open_system.diagnostics.verify_lindblad_final_state(rho, *, hamiltonian, jumps, target_state=None, atol=1e-10, backend='scipy')[source]#
Verify density-matrix validity and Lindblad stationarity.
- Parameters:
rho (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Candidate final density matrix.
hamiltonian (Any) – Hamiltonian matrix.
jumps (list[Any] | tuple[Any, ...]) – Lindblad jump operators.
target_state (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional pure state for fidelity diagnostics.
atol (float) – Absolute tolerance passed to
verify_density_matrix().backend (Literal['scipy', 'cupy'] | ~qlinks.open_system.backend.OpenSystemBackend) – Open-system backend name or object.
- Returns:
Final-state verification record.
- Return type:
- class qlinks.open_system.diagnostics.MonitorKernelClosureDiagnostics(dim, n_monitors, closure_order, max_target_monitor_residual, target_monitor_residuals, monitor_kernel_dimension, target_projection_onto_monitor_kernel, target_distance_from_monitor_kernel, target_in_monitor_kernel, bad_monitor_kernel_dimension, bad_monitor_kernel_iprs, bad_kernel_hamiltonian_leakage_norms, min_bad_kernel_hamiltonian_leakage_norm, mean_bad_kernel_hamiltonian_leakage_norm, max_bad_kernel_hamiltonian_leakage_norm, closure_kernel_dimension, target_projection_onto_closure_kernel, target_distance_from_closure_kernel, target_in_closure_kernel, bad_closure_kernel_dimension, bad_closure_kernel_iprs)[source]#
Bases:
objectDiagnostics for monitor-kernel closure under Hamiltonian mixing.
The monitor kernel is
intersection_i ker(M_i). For a monitor-recycler designL_i = V_i M_i, this kernel is always contained in the jump kernel and therefore measures what the recyclers cannot see directly.The first Hamiltonian-closure layer appends the constraints
M_i H. If this sharply reduces the bad kernel, attraction is possible but can be slow because the Hamiltonian must rotate bad monitor-kernel states into the monitored subspace before dissipation acts.- __init__(dim, n_monitors, closure_order, max_target_monitor_residual, target_monitor_residuals, monitor_kernel_dimension, target_projection_onto_monitor_kernel, target_distance_from_monitor_kernel, target_in_monitor_kernel, bad_monitor_kernel_dimension, bad_monitor_kernel_iprs, bad_kernel_hamiltonian_leakage_norms, min_bad_kernel_hamiltonian_leakage_norm, mean_bad_kernel_hamiltonian_leakage_norm, max_bad_kernel_hamiltonian_leakage_norm, closure_kernel_dimension, target_projection_onto_closure_kernel, target_distance_from_closure_kernel, target_in_closure_kernel, bad_closure_kernel_dimension, bad_closure_kernel_iprs)#
- qlinks.open_system.diagnostics.diagnose_monitor_kernel_closure(*, hamiltonian, monitors, target_state, closure_order=1, tolerance=1e-10)[source]#
Diagnose whether local monitors are closed by Hamiltonian mixing.
This is designed for monitor-recycler jumps
L_i = V_i M_i. Recyclers cannot act on states inintersection_i ker(M_i), so the size of this kernel and its leakage underHare the first diagnostics to inspect.Currently
closure_ordersupports0or1. Order 1 appends the constraintsM_i Hand computes the common kernel of{M_i, M_i H}.
- class qlinks.open_system.diagnostics.DarkSubspaceDiagnostics(dim, n_jumps, target_norm, target_jump_residuals, max_target_jump_residual, target_liouvillian_residual, common_jump_kernel_dimension, target_projection_onto_common_kernel, target_distance_from_common_kernel, target_in_common_jump_kernel, bad_common_jump_kernel_dimension, bad_common_jump_kernel_iprs, liouvillian_zero_mode_count, liouvillian_zero_mode_count_is_lower_bound, liouvillian_spectral_gap, liouvillian_decay_gap, liouvillian_peripheral_mode_count, liouvillian_spectrum_method, liouvillian_eigenvalues, likely_unique_dark_state)[source]#
Bases:
objectDiagnostics for whether a dark target is unique/attractive.
- __init__(dim, n_jumps, target_norm, target_jump_residuals, max_target_jump_residual, target_liouvillian_residual, common_jump_kernel_dimension, target_projection_onto_common_kernel, target_distance_from_common_kernel, target_in_common_jump_kernel, bad_common_jump_kernel_dimension, bad_common_jump_kernel_iprs, liouvillian_zero_mode_count, liouvillian_zero_mode_count_is_lower_bound, liouvillian_spectral_gap, liouvillian_decay_gap, liouvillian_peripheral_mode_count, liouvillian_spectrum_method, liouvillian_eigenvalues, likely_unique_dark_state)#
- class qlinks.open_system.diagnostics.DarkManifoldDiagnostics(dim, n_jumps, manifold_dimension, hamiltonian_closure_residual, target_jump_residuals, max_target_jump_residual, target_density_liouvillian_residual, inflow_norm, common_jump_kernel_dimension, target_projection_onto_common_kernel, target_distance_from_common_kernel, target_in_common_jump_kernel, bad_common_jump_kernel_dimension, bad_common_jump_kernel_iprs, internal_hamiltonian_eigenvalues, expected_internal_liouvillian_eigenvalues, expected_internal_zero_mode_count, expected_internal_peripheral_mode_count, liouvillian_zero_mode_count, liouvillian_zero_mode_count_is_lower_bound, liouvillian_spectral_gap, liouvillian_decay_gap, liouvillian_peripheral_mode_count, liouvillian_spectrum_method, liouvillian_eigenvalues, matched_internal_nondecaying_mode_count, missing_internal_nondecaying_mode_count, extra_nondecaying_mode_count, extra_zero_mode_count, external_decay_gap, likely_attractive_dark_manifold)[source]#
Bases:
objectDiagnostics for an attractive dark manifold/DFS target.
The target is a column-orthonormal basis
Mand the target projector isP_M = M M†. UnlikeDarkSubspaceDiagnostics, this report does not expect a unique pure steady state. Internal zero or imaginary-axis Liouvillian modes generated by the projected Hamiltonian on the target manifold are treated as expected modes; only additional non-decaying modes outside the target manifold are flagged as obstructions.- __init__(dim, n_jumps, manifold_dimension, hamiltonian_closure_residual, target_jump_residuals, max_target_jump_residual, target_density_liouvillian_residual, inflow_norm, common_jump_kernel_dimension, target_projection_onto_common_kernel, target_distance_from_common_kernel, target_in_common_jump_kernel, bad_common_jump_kernel_dimension, bad_common_jump_kernel_iprs, internal_hamiltonian_eigenvalues, expected_internal_liouvillian_eigenvalues, expected_internal_zero_mode_count, expected_internal_peripheral_mode_count, liouvillian_zero_mode_count, liouvillian_zero_mode_count_is_lower_bound, liouvillian_spectral_gap, liouvillian_decay_gap, liouvillian_peripheral_mode_count, liouvillian_spectrum_method, liouvillian_eigenvalues, matched_internal_nondecaying_mode_count, missing_internal_nondecaying_mode_count, extra_nondecaying_mode_count, extra_zero_mode_count, external_decay_gap, likely_attractive_dark_manifold)#
- class qlinks.open_system.diagnostics.CommonKernelHamiltonianInvariantSectorReport(dim, n_jumps, manifold_dimension, common_jump_kernel_dimension, bad_common_jump_kernel_dimension, bad_h_invariant_kernel_dimension, h_leakage_norm_from_bad_kernel, h_leakage_norm_from_invariant_kernel, h_target_coupling_norm_from_bad_kernel, h_bad_block_norm, h_invariant_block_eigenvalues, bad_h_invariant_kernel_iprs, target_in_common_jump_kernel, kernel_tolerance)[source]#
Bases:
objectCheap obstruction diagnostic inside the common jump kernel.
The common jump-kernel condition
cap_mu ker J_mu = Mis sufficient but stronger than necessary. A complement vector in the common kernel is only a Hamiltonian-stable dark obstruction if its whole Krylov orbit underHremains inside the common jump kernel. This report computes the largest such subspace inside(cap_mu ker J_mu) cap M^perpusing a small dense nullspace problem.- __init__(dim, n_jumps, manifold_dimension, common_jump_kernel_dimension, bad_common_jump_kernel_dimension, bad_h_invariant_kernel_dimension, h_leakage_norm_from_bad_kernel, h_leakage_norm_from_invariant_kernel, h_target_coupling_norm_from_bad_kernel, h_bad_block_norm, h_invariant_block_eigenvalues, bad_h_invariant_kernel_iprs, target_in_common_jump_kernel, kernel_tolerance)#
- qlinks.open_system.diagnostics.bad_h_invariant_common_kernel_basis(*, hamiltonian, jumps, target_states, kernel_tolerance=1e-10)[source]#
Return the bad H-invariant sector inside the common jump kernel.
The returned columns form an orthonormal basis for the largest subspace of
(cap_mu ker J_mu) cap M^perpwhose Hamiltonian orbit stays inside the common jump kernel. An empty(dim, 0)array means the selected jumps have no Hamiltonian-stable dark obstruction outside the target manifold.This helper exposes the obstruction basis used internally by
diagnose_common_kernel_h_invariant_sector(), so jump-design routines can add a targeted completion stage without recomputing or interpreting a Liouvillian spectrum.
- qlinks.open_system.diagnostics.diagnose_common_kernel_h_invariant_sector(*, hamiltonian, jumps, target_states, kernel_tolerance=1e-10)[source]#
Diagnose Hamiltonian-stable obstructions inside the common jump kernel.
This is a cheap alternative to a Liouvillian spectrum check. It first computes the common jump kernel
K = cap_mu ker J_muand the bad complementB = K cap M^perp. It then computes the largest subspace ofBwhose Hamiltonian Krylov orbit stays insideK. Only this H-invariant part is a purely dark Hamiltonian-stable complement sector.
- qlinks.open_system.diagnostics.diagnose_dark_manifold(*, hamiltonian, jumps, target_states, backend='scipy', kernel_tolerance=1e-10, liouvillian_zero_tolerance=1e-09, check_liouvillian_spectrum=True, max_liouvillian_dense_dimension=4096, liouvillian_spectrum_method='auto', sparse_liouvillian_eigenvalue_count=32)[source]#
Diagnose whether a target manifold is an attractive dark manifold.
The columns of
target_statesspan the target manifold. They need not be orthonormal; this function orthonormalizes them and uses the target projectorP_M. The diagnostic accepts the internal non-decaying Liouvillian modes generated by the projected HamiltonianM† H Mand reports additional zero/peripheral modes as possible complement obstructions.
- qlinks.open_system.diagnostics.diagnose_dark_subspace(*, hamiltonian, jumps, target_state, backend='scipy', kernel_tolerance=1e-10, liouvillian_zero_tolerance=1e-09, check_liouvillian_spectrum=True, max_liouvillian_dense_dimension=4096, liouvillian_spectrum_method='auto', sparse_liouvillian_eigenvalue_count=16)[source]#
Diagnose whether a dark target is likely unique/attractive.
This is intended for small systems. It computes:
target jump residuals ||J_mu psi||;
common jump kernel dim intersection_mu ker J_mu;
bad common-kernel dimension after removing the target direction;
target Liouvillian residual ||L(|psi><psi|)||;
optional Liouvillian zero-mode count.
The Liouvillian spectrum check uses a dense solver for small Liouvillians and a sparse shift-invert Arnoldi solver for larger ones when
liouvillian_spectrum_method="auto". The sparse zero-mode count is a lower bound if all requested eigenvalues are numerically zero; increasesparse_liouvillian_eigenvalue_countto resolve more zero modes.
- class qlinks.open_system.diagnostics.AbsorbingProjectorJumpDiagnostics(jump_index, target_residual, outflow_norm, inflow_norm, commutator_norm, dissipator_adjoint_projector_norm)[source]#
Bases:
objectDiagnostics for one jump relative to a target projector.
- __init__(jump_index, target_residual, outflow_norm, inflow_norm, commutator_norm, dissipator_adjoint_projector_norm)#
- class qlinks.open_system.diagnostics.AbsorbingProjectorSymmetryDiagnostics(dim, n_jumps, hamiltonian_commutator_norm, liouvillian_adjoint_projector_norm, max_target_residual, max_outflow_norm, max_inflow_norm, max_jump_projector_commutator_norm, jump_diagnostics, absorbing_projector_is_conserved, target_is_dark, has_recycling_inflow, has_absorbing_projector_symmetry)[source]#
Bases:
objectDiagnostics for the absorbing-state projector symmetry P_psi.
- jump_diagnostics: tuple[AbsorbingProjectorJumpDiagnostics, ...]#
- __init__(dim, n_jumps, hamiltonian_commutator_norm, liouvillian_adjoint_projector_norm, max_target_residual, max_outflow_norm, max_inflow_norm, max_jump_projector_commutator_norm, jump_diagnostics, absorbing_projector_is_conserved, target_is_dark, has_recycling_inflow, has_absorbing_projector_symmetry)#
- qlinks.open_system.diagnostics.diagnose_absorbing_projector_symmetry(*, hamiltonian, jumps, target_state, backend='scipy', tolerance=1e-10)[source]#
Diagnose whether P_psi is an absorbing-state projector symmetry.
The target projector is
P_psi = |psi><psi|.
The relevant obstruction to attraction is:
J_mu |psi> = 0 and P_psi J_mu (I - P_psi) = 0
for all jumps. Then the target is dark, but there is no jump-induced inflow from psi_perp into psi. Equivalently, P_psi is conserved by the Heisenberg-picture Lindbladian.
qlinks.open_system.local_recycling module#
- class qlinks.open_system.local_recycling.TwoPatternRecyclingStructure(variable_indices, pattern_a, pattern_b, alpha_index, beta_index, phase, residual, matrix_unit_terms)[source]#
Bases:
objectDetected local two-pattern recycling structure.
This represents a local jump of the form |minus><plus|, up to phase and convention.
- matrix_unit_terms: tuple[LocalMatrixUnitTerm, ...]#
- __init__(variable_indices, pattern_a, pattern_b, alpha_index, beta_index, phase, residual, matrix_unit_terms)#
- class qlinks.open_system.local_recycling.LocalRecyclingCandidate(variable_indices, alpha_index, beta_index, jump, target_residual, inflow_norm, outflow_norm, projector_commutator_norm, local_alpha_vector, local_beta_vector, local_operator=None)[source]#
Bases:
objectOne embedded local RDM recycling jump candidate.
Most candidates are rank-one maps
|alpha><beta|between the local support and null spaces of the target reduced density matrix. A compressed block-reset candidate can instead carry a higher-ranklocal_operatorthat maps several null directions into the local target support with one Lindblad channel. Thelocal_alpha_vectorandlocal_beta_vectorfields are retained for rank-one readouts and hold representative support and null vectors for block-reset candidates.- __init__(variable_indices, alpha_index, beta_index, jump, target_residual, inflow_norm, outflow_norm, projector_commutator_norm, local_alpha_vector, local_beta_vector, local_operator=None)#
- class qlinks.open_system.local_recycling.LocalRecyclingScanResult(reduced_density_matrix, candidates)[source]#
Bases:
objectCandidate jumps from one local region.
- reduced_density_matrix: LocalReducedDensityMatrix#
- candidates: tuple[LocalRecyclingCandidate, ...]#
- property best_candidates: tuple[LocalRecyclingCandidate, ...]#
- __init__(reduced_density_matrix, candidates)#
- class qlinks.open_system.local_recycling.LocalRecyclingSelection(candidate, two_pattern_structure, score)[source]#
Bases:
objectSelected recycling candidate plus optional detected structure.
- candidate: LocalRecyclingCandidate#
- two_pattern_structure: TwoPatternRecyclingStructure | None#
- __init__(candidate, two_pattern_structure, score)#
- class qlinks.open_system.local_recycling.LocalRecyclingBuildResult(scan_results, selections)[source]#
Bases:
objectSelected recycling jumps from several local regions.
- scan_results: tuple[LocalRecyclingScanResult, ...]#
- selections: tuple[LocalRecyclingSelection, ...]#
- to_subspace_support_report()[source]#
Return a local-support/nullity report for the scanned regions.
- __init__(scan_results, selections)#
- class qlinks.open_system.local_recycling.LocalSubspaceSupportReportEntry(variable_indices, local_dim, support_rank, nullity, support_trace, min_nonzero_eigenvalue, max_eigenvalue, n_candidate_jumps, n_selected_jumps)[source]#
Bases:
objectLocal support/nullity diagnostics for one candidate region.
The local RDM is the reduced density matrix of the normalized projector onto a target subspace.
nullityis the number of local source directions annihilated by the target manifold. If it is zero, no strictly local right-detectorD_Ron this region can satisfyD_R P_M = 0.- __init__(variable_indices, local_dim, support_rank, nullity, support_trace, min_nonzero_eigenvalue, max_eigenvalue, n_candidate_jumps, n_selected_jumps)#
- class qlinks.open_system.local_recycling.LocalSubspaceSupportReport(entries)[source]#
Bases:
objectLocal-support report explaining manifold recycler availability.
- entries: tuple[LocalSubspaceSupportReportEntry, ...]#
- __init__(entries)#
- qlinks.open_system.local_recycling.local_subspace_support_report_from_recycling_build_result(build_result)[source]#
Summarize local RDM support/nullity and selected recyclers by region.
- qlinks.open_system.local_recycling.local_subspace_support_report_for_subspace(*, basis_configs, states, regions, source='local_rdm_block_reset', deduplicate_regions=False, max_jumps_per_region=1, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, max_candidates_per_region=None, prefer_sparse=True, two_pattern_tolerance=1e-08)[source]#
Build only the local manifold-support report for candidate regions.
- qlinks.open_system.local_recycling.score_recycling_jump_for_subspace(*, jump, states, tolerance=1e-10)[source]#
Return residual/inflow/outflow diagnostics for a target subspace.
The target subspace is represented by an orthonormal basis
Q. The returned values are Frobenius norms ofJ QandJ^† Q; whenJ Q=0the second norm equals the direct inflow blockQ_perp J^† Q.
- qlinks.open_system.local_recycling.score_recycling_jump(*, jump, target_state)[source]#
Return target residual, inflow, outflow, and projector commutator.
The diagnostics are Frobenius norms of the corresponding projected operators. They can be evaluated from
J|psi>andJ^dagger|psi>without materializing the dense projectors|psi><psi|andI-|psi><psi|.
- qlinks.open_system.local_recycling.scan_local_recycling_candidates(*, basis_configs, target_state, variable_indices, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-10, max_candidates=None)[source]#
Scan local rank-one recycling jumps from rho_Omega.
- qlinks.open_system.local_recycling.detect_two_pattern_recycling_structure(*, candidate, local_patterns, tolerance=1e-08)[source]#
Detect whether a candidate is a two-pattern |minus><plus| jump.
- qlinks.open_system.local_recycling.select_local_recycling_candidates(*, scan_result, source='local_rdm_two_pattern', max_candidates=1, prefer_sparse=True, two_pattern_tolerance=1e-08)[source]#
Select recycling candidates from one scan result.
local_rdm_rank_oneandlocal_rdm_two_patternkeep the historical behavior: they choose the best few rank-one reset maps|alpha><beta|.local_rdm_null_basisis designed for monitor-recycler jumpsL=V P. A single rank-one recycler can makeV Pmuch more singular than the monitorPitself, because it only tests one localbetadirection. This source instead selects one good target-support vectoralphafor every local-RDM null vectorbeta.local_rdm_block_resetis the compressed version: it groups up torank(rho_R)null vectors into each reset channel. Themax_candidatesargument is intentionally ignored for both null-basis and block-reset sources, because their counts are determined by the local RDM ranks.
- qlinks.open_system.local_recycling.scan_local_recycling_candidates_for_subspace(*, basis_configs, states, variable_indices, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-10, max_candidates=None)[source]#
Scan local rank-one recycling jumps from a target subspace RDM.
- qlinks.open_system.local_recycling.build_local_recycling_jumps_from_subspace_regions(*, basis_configs, states, regions, source='local_rdm_block_reset', deduplicate_regions=False, max_jumps_per_region=1, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, max_candidates_per_region=None, prefer_sparse=True, two_pattern_tolerance=1e-08)[source]#
Scan local recycling jumps that annihilate a target state subspace.
- qlinks.open_system.local_recycling.build_local_recycling_jumps_from_regions(*, basis_configs, target_state, regions, source='local_rdm_two_pattern', deduplicate_regions=False, max_jumps_per_region=1, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, max_candidates_per_region=None, prefer_sparse=True, two_pattern_tolerance=1e-08)[source]#
Scan several regions and return selected local recycling jumps.
Set
deduplicate_regions=Truewhen repeated monitor components share the same local support and should use one recycler family rather than one copy per component. The default keeps the historical behavior.
qlinks.open_system.operators module#
- class qlinks.open_system.operators.DenseLindbladOperators(backend, hamiltonian, jumps, jump_daggers, jump_dagger_jumps)[source]#
Bases:
objectDense Lindblad operators prepared for repeated RHS evaluations.
- backend: OpenSystemBackend#
- __init__(backend, hamiltonian, jumps, jump_daggers, jump_dagger_jumps)#
- class qlinks.open_system.operators.SparseLindbladOperators(backend, sparse_format, hamiltonian, identity, jumps, jump_dagger_jumps)[source]#
Bases:
objectSparse Lindblad operators prepared for Liouville-space construction.
- backend: OpenSystemBackend#
- __init__(backend, sparse_format, hamiltonian, identity, jumps, jump_dagger_jumps)#
- qlinks.open_system.operators.prepare_dense_lindblad_operators(*, hamiltonian, jumps, backend='scipy', dtype=<class 'numpy.complex128'>)[source]#
Convert Lindblad operators once for repeated dense RHS calls.
- qlinks.open_system.operators.prepare_sparse_lindblad_operators(*, hamiltonian, jumps, backend='scipy', sparse_format='csc', dtype=<class 'numpy.complex128'>)[source]#
Convert sparse Lindblad operators once for Liouville-space construction.
- qlinks.open_system.operators.vectorize_density_matrix(density_matrix)[source]#
Vectorize a density matrix in column-major Liouville convention.
- qlinks.open_system.operators.unvectorize_density_matrix(vectorized_density_matrix, dim)[source]#
Restore a density matrix from column-major Liouville vectorization.
- Parameters:
vectorized_density_matrix (Any) – Vector returned by
vectorize_density_matrix().dim (int) – Hilbert-space dimension.
- Returns:
(dim, dim)density matrix.- Return type:
- qlinks.open_system.operators.build_liouvillian_from_prepared(sparse_operators)[source]#
Build the Liouvillian from preconverted sparse Lindblad operators.
- qlinks.open_system.operators.build_liouvillian(hamiltonian, jumps, *, backend='scipy', sparse_format='csc', dtype=<class 'numpy.complex128'>)[source]#
Build the sparse Liouvillian superoperator.
The Liouvillian acts on density matrices vectorized with
vectorize_density_matrix().- Parameters:
hamiltonian (Any) – Hamiltonian matrix.
jumps (list[Any] | tuple[Any, ...]) – Lindblad jump operators.
backend (Literal['scipy', 'cupy'] | ~qlinks.open_system.backend.OpenSystemBackend) – Open-system backend name or object.
sparse_format (str) – Sparse format for the returned superoperator.
dtype – Complex dtype used during conversion.
- Returns:
Sparse Liouvillian matrix with shape
(dim * dim, dim * dim).
- qlinks.open_system.operators.lindblad_rhs_density_matrix(density_matrix, *, hamiltonian, jumps, backend='scipy')[source]#
Evaluate the Lindblad master-equation right-hand side.
Computes
d rho / dt = -i[H, rho] + sum_j D[J_j](rho)using dense backend arrays. For repeated calls, useprepare_dense_lindblad_operators()andlindblad_rhs_density_matrix_prepared().- Parameters:
- Returns:
Density-matrix derivative on the requested backend.
- qlinks.open_system.operators.lindblad_rhs_density_matrix_prepared(density_matrix, *, dense_operators)[source]#
Evaluate the dense Lindblad RHS using preconverted operators.
- qlinks.open_system.operators.lindblad_rhs_density_matrix_sparse_prepared(density_matrix, *, sparse_operators)[source]#
Evaluate the Lindblad RHS using sparse operators on a dense rho.
This is the matrix-free Liouville action in density-matrix form. It avoids constructing the dim^2 x dim^2 Liouvillian and also avoids densifying sparse Hamiltonian/jump operators. It is useful for intermediate dimensions where the explicit Liouvillian is too large but the density matrix itself still fits in memory.
qlinks.open_system.protocols module#
Structural interfaces accepted by open-system construction workflows.
- class qlinks.open_system.protocols.CageStateRecordLike(*args, **kwargs)[source]#
Bases:
ProtocolMinimal cage-state record interface needed by Lindblad construction.
Concrete cage-search records satisfy this protocol structurally. Keeping the protocol here avoids coupling the open-system layer to the caging search implementation and also permits lightweight user-defined records.
- __init__(*args, **kwargs)#
qlinks.open_system.solvers module#
- class qlinks.open_system.solvers.LindbladEvolutionOptions(method='auto', backend='scipy', rk4_step_policy='adaptive', max_dimension_for_liouvillian=400, max_dimension_for_krylov=400, max_rk4_step_scale=0.05, adaptive_tolerance=1e-08, min_substeps=1, max_substeps=1024, enforce_hermiticity=True, renormalize_trace=True, check_density_matrix=True)[source]#
Bases:
objectOptions controlling Lindblad time evolution.
- method#
Solver method.
"auto"chooses between Krylov and RK4 variants from system size and backend capabilities.- Type:
Literal[‘auto’, ‘krylov’, ‘rk4_matrix’, ‘rk4_sparse_matrix’, ‘rk4_liouville’]
- backend#
Backend used for dense/sparse array operations.
- Type:
Literal[‘scipy’, ‘cupy’]
- rk4_step_policy#
Policy when the requested time grid is too coarse for RK4 according to the Lindblad scale estimate.
- Type:
Literal[‘raise’, ‘warn’, ‘adaptive’, ‘ignore’]
- max_dimension_for_liouvillian#
Largest Hilbert dimension for explicit Liouville-space RK4 in
"auto"mode.- Type:
- max_dimension_for_krylov#
Largest Hilbert dimension for Krylov
expm_multiplyin"auto"mode.- Type:
- __init__(method='auto', backend='scipy', rk4_step_policy='adaptive', max_dimension_for_liouvillian=400, max_dimension_for_krylov=400, max_rk4_step_scale=0.05, adaptive_tolerance=1e-08, min_substeps=1, max_substeps=1024, enforce_hermiticity=True, renormalize_trace=True, check_density_matrix=True)#
- class qlinks.open_system.solvers.LindbladEvolutionResult(times, density_matrices, method, backend, diagnostics, n_substeps_per_interval)[source]#
Bases:
objectResult returned by Lindblad time-evolution solvers.
- times#
Time grid used by the evolution.
- Type:
- n_substeps_per_interval#
RK4 substep counts for each interval, or an empty tuple for non-RK4 methods.
- __init__(times, density_matrices, method, backend, diagnostics, n_substeps_per_interval)#
- class qlinks.open_system.solvers.LindbladProblem(*, hamiltonian, jumps, backend='scipy')[source]#
Bases:
objectReusable Lindblad problem with cached prepared operators.
The problem stores a Hamiltonian and jump list, prepares dense/sparse operator bundles lazily, and exposes RHS, Liouvillian, and evolution methods that reuse those caches.
- property dense_operators: DenseLindbladOperators[source]#
- qlinks.open_system.solvers.solve_lindblad(*, hamiltonian, jumps, density_matrix_initial, times, method='auto', backend='scipy', options=None)[source]#
Evolve a density matrix under a Lindblad master equation.
- Parameters:
hamiltonian (Any) – Hamiltonian matrix.
jumps (list[Any] | tuple[Any, ...]) – Lindblad jump operators.
density_matrix_initial (Any) – Initial density matrix.
times (ndarray) – Strictly increasing one-dimensional time grid.
method (Literal['auto', 'krylov', 'rk4_matrix', 'rk4_sparse_matrix', 'rk4_liouville']) – Solver method, or
"auto".backend (Literal['scipy', 'cupy']) – Open-system backend name.
options (LindbladEvolutionOptions | None) – Optional full options object. When supplied,
methodandbackendoverride the corresponding fields.
- Returns:
Evolution result containing density matrices and diagnostics metadata.
- Return type:
qlinks.open_system.states module#
- qlinks.open_system.states.normalize_state(state, *, atol=0.0)[source]#
Return a normalized complex state vector.
- qlinks.open_system.states.random_pure_state(dim, *, rng=None)[source]#
Draw a Haar-like random complex state vector.
- qlinks.open_system.states.density_matrix_from_state(state, *, normalize=True)[source]#
Return the pure density matrix associated with a state vector.
- Parameters:
- Returns:
Complex density matrix
|psi><psi|.- Return type:
- qlinks.open_system.states.pure_density_matrix(state, *, normalize=True)[source]#
Return |psi><psi|.
- qlinks.open_system.states.random_pure_density_matrix(dim, *, rng=None)[source]#
Draw a random pure density matrix |psi><psi|.
- qlinks.open_system.states.random_mixed_density_matrix(dim, *, rank=None, rng=None)[source]#
Draw a random mixed density matrix using a Ginibre ensemble.
The state is generated as
rho = X X^\dagger / Tr(X X^\dagger)whereXhas shape(dim, rank).- Parameters:
- Returns:
Hermitian, positive-semidefinite density matrix with trace one.
- Return type:
- qlinks.open_system.states.random_density_matrix(dim, *, kind='mixed', rank=None, rng=None)[source]#
Draw a random pure or mixed density matrix.
- Parameters:
- Returns:
Density matrix with trace one.
- Raises:
ValueError – If
kindis unsupported orrankis incompatible.- Return type:
qlinks.open_system.stochastic_schrodinger module#
- class qlinks.open_system.stochastic_schrodinger.McwfOptions(backend='scipy', n_trajectories=128, seed=None, return_backend_arrays=False, store_states=True, store_trajectories=False, normalize_each_step=True, max_jump_probability=0.1, prefer_sparse_operators=True, prefer_sparse_rate_evaluator=True, use_total_rate_first=True, compress_collinear_jumps=False, jump_compression_tolerance=1e-10, store_density_matrices=True, store_state_snapshots=False, trajectory_chunk_size=None, trajectory_chunk_workers=None, adaptive_trajectory_block_size=None, fidelity_targets=None, timing_collector=None, adaptive_time_step=False, adaptive_safety_factor=0.8, min_step_size=1e-12, max_substeps_per_interval=100000)[source]#
Bases:
objectOptions for Monte Carlo wave-function sampling.
- timing_collector: MutableMapping[str, float] | None#
- __init__(backend='scipy', n_trajectories=128, seed=None, return_backend_arrays=False, store_states=True, store_trajectories=False, normalize_each_step=True, max_jump_probability=0.1, prefer_sparse_operators=True, prefer_sparse_rate_evaluator=True, use_total_rate_first=True, compress_collinear_jumps=False, jump_compression_tolerance=1e-10, store_density_matrices=True, store_state_snapshots=False, trajectory_chunk_size=None, trajectory_chunk_workers=None, adaptive_trajectory_block_size=None, fidelity_targets=None, timing_collector=None, adaptive_time_step=False, adaptive_safety_factor=0.8, min_step_size=1e-12, max_substeps_per_interval=100000)#
- class qlinks.open_system.stochastic_schrodinger.TrajectoryResult(times, states, jump_times, jump_indices, norm_errors)[source]#
Bases:
objectSingle Monte Carlo wave-function trajectory.
- __init__(times, states, jump_times, jump_indices, norm_errors)#
- class qlinks.open_system.stochastic_schrodinger.EnsembleResult(times, rho_t, trajectories=None, state_snapshots=None, target_fidelities=None)[source]#
Bases:
objectEnsemble-averaged MCWF result.
- trajectories: tuple[TrajectoryResult, ...] | None#
- __init__(times, rho_t, trajectories=None, state_snapshots=None, target_fidelities=None)#
- qlinks.open_system.stochastic_schrodinger.projector(state)[source]#
Return |state><state|.
- qlinks.open_system.stochastic_schrodinger.expectation(state, operator)[source]#
Return <state|operator|state>.
- qlinks.open_system.stochastic_schrodinger.effective_hamiltonian(hamiltonian, jumps)[source]#
Return H_eff = H - i/2 sum_mu J_mu^dagger J_mu.
- qlinks.open_system.stochastic_schrodinger.jump_probabilities(state, jumps, step_size, *, backend)[source]#
Return first-order jump probabilities dt <psi|J^dagger J|psi>.
- qlinks.open_system.stochastic_schrodinger.choose_jump(probabilities, rng)[source]#
Choose a jump index according to normalized probabilities.
- qlinks.open_system.stochastic_schrodinger.evolve_no_jump_first_order(state, effective_hamiltonian_matrix, step_size)[source]#
First-order no-jump evolution under H_eff.
- qlinks.open_system.stochastic_schrodinger.run_quantum_jump_trajectory(*, hamiltonian, jumps, state_initial, times, rng=None, backend='scipy', return_backend_arrays=False, store_states=True, normalize_each_step=True, max_jump_probability=0.1, prefer_sparse_operators=True, prefer_sparse_rate_evaluator=True, use_total_rate_first=True, adaptive_time_step=False, adaptive_safety_factor=0.8, min_step_size=1e-12, max_substeps_per_interval=100000)[source]#
Run one Monte Carlo wave-function trajectory.
This uses a first-order no-jump propagator. It is therefore deliberately conservative: if the total jump probability in one time step is too large, it raises an error and asks the caller to refine the time grid.
- qlinks.open_system.stochastic_schrodinger.density_matrix_from_state_matrix(states)[source]#
Return the ensemble density matrix represented by state columns.
states[:, trajectory_index]is one normalized MCWF trajectory state. The returned matrix is the average projector over columns.
- qlinks.open_system.stochastic_schrodinger.sample_lindblad_mcwf(*, hamiltonian, jumps, times, state_initial=None, state_sampler=None, options=None, rng=None)[source]#
Estimate Lindblad evolution with Monte Carlo wavefunction trajectories.
- Parameters:
hamiltonian (Any) – Hamiltonian matrix.
jumps (list[Any] | tuple[Any, ...]) – Lindblad jump operators.
times (ndarray[tuple[Any, ...], dtype[float64]]) – Strictly increasing time grid.
state_initial (Any | None) – Fixed initial pure state used for every trajectory. Mutually exclusive with
state_sampler.state_sampler (Callable[[Generator], Any] | None) – Optional callable that samples an initial pure state from a NumPy random generator.
options (McwfOptions | None) – MCWF sampling and storage options.
rng (Generator | int | None) – Optional RNG or seed. Overrides
options.seedwhen supplied.
- Returns:
Ensemble result containing averaged density matrices when requested, optional low-rank state snapshots, and optional stored trajectories.
- Return type:
Module contents#
- class qlinks.open_system.AbsorbingProjectorJumpDiagnostics(jump_index, target_residual, outflow_norm, inflow_norm, commutator_norm, dissipator_adjoint_projector_norm)[source]#
Bases:
objectDiagnostics for one jump relative to a target projector.
- __init__(jump_index, target_residual, outflow_norm, inflow_norm, commutator_norm, dissipator_adjoint_projector_norm)#
- class qlinks.open_system.AbsorbingProjectorSymmetryDiagnostics(dim, n_jumps, hamiltonian_commutator_norm, liouvillian_adjoint_projector_norm, max_target_residual, max_outflow_norm, max_inflow_norm, max_jump_projector_commutator_norm, jump_diagnostics, absorbing_projector_is_conserved, target_is_dark, has_recycling_inflow, has_absorbing_projector_symmetry)[source]#
Bases:
objectDiagnostics for the absorbing-state projector symmetry P_psi.
- jump_diagnostics: tuple[AbsorbingProjectorJumpDiagnostics, ...]#
- __init__(dim, n_jumps, hamiltonian_commutator_norm, liouvillian_adjoint_projector_norm, max_target_residual, max_outflow_norm, max_inflow_norm, max_jump_projector_commutator_norm, jump_diagnostics, absorbing_projector_is_conserved, target_is_dark, has_recycling_inflow, has_absorbing_projector_symmetry)#
- class qlinks.open_system.CageLindbladDesignProblem(build_result, construction)[source]#
Bases:
objectUnified cage-state Lindblad design problem.
The object stores only the target manifold, basis/configuration metadata, and local regions needed by the successful dark-detector workflow. Use
build_cage_lindblad_problem()to construct it from either one state, many states, or cage records.- build_result: ModelBuildResult#
- construction: DegenerateCageLindbladConstruction#
- property target_manifold_projector: ndarray[tuple[Any, ...], dtype[complex128]]#
Projector onto the target dark/cage manifold.
- target_manifold_weight_series(**kwargs)[source]#
Return
Tr(P_target rho(t))for solver or MCWF output.The method forwards data-source keywords such as
evolution_result,density_matrices,ensemble_result, orstate_snapshotstoqlinks.open_system.diagnostics.target_manifold_weight_series()and automatically supplies this problem’s target basis.
- target_manifold_density_matrix_series(**kwargs)[source]#
Return the conditioned density matrix inside the target manifold.
- target_manifold_populations_series(**kwargs)[source]#
Return target-basis populations inside the target manifold.
- target_manifold_coherence_series(**kwargs)[source]#
Return off-diagonal target-manifold coherence over time.
- target_manifold_purity_series(**kwargs)[source]#
Return purity of the conditioned target-manifold state over time.
- target_manifold_entropy_series(**kwargs)[source]#
Return entropy of the conditioned target-manifold state over time.
- property regional_units: tuple[tuple[int, ...], ...]#
Model-natural region units used by regional-unit modes.
- to_lindblad_problem(*, jumps, hamiltonian=None, backend=None)[source]#
Package a jump set as a solver-ready Lindblad problem.
This method is retained as a low-level helper for custom jump designs. The preferred path is
design_jumps(), which returns both the workflow report and the packagedLindbladProblemin one result.
- design_workflow(*, detector_operators, detector_operator_names=None, hamiltonian=None, basis_configs=None, **workflow_kwargs)[source]#
Run the raw dark-detector/recycler workflow report.
Most users should call
design_jumps(), which packages this report together with a solver-readyLindbladProblem. This lower-level method is useful when comparing alternative jump-design workflows.
- design_jumps(*, detector_operators, detector_operator_names=None, hamiltonian=None, basis_configs=None, backend=None, **workflow_kwargs)[source]#
Design jumps and return a solver-ready result.
The returned object exposes the workflow report through
.workflowand delegates common report properties/methods, while.lindblad_problemcan be passed directly to solvers. This avoids the older two-step patternworkflow = problem.design_jumps(...); problem = workflow.to_lindblad_problem(...).
- design_lindblad_problem(*, detector_operators, detector_operator_names=None, hamiltonian=None, basis_configs=None, backend=None, **workflow_kwargs)[source]#
Design jumps and return only the solver-ready Lindblad problem.
- __init__(build_result, construction)#
- class qlinks.open_system.CageLindbladDesignResult(problem, workflow, lindblad_problem, detector_operators=(), detector_operator_names=(), detector_terms=())[source]#
Bases:
objectResult of the unified cage-Lindblad jump-design workflow.
workflowcontains all diagnostic/readout detail.lindblad_problemis the solver-ready object with the final jump set already packaged. Common workflow methods and attributes are delegated for notebook convenience. Detector metadata is retained so the design can be exported as a reconstructable analyticalJ = R Ddata bundle.- problem: CageLindbladDesignProblem#
- workflow: DegenerateCageJumpDesignWorkflowReport#
- lindblad_problem: LindbladProblem#
- detector_terms: tuple[LocalTermDescriptor, ...]#
- property h_invariant_report: CommonKernelHamiltonianInvariantSectorReport | None#
- property solver_problem: LindbladProblem#
Alias for
lindblad_problemused by some solver-oriented notebooks.
- property target_manifold_projector: ndarray[tuple[Any, ...], dtype[complex128]]#
Projector onto this design’s target dark/cage manifold.
- target_manifold_weight_series(**kwargs)[source]#
Return
Tr(P_target rho(t))for evolution or MCWF output.Examples
design.target_manifold_weight_series(evolution_result=result)for Lindblad density-matrix solvers, ordesign.target_manifold_weight_series(ensemble_result=mcwf)for MCWF results containingrho_torstate_snapshots.
- target_manifold_density_matrix_series(**kwargs)[source]#
Return the conditioned density matrix inside the target manifold.
- target_manifold_populations_series(**kwargs)[source]#
Return target-basis populations inside the target manifold.
- target_manifold_coherence_series(**kwargs)[source]#
Return off-diagonal target-manifold coherence over time.
- target_manifold_purity_series(**kwargs)[source]#
Return purity of the conditioned target-manifold state over time.
- target_manifold_entropy_series(**kwargs)[source]#
Return entropy of the conditioned target-manifold state over time.
- evolve_with_target_weight(density_matrix_initial, times, *, options=None)[source]#
Evolve this Lindblad problem and return target-manifold weights.
This is a convenience wrapper around
self.lindblad_problem.evolvefollowed byTr(P_target rho(t)).
- export(path, *, include_basis=True, include_global_matrices=False, include_detector_matrices=False, include_readouts=True, matrix_element_tolerance=0.0, overwrite=False)[source]#
Export this design as a versioned JSON/JSONL data bundle.
The export stores the analytical jump structure by default: dark detectors as coefficient combinations and recycled/targeted local matrices in COO form. Full sparse matrices are optional and stored as SciPy
.npzfiles when requested.
- __init__(problem, workflow, lindblad_problem, detector_operators=(), detector_operator_names=(), detector_terms=())#
- class qlinks.open_system.CageLindbladDetectorOperators(operators, names, terms=())[source]#
Bases:
objectNamed local operators used to build dark detector combinations.
operatorsare the matricesO_isupplied to the dark-detector solver, whilenamesare the corresponding labels used in workflow/readout reports.- terms: tuple[LocalTermDescriptor, ...]#
- __init__(operators, names, terms=())#
- class qlinks.open_system.CageLindbladExportResult(path, manifest_path)[source]#
Bases:
objectPaths written by
export_cage_lindblad_design().- __init__(path, manifest_path)#
- qlinks.open_system.CageLindbladWorkflowReport#
alias of
DegenerateCageJumpDesignWorkflowReport
- class qlinks.open_system.CommonKernelHamiltonianInvariantSectorReport(dim, n_jumps, manifold_dimension, common_jump_kernel_dimension, bad_common_jump_kernel_dimension, bad_h_invariant_kernel_dimension, h_leakage_norm_from_bad_kernel, h_leakage_norm_from_invariant_kernel, h_target_coupling_norm_from_bad_kernel, h_bad_block_norm, h_invariant_block_eigenvalues, bad_h_invariant_kernel_iprs, target_in_common_jump_kernel, kernel_tolerance)[source]#
Bases:
objectCheap obstruction diagnostic inside the common jump kernel.
The common jump-kernel condition
cap_mu ker J_mu = Mis sufficient but stronger than necessary. A complement vector in the common kernel is only a Hamiltonian-stable dark obstruction if its whole Krylov orbit underHremains inside the common jump kernel. This report computes the largest such subspace inside(cap_mu ker J_mu) cap M^perpusing a small dense nullspace problem.- __init__(dim, n_jumps, manifold_dimension, common_jump_kernel_dimension, bad_common_jump_kernel_dimension, bad_h_invariant_kernel_dimension, h_leakage_norm_from_bad_kernel, h_leakage_norm_from_invariant_kernel, h_target_coupling_norm_from_bad_kernel, h_bad_block_norm, h_invariant_block_eigenvalues, bad_h_invariant_kernel_iprs, target_in_common_jump_kernel, kernel_tolerance)#
- class qlinks.open_system.DarkDetectorMatrixReadout(detector_index, label, coefficients, operator_names, terms, action_residual, relative_action_residual, operator_frobenius_norm, coefficient_ipr, effective_operator_count)[source]#
Bases:
objectCoefficient readout for a collective dark detector.
This intentionally does not store a dense global matrix. The detector is a linear combination of the supplied detector operator family; the readout is meant for inspecting the algebraic structure of that combination.
- terms: tuple[DarkOperatorTerm, ...]#
- property is_local_matrix_readout: bool#
Whether this readout can be drawn by
LocalBasisGridVisualizer.
- __init__(detector_index, label, coefficients, operator_names, terms, action_residual, relative_action_residual, operator_frobenius_norm, coefficient_ipr, effective_operator_count)#
- class qlinks.open_system.DarkManifoldDiagnostics(dim, n_jumps, manifold_dimension, hamiltonian_closure_residual, target_jump_residuals, max_target_jump_residual, target_density_liouvillian_residual, inflow_norm, common_jump_kernel_dimension, target_projection_onto_common_kernel, target_distance_from_common_kernel, target_in_common_jump_kernel, bad_common_jump_kernel_dimension, bad_common_jump_kernel_iprs, internal_hamiltonian_eigenvalues, expected_internal_liouvillian_eigenvalues, expected_internal_zero_mode_count, expected_internal_peripheral_mode_count, liouvillian_zero_mode_count, liouvillian_zero_mode_count_is_lower_bound, liouvillian_spectral_gap, liouvillian_decay_gap, liouvillian_peripheral_mode_count, liouvillian_spectrum_method, liouvillian_eigenvalues, matched_internal_nondecaying_mode_count, missing_internal_nondecaying_mode_count, extra_nondecaying_mode_count, extra_zero_mode_count, external_decay_gap, likely_attractive_dark_manifold)[source]#
Bases:
objectDiagnostics for an attractive dark manifold/DFS target.
The target is a column-orthonormal basis
Mand the target projector isP_M = M M†. UnlikeDarkSubspaceDiagnostics, this report does not expect a unique pure steady state. Internal zero or imaginary-axis Liouvillian modes generated by the projected Hamiltonian on the target manifold are treated as expected modes; only additional non-decaying modes outside the target manifold are flagged as obstructions.- __init__(dim, n_jumps, manifold_dimension, hamiltonian_closure_residual, target_jump_residuals, max_target_jump_residual, target_density_liouvillian_residual, inflow_norm, common_jump_kernel_dimension, target_projection_onto_common_kernel, target_distance_from_common_kernel, target_in_common_jump_kernel, bad_common_jump_kernel_dimension, bad_common_jump_kernel_iprs, internal_hamiltonian_eigenvalues, expected_internal_liouvillian_eigenvalues, expected_internal_zero_mode_count, expected_internal_peripheral_mode_count, liouvillian_zero_mode_count, liouvillian_zero_mode_count_is_lower_bound, liouvillian_spectral_gap, liouvillian_decay_gap, liouvillian_peripheral_mode_count, liouvillian_spectrum_method, liouvillian_eigenvalues, matched_internal_nondecaying_mode_count, missing_internal_nondecaying_mode_count, extra_nondecaying_mode_count, extra_zero_mode_count, external_decay_gap, likely_attractive_dark_manifold)#
- class qlinks.open_system.DarkOperatorTerm(operator_index, operator_name, coefficient, weight)[source]#
Bases:
objectOne non-negligible coefficient in a dark detector candidate.
- __init__(operator_index, operator_name, coefficient, weight)#
- class qlinks.open_system.DarkSubspaceDiagnostics(dim, n_jumps, target_norm, target_jump_residuals, max_target_jump_residual, target_liouvillian_residual, common_jump_kernel_dimension, target_projection_onto_common_kernel, target_distance_from_common_kernel, target_in_common_jump_kernel, bad_common_jump_kernel_dimension, bad_common_jump_kernel_iprs, liouvillian_zero_mode_count, liouvillian_zero_mode_count_is_lower_bound, liouvillian_spectral_gap, liouvillian_decay_gap, liouvillian_peripheral_mode_count, liouvillian_spectrum_method, liouvillian_eigenvalues, likely_unique_dark_state)[source]#
Bases:
objectDiagnostics for whether a dark target is unique/attractive.
- __init__(dim, n_jumps, target_norm, target_jump_residuals, max_target_jump_residual, target_liouvillian_residual, common_jump_kernel_dimension, target_projection_onto_common_kernel, target_distance_from_common_kernel, target_in_common_jump_kernel, bad_common_jump_kernel_dimension, bad_common_jump_kernel_iprs, liouvillian_zero_mode_count, liouvillian_zero_mode_count_is_lower_bound, liouvillian_spectral_gap, liouvillian_decay_gap, liouvillian_peripheral_mode_count, liouvillian_spectrum_method, liouvillian_eigenvalues, likely_unique_dark_state)#
- class qlinks.open_system.DenseLindbladOperators(backend, hamiltonian, jumps, jump_daggers, jump_dagger_jumps)[source]#
Bases:
objectDense Lindblad operators prepared for repeated RHS evaluations.
- backend: OpenSystemBackend#
- __init__(backend, hamiltonian, jumps, jump_daggers, jump_dagger_jumps)#
- class qlinks.open_system.DensityMatrixVerification(trace, trace_error, hermiticity_error, min_eigenvalue, purity, fidelity_with_target, is_hermitian, is_trace_one, is_positive_semidefinite, is_density_matrix)[source]#
Bases:
objectNumerical checks for a candidate density matrix.
- __init__(trace, trace_error, hermiticity_error, min_eigenvalue, purity, fidelity_with_target, is_hermitian, is_trace_one, is_positive_semidefinite, is_density_matrix)#
- class qlinks.open_system.DressedManifoldDarkDetectorCandidate(candidate_index, detector_index, detector_name, left_multiplier_index, left_multiplier_name, dark_residual, relative_dark_residual, inflow_norm, jump_frobenius_norm, target_block_norm, detector_action_residual, detector_relative_action_residual)[source]#
Bases:
objectOne dressed jump candidate
J = V Dfor a dark manifold.Dis a collective detector satisfyingD P_M ~= 0. The left multiplierVis tested as a possible recycler/inflow operator.- __init__(candidate_index, detector_index, detector_name, left_multiplier_index, left_multiplier_name, dark_residual, relative_dark_residual, inflow_norm, jump_frobenius_norm, target_block_norm, detector_action_residual, detector_relative_action_residual)#
- class qlinks.open_system.DressedManifoldDarkDetectorReport(manifold_dimension, hilbert_dimension, gram_residual, detector_names, left_multiplier_names, dark_tolerance, inflow_tolerance, candidates)[source]#
Bases:
objectReport for paper-style dressed jumps
J = V D.The supplied detector coefficients define operators
D_alphathat are expected to annihilate the target manifold. This report tests whether left multipliersV_betaturn those dark detectors into jump operators with direct inflow into the manifold.- candidates: tuple[DressedManifoldDarkDetectorCandidate, ...]#
- __init__(manifold_dimension, hilbert_dimension, gram_residual, detector_names, left_multiplier_names, dark_tolerance, inflow_tolerance, candidates)#
- class qlinks.open_system.EnsembleResult(times, rho_t, trajectories=None, state_snapshots=None, target_fidelities=None)[source]#
Bases:
objectEnsemble-averaged MCWF result.
- trajectories: tuple[TrajectoryResult, ...] | None#
- __init__(times, rho_t, trajectories=None, state_snapshots=None, target_fidelities=None)#
- class qlinks.open_system.EvolutionDiagnostics(trace_errors, hermiticity_errors, min_eigenvalues, purities, fidelities, lindblad_residuals, times=None, source='density_matrices', density_check_mode='full', trajectory_counts=None, state_norm_errors=None)[source]#
Bases:
objectDiagnostics for density-matrix or MCWF evolution output.
- trace_errors#
Absolute errors of
Tr(rho)from one.- Type:
- hermiticity_errors#
Frobenius norm of anti-Hermitian parts.
- Type:
- min_eigenvalues#
Smallest density-matrix eigenvalue at each time.
- Type:
- purities#
Tr(rho^2)values.- Type:
- fidelities#
Optional fidelity with a target state/density matrix.
- Type:
numpy.ndarray | None
- lindblad_residuals#
Optional norm of the Lindblad RHS at each time.
- Type:
numpy.ndarray | None
- times#
Optional time grid.
- Type:
numpy.ndarray | None
- trajectory_counts#
Optional number of trajectories per time point.
- Type:
numpy.ndarray | None
- state_norm_errors#
Optional norm errors for pure-state trajectories.
- Type:
numpy.ndarray | None
- __init__(trace_errors, hermiticity_errors, min_eigenvalues, purities, fidelities, lindblad_residuals, times=None, source='density_matrices', density_check_mode='full', trajectory_counts=None, state_norm_errors=None)#
- class qlinks.open_system.JumpSpanDiagnostics(dim, n_jumps, span_rank, dependent_jump_count, compression_ratio, rank_tolerance, absolute_rank_threshold, gram_eigenvalues, effective_rank, participation_rank, total_jump_nnz, span_matrix_nnz, max_normalized_overlap, mean_normalized_overlap)[source]#
Bases:
objectHilbert-Schmidt span diagnostics for a Lindblad jump list.
- __init__(dim, n_jumps, span_rank, dependent_jump_count, compression_ratio, rank_tolerance, absolute_rank_threshold, gram_eigenvalues, effective_rank, participation_rank, total_jump_nnz, span_matrix_nnz, max_normalized_overlap, mean_normalized_overlap)#
- class qlinks.open_system.LindbladEvolutionOptions(method='auto', backend='scipy', rk4_step_policy='adaptive', max_dimension_for_liouvillian=400, max_dimension_for_krylov=400, max_rk4_step_scale=0.05, adaptive_tolerance=1e-08, min_substeps=1, max_substeps=1024, enforce_hermiticity=True, renormalize_trace=True, check_density_matrix=True)[source]#
Bases:
objectOptions controlling Lindblad time evolution.
- method#
Solver method.
"auto"chooses between Krylov and RK4 variants from system size and backend capabilities.- Type:
Literal[‘auto’, ‘krylov’, ‘rk4_matrix’, ‘rk4_sparse_matrix’, ‘rk4_liouville’]
- backend#
Backend used for dense/sparse array operations.
- Type:
Literal[‘scipy’, ‘cupy’]
- rk4_step_policy#
Policy when the requested time grid is too coarse for RK4 according to the Lindblad scale estimate.
- Type:
Literal[‘raise’, ‘warn’, ‘adaptive’, ‘ignore’]
- max_dimension_for_liouvillian#
Largest Hilbert dimension for explicit Liouville-space RK4 in
"auto"mode.- Type:
- max_dimension_for_krylov#
Largest Hilbert dimension for Krylov
expm_multiplyin"auto"mode.- Type:
- __init__(method='auto', backend='scipy', rk4_step_policy='adaptive', max_dimension_for_liouvillian=400, max_dimension_for_krylov=400, max_rk4_step_scale=0.05, adaptive_tolerance=1e-08, min_substeps=1, max_substeps=1024, enforce_hermiticity=True, renormalize_trace=True, check_density_matrix=True)#
- class qlinks.open_system.LindbladEvolutionResult(times, density_matrices, method, backend, diagnostics, n_substeps_per_interval)[source]#
Bases:
objectResult returned by Lindblad time-evolution solvers.
- times#
Time grid used by the evolution.
- Type:
- n_substeps_per_interval#
RK4 substep counts for each interval, or an empty tuple for non-RK4 methods.
- __init__(times, density_matrices, method, backend, diagnostics, n_substeps_per_interval)#
- class qlinks.open_system.LindbladFinalStateVerification(density_matrix, lindblad_residual, relative_lindblad_residual)[source]#
Bases:
objectVerification of a final Lindblad density matrix.
- density_matrix#
Basic density-matrix validity diagnostics.
- density_matrix: DensityMatrixVerification#
- __init__(density_matrix, lindblad_residual, relative_lindblad_residual)#
- class qlinks.open_system.LindbladProblem(*, hamiltonian, jumps, backend='scipy')[source]#
Bases:
objectReusable Lindblad problem with cached prepared operators.
The problem stores a Hamiltonian and jump list, prepares dense/sparse operator bundles lazily, and exposes RHS, Liouvillian, and evolution methods that reuse those caches.
- property dense_operators: DenseLindbladOperators[source]#
- class qlinks.open_system.LocalMatrixUnitTerm(coefficient, target_pattern, source_pattern)[source]#
Bases:
objectOne local matrix-unit term
coefficient * |target><source|.- __init__(coefficient, target_pattern, source_pattern)#
- class qlinks.open_system.LocalOperatorMatrixReadout(label, source, variable_indices, local_patterns, local_operator, metadata=())[source]#
Bases:
objectLocal matrix readout compatible with
LocalBasisGridVisualizer.The visualizer only requires
variable_indices,local_patterns, and alocal_operator/density_matrixattribute. This readout carries the extra candidate metadata needed to interpret selected Lindblad recyclers and targeted completion operators in notebooks.- property is_local_matrix_readout: bool#
Whether this readout can be drawn by
LocalBasisGridVisualizer.
- nonzero_matrix_elements(*, tolerance=0.0)[source]#
Return
(target_index, source_index, value)nonzero local entries.
- __init__(label, source, variable_indices, local_patterns, local_operator, metadata=())#
- class qlinks.open_system.LocalRecyclingBuildResult(scan_results, selections)[source]#
Bases:
objectSelected recycling jumps from several local regions.
- scan_results: tuple[LocalRecyclingScanResult, ...]#
- selections: tuple[LocalRecyclingSelection, ...]#
- to_subspace_support_report()[source]#
Return a local-support/nullity report for the scanned regions.
- __init__(scan_results, selections)#
- class qlinks.open_system.LocalRecyclingCandidate(variable_indices, alpha_index, beta_index, jump, target_residual, inflow_norm, outflow_norm, projector_commutator_norm, local_alpha_vector, local_beta_vector, local_operator=None)[source]#
Bases:
objectOne embedded local RDM recycling jump candidate.
Most candidates are rank-one maps
|alpha><beta|between the local support and null spaces of the target reduced density matrix. A compressed block-reset candidate can instead carry a higher-ranklocal_operatorthat maps several null directions into the local target support with one Lindblad channel. Thelocal_alpha_vectorandlocal_beta_vectorfields are retained for rank-one readouts and hold representative support and null vectors for block-reset candidates.- __init__(variable_indices, alpha_index, beta_index, jump, target_residual, inflow_norm, outflow_norm, projector_commutator_norm, local_alpha_vector, local_beta_vector, local_operator=None)#
- class qlinks.open_system.LocalRecyclingScanResult(reduced_density_matrix, candidates)[source]#
Bases:
objectCandidate jumps from one local region.
- reduced_density_matrix: LocalReducedDensityMatrix#
- candidates: tuple[LocalRecyclingCandidate, ...]#
- property best_candidates: tuple[LocalRecyclingCandidate, ...]#
- __init__(reduced_density_matrix, candidates)#
- class qlinks.open_system.LocalRecyclingSelection(candidate, two_pattern_structure, score)[source]#
Bases:
objectSelected recycling candidate plus optional detected structure.
- candidate: LocalRecyclingCandidate#
- two_pattern_structure: TwoPatternRecyclingStructure | None#
- __init__(candidate, two_pattern_structure, score)#
- class qlinks.open_system.LocalReducedDensityMatrix(variable_indices, local_patterns, density_matrix, eigenvalues, support_basis, null_basis)[source]#
Bases:
objectReduced density matrix of a pure state or subspace on selected variables.
- __init__(variable_indices, local_patterns, density_matrix, eigenvalues, support_basis, null_basis)#
- class qlinks.open_system.LocalSubspaceSupportReport(entries)[source]#
Bases:
objectLocal-support report explaining manifold recycler availability.
- entries: tuple[LocalSubspaceSupportReportEntry, ...]#
- __init__(entries)#
- class qlinks.open_system.LocalSubspaceSupportReportEntry(variable_indices, local_dim, support_rank, nullity, support_trace, min_nonzero_eigenvalue, max_eigenvalue, n_candidate_jumps, n_selected_jumps)[source]#
Bases:
objectLocal support/nullity diagnostics for one candidate region.
The local RDM is the reduced density matrix of the normalized projector onto a target subspace.
nullityis the number of local source directions annihilated by the target manifold. If it is zero, no strictly local right-detectorD_Ron this region can satisfyD_R P_M = 0.- __init__(variable_indices, local_dim, support_rank, nullity, support_trace, min_nonzero_eigenvalue, max_eigenvalue, n_candidate_jumps, n_selected_jumps)#
- class qlinks.open_system.ManifoldDarkOperatorBasisReport(operator_names, manifold_dimension, hilbert_dimension, gram_residual, constraint_matrix_shape, constraint_rank, detector_nullity, singular_values, cutoff, candidates, tolerance, candidate_strategy='svd_basis')[source]#
Bases:
objectNullspace report for collective local operators dark on a manifold.
Given an operator basis
O_aand target manifold basisQ, this report solvessum_a c_a O_a Q = 0.
A nonzero solution is a collective dark detector for the supplied manifold. This is strictly more general than the local RDM null-space test: each individual region may have full local support, while a sum of local terms can still annihilate the manifold by cancellation.
- candidates: tuple[ManifoldDarkOperatorCandidate, ...]#
- detector_readout(detector_index=0)[source]#
Return a coefficient readout for one dark detector candidate.
- detector_readouts(*, max_readouts=None)[source]#
Return coefficient readouts for reported dark detector candidates.
- __init__(operator_names, manifold_dimension, hilbert_dimension, gram_residual, constraint_matrix_shape, constraint_rank, detector_nullity, singular_values, cutoff, candidates, tolerance, candidate_strategy='svd_basis')#
- class qlinks.open_system.ManifoldDarkOperatorCandidate(candidate_index, coefficients, action_residual, relative_action_residual, operator_frobenius_norm, coefficient_ipr, effective_operator_count, terms)[source]#
Bases:
objectLinear-combination detector satisfying
D P_M ~= 0.- terms: tuple[DarkOperatorTerm, ...]#
- __init__(candidate_index, coefficients, action_residual, relative_action_residual, operator_frobenius_norm, coefficient_ipr, effective_operator_count, terms)#
- class qlinks.open_system.McwfOptions(backend='scipy', n_trajectories=128, seed=None, return_backend_arrays=False, store_states=True, store_trajectories=False, normalize_each_step=True, max_jump_probability=0.1, prefer_sparse_operators=True, prefer_sparse_rate_evaluator=True, use_total_rate_first=True, compress_collinear_jumps=False, jump_compression_tolerance=1e-10, store_density_matrices=True, store_state_snapshots=False, trajectory_chunk_size=None, trajectory_chunk_workers=None, adaptive_trajectory_block_size=None, fidelity_targets=None, timing_collector=None, adaptive_time_step=False, adaptive_safety_factor=0.8, min_step_size=1e-12, max_substeps_per_interval=100000)[source]#
Bases:
objectOptions for Monte Carlo wave-function sampling.
- timing_collector: MutableMapping[str, float] | None#
- __init__(backend='scipy', n_trajectories=128, seed=None, return_backend_arrays=False, store_states=True, store_trajectories=False, normalize_each_step=True, max_jump_probability=0.1, prefer_sparse_operators=True, prefer_sparse_rate_evaluator=True, use_total_rate_first=True, compress_collinear_jumps=False, jump_compression_tolerance=1e-10, store_density_matrices=True, store_state_snapshots=False, trajectory_chunk_size=None, trajectory_chunk_workers=None, adaptive_trajectory_block_size=None, fidelity_targets=None, timing_collector=None, adaptive_time_step=False, adaptive_safety_factor=0.8, min_step_size=1e-12, max_substeps_per_interval=100000)#
- class qlinks.open_system.MonitorKernelClosureDiagnostics(dim, n_monitors, closure_order, max_target_monitor_residual, target_monitor_residuals, monitor_kernel_dimension, target_projection_onto_monitor_kernel, target_distance_from_monitor_kernel, target_in_monitor_kernel, bad_monitor_kernel_dimension, bad_monitor_kernel_iprs, bad_kernel_hamiltonian_leakage_norms, min_bad_kernel_hamiltonian_leakage_norm, mean_bad_kernel_hamiltonian_leakage_norm, max_bad_kernel_hamiltonian_leakage_norm, closure_kernel_dimension, target_projection_onto_closure_kernel, target_distance_from_closure_kernel, target_in_closure_kernel, bad_closure_kernel_dimension, bad_closure_kernel_iprs)[source]#
Bases:
objectDiagnostics for monitor-kernel closure under Hamiltonian mixing.
The monitor kernel is
intersection_i ker(M_i). For a monitor-recycler designL_i = V_i M_i, this kernel is always contained in the jump kernel and therefore measures what the recyclers cannot see directly.The first Hamiltonian-closure layer appends the constraints
M_i H. If this sharply reduces the bad kernel, attraction is possible but can be slow because the Hamiltonian must rotate bad monitor-kernel states into the monitored subspace before dissipation acts.- __init__(dim, n_monitors, closure_order, max_target_monitor_residual, target_monitor_residuals, monitor_kernel_dimension, target_projection_onto_monitor_kernel, target_distance_from_monitor_kernel, target_in_monitor_kernel, bad_monitor_kernel_dimension, bad_monitor_kernel_iprs, bad_kernel_hamiltonian_leakage_norms, min_bad_kernel_hamiltonian_leakage_norm, mean_bad_kernel_hamiltonian_leakage_norm, max_bad_kernel_hamiltonian_leakage_norm, closure_kernel_dimension, target_projection_onto_closure_kernel, target_distance_from_closure_kernel, target_in_closure_kernel, bad_closure_kernel_dimension, bad_closure_kernel_iprs)#
- class qlinks.open_system.OpenSystemBackend(name, array_module, sparse_module, sparse_linalg_module, supports_expm_multiply)[source]#
Bases:
objectArray/sparse backend bundle for open-system solvers.
- name#
Backend name.
- Type:
Literal[‘scipy’, ‘cupy’]
- array_module#
Dense array module, such as NumPy or CuPy.
- Type:
Any
- sparse_module#
Sparse matrix module.
- Type:
Any
- sparse_linalg_module#
Sparse linear-algebra module, if available.
- Type:
Any | None
- __init__(name, array_module, sparse_module, sparse_linalg_module, supports_expm_multiply)#
- class qlinks.open_system.RecycledManifoldCandidateFamilyKernelReport(manifold_dimension, hilbert_dimension, candidate_report, candidate_report_was_expanded, dark_tolerance, inflow_tolerance, candidate_jumps, diagnostics, candidate_jump_count=None, candidate_total_jump_nnz=None, candidate_max_jump_nnz=None)[source]#
Bases:
objectCommon-kernel diagnostic for an entire recycled-detector family.
This report answers a different question from greedy subset selection: if all eligible local candidates are used as jumps, does the family itself remove the complement common jump kernel? If the bad kernel remains nonzero for the full family, no subset of that candidate family can remove it.
- candidate_report: RecycledManifoldDarkDetectorReport#
- __init__(manifold_dimension, hilbert_dimension, candidate_report, candidate_report_was_expanded, dark_tolerance, inflow_tolerance, candidate_jumps, diagnostics, candidate_jump_count=None, candidate_total_jump_nnz=None, candidate_max_jump_nnz=None)#
- class qlinks.open_system.RecycledManifoldCollectiveRecyclerGroup(group_index, detector_index, detector_name, region_index, variable_indices, local_dim, candidate_indices, recycler_indices, recycler_names, weights, local_operator, jump_frobenius_norm, recycler_frobenius_norm, recycler_nnz, jump_nnz, unbundled_inflow_norm=None, bundled_inflow_norm=None)[source]#
Bases:
objectOne collective local recycler replacing selected microscopic recyclers.
The bundled jump has the form
J = R_bundle DwhereDis the selected dark detector andR_bundleis a local matrix supported on one region. Bundling only within a fixed(detector_index, region_index)preserves the same real-space support as the selected microscopic recyclers while reducing the number of Lindblad channels.- __init__(group_index, detector_index, detector_name, region_index, variable_indices, local_dim, candidate_indices, recycler_indices, recycler_names, weights, local_operator, jump_frobenius_norm, recycler_frobenius_norm, recycler_nnz, jump_nnz, unbundled_inflow_norm=None, bundled_inflow_norm=None)#
- class qlinks.open_system.RecycledManifoldDarkDetectorCandidate(candidate_index, detector_index, detector_name, region_index, variable_indices, local_dim, recycler_index, recycler_name, dark_residual, relative_dark_residual, inflow_norm, jump_frobenius_norm, target_block_norm, detector_action_residual, detector_relative_action_residual, recycler_frobenius_norm, recycler_nnz, jump_nnz)[source]#
Bases:
objectOne candidate jump
J = R Dfor a dark manifold.Dis a collective detector satisfyingD P_M ~= 0.Ris a local recycler/matrix-unit operator embedded on one bounded region. Unlike a standalone RDM recycler,Rdoes not need to annihilate the target manifold because target darkness is supplied by the right detector.- __init__(candidate_index, detector_index, detector_name, region_index, variable_indices, local_dim, recycler_index, recycler_name, dark_residual, relative_dark_residual, inflow_norm, jump_frobenius_norm, target_block_norm, detector_action_residual, detector_relative_action_residual, recycler_frobenius_norm, recycler_nnz, jump_nnz)#
- class qlinks.open_system.RecycledManifoldDarkDetectorReport(manifold_dimension, hilbert_dimension, gram_residual, detector_names, region_variable_indices, local_dims, recycler_source, n_tested_candidates, n_nonzero_candidates, dark_tolerance, inflow_tolerance, candidates)[source]#
Bases:
objectReport for RDM/matrix-unit recycled dark-detector jumps
J = R D.The report is meant as a necessary-condition scan for attractive manifold Lindblad constructions. Candidates with small dark residual and nonzero inflow satisfy
J P_M ~= 0andP_M J (I-P_M) != 0. A selected set of such jumps still needs the full dark-manifold diagnostic to rule out closed complement sectors.- candidates: tuple[RecycledManifoldDarkDetectorCandidate, ...]#
- __init__(manifold_dimension, hilbert_dimension, gram_residual, detector_names, region_variable_indices, local_dims, recycler_source, n_tested_candidates, n_nonzero_candidates, dark_tolerance, inflow_tolerance, candidates)#
- class qlinks.open_system.RecycledManifoldJumpSelectionReport(manifold_dimension, hilbert_dimension, candidate_pool_size, max_selected_jumps, target_bad_kernel_dimension, dark_tolerance, inflow_tolerance, jumps, steps, final_diagnostics, candidate_report, candidate_report_was_expanded=False, candidate_pool_was_limited=False, compression_strategy='none', n_compression_passes=0, n_compressed_jumps_removed=0, collective_recycler_strategy='none', unbundled_n_jumps=None, collective_groups=(), selected_inflow_norm=None, unbundled_inflow_norm=None)[source]#
Bases:
objectGreedy small-subset selection report for recycled dark-detector jumps.
The report owns the selected jump operators. The summary intentionally omits raw sparse matrices, but
report.jumpscan be passed directly toqlinks.open_system.diagnose_dark_manifold()or a Lindblad solver. The stopping criterion uses the common jump kernel in the complement of the target manifold. Reaching zero is a strong sufficient condition that no complement vector is dark under all selected jumps.- steps: tuple[RecycledManifoldJumpSelectionStep, ...]#
- candidate_report: RecycledManifoldDarkDetectorReport#
- collective_groups: tuple[RecycledManifoldCollectiveRecyclerGroup, ...]#
- property selected_candidates: tuple[RecycledManifoldDarkDetectorCandidate, ...]#
- selected_recycler_readouts(*, basis_configs, states=None, max_readouts=None, tolerance=1e-10, rdm_tolerance=1e-10)[source]#
Return local-matrix readouts for selected recycled jump recyclers.
The returned objects can be passed directly to
LocalBasisGridVisualizer.plot_readout. Forrdm_support_matrix_unitsrecyclers, pass the target state/manifold throughstatesso the local RDM support basis can be reconstructed.
- __init__(manifold_dimension, hilbert_dimension, candidate_pool_size, max_selected_jumps, target_bad_kernel_dimension, dark_tolerance, inflow_tolerance, jumps, steps, final_diagnostics, candidate_report, candidate_report_was_expanded=False, candidate_pool_was_limited=False, compression_strategy='none', n_compression_passes=0, n_compressed_jumps_removed=0, collective_recycler_strategy='none', unbundled_n_jumps=None, collective_groups=(), selected_inflow_norm=None, unbundled_inflow_norm=None)#
- class qlinks.open_system.RecycledManifoldJumpSelectionStep(step_index, candidate, bad_common_jump_kernel_dimension, inflow_norm, max_target_jump_residual, n_selected_jumps)[source]#
Bases:
objectOne greedy selection step for recycled dark-detector jumps.
- candidate: RecycledManifoldDarkDetectorCandidate#
- __init__(step_index, candidate, bad_common_jump_kernel_dimension, inflow_norm, max_target_jump_residual, n_selected_jumps)#
- class qlinks.open_system.RecycledManifoldResidualKernelReport(manifold_dimension, hilbert_dimension, family_report, residual_basis, hamiltonian_target_coupling_norm, hamiltonian_residual_block_norm, hamiltonian_outside_residual_norm, hamiltonian_residual_eigenvalues, operator_action_reports, local_support_entries, kernel_tolerance)[source]#
Bases:
objectDiagnostics for the residual complement kernel left by a recycled family.
The report focuses on the bad subspace
B = (cap_mu ker J_mu) cap M^perp,
where
J_muranges over the chosen recycled-detector family. It is meant to distinguish a mere subset-selection failure from a structural residual sector that the current local operator family cannot see.- family_report: RecycledManifoldCandidateFamilyKernelReport#
- operator_action_reports: tuple[ResidualKernelOperatorActionReport, ...]#
- local_support_entries: tuple[ResidualKernelLocalSupportEntry, ...]#
- __init__(manifold_dimension, hilbert_dimension, family_report, residual_basis, hamiltonian_target_coupling_norm, hamiltonian_residual_block_norm, hamiltonian_outside_residual_norm, hamiltonian_residual_eigenvalues, operator_action_reports, local_support_entries, kernel_tolerance)#
- class qlinks.open_system.ResidualKernelLocalSupportEntry(variable_indices, local_dim, target_support_rank, target_nullity, residual_support_rank, residual_nullity, combined_support_rank, combined_nullity, residual_support_outside_target_norm)[source]#
Bases:
objectLocal support comparison between target and residual bad-kernel subspaces.
- __init__(variable_indices, local_dim, target_support_rank, target_nullity, residual_support_rank, residual_nullity, combined_support_rank, combined_nullity, residual_support_outside_target_norm)#
- class qlinks.open_system.ResidualKernelOperatorActionEntry(operator_index, operator_name, action_norm, target_component_norm, residual_component_norm, outside_component_norm)[source]#
Bases:
objectAction of one probe operator on the residual bad-kernel subspace.
- __init__(operator_index, operator_name, action_norm, target_component_norm, residual_component_norm, outside_component_norm)#
- class qlinks.open_system.ResidualKernelOperatorActionReport(group_name, n_operators, entries)[source]#
Bases:
objectProbe-operator action on the residual bad-kernel subspace.
- entries: tuple[ResidualKernelOperatorActionEntry, ...]#
- __init__(group_name, n_operators, entries)#
- class qlinks.open_system.SparseLindbladOperators(backend, sparse_format, hamiltonian, identity, jumps, jump_dagger_jumps)[source]#
Bases:
objectSparse Lindblad operators prepared for Liouville-space construction.
- backend: OpenSystemBackend#
- __init__(backend, sparse_format, hamiltonian, identity, jumps, jump_dagger_jumps)#
- class qlinks.open_system.TargetedResidualKernelJumpSelectionReport(manifold_dimension, hilbert_dimension, residual_dimension, max_selected_jumps, target_residual_kernel_dimension, targeted_report, base_jumps, jumps, steps, final_diagnostics, selection_target, initial_selection_kernel_dimension, target_selection_kernel_dimension, kernel_tolerance, dark_tolerance, inflow_tolerance, selected_inflow_norm=None)[source]#
Bases:
objectGreedy subset of targeted local jumps that removes a residual kernel.
- targeted_report: TargetedResidualKernelLinearSearchReport#
- steps: tuple[TargetedResidualKernelJumpSelectionStep, ...]#
- property selected_candidates: tuple[TargetedResidualKernelLinearCandidate, ...]#
- selected_operator_readouts(*, basis_configs, max_readouts=None)[source]#
Return local-matrix readouts for selected targeted completion operators.
- __init__(manifold_dimension, hilbert_dimension, residual_dimension, max_selected_jumps, target_residual_kernel_dimension, targeted_report, base_jumps, jumps, steps, final_diagnostics, selection_target, initial_selection_kernel_dimension, target_selection_kernel_dimension, kernel_tolerance, dark_tolerance, inflow_tolerance, selected_inflow_norm=None)#
- class qlinks.open_system.TargetedResidualKernelJumpSelectionStep(step_index, candidate, residual_kernel_dimension, n_selected_jumps)[source]#
Bases:
objectOne greedy step selecting a targeted residual-kernel jump.
- candidate: TargetedResidualKernelLinearCandidate#
- __init__(step_index, candidate, residual_kernel_dimension, n_selected_jumps)#
- class qlinks.open_system.TargetedResidualKernelLinearCandidate(candidate_index, region_index, variable_indices, local_dim, operator_source, dark_constraint_rank, dark_nullity, singular_value, residual_target_inflow_norm, dark_residual, relative_dark_residual, total_inflow_norm, target_block_norm, jump_frobenius_norm, jump_nnz, coefficients, terms, residual_action_norm=0.0, residual_score_norm=0.0, residual_objective='target_inflow')[source]#
Bases:
objectA local jump candidate found by constrained residual-kernel search.
- terms: tuple[TargetedResidualKernelLinearTerm, ...]#
- __init__(candidate_index, region_index, variable_indices, local_dim, operator_source, dark_constraint_rank, dark_nullity, singular_value, residual_target_inflow_norm, dark_residual, relative_dark_residual, total_inflow_norm, target_block_norm, jump_frobenius_norm, jump_nnz, coefficients, terms, residual_action_norm=0.0, residual_score_norm=0.0, residual_objective='target_inflow')#
- class qlinks.open_system.TargetedResidualKernelLinearSearchReport(manifold_dimension, hilbert_dimension, residual_basis, region_variable_indices, operator_source, family_report, candidates, candidate_jumps, tolerance, dark_tolerance, inflow_tolerance, residual_objective='target_inflow', n_regions_evaluated=0, n_regions_skipped_by_local_dim=0, n_regions_with_no_recycler_specs=0, n_regions_with_no_nonzero_local_operators=0, n_regions_with_zero_dark_nullity=0, n_regions_with_dark_nullity_detected=-1, n_regions_with_zero_residual_inflow=0, n_candidate_modes_generated=-1, max_encountered_local_dim=0)[source]#
Bases:
objectConstrained local search targeting a recycled-family residual kernel.
For each local region with operator basis
O_a, the search solvessum_a c_a O_a P_M = 0
and, inside that dark nullspace, maximizes either
||P_M (sum_a c_a O_a) B||_F
or
||(sum_a c_a O_a) B||_F,
where
Bis the residual bad common-kernel basis left by a recycled detector family. The first objective emphasizes direct inflow to the target manifold; the second directly attacks a remaining dark kernel sector even when it does not couple to the target in one jump.- family_report: RecycledManifoldCandidateFamilyKernelReport | None#
- candidates: tuple[TargetedResidualKernelLinearCandidate, ...]#
- residual_kernel_dimension_after_candidate_prefix(n_candidates=None, *, tolerance=None)[source]#
Return residual-kernel dimension after the first reported jumps.
- property reported_candidate_residual_kernel_dimension: int#
Residual-family kernel dimension after all reported targeted candidates.
This is the dimension of the residual bad kernel supplied to this targeted search after applying the reported candidate jumps. In the end-to-end workflow this is the residual left by the full recycled detector family, not necessarily the bad common kernel left by a compact selected recycled subset.
- property reported_candidate_family_residual_kernel_dimension: int#
Alias with explicit workflow terminology.
- property reported_candidates_remove_family_residual_kernel: bool#
Whether reported candidates remove the full-family residual kernel.
- candidate_readouts(*, basis_configs, max_readouts=None)[source]#
Return local-matrix readouts for reported targeted candidates.
- __init__(manifold_dimension, hilbert_dimension, residual_basis, region_variable_indices, operator_source, family_report, candidates, candidate_jumps, tolerance, dark_tolerance, inflow_tolerance, residual_objective='target_inflow', n_regions_evaluated=0, n_regions_skipped_by_local_dim=0, n_regions_with_no_recycler_specs=0, n_regions_with_no_nonzero_local_operators=0, n_regions_with_zero_dark_nullity=0, n_regions_with_dark_nullity_detected=-1, n_regions_with_zero_residual_inflow=0, n_candidate_modes_generated=-1, max_encountered_local_dim=0)#
- class qlinks.open_system.TargetedResidualKernelLinearTerm(operator_index, operator_name, coefficient, weight)[source]#
Bases:
objectOne local matrix-unit term in a targeted residual-kernel jump.
- __init__(operator_index, operator_name, coefficient, weight)#
- class qlinks.open_system.TrajectoryResult(times, states, jump_times, jump_indices, norm_errors)[source]#
Bases:
objectSingle Monte Carlo wave-function trajectory.
- __init__(times, states, jump_times, jump_indices, norm_errors)#
- class qlinks.open_system.TwoPatternRecyclingStructure(variable_indices, pattern_a, pattern_b, alpha_index, beta_index, phase, residual, matrix_unit_terms)[source]#
Bases:
objectDetected local two-pattern recycling structure.
This represents a local jump of the form |minus><plus|, up to phase and convention.
- matrix_unit_terms: tuple[LocalMatrixUnitTerm, ...]#
- __init__(variable_indices, pattern_a, pattern_b, alpha_index, beta_index, phase, residual, matrix_unit_terms)#
- qlinks.open_system.analyze_lindblad_evolution(density_matrices=None, *, ensemble_result=None, state_snapshots=None, trajectories=None, times=None, target_state=None, hamiltonian=None, jumps=None, atol=1e-10, backend='scipy', density_check_mode='auto')[source]#
Analyze diagnostics along Lindblad or MCWF evolution output.
The function accepts dense density matrices directly, but it can also read MCWF ensemble outputs. When an ensemble stores low-rank state snapshots but not
rho_t, diagnostics can be computed without materializing dense density matrices unlessdensity_check_mode="full"is requested.- Parameters:
density_matrices (Sequence[Any] | None) – Optional sequence of density matrices.
ensemble_result (Any | None) – Optional MCWF ensemble result. The analyzer prefers populated
rho_t, thenstate_snapshots, then stored trajectories.state_snapshots (Sequence[Any] | None) – Optional sequence of matrices with shape
(dim, n_trajectories).trajectories (Sequence[Any] | None) – Optional trajectory results with stored states.
times (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional time grid.
target_state (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional pure state for fidelity diagnostics.
hamiltonian – Optional Hamiltonian for Lindblad residual diagnostics.
jumps – Optional jump operators for Lindblad residual diagnostics.
atol (float) – Numerical tolerance for density-matrix checks.
backend (Literal['scipy', 'cupy'] | ~qlinks.open_system.backend.OpenSystemBackend) – Open-system backend name or object.
density_check_mode (str) –
"auto","full", or"low_rank"."low_rank"avoids materializing density matrices from MCWF snapshots and reportsNaNfor minimum eigenvalues.
- Returns:
Evolution diagnostics arrays.
- Return type:
- qlinks.open_system.as_backend_dense_array(matrix, *, backend, dtype=<class 'numpy.complex128'>)[source]#
Convert a dense or sparse matrix to a backend dense array.
- Parameters:
matrix (Any) – Input matrix in dense, SciPy sparse, or backend sparse form.
backend (OpenSystemBackend) – Target backend.
dtype – Complex dtype for the converted array.
- Returns:
Dense array on the requested backend.
- qlinks.open_system.as_backend_sparse_matrix(matrix, *, backend, format='csr', dtype=<class 'numpy.complex128'>)[source]#
Convert a dense or sparse matrix to a backend sparse matrix.
- Parameters:
matrix (Any) – Input matrix in dense, SciPy sparse, or backend sparse form.
backend (OpenSystemBackend) – Target backend.
format (str) – Sparse format requested from the backend.
dtype – Complex dtype for the converted matrix.
- Returns:
Sparse matrix on the requested backend.
- qlinks.open_system.bad_h_invariant_common_kernel_basis(*, hamiltonian, jumps, target_states, kernel_tolerance=1e-10)[source]#
Return the bad H-invariant sector inside the common jump kernel.
The returned columns form an orthonormal basis for the largest subspace of
(cap_mu ker J_mu) cap M^perpwhose Hamiltonian orbit stays inside the common jump kernel. An empty(dim, 0)array means the selected jumps have no Hamiltonian-stable dark obstruction outside the target manifold.This helper exposes the obstruction basis used internally by
diagnose_common_kernel_h_invariant_sector(), so jump-design routines can add a targeted completion stage without recomputing or interpreting a Liouvillian spectrum.
- qlinks.open_system.build_cage_lindblad_detector_operators(*, model, build_result, term_kind='plaquette', operator_kind='potential', builder='sparse', backend='scipy', on_missing='skip', name_prefix=None)[source]#
Build a named local detector-operator family from model local terms.
operator_kind='hamiltonian'includes both kinetic and potential terms when the model exposes them. The returned bundle can be passed directly toCageLindbladDesignProblem.design_jumps().
- qlinks.open_system.build_cage_lindblad_problem(*, build_result, target_state=None, target_states=None, states=None, records=None, model=None, local_regions=None, regional_units=None, local_term_kind=None, region_source='kinetic', validate_record_signature=True, open_system_backend='scipy', residual_tolerance=1e-10, target_tolerance=1e-10)[source]#
Create a unified cage Lindblad design problem.
A single cage state is supplied with
target_state. A degenerate cage manifold is supplied withtarget_states/statesorrecords. The returned object uses the samedesign_jumpsmethod in both cases.
- qlinks.open_system.build_liouvillian(hamiltonian, jumps, *, backend='scipy', sparse_format='csc', dtype=<class 'numpy.complex128'>)[source]#
Build the sparse Liouvillian superoperator.
The Liouvillian acts on density matrices vectorized with
vectorize_density_matrix().- Parameters:
hamiltonian (Any) – Hamiltonian matrix.
jumps (list[Any] | tuple[Any, ...]) – Lindblad jump operators.
backend (Literal['scipy', 'cupy'] | ~qlinks.open_system.backend.OpenSystemBackend) – Open-system backend name or object.
sparse_format (str) – Sparse format for the returned superoperator.
dtype – Complex dtype used during conversion.
- Returns:
Sparse Liouvillian matrix with shape
(dim * dim, dim * dim).
- qlinks.open_system.build_liouvillian_from_prepared(sparse_operators)[source]#
Build the Liouvillian from preconverted sparse Lindblad operators.
- qlinks.open_system.build_local_recycling_jumps_from_regions(*, basis_configs, target_state, regions, source='local_rdm_two_pattern', deduplicate_regions=False, max_jumps_per_region=1, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, max_candidates_per_region=None, prefer_sparse=True, two_pattern_tolerance=1e-08)[source]#
Scan several regions and return selected local recycling jumps.
Set
deduplicate_regions=Truewhen repeated monitor components share the same local support and should use one recycler family rather than one copy per component. The default keeps the historical behavior.
- qlinks.open_system.build_local_recycling_jumps_from_subspace_regions(*, basis_configs, states, regions, source='local_rdm_block_reset', deduplicate_regions=False, max_jumps_per_region=1, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, max_candidates_per_region=None, prefer_sparse=True, two_pattern_tolerance=1e-08)[source]#
Scan local recycling jumps that annihilate a target state subspace.
- qlinks.open_system.density_matrix_from_state(state, *, normalize=True)[source]#
Return the pure density matrix associated with a state vector.
- Parameters:
- Returns:
Complex density matrix
|psi><psi|.- Return type:
- qlinks.open_system.density_matrix_from_state_matrix(states)[source]#
Return the ensemble density matrix represented by state columns.
states[:, trajectory_index]is one normalized MCWF trajectory state. The returned matrix is the average projector over columns.
- qlinks.open_system.detect_two_pattern_recycling_structure(*, candidate, local_patterns, tolerance=1e-08)[source]#
Detect whether a candidate is a two-pattern |minus><plus| jump.
- qlinks.open_system.diagnose_absorbing_projector_symmetry(*, hamiltonian, jumps, target_state, backend='scipy', tolerance=1e-10)[source]#
Diagnose whether P_psi is an absorbing-state projector symmetry.
The target projector is
P_psi = |psi><psi|.
The relevant obstruction to attraction is:
J_mu |psi> = 0 and P_psi J_mu (I - P_psi) = 0
for all jumps. Then the target is dark, but there is no jump-induced inflow from psi_perp into psi. Equivalently, P_psi is conserved by the Heisenberg-picture Lindbladian.
- qlinks.open_system.diagnose_common_kernel_h_invariant_sector(*, hamiltonian, jumps, target_states, kernel_tolerance=1e-10)[source]#
Diagnose Hamiltonian-stable obstructions inside the common jump kernel.
This is a cheap alternative to a Liouvillian spectrum check. It first computes the common jump kernel
K = cap_mu ker J_muand the bad complementB = K cap M^perp. It then computes the largest subspace ofBwhose Hamiltonian Krylov orbit stays insideK. Only this H-invariant part is a purely dark Hamiltonian-stable complement sector.
- qlinks.open_system.diagnose_dark_manifold(*, hamiltonian, jumps, target_states, backend='scipy', kernel_tolerance=1e-10, liouvillian_zero_tolerance=1e-09, check_liouvillian_spectrum=True, max_liouvillian_dense_dimension=4096, liouvillian_spectrum_method='auto', sparse_liouvillian_eigenvalue_count=32)[source]#
Diagnose whether a target manifold is an attractive dark manifold.
The columns of
target_statesspan the target manifold. They need not be orthonormal; this function orthonormalizes them and uses the target projectorP_M. The diagnostic accepts the internal non-decaying Liouvillian modes generated by the projected HamiltonianM† H Mand reports additional zero/peripheral modes as possible complement obstructions.
- qlinks.open_system.diagnose_dark_subspace(*, hamiltonian, jumps, target_state, backend='scipy', kernel_tolerance=1e-10, liouvillian_zero_tolerance=1e-09, check_liouvillian_spectrum=True, max_liouvillian_dense_dimension=4096, liouvillian_spectrum_method='auto', sparse_liouvillian_eigenvalue_count=16)[source]#
Diagnose whether a dark target is likely unique/attractive.
This is intended for small systems. It computes:
target jump residuals ||J_mu psi||;
common jump kernel dim intersection_mu ker J_mu;
bad common-kernel dimension after removing the target direction;
target Liouvillian residual ||L(|psi><psi|)||;
optional Liouvillian zero-mode count.
The Liouvillian spectrum check uses a dense solver for small Liouvillians and a sparse shift-invert Arnoldi solver for larger ones when
liouvillian_spectrum_method="auto". The sparse zero-mode count is a lower bound if all requested eigenvalues are numerically zero; increasesparse_liouvillian_eigenvalue_countto resolve more zero modes.
- qlinks.open_system.diagnose_dressed_manifold_dark_detectors(*, states, detector_operators, left_multipliers, detector_coefficients=None, dark_operator_report=None, detector_operator_names=None, left_multiplier_names=None, detector_names=None, tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, max_detectors=None, sort_by_inflow=True)[source]#
Test paper-style dressed jumps
J = V Dfor a dark manifold.- Parameters:
states (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Target manifold basis. Columns are orthonormalized.
detector_operators (tuple[Any, ...] | list[Any]) – Operator basis
O_aused to assembleD=sum_a c_a O_a.left_multipliers (tuple[Any, ...] | list[Any]) – Candidate left multipliers
V_beta.detector_coefficients (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional coefficient matrix for the detectors. If omitted, coefficients are taken from
dark_operator_report.dark_operator_report (ManifoldDarkOperatorBasisReport | None) – Optional report from
diagnose_manifold_dark_operator_basis().detector_operator_names (tuple[str, ...] | list[str] | None) – Names for
detector_operators. Only used to build default detector names.left_multiplier_names (tuple[str, ...] | list[str] | None) – Names for the left multipliers.
detector_names (tuple[str, ...] | list[str] | None) – Optional explicit detector names.
tolerance (float) – Orthonormalization and shape-check tolerance.
dark_tolerance (float) – Relative dark residual threshold.
inflow_tolerance (float) – Direct-inflow threshold.
max_detectors (int | None) – Optional maximum number of detectors to test.
sort_by_inflow (bool) – If true, store candidates with largest inflow first.
- Returns:
A report of dressed candidates. A candidate with small dark residual and positive inflow satisfies the necessary direct-inflow condition for manifold attraction, but does not by itself rule out invariant sectors in the complement.
- Return type:
- qlinks.open_system.diagnose_jump_span(jumps, *, rank_tolerance=1e-10)[source]#
Diagnose exact/near linear dependencies among jump operators.
The jump-operator span is measured in the Hilbert-Schmidt inner product,
<J_i, J_j> = Tr(J_i† J_j). The rank of this Gram matrix is the number of independent jump directions. If this rank is much smaller than the raw number of jumps, a future compression pass can rotate/drop jumps before MCWF sampling without changing the Lindblad dissipator.
- qlinks.open_system.diagnose_manifold_dark_operator_basis(*, states, operators, operator_names=None, tolerance=1e-10, coefficient_tolerance=1e-08, max_candidates=16, candidate_strategy='svd_basis', candidate_overlap_tolerance=1e-07)[source]#
Find linear combinations of supplied operators annihilating a manifold.
- Parameters:
states (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Target manifold basis with shape
(dim, n_states)or rows as states. The columns are orthonormalized before the nullspace solve.operators (tuple[Any, ...] | list[Any]) – Operator basis matrices with the same Hilbert dimension.
operator_names (tuple[str, ...] | list[str] | None) – Optional names for the operators.
tolerance (float) – Absolute/relative SVD tolerance used for the dark-detector nullspace.
coefficient_tolerance (float) – Coefficient magnitude threshold for term readout.
max_candidates (int | None) – Maximum number of nullspace candidates to store. Use
Noneto keep all candidates.candidate_strategy (Literal['svd_basis', 'coordinate_ipr']) –
"svd_basis"keeps the numerical nullspace basis."coordinate_ipr"projects individual supplied operators onto the dark nullspace and ranks the results by coefficient IPR, producing more localized/interpretable detector combinations when the dark solution space is degenerate.candidate_overlap_tolerance (float) – Deduplication tolerance for
candidate_strategy="coordinate_ipr".
- Returns:
A report whose candidate coefficient columns define
D=sum_a c_a O_awithD P_M ~= 0.- Return type:
- qlinks.open_system.diagnose_monitor_kernel_closure(*, hamiltonian, monitors, target_state, closure_order=1, tolerance=1e-10)[source]#
Diagnose whether local monitors are closed by Hamiltonian mixing.
This is designed for monitor-recycler jumps
L_i = V_i M_i. Recyclers cannot act on states inintersection_i ker(M_i), so the size of this kernel and its leakage underHare the first diagnostics to inspect.Currently
closure_ordersupports0or1. Order 1 appends the constraintsM_i Hand computes the common kernel of{M_i, M_i H}.
- qlinks.open_system.diagnose_recycled_manifold_candidate_family_kernel(*, hamiltonian, states, basis_configs, detector_operators, local_regions, detector_coefficients=None, dark_operator_report=None, candidate_report=None, detector_operator_names=None, detector_names=None, recycler_source='rdm_support_matrix_units', tolerance=1e-10, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, kernel_tolerance=1e-10, liouvillian_zero_tolerance=1e-09, max_detectors=None, expand_candidate_report=True, kernel_method='streamed', store_candidate_jumps=False)[source]#
Diagnose the common jump kernel of the full recycled-detector family.
This is the decisive follow-up when greedy selection saturates at a nonzero complement kernel. If the family of all eligible local candidates still has a bad common jump kernel, no subset selected from that family can remove it. If the family removes the kernel but the greedy subset does not, the problem is the subset-selection heuristic rather than the operator family.
- qlinks.open_system.diagnose_recycled_manifold_dark_detectors(*, states, basis_configs, detector_operators, local_regions, detector_coefficients=None, dark_operator_report=None, detector_operator_names=None, detector_names=None, recycler_source='rdm_support_matrix_units', tolerance=1e-10, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, max_detectors=None, max_report_candidates=256, sort_by_inflow=True)[source]#
Test local RDM/matrix-unit recyclers after dark detectors.
This scans jumps of the form
J = R D. The right detectorDis a collective operator satisfyingD P_M ~= 0. The left operatorRis a local recycler on one bounded region. Since target darkness comes fromD, the recycler can be a general local matrix unit and need not be dark on the target manifold by itself.- Parameters:
states (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Target manifold basis; columns are orthonormalized.
basis_configs (ndarray[tuple[Any, ...], dtype[integer]]) – Constrained/product basis configurations aligned with the Hilbert-space basis used by
detector_operators.detector_operators (tuple[Any, ...] | list[Any]) – Operator basis used to assemble the detectors.
local_regions (tuple[tuple[int, ...], ...] | list[tuple[int, ...]] | list[list[int]]) – Variable-index regions where local recyclers are embedded.
detector_coefficients (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional coefficient matrix defining detectors. If omitted, coefficients are read from
dark_operator_report.dark_operator_report (ManifoldDarkOperatorBasisReport | None) – Report from
diagnose_manifold_dark_operator_basis().detector_operator_names (tuple[str, ...] | list[str] | None) – Names for the detector operator basis.
detector_names (tuple[str, ...] | list[str] | None) – Optional explicit detector names.
recycler_source (Literal['matrix_units', 'rdm_support_matrix_units']) –
"matrix_units"scans canonical local matrix units;"rdm_support_matrix_units"maps canonical source patterns into the local support eigenvectors of the target manifold RDM.tolerance (float) – Orthonormalization and shape-check tolerance.
rdm_tolerance (float) – Local RDM support threshold.
dark_tolerance (float) – Relative dark residual threshold for
J P_M.inflow_tolerance (float) – Threshold for
||P_M J (I-P_M)||_F.max_detectors (int | None) – Optional maximum detector columns to scan.
max_report_candidates (int | None) – Optional maximum number of best candidates to retain in the report. All candidates are still counted in
n_tested_candidates.sort_by_inflow (bool) – If true, report candidates with largest inflow first.
- Returns:
A report of local-recycler dressed candidates. Nonzero inflow is a necessary, not sufficient, condition for attractive dark-manifold dynamics.
- Return type:
- qlinks.open_system.diagnose_recycled_manifold_residual_kernel(*, hamiltonian, states, basis_configs, detector_operators, local_regions, detector_coefficients=None, dark_operator_report=None, candidate_report=None, family_report=None, detector_operator_names=None, detector_names=None, recycler_source='rdm_support_matrix_units', operator_groups=None, local_support_regions=None, tolerance=1e-10, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, kernel_tolerance=1e-10, liouvillian_zero_tolerance=1e-09, max_detectors=None, expand_candidate_report=True, max_operator_entries=64)[source]#
Diagnose the residual bad kernel left by a recycled-detector family.
This function first computes the full-family common jump kernel for the specified recycled-detector candidates. It then extracts the bad complement subspace and reports whether the Hamiltonian and optional probe-operator groups couple that subspace to the target manifold, leave it invariant, or push it outside the target-plus-residual sector.
- qlinks.open_system.diagnose_targeted_residual_kernel_linear_search(*, states, basis_configs, local_regions, residual_basis=None, residual_report=None, detector_operators=None, residual_family_local_regions=None, detector_coefficients=None, dark_operator_report=None, candidate_report=None, family_report=None, detector_operator_names=None, detector_names=None, recycler_source='rdm_support_matrix_units', operator_source='matrix_units', residual_objective='target_inflow', tolerance=1e-10, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, kernel_tolerance=1e-10, max_detectors=None, max_modes_per_region=1, max_report_candidates=32, max_local_dim=None, coefficient_tolerance=1e-08)[source]#
Search local dark jumps that directly target a residual bad kernel.
This is stronger than optimizing linear combinations of the factorized recycled-detector family
R D. For each supplied local region, it builds a local operator basisO_aand solves the constrained problemsum_a c_a O_a P_M = 0,
then ranks dark combinations by their action
||P_M (sum_a c_a O_a) B||_F,
where
Bis the residual complement common kernel left by a recycled detector family.
- qlinks.open_system.effective_hamiltonian(hamiltonian, jumps)[source]#
Return H_eff = H - i/2 sum_mu J_mu^dagger J_mu.
- qlinks.open_system.embed_local_pattern_operator(*, basis_configs, variable_indices, local_patterns, local_operator)[source]#
Embed a local operator into the constrained full basis.
- qlinks.open_system.estimate_lindblad_scale(*, hamiltonian, jumps, backend='scipy')[source]#
Cheap stiffness scale for RK4 step-size sanity checks.
- qlinks.open_system.estimate_lindblad_scale_prepared(dense_operators)[source]#
Cheap stiffness scale from preconverted dense operators.
- qlinks.open_system.expand_local_regions_to_cluster_unions(local_regions, *, cluster_size=3, cluster_mode='overlap_connected', min_overlap=1, max_region_size=None, include_single_regions=False, include_smaller_clusters=False)[source]#
Return bounded unions of multiple local regions.
This generalizes
expand_local_regions_to_pair_unions()to one or more regional units.cluster_size=1returns the normalized base regions themselves, which is useful when each base region is already a model-natural non-onsite unit such as a plaquette, rhombus, hexagon, or bond.cluster_mode="overlap_connected"keeps larger clusters that are connected in the overlap graph of the base regions; this is the natural setting for connected multi-plaquette QDM patches.The normalized expansion is cached and the connected mode grows clusters on the overlap graph directly. This makes repeated
local_region_mode="regional_unit_clusters"calls much cheaper in notebook sweeps, especially when trying several detector/recycler settings with the same model-natural plaquette or bond units.
- qlinks.open_system.expand_local_regions_to_pair_unions(local_regions, *, pair_mode='overlap', min_overlap=1, max_region_size=None, include_single_regions=False)[source]#
Return unions of pairs of local regions, useful for two-block recyclers.
The single-plaquette recycled-detector family can leave residual bad kernel sectors when the target manifold is built from two-plaquette singlet-like structures. This helper creates bounded two-region supports that can be supplied to
diagnose_recycled_manifold_dark_detectorsordiagnose_recycled_manifold_candidate_family_kernelaslocal_regions.- Parameters:
local_regions (tuple[tuple[int, ...], ...] | list[tuple[int, ...]] | list[list[int]]) – Base local regions, usually plaquette supports.
pair_mode (Literal['overlap', 'all']) –
"overlap"keeps only pairs sharing at leastmin_overlapvariables;"all"keeps all unordered pairs.min_overlap (int) – Minimum number of shared variables when
pair_mode="overlap".max_region_size (int | None) – Optional upper bound on the size of the union.
include_single_regions (bool) – Whether to prepend the original regions.
- Returns:
Deduplicated sorted variable-index unions.
- Return type:
- qlinks.open_system.export_cage_lindblad_design(design, *, path, include_basis=True, include_global_matrices=False, include_detector_matrices=False, include_readouts=True, include_certificates=True, matrix_element_tolerance=0.0, overwrite=False)[source]#
Export a cage-Lindblad design as a versioned JSON/JSONL bundle.
The default export is intended for papers and arXiv data: it stores detectors as coefficient combinations, recycled jumps as
R Drecords, targeted jumps as local dark-operator records, and certificates/summary metadata as JSON. Full sparse matrices can be included withinclude_global_matrices=Trueand detector matrices withinclude_detector_matrices=True.
- qlinks.open_system.get_open_system_backend(backend)[source]#
Resolve an open-system backend name or backend object.
- Parameters:
backend (Literal['scipy', 'cupy'] | ~qlinks.open_system.backend.OpenSystemBackend) –
"scipy","cupy", or an existing backend object.- Returns:
Backend object used by open-system operators and solvers.
- Raises:
ImportError – If
backend="cupy"is requested but CuPy is not installed.ValueError – If the backend name is unknown.
- Return type:
- qlinks.open_system.initial_density_matrix(dim, *, kind='mixed', rank=None, rng=None)[source]#
Create a convenient initial density matrix.
- qlinks.open_system.jump_activity(density_matrix, jumps)[source]#
Return total Lindblad jump activity
sum_mu Tr(J_mu^dag J_mu rho).
- qlinks.open_system.jump_activity_series(*, jumps, density_matrices=None, evolution_result=None, ensemble_result=None, state_snapshots=None)[source]#
Return total jump activity for each time point.
For density matrices this evaluates
sum_mu Tr(J_mu^dagger J_mu rho(t)). For MCWF state snapshots it returns the trajectory average ofsum_mu ||J_mu |psi(t)>||^2.
- qlinks.open_system.jump_probabilities(state, jumps, step_size, *, backend)[source]#
Return first-order jump probabilities dt <psi|J^dagger J|psi>.
- qlinks.open_system.lindblad_rhs_density_matrix(density_matrix, *, hamiltonian, jumps, backend='scipy')[source]#
Evaluate the Lindblad master-equation right-hand side.
Computes
d rho / dt = -i[H, rho] + sum_j D[J_j](rho)using dense backend arrays. For repeated calls, useprepare_dense_lindblad_operators()andlindblad_rhs_density_matrix_prepared().- Parameters:
- Returns:
Density-matrix derivative on the requested backend.
- qlinks.open_system.lindblad_rhs_density_matrix_prepared(density_matrix, *, dense_operators)[source]#
Evaluate the dense Lindblad RHS using preconverted operators.
- qlinks.open_system.lindblad_rhs_density_matrix_sparse_prepared(density_matrix, *, sparse_operators)[source]#
Evaluate the Lindblad RHS using sparse operators on a dense rho.
This is the matrix-free Liouville action in density-matrix form. It avoids constructing the dim^2 x dim^2 Liouvillian and also avoids densifying sparse Hamiltonian/jump operators. It is useful for intermediate dimensions where the explicit Liouvillian is too large but the density matrix itself still fits in memory.
- qlinks.open_system.local_operator_matrix_unit_expansion(*, local_patterns, local_operator, tolerance=1e-10)[source]#
Expand a local operator into matrix-unit terms.
- qlinks.open_system.local_rank_one_matrix_unit_expansion(*, local_patterns, alpha, beta, tolerance=1e-10)[source]#
Expand
|alpha><beta|into local matrix units|a><b|.
- qlinks.open_system.local_reduced_density_matrix_from_state(*, basis_configs, state, variable_indices, tolerance=1e-10)[source]#
Compute the local RDM of a state represented in a constrained basis.
- qlinks.open_system.local_reduced_density_matrix_from_state_matrix(*, basis_configs, states, variable_indices, tolerance=1e-10)[source]#
Compute the local RDM of the normalized projector onto a state subspace.
statesmay have shape(dim, n_states)or(n_states, dim). The columns are orthonormalized before tracing out the environment, so callers may pass linearly dependent representatives without changing local support.
- qlinks.open_system.local_subspace_support_report_for_subspace(*, basis_configs, states, regions, source='local_rdm_block_reset', deduplicate_regions=False, max_jumps_per_region=1, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, max_candidates_per_region=None, prefer_sparse=True, two_pattern_tolerance=1e-08)[source]#
Build only the local manifold-support report for candidate regions.
- qlinks.open_system.local_subspace_support_report_from_recycling_build_result(build_result)[source]#
Summarize local RDM support/nullity and selected recyclers by region.
- qlinks.open_system.normalize_state(state, *, atol=0.0)[source]#
Return a normalized complex state vector.
- qlinks.open_system.observable_vs_time(rho_t, observable)[source]#
Return Tr[rho(t) observable] for each density matrix.
- qlinks.open_system.prepare_dense_lindblad_operators(*, hamiltonian, jumps, backend='scipy', dtype=<class 'numpy.complex128'>)[source]#
Convert Lindblad operators once for repeated dense RHS calls.
- qlinks.open_system.prepare_sparse_lindblad_operators(*, hamiltonian, jumps, backend='scipy', sparse_format='csc', dtype=<class 'numpy.complex128'>)[source]#
Convert sparse Lindblad operators once for Liouville-space construction.
- qlinks.open_system.projector(state)[source]#
Return |state><state|.
- qlinks.open_system.pure_density_matrix(state, *, normalize=True)[source]#
Return |psi><psi|.
- qlinks.open_system.random_density_matrix(dim, *, kind='mixed', rank=None, rng=None)[source]#
Draw a random pure or mixed density matrix.
- Parameters:
- Returns:
Density matrix with trace one.
- Raises:
ValueError – If
kindis unsupported orrankis incompatible.- Return type:
- qlinks.open_system.random_mixed_density_matrix(dim, *, rank=None, rng=None)[source]#
Draw a random mixed density matrix using a Ginibre ensemble.
The state is generated as
rho = X X^\dagger / Tr(X X^\dagger)whereXhas shape(dim, rank).- Parameters:
- Returns:
Hermitian, positive-semidefinite density matrix with trace one.
- Return type:
- qlinks.open_system.random_pure_density_matrix(dim, *, rng=None)[source]#
Draw a random pure density matrix |psi><psi|.
- qlinks.open_system.random_pure_state(dim, *, rng=None)[source]#
Draw a Haar-like random complex state vector.
- qlinks.open_system.run_quantum_jump_trajectory(*, hamiltonian, jumps, state_initial, times, rng=None, backend='scipy', return_backend_arrays=False, store_states=True, normalize_each_step=True, max_jump_probability=0.1, prefer_sparse_operators=True, prefer_sparse_rate_evaluator=True, use_total_rate_first=True, adaptive_time_step=False, adaptive_safety_factor=0.8, min_step_size=1e-12, max_substeps_per_interval=100000)[source]#
Run one Monte Carlo wave-function trajectory.
This uses a first-order no-jump propagator. It is therefore deliberately conservative: if the total jump probability in one time step is too large, it raises an error and asks the caller to refine the time grid.
- qlinks.open_system.sample_lindblad_mcwf(*, hamiltonian, jumps, times, state_initial=None, state_sampler=None, options=None, rng=None)[source]#
Estimate Lindblad evolution with Monte Carlo wavefunction trajectories.
- Parameters:
hamiltonian (Any) – Hamiltonian matrix.
jumps (list[Any] | tuple[Any, ...]) – Lindblad jump operators.
times (ndarray[tuple[Any, ...], dtype[float64]]) – Strictly increasing time grid.
state_initial (Any | None) – Fixed initial pure state used for every trajectory. Mutually exclusive with
state_sampler.state_sampler (Callable[[Generator], Any] | None) – Optional callable that samples an initial pure state from a NumPy random generator.
options (McwfOptions | None) – MCWF sampling and storage options.
rng (Generator | int | None) – Optional RNG or seed. Overrides
options.seedwhen supplied.
- Returns:
Ensemble result containing averaged density matrices when requested, optional low-rank state snapshots, and optional stored trajectories.
- Return type:
- qlinks.open_system.scan_local_recycling_candidates(*, basis_configs, target_state, variable_indices, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-10, max_candidates=None)[source]#
Scan local rank-one recycling jumps from rho_Omega.
- qlinks.open_system.scan_local_recycling_candidates_for_subspace(*, basis_configs, states, variable_indices, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-10, max_candidates=None)[source]#
Scan local rank-one recycling jumps from a target subspace RDM.
- qlinks.open_system.score_recycling_jump(*, jump, target_state)[source]#
Return target residual, inflow, outflow, and projector commutator.
The diagnostics are Frobenius norms of the corresponding projected operators. They can be evaluated from
J|psi>andJ^dagger|psi>without materializing the dense projectors|psi><psi|andI-|psi><psi|.
- qlinks.open_system.score_recycling_jump_for_subspace(*, jump, states, tolerance=1e-10)[source]#
Return residual/inflow/outflow diagnostics for a target subspace.
The target subspace is represented by an orthonormal basis
Q. The returned values are Frobenius norms ofJ QandJ^† Q; whenJ Q=0the second norm equals the direct inflow blockQ_perp J^† Q.
- qlinks.open_system.select_local_recycling_candidates(*, scan_result, source='local_rdm_two_pattern', max_candidates=1, prefer_sparse=True, two_pattern_tolerance=1e-08)[source]#
Select recycling candidates from one scan result.
local_rdm_rank_oneandlocal_rdm_two_patternkeep the historical behavior: they choose the best few rank-one reset maps|alpha><beta|.local_rdm_null_basisis designed for monitor-recycler jumpsL=V P. A single rank-one recycler can makeV Pmuch more singular than the monitorPitself, because it only tests one localbetadirection. This source instead selects one good target-support vectoralphafor every local-RDM null vectorbeta.local_rdm_block_resetis the compressed version: it groups up torank(rho_R)null vectors into each reset channel. Themax_candidatesargument is intentionally ignored for both null-basis and block-reset sources, because their counts are determined by the local RDM ranks.
- qlinks.open_system.select_recycled_manifold_dark_detector_jumps(*, hamiltonian, states, basis_configs, detector_operators, local_regions, detector_coefficients=None, dark_operator_report=None, candidate_report=None, detector_operator_names=None, detector_names=None, recycler_source='rdm_support_matrix_units', tolerance=1e-10, rdm_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, kernel_tolerance=1e-10, liouvillian_zero_tolerance=1e-09, max_detectors=None, max_candidate_pool=128, max_selected_jumps=16, target_bad_kernel_dimension=0, allow_non_improving=False, expand_candidate_report=False, selection_strategy='diagnostics', compression_strategy='none', max_compression_passes=1, collective_recycler_strategy='none', collective_recycler_weighting='unit', normalize_collective_recyclers=True, check_final_diagnostics=None)[source]#
Greedily select a small recycled-detector jump subset.
The candidate family is
J=R D:Dis a collective detector dark on the target manifold, andRis a local matrix-unit/RDM-support recycler. The selector first keeps the best direct-inflow candidates, then adds jumps one at a time to minimize the complement common jump-kernel dimensiondim( intersection_mu ker J_mu ∩ P_M^perp ).
Reaching
target_bad_kernel_dimension=0is a strong, jump-only sufficient condition that no complement vector remains dark under all selected jumps. It is stronger than the true invariant-subspace condition includingH, but cheaper and useful before expensive Liouvillian spectrum checks.If
candidate_reportis a truncated diagnostic report, setexpand_candidate_report=Trueandmax_candidate_pool=Noneto rescan and use the full local recycler candidate family. This is often the right follow-up when a small inflow-ranked pool leaves a low-dimensional bad complement kernel.selection_strategy="kernel_projection"is faster for large two-region recycler pools: it updates the current complement common kernel directly by applying each candidate to the current bad subspace, and runs the full diagnostics only once at the end."ranked_inflow"is the production preselection mode for large scans: it trusts the inflow-ranked candidate report and selects the top candidates directly. By default this production mode skips the expensive final common-kernel diagnostic; passcheck_final_diagnostics=Truewhen you want the full certificate.
- qlinks.open_system.select_targeted_residual_kernel_jumps(*, targeted_report, hamiltonian=None, states=None, base_jumps=(), max_selected_jumps=16, target_residual_kernel_dimension=0, selection_target='reported_residual_kernel', allow_non_improving=False, kernel_tolerance=1e-10, dark_tolerance=1e-10, inflow_tolerance=1e-12, liouvillian_zero_tolerance=1e-09, check_manifold_diagnostics=True, liouvillian_spectrum_method='none', sparse_liouvillian_eigenvalue_count=32)[source]#
Greedily select targeted local jumps removing a residual bad kernel.
The input report is produced by
diagnose_targeted_residual_kernel_linear_search().With
selection_target="reported_residual_kernel"this preserves the original behavior: each step minimizes the remaining kernel inside the residual basis stored intargeted_report. Withselection_target="combined_common_kernel"the selector instead starts from the complement common jump-kernel of the suppliedbase_jumpsand greedily minimizes the combined bad kernel ofbase_jumpsplus the targeted candidates. The latter is the right mode after a compressed recycled-detector subset leaves a small complement kernel that is not identical to the full-family residual basis used to create the targeted report.
- qlinks.open_system.solve_lindblad(*, hamiltonian, jumps, density_matrix_initial, times, method='auto', backend='scipy', options=None)[source]#
Evolve a density matrix under a Lindblad master equation.
- Parameters:
hamiltonian (Any) – Hamiltonian matrix.
jumps (list[Any] | tuple[Any, ...]) – Lindblad jump operators.
density_matrix_initial (Any) – Initial density matrix.
times (ndarray) – Strictly increasing one-dimensional time grid.
method (Literal['auto', 'krylov', 'rk4_matrix', 'rk4_sparse_matrix', 'rk4_liouville']) – Solver method, or
"auto".backend (Literal['scipy', 'cupy']) – Open-system backend name.
options (LindbladEvolutionOptions | None) – Optional full options object. When supplied,
methodandbackendoverride the corresponding fields.
- Returns:
Evolution result containing density matrices and diagnostics metadata.
- Return type:
- qlinks.open_system.target_manifold_coherence_series(*, norm='fro', **kwargs)[source]#
Return off-diagonal coherence of target-manifold density matrices.
norm="fro"returns the Frobenius norm of off-diagonal entries, whilenorm="l1"returns their elementwise absolute sum.
- qlinks.open_system.target_manifold_density_matrix(density_matrix, *, target_states=None, target_basis=None, normalize=True, tolerance=1e-10)[source]#
Return the density matrix reduced to the target manifold basis.
The returned matrix is
Q^dagger rho Qwhere columns ofQare an orthonormal target basis. Whennormalize=Truethis is conditioned on being in the manifold by dividing byTr(Q^dagger rho Q). If the weight is numerically zero, the unnormalized zero matrix is returned.
- qlinks.open_system.target_manifold_density_matrix_series(*, density_matrices=None, evolution_result=None, ensemble_result=None, state_snapshots=None, target_states=None, target_basis=None, normalize=True, tolerance=1e-10)[source]#
Return
Q^dagger rho(t) Qfor a target manifold basis.The result has shape
(n_times, manifold_dimension, manifold_dimension). Withnormalize=Trueeach time slice is conditioned by its target-manifold weight, i.e. it is divided byTr(P_target rho(t))when the weight is nonzero.
- qlinks.open_system.target_manifold_entropy_series(*, base=None, tolerance=1e-12, **kwargs)[source]#
Return von Neumann entropy of target-manifold density matrices.
The input density matrices are usually conditioned by leaving
normalize=Trueinkwargs. Eigenvalues belowtoleranceare ignored in the logarithm.
- qlinks.open_system.target_manifold_populations_series(**kwargs)[source]#
Return diagonal populations of the target-manifold density matrices.
- qlinks.open_system.target_manifold_projector(target_states, *, tolerance=1e-10)[source]#
Return the projector onto a target manifold.
target_statesmay be one target vector, a(dim, n_states)matrix, or an(n_states, dim)matrix. The columns/rows are orthonormalized before building the projector, so linearly dependent target vectors are harmless.
- qlinks.open_system.target_manifold_purity_series(**kwargs)[source]#
Return
Tr(rho_target(t)^2)for target-manifold density matrices.
- qlinks.open_system.target_manifold_weight(density_matrix, *, target_states=None, target_basis=None, projector=None, tolerance=1e-10)[source]#
Return
Tr(P_target rho)for one density matrix.Pass either
target_states/target_basisor an explicitprojector. When a target basis is supplied, the computation usesTr(Q^dagger rho Q)and avoids materializing the full projector.
- qlinks.open_system.target_manifold_weight_series(*, density_matrices=None, evolution_result=None, ensemble_result=None, state_snapshots=None, target_states=None, target_basis=None, projector=None, tolerance=1e-10)[source]#
Return
Tr(P_target rho(t))for evolution or MCWF output.Exactly one data source must be supplied:
density_matrices, aLindbladEvolutionResultviaevolution_result, anEnsembleResultviaensemble_result, or MCWFstate_snapshots. For state snapshots, each snapshot is expected to be a(dim, n_trajectories)state matrix and the returned weight is the trajectory average of<psi|P_target|psi>.
- qlinks.open_system.unvectorize_density_matrix(vectorized_density_matrix, dim)[source]#
Restore a density matrix from column-major Liouville vectorization.
- Parameters:
vectorized_density_matrix (Any) – Vector returned by
vectorize_density_matrix().dim (int) – Hilbert-space dimension.
- Returns:
(dim, dim)density matrix.- Return type:
- qlinks.open_system.vectorize_density_matrix(density_matrix)[source]#
Vectorize a density matrix in column-major Liouville convention.
- qlinks.open_system.verify_density_matrix(rho, *, target_state=None, atol=1e-10)[source]#
Check whether an array is a valid density matrix.
- Parameters:
rho (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Candidate density matrix.
target_state (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional pure state used to compute
<psi|rho|psi>.atol (float) – Absolute tolerance for trace, Hermiticity, and positivity checks.
- Returns:
Verification record with scalar diagnostics and boolean flags.
- Raises:
ValueError – If
rhois not square ortarget_stateis invalid.- Return type:
- qlinks.open_system.verify_lindblad_final_state(rho, *, hamiltonian, jumps, target_state=None, atol=1e-10, backend='scipy')[source]#
Verify density-matrix validity and Lindblad stationarity.
- Parameters:
rho (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Candidate final density matrix.
hamiltonian (Any) – Hamiltonian matrix.
jumps (list[Any] | tuple[Any, ...]) – Lindblad jump operators.
target_state (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None) – Optional pure state for fidelity diagnostics.
atol (float) – Absolute tolerance passed to
verify_density_matrix().backend (Literal['scipy', 'cupy'] | ~qlinks.open_system.backend.OpenSystemBackend) – Open-system backend name or object.
- Returns:
Final-state verification record.
- Return type: