-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnalyseEnergy.cpp
119 lines (98 loc) · 3.21 KB
/
AnalyseEnergy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "AnalyseEnergy.hpp"
AnalyseEnergy::AnalyseEnergy(std::string const& sim, unsigned int const& max_level, unsigned int const& bash_file, unsigned int const& ref):
Analyse(sim,max_level,bash_file,ref)
{
do_analyse();
}
AnalyseEnergy::~AnalyseEnergy(){
if(study_){
Gnuplot gp(analyse_+path_+dir_,sim_.substr(0,sim_.size()-1));
gp.label("x","$\\frac{1}{N}$");
gp.label("y2","$\\frac{E}{nN^2}$","rotate by 0");
gp+="plot '"+sim_.substr(0,sim_.size()-1)+".dat' u ($1/$2==6?1.0/$1:1/0):3 t '$k=6$',\\";
gp+=" '"+sim_.substr(0,sim_.size()-1)+".dat' u ($1/$2==3?1.0/$1:1/0):3 t '$k=3$'";
gp.save_file();
gp.create_image(true,"png");
}
}
void AnalyseEnergy::open_files(){
if(level_>1){
jd_write_ = new IOFiles(sim_+path_+dir_.substr(0,dir_.size()-1)+".jdbin",true,false);
}
switch(level_){
case 8:
{
jd_write_->write("number of different wavefunction",nof_);
jd_write_->add_to_header()->np();
}break;
case 7:
{
jd_write_->write("number of different wavefunction",nof_);
jd_write_->add_to_header()->np();
}break;
case 5:
{ jd_write_->write("number of different boundary condition",nof_); }break;
case 3:
{
jd_write_->write("number of different size",nof_);
data_write_ = new IOFiles(analyse_+path_+dir_.substr(0,dir_.size()-1)+".dat",true,false);
data_write_->precision(10);
}break;
}
}
void AnalyseEnergy::close_files(){
switch(level_){
case 3:
{ list_rst_.last().figure(rel_level_+analyse_+path_+dir_.substr(0,dir_.size()-1)+".png","energy evolution with the system size",RST::target(rel_level_+analyse_+path_+dir_.substr(0,dir_.size()-1)+".gp")+RST::width("1000")); }break;
}
if(jd_write_){
list_rst_.last().text(jd_write_->get_header());
delete jd_write_;
jd_write_ = NULL;
}
if(data_write_){
delete data_write_;
data_write_ = NULL;
}
}
std::string AnalyseEnergy::extract_level_8(){ return extract_default(); }
std::string AnalyseEnergy::extract_level_7(){ return extract_best_of_previous_level(); }
std::string AnalyseEnergy::extract_level_6(){ return extract_best_of_previous_level(); }
std::string AnalyseEnergy::extract_level_5(){ return extract_default(); }
std::string AnalyseEnergy::extract_level_4(){
read_ = new IOFiles(sim_+path_+dir_+filename_+".jdbin",false,false);
(*read_)>>nof_;
/*!must save now nof_ because it doesn't refer to the number of file in
* the next directory but in the next-next directory*/
jd_write_->write("number of different boundary condition",nof_);
for(unsigned int i(0);i<nof_;i++){
Vector<double> tmp(*read_);
System s(*read_);
CreateSystem cs(&s);
cs.init(&tmp,NULL);
cs.set_IOSystem(this);
jd_write_->add_to_header()->nl();
cs.save(*jd_write_);
}
delete read_;
read_ = NULL;
return filename_;
}
std::string AnalyseEnergy::extract_level_3(){
read_ = new IOFiles(sim_+path_+dir_+filename_+".jdbin",false,false);
(*read_)>>nof_;
for(unsigned int i(0);i<nof_;i++){
Vector<double> tmp(*read_);
System s(*read_);
s.save(*data_write_);
CreateSystem cs(&s);
cs.init(&tmp,NULL);
cs.set_IOSystem(this);
jd_write_->add_to_header()->nl();
cs.save(*jd_write_);
}
delete read_;
read_ = NULL;
return filename_;
}
std::string AnalyseEnergy::extract_level_2(){ return fit_therm_limit(); }