Skip to content

Commit

Permalink
enable accuracy vs time comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkrogel committed Jan 13, 2020
1 parent 3ef40f0 commit d55eeba
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/QMCHamiltonians/CoulombPBCAA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,31 @@ CoulombPBCAA::CoulombPBCAA(ParticleSet& ref, bool active, bool computeForces)
//ewald.findOptKGrid(R);


ewald.setupOpt(R,dt);

app_log()<<" sr ref : "<< ewald.ewaldEnergySR(R) <<std::endl;
app_log()<<" sr opt : "<< ewald.ewaldEnergySROpt(dt) <<" "<<ewald.getKappa() <<std::endl;

//auto g = 2*ewald.nkmax+1;
//size_t nkpoints_ref = g[0]*g[1]*g[2];

//ewald.setupOpt(R,dt);
//
//app_log()<<" sr ref : "<< sr_ref <<std::endl;
//app_log()<<" sr opt : "<< ewald.ewaldEnergySROpt(dt) <<" "<<ewald.getKappa() <<std::endl;
//
//
//app_log()<<std::endl;
//app_log()<<std::endl;
//
//app_log()<<" lr ref : "<< lr_ref<<" "<< nkpoints_ref <<std::endl;
//app_log()<<" lr opt : "<< ewald.ewaldEnergyLROpt(R) <<" "<< ewald.getNkpoints() <<std::endl;
//
//app_log()<<" ewald optimized energy: "<<ewald.ewaldEnergyOpt(R,dt)<<std::endl;



app_log()<<std::endl;
app_log()<<std::endl;

RealType lr_ref = ewald.ewaldEnergyLR(R);
auto g = 2*ewald.nkmax+1;
app_log()<<" lr ref : "<< lr_ref<<" "<< g[0]*g[1]*g[2] <<std::endl;
app_log()<<" lr opt : "<< ewald.ewaldEnergyLROpt(R) <<" "<< ewald.getNkpoints() <<std::endl;
ewald.printErrorAndTimeVSTolerance(R,dt);



Expand Down
23 changes: 23 additions & 0 deletions src/QMCHamiltonians/EwaldTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#define EWALD_TOOLS_H

#include "QMCHamiltonians/EwaldRef.h"
#include "Utilities/Clock.h"


namespace qmcplusplus
{
Expand Down Expand Up @@ -810,6 +812,27 @@ class AnisotropicEwald
}
}

template<typename PA, typename DT>
void printErrorAndTimeVSTolerance(const PA& R, const DT& dt)
{
std::cout << std::scientific;
real_t ref_errtol = 1e-20;
real_t t1,t2,t3;
for(int n=0;n<16;n++)
{
real_t errtol = 1.0*std::pow(10.0,-n);
setupOpt(R,dt,errtol);
real_t sr_ref = ewaldEnergySR(R,ref_errtol);
real_t lr_ref = ewaldEnergyLR(R,ref_errtol);
t1 = cpu_clock();
real_t sr = ewaldEnergySROpt(dt);
t2 = cpu_clock();
real_t lr = ewaldEnergyLROpt(R);
t3 = cpu_clock();
std::cout<<n<<" "<<errtol<<" "<<sr-sr_ref<<" "<<lr-lr_ref<<" "<<t2-t1<<" "<<t3-t2<<" "<<getNkpoints()<<std::endl;
}

}


/// SR (real-space) part of total energy computed adaptively
Expand Down

0 comments on commit d55eeba

Please sign in to comment.