Commit de21bb80 by Francois Gygi

Cleanup test programs

parent a3122518
......@@ -99,8 +99,19 @@ CXXFLAGS += -DTARGET='"$(TARGET)"'
testEnergyFunctional: testEnergyFunctional.o EnergyFunctional.o Basis.o \
SlaterDet.o Matrix.o UnitCell.o Context.o FourierTransform.o \
Wavefunction.o Species.o Atom.o AtomSet.o StructureFactor.o \
ChargeDensity.o \
sinft.o spline.o
ExtForceSet.o ExtForce.o PairExtForce.o AtomicExtForce.o \
GlobalExtForce.o \
ConstraintSet.o Constraint.o DistanceConstraint.o \
AngleConstraint.o TorsionConstraint.o PositionConstraint.o \
NonLocalPotential.o sampling.o Base64Transcoder.o \
ChargeDensity.o sinft.o spline.o \
XCOperator.o ExchangeOperator.o Bisection.o \
XCPotential.o LDAFunctional.o VWNFunctional.o \
PBEFunctional.o BLYPFunctional.o B3LYPFunctional.o \
BHandHLYPFunctional.o \
ExponentialIntegral.o HSEFunctional.o RSHFunctional.o \
ConfinementPotential.o ElectricEnthalpy.o MLWFTransform.o \
jade.o BasisMapping.o
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
testSlaterDet: testSlaterDet.o SlaterDet.o FourierTransform.o \
Basis.o UnitCell.o Matrix.o Context.o Base64Transcoder.o
......@@ -113,6 +124,10 @@ CXXFLAGS += -DTARGET='"$(TARGET)"'
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
testXCFunctional: testXCFunctional.o LDAFunctional.o PBEFunctional.o
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
testLDAFunctional: testLDAFunctional.o LDAFunctional.o
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
testVWN: testVWN.o VWNFunctional.o LDAFunctional.o
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
testMatrix: testMatrix.o Matrix.o Context.o
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
testjacobi: testjacobi.o jacobi.o Matrix.o Context.o
......@@ -131,6 +146,8 @@ CXXFLAGS += -DTARGET='"$(TARGET)"'
testXMLGFPreprocessor: testXMLGFPreprocessor.o XMLGFPreprocessor.o Context.o \
Base64Transcoder.o Matrix.o
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
testBase64Transcoder: testBase64Transcoder.o Base64Transcoder.o
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
test_fftw: test_fftw.o $(PLTOBJECTS)
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
#------------------------------------------------------------------------------
......@@ -666,7 +683,8 @@ SpeciesReader.o: Species.h SpeciesReader.h StructuredDocumentHandler.h StrX.h
SpeciesReader.o: StructureHandler.h SpeciesHandler.h
StatusCmd.o: UserInterface.h Sample.h AtomSet.h Context.h blacs.h Atom.h
StatusCmd.o: D3vector.h UnitCell.h D3tensor.h blas.h ConstraintSet.h
StatusCmd.o: ExtForceSet.h Wavefunction.h Control.h
StatusCmd.o: ExtForceSet.h Wavefunction.h Control.h ChargeDensity.h Timer.h
StatusCmd.o: FourierTransform.h
StrainCmd.o: UserInterface.h Sample.h AtomSet.h Context.h blacs.h Atom.h
StrainCmd.o: D3vector.h UnitCell.h D3tensor.h blas.h ConstraintSet.h
StrainCmd.o: ExtForceSet.h Wavefunction.h Control.h
......@@ -754,14 +772,15 @@ qb.o: FoldInWsCmd.h HelpCmd.h KpointCmd.h ListAtomsCmd.h ListSpeciesCmd.h
qb.o: LoadCmd.h MoveCmd.h PartialChargeCmd.h PlotCmd.h PrintCmd.h QuitCmd.h
qb.o: RandomizeRCmd.h RandomizeVCmd.h RandomizeWfCmd.h ResetRotationCmd.h
qb.o: ResetVcmCmd.h RescaleVCmd.h RseedCmd.h RunCmd.h SaveCmd.h SetCmd.h
qb.o: SetVelocityCmd.h SpeciesCmd.h StatusCmd.h StrainCmd.h TorsionCmd.h
qb.o: BisectionCmd.h Bisection.h SlaterDet.h Basis.h Matrix.h AlphaPBE0.h
qb.o: AlphaRSH.h AtomsDyn.h BetaRSH.h BlHF.h BtHF.h Cell.h CellDyn.h
qb.o: CellLock.h CellMass.h ChargeMixCoeff.h ChargeMixNdim.h ChargeMixRcut.h
qb.o: Debug.h Dspin.h Ecut.h Ecutprec.h Ecuts.h Efield.h Polarization.h
qb.o: Emass.h ExtStress.h FermiTemp.h IterCmd.h IterCmdPeriod.h Dt.h MuRSH.h
qb.o: Nempty.h NetCharge.h Nrowmax.h Nspin.h RefCell.h ScfTol.h Stress.h
qb.o: Thermostat.h ThTemp.h ThTime.h ThWidth.h WfDiag.h WfDyn.h Xc.h
qb.o: SetVelocityCmd.h SpeciesCmd.h StatusCmd.h ChargeDensity.h
qb.o: FourierTransform.h StrainCmd.h TorsionCmd.h BisectionCmd.h Bisection.h
qb.o: SlaterDet.h Basis.h Matrix.h AlphaPBE0.h AlphaRSH.h AtomsDyn.h
qb.o: BetaRSH.h BlHF.h BtHF.h Cell.h CellDyn.h CellLock.h CellMass.h
qb.o: ChargeMixCoeff.h ChargeMixNdim.h ChargeMixRcut.h Debug.h Dspin.h Ecut.h
qb.o: Ecutprec.h Ecuts.h Efield.h Polarization.h Emass.h ExtStress.h
qb.o: FermiTemp.h IterCmd.h IterCmdPeriod.h Dt.h MuRSH.h Nempty.h NetCharge.h
qb.o: Nrowmax.h Nspin.h RefCell.h ScfTol.h Stress.h Thermostat.h ThTemp.h
qb.o: ThTime.h ThWidth.h WfDiag.h WfDyn.h Xc.h
qbox_xmlns.o: qbox_xmlns.h
release.o: release.h
sinft.o: sinft.h
......@@ -779,9 +798,9 @@ testContext.o: Context.h blacs.h
testEnergyFunctional.o: Context.h blacs.h Sample.h AtomSet.h Atom.h
testEnergyFunctional.o: D3vector.h UnitCell.h D3tensor.h blas.h
testEnergyFunctional.o: ConstraintSet.h ExtForceSet.h Wavefunction.h
testEnergyFunctional.o: Control.h EnergyFunctional.h StructureFactor.h
testEnergyFunctional.o: ElectricEnthalpy.h Matrix.h SlaterDet.h Basis.h
testEnergyFunctional.o: Timer.h
testEnergyFunctional.o: Control.h ChargeDensity.h Timer.h EnergyFunctional.h
testEnergyFunctional.o: StructureFactor.h ElectricEnthalpy.h Matrix.h
testEnergyFunctional.o: SlaterDet.h Basis.h
testFourierTransform.o: Basis.h D3vector.h UnitCell.h FourierTransform.h
testFourierTransform.o: Timer.h
testLDAFunctional.o: LDAFunctional.h XCFunctional.h
......
......@@ -18,6 +18,7 @@
#include "Base64Transcoder.h"
#include <iostream>
#include <cassert>
using namespace std;
int main()
......
......@@ -26,6 +26,7 @@
#include <fstream>
#include <iomanip>
#include <cassert>
#include <cstdlib>
using namespace std;
#ifdef USE_MPI
......@@ -39,7 +40,6 @@ int main(int argc, char **argv)
#endif
{
// use: testBasisMapping a0 a1 a2 b0 b1 b2 c0 c1 c2 ecut npr npc
double err;
assert(argc==13);
D3vector a(atof(argv[1]),atof(argv[2]),atof(argv[3]));
D3vector b(atof(argv[4]),atof(argv[5]),atof(argv[6]));
......
......@@ -40,7 +40,13 @@ int main(int argc, char **argv)
{
// use:
// testChargeDensity a0 a1 a2 b0 b1 b2 c0 c1 c2 ecut nel nspin nkp
assert(argc==14);
if ( argc !=14 )
{
cout <<
" use: testChargeDensity a0 a1 a2 b0 b1 b2 c0 c1 c2 ecut nel nspin nkp"
<< endl;
return 1;
}
D3vector a(atof(argv[1]),atof(argv[2]),atof(argv[3]));
D3vector b(atof(argv[4]),atof(argv[5]),atof(argv[6]));
D3vector c(atof(argv[7]),atof(argv[8]),atof(argv[9]));
......
......@@ -32,6 +32,11 @@ int main(int argc, char **argv)
MPI_Comm_size(MPI_COMM_WORLD, &npes);
MPI_Comm_rank(MPI_COMM_WORLD, &mype);
if ( argc != 3 )
{
cout << "use: testContext nrow ncol" << endl;
return 1;
}
int nr = atoi(argv[1]);
int nc = atoi(argv[2]);
......
......@@ -19,6 +19,7 @@
#include "Context.h"
#include "Sample.h"
#include "Wavefunction.h"
#include "ChargeDensity.h"
#include "EnergyFunctional.h"
#include "Timer.h"
......@@ -38,7 +39,12 @@ int main(int argc, char **argv)
#endif
{
// use: testEnergyFunctional a0 a1 a2 b0 b1 b2 c0 c1 c2 ecut nel
assert(argc==12);
if ( argc != 12 )
{
cout << "use: testEnergyFunctional a0 a1 a2 b0 b1 b2 c0 c1 c2 ecut nel"
<< endl;
return 1;
}
D3vector a(atof(argv[1]),atof(argv[2]),atof(argv[3]));
D3vector b(atof(argv[4]),atof(argv[5]),atof(argv[6]));
D3vector c(atof(argv[7]),atof(argv[8]),atof(argv[9]));
......@@ -48,21 +54,17 @@ int main(int argc, char **argv)
Timer tm;
Context ctxt;
Context ctxt(MPI_COMM_WORLD);
cout << " initial context: " << ctxt;
Sample s(ctxt);
s.atoms.addAtom(
new Atom("G","gaussium",D3vector(0.2,0.3,0),D3vector(0,0,0)));
s.atoms.listAtoms();
s.atoms.listSpecies();
s.wf.resize(cell,cell,ecut);
s.wf.set_nel(nel);
if ( ctxt.onpe0() ) cout << " nel: " << s.wf.nel() << endl;
s.wf.update_occ();
//s.wf.randomize(0.05);
s.wf.update_occ(0.0);
s.wf.randomize(0.05);
tm.reset();
tm.start();
......@@ -70,16 +72,31 @@ int main(int argc, char **argv)
tm.stop();
cout << " Gram: CPU/Real: " << tm.cpu() << " / " << tm.real() << endl;
ChargeDensity cd(s.wf);
tm.reset();
tm.start();
EnergyFunctional ef(s);
cout << " ChargeDensity::update_density..." << endl;
cd.update_density();
tm.stop();
cout << " ChargeDensity::update_density: CPU/Real: "
<< tm.cpu() << " / " << tm.real() << endl;
s.ctrl.xc = "LDA";
s.ctrl.polarization = "OFF";
tm.reset();
tm.start();
EnergyFunctional ef(s,cd);
tm.stop();
cout << " EnergyFunctional:ctor: CPU/Real: "
<< tm.cpu() << " / " << tm.real() << endl;
tm.reset();
tm.start();
cout << " ef.energy(): " << ef.energy() << endl;
Wavefunction dwf(s.wf);
vector<vector<double> > fion;
valarray<double> sigma(6);
double e = ef.energy(true,dwf,false,fion,false,sigma);
cout << " ef.energy(): " << e << endl;
tm.stop();
cout << " EnergyFunctional:energy: CPU/Real: "
<< tm.cpu() << " / " << tm.real() << endl;
......
......@@ -23,27 +23,26 @@
// dExc/da must be 0.911682
#include<iostream>
#include<vector>
#include "LDAFunctional.h"
#include <cassert>
#include <cmath>
#include <cstdlib>
using namespace std;
int main(int argc, char **argv)
{
// use: testxcf alat np
if ( argc != 3 )
{
cout << " use: testLDAFunctional alat np" << endl;
return 0;
cout << " use: testLDAFunctional alat n" << endl;
return 1;
}
assert(argc==3);
double a = atof(argv[1]);
double omega = a*a*a;
int n = atoi(argv[2]);
int n3 = n*n*n;
double *rh = new double[n3];
double *vxc = new double[n3];
double *exc = new double[n3];
vector<vector<double> > rh(1);
rh[0].resize(n3);
double excsum = 0.0, dxcsum = 0.0;
double rc = 0.1 * a;
......@@ -62,8 +61,8 @@ int main(int argc, char **argv)
double z = ( k * a ) / n - a/2;
double r2 = x*x + y*y + z*z;
int ii = i + n * ( j + n * k );
rh[ii] = fac * exp( -r2 / (rc*rc) );
sum += rh[ii];
rh[0][ii] = fac * exp( -r2 / (rc*rc) );
sum += rh[0][ii];
}
}
}
......@@ -71,19 +70,13 @@ int main(int argc, char **argv)
// the density should be normalized
cout << " Integrated density: " << sum << endl;
LDAFunctional xcf;
int nspin = 1;
xcf.rho = rh;
xcf.vxc1 = vxc;
xcf.exc = exc;
xcf.setxc(n3,nspin);
LDAFunctional xcf(rh);
xcf.setxc();
for ( int i = 0; i < n3; i++ )
excsum += rh[i] * exc[i];
excsum += xcf.rho[i] * xcf.exc[i];
for ( int i = 0; i < n3; i++ )
dxcsum += rh[i] * ( exc[i] - vxc[i] );
dxcsum += xcf.rho[i] * ( xcf.exc[i] - xcf.vxc1[i] );
cout << " Total LDA xc energy: " << excsum * omega / n3 << endl;
......
......@@ -61,6 +61,11 @@ int main(int argc, char **argv)
ifstream infile(infilename);
assert(argc == 2 || argc == 3);
if ( !(argc==2 || argc==3) )
{
cout << "use: testMatrix inputfile [-check]" << endl;
return 1;
}
bool tcheck = false;
if ( argc == 3 )
{
......
......@@ -45,6 +45,11 @@ int main(int argc, char** argv)
SampleReader s_reader(s->ctxt_);
bool serial = false;
if ( argc != 2 )
{
cout << "use: testSampleReader {file|URI}" << endl;
return 1;
}
const char* filename = argv[1];
try
......
......@@ -38,8 +38,15 @@ int main(int argc, char **argv)
#endif
{
// use: testSlaterDet a0 a1 a2 b0 b1 b2 c0 c1 c2 ecut nst kx ky kz npr npc
if ( argc != 17 )
{
cout <<
"use: testSlaterDet a0 a1 a2 b0 b1 b2 c0 c1 c2 ecut nst kx ky kz npr npc"
<< endl;
return 1;
}
double err;
assert(argc==17);
D3vector a(atof(argv[1]),atof(argv[2]),atof(argv[3]));
D3vector b(atof(argv[4]),atof(argv[5]),atof(argv[6]));
D3vector c(atof(argv[7]),atof(argv[8]),atof(argv[9]));
......
......@@ -37,7 +37,13 @@ int main(int argc, char **argv)
{
// use:
// testWavefunction a0 a1 a2 b0 b1 b2 c0 c1 c2 ecut nel nempty nspin nkp
assert(argc==15);
if ( argc != 15 )
{
cout <<
"use: testWavefunction a0 a1 a2 b0 b1 b2 c0 c1 c2 ecut nel nempty nspin nkp"
<< endl;
return 1;
}
D3vector a(atof(argv[1]),atof(argv[2]),atof(argv[3]));
D3vector b(atof(argv[4]),atof(argv[5]),atof(argv[6]));
D3vector c(atof(argv[7]),atof(argv[8]),atof(argv[9]));
......@@ -72,6 +78,12 @@ int main(int argc, char **argv)
cout << " wf.set_nspin: CPU/Real: "
<< tm.cpu() << " / " << tm.real() << endl;
tm.reset(); tm.start();
wf.set_nempty(nempty);
tm.stop();
cout << " wf.set_nempty: CPU/Real: "
<< tm.cpu() << " / " << tm.real() << endl;
for ( int ikp = 0; ikp < nkp-1; ikp++ )
{
wf.add_kpoint(D3vector((0.5*(ikp+1))/(nkp-1),0,0),1.0);
......
......@@ -29,6 +29,7 @@
#include "Timer.h"
#include <cassert>
#include <cmath>
#include <cstdlib>
using namespace std;
int main(int argc, char **argv)
......
......@@ -34,7 +34,11 @@ int main(int argc, char** argv)
// extra scope to ensure that BlacsContext objects get destructed before
// the MPI_Finalize call
{
assert(argc==4);
if ( argc != 4 )
{
cout << "use: testXMLGFPreprocessor nprow npcol filename" << endl;
return 1;
}
const int nr = atoi(argv[1]);
const int nc = atoi(argv[2]);
const char* const filename = argv[3];
......
......@@ -65,7 +65,11 @@ int main(int argc, char **argv)
//ifstream infile(infilename);
Timer tm;
assert(argc==5);
if ( argc != 5 )
{
cout << "use: testjacobi nprow npcol n nb" << endl;
return 1;
}
int nprow=atoi(argv[1]);
int npcol=atoi(argv[2]);
int m_a=atoi(argv[3]);
......
......@@ -118,7 +118,11 @@ int main(int argc, char **argv)
#endif
Timer tm;
assert(argc==5);
if ( argc != 5 )
{
cout << "use: testjade nprow npcol n nb" << endl;
return 1;
}
int nprow=atoi(argv[1]);
int npcol=atoi(argv[2]);
int m_a=atoi(argv[3]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment