-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delayed update #242
Add delayed update #242
Conversation
test this please |
test this please |
Absolute error checking is quite unreliable on deteriminants. MP build is not checked with deteriminant.
Test this please |
Test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good improvements to the build and check_det is gone also good. But import of ParticleSet, EinsplineSPO and DiracDeterminant entanglements not previously an issue in miniqmc. Whether those should be added to develop is a question of what miniqmc is supposed to be...
I think the added entanglements are necessary for real QMC algorithm and QMCPACK needs. Ownership of SPO. EinsplineSPO or base class SPOSet. SPOSet using ParticleSet instead of particle positions. |
I don't understand the argument about the harmonic oscillator basis, but if you are just going to appeal to the main source code everytime miniqmc simply isn't useful for design discussions. I think it's much clearer if the actual terms needed to evaluate the function are in the function signature. If that requires specialized code that is fine there is an important detail that at least the einspline SPO doesn't have. So to me the second is much better. The idea that |
Anyway make the other changes and I will approve, the ParticleSet discussion is too big for this PR. |
I made a mistake harmonic oscillator is a SPO not a WaveFunctionComponent. I correct all the words and removed harmonic oscillator as example. I would consider the old design as one of the candidates of the new design not being excluded. I think for virtual functions and functions of templates classes, it is better to have call APIs as generic as possible. If call APIs and classes both need specialization, we cannot solve an all-to-all problem. |
Seems more like a specialization on an |
@PDoakORNL Could you correct my following broken code using
|
#include<vector>
#include<type_traits>
#include<iostream>
class LCAOSet
{
public:
void evaluate(double pos, std::vector<double>& ions) { std::cout << "ions matter\n"; }
};
class EinsplineSet
{
public:
void evaluate(double pos) { std::cout << "what's an ion?\n"; }
};
template <typename t>
struct isDependentOnIonPositions : public std::false_type {};
template<>
struct isDependentOnIonPositions<LCAOSet> : public std::true_type {};
template<class SPOT>
struct StateIShouldNotHave;
template<>
struct StateIShouldNotHave<EinsplineSet>
{
double pos = 1.0;
};
template<>
struct StateIShouldNotHave<LCAOSet>
{
double pos = 1.0;
std::vector<double> ions = {1.0, 2.0, 3.0};
};
template<class SPOT>
class Determinant
{
SPOT spo;
StateIShouldNotHave<SPOT> state;
public:
template<typename U = SPOT,
typename std::enable_if<isDependentOnIonPositions<U>::value, std::nullptr_t>::type = nullptr>
void ratioGrad()
{
spo.evaluate(state.pos , state.ions);
}
template<typename U = SPOT,
typename std::enable_if<!isDependentOnIonPositions<U>::value, std::nullptr_t>::type = nullptr>
void ratioGrad()
{
spo.evaluate(state.pos);
}
};
int main()
{
Determinant<LCAOSet> det_lcao;
Determinant<EinsplineSet> det_einsplineset;
det_einsplineset.ratioGrad();
det_lcao.ratioGrad();
} Even xlc++ can do it Edit: I'd rather the enable_if in the parameter list |
@PDoakORNL Thank you. I expected this complexity. If I have not just one call inside ratioGrad but very long function body, having it repeated the whole function because of 1 call difference, I feel, is not really worth it. If we have a third SPOSet which need another interface, the ratioGrad need a third version. Hopefully you can consider evaluate(const ParticleSet&) and we don't need to maintain this complexity. The code pattern you showed is very powerful to handle data types or functions from libraries which is often not allowed to be modified. Having traits and SFINAE works very well. |
Closes #239.
Unit test and "check_wfc -f Det" are added.