Skip to content

Commit

Permalink
Merge pull request QMCPACK#4772 from ye-luo/rename-type
Browse files Browse the repository at this point in the history
Type renaming Psi/LogValueType to Psi/LogValue
  • Loading branch information
ye-luo authored Oct 13, 2023
2 parents 687f341 + ab9e75a commit 6f7eefe
Show file tree
Hide file tree
Showing 59 changed files with 812 additions and 819 deletions.
10 changes: 5 additions & 5 deletions src/QMCDrivers/DMC/DMCBatched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
namespace qmcplusplus
{
using std::placeholders::_1;
using WP = WalkerProperties::Indexes;
using PsiValueType = TrialWaveFunction::PsiValueType;
using WP = WalkerProperties::Indexes;
using PsiValue = TrialWaveFunction::PsiValue;

/** Constructor maintains proper ownership of input parameters
*
Expand Down Expand Up @@ -119,7 +119,7 @@ void DMCBatched::advanceWalkers(const StateForThread& sft,
//This generates an entire steps worth of deltas.
makeGaussRandomWithEngine(walker_deltas, step_context.get_random_gen());

std::vector<PsiValueType> ratios(num_walkers, PsiValueType(0.0));
std::vector<PsiValue> ratios(num_walkers, PsiValue(0.0));
std::vector<RealType> log_gf(num_walkers, 0.0);
std::vector<RealType> log_gb(num_walkers, 0.0);
std::vector<RealType> prob(num_walkers, 0.0);
Expand Down Expand Up @@ -195,8 +195,8 @@ void DMCBatched::advanceWalkers(const StateForThread& sft,

computeLogGreensFunction(drifts_reverse, taus, log_gb);

auto checkPhaseChanged = [&sft](const PsiValueType& ratio, int& is_reject) {
if (ratio == PsiValueType(0) || sft.branch_engine.phaseChanged(std::arg(ratio)))
auto checkPhaseChanged = [&sft](const PsiValue& ratio, int& is_reject) {
if (ratio == PsiValue(0) || sft.branch_engine.phaseChanged(std::arg(ratio)))
is_reject = 1;
else
is_reject = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/QMCDrivers/QMCDriverNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void QMCDriverNew::checkLogAndGL(Crowd& crowd, const std::string_view location)

const RefVectorWithLeader<ParticleSet> walker_elecs(crowd.get_walker_elecs()[0], crowd.get_walker_elecs());
const RefVectorWithLeader<TrialWaveFunction> walker_twfs(crowd.get_walker_twfs()[0], crowd.get_walker_twfs());
std::vector<TrialWaveFunction::LogValueType> log_values(walker_twfs.size());
std::vector<TrialWaveFunction::LogValue> log_values(walker_twfs.size());
std::vector<ParticleSet::ParticleGradient> Gs;
std::vector<ParticleSet::ParticleLaplacian> Ls;
Gs.reserve(log_values.size());
Expand Down Expand Up @@ -545,7 +545,7 @@ void QMCDriverNew::checkLogAndGL(Crowd& crowd, const std::string_view location)
{
auto& ref_G = walker_twfs[iw].G;
auto& ref_L = walker_twfs[iw].L;
TrialWaveFunction::LogValueType ref_log{walker_twfs[iw].getLogPsi(), walker_twfs[iw].getPhase()};
TrialWaveFunction::LogValue ref_log{walker_twfs[iw].getLogPsi(), walker_twfs[iw].getPhase()};
if (std::abs(std::exp(log_values[iw]) - std::exp(ref_log)) > std::abs(std::exp(ref_log)) * threshold)
{
success = false;
Expand Down
4 changes: 2 additions & 2 deletions src/QMCDrivers/QMCUpdateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ QMCUpdateBase::RealType QMCUpdateBase::getNodeCorrection(const ParticleSet::Part
void QMCUpdateBase::checkLogAndGL(ParticleSet& pset, TrialWaveFunction& twf, const std::string_view location)
{
bool success = true;
TrialWaveFunction::LogValueType log_value{twf.getLogPsi(), twf.getPhase()};
TrialWaveFunction::LogValue log_value{twf.getLogPsi(), twf.getPhase()};
ParticleSet::ParticleGradient G_saved = twf.G;
ParticleSet::ParticleLaplacian L_saved = twf.L;

Expand All @@ -294,7 +294,7 @@ void QMCUpdateBase::checkLogAndGL(ParticleSet& pset, TrialWaveFunction& twf, con
std::ostringstream msg;
auto& ref_G = twf.G;
auto& ref_L = twf.L;
TrialWaveFunction::LogValueType ref_log{twf.getLogPsi(), twf.getPhase()};
TrialWaveFunction::LogValue ref_log{twf.getLogPsi(), twf.getPhase()};
if (std::abs(std::exp(log_value) - std::exp(ref_log)) > std::abs(std::exp(ref_log)) * threshold)
{
success = false;
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/VMC/VMCBatched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void VMCBatched::advanceWalkers(const StateForThread& sft,
constexpr RealType mhalf(-0.5);
const bool use_drift = sft.vmcdrv_input.get_use_drift();

std::vector<TrialWaveFunction::PsiValueType> ratios(num_walkers);
std::vector<TrialWaveFunction::PsiValue> ratios(num_walkers);
std::vector<RealType> log_gf(num_walkers);
std::vector<RealType> log_gb(num_walkers);
std::vector<RealType> prob(num_walkers);
Expand Down
12 changes: 7 additions & 5 deletions src/QMCDrivers/WaveFunctionTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ class FiniteDifference : public QMCTraits
FiniteDiff_LowOrder, // use simplest low-order formulas
FiniteDiff_Richardson // use Richardson extrapolation
};
FiniteDifference(size_t ndim_in, FiniteDiffType fd_type = FiniteDiff_Richardson) : ndim(ndim_in), m_RichardsonSize(10), m_fd_type(fd_type) {}
FiniteDifference(size_t ndim_in, FiniteDiffType fd_type = FiniteDiff_Richardson)
: ndim(ndim_in), m_RichardsonSize(10), m_fd_type(fd_type)
{}

const size_t ndim;
int m_RichardsonSize;
Expand Down Expand Up @@ -790,7 +792,7 @@ bool WaveFunctionTester::checkGradientAtConfiguration(MCWalkerConfiguration::Wal
ParticleSet::ParticleLaplacian L(nat), tmpL(nat), L1(nat);


LogValueType logpsi1 = orb->evaluateLog(W, G, L);
LogValue logpsi1 = orb->evaluateLog(W, G, L);

fail_log << "WaveFunctionComponent " << iorb << " " << orb->getClassName() << " log psi = " << logpsi1 << std::endl;

Expand All @@ -804,7 +806,7 @@ bool WaveFunctionTester::checkGradientAtConfiguration(MCWalkerConfiguration::Wal
ParticleSet::SingleParticlePos zeroR;
W.makeMove(it->index, zeroR);

LogValueType logpsi0 = orb->evaluateLog(W, tmpG, tmpL);
LogValue logpsi0 = orb->evaluateLog(W, tmpG, tmpL);
#if defined(QMC_COMPLEX)
ValueType logpsi(logpsi0.real(), logpsi0.imag());
#else
Expand Down Expand Up @@ -836,7 +838,7 @@ bool WaveFunctionTester::checkGradientAtConfiguration(MCWalkerConfiguration::Wal
ParticleSet::ParticleGradient G(nat), tmpG(nat), G1(nat);
ParticleSet::ParticleLaplacian L(nat), tmpL(nat), L1(nat);
DiracDeterminantBase& det = *sd->Dets[isd];
LogValueType logpsi2 = det.evaluateLog(W, G, L); // this won't work with backflow
LogValue logpsi2 = det.evaluateLog(W, G, L); // this won't work with backflow
fail_log << " Slater Determiant " << isd << " (for particles " << det.getFirstIndex() << " to "
<< det.getLastIndex() << ") log psi = " << logpsi2 << std::endl;
// Should really check the condition number on the matrix determinant.
Expand All @@ -853,7 +855,7 @@ bool WaveFunctionTester::checkGradientAtConfiguration(MCWalkerConfiguration::Wal
W.R[it->index] = it->r;
W.update();

LogValueType logpsi0 = det.evaluateLog(W, tmpG, tmpL);
LogValue logpsi0 = det.evaluateLog(W, tmpG, tmpL);
#if defined(QMC_COMPLEX)
ValueType logpsi(logpsi0.real(), logpsi0.imag());
#else
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/WaveFunctionTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class WaveFunctionTester : public QMCDriver
{
public:
/// type definition
using LogValueType = WaveFunctionComponent::LogValueType;
using LogValue = WaveFunctionComponent::LogValue;

/// Constructor.
WaveFunctionTester(const ProjectData& project_data,
Expand Down
10 changes: 5 additions & 5 deletions src/QMCWaveFunctions/AGPDeterminant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ void AGPDeterminant::resize(int nup, int ndown)
*contribution of the determinant to G(radient) and L(aplacian)
*for local energy calculations.
*/
AGPDeterminant::LogValueType AGPDeterminant::evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L)
AGPDeterminant::LogValue AGPDeterminant::evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L)
{
evaluateLogAndStore(P);
G += myG;
Expand Down Expand Up @@ -172,7 +172,7 @@ void AGPDeterminant::registerData(ParticleSet& P, WFBufferType& buf)
//buf.add(myL.begin(), myL.end());
}

AGPDeterminant::LogValueType AGPDeterminant::updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch)
AGPDeterminant::LogValue AGPDeterminant::updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch)
{
evaluateLogAndStore(P);
P.G += myG;
Expand Down Expand Up @@ -224,7 +224,7 @@ void AGPDeterminant::copyFromBuffer(ParticleSet& P, WFBufferType& buf)
* @param P current configuration
* @param iat the particle thas is being moved
*/
AGPDeterminant::PsiValueType AGPDeterminant::ratio(ParticleSet& P, int iat)
AGPDeterminant::PsiValue AGPDeterminant::ratio(ParticleSet& P, int iat)
{
UpdateMode = ORB_PBYP_RATIO;
//GeminalBasis->evaluate(P,iat);
Expand Down
12 changes: 6 additions & 6 deletions src/QMCWaveFunctions/AGPDeterminant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class AGPDeterminant : public WaveFunctionComponent

void registerData(ParticleSet& P, WFBufferType& buf) override;

LogValueType updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) override;
LogValue updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) override;

void copyFromBuffer(ParticleSet& P, WFBufferType& buf) override;

/** return the ratio only for the iat-th partcle move
* @param P current configuration
* @param iat the particle thas is being moved
*/
PsiValueType ratio(ParticleSet& P, int iat) override;
PsiValue ratio(ParticleSet& P, int iat) override;

void ratioUp(ParticleSet& P, int iat);

Expand All @@ -87,9 +87,9 @@ class AGPDeterminant : public WaveFunctionComponent
*contribution of the determinant to G(radient) and L(aplacian)
*for local energy calculations.
*/
LogValueType evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L) override;
LogValue evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L) override;

std::unique_ptr<WaveFunctionComponent> makeClone(ParticleSet& tqp) const override;

Expand Down Expand Up @@ -157,7 +157,7 @@ class AGPDeterminant : public WaveFunctionComponent
IndexVector Pivot;

///current ratio
PsiValueType curRatio;
PsiValue curRatio;
///cummulate ratio for particle-by-particle update
RealType cumRatio;
///address of dpsiU[0][0]
Expand Down
14 changes: 7 additions & 7 deletions src/QMCWaveFunctions/ConstantOrbital.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ namespace qmcplusplus
class ConstantOrbital : public WaveFunctionComponent
{
public:
PsiValueType FakeGradRatio;
PsiValue FakeGradRatio;

ConstantOrbital() : FakeGradRatio(1.0) {}

std::string getClassName() const override { return "ConstantOrbital"; }

LogValueType evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L) override
LogValue evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L) override
{
G = 0.0;
L = 0.0;
Expand All @@ -39,15 +39,15 @@ class ConstantOrbital : public WaveFunctionComponent

void restore(int iat) override {}

PsiValueType ratio(ParticleSet& P, int iat) override { return 1.0; }
PsiValue ratio(ParticleSet& P, int iat) override { return 1.0; }

GradType evalGrad(ParticleSet& P, int iat) override { return GradType(0.0); }

PsiValueType ratioGrad(ParticleSet& P, int iat, GradType& grad_iat) override { return FakeGradRatio; }
PsiValue ratioGrad(ParticleSet& P, int iat, GradType& grad_iat) override { return FakeGradRatio; }

void registerData(ParticleSet& P, WFBufferType& buf) override {}

LogValueType updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) override { return 0.0; }
LogValue updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) override { return 0.0; }

void copyFromBuffer(ParticleSet& P, WFBufferType& buf) override {}

Expand Down
16 changes: 8 additions & 8 deletions src/QMCWaveFunctions/ExampleHeComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ bool ExampleHeComponent::put(xmlNodePtr cur)
return true;
}

ExampleHeComponent::LogValueType ExampleHeComponent::evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L)
ExampleHeComponent::LogValue ExampleHeComponent::evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L)
{
const auto& ee_table = P.getDistTableAA(my_table_ee_idx_);
const auto& ee_dists = ee_table.getDistances();
Expand Down Expand Up @@ -111,7 +111,7 @@ ExampleHeComponent::LogValueType ExampleHeComponent::evaluateLog(const ParticleS
return log_value_;
}

ExampleHeComponent::PsiValueType ExampleHeComponent::ratio(ParticleSet& P, int iat)
ExampleHeComponent::PsiValue ExampleHeComponent::ratio(ParticleSet& P, int iat)
{
const auto& ee_table = P.getDistTableAA(my_table_ee_idx_);
const auto& ee_dists = ee_table.getDistances();
Expand All @@ -134,7 +134,7 @@ ExampleHeComponent::PsiValueType ExampleHeComponent::ratio(ParticleSet& P, int i
double log_v_old = -Z * (r_old)-u_old;
double log_v_new = -Z * (r_new)-u_new;

return std::exp(static_cast<PsiValueType>(log_v_new - log_v_old));
return std::exp(static_cast<PsiValue>(log_v_new - log_v_old));
}

ExampleHeComponent::GradType ExampleHeComponent::evalGrad(ParticleSet& P, int iat)
Expand All @@ -159,7 +159,7 @@ ExampleHeComponent::GradType ExampleHeComponent::evalGrad(ParticleSet& P, int ia
return Z * rhat + rhat12 * du;
}

ExampleHeComponent::PsiValueType ExampleHeComponent::ratioGrad(ParticleSet& P, int iat, GradType& grad_iat)
ExampleHeComponent::PsiValue ExampleHeComponent::ratioGrad(ParticleSet& P, int iat, GradType& grad_iat)
{
const auto& ee_table = P.getDistTableAA(my_table_ee_idx_);
const auto& ee_dists = ee_table.getDistances();
Expand Down Expand Up @@ -195,11 +195,11 @@ ExampleHeComponent::PsiValueType ExampleHeComponent::ratioGrad(ParticleSet& P, i
double log_v_old = -Z * (r_old)-u_old;
double log_v_new = -Z * (r_new)-u_new;

return std::exp(static_cast<PsiValueType>(log_v_new - log_v_old));
return std::exp(static_cast<PsiValue>(log_v_new - log_v_old));
}


ExampleHeComponent::LogValueType ExampleHeComponent::updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch)
ExampleHeComponent::LogValue ExampleHeComponent::updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch)
{
return evaluateLog(P, P.G, P.L);
}
Expand Down
12 changes: 6 additions & 6 deletions src/QMCWaveFunctions/ExampleHeComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ class ExampleHeComponent : public WaveFunctionComponent, OptimizableObject
void checkOutVariables(const OptVariablesType& active) override { my_vars_.getIndex(active); }
void resetParametersExclusive(const OptVariablesType& active) override;

LogValueType evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L) override;
LogValue evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient& G,
ParticleSet::ParticleLaplacian& L) override;

void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) override {}

void restore(int iat) override {}

PsiValueType ratio(ParticleSet& P, int iat) override;
PsiValue ratio(ParticleSet& P, int iat) override;

GradType evalGrad(ParticleSet& P, int iat) override;

PsiValueType ratioGrad(ParticleSet& P, int iat, GradType& grad_iat) override;
PsiValue ratioGrad(ParticleSet& P, int iat, GradType& grad_iat) override;

void evaluateDerivatives(ParticleSet& P,
const OptVariablesType& optvars,
Expand All @@ -64,7 +64,7 @@ class ExampleHeComponent : public WaveFunctionComponent, OptimizableObject

void registerData(ParticleSet& P, WFBufferType& buf) override {}

LogValueType updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) override;
LogValue updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) override;

void copyFromBuffer(ParticleSet& P, WFBufferType& buf) override {}

Expand Down
Loading

0 comments on commit 6f7eefe

Please sign in to comment.