25 for (
int mo = 0; mo < nSpinors; mo++)
28 for (
int ao = 0; ao < numAO; ao++)
35 std::string new_label =
label;
36 assert(
label[1] ==
'1');
42 for (
int mo = 0; mo < nspinor; mo++)
44 for (
int ao = 0; ao < numAO; ao++)
59 os <<
" Representation: " <<
label <<
" with " <<
states.size() <<
" states" << std::endl;
60 os <<
"state# Energies and Ndets: " << std::endl;
61 for (
int i = 0; i <
states.size(); i++)
63 os <<
" " << tot_state_count <<
" " <<
states[i].energy <<
" " <<
states[i].coeffs.size() << std::endl;
166 std::string dirac_out = fname;
167 std::ifstream fin(dirac_out.c_str());
170 std::cerr <<
"Error when opening file: " << dirac_out << std::endl;
187 std::cout <<
"Found " <<
NumberOfSpecies <<
" unique species" << std::endl;
188 std::cout <<
"Found " <<
NumberOfAtoms <<
" total number of atoms" << std::endl;
190 search(fin,
"*SCF: Set-up for");
202 search(fin,
"* Shell specifications:");
210 std::cerr <<
"Error number of electrons" << std::endl;
220 std::cout << std::endl;
221 std::cout << std::endl;
222 std::cout << std::endl;
227 const double ang_to_bohr = 1.0 / 0.529177e0;
231 search(is,
"label atoms charge prim cont basis",
aline);
233 std::map<std::string, int> zMap;
234 std::map<std::string, int> zeffMap;
240 for (
int i = 0; i <
IonName.size(); i++)
244 std::pair<std::string, int> x(name, i);
245 std::pair<std::string, int> y(name, zeff);
260 while (
lookFor(is,
"Nuclear Gaussian exponent for atom",
aline))
264 std::getline(is,
aline);
265 if (
aline.size() == 0)
271 zeffMap.find(
IonName[z])->second = zeff;
276 search(is,
"Cartesian coordinates in XYZ format",
aline);
282 for (
int d = 0; d < 3; d++)
287 int speciesID = species.addSpecies(
GroupName[iat]);
299 search(is,
"Contents of the molecule file",
aline);
308 basisset[iat].elementType = species.speciesName[iat];
309 std::vector<int> numPerL;
314 std::cerr <<
"Cannot extract basis. Rerun with EXPLICIT basis" << std::endl;
322 for (
int l = 0; l < numPerL.size(); l++)
324 for (
int il = 0; il < numPerL[l]; il++)
333 for (
int n = 0;
n < nprim;
n++)
340 bas.
n =
basisset[iat].basisGroups.size();
343 basisset[iat].basisGroups.push_back(bas);
348 int bgstart =
basisset[iat].basisGroups.size();
349 for (
int n = 0;
n < ncont;
n++)
354 basisset[iat].basisGroups.push_back(bg);
356 for (
int n = 0;
n < nprim;
n++)
360 for (
int c = 0; c < ncont; c++)
365 basisset[iat].basisGroups[bgstart + c].radfuncs.push_back(p);
374 std::map<std::string, int> basisDataMap;
378 std::map<std::string, int>::iterator it(basisDataMap.find(
GroupName[i]));
379 if (it == basisDataMap.end())
393 std::map<std::string, int>::iterator it(basisDataMap.find(
GroupName[i]));
394 if (it == basisDataMap.end())
396 std::cerr <<
"Error in parser.\n";
400 int indx = it->second;
401 gtot +=
basisset[indx].basisGroups.size();
402 for (
int k = 0; k <
basisset[indx].basisGroups.size(); k++)
404 int l =
basisset[indx].basisGroups[k].l;
405 int sh = (l == 0) ? 1 : l + 2;
408 for (
int k = 0; k <
basisset[indx].basisGroups.size(); k++)
410 for (
int k = 0; k <
basisset[indx].basisGroups.size(); k++)
412 for (
int c = 0; c <
basisset[indx].basisGroups[k].radfuncs.size(); c++)
414 gExp.push_back(
basisset[indx].basisGroups[k].radfuncs[c].first);
424 std::cout << std::endl;
425 std::cout <<
"Reading spinor info" << std::endl;
426 std::cout <<
"========================================================================" << std::endl;
430 search(is,
"Output from DBLGRP");
435 std::vector<std::string> labels(nirrep);
436 for (
int i = 0; i < nirrep; i++)
439 for (
int i = 0; i < nirrep; i++)
443 search(is,
"VECINP: Vector print");
444 std::string irstr =
"- Orbitals in fermion ircop " + labels[i];
449 search(is,
"* Occupation of subblocks");
455 for (
int j = 0; j < nj; j++)
461 std::string splitby =
":.";
466 std::cerr <<
"Error: For vector printing, need to use 1..oo or 1..N" << std::endl;
474 std::cout <<
"Found " << nirrep <<
" fermion irreps." << std::endl;
475 for (
int i = 0; i < nirrep; i++)
476 std::cout <<
" irrep " <<
irreps[i].get_label() <<
" with " <<
irreps[i].get_num_spinors() <<
" spinors and " 477 <<
irreps[i].get_num_ao() <<
" AO coefficients." << std::endl;
480 std::streampos startspinors = is.tellg();
482 for (
int i = 0; i < nirrep; i++)
485 is.seekg(startspinors);
486 std::string start_irrep =
"Fermion ircop " +
irreps[i].get_label();
488 for (
int mo = 0; mo <
irreps[i].get_num_spinors(); mo++)
494 while (std::getline(is,
aline))
496 if (
aline.size() == 0)
498 if (std::string(
aline).find(
"*********") != std::string::npos)
500 std::cerr <<
"ERROR parsing line: " << std::endl;
501 std::cerr <<
aline << std::endl;
502 std::cerr <<
"One of the printed AO coefficients is outside the default DIRAC print format" << std::endl;
503 std::cerr <<
"In order to continue, please change the following in DIRAC/src/dirac/dirout.F (around line 427)" 505 std::cerr <<
" 100 FORMAT(3X,I5,2X,A12,2X,4F14.10)" << std::endl;
506 std::cerr <<
" to " << std::endl;
507 std::cerr <<
" 100 FORMAT(3X,I5,2X,A12,2X,4F20.10)" << std::endl;
509 <<
" and recompile DIRAC. Then rerun your particular calulcation in order to get accurate AO coefficients" 516 std::cerr <<
"ERROR parsing line: " << std::endl;
517 std::cerr <<
aline << std::endl;
518 std::cerr <<
"Expected line to be parsed into vector<string> of length 9" << std::endl;
520 <<
"Either recompile DIRAC in DIRAC/src/dirac/dirout.F (around line 427) to avoid this issue from now on" 522 std::cerr <<
" 100 FORMAT(3X,I5,2X,A12,2X,4F14.10)" << std::endl;
523 std::cerr <<
" to " << std::endl;
524 std::cerr <<
" 100 FORMAT(3X,I5,2X,A12,2X,4F20.10)" << std::endl;
525 std::cerr <<
" or just add a space appropriately to this line" << std::endl;
532 normMapType::iterator it =
normMap.find(label);
537 std::cerr <<
"Unknown basis function type. Aborting" << std::endl;
546 irreps[i].spinor_mo_coeffs[mo][bidx][0] = up_r *
norm;
547 irreps[i].spinor_mo_coeffs[mo][bidx][1] = up_i *
norm;
548 irreps[i].spinor_mo_coeffs[mo][bidx][2] = dn_r *
norm;
549 irreps[i].spinor_mo_coeffs[mo][bidx][3] = dn_i *
norm;
553 std::cout <<
"Found coefficients for " <<
irreps[i].get_label() << std::endl;
555 std::cout <<
"Generated kramers pair with irrep " <<
kp_irreps[i].get_label() << std::endl;
558 std::cout <<
"Now we have the following spinors" << std::endl;
559 for (
int i = 0; i < irreps.size(); i++)
561 std::cout <<
" irrep " << irreps[i].get_label() <<
" with " << irreps[i].get_num_spinors() <<
" spinors and " 562 << irreps[i].get_num_ao() <<
" AO coefficients." << std::endl;
563 std::cout <<
" irrep " << kp_irreps[i].get_label() <<
" with " << kp_irreps[i].get_num_spinors() <<
" spinors and " 564 << kp_irreps[i].get_num_ao() <<
" AO coefficients." << std::endl;
568 for (
int i = 0; i < irreps.size(); i++)
569 numMO += 2 * irreps[i].get_num_spinors();
576 std::cout << std::endl;
577 std::cout <<
"Parsing wave function info" << std::endl;
578 std::cout <<
"========================================================================" << std::endl;
580 if (
lookFor(is,
"Resolution of open-shell states",
aline))
582 bool closed =
lookFor(is,
"No open-shell electrons",
aline);
585 std::cout <<
"Found single determinant wave function" << std::endl;
590 std::cout <<
"Found Complete Open-Shell CI (COSCI) wave function" << std::endl;
596 std::cout <<
"Found single determinant wave function" << std::endl;
604 std::cout <<
"Sorting spinors by energy" << std::endl;
605 std::vector<std::pair<double, std::pair<int, int>>> idx;
606 for (
int ir = 0; ir <
irreps.size(); ir++)
608 for (
int mo = 0; mo <
irreps[ir].get_num_spinors(); mo++)
610 std::pair<int, int> irmo(ir, mo);
611 std::pair<double, std::pair<int, int>> enirmo(
irreps[ir].energies[mo], irmo);
612 idx.push_back(enirmo);
615 std::sort(idx.begin(), idx.end());
623 std::vector<int> spinor_component = {0, 2, 1, 3};
624 for (
int d = 0; d < 4; d++)
626 for (
int i = 0; i < idx.size(); i++)
634 int ir = idx[i].second.first;
635 int mo = idx[i].second.second;
636 for (
int ao = 0; ao <
irreps[ir].get_num_ao(); ao++)
637 EigVec.push_back(
irreps[ir].spinor_mo_coeffs[mo][ao][spinor_component[d]]);
638 for (
int ao = 0; ao <
irreps[ir].get_num_ao(); ao++)
639 EigVec.push_back(
kp_irreps[ir].spinor_mo_coeffs[mo][ao][spinor_component[d]]);
646 std::string orbtype_str;
648 orbtype_str =
"Core";
650 orbtype_str =
"Active";
653 std::cerr <<
"Orb type must be CORE or ACTIVE" << std::endl;
658 search(is,
"Resolution of open-shell states");
659 std::string tmp =
"- " + orbtype_str +
" orbitals";
673 if (
aline.size() == 0)
679 irreps[irrep_idx].orbtypes[idx] = type;
680 kp_irreps[irrep_idx].orbtypes[idx] = type;
684 std::cerr <<
"Error: Read in more indices than exist for irrep " <<
irreps[irrep_idx].label << std::endl;
687 else if (count == norb)
696 for (
int ir = 0; ir <
irreps.size(); ir++)
698 std::vector<std::pair<double, std::pair<int, int>>> idx;
699 for (
int mo = 0; mo <
irreps[ir].get_num_spinors(); mo++)
701 if (
irreps[ir].orbtypes[mo] == type)
703 std::pair<int, int> irmo(ir, mo);
704 std::pair<double, std::pair<int, int>> enirmo(
irreps[ir].energies[mo], irmo);
705 idx.push_back(enirmo);
709 for (
int i = 0; i < idx.size(); i++)
711 if (spinor_component == 0)
716 int ir = idx[i].second.first;
717 int mo = idx[i].second.second;
718 for (
int ao = 0; ao <
irreps[ir].get_num_ao(); ao++)
719 EigVec.push_back(
irreps[ir].spinor_mo_coeffs[mo][ao][spinor_component]);
722 for (
int i = 0; i < idx.size(); i++)
724 if (spinor_component == 0)
729 int ir = idx[i].second.first;
730 int mo = idx[i].second.second;
731 for (
int ao = 0; ao <
irreps[ir].get_num_ao(); ao++)
732 EigVec.push_back(
kp_irreps[ir].spinor_mo_coeffs[mo][ao][spinor_component]);
746 for (
int i = 0; i <
irreps.size(); i++)
752 std::cout << std::endl;
753 std::cout <<
"Orbital Info" << std::endl;
754 std::cout <<
"------------------------------------" << std::endl;
755 for (
int i = 0; i <
irreps.size(); i++)
757 std::cout <<
"irrep: " <<
irreps[i].label << std::endl;
761 for (
int j = 0; j <
irreps[i].orbtypes.size(); j++)
770 std::cout <<
" closed : " << closed << std::endl;
771 std::cout <<
" active : " << active << std::endl;
772 std::cout <<
" virtual : " << virt << std::endl;
773 std::cout <<
" total : " << closed + active + virt << std::endl;
776 std::cout << std::endl;
777 std::cout <<
"Sorting spinors into DIRAC COSCI order" << std::endl;
803 std::string core_occstr;
804 for (
int i = 0; i < total_core; i++)
806 std::string virt_occstr;
807 for (
int i = 0; i < total_virtual; i++)
812 search(is,
"Resolution of open-shell states");
813 search(is,
"Orbital Representation");
815 std::vector<std::streampos> rep_pos;
817 rep_pos.push_back(is.tellg());
820 for (
int i = 0; i < rep_pos.size(); i++)
822 is.seekg(rep_pos[i]);
830 for (
int j = 0; j < nstates; j++)
832 std::vector<double> ci_coeffs;
833 std::vector<std::string> ci_occs;
835 while (getline(is,
aline))
837 if (
aline.size() == 0)
850 std::string tmp = core_occstr +
currentWords[1] + virt_occstr;
851 ci_occs.push_back(tmp);
864 std::cout << std::endl;
865 std::cout <<
"COSCI State Info" << std::endl;
866 std::cout <<
"------------------------------------" << std::endl;
867 std::cout <<
"Found " <<
cosciReps.size() <<
" representations" << std::endl;
869 for (
int i = 0; i <
cosciReps.size(); i++)
870 cosciReps[i].printInfo(std::cout, state_count);
871 std::cout <<
"Saving wave function for target state " <<
target_state << std::endl;
872 std::cout <<
"note: if you want another state run with --TargetState #_of_desired_state shown above" << std::endl;
877 for (
int i = 0; i <
cosciReps.size(); i++)
879 for (
int j = 0; j <
cosciReps[i].states.size(); j++)
897 std::cerr <<
"Could not find requested state" << std::endl;
std::vector< value_type > EigVal_beta
std::vector< cosciRep > cosciReps
std::vector< std::string > currentWords
void parse(const std::string &fname) override
cosciRep(std::string in_label, int nstates)
std::vector< double > CIcoeff
std::vector< primExpCoeff > basisFunc
fermIrrep(std::string label_in, int nSpinors, int numAO)
std::vector< std::vector< std::vector< double > > > spinor_mo_coeffs
void getWF(std::istream &is)
std::vector< ciState > states
std::vector< std::string > GroupName
std::vector< std::string > occstrings
void skiplines(std::istream &is, int n)
ParticleIndex GroupID
Species ID.
void getGeometry(std::istream &is)
std::vector< double > coeffs
std::vector< value_type > EigVal_alpha
std::vector< int > gBound
std::vector< value_type > gC0
double norm(const zVec &c)
unsigned parsewords(const char *inbuf, std::vector< std::string > &slist, const std::string &extra_tokens)
std::vector< primBasis > radfuncs
std::vector< value_type > EigVec
void getSingleDet(std::istream &is)
int search(std::istream &is, const std::string &keyword)
fermIrrep generate_kramers_pair()
std::vector< value_type > gExp
static std::map< int, std::string > IonName
std::vector< OrbType > orbtypes
int sortAndStoreCOSCIOrbs(OrbType type, const int spinor_component)
std::streampos pivot_begin
std::pair< double, double > primExpCoeff
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
std::vector< std::string > CIalpha
void create(const std::vector< int > &agroup)
create grouped particles
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
bool lookFor(std::istream &is, const std::string &keyword)
std::vector< double > energies
void getSpinors(std::istream &is)
std::vector< int > gNumber
void getCOSCI(std::istream &is)
Custom container for set of attributes for a set of species.
DiracParser(int argc, char **argv)
int getwords(std::vector< std::string > &slist, std::istream &fp, std::string &aline)
std::vector< std::string > CIbeta
std::vector< value_type > gC1
void printInfo(std::ostream &os, int &tot_state_count)
std::pair< double, double > primBasis
void getGaussianCenters(std::istream &is)
std::vector< int > gShell
std::vector< atBasisSet > basisset
std::vector< fermIrrep > kp_irreps
void parseCOSCIOrbInfo(std::istream &is, const int irrep_idx, OrbType type)
std::vector< fermIrrep > irreps