Skip to content

Commit 2dbdfba

Browse files
committed
new docstring
1 parent 4d656cb commit 2dbdfba

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

tensorcircuit/timeevol.py

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -493,17 +493,15 @@ def ode_evol_local(
493493
) -> Tensor:
494494
"""
495495
ODE-based time evolution for a time-dependent Hamiltonian acting on a subsystem of qubits.
496-
497496
This function solves the time-dependent Schrodinger equation using numerical ODE integration.
498497
The Hamiltonian is applied only to a specific subset of qubits (indices) in the system.
499-
500-
The ode_backend parameter defaults to 'jaxode' (which uses `jax.experimental.ode.odeint` with a default solver
501-
of 'Dopri5');if set to 'diffrax', it uses `diffrax.diffeqsolve` instead (with a default solver of 'Tsit5').
498+
The ode_backend parameter defaults to 'jaxode' (which uses ``jax.experimental.ode.odeint`` with a default solver
499+
of 'Dopri5'); if set to 'diffrax', it uses ``diffrax.diffeqsolve`` instead (with a default solver of 'Tsit5').
502500
503501
Note: This function currently only supports the JAX backend.
504502
505503
:param hamiltonian: A function that returns a dense Hamiltonian matrix for the specified
506-
subsystem size. The function signature should be hamiltonian(time, *args) -> Tensor.
504+
subsystem size. The function signature should be ``hamiltonian(time, *args) -> Tensor``.
507505
:type hamiltonian: Callable[..., Tensor]
508506
:param initial_state: The initial quantum state vector of the full system.
509507
:type initial_state: Tensor
@@ -515,15 +513,16 @@ def ode_evol_local(
515513
:type callback: Optional[Callable[..., Tensor]]
516514
:param args: Additional arguments to pass to the Hamiltonian function.
517515
:param solver_kws: Additional keyword arguments to pass to the ODE solver.
518-
ode_backend='jaxode'(default) uses `jax.experimental.ode.odeint`; ode_backend='diffrax'
519-
uses `diffrax.diffeqsolve`.
520-
rtol (default: 1e-12) and atol (default: 1e-12) are used to determine how accurately you would
521-
like the numerical approximation to your equation.
522-
The solver parameter accepts one of {'Tsit5' (default), 'Dopri5', 'Dopri8', 'Kvaerno5'}
523-
and only works when ode_backend='diffrax'.
524-
dt0 (default: 0.01) specifies the initial step size and only works when ode_backend='diffrax'.
525-
max_steps (default: 10000) The maximum number of steps to take before quitting the computation
526-
unconditionally and only works when ode_backend='diffrax'.
516+
- ode_backend='jaxode'(default) uses ``jax.experimental.ode.odeint``; ode_backend='diffrax'
517+
uses ``diffrax.diffeqsolve``.
518+
- rtol (default: 1e-12) and atol (default: 1e-12) are used to determine how accurately you would
519+
like the numerical approximation to your equation.
520+
- The solver parameter accepts one of {'Tsit5' (default), 'Dopri5', 'Dopri8', 'Kvaerno5'}
521+
and only works when ode_backend='diffrax'.
522+
- dt0 (default: 0.01) specifies the initial step size and only works when ode_backend='diffrax'.
523+
- max_steps (default: 10000) The maximum number of steps to take before quitting the computation
524+
unconditionally and only works when ode_backend='diffrax'.
525+
527526
:return: Evolved quantum states at the specified time points. If callback is provided,
528527
returns the callback results; otherwise returns the state vectors.
529528
:rtype: Tensor
@@ -566,18 +565,16 @@ def ode_evol_global(
566565
) -> Tensor:
567566
"""
568567
ODE-based time evolution for a time-dependent Hamiltonian acting on the entire system.
569-
570568
This function solves the time-dependent Schrodinger equation using numerical ODE integration.
571-
The Hamiltonian is applied to the full system and should be provided in sparse matrix format
572-
for efficiency.
573-
574-
The ode_backend parameter defaults to 'jaxode' (which uses `jax.experimental.ode.odeint` with a default solver
575-
of 'Dopri5');if set to 'diffrax', it uses `diffrax.diffeqsolve` instead (with a default solver of 'Tsit5').
569+
The Hamiltonian is applied to the full system and should be provided in sparse matrix
570+
format for efficiency.
571+
The ode_backend parameter defaults to 'jaxode' (which uses ``jax.experimental.ode.odeint`` with a default solver
572+
of 'Dopri5'); if set to 'diffrax', it uses ``diffrax.diffeqsolve`` instead (with a default solver of 'Tsit5').
576573
577574
Note: This function currently only supports the JAX backend.
578575
579576
:param hamiltonian: A function that returns a sparse Hamiltonian matrix for the full system.
580-
The function signature should be hamiltonian(time, *args) -> Tensor.
577+
The function signature should be ``hamiltonian(time, *args) -> Tensor``.
581578
:type hamiltonian: Callable[..., Tensor]
582579
:param initial_state: The initial quantum state vector.
583580
:type initial_state: Tensor
@@ -588,15 +585,16 @@ def ode_evol_global(
588585
:param args: Additional arguments to pass to the Hamiltonian function.
589586
:type args: tuple | list
590587
:param solver_kws: Additional keyword arguments to pass to the ODE solver.
591-
ode_backend='jaxode'(default) uses `jax.experimental.ode.odeint`; ode_backend='diffrax'
592-
uses `diffrax.diffeqsolve`.
593-
rtol (default: 1e-12) and atol (default: 1e-12) are used to determine how accurately you would
594-
like the numerical approximation to your equation.
595-
The solver parameter accepts one of {'Tsit5' (default), 'Dopri5', 'Dopri8', 'Kvaerno5'}
596-
and only works when ode_backend='diffrax'.
597-
dt0 (default: 0.01) specifies the initial step size and only works when ode_backend='diffrax'.
598-
max_steps (default: 10000) The maximum number of steps to take before quitting the computation
599-
unconditionally and only works when ode_backend='diffrax'.
588+
- ode_backend='jaxode'(default) uses ``jax.experimental.ode.odeint``; ode_backend='diffrax'
589+
uses ``diffrax.diffeqsolve``.
590+
- rtol (default: 1e-12) and atol (default: 1e-12) are used to determine how accurately you would
591+
like the numerical approximation to your equation.
592+
- The solver parameter accepts one of {'Tsit5' (default), 'Dopri5', 'Dopri8', 'Kvaerno5'}
593+
and only works when ode_backend='diffrax'.
594+
- dt0 (default: 0.01) specifies the initial step size and only works when ode_backend='diffrax'.
595+
- max_steps (default: 10000) The maximum number of steps to take before quitting the computation
596+
unconditionally and only works when ode_backend='diffrax'.
597+
600598
:type solver_kws: dict
601599
:return: Evolved quantum states at the specified time points. If callback is provided,
602600
returns the callback results; otherwise returns the state vectors.
@@ -632,7 +630,7 @@ def evol_local(
632630
:param index: qubit sites to evolve
633631
:type index: Sequence[int]
634632
:param h_fun: h_fun should return a dense Hamiltonian matrix
635-
with input arguments time and *args
633+
with input arguments ``time`` and ``*args``
636634
:type h_fun: Callable[..., Tensor]
637635
:param t: evolution time
638636
:type t: float
@@ -658,7 +656,7 @@ def evol_global(
658656
:param c: _description_
659657
:type c: Circuit
660658
:param h_fun: h_fun should return a **SPARSE** Hamiltonian matrix
661-
with input arguments time and *args
659+
with input arguments ``time`` and ``*args``
662660
:type h_fun: Callable[..., Tensor]
663661
:param t: _description_
664662
:type t: float

0 commit comments

Comments
 (0)