qmctorch.wavefunction.jastrows.elec_elec.kernels package

Submodules

qmctorch.wavefunction.jastrows.elec_elec.kernels.fully_connected_jastrow_kernel module

class qmctorch.wavefunction.jastrows.elec_elec.kernels.fully_connected_jastrow_kernel.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

qmctorch.wavefunction.jastrows.elec_elec.kernels.jastrow_kernel_electron_electron_base module

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

Bases: Module

Base class for the elec-elec jastrow kernels

Parameters:
  • nup ([type]) – [description]

  • down ([type]) – [description]

  • cuda (bool, optional) – [description]. Defaults to False.

forward(r: torch.Tensor)[source]

Get the elements of the jastrow matrix :

Parameters:

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

Returns:

matrix fof the jastrow elements

Nmo x Nbatch x Nelec_pair

Return type:

torch.tensor

Note

The kernel receives a [Nbatch x Npair] tensor. The kernel must first reshape that tensor to a [Nbatch*Npair, 1]. The kernel must process this tensor to another [Nbatch*Npair, 1] tensor. The kenrel must reshape the output to a [Nbatch x Npair] tensor.

Example

>>> def forward(self, x):
>>>     nbatch, npairs = x.shape
>>>     x = x.reshape(-1, 1)
>>>     x = self.fc1(x)
>>>     ...
>>>     return(x.reshape(nbatch, npairs))
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 using automatic differentiation

Parameters:
  • r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec_pair

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

Returns:

matrix fof the derivative of the jastrow elements

Nmo x Nbatch x Ndim x Nelec_pair

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 using automatic differentiation

Parameters:
  • r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec_pair

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

  • d2r (torch.tensor) –

    matrix of the 2nd derivative of

    the e-e distances

    Nbatch x Ndim x Nelec_pair

Returns:

matrix fof the pure 2nd derivative of

the jastrow elements Nmo x Nbatch x Ndim x Nelec_pair

Return type:

torch.tensor

qmctorch.wavefunction.jastrows.elec_elec.kernels.pade_jastrow_kernel module

class qmctorch.wavefunction.jastrows.elec_elec.kernels.pade_jastrow_kernel.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

qmctorch.wavefunction.jastrows.elec_elec.kernels.pade_jastrow_polynomial_kernel module

class qmctorch.wavefunction.jastrows.elec_elec.kernels.pade_jastrow_polynomial_kernel.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

Module contents

class qmctorch.wavefunction.jastrows.elec_elec.kernels.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.kernels.JastrowKernelElectronElectronBase(*args: Any, **kwargs: Any)[source]

Bases: Module

Base class for the elec-elec jastrow kernels

Parameters:
  • nup ([type]) – [description]

  • down ([type]) – [description]

  • cuda (bool, optional) – [description]. Defaults to False.

forward(r: torch.Tensor)[source]

Get the elements of the jastrow matrix :

Parameters:

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

Returns:

matrix fof the jastrow elements

Nmo x Nbatch x Nelec_pair

Return type:

torch.tensor

Note

The kernel receives a [Nbatch x Npair] tensor. The kernel must first reshape that tensor to a [Nbatch*Npair, 1]. The kernel must process this tensor to another [Nbatch*Npair, 1] tensor. The kenrel must reshape the output to a [Nbatch x Npair] tensor.

Example

>>> def forward(self, x):
>>>     nbatch, npairs = x.shape
>>>     x = x.reshape(-1, 1)
>>>     x = self.fc1(x)
>>>     ...
>>>     return(x.reshape(nbatch, npairs))
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 using automatic differentiation

Parameters:
  • r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec_pair

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

Returns:

matrix fof the derivative of the jastrow elements

Nmo x Nbatch x Ndim x Nelec_pair

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 using automatic differentiation

Parameters:
  • r (torch.tensor) – matrix of the e-e distances Nbatch x Nelec_pair

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

  • d2r (torch.tensor) –

    matrix of the 2nd derivative of

    the e-e distances

    Nbatch x Ndim x Nelec_pair

Returns:

matrix fof the pure 2nd derivative of

the jastrow elements Nmo x Nbatch x Ndim x Nelec_pair

Return type:

torch.tensor

class qmctorch.wavefunction.jastrows.elec_elec.kernels.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.kernels.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