34 if (!hin.
open(fname.c_str(), H5F_ACC_RDONLY))
36 std::cerr <<
"Could not open H5 file" << std::endl;
39 hin.
push(
"supercell");
41 hin.
read(LatticeVec,
"primitive_vectors");
42 X[0] = LatticeVec[0][0];
43 X[1] = LatticeVec[0][1];
44 X[2] = LatticeVec[0][2];
45 Y[0] = LatticeVec[1][0];
46 Y[1] = LatticeVec[1][1];
47 Y[2] = LatticeVec[1][2];
48 Z[0] = LatticeVec[2][0];
49 Z[1] = LatticeVec[2][1];
50 Z[2] = LatticeVec[2][2];
52 std::cout <<
"Lattice parameters in Bohr:" << std::endl;
53 std::cout <<
X[0] <<
" " <<
X[1] <<
" " <<
X[2] << std::endl;
54 std::cout <<
Y[0] <<
" " <<
Y[1] <<
" " <<
Y[2] << std::endl;
55 std::cout <<
Z[0] <<
" " <<
Z[1] <<
" " <<
Z[2] << std::endl;
60 std::cout <<
" RMGParser::dumpPBC " << std::endl;
63 xmlDocPtr doc_p = xmlNewDoc((
const xmlChar*)
"1.0");
64 xmlNodePtr qm_root_p = xmlNewNode(NULL, BAD_CAST
"qmcsystem");
69 xmlDocSetRootElement(doc_p, qm_root_p);
70 std::string fname =
Title +
".structure.xml";
71 xmlSaveFormatFile(fname.c_str(), doc_p, 1);
75 xmlDocPtr
doc = xmlNewDoc((
const xmlChar*)
"1.0");
76 xmlNodePtr qm_root = xmlNewNode(NULL, BAD_CAST
"qmcsystem");
79 xmlNodePtr wfPtr = xmlNewNode(NULL, (
const xmlChar*)
"wavefunction");
80 xmlNewProp(wfPtr, (
const xmlChar*)
"name", (
const xmlChar*)psi_tag.c_str());
81 xmlNewProp(wfPtr, (
const xmlChar*)
"target", (
const xmlChar*)
"e");
83 xmlNodePtr detsetPtr = xmlNewNode(NULL, (
const xmlChar*)
"determinantset");
84 xmlNewProp(detsetPtr, (
const xmlChar*)
"type", (
const xmlChar*)
"bspline");
85 xmlNewProp(detsetPtr, (
const xmlChar*)
"href", (
const xmlChar*)
h5file.c_str());
86 xmlNewProp(detsetPtr, (
const xmlChar*)
"source", (
const xmlChar*)ion_tag.c_str());
88 xmlNewProp(detsetPtr, (
const xmlChar*)
"sort", (
const xmlChar*)
"1");
89 xmlNewProp(detsetPtr, (
const xmlChar*)
"tilematrix", (
const xmlChar*)
"1 0 0 0 1 0 0 0 1");
90 xmlNewProp(detsetPtr, (
const xmlChar*)
"twistnum", (
const xmlChar*)
"0");
91 xmlNewProp(detsetPtr, (
const xmlChar*)
"version", (
const xmlChar*)
"0.10");
93 std::ostringstream up_size, down_size;
97 xmlNodePtr slaterdetPtr = xmlNewNode(NULL, (
const xmlChar*)
"slaterdeterminant");
99 xmlNodePtr updetPtr = xmlNewNode(NULL, (
const xmlChar*)
"determinant");
100 xmlNewProp(updetPtr, (
const xmlChar*)
"id", (
const xmlChar*)
"updet");
101 xmlNewProp(updetPtr, (
const xmlChar*)
"size", (
const xmlChar*)up_size.str().c_str());
103 xmlNodePtr occUpPtr = xmlNewNode(NULL, (
const xmlChar*)
"occupation");
104 xmlNewProp(occUpPtr, (
const xmlChar*)
"mode", (
const xmlChar*)
"ground");
105 xmlNewProp(occUpPtr, (
const xmlChar*)
"spindataset", (
const xmlChar*)
"0");
106 xmlAddChild(updetPtr, occUpPtr);
109 xmlNodePtr downdetPtr = xmlNewNode(NULL, (
const xmlChar*)
"determinant");
110 xmlNewProp(downdetPtr, (
const xmlChar*)
"id", (
const xmlChar*)
"downdet");
111 xmlNewProp(downdetPtr, (
const xmlChar*)
"size", (
const xmlChar*)down_size.str().c_str());
113 xmlNodePtr occDownPtr = xmlNewNode(NULL, (
const xmlChar*)
"occupation");
114 xmlNewProp(occDownPtr, (
const xmlChar*)
"mode", (
const xmlChar*)
"ground");
117 xmlNewProp(downdetPtr, (
const xmlChar*)
"ref", (
const xmlChar*)
"updet");
118 xmlNewProp(occDownPtr, (
const xmlChar*)
"spindataset", (
const xmlChar*)
"1");
122 xmlNewProp(occDownPtr, (
const xmlChar*)
"spindataset", (
const xmlChar*)
"0");
126 std::cerr <<
"Error: Number of spins should be 1 or 2. (" <<
NumberOfSpins <<
")" << std::endl;
129 xmlAddChild(downdetPtr, occDownPtr);
131 xmlAddChild(slaterdetPtr, updetPtr);
132 xmlAddChild(slaterdetPtr, downdetPtr);
134 xmlAddChild(detsetPtr, slaterdetPtr);
136 xmlAddChild(wfPtr, detsetPtr);
139 std::cout << R
"(Adding Two-Body and One-Body jastrows with rcut="10" and size="10")" << std::endl; 147 std::cout <<
"Adding Three-Body jastrows with rcut=\"5\"" << std::endl;
152 xmlAddChild(qm_root, wfPtr);
154 xmlDocSetRootElement(
doc, qm_root);
156 xmlSaveFormatFile(fname.c_str(),
doc, 1);
164 if (!hin.
open(fname.c_str(), H5F_ACC_RDONLY))
166 std::cerr <<
"Could not open H5 file" << std::endl;
170 hin.
push(
"application");
172 std::cout <<
"Converting Wavefunction from the " <<
CodeName <<
" Code" << std::endl;
175 hin.
push(
"electrons");
176 std::vector<double> Nalpha_Nbeta(2);
177 hin.
read(Nalpha_Nbeta,
"number_of_electrons");
184 std::cout <<
"Number of spins: " <<
NumberOfSpins << std::endl;
189 std::cout <<
"Number of atoms: " <<
NumberOfAtoms << std::endl;
196 std::vector<int> atomic_number;
197 std::vector<double> q;
202 std::map<int, int> AtomIndexmap;
203 hin.
read(idx,
"species_ids");
206 AtomIndexmap.insert(std::pair<int, int>(i, idx[i]));
210 std::string speciesName(
"species_");
211 speciesName = speciesName + std::to_string(AtomIndexmap[i]);
212 hin.
push(speciesName);
216 std::string ecpName =
"";
217 hin.
read(zint,
"atomic_number");
218 atomic_number.push_back(zint);
219 hin.
read(z,
"valence_charge");
221 hin.
read(Name,
"name");
224 hin.
read(ecpName,
"pseudopotential");
230 std::cerr <<
"WARNING: no ECP found for " << speciesName <<
":" << Name << std::endl;
235 hin.
read(IonPos,
"positions");
244 int speciesID = species.addSpecies(
GroupName[i]);
257 hin.
push(
"Super_Twist");
259 hin.
read(STVec,
"Coord");
267 std::cout <<
"Could not find Super_Twist, using [0,0,0] (not yet implemented in basic RMG interface)" << std::endl;
bool open(const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
open a file
void close()
close all the open groups and file
void parse(const std::string &fname) override
void dumpPBC(const std::string &psi_tag, const std::string &ion_tag) override
xmlNodePtr createIonSet()
std::vector< std::string > GroupName
ParticleIndex GroupID
Species ID.
std::vector< double > STwist_Coord
static std::map< int, std::string > IonName
xmlNodePtr createElectronSet(const std::string &ion_tag)
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
void create(const std::vector< int > &agroup)
create grouped particles
void push(const std::string &gname, bool createit=true)
push a group to the group stack
void read(T &data, const std::string &aname)
read the data from the group aname and check status runtime error is issued on I/O error ...
Custom container for set of attributes for a set of species.
void getCell(const std::string &fname)
std::vector< std::string > ECP_names