netket.experimental.TDVP#

class netket.experimental.TDVP[source]#

Bases: TDVPBaseDriver

Variational 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.

Note

This TDVP Driver uses the time-integrators from the nkx.dynamics module, which are automatically executed under a jax.jit context.

When running computations on GPU, this can lead to infinite hangs or extremely long compilation times. In those cases, you might try setting the configuration variable nk.config.netket_experimental_disable_ode_jit = True to mitigate those issues.

Inheritance
Inheritance diagram of netket.experimental.TDVP
__init__(operator, variational_state, ode_solver=None, *, t0=0.0, propagation_type='real', integrator=None, 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) – 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) -> x that 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 to nk.optimizer.solver.pinv_smooth() with the default svd threshold of 1e-10. To change the svd threshold you can use functools.partial() as follows: functools.partial(nk.optimizer.solver.pinv_smooth, rcond_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 signature norm(x: PyTree) -> float which maps a PyTree of parameters x to the corresponding norm. Note that norm is used in jax.jit-compiled code.

  • integrator (AbstractSolver)

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.

optimizer#

The optimizer used to update the parameters at every iteration.

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
advance(T)[source]#

Advance the time propagation by T to self.t + T.

Parameters:

T (float) – Length of the integration interval.

estimate(observables)[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.

Returns:

A pytree of the same structure as the input, containing MCMC statistics for the corresponding operators as leaves.

iter(T, *, tstops=None)[source]#

Returns a generator which advances the time evolution for an interval of length T, stopping at tstops.

Parameters:
  • T (float) – Length of the integration interval.

  • tstops (Sequence[float] | None) – A sequence of stopping times, each within the interval [self.t0, self.t0 + T], at which this method will stop and yield. By default, a stop is performed after each time step (at potentially varying step size if an adaptive integrator is used).

Yields:

The current step count.

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.generator and \(\gamma\) one of \(\gamma = -1\) (imaginary-time dynamics for MCState), \(\gamma = -i\) (real-time dynamics for MCState), or \(\gamma = 1\) (real-time dynamics for MCMixedState).

Parameters:
  • t – Time (defaults to self.t).

  • w – Variational parameters (defaults to self.state.parameters).

Returns:

The time-derivative \(\dot w\).

reset()[source]#

Resets the driver.

Subclasses should make sure to call super().reset() to ensure that the step count is set to 0.

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.

  • timeit (bool) – If True, provide timing information.

update_parameters(dp)[source]#

Updates the parameters of the machine using the optimizer in this driver

Parameters:

dp – the pytree containing the updates to the parameters