CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-qutip

Comprehensive Python library for simulating quantum systems dynamics and quantum information processing.

Pending
Overview
Eval results
Files

solvers.mddocs/

Time Evolution Solvers

Comprehensive suite of solvers for quantum system dynamics including unitary evolution, open system dynamics, stochastic methods, and specialized solvers.

Capabilities

Schrödinger Equation Solver

Unitary time evolution for closed quantum systems.

def sesolve(H, psi0, tlist, e_ops=None, args=None, options=None) -> Result:
    """
    Solve time-dependent Schrödinger equation.
    
    Parameters:
    - H: Hamiltonian (Qobj or list for time-dependent)
    - psi0: Initial state vector (Qobj)
    - tlist: Array of time points
    - e_ops: List of operators for expectation values
    - args: Dictionary of parameters for time-dependent H
    - options: Solver options (SolverOptions object)
    
    Returns:
    - Result: Object containing times, states, and expectation values
    """

class SESolver:
    """
    Schrödinger equation solver class for repeated calculations.
    """
    def __init__(self, H, e_ops=None, options=None):
        """
        Initialize Schrödinger solver.
        
        Parameters:
        - H: Hamiltonian
        - e_ops: Expectation value operators
        - options: Solver options
        """
    
    def solve(self, psi0, tlist, args=None) -> Result:
        """
        Solve for given initial state and times.
        
        Parameters:
        - psi0: Initial state
        - tlist: Time points
        - args: Time-dependent parameters
        
        Returns:
        - Result: Solution object
        """

Master Equation Solver

Open system dynamics with Lindblad master equation.

def mesolve(H, rho0, tlist, c_ops=None, e_ops=None, args=None, options=None) -> Result:
    """
    Solve Lindblad master equation for open quantum systems.
    
    Parameters:
    - H: Hamiltonian (Qobj or list for time-dependent)
    - rho0: Initial density matrix (Qobj)
    - tlist: Array of time points
    - c_ops: List of collapse operators
    - e_ops: List of operators for expectation values
    - args: Dictionary of parameters for time-dependent terms
    - options: Solver options (SolverOptions object)
    
    Returns:
    - Result: Object containing times, states, and expectation values
    """

class MESolver:
    """
    Master equation solver class for repeated calculations.
    """
    def __init__(self, H, c_ops=None, e_ops=None, options=None):
        """
        Initialize master equation solver.
        
        Parameters:
        - H: Hamiltonian
        - c_ops: Collapse operators
        - e_ops: Expectation value operators
        - options: Solver options
        """
    
    def solve(self, rho0, tlist, args=None) -> Result:
        """
        Solve for given initial state and times.
        
        Parameters:
        - rho0: Initial density matrix
        - tlist: Time points
        - args: Time-dependent parameters
        
        Returns:
        - Result: Solution object
        """

Monte Carlo Solver

Quantum trajectory method for open systems.

def mcsolve(H, psi0, tlist, c_ops=None, e_ops=None, ntraj=500, args=None, options=None) -> McResult:
    """
    Solve stochastic Schrödinger equation using Monte Carlo method.
    
    Parameters:
    - H: Hamiltonian (Qobj or list for time-dependent)
    - psi0: Initial state vector (Qobj)
    - tlist: Array of time points
    - c_ops: List of collapse operators
    - e_ops: List of operators for expectation values
    - ntraj: Number of Monte Carlo trajectories
    - args: Dictionary of parameters for time-dependent terms
    - options: Solver options (SolverOptions object)
    
    Returns:
    - McResult: Object with trajectory data and averaged results
    """

class MCSolver:
    """
    Monte Carlo solver class for repeated calculations.
    """
    def __init__(self, H, c_ops=None, e_ops=None, options=None):
        """
        Initialize Monte Carlo solver.
        
        Parameters:
        - H: Hamiltonian
        - c_ops: Collapse operators
        - e_ops: Expectation value operators
        - options: Solver options
        """
    
    def solve(self, psi0, tlist, ntraj=500, args=None) -> McResult:
        """
        Solve for given initial state and times.
        
        Parameters:
        - psi0: Initial state
        - tlist: Time points
        - ntraj: Number of trajectories
        - args: Time-dependent parameters
        
        Returns:
        - McResult: Monte Carlo results
        """

Steady State Solvers

Finding equilibrium states of open quantum systems.

def steadystate(A, c_ops=None, method='direct', sparse=True, use_wbm=False, 
                weight=None, **kwargs) -> Qobj:
    """
    Calculate steady state of open quantum system.
    
    Parameters:
    - A: Hamiltonian or Liouvillian superoperator
    - c_ops: List of collapse operators (if A is Hamiltonian)
    - method: 'direct', 'eigen', 'iterative-gmres', 'iterative-lgmres', 'iterative-bicgstab'
    - sparse: Use sparse matrices
    - use_wbm: Use weighted bipartite matching
    - weight: Weighting factor for balancing
    
    Returns:
    - Qobj: Steady state density matrix
    """

def steadystate_floquet(H_S, c_ops, A, w, H_0=None, max_iter=10000, tol=1e-6) -> Qobj:
    """
    Calculate steady state for periodically driven system using Floquet formalism.
    
    Parameters:
    - H_S: System Hamiltonian
    - c_ops: List of collapse operators
    - A: Floquet driving amplitude
    - w: Driving frequency
    - H_0: Additional constant Hamiltonian
    - max_iter: Maximum iterations
    - tol: Convergence tolerance
    
    Returns:
    - Qobj: Floquet steady state
    """

Propagator

Time evolution operators and propagators.

def propagator(H, t, c_ops=None, args=None, options=None, unitary_mode='batch', parallel=False) -> Qobj:
    """
    Calculate time evolution propagator.
    
    Parameters:
    - H: Hamiltonian
    - t: Time or list of times
    - c_ops: Collapse operators (for Liouvillian propagator)
    - args: Time-dependent parameters
    - options: Solver options
    - unitary_mode: 'batch' or 'single' calculation mode
    - parallel: Use parallel computation
    
    Returns:
    - Qobj: Evolution operator U(t) or superoperator
    """

class Propagator:
    """
    Propagator class for efficient repeated calculations.
    """
    def __init__(self, H, c_ops=None, options=None):
        """
        Initialize propagator.
        
        Parameters:
        - H: Hamiltonian
        - c_ops: Collapse operators
        - options: Solver options
        """
    
    def propagate(self, t, args=None) -> Qobj:
        """
        Calculate propagator for given time.
        
        Parameters:
        - t: Evolution time
        - args: Time-dependent parameters
        
        Returns:
        - Qobj: Propagator
        """

Stochastic Solvers

Stochastic differential equations for open quantum systems.

def smesolve(H, rho0, tlist, c_ops=None, sc_ops=None, e_ops=None, 
             _safe_mode=True, **kwargs) -> Result:
    """
    Solve stochastic master equation.
    
    Parameters:
    - H: Hamiltonian
    - rho0: Initial density matrix
    - tlist: Time points
    - c_ops: Collapse operators
    - sc_ops: Stochastic collapse operators  
    - e_ops: Expectation value operators
    - _safe_mode: Use safe integration mode
    
    Returns:
    - Result: Stochastic evolution results
    """

def ssesolve(H, psi0, tlist, c_ops=None, sc_ops=None, e_ops=None,
             _safe_mode=True, **kwargs) -> Result:
    """
    Solve stochastic Schrödinger equation.
    
    Parameters:
    - H: Hamiltonian
    - psi0: Initial state vector
    - tlist: Time points
    - c_ops: Collapse operators
    - sc_ops: Stochastic collapse operators
    - e_ops: Expectation value operators
    - _safe_mode: Use safe integration mode
    
    Returns:
    - Result: Stochastic evolution results
    """

Floquet Theory Solvers

Periodically driven quantum systems.

def floquet_modes(H, T, args=None, sort=True, U=None) -> tuple:
    """
    Calculate Floquet modes and quasi-energies.
    
    Parameters:
    - H: Time-dependent Hamiltonian (list format)
    - T: Period of driving
    - args: Parameters for time-dependent H
    - sort: Sort by quasi-energy
    - U: Pre-calculated evolution operator
    
    Returns:
    - tuple: (quasi_energies, floquet_modes)
    """

def floquet_states(H, T, args=None, sort=True, U=None) -> tuple:
    """
    Calculate Floquet states at t=0.
    
    Parameters:
    - H: Time-dependent Hamiltonian
    - T: Period of driving
    - args: Parameters for time-dependent H
    - sort: Sort by quasi-energy
    - U: Pre-calculated evolution operator
    
    Returns:
    - tuple: (quasi_energies, floquet_states)
    """

def fsesolve(H, psi0, tlist, e_ops=None, T=None, args=None, options=None) -> Result:
    """
    Solve Schrödinger equation using Floquet formalism.
    
    Parameters:
    - H: Time-dependent Hamiltonian
    - psi0: Initial state
    - tlist: Time points
    - e_ops: Expectation value operators
    - T: Driving period
    - args: Time-dependent parameters
    - options: Solver options
    
    Returns:
    - Result: Floquet evolution results
    """

def fmmesolve(H, rho0, tlist, c_ops=None, e_ops=None, T=None, args=None, options=None) -> Result:
    """
    Solve master equation using Floquet-Markov formalism.
    
    Parameters:
    - H: Time-dependent Hamiltonian
    - rho0: Initial density matrix
    - tlist: Time points
    - c_ops: Collapse operators
    - e_ops: Expectation value operators
    - T: Driving period
    - args: Time-dependent parameters
    - options: Solver options
    
    Returns:
    - Result: Floquet-Markov evolution results
    """

Bloch-Redfield Solver

Non-Markovian open system dynamics.

def brmesolve(H, rho0, tlist, a_ops, e_ops=None, c_ops=None, args=None, 
              use_secular=True, options=None) -> Result:
    """
    Solve Bloch-Redfield master equation.
    
    Parameters:
    - H: System Hamiltonian
    - rho0: Initial density matrix
    - tlist: Time points
    - a_ops: List of system operators coupled to bath
    - e_ops: Expectation value operators
    - c_ops: Additional Lindblad operators
    - args: Time-dependent parameters
    - use_secular: Use secular approximation
    - options: Solver options
    
    Returns:
    - Result: Bloch-Redfield evolution results
    """

class BRSolver:
    """
    Bloch-Redfield solver class.
    """
    def __init__(self, H, a_ops, e_ops=None, c_ops=None, options=None):
        """
        Initialize Bloch-Redfield solver.
        
        Parameters:
        - H: System Hamiltonian
        - a_ops: System-bath coupling operators
        - e_ops: Expectation value operators
        - c_ops: Additional collapse operators
        - options: Solver options
        """
    
    def solve(self, rho0, tlist, args=None) -> Result:
        """
        Solve Bloch-Redfield equation.
        
        Parameters:
        - rho0: Initial density matrix
        - tlist: Time points
        - args: Time-dependent parameters
        
        Returns:
        - Result: Evolution results
        """

Solver Options

Configuration options for all solvers.

class SolverOptions:
    """
    Options for ODE solvers.
    
    Attributes:
        atol: Absolute tolerance (default: 1e-8)
        rtol: Relative tolerance (default: 1e-6)
        method: Integration method ('adams', 'bdf', etc.)
        order: Integration order
        nsteps: Maximum number of steps
        first_step: Initial step size
        min_step: Minimum step size
        max_step: Maximum step size
        tidy: Clean up small matrix elements
        num_cpus: Number of CPUs for parallel execution
    """
    def __init__(self, atol=1e-8, rtol=1e-6, method='adams', order=12, 
                 nsteps=1000, first_step=0, min_step=0, max_step=0,
                 tidy=True, num_cpus=0):
        """Initialize solver options."""

Usage Examples

import qutip as qt
import numpy as np

# Define system
N = 10
a = qt.destroy(N)
H = a.dag() * a  # Number operator Hamiltonian
psi0 = qt.coherent(N, 2.0)  # Initial coherent state
times = np.linspace(0, 10, 100)

# Closed system evolution (Schrödinger equation)
result_se = qt.sesolve(H, psi0, times, e_ops=[a.dag()*a])
populations = result_se.expect[0]

# Open system with damping (Master equation)
gamma = 0.1
c_ops = [np.sqrt(gamma) * a]  # Damping
rho0 = psi0 * psi0.dag()
result_me = qt.mesolve(H, rho0, times, c_ops, e_ops=[a.dag()*a])

# Monte Carlo trajectories
result_mc = qt.mcsolve(H, psi0, times, c_ops, e_ops=[a.dag()*a], ntraj=100)
print(f"Collapse events: {result_mc.col_times}")

# Steady state calculation
L = qt.liouvillian(H, c_ops)  # Liouvillian superoperator
rho_ss = qt.steadystate(H, c_ops)  # Direct method
print(f"Steady state population: {qt.expect(a.dag()*a, rho_ss)}")

# Time-dependent Hamiltonian
def H_coeff(t, args):
    return np.cos(args['w'] * t)

H_td = [H, [a.dag() + a, H_coeff]]  # H(t) = H + cos(wt)(a† + a)
args = {'w': 1.0}
result_td = qt.sesolve(H_td, psi0, times, args=args)

# Floquet system (periodic driving)
T = 2*np.pi  # Driving period
quasi_energies, floquet_modes = qt.floquet_modes(H_td, T, args=args)
print(f"Quasi-energies: {quasi_energies}")

# Stochastic evolution
sc_ops = [a]  # Stochastic collapse operators
result_sme = qt.smesolve(H, rho0, times, c_ops, sc_ops)

# Propagator calculation
t_prop = 1.0
U = qt.propagator(H, t_prop)  # Evolution operator U(t)
psi_evolved = U * psi0  # Evolved state

# Solver with custom options
options = qt.SolverOptions(atol=1e-10, rtol=1e-8, nsteps=2000)
result_precise = qt.mesolve(H, rho0, times, c_ops, options=options)

# Bloch-Redfield solver for structured environment
a_ops = [[a.dag(), lambda w: 0.1 * w / (1 + w**2)]]  # System-bath coupling
result_br = qt.brmesolve(H, rho0, times, a_ops)

Types

class Result:
    """
    Result object containing solver output.
    
    Attributes:
        solver: String identifier of solver used
        times: Array of time points
        states: List of quantum states at each time
        expect: List of expectation value arrays
        num_expect: Number of expectation operators
        num_collapse: Number of collapse operators
    """

class McResult(Result):
    """
    Monte Carlo result with trajectory information.
    
    Additional Attributes:
        ntraj: Number of trajectories
        col_times: List of collapse times for each trajectory
        col_which: List of which collapse operator triggered each event
        photocurrent: Photocurrent measurement record (if applicable)
    """

class SolverOptions:
    """
    Configuration options for numerical integration.
    
    Main Attributes:
        atol: Absolute tolerance
        rtol: Relative tolerance  
        method: Integration method
        nsteps: Maximum integration steps
    """

Install with Tessl CLI

npx tessl i tessl/pypi-qutip

docs

index.md

operators.md

phase-space.md

process-tomography.md

quantum-gates.md

quantum-information.md

quantum-objects.md

random-objects.md

solvers.md

states.md

superoperators.md

tensor-operations.md

utilities.md

visualization.md

tile.json