psiqit.dynamics
Auto-generated documentation for the psiqit.dynamics module.
psiqit.dynamics
PSIQIT - Python Scientific Quantum Information Toolkit Dynamics Module
This module provides quantum dynamics and time evolution capabilities.
Submodules:
adiabatic.py - Adiabatic evolution and quantum annealing heisenberg.py - Heisenberg picture evolution interaction.py - Interaction picture dynamics lindblad.py - Lindblad master equation for open quantum systems monte_carlo.py - Quantum trajectories (Monte Carlo wavefunction method) schrodinger.py - Schrödinger equation (time-independent and time-dependent) time_evolution.py - Numerical time evolution methods (Trotter, Chebyshev, Krylov)
AdiabaticResult
dataclass
Result container for adiabatic evolution
Attributes:
| Name | Type | Description |
|---|---|---|
times |
ndarray
|
Time points |
states |
List[Ket]
|
List of quantum states at each time |
energies |
List[float]
|
List of energies at each time |
fidelities |
List[float]
|
List of fidelities with instantaneous ground state |
success |
bool
|
Whether evolution was successful |
message |
str
|
Additional information |
n_steps |
int
|
Number of time steps |
final_state |
Optional[Ket]
|
Final state |
final_energy |
Optional[float]
|
Final energy |
Source code in psiqit\dynamics\adiabatic.py
__post_init__()
get_fidelity_history()
get_energy_history()
get_state_at_time(index)
get_final_state()
AdiabaticEvolution
Adiabatic quantum evolution
Simulates the time-dependent Schrödinger equation for a Hamiltonian that interpolates between an initial and final Hamiltonian.
H(t) = (1 - s(t)) * H_initial + s(t) * H_final
where s(t) = t/T is the interpolation parameter.
Example
from psiqit.quantum import pauli_x, pauli_z, zero H_i = pauli_x() # Initial Hamiltonian H_f = pauli_z() # Final Hamiltonian evo = AdiabaticEvolution(H_i, H_f, T=10.0, n_steps=100) result = evo.evolve(zero()) print(result.final_energy)
Source code in psiqit\dynamics\adiabatic.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
__init__(H_initial, H_final, T, n_steps=100, schedule=None)
Initialize adiabatic evolution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
H_initial
|
Operator
|
Initial Hamiltonian (at t=0) |
required |
H_final
|
Operator
|
Final Hamiltonian (at t=T) |
required |
T
|
float
|
Total evolution time |
required |
n_steps
|
int
|
Number of time steps |
100
|
schedule
|
Optional[Callable[[float], float]]
|
Interpolation schedule s(t) (default: linear s(t) = t/T) |
None
|
Example
H_i = pauli_x() H_f = pauli_z() evo = AdiabaticEvolution(H_i, H_f, T=10.0, n_steps=100)
Source code in psiqit\dynamics\adiabatic.py
evolve(psi0)
Perform adiabatic evolution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state (usually ground state of H_initial) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AdiabaticResult |
AdiabaticResult
|
Evolution results |
Example
from psiqit.quantum import zero result = evo.evolve(zero()) print(result.final_energy)
Source code in psiqit\dynamics\adiabatic.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
get_min_gap(n_points=1000)
Estimate the minimum energy gap during evolution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_points
|
int
|
Number of points to sample |
1000
|
Returns:
| Name | Type | Description |
|---|---|---|
Tuple |
Tuple[float, float]
|
(min_gap, time_of_min_gap) |
Example
evo = AdiabaticEvolution(H_i, H_f, T=10.0) min_gap, t_gap = evo.get_min_gap() print(f"Minimum gap: {min_gap:.6f} at t={t_gap:.3f}")
Source code in psiqit\dynamics\adiabatic.py
get_adiabatic_condition(n_points=100)
Check the adiabatic condition: |⟨1|dH/dt|0⟩| / (ΔE)² << 1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_points
|
int
|
Number of points to sample |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Maximum violation of adiabatic condition |
Source code in psiqit\dynamics\adiabatic.py
QuantumAnnealing
Bases: AdiabaticEvolution
Quantum annealing algorithm
Quantum annealing is a special case of adiabatic evolution where the Hamiltonian is:
H(s) = (1-s) * H_transverse + s * H_problem
where H_transverse = -Σ σ_x^i (transverse field) and H_problem is the problem Hamiltonian (usually Ising model)
Example
Simple 2-qubit Ising problem
problem_hamiltonian = {'Z0Z1': 1.0, 'Z0': 0.5, 'Z1': -0.5} qa = QuantumAnnealing(problem_hamiltonian, T=10.0, n_steps=100) result = qa.run() print(result.final_energy)
Source code in psiqit\dynamics\adiabatic.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
__init__(problem_hamiltonian, T, transverse_field=1.0, n_steps=100, schedule=None)
Initialize quantum annealing
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem_hamiltonian
|
Dict[str, float]
|
Problem Hamiltonian as Pauli strings {'Z0': 1.0, 'Z0Z1': 0.5, ...} |
required |
T
|
float
|
Total annealing time |
required |
transverse_field
|
float
|
Strength of transverse field |
1.0
|
n_steps
|
int
|
Number of time steps |
100
|
schedule
|
Optional[Callable[[float], float]]
|
Annealing schedule (default: linear) |
None
|
Example
Ising problem: -Z0Z1 (anti-ferromagnetic)
problem = {'Z0Z1': -1.0} qa = QuantumAnnealing(problem, T=5.0, n_steps=50)
Source code in psiqit\dynamics\adiabatic.py
run(initial_state=None, return_all=False)
Run the quantum annealing algorithm
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_state
|
Optional[Ket]
|
Initial state (default: ground state of transverse field) |
None
|
return_all
|
bool
|
Return all states (for analysis) |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
AdiabaticResult |
AdiabaticResult
|
Annealing results |
Example
qa = QuantumAnnealing({'Z0Z1': -1.0}, T=5.0) result = qa.run() print(f"Final energy: {result.final_energy:.6f}") print(f"Success: {result.success}")
Source code in psiqit\dynamics\adiabatic.py
get_final_state_probabilities(result)
Get the probabilities of the final state in the computational basis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
AdiabaticResult
|
Result from run() |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict[str, float]
|
Basis state probabilities |
Source code in psiqit\dynamics\adiabatic.py
get_ground_state_energy()
Get the ground state energy of the problem Hamiltonian
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Ground state energy |
Source code in psiqit\dynamics\adiabatic.py
get_ground_state()
Get the ground state of the problem Hamiltonian
Returns:
| Name | Type | Description |
|---|---|---|
Ket |
Ket
|
Ground state |
Source code in psiqit\dynamics\adiabatic.py
HeisenbergResult
dataclass
Result container for Heisenberg evolution
Attributes:
| Name | Type | Description |
|---|---|---|
times |
ndarray
|
Time points |
operators |
List[Operator]
|
List of operators at each time |
success |
bool
|
Whether evolution was successful |
message |
str
|
Additional information |
n_steps |
int
|
Number of time steps |
initial_operator |
Optional[Operator]
|
Initial operator |
final_operator |
Optional[Operator]
|
Final operator |
expectation_values |
Optional[List[float]]
|
List of expectation values (if state provided) |
Source code in psiqit\dynamics\heisenberg.py
__post_init__()
get_operator_at_time(index)
get_final_operator()
get_expectation_history()
HeisenbergEvolution
Heisenberg picture evolution of operators
In the Heisenberg picture, operators evolve in time while states remain constant. The evolution of an operator A is given by:
A(t) = e^{iHt/ħ} A(0) e^{-iHt/ħ}
Example
from psiqit.quantum import pauli_x, pauli_z H = pauli_z() # Hamiltonian evo = HeisenbergEvolution(H) X_t = evo.evolve_operator(pauli_x(), t=1.0) print(X_t) # Rotated operator
Source code in psiqit\dynamics\heisenberg.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
__init__(hamiltonian, hbar=1.0)
Initialize Heisenberg evolution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hamiltonian
|
Operator
|
Hamiltonian operator (Hermitian) |
required |
hbar
|
float
|
Reduced Planck constant (default: 1) |
1.0
|
Example
from psiqit.quantum import pauli_z H = pauli_z() evo = HeisenbergEvolution(H)
Source code in psiqit\dynamics\heisenberg.py
evolve_operator(A, t, method='series', order=5, n_steps=100)
Evolve an operator in the Heisenberg picture
A(t) = e^{iHt/ħ} A(0) e^{-iHt/ħ}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator to evolve |
required |
t
|
float
|
Evolution time |
required |
method
|
str
|
'series', 'exact', or 'trotter' |
'series'
|
order
|
int
|
Order for series expansion |
5
|
n_steps
|
int
|
Number of steps for Trotter method |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Evolved operator |
Example
X = pauli_x() X_t = evo.evolve_operator(X, t=np.pi/2) print(X_t) # Rotated operator
Source code in psiqit\dynamics\heisenberg.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
evolve_operator_sequence(A, times, method='exact', **kwargs)
Evolve an operator at multiple time points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator to evolve |
required |
times
|
ndarray
|
Array of time points |
required |
method
|
str
|
Evolution method |
'exact'
|
**kwargs
|
Additional arguments for evolve_operator |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
HeisenbergResult |
HeisenbergResult
|
Evolution results |
Example
times = np.linspace(0, 2*np.pi, 50) result = evo.evolve_operator_sequence(pauli_x(), times) print(len(result.operators)) # 50
Source code in psiqit\dynamics\heisenberg.py
compute_expectation(A, state, t, method='exact', **kwargs)
Compute expectation value ⟨ψ|A(t)|ψ⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator to evolve |
required |
state
|
Ket
|
Quantum state |
required |
t
|
float
|
Evolution time |
required |
method
|
str
|
Evolution method |
'exact'
|
**kwargs
|
Additional arguments for evolve_operator |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Expectation value |
Example
from psiqit.quantum import zero state = zero() exp = evo.compute_expectation(pauli_x(), state, t=np.pi/2) print(exp)
Source code in psiqit\dynamics\heisenberg.py
compute_expectation_sequence(A, state, times, method='exact', **kwargs)
Compute expectation values at multiple time points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator |
required |
state
|
Ket
|
Quantum state |
required |
times
|
ndarray
|
Array of time points |
required |
method
|
str
|
Evolution method |
'exact'
|
**kwargs
|
Additional arguments for evolve_operator |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Tuple |
Tuple[ndarray, List[float]]
|
(times, expectation_values) |
Example
times = np.linspace(0, 2*np.pi, 50) result = evo.compute_expectation_sequence(pauli_x(), zero(), times) print(result[1][:5]) # First 5 expectation values
Source code in psiqit\dynamics\heisenberg.py
HeisenbergEquation
Heisenberg equation of motion
dA/dt = (i/ħ) [H, A] + (∂A/∂t)
For time-independent operators: dA/dt = (i/ħ) [H, A]
Example
from psiqit.quantum import pauli_x, pauli_z H = pauli_z() eq = HeisenbergEquation(H) dXdt = eq.equation_of_motion(pauli_x()) print(dXdt) # -i/ħ [Z, X] = -2/ħ Y
Source code in psiqit\dynamics\heisenberg.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
__init__(hamiltonian, hbar=1.0)
Initialize Heisenberg equation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hamiltonian
|
Operator
|
Hamiltonian operator |
required |
hbar
|
float
|
Reduced Planck constant |
1.0
|
Example
from psiqit.quantum import pauli_z H = pauli_z() eq = HeisenbergEquation(H)
Source code in psiqit\dynamics\heisenberg.py
equation_of_motion(A)
Compute the Heisenberg equation of motion for an operator
dA/dt = (i/ħ) [H, A]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Time derivative of the operator |
Example
X = pauli_x() dXdt = eq.equation_of_motion(X) print(dXdt) # (i/ħ)[H, X]
Source code in psiqit\dynamics\heisenberg.py
equation_of_motion_explicit(A)
Compute the explicit form of the equation of motion
Same as equation_of_motion, but with expanded form
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Time derivative of the operator |
Source code in psiqit\dynamics\heisenberg.py
get_time_evolution_operator(t)
Get the time evolution operator U(t) = e^{-iHt/ħ}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Time evolution operator |
Source code in psiqit\dynamics\heisenberg.py
evolve_operator_infinitesimal(A, dt)
Evolve an operator by an infinitesimal time step
A(t+dt) ≈ A(t) + (dA/dt) * dt
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator |
required |
dt
|
float
|
Time step |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Evolved operator |
Source code in psiqit\dynamics\heisenberg.py
get_conserved_quantities(operators)
Check which operators commute with the Hamiltonian
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operators
|
List[Operator]
|
List of operators |
required |
Returns:
| Type | Description |
|---|---|
List[bool]
|
List[bool]: True if operator commutes with Hamiltonian |
Example
from psiqit.quantum import pauli_x, pauli_z, identity H = pauli_z() eq = HeisenbergEquation(H) conserved = eq.get_conserved_quantities([pauli_x(), pauli_z(), identity()]) print(conserved) # [False, True, True]
Source code in psiqit\dynamics\heisenberg.py
InteractionResult
dataclass
Result container for interaction picture evolution
Attributes:
| Name | Type | Description |
|---|---|---|
times |
ndarray
|
Time points |
states |
List[Ket]
|
List of quantum states at each time |
success |
bool
|
Whether evolution was successful |
message |
str
|
Additional information |
n_steps |
int
|
Number of time steps |
final_state |
Optional[Ket]
|
Final state |
initial_state |
Optional[Ket]
|
Initial state |
Source code in psiqit\dynamics\interaction.py
__post_init__()
get_state_at_time(index)
get_final_state()
get_fidelity_with_initial()
Get fidelity of each state with the initial state
Returns:
| Type | Description |
|---|---|
List[float]
|
List[float]: Fidelity values |
Source code in psiqit\dynamics\interaction.py
InteractionPicture
Interaction picture dynamics
In the interaction picture, the Hamiltonian is split into: H = H₀ + V
where H₀ is the free (solvable) part and V is the interaction. The evolution is governed by the interaction Hamiltonian:
V_I(t) = e^{iH₀t/ħ} V e^{-iH₀t/ħ}
States evolve as: |ψ_I(t)⟩ = U_I(t) |ψ_I(0)⟩
where U_I(t) = T exp(-i/ħ ∫₀ᵗ V_I(t') dt')
Example
from psiqit.quantum import pauli_z, pauli_x H0 = pauli_z() # Free Hamiltonian V = pauli_x() # Interaction ip = InteractionPicture(H0, V) psi_t = ip.evolve_state(zero(), t=1.0)
Source code in psiqit\dynamics\interaction.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
__init__(H0, V, hbar=1.0)
Initialize interaction picture
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
H0
|
Operator
|
Free Hamiltonian (solvable part) |
required |
V
|
Operator
|
Interaction Hamiltonian |
required |
hbar
|
float
|
Reduced Planck constant |
1.0
|
Example
from psiqit.quantum import pauli_z, pauli_x H0 = pauli_z() V = pauli_x() ip = InteractionPicture(H0, V)
Source code in psiqit\dynamics\interaction.py
interaction_operator(t)
Compute the interaction Hamiltonian in the interaction picture
V_I(t) = e^{iH₀t/ħ} V e^{-iH₀t/ħ}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Interaction operator V_I(t) |
Example
ip = InteractionPicture(H0, V) V_I = ip.interaction_operator(t=0.5) print(V_I.name)
Source code in psiqit\dynamics\interaction.py
evolve_state(psi0, t, dt=0.01, method='rk4')
Evolve a state in the interaction picture
|ψ_I(t)⟩ = U_I(t) |ψ_I(0)⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state (in interaction picture) |
required |
t
|
float
|
Evolution time |
required |
dt
|
float
|
Time step |
0.01
|
method
|
str
|
Integration method ('euler' or 'rk4') |
'rk4'
|
Returns:
| Name | Type | Description |
|---|---|---|
Ket |
Ket
|
Evolved state |
Example
from psiqit.quantum import zero psi_t = ip.evolve_state(zero(), t=1.0, dt=0.01) print(psi_t)
Source code in psiqit\dynamics\interaction.py
evolve_state_sequence(psi0, times, dt=0.01, method='rk4')
Evolve a state at multiple time points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
times
|
ndarray
|
Array of time points |
required |
dt
|
float
|
Time step for integration |
0.01
|
method
|
str
|
Integration method |
'rk4'
|
Returns:
| Name | Type | Description |
|---|---|---|
InteractionResult |
InteractionResult
|
Evolution results |
Example
times = np.linspace(0, 2*np.pi, 50) result = ip.evolve_state_sequence(zero(), times) print(len(result.states)) # 50
Source code in psiqit\dynamics\interaction.py
evolve_operator(A, t)
Evolve an operator in the interaction picture
A_I(t) = e^{iH₀t/ħ} A e^{-iH₀t/ħ}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator to evolve |
required |
t
|
float
|
Time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Evolved operator |
Example
from psiqit.quantum import pauli_x A_t = ip.evolve_operator(pauli_x(), t=1.0) print(A_t.name)
Source code in psiqit\dynamics\interaction.py
evolve_operator_sequence(A, times)
Evolve an operator at multiple time points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator |
required |
times
|
ndarray
|
Array of time points |
required |
Returns:
| Type | Description |
|---|---|
List[Operator]
|
List[Operator]: Evolved operators |
Source code in psiqit\dynamics\interaction.py
compute_expectation(A, state, t)
Compute expectation value ⟨ψ|A_I(t)|ψ⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator |
required |
state
|
Ket
|
Quantum state |
required |
t
|
float
|
Time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Expectation value |
Source code in psiqit\dynamics\interaction.py
compute_expectation_sequence(A, state, times)
Compute expectation values at multiple time points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Operator
|
Operator |
required |
state
|
Ket
|
Quantum state |
required |
times
|
ndarray
|
Array of time points |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Tuple |
Tuple[ndarray, List[float]]
|
(times, expectation_values) |
Source code in psiqit\dynamics\interaction.py
get_time_evolution_operator(t)
Get the full time evolution operator in the interaction picture
U_I(t) = T exp(-i/ħ ∫₀ᵗ V_I(t') dt')
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Time evolution operator |
Note
This is a simplified version that uses the series expansion for the time-ordered exponential.
Source code in psiqit\dynamics\interaction.py
to_schrodinger_picture(psi_I, t)
Convert a state from interaction picture to Schrödinger picture
|ψ_S(t)⟩ = e^{-iH₀t/ħ} |ψ_I(t)⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi_I
|
Ket
|
State in interaction picture |
required |
t
|
float
|
Time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Ket |
Ket
|
State in Schrödinger picture |
Source code in psiqit\dynamics\interaction.py
to_interaction_picture(psi_S, t)
Convert a state from Schrödinger picture to interaction picture
|ψ_I(t)⟩ = e^{iH₀t/ħ} |ψ_S(t)⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi_S
|
Ket
|
State in Schrödinger picture |
required |
t
|
float
|
Time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Ket |
Ket
|
State in interaction picture |
Source code in psiqit\dynamics\interaction.py
LindbladResult
dataclass
Result container for Lindblad master equation evolution
Attributes:
| Name | Type | Description |
|---|---|---|
times |
ndarray
|
Time points |
states |
List[ndarray]
|
List of density matrices at each time |
populations |
List[ndarray]
|
List of populations for each state |
success |
bool
|
Whether evolution was successful |
message |
str
|
Additional information |
n_steps |
int
|
Number of time steps |
final_state |
Optional[ndarray]
|
Final density matrix |
fidelity |
Optional[float]
|
Fidelity with steady state (if available) |
Source code in psiqit\dynamics\lindblad.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
__post_init__()
get_state_at_time(index)
get_final_state()
get_population_at_time(index)
get_population_evolution(state_index)
Get the evolution of a specific population
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_index
|
int
|
Index of the state |
required |
Returns:
| Type | Description |
|---|---|
List[float]
|
List[float]: Population values over time |
Source code in psiqit\dynamics\lindblad.py
get_fidelity_with_initial()
Get fidelity of each state with the initial state
Returns:
| Type | Description |
|---|---|
List[float]
|
List[float]: Fidelity values |
Source code in psiqit\dynamics\lindblad.py
LindbladSolver
Lindblad master equation solver for open quantum systems
The Lindblad master equation describes the evolution of an open quantum system:
dρ/dt = -i/ħ [H, ρ] + Σ_k (L_k ρ L_k† - 1/2{L_k†L_k, ρ})
where H is the Hamiltonian and L_k are collapse operators.
Example
from psiqit.quantum import pauli_z, pauli_x H = pauli_z() # Hamiltonian L = pauli_x() # Collapse operator solver = LindbladSolver(H, [L], gamma=[0.1]) rho0 = np.array([[1, 0], [0, 0]]) # Initial state |0⟩⟨0| result = solver.evolve(rho0, t_max=10.0, dt=0.01) print(result.final_state)
Source code in psiqit\dynamics\lindblad.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | |
__init__(hamiltonian, collapse_ops, gamma=None, hbar=1.0)
Initialize Lindblad solver
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hamiltonian
|
Operator
|
System Hamiltonian (Hermitian) |
required |
collapse_ops
|
List[Operator]
|
List of collapse operators L_k |
required |
gamma
|
Optional[List[float]]
|
List of decay rates for each collapse operator If None, all rates are set to 1.0 |
None
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Example
H = pauli_z() L = pauli_x() solver = LindbladSolver(H, [L], gamma=[0.1])
Source code in psiqit\dynamics\lindblad.py
evolve(rho0, t_max, dt=0.01, method='euler', save_every=1)
Evolve the density matrix according to the Lindblad master equation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho0
|
ndarray
|
Initial density matrix |
required |
t_max
|
float
|
Maximum evolution time |
required |
dt
|
float
|
Time step |
0.01
|
method
|
str
|
Integration method ('euler' or 'rk4') |
'euler'
|
save_every
|
int
|
Save state every N steps |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
LindbladResult |
LindbladResult
|
Evolution results |
Example
rho0 = np.array([[1, 0], [0, 0]]) result = solver.evolve(rho0, t_max=10.0, dt=0.01)
Source code in psiqit\dynamics\lindblad.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
steady_state(tol=1e-10, max_iter=1000, initial_guess=None)
Find the steady state (stationary solution) of the Lindblad equation
Solves: dρ/dt = 0
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tol
|
float
|
Convergence tolerance |
1e-10
|
max_iter
|
int
|
Maximum number of iterations |
1000
|
initial_guess
|
Optional[ndarray]
|
Initial guess for steady state |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Steady state density matrix |
Example
rho_ss = solver.steady_state() print(np.trace(rho_ss)) # 1.0
Source code in psiqit\dynamics\lindblad.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
get_steady_state_analytical()
Try to find the steady state analytically (for simple systems)
Returns:
| Type | Description |
|---|---|
Optional[ndarray]
|
Optional[np.ndarray]: Steady state or None if not found |
Source code in psiqit\dynamics\lindblad.py
MonteCarloResult
dataclass
Result container for Monte Carlo quantum trajectories
Attributes:
| Name | Type | Description |
|---|---|---|
times |
ndarray
|
Time points |
avg_states |
List[ndarray]
|
Average density matrices over trajectories |
jump_times |
List[List[float]]
|
List of jump times for each trajectory |
n_jumps |
List[int]
|
Number of jumps for each trajectory |
success |
bool
|
Whether simulation was successful |
message |
str
|
Additional information |
n_trajectories |
int
|
Number of trajectories |
n_steps |
int
|
Number of time steps |
final_avg_state |
Optional[ndarray]
|
Final average density matrix |
trajectories |
Optional[List[Dict]]
|
List of individual trajectory results |
Source code in psiqit\dynamics\monte_carlo.py
__post_init__()
get_avg_state_at_time(index)
Get average density matrix at a specific time index
get_final_avg_state()
get_total_jumps()
get_jump_rate()
get_population_evolution(state_index)
Get the evolution of a specific population
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_index
|
int
|
Index of the state |
required |
Returns:
| Type | Description |
|---|---|
List[float]
|
List[float]: Population values over time |
Source code in psiqit\dynamics\monte_carlo.py
QuantumTrajectory
Quantum Monte Carlo trajectory simulation
Simulates stochastic quantum trajectories for open quantum systems. The method uses a Monte Carlo wavefunction approach where the evolution is a sequence of deterministic evolution and quantum jumps.
The non-Hermitian effective Hamiltonian is: H_eff = H - iħ/2 Σ_k γ_k L_k† L_k
Between jumps, the state evolves as: |ψ(t+dt)⟩ = (1 - iH_eff dt/ħ) |ψ(t)⟩ / ||...||
Jumps occur with probability: dp_k = γ_k dt ⟨ψ|L_k† L_k|ψ⟩
Example
from psiqit.quantum import pauli_z, pauli_x, zero H = pauli_z() L = pauli_x() qt = QuantumTrajectory(H, [L], gamma=[0.1]) result = qt.run(zero(), t_max=10.0, dt=0.01, n_trajectories=100) print(result.final_avg_state)
Source code in psiqit\dynamics\monte_carlo.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | |
__init__(hamiltonian, collapse_ops, gamma=None, hbar=1.0)
Initialize quantum trajectory simulation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hamiltonian
|
Operator
|
System Hamiltonian (Hermitian) |
required |
collapse_ops
|
List[Operator]
|
List of collapse operators L_k |
required |
gamma
|
Optional[List[float]]
|
List of decay rates for each collapse operator If None, all rates are set to 1.0 |
None
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Example
H = pauli_z() L = pauli_x() qt = QuantumTrajectory(H, [L], gamma=[0.1])
Source code in psiqit\dynamics\monte_carlo.py
single_trajectory(psi0, t_max, dt=0.01, seed=None)
Simulate a single quantum trajectory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
t_max
|
float
|
Maximum evolution time |
required |
dt
|
float
|
Time step |
0.01
|
seed
|
Optional[int]
|
Random seed for reproducibility |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict[str, Any]
|
Trajectory results with states, jump times, etc. |
Example
result = qt.single_trajectory(zero(), t_max=5.0, dt=0.01) print(result['n_jumps'])
Source code in psiqit\dynamics\monte_carlo.py
run(psi0, t_max, dt=0.01, n_trajectories=100, seeds=None, progress=True)
Run multiple quantum trajectories and average results
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
t_max
|
float
|
Maximum evolution time |
required |
dt
|
float
|
Time step |
0.01
|
n_trajectories
|
int
|
Number of trajectories |
100
|
seeds
|
Optional[List[int]]
|
List of random seeds for each trajectory |
None
|
progress
|
bool
|
Show progress bar |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
MonteCarloResult |
MonteCarloResult
|
Averaged results |
Example
result = qt.run(zero(), t_max=10.0, dt=0.01, n_trajectories=100) print(result.final_avg_state)
Source code in psiqit\dynamics\monte_carlo.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | |
compute_steady_state_mc(psi0, t_max, dt=0.01, n_trajectories=100, averaging_start=0.0)
Compute steady state using Monte Carlo wavefunction method
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
t_max
|
float
|
Maximum evolution time |
required |
dt
|
float
|
Time step |
0.01
|
n_trajectories
|
int
|
Number of trajectories |
100
|
averaging_start
|
float
|
Time to start averaging (to skip transient) |
0.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Steady state density matrix |
Source code in psiqit\dynamics\monte_carlo.py
WaveFunction
Wavefunction representation for quantum mechanics
Represents a wavefunction ψ(x, t) with methods for computing expectation values, uncertainties, and probability densities.
Example
import numpy as np x = np.linspace(-5, 5, 100) psi = np.exp(-x**2/2) / np.sqrt(np.sqrt(np.pi)) wf = WaveFunction(x, psi) print(wf.expectation_x()) # 0.0 print(wf.uncertainty_x()) # 0.707
Source code in psiqit\dynamics\schrodinger.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
__init__(x, psi, t=0.0)
Initialize a wavefunction
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Spatial grid |
required |
psi
|
ndarray
|
Wavefunction values (complex) |
required |
t
|
float
|
Time (default: 0.0) |
0.0
|
Source code in psiqit\dynamics\schrodinger.py
probability_density()
Compute the probability density |ψ(x)|²
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Probability density |
normalize()
Normalize the wavefunction so that ∫|ψ|² dx = 1
Returns:
| Name | Type | Description |
|---|---|---|
WaveFunction |
WaveFunction
|
Self for chaining |
Source code in psiqit\dynamics\schrodinger.py
expectation_x()
Compute expectation value of position ⟨x⟩
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
⟨x⟩ |
expectation_p(hbar=1.0)
Compute expectation value of momentum ⟨p⟩
⟨p⟩ = -iħ ∫ ψ* ∂ψ/∂x dx
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
⟨p⟩ |
Source code in psiqit\dynamics\schrodinger.py
expectation_x2()
Compute expectation value of x² ⟨x²⟩
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
⟨x²⟩ |
expectation_p2(hbar=1.0)
Compute expectation value of p² ⟨p²⟩
⟨p²⟩ = -ħ² ∫ ψ* ∂²ψ/∂x² dx
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
⟨p²⟩ |
Source code in psiqit\dynamics\schrodinger.py
uncertainty_x()
Compute uncertainty in position Δx = √(⟨x²⟩ - ⟨x⟩²)
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Δx |
uncertainty_p(hbar=1.0)
Compute uncertainty in momentum Δp = √(⟨p²⟩ - ⟨p⟩²)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Δp |
Source code in psiqit\dynamics\schrodinger.py
uncertainty_product(hbar=1.0)
Compute the product of uncertainties Δx * Δp
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Δx * Δp (should be >= ħ/2) |
Source code in psiqit\dynamics\schrodinger.py
kinetic_energy(mass=1.0, hbar=1.0)
Compute kinetic energy ⟨p²⟩/(2m)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mass
|
float
|
Particle mass |
1.0
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Kinetic energy |
Source code in psiqit\dynamics\schrodinger.py
potential_energy(potential)
Compute potential energy ⟨V(x)⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
potential
|
Callable[[float], float]
|
Potential function V(x) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Potential energy |
Source code in psiqit\dynamics\schrodinger.py
total_energy(potential, mass=1.0, hbar=1.0)
Compute total energy ⟨H⟩ = ⟨p²⟩/(2m) + ⟨V(x)⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
potential
|
Callable[[float], float]
|
Potential function V(x) |
required |
mass
|
float
|
Particle mass |
1.0
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Total energy |
Source code in psiqit\dynamics\schrodinger.py
expectation_value(operator)
Compute expectation value of a general operator
⟨O⟩ = ∫ ψ* O ψ dx
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operator
|
Callable[[ndarray], ndarray]
|
Operator function acting on wavefunction |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Expectation value |
Source code in psiqit\dynamics\schrodinger.py
EvolutionResult
dataclass
Result container for time evolution
Attributes:
| Name | Type | Description |
|---|---|---|
times |
ndarray
|
Time points |
states |
List[Ket]
|
List of quantum states at each time |
fidelities |
List[float]
|
List of fidelities with initial state |
success |
bool
|
Whether evolution was successful |
message |
str
|
Additional information |
n_steps |
int
|
Number of time steps |
final_state |
Optional[Ket]
|
Final state |
initial_state |
Optional[Ket]
|
Initial state |
method |
str
|
Method used for evolution |
Source code in psiqit\dynamics\time_evolution.py
__post_init__()
get_state_at_time(index)
get_final_state()
get_fidelity_history()
get_population(basis_state)
Get population of a basis state over time
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis_state
|
int
|
Index of the basis state |
required |
Returns:
| Type | Description |
|---|---|
List[float]
|
List[float]: Population values over time |
Source code in psiqit\dynamics\time_evolution.py
TrotterEvolution
Trotter-Suzuki decomposition for quantum time evolution
Implements the Trotter-Suzuki approximation: e^{-iHt} ≈ (e^{-iH₁t/n} e^{-iH₂t/n} ... e^{-iH_kt/n})^n
Example
from psiqit.quantum import pauli_x, pauli_z, zero H = pauli_x() + pauli_z() trotter = TrotterEvolution(H, n_steps=100, decomposition='first') state = trotter.evolve(zero(), t=1.0) print(state)
Source code in psiqit\dynamics\time_evolution.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
__init__(hamiltonian, n_steps=100, decomposition='first', hbar=1.0)
Initialize Trotter evolution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hamiltonian
|
Operator
|
Hamiltonian operator (can be sum of terms) |
required |
n_steps
|
int
|
Number of Trotter steps |
100
|
decomposition
|
str
|
'first' (first-order) or 'second' (second-order) |
'first'
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Example
H = pauli_x() + pauli_z() trotter = TrotterEvolution(H, n_steps=100, decomposition='first')
Source code in psiqit\dynamics\time_evolution.py
evolve(psi0, t)
Evolve a state using Trotter decomposition
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
t
|
float
|
Evolution time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Ket |
Ket
|
Evolved state |
Example
state = trotter.evolve(zero(), t=1.0)
Source code in psiqit\dynamics\time_evolution.py
evolve_sequence(psi0, times)
Evolve a state at multiple time points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
times
|
ndarray
|
Array of time points |
required |
Returns:
| Name | Type | Description |
|---|---|---|
EvolutionResult |
EvolutionResult
|
Evolution results |
Source code in psiqit\dynamics\time_evolution.py
ChebyshevEvolution
Chebyshev polynomial expansion for quantum time evolution
Implements the Chebyshev polynomial method for time evolution: e^{-iHt} ψ ≈ Σ c_n T_n(H) ψ
Example
from psiqit.quantum import pauli_x, pauli_z, zero H = pauli_x() + pauli_z() cheb = ChebyshevEvolution(H, order=50) state = cheb.evolve(zero(), t=1.0) print(state)
Source code in psiqit\dynamics\time_evolution.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
__init__(hamiltonian, order=50, hbar=1.0)
Initialize Chebyshev evolution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hamiltonian
|
Operator
|
Hamiltonian operator |
required |
order
|
int
|
Chebyshev polynomial order |
50
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Example
H = pauli_x() + pauli_z() cheb = ChebyshevEvolution(H, order=50)
Source code in psiqit\dynamics\time_evolution.py
evolve(psi0, t)
Evolve a state using Chebyshev polynomial expansion
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
t
|
float
|
Evolution time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Ket |
Ket
|
Evolved state |
Example
state = cheb.evolve(zero(), t=1.0)
Source code in psiqit\dynamics\time_evolution.py
evolve_sequence(psi0, times)
Evolve a state at multiple time points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
times
|
ndarray
|
Array of time points |
required |
Returns:
| Name | Type | Description |
|---|---|---|
EvolutionResult |
EvolutionResult
|
Evolution results |
Source code in psiqit\dynamics\time_evolution.py
KrylovEvolution
Krylov subspace method for quantum time evolution
Implements the Krylov subspace method for time evolution: Builds a Krylov subspace and projects the Hamiltonian, then evolves in the reduced subspace.
Example
from psiqit.quantum import pauli_x, pauli_z, zero H = pauli_x() + pauli_z() krylov = KrylovEvolution(H, krylov_dim=20) state = krylov.evolve(zero(), t=1.0) print(state)
Source code in psiqit\dynamics\time_evolution.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 | |
__init__(hamiltonian, krylov_dim=20, hbar=1.0)
Initialize Krylov evolution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hamiltonian
|
Operator
|
Hamiltonian operator |
required |
krylov_dim
|
int
|
Krylov subspace dimension |
20
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Example
H = pauli_x() + pauli_z() krylov = KrylovEvolution(H, krylov_dim=20)
Source code in psiqit\dynamics\time_evolution.py
evolve(psi0, t)
Evolve a state using Krylov subspace method
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
t
|
float
|
Evolution time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Ket |
Ket
|
Evolved state |
Example
state = krylov.evolve(zero(), t=1.0)
Source code in psiqit\dynamics\time_evolution.py
evolve_sequence(psi0, times)
Evolve a state at multiple time points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
Ket
|
Initial state |
required |
times
|
ndarray
|
Array of time points |
required |
Returns:
| Name | Type | Description |
|---|---|---|
EvolutionResult |
EvolutionResult
|
Evolution results |
Source code in psiqit\dynamics\time_evolution.py
ising_hamiltonian(J, h=None)
Create an Ising model Hamiltonian
H = Σ J_ij Z_i Z_j + Σ h_i Z_i
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
J
|
Dict[Tuple[int, int], float]
|
Coupling strengths {(i, j): J_ij} |
required |
h
|
Dict[int, float]
|
Local fields {i: h_i} |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict[str, float]
|
Hamiltonian as Pauli strings |
Example
J = {(0, 1): -1.0} # Ferromagnetic coupling h = {0: 0.5, 1: -0.5} # Local fields H = ising_hamiltonian(J, h)
H = -Z0Z1 + 0.5Z0 - 0.5Z1
Source code in psiqit\dynamics\adiabatic.py
maxcut_hamiltonian(edges)
Create MaxCut problem Hamiltonian
H = -Σ_{(i,j)∈E} Z_i Z_j
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
List[Tuple[int, int]]
|
List of edges in the graph |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict[str, float]
|
Hamiltonian as Pauli strings |
Example
edges = [(0, 1), (1, 2), (0, 2)] # Triangle graph H = maxcut_hamiltonian(edges)
H = -Z0Z1 - Z1Z2 - Z0Z2
Source code in psiqit\dynamics\adiabatic.py
qubo_to_hamiltonian(qubo, offset=0.0)
Convert QUBO (Quadratic Unconstrained Binary Optimization) to Ising Hamiltonian
QUBO: minimize Σ Q_ij x_i x_j, x_i ∈ {0, 1} Ising: H = Σ J_ij Z_i Z_j + Σ h_i Z_i + constant
Mapping: x_i = (1 - Z_i)/2
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qubo
|
Dict[Tuple[int, int], float]
|
QUBO matrix {(i, j): Q_ij} |
required |
offset
|
float
|
Constant offset |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict[str, float]
|
Hamiltonian as Pauli strings |
Example
Q = {(0, 0): -1.0, (1, 1): -1.0, (0, 1): 2.0} H = qubo_to_hamiltonian(Q)
Source code in psiqit\dynamics\adiabatic.py
harmonic_oscillator_hamiltonian(omega=1.0, mass=1.0, hbar=1.0)
Create harmonic oscillator Hamiltonian in position basis
H = (p²/2m) + (1/2)mω²x²
This returns a simplified version using Pauli operators
for a two-level approximation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega
|
float
|
Angular frequency |
1.0
|
mass
|
float
|
Mass |
1.0
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Harmonic oscillator Hamiltonian |
Example
H = harmonic_oscillator_hamiltonian(omega=1.0) print(H.is_hermitian) # True
Source code in psiqit\dynamics\heisenberg.py
spin_hamiltonian(J, B=0.0, n_spins=2)
Create spin Hamiltonian (Heisenberg model)
H = -J Σ σ_i · σ_j - B Σ σ_z^i
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
J
|
float
|
Exchange coupling |
required |
B
|
float
|
External magnetic field |
0.0
|
n_spins
|
int
|
Number of spins |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Spin Hamiltonian |
Example
H = spin_hamiltonian(J=1.0, B=0.5, n_spins=2) print(H.dim) # 4
Source code in psiqit\dynamics\heisenberg.py
two_level_hamiltonian(delta, omega)
Create a two-level Hamiltonian
H = (δ/2) Z + (Ω/2) X
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delta
|
float
|
Detuning (energy splitting) |
required |
omega
|
float
|
Rabi frequency (coupling) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Two-level Hamiltonian |
Example
H = two_level_hamiltonian(delta=1.0, omega=0.5) print(H.is_hermitian) # True
Source code in psiqit\dynamics\heisenberg.py
create_interaction_hamiltonian(coupling, operator_A, operator_B)
Create an interaction Hamiltonian of the form V = g * A ⊗ B
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coupling
|
float
|
Coupling strength g |
required |
operator_A
|
Operator
|
Operator acting on system A |
required |
operator_B
|
Operator
|
Operator acting on system B |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Interaction Hamiltonian |
Example
from psiqit.quantum import pauli_x, pauli_z V = create_interaction_hamiltonian(0.5, pauli_x(), pauli_z()) print(V.name)
Source code in psiqit\dynamics\interaction.py
rotating_frame(H0, V, omega, t)
Transform to a rotating frame
In the rotating frame, the Hamiltonian becomes: H_rot = e^{iωt/ħ} H e^{-iωt/ħ} - ħω I
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
H0
|
Operator
|
Free Hamiltonian |
required |
V
|
Operator
|
Interaction Hamiltonian |
required |
omega
|
float
|
Rotation frequency |
required |
t
|
float
|
Time |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Hamiltonian in the rotating frame |
Source code in psiqit\dynamics\interaction.py
thermal_state(H, beta, hbar=1.0)
Create a thermal (Gibbs) state
ρ = e^{-βH} / Tr(e^{-βH})
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
H
|
Operator
|
Hamiltonian |
required |
beta
|
float
|
Inverse temperature (1/k_B T) |
required |
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Thermal density matrix |
Example
from psiqit.quantum import pauli_z rho = thermal_state(pauli_z(), beta=1.0) print(np.trace(rho)) # 1.0
Source code in psiqit\dynamics\lindblad.py
dephasing_channel(rho, gamma, dt)
Apply a dephasing channel to a density matrix
ρ → (1 - p)ρ + p Z ρ Z
where p = (1 - e^{-γt})/2
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
ndarray
|
Density matrix |
required |
gamma
|
float
|
Dephasing rate |
required |
dt
|
float
|
Time step |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Dephased density matrix |
Source code in psiqit\dynamics\lindblad.py
amplitude_damping_channel(rho, gamma, dt)
Apply an amplitude damping channel to a density matrix
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
ndarray
|
Density matrix |
required |
gamma
|
float
|
Damping rate |
required |
dt
|
float
|
Time step |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Damped density matrix |
Source code in psiqit\dynamics\lindblad.py
jump_operator(L, gamma=1.0)
Create a jump operator with rate
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
L
|
Operator
|
Collapse operator |
required |
gamma
|
float
|
Decay rate |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Jump operator with rate |
Source code in psiqit\dynamics\monte_carlo.py
photon_loss_channel(gamma=0.1)
Create a photon loss collapse operator
L = √γ a (annihilation operator)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gamma
|
float
|
Loss rate |
0.1
|
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Photon loss collapse operator |
Source code in psiqit\dynamics\monte_carlo.py
dephasing_operator(gamma=0.1)
Create a dephasing collapse operator
L = √γ Z
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gamma
|
float
|
Dephasing rate |
0.1
|
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Dephasing collapse operator |
Source code in psiqit\dynamics\monte_carlo.py
amplitude_damping_operator(gamma=0.1)
Create an amplitude damping collapse operator
L = √γ σ_-
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gamma
|
float
|
Damping rate |
0.1
|
Returns:
| Name | Type | Description |
|---|---|---|
Operator |
Operator
|
Amplitude damping collapse operator |
Source code in psiqit\dynamics\monte_carlo.py
solve_time_independent(potential, x_range, n_points=1000, n_states=5, mass=1.0, hbar=1.0)
Solve the time-independent Schrödinger equation numerically
-ħ²/(2m) d²ψ/dx² + V(x)ψ = Eψ
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
potential
|
Callable[[float], float]
|
Potential function V(x) |
required |
x_range
|
Tuple[float, float]
|
(x_min, x_max) |
required |
n_points
|
int
|
Number of grid points |
1000
|
n_states
|
int
|
Number of eigenstates to compute |
5
|
mass
|
float
|
Particle mass |
1.0
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Tuple |
Tuple[ndarray, List[ndarray]]
|
(eigenvalues, eigenstates) |
Example
def harmonic(x): return 0.5 * x**2 energies, states = solve_time_independent(harmonic, (-5, 5), n_points=500, n_states=5) print(energies) # [0.5, 1.5, 2.5, ...]
Source code in psiqit\dynamics\schrodinger.py
solve_time_dependent(psi0, x, potential, t_max, dt=0.001, mass=1.0, hbar=1.0, method='split', save_every=10)
Solve the time-dependent Schrödinger equation
iħ ∂ψ/∂t = -ħ²/(2m) ∂²ψ/∂x² + V(x,t)ψ
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
ndarray
|
Initial wavefunction |
required |
x
|
ndarray
|
Spatial grid |
required |
potential
|
Callable[[float, float], float]
|
Potential function V(x, t) |
required |
t_max
|
float
|
Maximum time |
required |
dt
|
float
|
Time step |
0.001
|
mass
|
float
|
Particle mass |
1.0
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
method
|
str
|
'split' (split-step Fourier) or 'crank' (Crank-Nicolson) |
'split'
|
save_every
|
int
|
Save state every N steps |
10
|
Returns:
| Type | Description |
|---|---|
List[WaveFunction]
|
List[WaveFunction]: Time evolution results |
Example
def harmonic(x, t): return 0.5 * x2 psi0 = np.exp(-x2/2) / np.sqrt(np.sqrt(np.pi)) results = solve_time_dependent(psi0, x, harmonic, t_max=5.0, dt=0.01) print(len(results)) # Number of saved states
Source code in psiqit\dynamics\schrodinger.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
time_evolution_operator(H, t, hbar=1.0)
Compute the time evolution operator U(t) = e^{-iHt/ħ}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
H
|
ndarray
|
Hamiltonian matrix |
required |
t
|
float
|
Time |
required |
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Time evolution operator |
Example
H = np.array([[1, 0], [0, -1]]) U = time_evolution_operator(H, np.pi/2) print(U) # [[e^{-iπ/2}, 0], [0, e^{iπ/2}]]
Source code in psiqit\dynamics\schrodinger.py
propagate_state(psi0, H, t, hbar=1.0)
Propagate a state using the time evolution operator
|ψ(t)⟩ = e^{-iHt/ħ} |ψ(0)⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi0
|
ndarray
|
Initial state vector |
required |
H
|
ndarray
|
Hamiltonian matrix |
required |
t
|
float
|
Time |
required |
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Propagated state |
Example
psi0 = np.array([1, 0]) H = np.array([[0, 1], [1, 0]]) psi = propagate_state(psi0, H, np.pi/2) print(psi) # Rotated state
Source code in psiqit\dynamics\schrodinger.py
expectation_value(psi, operator, dx)
Compute expectation value ⟨ψ|O|ψ⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi
|
ndarray
|
Wavefunction |
required |
operator
|
ndarray
|
Operator matrix |
required |
dx
|
float
|
Grid spacing |
required |
Returns:
| Name | Type | Description |
|---|---|---|
complex |
complex
|
Expectation value |
Source code in psiqit\dynamics\schrodinger.py
uncertainty_relation(psi, x_operator, p_operator, hbar=1.0, dx=0.01)
Compute uncertainties and verify Heisenberg uncertainty relation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi
|
ndarray
|
Wavefunction |
required |
x_operator
|
ndarray
|
Position operator |
required |
p_operator
|
ndarray
|
Momentum operator |
required |
hbar
|
float
|
Reduced Planck constant |
1.0
|
dx
|
float
|
Grid spacing |
0.01
|
Returns:
| Name | Type | Description |
|---|---|---|
Tuple |
Tuple[float, float, float]
|
(Δx, Δp, Δx*Δp) |
Example
from psiqit.dynamics import gaussian_wavepacket x = np.linspace(-5, 5, 100) psi = gaussian_wavepacket(x, sigma=1.0) dx, dp, product = uncertainty_relation(psi, x_op, p_op) print(product) # >= ħ/2
Source code in psiqit\dynamics\schrodinger.py
gaussian_wavepacket(x, x0=0.0, sigma=1.0, k0=0.0, phase=0.0)
Create a Gaussian wavepacket
ψ(x) = (1/(2πσ²))^(1/4) * exp(-(x-x0)²/(4σ²)) * e^{ik0x}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Spatial grid |
required |
x0
|
float
|
Center position |
0.0
|
sigma
|
float
|
Width parameter |
1.0
|
k0
|
float
|
Momentum (wave number) |
0.0
|
phase
|
float
|
Global phase |
0.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Wavefunction |
Example
x = np.linspace(-10, 10, 100) psi = gaussian_wavepacket(x, x0=0, sigma=1.0, k0=2.0)
Source code in psiqit\dynamics\schrodinger.py
plane_wave(x, k, phase=0.0)
Create a plane wave
ψ(x) = e^{i(kx + φ)}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Spatial grid |
required |
k
|
float
|
Wave number |
required |
phase
|
float
|
Global phase |
0.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Wavefunction |
Example
x = np.linspace(-10, 10, 100) psi = plane_wave(x, k=1.0)
Source code in psiqit\dynamics\schrodinger.py
square_well_ground_state(x, L)
Create the ground state wavefunction of an infinite square well
ψ(x) = √(2/L) sin(πx/L) for 0 < x < L
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Spatial grid |
required |
L
|
float
|
Well width |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Wavefunction |
Example
x = np.linspace(0, 1, 100) psi = square_well_ground_state(x, L=1.0)
Source code in psiqit\dynamics\schrodinger.py
harmonic_oscillator_state(x, n, mass=1.0, omega=1.0, hbar=1.0)
Create harmonic oscillator eigenstate
ψ_n(x) = (1/√(2^n n!)) (mω/πħ)^(1/4) * e^(-mωx²/2ħ) * H_n(√(mω/ħ) x)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Spatial grid |
required |
n
|
int
|
Quantum number |
required |
mass
|
float
|
Particle mass |
1.0
|
omega
|
float
|
Angular frequency |
1.0
|
hbar
|
float
|
Reduced Planck constant |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Wavefunction |
Example
x = np.linspace(-5, 5, 100) psi_2 = harmonic_oscillator_state(x, n=2)
Source code in psiqit\dynamics\schrodinger.py
infinite_well_state(x, n, L)
Create the n-th state of an infinite square well
ψ_n(x) = √(2/L) sin(nπx/L) for 0 < x < L
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Spatial grid |
required |
n
|
int
|
Quantum number (1, 2, 3, ...) |
required |
L
|
float
|
Well width |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Wavefunction |
Example
x = np.linspace(0, 1, 100) psi_2 = infinite_well_state(x, n=2, L=1.0)
Source code in psiqit\dynamics\schrodinger.py
info()
Get information about the dynamics module
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Module information |
Source code in psiqit\dynamics\__init__.py
test()
Run basic tests for the dynamics module
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Test results |
Source code in psiqit\dynamics\__init__.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |