qmctorch.wavefunction.jastrows.elec_elec package

Subpackages

Submodules

qmctorch.wavefunction.jastrows.elec_elec.jastrow_factor_electron_electron module

class qmctorch.wavefunction.jastrows.elec_elec.jastrow_factor_electron_electron.JastrowFactorElectronElectron(*args: Any, **kwargs: Any)[source]

Bases: Module

Electron-Electron Jastrow factor.

\[J = \prod_{i<j} \exp(\text{Kernel}(r_{ij}))\]
Parameters:
  • nup (int) – number of spin up electons

  • ndow (int) – number of spin down electons

  • jastrow_kernel (kernel) – class of a electron-electron Jastrow kernel

  • kernel_kwargs (dict, optional) – keyword argument of the kernel. Defaults to {}.

  • scale (bool, optional) – use scaled electron-electron distance. Defaults to False.

  • scale_factor (float, optional) – scaling factor for elec-elec distance. Defaults to 0.6.

  • cuda (bool, optional) – use cuda. Defaults to False.

get_mask_tri_up() Tuple[torch.Tensor, torch.Tensor, torch.Tensor][source]

Get the mask to select the triangular up matrix

Returns:

mask of the tri up matrix, shape (nelec, nelec) index_col (torch.Tensor): long tensor of the column index, shape (-1,) index_row (torch.Tensor): long tensor of the row index, shape (-1,)

Return type:

mask (torch.Tensor)

extract_tri_up(inp: torch.Tensor) torch.Tensor[source]

extract the upper triangular elements

Parameters:

inp (torch.tensor) – input matrices (nbatch, n, n)

Returns:

triangular up element (nbatch, -1)

Return type:

torch.tensor

get_edist_unique(pos: torch.Tensor, derivative: int = 0) torch.Tensor[source]

Get the unique elements of the electron-electron distance matrix.

Parameters:
  • pos (torch.tensor) – positions of the electrons (Nbatch, Nelec*3)

  • derivative (int, optional) – order of the derivative

Returns:

unique values of the electron-electron distance matrix

Return type:

torch.tensor

forward(pos: torch.Tensor, derivative: int = 0, sum_grad: bool = True) torch.Tensor | Tuple[torch.Tensor, torch.Tensor, torch.Tensor][source]

Compute the Jastrow factors.

Parameters:
  • pos (torch.tensor) – Positions of the electrons Size : Nbatch, Nelec x Ndim

  • derivative (int, optional) – order of the derivative (0,1,2,). Defaults to 0.

  • sum_grad (bool, optional) – Return the sum_grad (i.e. the sum of the derivatives) or the individual terms. Defaults to True. False only for derivative=1

Returns:

value of the jastrow parameter for all confs

derivative = 0 (Nmo) x Nbatch x 1 derivative = 1 (Nmo) x Nbatch x Nelec (for sum_grad = True) derivative = 1 (Nmo) x Nbatch x Ndim x Nelec (for sum_grad = False) derivative = 2 (Nmo) x Nbatch x Nelec

Return type:

torch.tensor

jastrow_factor_derivative(r: torch.Tensor, dr: torch.Tensor, jast: torch.Tensor, sum_grad: bool) torch.Tensor[source]

Compute the value of the derivative of the Jastrow factor

Parameters:
  • r (torch.tensor) – distance matrix Nbatch x Nelec x Nelec

  • dr (torch.tensor) – derivative of the distance matrix Nbatch x Nelec x Nelec x 3

  • jast (torch.tensor) – values of the jastrow elements Nbatch x Nelec x Nelec

  • sum_grad (bool) – return the sum of the gradient or the individual components

Returns:

gradient of the jastrow factors

Nbatch x Nelec x Ndim

Return type:

torch.tensor

jastrow_factor_second_derivative(r: torch.Tensor, dr: torch.Tensor, d2r: torch.Tensor, jast: torch.Tensor) torch.Tensor[source]

Compute the value of the pure 2nd derivative of the Jastrow factor

Parameters:
  • r (torch.tensor) – distance matrix Nbatch x Nelec x Nelec

  • dr (torch.tensor) – derivative of the distance matrix Nbatch x Nelec x Nelec x 3

  • d2r (torch.tensor) – 2nd derivative of the distance matrix Nbatch x Nelec x Nelec x 3

  • jast (torch.tensor) – values of the ajstrow elements Nbatch x Nelec x Nelec

Returns:

diagonal hessian of the jastrow factors

Nbatch x Nelec x Ndim

Return type:

torch.tensor

partial_derivative(djast: torch.Tensor) torch.Tensor[source]

Computes the partial derivative

Parameters:

djast (torch.tensor) – values of the derivative of the jastrow kernels

Module contents

qmctorch.wavefunction.jastrows.elec_elec.JastrowFactor

alias of JastrowFactorElectronElectron

class qmctorch.wavefunction.jastrows.elec_elec.PadeJastrowKernel(*args: Any, **kwargs: Any)[source]

Bases: JastrowKernelElectronElectronBase

Computes the Simple Pade-Jastrow factor

\[B_{ij} = \frac{w_0 r_{ij}}{1 + w r_{ij}}\]

where \(w_0\) equals 0.5 for parallel spin and 0.25 for antiparallel spin

Parameters:
  • nup (int) – number of spin up electons

  • ndow (int) – number of spin down electons

  • cuda (bool) – Turns GPU ON/OFF.

  • w (float, optional) – Value of the variational parameter. Defaults to 1.

get_static_weight() torch.Tensor[source]

Get the matrix of static weights

Returns:

matrix of the static weights

Return type:

torch.tensor

forward(r: torch.Tensor) torch.Tensor[source]

Get the jastrow kernel.

\[B_{ij} = \frac{w_0 r_{i,j}}{1+w r_{i,j}}\]
Parameters:

r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec x Nelec

Returns:

matrix of the jastrow kernels

Nbatch x Nelec x Nelec

Return type:

torch.tensor

compute_derivative(r: torch.Tensor, dr: torch.Tensor) torch.Tensor[source]

Get the elements of the derivative of the jastrow kernels wrt to the first electrons

\[\frac{d B_{ij}}{d k_i} = \frac{d B_{ij}}{ d k_j } = - \frac{d B_{ji}}{d k_i}\]
\[\text{out}_{k,i,j} = A1 + A2\]
\[A1_{kij} = w0 \frac{dr_{ij}}{dk_i} \frac{1}{1 + w r_{ij}}\]
\[A2_{kij} = - w0 w' r_{ij} \frac{dr_{ij}}{dk_i} \frac{1}{1 + w r_{ij}}^2\]
Parameters:
  • r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec x Nelec

  • dr (torch.tensor) – matrix of the derivative of the e-e distances Nbatch x Ndim x Nelec x Nelec

Returns:

matrix fof the derivative of the jastrow elements

Nbatch x Ndim x Nelec x Nelec

Return type:

torch.tensor

compute_second_derivative(r: torch.Tensor, dr: torch.Tensor, d2r: torch.Tensor) torch.Tensor[source]

Get the elements of the pure 2nd derivative of the jastrow kernels wrt to the first electron

\[\frac{d^2 B_{ij}}{d k_i^2} = \frac{d^2 B_{ij}}{d k_j^2} = \frac{d^2 B_{ji}}{ d k_i^2}\]
Parameters:
  • r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec x Nelec

  • dr (torch.tensor) – matrix of the derivative of the e-e distances Nbatch x Ndim x Nelec x Nelec

  • d2r (torch.tensor) – matrix of the 2nd derivative of the e-e distances Nbatch x Ndim x Nelec x Nelec

Returns:

matrix fof the pure 2nd derivative of

the jastrow elements Nbatch x Ndim x Nelec x Nelec

Return type:

torch.tensor

class qmctorch.wavefunction.jastrows.elec_elec.FullyConnectedJastrowKernel(*args: Any, **kwargs: Any)[source]

Bases: JastrowKernelElectronElectronBase

Defines a fully connected jastrow factors.

Parameters:
  • nup (int) – Number of spin up electrons.

  • ndown (int) – Number of spin down electrons.

  • cuda (bool) – Whether to use the GPU or not.

  • size1 (int, optional) – Number of neurons in the first hidden layer. Defaults to 16.

  • size2 (int, optional) – Number of neurons in the second hidden layer. Defaults to 8.

  • eps (float, optional) – Small value for initialization. Defaults to 1E-6.

  • activation (torch.nn.Module, optional) – Activation function. Defaults to torch.nn.Sigmoid.

  • include_cusp_weight (bool, optional) – Whether to include the cusp weights or not. Defaults to True.

get_idx_pair() None[source]

Generate the indices of the same spin and opposite spin pairs.

The Jastrow factor is applied on all pair of electrons. To apply the same spin Jastrow kernel or the opposite spin Jastrow kernel, it is necessary to know the indices of the same spin and opposite spin pairs. This function generate the indices of the same spin and opposite spin pairs.

Return type:

None

forward(x: torch.Tensor) torch.Tensor[source]

Compute the kernel values

Parameters:

x (torch.tensor) – e-e distance Nbatch, Nele_pairs

Returns:

values of the f_ij

Return type:

torch.tensor

class qmctorch.wavefunction.jastrows.elec_elec.SpinPairFullyConnectedJastrowKernel(*args: Any, **kwargs: Any)[source]

Bases: JastrowKernelElectronElectronBase

Defines a fully connected jastrow factors with a separate fully connected layers for same and opposite spin

Parameters:
  • nup (int) – Number of spin up electrons.

  • ndown (int) – Number of spin down electrons.

  • cuda (bool) – Whether to use the GPU or not.

  • size1 (int, optional) – Number of neurons in the first hidden layer. Defaults to 16.

  • size2 (int, optional) – Number of neurons in the second hidden layer. Defaults to 8.

  • eps (float, optional) – Small value for initialization. Defaults to 1E-6.

  • activation (torch.nn.Module, optional) – Activation function. Defaults to torch.nn.Sigmoid.

get_idx_pair() None[source]

Generate the indices of the same spin and opposite spin pairs.

The Jastrow factor is applied on all pair of electrons. To apply the same spin Jastrow kernel or the opposite spin Jastrow kernel, it is necessary to know the indices of the same spin and opposite spin pairs. This function generate the indices of the same spin and opposite spin pairs.

Parameters:

None

Return type:

None

forward(x: torch.Tensor) torch.Tensor[source]

Compute the values of the kernel for same spin and opposite spin pairs.

Parameters:

x (torch.tensor) – e-e distance Nbatch, Nele_pairs

Returns:

values of the kernel

Return type:

torch.tensor

class qmctorch.wavefunction.jastrows.elec_elec.PadeJastrowPolynomialKernel(*args: Any, **kwargs: Any)[source]

Bases: JastrowKernelElectronElectronBase

Computes a polynomial Pade-Jastrow factor

\[B_{ij} = \frac{P_{ij}}{Q_{ij}}\]

with : .. math:

P_{ij} = a_1 r_{i,j} + a_2 r_{ij}^2 + ....

and :

Parameters:
  • nup (int) – number of spin up electons

  • ndow (int) – number of spin down electons

  • order (int) – degree of the polynomial

  • weight_a (torch.tensor, optional) – Value of the weight

  • weight_b (torch.tensor, optional) – Value of the weight

  • cuda (bool, optional) – Turns GPU ON/OFF. Defaults to False.

get_static_weight() torch.Tensor[source]

Get the matrix of static weights

Returns:

static weight (0.5 (0.25) for parallel(anti) spins

Return type:

torch.tensor

set_variational_weights(weight_a: torch.Tensor | None, weight_b: torch.Tensor | None) None[source]

Define the initial values of the variational weights.

Parameters:
  • weight_a (torch.tensor or None) – Value of the weight

  • weight_b (torch.tensor or None) – Value of the weight

forward(r: torch.Tensor) torch.Tensor[source]

Get the jastrow kernel.

\[B_{ij} = \frac{P_{ij}}{Q_{ij}}\]
Parameters:

r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec x Nelec

Returns:

matrix of the jastrow kernels

Nbatch x Nelec x Nelec

Return type:

torch.tensor

compute_derivative(r: torch.Tensor, dr: torch.Tensor) torch.Tensor[source]

Get the elements of the derivative of the jastrow kernels wrt to the first electrons

The derivative is given by:

\[\text{out}_{k,i,j} = \frac{P'Q - PQ'}{Q^2}\]

with:

\[P_{ij} = a_1 r_{i,j} + a_2 r_{ij}^2 + .... Q_{ij} = 1 + b_1 r_{i,j} + b_2 r_{ij}^2 +\]

and :

\[P'_{ij} = a_1 dr + a_2 2 r dr + a_r 3 dr r^2 + .... Q'_{ij} = b_1 dr + b_2 2 r dr + b_r 3 dr r^2 + ....\]

Due to the properties of the derivative we have .. math:

\frac{d B_{ij}}{d k_i} =  \frac{d B_{ij}}{d k_j}  = -\frac{d B_{ji}{d k_i}
Parameters:
  • r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec x Nelec

  • dr (torch.tensor) – matrix of the derivative of the e-e distances Nbatch x Ndim x Nelec x Nelec

Returns:

matrix fof the derivative of the jastrow elements

Nbatch x Ndim x Nelec x Nelec

Return type:

torch.tensor

compute_second_derivative(r: torch.Tensor, dr: torch.Tensor, d2r: torch.Tensor) torch.Tensor[source]

Get the elements of the pure 2nd derivative of the jastrow kernels wrt to the first electron

Due to the properties of the derivative we have .. math:

\frac{d B_{ij}}{d k_i} =  \frac{d B_{ij}}{d k_j}  = \frac{d B_{ji}{d k_i}
Parameters:
  • r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec x Nelec

  • dr (torch.tensor) – matrix of the derivative of the e-e distances Nbatch x Ndim x Nelec x Nelec

  • d2r (torch.tensor) –

    matrix of the 2nd derivative of

    the e-e distances

    Nbatch x Ndim x Nelec x Nelec

Returns:

matrix fof the pure 2nd derivative of

the jastrow elements Nbatch x Ndim x Nelec x Nelec

Return type:

torch.tensor