IM-SRG++  0
IMSRGSolver.hh
1 
2 #ifndef IMSRGSolver_h
3 #define IMSRGSolver_h 1
4 
5 #include <fstream>
6 #include <string>
7 #include <deque>
8 #include "Operator.hh"
9 #include "Generator.hh"
10 #include "IMSRGProfiler.hh"
11 #include "ReadWrite.hh"
12 
13 using namespace std;
14 
15 
17 {
18 
19  public:
20 
21 // private:
22  ModelSpace* modelspace;
23  ReadWrite* rw;
24  Operator* H_0;
25  deque<Operator> FlowingOps;
26  Operator H_saved;
27  Operator Eta;
28  deque<Operator> Omega;
29  Generator generator;
30  int istep;
31  double s;
32  double ds;
33  double ds_max;
34  double smax;
35  double norm_domega;
36  double omega_norm_max;
37  double eta_criterion;
38  string method;
39  string flowfile;
40  IMSRGProfiler profiler;
41  int n_omega_written;
42  int max_omega_written;
43  bool magnus_adaptive;
44 
45 
46 
47  ~IMSRGSolver();
48  IMSRGSolver();
49  IMSRGSolver( Operator& H_in);
50  void NewOmega();
51  void SetHin( Operator& H_in);
52  void SetReadWrite( ReadWrite& r){rw = &r;};
53  void Reset();
54  void AddOperator(Operator& Op){FlowingOps.push_back(Op);};
55  void UpdateEta(); // Force eta to be calculated. For debugging.
56 
57  void SetMethod(string m){method=m;};
58  void Solve();
59  void Solve_magnus_euler();
60  void Solve_magnus_modified_euler();
61 
62  Operator Transform(Operator& OpIn);
63  Operator Transform(Operator&& OpIn);
64  Operator InverseTransform(Operator& OpIn);
65  Operator GetOmega(int i){return Omega[i];};
66  int GetOmegaSize(){return Omega.size();};
67  int GetNOmegaWritten(){return n_omega_written;};
68  Operator Transform_Partial(Operator& OpIn, int n);
69  Operator Transform_Partial(Operator&& OpIn, int n);
70 
71  void SetFlowFile(string s);
72  void SetDs(double d){ds = d;};
73  void SetDsmax(double d){ds_max = d;};
74  void SetdOmega(double d){norm_domega = d;};
75  void SetSmax(double d){smax = d;};
76  void SetGenerator(string g);
77  void SetOmegaNormMax(double x){omega_norm_max = x;};
78  void SetODETolerance(float x){ode_e_abs=x;ode_e_rel=x;};
79  void SetEtaCriterion(float x){eta_criterion = x;};
80  void SetMagnusAdaptive(bool b){magnus_adaptive = b;};
81 
82  int GetSystemDimension();
83  Operator& GetH_s(){return FlowingOps[0];};
84  Operator& GetEta(){return Eta;};
85  Generator& GetGenerator(){return generator;};
86 
87  void UpdateOmega();
88  void UpdateH();
89 
90  void WriteFlowStatus(ostream&);
91  void WriteFlowStatusHeader(ostream&);
92  void WriteFlowStatus(string);
93  void WriteFlowStatusHeader(string);
94 
95  void SetDenominatorCutoff(double c){generator.SetDenominatorCutoff(c);};
96  void SetDenominatorDelta(double d){generator.SetDenominatorDelta(d);};
97  void SetDenominatorDeltaIndex(int i){generator.SetDenominatorDeltaIndex(i);};
98  void SetDenominatorDeltaOrbit(string o){generator.SetDenominatorDeltaOrbit(o);};
99 
100  void CleanupScratch();
101 
102 
103  // This is used to get flow info from odeint
105  {
106  public:
107  ODE_Monitor(IMSRGSolver& solver)
108  : imsrgsolver(solver), times(solver.times), E0(solver.E0),
109  eta1(solver.eta1),eta2(solver.eta2) {};
110  IMSRGSolver& imsrgsolver;
111  vector<double>& times;
112  vector<double>& E0;
113  vector<double>& eta1;
114  vector<double>& eta2;
115 // void operator() (const vector<Operator>& x, double t)
116  void operator() (const deque<Operator>& x, double t)
117  {
118  times.push_back(t);
119  E0.push_back(x.front().ZeroBody);
120  eta1.push_back(imsrgsolver.Eta.OneBodyNorm());
121  eta2.push_back(imsrgsolver.Eta.TwoBodyNorm());
122  }
123  void report()
124  {
125  for (size_t i=0; i<times.size(); ++i)
126  {
127  cout << times[i] << " " << E0[i] << " "
128  << eta1[i] << " " << eta2[i] << endl;
129  }
130  }
131  };
132 
133 
134  ODE_Monitor ode_monitor;
135 
136  vector<double> times;
137  vector<double> E0;
138  vector<double> eta1;
139  vector<double> eta2;
140  string ode_mode;
141  float ode_e_abs;
142  float ode_e_rel;
143 
144 
145 // void operator()( const vector<Operator>& x, vector<Operator>& dxdt, const double t);
146  void operator()( const deque<Operator>& x, deque<Operator>& dxdt, const double t);
147  void Solve_ode();
148  void Solve_ode_adaptive();
149  void Solve_ode_magnus();
150 
151 
152 };
153 
154 
155 
156 
157 
158 #endif
159 
Definition: Operator.hh:21
Definition: ReadWrite.cc:3012
Definition: IMSRGProfiler.hh:17
Definition: IMSRGSolver.hh:16
Definition: ReadWrite.hh:13
Definition: ModelSpace.hh:157
Definition: IMSRGSolver.hh:104
Definition: Generator.hh:9