trotter

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package trotter implements Trotter-Suzuki Hamiltonian simulation.

Given a Hamiltonian H = sum_k c_k P_k expressed as a PauliSum, the algorithm approximates the time-evolution operator e^{-iHt} by decomposing it into a product of single-term exponentials.

First-order (Lie-Trotter):

e^{-iHt} ~ [prod_k e^{-i c_k P_k dt/steps}]^steps

Second-order (Suzuki-Trotter):

e^{-iHt} ~ [prod_k e^{-i c_k P_k dt/(2*steps)} * prod_k' e^{-i c_k' P_k' dt/(2*steps)}]^steps

where the second product runs in reverse order.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Evolve

func Evolve(ctx context.Context, cfg Config, initial *ir.Circuit) ([]complex128, error)

Evolve builds the Trotter circuit, optionally prepends an initial state preparation circuit, evolves the combined circuit using a statevector simulator, and returns the final state vector.

Types

type Config

type Config struct {
	// Hamiltonian is the operator to simulate, expressed as a sum of Pauli strings.
	Hamiltonian pauli.PauliSum
	// Time is the total evolution time t in e^{-iHt}.
	Time float64
	// Steps is the number of Trotter steps (higher = more accurate). Default: 1.
	Steps int
	// Order is the Trotter decomposition order. Default: First.
	Order Order
}

Config specifies the Trotter simulation parameters.

type Order

type Order int

Order specifies the Trotter decomposition order.

const (
	// First is the first-order Lie-Trotter decomposition.
	First Order = 1
	// Second is the second-order symmetric Suzuki-Trotter decomposition.
	Second Order = 2
)

type Result

type Result struct {
	// Circuit is the compiled Trotter circuit.
	Circuit *ir.Circuit
	// Steps is the number of Trotter steps used.
	Steps int
	// Order is the Trotter decomposition order used.
	Order Order
}

Result holds the output of a Trotter simulation circuit construction.

func Run

func Run(ctx context.Context, cfg Config) (*Result, error)

Run builds a Trotter circuit for the given Hamiltonian simulation and returns it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL