netket.vqs.apply_operator

Contents

netket.vqs.apply_operator#

netket.vqs.apply_operator(operator, vstate, *, seed=None)[source]#

Apply an operator to a variational state.

The returned variational state wraps the model of vstate with an operator transformation. The implementation depends on the model type:

  • Linen modules: Wrapped in a ApplyOperatorModuleLinen. Operator stored in flattened form with leaves accessible as op_vstate.variables['operator']['leaves'] and treedef stored in the module as op_vstate._model.operator_treedef.

  • NNX modules: Wrapped in a ApplyOperatorModuleNNX. Operator accessible as op_vstate.model.operator.

  • Other (functional): Uses the functional approach with make_logpsi_op_afun(). Operator accessible as op_vstate.variables['operator'].

Note

Note that is the vstate’s chunk size is specified, the chunk size of the transformed vstate will be set to vstate.chunk_size // operator.max_conn_size to account for the increased memory usage.

Note

When applying an operator to a vstate that already has an operator applied (nested application), the operators are automatically combined into a ProductOperator to avoid double wrapping. For example, B@[A@psi] will be computed as (B*A)@psi instead of B@(A@psi).

Parameters:
  • operator (AbstractOperator) – The operator to apply in front of the variational state ket

  • vstate (VariationalState) – The variational state (or ket)

Return type:

VariationalState