Skip to content

Commit

Permalink
single-particle update support for MultiComponentWaveFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
Ithanil committed Aug 14, 2019
1 parent 7ff9775 commit f3494d3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
22 changes: 12 additions & 10 deletions include/vmc/MultiComponentWaveFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace vmc
{

class MultiComponentWaveFunction: public WaveFunction
class MultiComponentWaveFunction final: public WaveFunction
{
private:
std::vector<WaveFunction *> _wfs;
Expand All @@ -24,31 +24,33 @@ class MultiComponentWaveFunction: public WaveFunction
}

// we contain ProtoFunctionInterfaces as members, so we need to implement these:
void _newToOld() override;
void _oldToNew() override;
void _newToOld() final;
void _oldToNew() final;

public:
MultiComponentWaveFunction(int nspacedim, int npart, bool flag_vd1 = false, bool flag_d1vd1 = false, bool flag_d2vd1 = false):
WaveFunction(nspacedim, npart, 0, 0, flag_vd1, flag_d1vd1, flag_d2vd1) {}
~MultiComponentWaveFunction() override
~MultiComponentWaveFunction() final
{
_wfs.clear();
}


void addWaveFunction(WaveFunction * wf);

void setVP(const double * vp) override;
void setVP(const double vp[]) final;

void getVP(double * vp) const override;
void getVP(double vp[]) const final;

void protoFunction(const double * in, double * out) override;
void protoFunction(const double in[], double out[]) final;

double acceptanceFunction(const double * protoold, const double * protonew) const override;
double acceptanceFunction(const double protoold[], const double protonew[]) const final;

void computeAllDerivatives(const double * x) override;
double updatedAcceptance(const mci::WalkerState &wlk, const double protoold[], double protonew[]) final;

double computeWFValue(const double * protovalues) const override;
void computeAllDerivatives(const double x[]) final;

double computeWFValue(const double protovalues[]) const final;
};
} // namespace vmc

Expand Down
23 changes: 17 additions & 6 deletions src/MultiComponentWaveFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void MultiComponentWaveFunction::computeAllDerivatives(const double x[])
}
}

double MultiComponentWaveFunction::computeWFValue(const double * protovalues) const
double MultiComponentWaveFunction::computeWFValue(const double protovalues[]) const
{
double out = 1.;
int contproto = 0;
Expand All @@ -123,7 +123,7 @@ double MultiComponentWaveFunction::computeWFValue(const double * protovalues) co
return out;
}

double MultiComponentWaveFunction::acceptanceFunction(const double * protoold, const double * protonew) const
double MultiComponentWaveFunction::acceptanceFunction(const double protoold[], const double protonew[]) const
{
double acceptance = 1.;
int contproto = 0;
Expand All @@ -134,7 +134,18 @@ double MultiComponentWaveFunction::acceptanceFunction(const double * protoold, c
return acceptance;
}

void MultiComponentWaveFunction::protoFunction(const double * in, double * out)
double MultiComponentWaveFunction::updatedAcceptance(const mci::WalkerState &wlk, const double protoold[], double protonew[])
{
double acceptance = 1.;
int contproto = 0;
for (WaveFunction * wf : _wfs) {
acceptance *= wf->updatedAcceptance(wlk, protoold + contproto, protonew + contproto);
contproto += wf->getNProto();
}
return acceptance;
}

void MultiComponentWaveFunction::protoFunction(const double in[], double out[])
{
int contproto = 0;
for (WaveFunction * wf : _wfs) {
Expand All @@ -144,7 +155,7 @@ void MultiComponentWaveFunction::protoFunction(const double * in, double * out)
}


void MultiComponentWaveFunction::getVP(double * vp) const
void MultiComponentWaveFunction::getVP(double vp[]) const
{
int contvp = 0;
for (WaveFunction * wf : _wfs) {
Expand All @@ -154,7 +165,7 @@ void MultiComponentWaveFunction::getVP(double * vp) const
}


void MultiComponentWaveFunction::setVP(const double * vp)
void MultiComponentWaveFunction::setVP(const double vp[])
{
int contvp = 0;
for (WaveFunction * wf : _wfs) {
Expand Down Expand Up @@ -201,4 +212,4 @@ void MultiComponentWaveFunction::_oldToNew()
wf->oldToNew();
}
}
} // namespace vmc
} // namespace vmc

0 comments on commit f3494d3

Please sign in to comment.