QMCPACK
SOECPComponent.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2023 QMCPACK developers.
6 //
7 // File developed by: Raymond Clay, rclay@sandia.gov, Sandia National Laboratory
8 // Cody A. Melton, cmelton@sandia.gov, Sandia National Laboratories
9 //
10 // File created by: Raymond Clay, rclay@sandia.gov, Sandia National Laboratory
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #ifndef QMCPLUSPLUS_SO_ECPOTENTIAL_COMPONENT_H
15 #define QMCPLUSPLUS_SO_ECPOTENTIAL_COMPONENT_H
19 #include <ResourceCollection.h>
24 
25 namespace qmcplusplus
26 {
27 
28 namespace testing
29 {
30 class TestSOECPotential;
31 }
32 /** class SOECPComponent
33  ** brief Computes the nonlocal spin-orbit interaction \f$\Delta V_SO(r) |ljm_j><ljm_j|\f$.
34  ** details This computes the nonlocal spin-orbit interaction between a single ion species and
35  ** a given electron.
36  ** Currently, this class does nothing other than generate and store \f$\Delta V_SO(r)\f$
37  ** for different orbital angular momenta. Implementation coming soon!
38  **/
39 
40 class SOECPComponent : public QMCTraits
41 {
42 private:
43  using SpherGridType = std::vector<PosType>;
47 
48  ///Non Local part: angular momentum, potential and grid
49  int lmax_;
50  ///the number of non-local channels
51  int nchannel_;
52  int nknot_;
53  int sknot_;
54  int total_knots_; //spin + spatial knots
55  ///Maximum cutoff the non-local pseudopotential
57  ///Angular momentum map
59  ///Non-Local part of the pseudo-potential
60  std::vector<RadialPotentialType*> sopp_m_;
61 
62  static ComplexType sMatrixElements(RealType s1, RealType s2, int dim);
63  static ComplexType lmMatrixElements(int l, int m1, int m2, int dim);
64  static ComplexType matrixElementDecomposed(int l, int m1, int m2, RealType spin, bool plus = true);
65  static int kroneckerDelta(int x, int y);
66 
67  std::vector<PosType> deltaV_;
68  std::vector<RealType> deltaS_;
71  std::vector<ValueType> psiratio_;
72  std::vector<ValueType> vrad_;
73  std::vector<RealType> sgridweight_m_;
74  //total spin and quadrature weights
75  std::vector<RealType> spin_quad_weights_;
76  //work array
77  std::vector<ValueType> wvec_;
78  //scratch spaces used by evaluateValueAndDerivative
82 
83  //This builds the full quadrature grid for the Simpsons rule used for spin integrals as well as
84  //the spatial quadrature. In this function, it specifies the deltaS_ and deltaV_ for all the quadrature points and sets the interal weights
85  //in spin_quad_weights
86  //If there are s0,s1,...sN spin integral points and q0,q1,...qM spatial quadrature points, the order is
87  // s0q0, s0q1, ..., s0qM, s1q0, ..., sNq0, ..., sNqM for each of the deltaS_, deltaV_, and spin_quad_weights_
88  void buildTotalQuadrature(const RealType r, const PosType& dr, const RealType sold);
89 
90 public:
93 
95 
96  ///add a new Spin-Orbit component
97  void add(int l, RadialPotentialType* pp);
98 
99  void resize_warrays(int n, int m, int s);
100 
101  void rotateQuadratureGrid(const TensorType& rmat);
102 
103  ///API for accessing the value of an SO radial potential at distance r. For unit and other testing.
104  friend RealType getSplinedSOPot(SOECPComponent* so_pp, int l, double r);
105  /** @brief Evaluate the spin orbit pp contribution
106  * to total energy from ion "iat" and electron "iel".
107  *
108  * @param W electron particle set.
109  * @param iat index of ion.
110  * @param Psi trial wave function object
111  * @param iel index of electron
112  * @param r the distance between ion iat and electron iel.
113  * @param dr displacement from ion iat to electron iel.
114  *
115  * @return RealType Contribution to $\frac{V\Psi_T}{\Psi_T}$ from ion iat and electron iel.
116  */
117  RealType evaluateOne(ParticleSet& W, int iat, TrialWaveFunction& Psi, int iel, RealType r, const PosType& dr);
118 
120 
121  RealType evaluateOneExactSpinIntegration(ParticleSet& W, const int iat, const TrialWaveFunction& psi, const int iel, const RealType r, const PosType& dr);
122 
123  static void mw_evaluateOne(const RefVectorWithLeader<SOECPComponent>& soecp_component_list,
124  const RefVectorWithLeader<ParticleSet>& p_list,
126  const RefVector<const NLPPJob<RealType>>& joblist,
127  std::vector<RealType>& pairpots,
128  ResourceCollection& collection);
129 
131  int iat,
132  TrialWaveFunction& psi,
133  int iel,
134  RealType r,
135  const PosType& dr,
136  const opt_variables_type& optvars,
137  const Vector<ValueType>& dlogpsi,
138  Vector<ValueType>& dhpsioverpsi);
139 
140  void print(std::ostream& os);
141 
142  void initVirtualParticle(const ParticleSet& qp);
143  void deleteVirtualParticle();
144 
145  inline void setRmax(RealType rmax) { rmax_ = rmax; }
146  inline RealType getRmax() const { return rmax_; }
147  inline void setLmax(int lmax) { lmax_ = lmax; }
148  inline int getLmax() const { return lmax_; }
149  inline int getNknot() const { return nknot_; }
150  inline int getSknot() const { return sknot_; }
151 
152  const VirtualParticleSet* getVP() const { return vp_; };
153 
154  friend struct ECPComponentBuilder;
155  friend void copyGridUnrotatedForTest(SOECPComponent& nlpp);
156 
158 };
159 
160 } // namespace qmcplusplus
161 #endif
const VirtualParticleSet * getVP() const
int nchannel_
the number of non-local channels
std::vector< T, aligned_allocator< T > > aligned_vector
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
RealType evaluateOneExactSpinIntegration(ParticleSet &W, const int iat, const TrialWaveFunction &psi, const int iel, const RealType r, const PosType &dr)
void rotateQuadratureGrid(const TensorType &rmat)
Vector< ValueType > dlogpsi_vp_
aligned_vector< int > angpp_m_
Angular momentum map.
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
std::vector< ValueType > vrad_
int lmax_
Non Local part: angular momentum, potential and grid.
Declaration of OperatorBase.
void resize_warrays(int n, int m, int s)
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
Definition: SPOSet.h:50
VirtualParticleSet * vp_
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
void buildTotalQuadrature(const RealType r, const PosType &dr, const RealType sold)
class SOECPComponent brief Computes the nonlocal spin-orbit interaction .
friend RealType getSplinedSOPot(SOECPComponent *so_pp, int l, double r)
API for accessing the value of an SO radial potential at distance r. For unit and other testing...
Definition: test_ecp.cpp:44
static ComplexType sMatrixElements(RealType s1, RealType s2, int dim)
static ComplexType matrixElementDecomposed(int l, int m1, int m2, RealType spin, bool plus=true)
SPOSet::ValueMatrix ValueMatrix
An abstract base class to implement a One-Dimensional grid.
Decalaration of One-Dimesional grids.
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
RealType rmax_
Maximum cutoff the non-local pseudopotential.
std::vector< PosType > deltaV_
static ComplexType lmMatrixElements(int l, int m1, int m2, int dim)
RealType calculateProjector(RealType r, const PosType &dr, RealType sold)
friend void copyGridUnrotatedForTest(SOECPComponent &nlpp)
Definition: test_ecp.cpp:154
std::vector< ValueType > psiratio_
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
RealType evaluateValueAndDerivatives(ParticleSet &P, int iat, TrialWaveFunction &psi, int iel, RealType r, const PosType &dr, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
void initVirtualParticle(const ParticleSet &qp)
void print(std::ostream &os)
std::vector< PosType > SpherGridType
std::vector< RadialPotentialType * > sopp_m_
Non-Local part of the pseudo-potential.
void setRmax(RealType rmax)
Declaration of a TrialWaveFunction.
std::vector< ValueType > wvec_
std::vector< std::reference_wrapper< T > > RefVector
void add(int l, RadialPotentialType *pp)
add a new Spin-Orbit component
Class to represent a many-body trial wave function.
std::vector< RealType > sgridweight_m_
RealType evaluateOne(ParticleSet &W, int iat, TrialWaveFunction &Psi, int iel, RealType r, const PosType &dr)
Evaluate the spin orbit pp contribution to total energy from ion "iat" and electron "iel"...
meta data for NLPP calculation of a pair of ion and electron This is not just meta data...
static int kroneckerDelta(int x, int y)
traits for QMC variables
Definition: Configuration.h:49
SOECPComponent * makeClone(const ParticleSet &qp)
std::vector< RealType > deltaS_
Matrix< ValueType > dratio_
std::vector< RealType > spin_quad_weights_
static void mw_evaluateOne(const RefVectorWithLeader< SOECPComponent > &soecp_component_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVectorWithLeader< TrialWaveFunction > &psi_list, const RefVector< const NLPPJob< RealType >> &joblist, std::vector< RealType > &pairpots, ResourceCollection &collection)