Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lshulen committed Aug 29, 2018
1 parent d5f8788 commit 8531c92
Show file tree
Hide file tree
Showing 68 changed files with 31,066 additions and 0 deletions.
113 changes: 113 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#CXX=icpc -openmp -O3
#cc=icc -openmp -O3
CXX=g++ -O3 -g
cc=gcc -O3 -g
#CXX=g++ -O3 -g

spg_incs = spgstuff/arithmetic.h \
spgstuff/delaunay.h \
spgstuff/kpoint.h \
spgstuff/pointgroup.h \
spgstuff/sitesym_database.h \
spgstuff/spg_database.h \
spgstuff/symmetry.h \
spgstuff/cell.h \
spgstuff/hall_symbol.h \
spgstuff/mathfunc.h \
spgstuff/primitive.h \
spgstuff/site_symmetry.h \
spgstuff/spglib.h \
spgstuff/tetrahedron_method.h \
spgstuff/debug.h \
spgstuff/kgrid.h \
spgstuff/niggli.h \
spgstuff/refinement.h \
spgstuff/spacegroup.h \
spgstuff/spin.h \
spgstuff/version.h
spg_o = spgstuff/arithmetic.o \
spgstuff/cell.o \
spgstuff/debug.o \
spgstuff/delaunay.o \
spgstuff/hall_symbol.o \
spgstuff/kgrid.o \
spgstuff/kpoint.o \
spgstuff/mathfunc.o \
spgstuff/niggli.o \
spgstuff/pointgroup.o \
spgstuff/primitive.o \
spgstuff/refinement.o \
spgstuff/site_symmetry.o \
spgstuff/sitesym_database.o \
spgstuff/spacegroup.o \
spgstuff/spg_database.o \
spgstuff/spglib.o \
spgstuff/spin.o \
spgstuff/symmetry.o \
spgstuff/spglib_f.o \
spgstuff/tetrahedron_method.o

all:main
main: main.o pwscfData.o types.o util.o spgstuff/libmyspg.a handleTilemats.o
$(CXX) -o main main.o pwscfData.o types.o util.o handleTilemats.o spgstuff/libmyspg.a
pwscfData.o: pwscfData.cpp pwscfData.h
$(CXX) -c pwscfData.cpp
handleTilemats.o: handleTilemats.cpp handleTilemats.h util.h types.h pwscfData.h
$(CXX) -c handleTilemats.cpp
main.o: main.cpp pwscfData.h handleTilemats.h handlePwscf.h
$(CXX) -c main.cpp
types.o: types.cpp util.h util.h spgstuff/spglib.h
$(CXX) -Ispgstuff/ -c types.cpp
util.o: util.cpp util.h types.h
$(CXX) -c util.cpp
spgstuff/libmyspg.a: $(spg_o) $(spg_incs)
ar rcs spgstuff/libmyspg.a $(spg_o)
clean:
rm -f main *.o spgstuff/*.o spgstuff/libmyspg.a


spgstuff/arithmetic.o: spgstuff/arithmetic.c $(spg_incs)
$(cc) -o spgstuff/arithmetic.o -c spgstuff/arithmetic.c
spgstuff/hall_symbol.o: spgstuff/hall_symbol.c $(spg_incs)
$(cc) -o spgstuff/hall_symbol.o -c spgstuff/hall_symbol.c
spgstuff/niggli.o: spgstuff/niggli.c $(spg_incs)
$(cc) -o spgstuff/niggli.o -c spgstuff/niggli.c
spgstuff/sitesym_database.o: spgstuff/sitesym_database.c $(spg_incs)
$(cc) -o spgstuff/sitesym_database.o -c spgstuff/sitesym_database.c
spgstuff/spglib.o: spgstuff/spglib.c $(spg_incs)
$(cc) -o spgstuff/spglib.o -c spgstuff/spglib.c
spgstuff/test.o: spgstuff/test.c $(spg_incs)
$(cc) -o spgstuff/test.o -c spgstuff/test.c
spgstuff/cell.o: spgstuff/cell.c $(spg_incs)
$(cc) -o spgstuff/cell.o -c spgstuff/cell.c
spgstuff/kgrid.o: spgstuff/kgrid.c $(spg_incs)
$(cc) -o spgstuff/kgrid.o -c spgstuff/kgrid.c
spgstuff/pointgroup.o: spgstuff/pointgroup.c $(spg_incs)
$(cc) -o spgstuff/pointgroup.o -c spgstuff/pointgroup.c
spgstuff/site_symmetry.o: spgstuff/site_symmetry.c $(spg_incs)
$(cc) -o spgstuff/site_symmetry.o -c spgstuff/site_symmetry.c
spgstuff/spglib_f.o: spgstuff/spglib_f.c $(spg_incs)
$(cc) -o spgstuff/spglib_f.o -c spgstuff/spglib_f.c
spgstuff/tetrahedron_method.o: spgstuff/tetrahedron_method.c $(spg_incs)
$(cc) -o spgstuff/tetrahedron_method.o -c spgstuff/tetrahedron_method.c
spgstuff/debug.o: spgstuff/debug.c $(spg_incs)
$(cc) -o spgstuff/debug.o -c spgstuff/debug.c
spgstuff/kpoint.o: spgstuff/kpoint.c $(spg_incs)
$(cc) -o spgstuff/kpoint.o -c spgstuff/kpoint.c
spgstuff/primitive.o: spgstuff/primitive.c $(spg_incs)
$(cc) -o spgstuff/primitive.o -c spgstuff/primitive.c
spgstuff/spacegroup.o: spgstuff/spacegroup.c $(spg_incs)
$(cc) -o spgstuff/spacegroup.o -c spgstuff/spacegroup.c
spgstuff/spin.o: spgstuff/spin.c $(spg_incs)
$(cc) -o spgstuff/spin.o -c spgstuff/spin.c
spgstuff/delaunay.o: spgstuff/delaunay.c $(spg_incs)
$(cc) -o spgstuff/delaunay.o -c spgstuff/delaunay.c
spgstuff/mathfunc.o: spgstuff/mathfunc.c $(spg_incs)
$(cc) -o spgstuff/mathfunc.o -c spgstuff/mathfunc.c
spgstuff/refinement.o: spgstuff/refinement.c $(spg_incs)
$(cc) -o spgstuff/refinement.o -c spgstuff/refinement.c
spgstuff/spg_database.o: spgstuff/spg_database.c $(spg_incs)
$(cc) -o spgstuff/spg_database.o -c spgstuff/spg_database.c
spgstuff/symmetry.o: spgstuff/symmetry.c $(spg_incs)
$(cc) -o spgstuff/symmetry.o -c spgstuff/symmetry.c

45 changes: 45 additions & 0 deletions NOTES
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
We would like to be able to do the following:
1. specify things directly on the command line like before
2. read xml snippets and then override their values
2A For example: --dmcblock dmc.xml --dmctstep 0.01
2B Think about format for jastrows. Probably do the following: --onebodyjastrowblock Be Beonebody.xml.
There is a difficulty with how to addess those parameters though: Probably stick with only being able
to globally change jastrow parameters.
2C In order to do this, we will need to be able to hand xmlNodes to the various constructors.
Be careful here about memory leaks!!!
3. point the code to where an optimization was done and then have it use that determine the "optimal" wavefunction
4. With regards to how the code is set up to generate qmcpack input files, probably best to just have
an option like --qmcinputfile and then after all of the options changing things about the particleset,
wavefunction and the like, just have it do --qmcaction a b c... where a is the number of the action, b is the
type of the action, and then everything in c are options to be handled by the type of action listed in b,
and this is terminated by the next qmcaction block

5. Think about creating a atomlibrary type of xml file
<atomlibrary>
<atom elementType="Symbol" isAllElectron="yes/no" ppHash="md5sum">
<jastrow type="OneBody" function="Bspline">
<correlation elementType="Symbol" cusp="xxx" size="xxx" rcut="xxx">
<coefficients ....>
</coefficients>
</correlation>
</jastrow>
<jastrow type="OneBody" function="pade2">
<correlation...>
<coefficients ... >
</coefficients>
</correlation>
</jastrow>
<jastrow type="eeI" function="polynomial">
<correlation ...>
<coefficients ..>
</coefficients>
</correlation>
</jastrow>
<hybrid>
<parameter name="cutoff_radius>xxx</parameter>
<parameter name="spline_radius>xxx</parameter>
<parameter name="spline_npoints>xxx</parameter>
<parameter name="lmax">xxx</parameter>
</hybrid>
</atom>
</atomlibrary>
167 changes: 167 additions & 0 deletions handlePwscf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#ifndef HANDLE_PWSCF_H
#define HANDLE_PWSCF_H
#include "handleTilemats.h"
#include "types.h"
#include "util.h"
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;

void genWfn(int argc, char* argv[]) {

string inFileName = "undef";
int ssize;
int sskgrid[3];
int sskshift[3] = {0, 0, 0};

// read necessary info from the command line
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i],"--infile")) {
inFileName= string(argv[i+1]);
} else if (!strcmp(argv[i],"--supercellsize")) {
ssize = atoi(argv[i+1]);
} else if (!strcmp(argv[i],"--sskgrid")) {
for (int j = 0; j < 3; j++) {
stringstream ss1(argv[i+1+j]);
ss1 >> sskgrid[j];
}
i+=3;
} else if (!strcmp(argv[i],"--sskshift")) {
for (int j = 0; j < 3; j++) {
stringstream ss1(argv[i+1+j]);
ss1 >> sskshift[j];
}
i+=3;
}
}

if (inFileName == "undef") {
cout << "No pwscf input filename was given" << endl;
}

pwscfString ps(inFileName);
pwscfData pd(ps);

threeThreeMat<int> tilemat = getTilemat(pd, ssize);
physSys primcell(pd.ptv, pd.ionNames, pd.atpos);
physSys supercell(primcell, tilemat);

// These are the weighted supercell k-points;
vector<weightedKpt> outks;
supercell.getMesh(sskgrid[0], sskgrid[1], sskgrid[2], sskshift[0], sskshift[1], sskshift[2], outks);

// Now need to find the primitive cell k-points necessary
int numCopies = getDet(tilemat);
vector<weightedKpt> primks;

// loop over supercell kpoints
for (int i = 0; i < outks.size(); i++) {
double weight = outks[i].first;
vector<location> locPrimKs;
getPrimKpts(primcell, supercell, outks[i].second, locPrimKs, numCopies);
// for each found primitive cell kpt, see if it is in primks
// if it is add it's weight to the existing one
// if it is not, add it and its weight
for (int j = 0; j < locPrimKs.size(); j++) {
int found = 0;
for (int k = 0; k < primks.size(); k++) {
if (abs(locPrimKs[j][0] - primks[k].second[0]) < 1e-8 &&
abs(locPrimKs[j][1] - primks[k].second[1]) < 1e-8 &&
abs(locPrimKs[j][2] - primks[k].second[2]) < 1e-8) {
primks[k].first+=weight;
found = 1;
k+= primks.size();
}
}
if (!found) {
weightedKpt kp;
kp.first = weight;
for (int k = 0; k < 3; k++) {
kp.second[k] = locPrimKs[j][k];
}
primks.push_back(kp);
}
}
}

// Now outks has the symmetry independent supercell kpoints
// primks has the necessary primitive cell kpts to generate outks

stringstream ss;
ss << "K_POINTS {CRYSTAL}" << endl;
ss.setf(ios_base::fixed, ios_base::floatfield);
ss.precision(8);
ss << setw(8) << primks.size() << endl;
// ss << setw(16) << "kx" << setw(16) << "ky" << setw(16) << "kz" << setw(16) << "wt" << endl;
for (int i = 0; i < primks.size(); i++) {
ss << setw(16) << primks[i].second[0] << setw(16) << primks[i].second[1] << setw(16) << primks[i].second[2] << setw(16) << primks[i].first;
if (i+1 < primks.size()) {
ss << endl;
}
}
string kpointstring = ss.str();

// now need to replace the pwscfString (ps) object's K_POINTS card with a new
// one using kpointstring (need a pwscfReplaceWholeCard)
// Also need to change the calculation from scf to nscf (pwscfString.changePwscfToken)
// Also need to make sure the output has nosym=.true. and noinv=.true. (need an addToPwscfSection)
ps.changePwscfToken("calculation", "'nscf'");
ps.removePwscfToken("nosym");
ps.removePwscfToken("noinv");
ps.addToPwscfSection("system", "nosym", ".true.");
ps.addToPwscfSection("system", "noinv", ".true.");
ps.replaceWholePwscfCard("K_POINTS", kpointstring);

string nscfstring = ps.getOutput();

stringstream p2xstringss;
p2xstringss << "&inputpp" << endl;
p2xstringss << " outdir = '" << pd.outputDir << "'" << endl;
p2xstringss << " prefix = '" << pd.prefix << "'" << endl;
p2xstringss << " write_psir=.false." << endl;
p2xstringss << "/" << endl;


string nscfFname = inFileName;
// get rid of -scf if file has it
size_t index = nscfFname.find("-scf");
if (index != string::npos) {
nscfFname.erase(index, 4);
}
// get rid of .in if file has it
size_t index2 = nscfFname.find(".in");
if (index2 != string::npos) {
nscfFname.erase(index2,3);
}
stringstream fnss;
fnss << nscfFname;
fnss << "-supertwist" << sskgrid[0] << sskgrid[1] << sskgrid[2];
fnss << "-supershift" << sskshift[0] << sskshift[1] << sskshift[2];
fnss << "-nscf.in";
stringstream p2xss;
p2xss << nscfFname;
p2xss << "-supertwist" << sskgrid[0] << sskgrid[1] << sskgrid[2];
p2xss << "-supershift" << sskshift[0] << sskshift[1] << sskshift[2];
p2xss << "-pw2x.in";

//cout << "nscf filename: " << fnss.str() << endl;
//cout << "pw2x filename: " << p2xss.str() << endl;

// Now write the files themselves
ofstream nscffile(fnss.str().c_str());
nscffile << nscfstring;
nscffile.close();

ofstream pw2xfile(p2xss.str().c_str());
pw2xfile << p2xstringss.str();
pw2xfile.close();


}

#endif
Loading

0 comments on commit 8531c92

Please sign in to comment.