QMCPACK
SOECPComponent Class Reference

class SOECPComponent brief Computes the nonlocal spin-orbit interaction $\Delta V_SO(r) |ljm_j><ljm_j|$. More...

+ Inheritance diagram for SOECPComponent:
+ Collaboration diagram for SOECPComponent:

Public Member Functions

 SOECPComponent ()
 
 ~SOECPComponent ()
 
SOECPComponentmakeClone (const ParticleSet &qp)
 
void add (int l, RadialPotentialType *pp)
 add a new Spin-Orbit component More...
 
void resize_warrays (int n, int m, int s)
 
void rotateQuadratureGrid (const TensorType &rmat)
 
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". More...
 
RealType calculateProjector (RealType r, const PosType &dr, RealType sold)
 
RealType evaluateOneExactSpinIntegration (ParticleSet &W, const int iat, const TrialWaveFunction &psi, const int iel, const RealType r, const PosType &dr)
 
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 print (std::ostream &os)
 
void initVirtualParticle (const ParticleSet &qp)
 
void deleteVirtualParticle ()
 
void setRmax (RealType rmax)
 
RealType getRmax () const
 
void setLmax (int lmax)
 
int getLmax () const
 
int getNknot () const
 
int getSknot () const
 
const VirtualParticleSetgetVP () const
 

Static Public Member Functions

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)
 

Private Types

using SpherGridType = std::vector< PosType >
 
using GridType = OneDimGridBase< RealType >
 
using RadialPotentialType = OneDimCubicSpline< RealType >
 
using ValueMatrix = SPOSet::ValueMatrix
 

Private Member Functions

void buildTotalQuadrature (const RealType r, const PosType &dr, const RealType sold)
 

Static Private Member Functions

static ComplexType sMatrixElements (RealType s1, RealType s2, int dim)
 
static ComplexType lmMatrixElements (int l, int m1, int m2, int dim)
 
static ComplexType matrixElementDecomposed (int l, int m1, int m2, RealType spin, bool plus=true)
 
static int kroneckerDelta (int x, int y)
 

Private Attributes

int lmax_
 Non Local part: angular momentum, potential and grid. More...
 
int nchannel_
 the number of non-local channels More...
 
int nknot_
 
int sknot_
 
int total_knots_
 
RealType rmax_
 Maximum cutoff the non-local pseudopotential. More...
 
aligned_vector< int > angpp_m_
 Angular momentum map. More...
 
std::vector< RadialPotentialType * > sopp_m_
 Non-Local part of the pseudo-potential. More...
 
std::vector< PosTypedeltaV_
 
std::vector< RealTypedeltaS_
 
SpherGridType sgridxyz_m_
 
SpherGridType rrotsgrid_m_
 
std::vector< ValueTypepsiratio_
 
std::vector< ValueTypevrad_
 
std::vector< RealTypesgridweight_m_
 
std::vector< RealTypespin_quad_weights_
 
std::vector< ValueTypewvec_
 
Matrix< ValueTypedratio_
 
Vector< ValueTypedlogpsi_vp_
 
VirtualParticleSetvp_
 

Friends

struct ECPComponentBuilder
 
class testing::TestSOECPotential
 
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. More...
 
void copyGridUnrotatedForTest (SOECPComponent &nlpp)
 

Additional Inherited Members

- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Detailed Description

class SOECPComponent brief Computes the nonlocal spin-orbit interaction $\Delta V_SO(r) |ljm_j><ljm_j|$.

details This computes the nonlocal spin-orbit interaction between a single ion species and a given electron.
Currently, this class does nothing other than generate and store $\Delta V_SO(r)$ for different orbital angular momenta. Implementation coming soon!

Definition at line 40 of file SOECPComponent.h.

Member Typedef Documentation

◆ GridType

using GridType = OneDimGridBase<RealType>
private

Definition at line 44 of file SOECPComponent.h.

◆ RadialPotentialType

Definition at line 45 of file SOECPComponent.h.

◆ SpherGridType

using SpherGridType = std::vector<PosType>
private

Definition at line 43 of file SOECPComponent.h.

◆ ValueMatrix

Definition at line 46 of file SOECPComponent.h.

Constructor & Destructor Documentation

◆ SOECPComponent()

Definition at line 22 of file SOECPComponent.cpp.

Referenced by SOECPComponent::makeClone().

23  : lmax_(0), nchannel_(0), nknot_(0), sknot_(0), total_knots_(0), rmax_(-1), vp_(nullptr)
24 {}
int nchannel_
the number of non-local channels
int lmax_
Non Local part: angular momentum, potential and grid.
VirtualParticleSet * vp_
RealType rmax_
Maximum cutoff the non-local pseudopotential.

◆ ~SOECPComponent()

Definition at line 26 of file SOECPComponent.cpp.

References SOECPComponent::sopp_m_, and SOECPComponent::vp_.

27 {
28  for (int i = 0; i < sopp_m_.size(); i++)
29  delete sopp_m_[i];
30  if (vp_)
31  delete vp_;
32 }
VirtualParticleSet * vp_
std::vector< RadialPotentialType * > sopp_m_
Non-Local part of the pseudo-potential.

Member Function Documentation

◆ add()

void add ( int  l,
RadialPotentialType pp 
)

add a new Spin-Orbit component

Definition at line 51 of file SOECPComponent.cpp.

References SOECPComponent::angpp_m_, and SOECPComponent::sopp_m_.

52 {
53  angpp_m_.push_back(l);
54  sopp_m_.push_back(pp);
55 }
aligned_vector< int > angpp_m_
Angular momentum map.
std::vector< RadialPotentialType * > sopp_m_
Non-Local part of the pseudo-potential.

◆ buildTotalQuadrature()

void buildTotalQuadrature ( const RealType  r,
const PosType dr,
const RealType  sold 
)
private

Definition at line 430 of file SOECPComponent.cpp.

References SOECPComponent::deltaS_, SOECPComponent::deltaV_, SOECPComponent::nchannel_, SOECPComponent::nknot_, SOECPComponent::rrotsgrid_m_, SOECPComponent::sgridweight_m_, SOECPComponent::sknot_, SOECPComponent::sopp_m_, SOECPComponent::spin_quad_weights_, SOECPComponent::total_knots_, and SOECPComponent::vrad_.

Referenced by SOECPComponent::evaluateOne(), SOECPComponent::evaluateValueAndDerivatives(), and SOECPComponent::mw_evaluateOne().

431 {
432  int count = 0;
433  RealType smin(0.0);
434  RealType smax(TWOPI);
435  RealType dS = (smax - smin) / sknot_; //step size for spin
436 
437 
438  //for a given spin point in the Simpsons integration, this will copy the spatial quadrature points into
439  //the global quadrature arrays which includes spin and spatial quadrature.
440  //Sets deltaS_, deltaV_, and spin_quad_weights_ accordingly.
441  auto addSpatialQuadrature = [&](const int is, const RealType r, const PosType& dr, const RealType ds,
442  const RealType spin_weight) {
443  for (int iq = 0; iq < nknot_; iq++)
444  {
445  int offset = is * nknot_ + iq;
446  deltaV_[offset] = r * rrotsgrid_m_[iq] - dr;
447  deltaS_[offset] = ds;
448  //spin integral norm is 1/(2.0 * pi), spatial integral has 4.0 * pi, so overall weight is 2
449  spin_quad_weights_[offset] = 2.0 * spin_weight * sgridweight_m_[iq];
450  count++;
451  }
452  };
453 
454  //simpsons 1/3 rule for spin integral
455 
456  //odd points
457  for (int is = 1; is <= sknot_ - 1; is += 2)
458  {
459  RealType snew = smin + is * dS;
460  addSpatialQuadrature(is, r, dr, snew - sold, RealType(4. / 3.) * dS);
461  }
462 
463  //even points
464  for (int is = 2; is <= sknot_ - 2; is += 2)
465  {
466  RealType snew = smin + is * dS;
467  addSpatialQuadrature(is, r, dr, snew - sold, RealType(2. / 3.) * dS);
468  }
469 
470  //end points
471  addSpatialQuadrature(0, r, dr, smin - sold, RealType(1. / 3.) * dS);
472  addSpatialQuadrature(sknot_, r, dr, smax - sold, RealType(1. / 3.) * dS);
473 
474  assert(count == total_knots_);
475 
476  //also set the radial function
477  for (int ip = 0; ip < nchannel_; ip++)
478  vrad_[ip] = sopp_m_[ip]->splint(r);
479 }
int nchannel_
the number of non-local channels
QTBase::RealType RealType
Definition: Configuration.h:58
std::vector< ValueType > vrad_
QMCTraits::PosType PosType
std::vector< PosType > deltaV_
std::vector< RadialPotentialType * > sopp_m_
Non-Local part of the pseudo-potential.
QMCTraits::RealType RealType
std::vector< RealType > sgridweight_m_
std::vector< RealType > deltaS_
std::vector< RealType > spin_quad_weights_

◆ calculateProjector()

SOECPComponent::RealType calculateProjector ( RealType  r,
const PosType dr,
RealType  sold 
)

Definition at line 182 of file SOECPComponent.cpp.

References qmcplusplus::conj(), SOECPComponent::deltaS_, SOECPComponent::lmMatrixElements(), SOECPComponent::nchannel_, SOECPComponent::nknot_, SOECPComponent::psiratio_, SOECPComponent::rrotsgrid_m_, SOECPComponent::sMatrixElements(), qmcplusplus::sphericalHarmonic(), SOECPComponent::spin_quad_weights_, SOECPComponent::total_knots_, and SOECPComponent::vrad_.

Referenced by SOECPComponent::evaluateOne(), and SOECPComponent::mw_evaluateOne().

183 {
184  ComplexType pairpot;
185  for (int iq = 0; iq < total_knots_; iq++)
186  {
187  RealType snew = sold + deltaS_[iq];
188  ComplexType lsum;
189  for (int il = 0; il < nchannel_; il++)
190  {
191  int l = il + 1; //nchannels starts at l=1, so 0th element is p not s
192  ComplexType msums;
193  for (int m1 = -l; m1 <= l; m1++)
194  {
195  ComplexType Y = sphericalHarmonic(l, m1, dr);
196  for (int m2 = -l; m2 <= l; m2++)
197  {
198  ComplexType ldots;
199  for (int id = 0; id < 3; id++)
200  ldots += lmMatrixElements(l, m1, m2, id) * sMatrixElements(sold, snew, id);
202  msums += Y * cY * ldots;
203  }
204  }
205  lsum += vrad_[il] * msums;
206  }
207  pairpot += psiratio_[iq] * lsum * spin_quad_weights_[iq];
208  }
209  return std::real(pairpot);
210 }
int nchannel_
the number of non-local channels
QMCTraits::RealType real
std::vector< ValueType > vrad_
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
static ComplexType sMatrixElements(RealType s1, RealType s2, int dim)
static ComplexType lmMatrixElements(int l, int m1, int m2, int dim)
std::vector< ValueType > psiratio_
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
QMCTraits::RealType RealType
std::complex< T > sphericalHarmonic(const int l, const int m, const TinyVector< T, 3 > &r)
wrapper for Ylm, which can take any normal position vector as an argument param[in] l angular momentu...
Definition: Ylm.h:141
std::vector< RealType > deltaS_
std::vector< RealType > spin_quad_weights_

◆ deleteVirtualParticle()

void deleteVirtualParticle ( )

Definition at line 44 of file SOECPComponent.cpp.

References SOECPComponent::vp_.

45 {
46  if (vp_)
47  delete vp_;
48  vp_ = nullptr;
49 }
VirtualParticleSet * vp_

◆ evaluateOne()

SOECPComponent::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".

Parameters
Welectron particle set.
iatindex of ion.
Psitrial wave function object
ielindex of electron
rthe distance between ion iat and electron iel.
drdisplacement from ion iat to electron iel.
Returns
RealType Contribution to ${V}{}$ from ion iat and electron iel.

Definition at line 155 of file SOECPComponent.cpp.

References SOECPComponent::buildTotalQuadrature(), TrialWaveFunction::calcRatio(), SOECPComponent::calculateProjector(), SOECPComponent::deltaS_, SOECPComponent::deltaV_, TrialWaveFunction::evaluateRatios(), VirtualParticleSet::makeMovesWithSpin(), ParticleSet::makeMoveWithSpin(), SOECPComponent::psiratio_, ParticleSet::rejectMove(), TrialWaveFunction::resetPhaseDiff(), ParticleSet::spins, SOECPComponent::total_knots_, and SOECPComponent::vp_.

161 {
162  RealType sold = W.spins[iel];
163  buildTotalQuadrature(r, dr, sold);
164 
165  if (vp_)
166  {
167  vp_->makeMovesWithSpin(W, iel, deltaV_, deltaS_, true, iat);
168  Psi.evaluateRatios(*vp_, psiratio_);
169  }
170  else
171  for (int iq = 0; iq < total_knots_; iq++)
172  {
173  W.makeMoveWithSpin(iel, deltaV_[iq], deltaS_[iq]);
174  psiratio_[iq] = Psi.calcRatio(W, iel);
175  W.rejectMove(iel);
176  Psi.resetPhaseDiff();
177  }
178 
179  return calculateProjector(r, dr, sold);
180 }
void makeMovesWithSpin(const ParticleSet &refp, int jel, const std::vector< PosType > &deltaV, const std::vector< RealType > &deltaS, bool sphere=false, int iat=-1)
move virtual particles to new postions and update distance tables
VirtualParticleSet * vp_
void buildTotalQuadrature(const RealType r, const PosType &dr, const RealType sold)
std::vector< PosType > deltaV_
RealType calculateProjector(RealType r, const PosType &dr, RealType sold)
std::vector< ValueType > psiratio_
QMCTraits::RealType RealType
std::vector< RealType > deltaS_

◆ evaluateOneExactSpinIntegration()

SOECPComponent::RealType evaluateOneExactSpinIntegration ( ParticleSet W,
const int  iat,
const TrialWaveFunction psi,
const int  iel,
const RealType  r,
const PosType dr 
)

Definition at line 212 of file SOECPComponent.cpp.

References qmcplusplus::conj(), SOECPComponent::deltaV_, TrialWaveFunction::evaluateSpinorRatios(), VirtualParticleSet::makeMoves(), SOECPComponent::matrixElementDecomposed(), SOECPComponent::nchannel_, SOECPComponent::nknot_, SOECPComponent::psiratio_, SOECPComponent::rrotsgrid_m_, SOECPComponent::sgridweight_m_, SOECPComponent::sopp_m_, qmcplusplus::sphericalHarmonic(), ParticleSet::spins, SOECPComponent::vp_, and SOECPComponent::vrad_.

218 {
219 #ifdef QMC_COMPLEX
220  RealType sold = W.spins[iel];
221 
223  std::pair<ValueVector, ValueVector> spinor_multiplier;
224  auto& up_row = spinor_multiplier.first;
225  auto& dn_row = spinor_multiplier.second;
226  up_row.resize(nknot_);
227  dn_row.resize(nknot_);
228 
229  //buildQuadraturePointDeltaPositions
230  for (int j = 0; j < nknot_; j++)
231  deltaV_[j] = r * rrotsgrid_m_[j] - dr;
232  vp_->makeMoves(W, iel, deltaV_, true, iat);
233 
234  //calculate radial potentials
235  for (int ip = 0; ip < nchannel_; ip++)
236  vrad_[ip] = sopp_m_[ip]->splint(r);
237 
238  for (int iq = 0; iq < nknot_; iq++)
239  {
240  up_row[iq] = 0.0;
241  dn_row[iq] = 0.0;
242  for (int il = 0; il < nchannel_; il++)
243  {
244  int l = il + 1;
245  for (int m1 = -l; m1 <= l; m1++)
246  {
247  ComplexType Y = sphericalHarmonic(l, m1, dr);
248  for (int m2 = -l; m2 <= l; m2++)
249  {
251  ComplexType so_up = matrixElementDecomposed(l, m1, m2, sold, true);
252  ComplexType so_dn = matrixElementDecomposed(l, m1, m2, sold, false);
253  RealType fourpi = 4.0 * M_PI;
254  //Note: Need 4pi weight. In Normal NonLocalECP, 1/4Pi generated from transformation to legendre polynomials and gets absorbed into the
255  // quadrature integration. We don't get the 1/4Pi from legendre here, so we need to scale by 4Pi.
256  up_row[iq] += fourpi * vrad_[il] * Y * cY * so_up;
257  dn_row[iq] += fourpi * vrad_[il] * Y * cY * so_dn;
258  }
259  }
260  }
261  }
262 
263  psi.evaluateSpinorRatios(*vp_, spinor_multiplier, psiratio_);
264  ComplexType pairpot;
265  for (size_t iq = 0; iq < nknot_; iq++)
266  pairpot += psiratio_[iq] * sgridweight_m_[iq];
267  return std::real(pairpot);
268 #else
269  throw std::runtime_error("SOECPComponent::evaluateOneBodyOpMatrixContribution only implemented in complex build");
270 #endif
271 }
int nchannel_
the number of non-local channels
QMCTraits::RealType real
void makeMoves(const ParticleSet &refp, int jel, const std::vector< PosType > &deltaV, bool sphere=false, int iat=-1)
move virtual particles to new postions and update distance tables
std::vector< ValueType > vrad_
VirtualParticleSet * vp_
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
OrbitalSetTraits< ValueType >::ValueVector ValueVector
static ComplexType matrixElementDecomposed(int l, int m1, int m2, RealType spin, bool plus=true)
std::vector< PosType > deltaV_
std::vector< ValueType > psiratio_
OrbitalSetTraits< ValueType >::ValueVector ValueVector
Definition: SPOSet.h:49
std::vector< RadialPotentialType * > sopp_m_
Non-Local part of the pseudo-potential.
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
QMCTraits::RealType RealType
std::vector< RealType > sgridweight_m_
std::complex< T > sphericalHarmonic(const int l, const int m, const TinyVector< T, 3 > &r)
wrapper for Ylm, which can take any normal position vector as an argument param[in] l angular momentu...
Definition: Ylm.h:141

◆ evaluateValueAndDerivatives()

SOECPComponent::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 
)

Definition at line 348 of file SOECPComponent.cpp.

References ParticleSet::acceptMove(), TrialWaveFunction::acceptMove(), Vector< T, Alloc >::begin(), SOECPComponent::buildTotalQuadrature(), TrialWaveFunction::calcRatio(), qmcplusplus::conj(), Matrix< T, Alloc >::data(), Vector< T, Alloc >::data(), SOECPComponent::deltaS_, SOECPComponent::deltaV_, SOECPComponent::dlogpsi_vp_, SOECPComponent::dratio_, Vector< T, Alloc >::end(), TrialWaveFunction::evaluateDerivativesWF(), TrialWaveFunction::evaluateDerivRatios(), BLAS::gemv(), SOECPComponent::lmMatrixElements(), VirtualParticleSet::makeMovesWithSpin(), ParticleSet::makeMoveWithSpin(), SOECPComponent::nchannel_, SOECPComponent::nknot_, VariableSet::num_active_vars, SOECPComponent::psiratio_, ParticleSet::R, Matrix< T, Alloc >::resize(), Vector< T, Alloc >::resize(), SOECPComponent::rrotsgrid_m_, Vector< T, Alloc >::size(), SOECPComponent::sMatrixElements(), SOECPComponent::sopp_m_, qmcplusplus::sphericalHarmonic(), SOECPComponent::spin_quad_weights_, ParticleSet::spins, SOECPComponent::total_knots_, SOECPComponent::vp_, and SOECPComponent::wvec_.

357 {
358 #ifndef QMC_COMPLEX
359  throw std::runtime_error("SOECPComponent::evaluateValueAndDerivatives should not be called in real build\n");
360 #else
361 
362  const size_t num_vars = optvars.num_active_vars;
363  dratio_.resize(total_knots_, num_vars);
364  dlogpsi_vp_.resize(dlogpsi.size());
365  wvec_.resize(total_knots_);
366 
367  RealType sold = W.spins[iel];
368  buildTotalQuadrature(r, dr, sold);
369 
370  //Now we have all the spin and spatial quadrature points acculated to use in evaluation
371  //Now we need to obtain dlogpsi and dlogpsi_vp
372  if (vp_)
373  {
374  // Compute ratios with VP
375  vp_->makeMovesWithSpin(W, iel, deltaV_, deltaS_, true, iat);
376  Psi.evaluateDerivRatios(*vp_, optvars, psiratio_, dratio_);
377  }
378  else
379  for (int iq = 0; iq < total_knots_; iq++)
380  {
381  PosType posold = W.R[iel];
382  W.makeMoveWithSpin(iel, deltaV_[iq], deltaS_[iq]);
383  psiratio_[iq] = Psi.calcRatio(W, iel);
384  Psi.acceptMove(W, iel);
385  W.acceptMove(iel);
386 
387  std::fill(dlogpsi_vp_.begin(), dlogpsi_vp_.end(), 0.0);
388  Psi.evaluateDerivativesWF(W, optvars, dlogpsi_vp_);
389  for (int v = 0; v < dlogpsi_vp_.size(); ++v)
390  dratio_(iq, v) = dlogpsi_vp_[v] - dlogpsi[v];
391 
392  W.makeMoveWithSpin(iel, -deltaV_[iq], -deltaS_[iq]);
393  Psi.calcRatio(W, iel);
394  Psi.acceptMove(W, iel);
395  W.acceptMove(iel);
396  }
397 
398  ComplexType pairpot;
399  for (int iq = 0; iq < total_knots_; iq++)
400  {
401  ComplexType lsum;
402  for (int il = 0; il < nchannel_; il++)
403  {
404  int l = il + 1;
405  ComplexType msums;
406  for (int m1 = -l; m1 <= l; m1++)
407  {
408  ComplexType Y = sphericalHarmonic(l, m1, dr);
409  for (int m2 = -l; m2 <= l; m2++)
410  {
411  ComplexType ldots;
412  for (int id = 0; id < 3; id++)
413  ldots += lmMatrixElements(l, m1, m2, id) * sMatrixElements(W.spins[iel], W.spins[iel] + deltaS_[iq], id);
415  msums += Y * cY * ldots;
416  }
417  }
418  lsum += sopp_m_[il]->splint(r) * msums;
419  }
420  wvec_[iq] = lsum * psiratio_[iq] * spin_quad_weights_[iq];
421  pairpot += wvec_[iq];
422  }
423 
424  BLAS::gemv('N', num_vars, total_knots_, 1.0, dratio_.data(), num_vars, wvec_.data(), 1, 1.0, dhpsioverpsi.data(), 1);
425 
426  return std::real(pairpot);
427 #endif
428 }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
int nchannel_
the number of non-local channels
QMCTraits::RealType real
Vector< ValueType > dlogpsi_vp_
void makeMovesWithSpin(const ParticleSet &refp, int jel, const std::vector< PosType > &deltaV, const std::vector< RealType > &deltaS, bool sphere=false, int iat=-1)
move virtual particles to new postions and update distance tables
VirtualParticleSet * vp_
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
void buildTotalQuadrature(const RealType r, const PosType &dr, const RealType sold)
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
static ComplexType sMatrixElements(RealType s1, RealType s2, int dim)
static void gemv(int n, int m, const double *restrict amat, const double *restrict x, double *restrict y)
Definition: BLAS.hpp:118
QMCTraits::PosType PosType
std::vector< PosType > deltaV_
size_type size() const
return the current size
Definition: OhmmsVector.h:162
static ComplexType lmMatrixElements(int l, int m1, int m2, int dim)
std::vector< ValueType > psiratio_
std::vector< RadialPotentialType * > sopp_m_
Non-Local part of the pseudo-potential.
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
std::vector< ValueType > wvec_
QMCTraits::RealType RealType
std::complex< T > sphericalHarmonic(const int l, const int m, const TinyVector< T, 3 > &r)
wrapper for Ylm, which can take any normal position vector as an argument param[in] l angular momentu...
Definition: Ylm.h:141
std::vector< RealType > deltaS_
Matrix< ValueType > dratio_
std::vector< RealType > spin_quad_weights_

◆ getLmax()

int getLmax ( ) const
inline

Definition at line 148 of file SOECPComponent.h.

References SOECPComponent::lmax_.

148 { return lmax_; }
int lmax_
Non Local part: angular momentum, potential and grid.

◆ getNknot()

int getNknot ( ) const
inline

Definition at line 149 of file SOECPComponent.h.

References SOECPComponent::nknot_.

149 { return nknot_; }

◆ getRmax()

RealType getRmax ( ) const
inline

Definition at line 146 of file SOECPComponent.h.

References SOECPComponent::rmax_.

146 { return rmax_; }
RealType rmax_
Maximum cutoff the non-local pseudopotential.

◆ getSknot()

int getSknot ( ) const
inline

Definition at line 150 of file SOECPComponent.h.

References SOECPComponent::sknot_.

150 { return sknot_; }

◆ getVP()

const VirtualParticleSet* getVP ( ) const
inline

Definition at line 152 of file SOECPComponent.h.

References SOECPComponent::vp_.

152 { return vp_; };
VirtualParticleSet * vp_

◆ initVirtualParticle()

void initVirtualParticle ( const ParticleSet qp)

Definition at line 36 of file SOECPComponent.cpp.

References outputManager, OutputManagerClass::pause(), OutputManagerClass::resume(), SOECPComponent::total_knots_, and SOECPComponent::vp_.

37 {
38  assert(vp_ == nullptr);
40  vp_ = new VirtualParticleSet(qp, total_knots_);
42 }
void pause()
Pause the summary and log streams.
VirtualParticleSet * vp_
OutputManagerClass outputManager(Verbosity::HIGH)
void resume()
Resume the summary and log streams.

◆ kroneckerDelta()

int kroneckerDelta ( int  x,
int  y 
)
staticprivate

Definition at line 90 of file SOECPComponent.cpp.

Referenced by SOECPComponent::lmMatrixElements().

90 { return (x == y) ? 1 : 0; }

◆ lmMatrixElements()

SOECPComponent::ComplexType lmMatrixElements ( int  l,
int  m1,
int  m2,
int  dim 
)
staticprivate

Definition at line 108 of file SOECPComponent.cpp.

References APP_ABORT, SOECPComponent::kroneckerDelta(), and qmcplusplus::sqrt().

Referenced by SOECPComponent::calculateProjector(), SOECPComponent::evaluateValueAndDerivatives(), and SOECPComponent::matrixElementDecomposed().

109 {
110  ComplexType val;
111  RealType onehalf = 0.5;
112  RealType zero = 0.0;
113  switch (dim)
114  {
115  case 0: //x
116  val = onehalf *
117  ComplexType(std::sqrt(l * (l + 1) - m2 * (m2 + 1)) * kroneckerDelta(m1, m2 + 1) +
118  std::sqrt(l * (l + 1) - m2 * (m2 - 1)) * kroneckerDelta(m1, m2 - 1),
119  zero);
120  return val;
121  case 1:
122  val = onehalf *
123  ComplexType(0.0,
124  std::sqrt(l * (l + 1) - m2 * (m2 - 1)) * kroneckerDelta(m1, m2 - 1) -
125  std::sqrt(l * (l + 1) - m2 * (m2 + 1)) * kroneckerDelta(m1, m2 + 1));
126  return val;
127  case 2:
128  val = ComplexType(m2 * kroneckerDelta(m1, m2), zero);
129  return val;
130  default:
131  APP_ABORT("SOECPComponent::lMatrixElements Invalid operator dimension\n");
132  return 0;
133  }
134 }
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
static int kroneckerDelta(int x, int y)

◆ makeClone()

SOECPComponent * makeClone ( const ParticleSet qp)

Definition at line 57 of file SOECPComponent.cpp.

References SOECPComponent::SOECPComponent(), SOECPComponent::sopp_m_, SOECPComponent::total_knots_, and SOECPComponent::vp_.

58 {
59  SOECPComponent* myclone = new SOECPComponent(*this);
60  for (int i = 0; i < sopp_m_.size(); i++)
61  myclone->sopp_m_[i] = sopp_m_[i]->makeClone();
62  if (vp_)
63  myclone->vp_ = new VirtualParticleSet(qp, total_knots_);
64  return myclone;
65 }
VirtualParticleSet * vp_
std::vector< RadialPotentialType * > sopp_m_
Non-Local part of the pseudo-potential.

◆ matrixElementDecomposed()

SOECPComponent::ComplexType matrixElementDecomposed ( int  l,
int  m1,
int  m2,
RealType  spin,
bool  plus = true 
)
staticprivate

Definition at line 136 of file SOECPComponent.cpp.

References qmcplusplus::cos(), SOECPComponent::lmMatrixElements(), qmcplusplus::Units::mass::mp, qmcplusplus::Units::distance::pm, and qmcplusplus::sin().

Referenced by SOECPComponent::evaluateOneExactSpinIntegration().

137 {
138  RealType pm = plus ? RealType(1) : RealType(-1);
139  RealType mp = -1 * pm;
140 
141 
142  ComplexType lx = lmMatrixElements(l, m1, m2, 0);
143  ComplexType ly = lmMatrixElements(l, m1, m2, 1);
144  ComplexType lz = lmMatrixElements(l, m1, m2, 2);
145 
146  RealType cos2s = std::cos(2 * spin);
147  RealType sin2s = std::sin(2 * spin);
148  ComplexType phase(cos2s, mp * sin2s);
149  ComplexType eye(0, 1);
150  RealType onehalf = 0.5;
151  ComplexType val = onehalf * (pm * lz + phase * (lx + pm * eye * ly));
152  return val;
153 }
QTBase::RealType RealType
Definition: Configuration.h:58
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
static ComplexType lmMatrixElements(int l, int m1, int m2, int dim)
QMCTraits::RealType RealType

◆ mw_evaluateOne()

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 
)
static

Definition at line 273 of file SOECPComponent.cpp.

References SOECPComponent::buildTotalQuadrature(), TrialWaveFunction::calcRatio(), SOECPComponent::calculateProjector(), SOECPComponent::deltaS_, SOECPComponent::deltaV_, NLPPJob< T >::electron_id, RefVectorWithLeader< T >::getLeader(), NLPPJob< T >::ion_elec_displ, NLPPJob< T >::ion_elec_dist, ParticleSet::makeMoveWithSpin(), TrialWaveFunction::mw_evaluateRatios(), VirtualParticleSet::mw_makeMovesWithSpin(), SOECPComponent::psiratio_, ParticleSet::rejectMove(), TrialWaveFunction::resetPhaseDiff(), ParticleSet::spins, SOECPComponent::total_knots_, and SOECPComponent::vp_.

Referenced by SOECPotential::mw_evaluateImpl().

279 {
280  auto& soecp_component_leader = soecp_component_list.getLeader();
281  if (soecp_component_leader.vp_)
282  {
283  // Compute ratios with VP
284  RefVectorWithLeader<VirtualParticleSet> vp_list(*soecp_component_leader.vp_);
285  RefVectorWithLeader<const VirtualParticleSet> const_vp_list(*soecp_component_leader.vp_);
286  RefVector<const std::vector<PosType>> deltaV_list;
287  RefVector<const std::vector<RealType>> deltaS_list;
288  RefVector<std::vector<ValueType>> psiratios_list;
289  vp_list.reserve(soecp_component_list.size());
290  const_vp_list.reserve(soecp_component_list.size());
291  deltaV_list.reserve(soecp_component_list.size());
292  deltaS_list.reserve(soecp_component_list.size());
293  psiratios_list.reserve(soecp_component_list.size());
294 
295  for (size_t i = 0; i < soecp_component_list.size(); i++)
296  {
297  SOECPComponent& component(soecp_component_list[i]);
298  const NLPPJob<RealType>& job = joblist[i];
299  const RealType sold = p_list[i].spins[job.electron_id];
300 
301  component.buildTotalQuadrature(job.ion_elec_dist, job.ion_elec_displ, sold);
302 
303  vp_list.push_back(*component.vp_);
304  const_vp_list.push_back(*component.vp_);
305  deltaV_list.push_back(component.deltaV_);
306  deltaS_list.push_back(component.deltaS_);
307  psiratios_list.push_back(component.psiratio_);
308  }
309 
310  ResourceCollectionTeamLock<VirtualParticleSet> vp_res_lock(collection, vp_list);
311 
312  VirtualParticleSet::mw_makeMovesWithSpin(vp_list, p_list, deltaV_list, deltaS_list, joblist, true);
313 
314  TrialWaveFunction::mw_evaluateRatios(psi_list, const_vp_list, psiratios_list);
315  }
316  else
317  {
318  // Compute ratios without VP. Slow
319  for (size_t i = 0; i < p_list.size(); i++)
320  {
321  SOECPComponent& component(soecp_component_list[i]);
322  ParticleSet& W(p_list[i]);
323  TrialWaveFunction& psi(psi_list[i]);
324  const NLPPJob<RealType>& job = joblist[i];
325 
326  const RealType sold = W.spins[job.electron_id];
327  component.buildTotalQuadrature(job.ion_elec_dist, job.ion_elec_displ, sold);
328 
329  for (int j = 0; j < component.total_knots_; j++)
330  {
331  W.makeMoveWithSpin(job.electron_id, component.deltaV_[j], component.deltaS_[j]);
332  component.psiratio_[j] = psi.calcRatio(W, job.electron_id);
333  W.rejectMove(job.electron_id);
334  psi.resetPhaseDiff();
335  }
336  }
337  }
338 
339  for (size_t i = 0; i < p_list.size(); i++)
340  {
341  SOECPComponent& component(soecp_component_list[i]);
342  const NLPPJob<RealType>& job = joblist[i];
343  const RealType sold = p_list[i].spins[job.electron_id];
344  pairpots[i] = component.calculateProjector(job.ion_elec_dist, job.ion_elec_displ, sold);
345  }
346 }
static void mw_makeMovesWithSpin(const RefVectorWithLeader< VirtualParticleSet > &vp_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< const std::vector< PosType >> &deltaV_list, const RefVector< const std::vector< RealType >> &deltaS_list, const RefVector< const NLPPJob< RealType >> &joblist, bool sphere)
QMCTraits::RealType RealType
static void mw_evaluateRatios(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< const VirtualParticleSet > &Vp_list, const RefVector< std::vector< ValueType >> &ratios_list, ComputeType ct=ComputeType::ALL)
batched version of evaluateRatios Note: unlike other mw_ static functions, *this is the batch leader ...

◆ print()

void print ( std::ostream &  os)

Definition at line 34 of file SOECPComponent.cpp.

34 {}

◆ resize_warrays()

void resize_warrays ( int  n,
int  m,
int  s 
)

Definition at line 67 of file SOECPComponent.cpp.

References APP_ABORT, SOECPComponent::deltaS_, SOECPComponent::deltaV_, qmcplusplus::Units::distance::m, qmcplusplus::n, SOECPComponent::nchannel_, SOECPComponent::nknot_, SOECPComponent::psiratio_, SOECPComponent::rrotsgrid_m_, qmcplusplus::Units::time::s, SOECPComponent::sgridxyz_m_, SOECPComponent::sknot_, SOECPComponent::sopp_m_, SOECPComponent::spin_quad_weights_, SOECPComponent::total_knots_, and SOECPComponent::vrad_.

68 {
69  vrad_.resize(m);
70  rrotsgrid_m_.resize(n);
71  nchannel_ = sopp_m_.size();
72  nknot_ = sgridxyz_m_.size();
73  sknot_ = s;
74  if (sknot_ % 2 != 0 && sknot_ > 0)
75  throw std::runtime_error("Spin integration uses Simpson's rule. Must have even number of knots in this case");
76 
77  //Need +1 for Simpsons rule to include both end points.
78  //sknot here refers to the number of subintervals for integration
79  total_knots_ = nknot_ * (sknot_ + 1);
80  psiratio_.resize(total_knots_);
81  deltaV_.resize(total_knots_);
82  deltaS_.resize(total_knots_);
84  if (m != nchannel_)
85  {
86  APP_ABORT("SOECPComponent::resize_warrays has incorrect number of radial channels\n");
87  }
88 }
int nchannel_
the number of non-local channels
std::vector< ValueType > vrad_
std::vector< PosType > deltaV_
std::vector< ValueType > psiratio_
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::vector< RadialPotentialType * > sopp_m_
Non-Local part of the pseudo-potential.
std::vector< RealType > deltaS_
std::vector< RealType > spin_quad_weights_

◆ rotateQuadratureGrid()

void rotateQuadratureGrid ( const TensorType rmat)

Definition at line 481 of file SOECPComponent.cpp.

References qmcplusplus::dot(), SOECPComponent::rrotsgrid_m_, and SOECPComponent::sgridxyz_m_.

482 {
483  for (int i = 0; i < sgridxyz_m_.size(); i++)
484  rrotsgrid_m_[i] = dot(rmat, sgridxyz_m_[i]);
485 }
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)

◆ setLmax()

void setLmax ( int  lmax)
inline

Definition at line 147 of file SOECPComponent.h.

References SOECPComponent::lmax_.

147 { lmax_ = lmax; }
int lmax_
Non Local part: angular momentum, potential and grid.

◆ setRmax()

void setRmax ( RealType  rmax)
inline

Definition at line 145 of file SOECPComponent.h.

References SOECPComponent::rmax_.

145 { rmax_ = rmax; }
RealType rmax_
Maximum cutoff the non-local pseudopotential.

◆ sMatrixElements()

SOECPComponent::ComplexType sMatrixElements ( RealType  s1,
RealType  s2,
int  dim 
)
staticprivate

Definition at line 92 of file SOECPComponent.cpp.

References APP_ABORT, qmcplusplus::cos(), and qmcplusplus::sin().

Referenced by SOECPComponent::calculateProjector(), and SOECPComponent::evaluateValueAndDerivatives().

93 {
94  switch (dim)
95  {
96  case 0:
97  return ComplexType(std::cos(s1 + s2), 0.0);
98  case 1:
99  return ComplexType(std::sin(s1 + s2), 0.0);
100  case 2:
101  return ComplexType(0.0, std::sin(s1 - s2));
102  default:
103  APP_ABORT("SOECPComponent::sMatrixElements invalid operator dimension\n");
104  return 0;
105  }
106 }
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

Friends And Related Function Documentation

◆ copyGridUnrotatedForTest

void copyGridUnrotatedForTest ( SOECPComponent nlpp)
friend

Definition at line 154 of file test_ecp.cpp.

154 { sopp.rrotsgrid_m_ = sopp.sgridxyz_m_; }

◆ ECPComponentBuilder

friend struct ECPComponentBuilder
friend

Definition at line 152 of file SOECPComponent.h.

◆ getSplinedSOPot

RealType getSplinedSOPot ( SOECPComponent so_pp,
int  l,
double  r 
)
friend

API for accessing the value of an SO radial potential at distance r. For unit and other testing.

Definition at line 44 of file test_ecp.cpp.

44 { return so_comp->sopp_m_[l]->splint(r); }

◆ testing::TestSOECPotential

friend class testing::TestSOECPotential
friend

Definition at line 157 of file SOECPComponent.h.

Member Data Documentation

◆ angpp_m_

aligned_vector<int> angpp_m_
private

Angular momentum map.

Definition at line 58 of file SOECPComponent.h.

Referenced by SOECPComponent::add().

◆ deltaS_

◆ deltaV_

◆ dlogpsi_vp_

Vector<ValueType> dlogpsi_vp_
private

Definition at line 80 of file SOECPComponent.h.

Referenced by SOECPComponent::evaluateValueAndDerivatives().

◆ dratio_

Matrix<ValueType> dratio_
private

Definition at line 79 of file SOECPComponent.h.

Referenced by SOECPComponent::evaluateValueAndDerivatives().

◆ lmax_

int lmax_
private

Non Local part: angular momentum, potential and grid.

Definition at line 49 of file SOECPComponent.h.

Referenced by SOECPComponent::getLmax(), and SOECPComponent::setLmax().

◆ nchannel_

◆ nknot_

◆ psiratio_

◆ rmax_

RealType rmax_
private

Maximum cutoff the non-local pseudopotential.

Definition at line 56 of file SOECPComponent.h.

Referenced by SOECPComponent::getRmax(), and SOECPComponent::setRmax().

◆ rrotsgrid_m_

◆ sgridweight_m_

std::vector<RealType> sgridweight_m_
private

◆ sgridxyz_m_

◆ sknot_

◆ sopp_m_

◆ spin_quad_weights_

◆ total_knots_

◆ vp_

◆ vrad_

◆ wvec_

std::vector<ValueType> wvec_
private

Definition at line 77 of file SOECPComponent.h.

Referenced by SOECPComponent::evaluateValueAndDerivatives().


The documentation for this class was generated from the following files: