QNANO
Manybody_Executable_Template.h
1 #ifndef QNANO_NEW_MANYBODY_EXECUTABLE_TEMPLATE_DEFINED_H
2 #define QNANO_NEW_MANYBODY_EXECUTABLE_TEMPLATE_DEFINED_H
3 
4 #include "manybody/Manybody_Hamiltonian.h"
5 #include "tools/Abstract_Solver.h"
6 #include "tools/Eigenvector_Printer.h"
7 #include "tools/Parameter_Map.h"
8 
9 #include "manybody/Manybody_Perturbative_Correction_Template.h"
10 
11 template <class Tsolver> void Postprocess_Manybody_Template(Tsolver *solver, Manybody_Hamiltonian *hamil){
12 }
13 
14 
15 template <class Tsolver, class Tprinter>
16 void Manybody_Executable_Template(Parameter_Map &param_map, bool verbose){
17 
18  if(verbose)std::cout<<"Setting up manybody Hamiltonian..."<<std::endl;
19 
21  hamil->setup(param_map, verbose);
22 
23  if(verbose)std::cout<<"Dimension: "<<hamil->get_DIM()<<std::endl;
24  //TODO: Test if dimension smaller than number of threads
25  // if(hamil->get_DIM()<
26  bool dump=param_map.get_as_bool("dump",false);
27  if(verbose && dump){
28  std::cout<<"Dumping Hamiltonian"<<std::endl;
29  hamil->dump_sparse_Matrix("hamil_IA.dat", "hamil_JA.dat", "hamil_values.dat");
30  }
31 
32  if(verbose)std::cout<<"Setting up Eigen Solver"<<std::endl;
33  Tsolver *solver=new Tsolver(hamil);
34  solver->setup();
35 
36  if(verbose)std::cout<<"Solving"<<std::endl;
37  solver->solve();
38 
39  if(verbose)std::cout<<"Printing"<<std::endl;
40  if(!param_map.is_specified("eigenvalue_filename")){
41  param_map.add("eigenvalue_filename","energies.dat");
42  }
43 
44 
45 
46  Eigenvector_Printer *EVprinter=new Tprinter(solver, hamil);
47  EVprinter->setup(param_map);
48  EVprinter->print_sparse=true;
49  EVprinter->sparse_print_index=Manybody_Hilbert_Space::print_index;
50  Manybody_Hilbert_Space *fmhs=hamil->hilbert;
51  EVprinter->spi_ctx=(void*)( fmhs);
52  {
53  std::stringstream ss;
54  ss<<"rank_e "<<fmhs->get_rank_e()<<std::endl;
55  ss<<"rank_h "<<fmhs->get_rank_h()<<std::endl;
56  ss<<"nr_e "<<fmhs->get_nr_e()<<std::endl;
57  ss<<"nr_h "<<fmhs->get_nr_h()<<std::endl;
58  ss<<"eigenvalue $EIGENVALUE"<<std::endl;
59  ss<<"eigenvector:"<<std::endl;
60  EVprinter->EV_header=ss.str();
61  }
62 
63  EVprinter->print();
64 
65  Calculate_Manybody_Perturbation<Tsolver>(param_map,solver,EVprinter,hamil);
66 
67  Postprocess_Manybody_Template<Tsolver>(solver,hamil);
68 
69  delete EVprinter;
70  delete solver;
71  delete hamil;
72  if(verbose)std::cout<<"Done"<<std::endl;
73 }
74 #endif
Definition: Parameter_Map.h:12
Definition: Manybody_Hilbert_Space.h:8
virtual void setup(Parameter_Map &param_map)
Definition: Eigenvector_Printer.cc:35
int get_rank_e() const
nr of electron/hole states
Definition: Manybody_Hilbert_Space.h:14
void dump_sparse_Matrix(const std::string &file_IA, const std::string &file_JA, const std::string &file_values)
Support for dumping the sparse Matrix.
Definition: Sparse_Matrix_Generator.cc:3
Definition: Eigenvector_Printer.h:8
Definition: Manybody_Hamiltonian.h:14