25 #include "Permutation.h"
31 #include "SymMolecule.h"
32 #include "SimulatedAnnealing.h"
33 #include "Hamiltonian.h"
34 #include "OrbitalTransform.h"
35 #include "UnitaryMatrix.h"
36 #include "LocalMinimizer.h"
50 int main(
int argc,
char **argv)
58 std::string integralsfile =
"mo-integrals.h5";
59 std::string h5name =
"rdm.h5";
62 bool jacobirots =
false;
65 struct option long_options[] =
67 {
"integrals", required_argument, 0,
'i'},
68 {
"output", required_argument, 0,
'o'},
69 {
"unitary", required_argument, 0,
'u'},
70 {
"simulated-annealing", no_argument, 0,
's'},
71 {
"jacobi-rotations", no_argument, 0,
'j'},
72 {
"random", no_argument, 0,
'r'},
73 {
"help", no_argument, 0,
'h'},
79 while( (j = getopt_long (argc, argv,
"hi:o:su:jr", long_options, &i)) != -1)
84 cout <<
"Usage: " << argv[0] <<
" [OPTIONS]\n"
86 " -i, --integrals=integrals-file Set the input integrals file\n"
87 " -o, --output=h5-file Set the output filename for the RDM\n"
88 " -s, --simulated-annealing Use stimulated Annealing to find lowest energy\n"
89 " -j, --jacobi-rotations Use Jacobi Rotations to find lowest energy\n"
90 " -u, --unitary Use this unitary to calc energy\n"
91 " -r, --random Use a random unitary as start point\n"
92 " -h, --help Display this help\n"
97 integralsfile = optarg;
116 if(simanneal && jacobirots)
118 cout <<
"Cannot do both simulated annealing and jacobi rotations, you have to choose!" << endl;
125 setenv(
"SAVE_H5_PATH",
"./", 0);
127 cout <<
"Reading: " << integralsfile << endl;
134 cout <<
"Overriding the input unitary " << unitary <<
" with a random unitary!" << endl;
141 cout <<
"U=exp(X), X=" << endl;
147 std::string filename = getenv(
"SAVE_H5_PATH");
148 filename +=
"/random-start-unitary.h5";
152 cout <<
"Saving random start point to " << filename << endl;
156 if(!simanneal && !jacobirots)
160 cout <<
"Reading unitary " << unitary << endl;
170 auto start = std::chrono::high_resolution_clock::now();
172 auto end = std::chrono::high_resolution_clock::now();
174 cout <<
"Building took: " << std::fixed << std::chrono::duration_cast<std::chrono::duration<double,std::ratio<1>>>(end-start).count() <<
" s" << endl;
176 start = std::chrono::high_resolution_clock::now();
179 end = std::chrono::high_resolution_clock::now();
181 cout <<
"Diagonalization took: " << std::chrono::duration_cast<std::chrono::duration<double,std::ratio<1>>>(end-start).count() <<
" s" << endl;
183 for(
auto i=0;i<eig3.size();i++)
184 cout << i <<
" E = " << eig3[i] + mol.
get_nucl_rep() << endl;
221 cout <<
"Reading unitary " << unitary << endl;
230 auto start = std::chrono::high_resolution_clock::now();
234 auto end = std::chrono::high_resolution_clock::now();
236 cout <<
"The optimal energy is " << opt.
get_energy() << std::endl;
238 cout <<
"Optimization took: " << std::fixed << std::chrono::duration_cast<std::chrono::duration<double,std::ratio<1>>>(end-start).count() <<
" s" << endl;
245 auto eigs = ham.Diagonalize();
246 cout <<
"E = " << eigs.first + mol.
get_nucl_rep() << endl;
249 auto perm = ham.getPermutation();
250 start = std::chrono::high_resolution_clock::now();
251 rdm.
Build(perm, eigs.second);
252 end = std::chrono::high_resolution_clock::now();
254 cout <<
"Building 2DM took: " << std::chrono::duration_cast<std::chrono::duration<double,std::ratio<1>>>(end-start).count() <<
" s" << endl;
256 DM2 rdm_ham(opt_mol);
259 cout <<
"DM2 Energy = " << rdm.
Dot(rdm_ham) + mol.
get_nucl_rep() << endl;
260 cout <<
"DM2 Trace = " << rdm.
Trace() << endl;
271 cout <<
"Reading unitary " << unitary << endl;
277 cout <<
"The optimal energy is " << opt.
get_energy() << std::endl;
283 cout <<
"DM2 Energy = " << rdm.
Dot(rdm_ham) + mol.
get_nucl_rep() << endl;
284 cout <<
"DM2 Trace = " << rdm.
Trace() << endl;
286 std::string h5_name = getenv(
"SAVE_H5_PATH");
287 h5_name +=
"/rdm.h5";
289 cout <<
"Writing 2DM to " << h5_name << endl;
double get_energy() const
simanneal::OrbitalTransform & getOrbitalTf() const
void Minimize(bool dist_choice=false)
doci::DOCIHamiltonian & getHam() const
void Set_delta_angle(double)
void print_unitary() const
void Set_start_temp(double)
void WriteToFile(const std::string) const
Molecule const & getMolecule() const
simanneal::OrbitalTransform & getOrbitaltf() const
const doci::DM2 & get_DM2() const
double CalcEnergy() const
void Build(Permutation &, std::vector< double > &)
void BuildHamiltonian(const Molecule &)
void Set_max_angle(double)
void saveU(std::string savename) const
Save the unitary to disk.
void Set_delta_temp(double)
doci::Sym_Molecule & getHam() const
void loadU(std::string loadname)
Load the unitary from disk.
int main(int argc, char **argv)
double get_energy() const
double get_nucl_rep() const
CheMPS2::Hamiltonian & getHamObject() const
double Dot(const DM2 &) const
void make_skew_symmetric()