netket.experimental.TDVP#
- class netket.experimental.TDVP[source]#
Bases:
TDVPBaseDriverVariational time evolution based on the time-dependent variational principle which, when used with Monte Carlo sampling via
netket.vqs.MCState, is the time-dependent VMC (t-VMC) method.- Inheritance

- __init__(operator, variational_state, ode_solver, *, t0=0.0, propagation_type='real', qgt=None, linear_solver=<function pinv_smooth>, linear_solver_restart=False, error_norm='euclidean')[source]#
Initializes the time evolution driver.
- Parameters:
operator (
AbstractOperator) – The generator of the dynamics (Hamiltonian for pure states, Lindbladian for density operators).variational_state (
VariationalState) – The variational state.ode_solver (
AbstractSolver) – Solving algorithm used the ODE.t0 (
float) – Initial time at the start of the time evolution.propagation_type (
str) – Determines the equation of motion: “real” for the real-time Schrödinger equation (SE), “imag” for the imaginary-time SE.qgt (
LinearOperator|None) – The QGT specification.linear_solver – The solver for solving the linear system determining the time evolution. This must be a jax-jittable function
f(A,b) -> xthat accepts a Matrix-like, Linear Operator PyTree object \(A\) and a vector-like PyTree \(b\) and returns the PyTree \(x\) solving the system \(Ax=b\). Defaults tonk.optimizer.solver.pinv_smooth()with the default svd threshold of 1e-10. To change the svd threshold you can usefunctools.partial()as follows:functools.partial(nk.optimizer.solver.pinv_smooth, rtol_smooth=1e-5).linear_solver_restart (
bool) – If False (default), the last solution of the linear system is used as initial value in subsequent steps.error_norm (
str|Callable) – Norm function used to calculate the error with adaptive integrators. Can be either “euclidean” for the standard L2 vector norm \(w^\dagger w\), “maximum” for the maximum norm \(\max_i |w_i|\) or “qgt”, in which case the scalar product induced by the QGT \(S\) is used to compute the norm \(\Vert w \Vert^2_S = w^\dagger S w\) as suggested in PRL 125, 100503 (2020). Additionally, it possible to pass a custom function with signaturenorm(x: PyTree) -> floatwhich maps a PyTree of parametersxto the corresponding norm. Note that norm is used in jax.jit-compiled code.
- Attributes
- dt#
Current time step.
- error_norm#
Returns the Callable function computing the error of the norm used for adaptive timestepping by the integrator.
Can be set to a Callable accepting a pytree and returning a real scalar, or a string between ‘euclidean’, ‘maximum’ or ‘qgt’.
- generator#
The generator of the dynamics as a function with signature generator(t: float) -> AbstractOperator
- integrator#
The underlying integrator which computes the time steps.
- ode_solver#
The underlying solver which solves the ODE at each time step.
- state#
Returns the machine that is optimized by this driver.
- step_count#
Returns a monotonic integer labelling all the steps performed by this driver. This can be used, for example, to identify the line in a log file.
- step_value#
- t#
Current time.
- t0#
The initial time set when the driver was created.
- Methods
- compute_loss_and_update()[source]#
Attempts a step of the integrator from the current time, without changing the time and the parameters of the driver.
Returns the value of the generator at the start of the step, and the integrator after the step, which
update_parameters()applies.
- estimate(observables, fullsum=False)[source]#
Return MCMC statistics for the expectation value of observables in the current state of the driver.
- Parameters:
observables – A pytree of operators for which statistics should be computed.
fullsum (bool)
- Returns:
A pytree of the same structure as the input, containing MCMC statistics for the corresponding operators as leaves.
- ode(t=None, w=None)[source]#
Evaluates the TDVP equation of motion
\[G(w) \dot w = \gamma F(w, t)\]where \(G(w)\) is the QGT, \(F(w, t)\) the gradient of
self.generatorand \(\gamma\) one of \(\gamma = -1\) (imaginary-time dynamics forMCState), \(\gamma = -i\) (real-time dynamics forMCState), or \(\gamma = 1\) (real-time dynamics forMCMixedState).- Parameters:
t – Time (defaults to
self.t).w – Variational parameters (defaults to
self.state.parameters).
- Returns:
The time-derivative \(\dot w\).
- replace(**kwargs)[source]#
Replace the values of the fields of the object with the values of the keyword arguments. If the object is a dataclass, dataclasses.replace will be used. Otherwise, a new object will be created with the same type as the original object.
- Return type:
P- Parameters:
self (P)
kwargs (Any)
- reset()[source]#
Deprecated since version 3.22: Use
reset_step()to reset the sampler state at the beginning of a step. Note that the oldreset()also resetstep_countto 0; this behaviour is no longer supported.
- reset_step(hard=False)[source]#
Resets the state of the driver at the beginning of a new step.
This method is called at the beginning of every step in the optimization.
- Parameters:
hard (
bool) – If True, the reset is a hard reset, resulting in a complete resampling even if resample_fractionNone. (is not)
- run(T, out=(), obs=None, *, tstops=None, show_progress=True, callback=None, timeit=False)[source]#
Runs the time evolution.
By default uses
netket.logging.JsonLog. To know about the output format check it’s documentation. The logger object is also returned at the end of this function so that you can inspect the results without reading the json output.- Parameters:
T – The integration time period.
out – A logger object, or an iterable of loggers, to be used to store simulation log and data. If this argument is a string, it will be used as output prefix for the standard JSON logger.
obs – An iterable containing the observables that should be computed.
tstops – A sequence of stopping times, each within the interval
[self.t0, self.t0 + T], at which the driver will stop and perform estimation of observables, logging, and execute the callback function. By default, a stop is performed after each time step (at potentially varying step size if an adaptive integrator is used).show_progress – If true displays a progress bar (default=True)
callback – Callable or list of callable callback functions to be executed at each stopping time, with the time as their first argument. Like the loggers and the observables, they are not called at the other time steps.
AbstractCallbackobjects are instead called at every time step, with the step count, as in the other drivers.timeit (
bool) – If True, provide timing information.
- update_parameters(dp)[source]#
Moves the time and the parameters to the end of the step computed by
compute_loss_and_update().- Parameters:
dp – the integrator after the step.