39 basis_functions_(
"OneBodyDensityMatrices::basis"),
41 timers_(
"OneBodyDensityMatrix")
90 throw UniformCommunicateError(
"OneBodyDensityMatrices::OneBodyDensityMatrices only density sampling implemented " 91 "for calculations using spinors");
97 for (
int i = 0; i < sposets.size(); ++i)
99 auto spo_it =
spomap.find(sposets[i]);
100 if (spo_it ==
spomap.end())
108 throw UniformCommunicateError(
"OneBodyDensityMatrices::OneBodyDensityMatrices basis_size must be greater than one");
110 int nspecies = species.
size();
112 throw UniformCommunicateError(
"OneBodyDensityMatrices::OneBodyDensityMatrices error: Species set does not have the " 113 "required attribute 'membersize'");
118 for (
int s = 0;
s < nspecies; ++
s)
119 nparticles += species(isize,
s);
120 for (
int s = 0;
s < nspecies; ++
s)
122 for (
int s = 0;
s < nspecies; ++
s)
128 Real bn_standard = 1.0;
143 N_BB_.reserve(nspecies);
144 for (
int s = 0;
s < nspecies; ++
s)
182 std::size_t data_size =
data_.size();
190 throw std::runtime_error(
"There is no memory savings implementation for OneBodyDensityMatrices");
193 auto spawn = std::make_unique<OneBodyDensityMatrices>(*
this, spawn_data_locality);
194 spawn->get_data().resize(data_size, 0.0);
201 return 2 * basis_size * basis_size * nspecies;
203 return basis_size * basis_size * nspecies;
254 Position rmin = std::numeric_limits<Real>::max();
255 Position rmax = -std::numeric_limits<Real>::max();
263 rmax[d] = std::max(rmax[d], rd);
270 rstd[d] =
std::sqrt(rstd[d] - rmean[d] * rmean[d]);
271 app_log() <<
"\nrsamples properties:" << std::endl;
272 app_log() <<
" rmin = " << rmin << std::endl;
273 app_log() <<
" rmax = " << rmax << std::endl;
274 app_log() <<
" rmean = " << rmean << std::endl;
275 app_log() <<
" rstd = " << rstd << std::endl;
285 ushift[d] += rng() * du;
292 rp[d] = ind * du + ushift[d];
318 Real ot = 1.0 / timestep;
322 for (
int s = 0;
s < steps; ++
s)
338 Pacc = ratio *
std::exp(-ot * (
dot(diff, ds) + .5 *
dot(ds, ds)));
377 Real ot = 1.0 / timestep;
381 for (
int s = 0;
s < steps; ++
s)
403 auto spin_ds = dspinp +
dspcur_;
404 Pacc = ratio *
std::exp(-ot * (
dot(diff, ds) + .5 *
dot(ds, ds))) *
405 std::exp(-ot * (sdiff * spin_ds) + 0.5 * spin_ds * spin_ds);
543 for (
int iw = 0; iw <
walkers.size(); ++iw)
590 for (
int n = 0;
n < basis_size_sq; ++
n)
595 #if defined(QMC_COMPLEX) 762 gdims[d] = gdims[d - 1] / ngrid;
767 for (
int p = 0; p < ngtot; ++p)
772 int ind = nrem / gdims[d];
773 rp[d] = ind * du + du / 2;
774 nrem -= ind * gdims[d];
791 my_indexes.push_back(2);
793 int nentries = std::accumulate(my_indexes.begin(), my_indexes.end(), 1);
795 int spin_data_size = 0;
802 hdf_name /=
"number_matrix";
void resize(size_type n, Type_t val=Type_t())
Resize the container.
a class that defines a supercell in D-dimensional Euclean space.
void generateSampleRatios(ParticleSet &pset_target, TrialWaveFunction &psi_target, std::vector< Matrix< Value >> &Psi_nm)
std::vector< Real > ssamples_
int SuperCellEnum
supercell enumeration
SingleParticlePos Center
Center of the cell sum(Rv[i])/2.
std::vector< std::string > species_names_
Real acceptance_ratio_
running acceptance ratio over all samples
ValueType calcRatio(ParticleSet &P, int iat, ComputeType ct=ComputeType::ALL)
compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex...
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios)
void reset()
Evaluate the reciprocal vectors, volume and metric tensor.
NewTimer & gen_sample_basis_timer
void updateBasisD012(const Position &r, ParticleSet &pset_target)
evaluates vgl on basis_functions_ for r sideeffects:
helper functions for EinsplineSetBuilder
bool hasAttribute(const std::string &aname) const
Check for attribute presence This replaces code that gets numAttributes then tries to addAttribute fo...
bool get_write_acceptance_ratio() const
Real spcur_
spin related variables
std::vector< ObservableHelper > h5desc_
Position center_
If not defined in OBDMI taken from lattice_.
Per crowd Estimator for OneBodyDensityMatrices aka 1RDM DensityMatrices1B.
OneBodyDensityMatrixTimers timers_
bool get_volume_normalized() const
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
QMCTraits::ValueType Value
void accumulate(const RefVector< MCPWalker > &walkers, const RefVector< ParticleSet > &psets, const RefVector< TrialWaveFunction > &wfns, const RefVector< QMCHamiltonian > &hams, RandomBase< FullPrecReal > &rng) override
void calcDensity(const Position &r, Real &dens, ParticleSet &pset_target)
calculate density based on r
Vector< Value > basis_spin_gradients_
NewTimer & gen_particle_basis_timer
NewTimer & accumulate_timer
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
int size() const
return the size of the orbital set Ye: this needs to be replaced by getOrbitalSetSize(); ...
std::unique_ptr< OperatorEstBase > spawnCrowdClone() const override
Position rcorner_
with respect to center_ using lattice_;
void resize(size_type n, size_type m)
Resize the container.
std::vector< Matrix< Value > > Phi_NB_
row major per sample workspaces
size_t calcFullDataSize(size_t basis_size, int num_species)
void generateSampleBasis(Matrix< Value > &Phi_mb, ParticleSet &pset_target, TrialWaveFunction &psi_target)
set Phi_mp to basis vaules per sample sideeffects:
void updateBasisWithSpin(const Position &r, const Real &s, ParticleSet &pset_target)
basis set updates with spin
void calcDensityDrift(const Position &r, Real &dens, Position &drift, ParticleSet &pset_target)
calculate density and drift bashed on r
Matrix< Value > Phi_MB_
basis_values_ at each r of rsamples_ row: sample col: basis_value size: samples * basis_size ...
void normalizeBasis(ParticleSet &pset_target)
int size() const
return the number of species
DataLocality data_locality_
locality for accumulation of estimator data.
void generateDensitySamplesWithSpin(bool save, int steps, RandomBase< FullPrecReal > &rng, ParticleSet &pset_target)
same as above, but with spin variables included
Vector< Value > basis_laplacians_
void generateSamples(const Real weight, ParticleSet &pset_target, RandomBase< FullPrecReal > &rng, int steps=0)
Dispatch method to difference methods of generating samples.
Real get_timestep() const
bool get_corner_defined() const
void assignGaussRand(T *restrict a, unsigned n, RG &rng)
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
void evaluateMatrix(ParticleSet &pset_target, TrialWaveFunction &psi_target, const MCPWalker &walker, RandomBase< FullPrecReal > &rng)
omp_int_t omp_get_thread_num()
Specialized paritlce class for atomistic simulations.
std::vector< Position > rsamples_
Native representation for DensityMatrices1B Estimator's inputs.
QMCT::FullPrecRealType walkers_weight_
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
Scalar_t Volume
Physical properties of a supercell.
void generateDensitySamples(bool save, int steps, RandomBase< FullPrecReal > &rng, ParticleSet &pset_target)
generate samples for density integration
void warmupSampling(ParticleSet &pset_target, RandomBase< FullPrecReal > &rng)
does some warmup sampling i.e.
void product(const Matrix< T > &A, const Matrix< T > &B, Matrix< T > &C)
static function to perform C=AB for real matrices
This a subclass for runtime errors that will occur on all ranks.
bool get_use_drift() const
void evaluateVGL_spin(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi, ValueVector &dspin_psi) override
evaluate the values, gradients and laplacians and spin gradient of this single-particle orbital set ...
bool get_center_defined() const
std::vector< int > species_sizes_
An abstract class for gridded estimators.
Position diffuse(const Real sqt, RandomBase< FullPrecReal > &rng)
produce a position difference vector from timestep
OneBodyDensityMatricesInput input_
void generateParticleBasis(ParticleSet &pset_target, std::vector< Matrix< Value >> &phi_nb)
set phi_nb to basis values per target particleset particle sideeffects:
OneBodyDensityMatricesInput obdmi(node)
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
void generateUniformGrid(RandomBase< FullPrecReal > &rng)
bool get_normalized() const
void add(std::unique_ptr< SPOSet > component)
add a sposet component to this composite sposet
Vector< Real > samples_weights_
void calcDensityDriftWithSpin(const Position &r, const Real &s, Real &dens, Position &drift, Real &sdrift, ParticleSet &pset_target)
same as above, but with spin move
void calcDensityWithSpin(const Position &r, const Real &s, Real &dens, ParticleSet &pset_target)
same as above, but with spin move
void implAccumulate(const RefVector< MCPWalker > &walkers, const RefVector< ParticleSet > &psets, const RefVector< TrialWaveFunction > &wfns, RandomBase< FullPrecReal > &rng)
Unfortunate design RandomGenerator type aliasing and virtual inheritance requires this for testing...
void evaluateValue(const ParticleSet &P, int iat, ValueVector &psi) override
evaluate the values of this single-particle orbital set
Position get_center() const
Vector< Grad > basis_gradients_
Sampling sampling_
Sampling method, this derived values in input_.
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
std::vector< std::string > speciesName
Species name list.
Declaration of a TrialWaveFunction.
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
int get_warmup_samples() const
void evaluateVGL(const ParticleSet &P, int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi) override
evaluate the values, gradients and laplacians of this single-particle orbital set ...
Vector< Value > basis_values_
std::vector< std::reference_wrapper< T > > RefVector
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
void updateBasis(const Position &r, ParticleSet &pset_target)
basis set updates
Class to represent a many-body trial wave function.
int getAttribute(const std::string &aname) const
When a name species does not exist, return attribute.size()
void set_dimensions(const std::vector< int > &dims, int first)
set the shape of this observable
NewTimer & gen_sample_ratios_timer
const std::vector< std::string > & get_basis_sets() const
Real diffuseSpin(const Real sqt, RandomBase< FullPrecReal > &rng)
spin diffusion
CompositeSPOSet basis_functions_
std::vector< Matrix< Value > > Phi_Psi_NB_
Position get_corner() const
NewTimer & matrix_products_timer
DataLocality
data locality with respect to walker buffer
NewTimer & gen_samples_timer
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
SingleParticlePos toCart(const TinyVector< T1, D > &c) const
Convert a unit vector to a cartesian vector.
Custom container for set of attributes for a set of species.
std::vector< Matrix< Value > > N_BB_
Vector< Value > basis_norms_
Position rpcur_
current position – As long Positions are TinyVectors they are intialized to zero vectors ...
void registerOperatorEstimator(hdf_archive &file) override
create and tie OperatorEstimator's observable_helper hdf5 wrapper to stat.h5 file ...
int naccepted_
number of accepted samples
void product_AtB(const Matrix< T > &A, const Matrix< T > &B, Matrix< T > &C)
OneBodyDensityMatrices(OneBodyDensityMatricesInput &&obdmi, const Lattice &lattice, const SpeciesSet &species, const SPOMap &spomap, const ParticleSet &pset_target)
Standard Constructor Call this to make a new OBDM this is what you should be calling.
Integrator get_integrator() const
void startBlock(int steps) override
Real rhocur_
current density
A container class to represent a walker.
void generateUniformSamples(RandomBase< FullPrecReal > &rng)
void updateBasisD012WithSpin(const Position &r, const Real &s, ParticleSet &pset_target)
same as above, but includes spin gradients
Position dpcur_
current drift
std::vector< Value > psi_ratios_
, ' .
void diag_product(const Matrix< T1 > &A, const Vector< T2 > &B, Matrix< T3 > &C)
C = A*diag(B)
Evaluator get_evaluator() const
std::string my_name_
name of this object – only used for debugging and h5 output
std::vector< Matrix< Value > > Psi_NM_
ratio per particle per sample size: particles * samples vector is over species each matrix row: parti...