22#define H_TDDFT_PW_H
33
44#include " module_io/input_conv.h"
5+ #include " module_parameter/parameter.h" // PARAM.globalv.global_readin_dir, PARAM.inp.mdp.md_restart
56#include " pot_base.h"
67
78namespace elecstate
@@ -16,8 +17,25 @@ class H_TDDFT_pw : public PotBase
1617 this ->fixed_mode = true ;
1718
1819 this ->rho_basis_ = rho_basis_in;
20+
21+ // If it is the first time to create an H_TDDFT_pw instance and is restart calculation,
22+ // initialize istep using current_step_info
23+ if (!is_initialized && PARAM.inp .mdp .md_restart )
24+ {
25+ int restart_istep = -1 ;
26+ std::string file_dir = PARAM.globalv .global_readin_dir ;
27+ current_step_info (file_dir, restart_istep);
28+
29+ if (restart_istep >= 0 )
30+ {
31+ H_TDDFT_pw::istep = restart_istep - 1 ; // Update istep
32+ }
33+
34+ is_initialized = true ; // Mark as initialized, so that istep will not be initialized again
35+ }
1936 }
20- ~H_TDDFT_pw (){};
37+
38+ ~H_TDDFT_pw () {};
2139
2240 void cal_fixed_v (double * vl_pseudo) override ;
2341
@@ -42,17 +60,17 @@ class H_TDDFT_pw : public PotBase
4260 static int tstart;
4361 static int tend;
4462 static double dt;
45- // cut dt for integral
63+ // cut dt for integral
4664 static double dt_int;
4765 static int istep_int;
4866
4967 // space domain parameters
5068
51- // length gauge
69+ // length gauge
5270 static double lcut1;
5371 static double lcut2;
5472
55- // velocity gauge, vector magnetic potential
73+ // velocity gauge, vector magnetic potential
5674 static ModuleBase::Vector3<double > At;
5775
5876 // time domain parameters
@@ -64,8 +82,8 @@ class H_TDDFT_pw : public PotBase
6482 static std::vector<double > gauss_sigma; // time(a.u.)
6583 static std::vector<double > gauss_t0;
6684 static std::vector<double > gauss_amp; // Ry/bohr
67- // add for velocity gauge, recut dt into n pieces to make sure the integral is accurate Enough
68- // must be even, thus would get odd number of points for simpson integral
85+ // add for velocity gauge, recut dt into n pieces to make sure the integral is accurate Enough
86+ // must be even, thus would get odd number of points for simpson integral
6987 static std::vector<int > gauss_ncut;
7088
7189 // trapezoid
@@ -76,7 +94,7 @@ class H_TDDFT_pw : public PotBase
7694 static std::vector<double > trape_t2;
7795 static std::vector<double > trape_t3;
7896 static std::vector<double > trape_amp; // Ry/bohr
79- // add for velocity gauge, recut dt into n pieces to make sure the integral is accurate Enough
97+ // add for velocity gauge, recut dt into n pieces to make sure the integral is accurate Enough
8098 static std::vector<int > trape_ncut;
8199
82100 // Trigonometric
@@ -86,15 +104,15 @@ class H_TDDFT_pw : public PotBase
86104 static std::vector<double > trigo_phase1;
87105 static std::vector<double > trigo_phase2;
88106 static std::vector<double > trigo_amp; // Ry/bohr
89- // add for velocity gauge, recut dt into n pieces to make sure the integral is accurate Enough
107+ // add for velocity gauge, recut dt into n pieces to make sure the integral is accurate Enough
90108 static std::vector<int > trigo_ncut;
91109
92110 // Heaviside
93111 static int heavi_count;
94112 static std::vector<double > heavi_t0;
95113 static std::vector<double > heavi_amp; // Ry/bohr
96114
97- // update At for velocity gauge by intergral of E(t)dt
115+ // update At for velocity gauge by intergral of E(t)dt
98116 static void update_At ();
99117
100118 private:
@@ -103,6 +121,7 @@ class H_TDDFT_pw : public PotBase
103121 // Vext will evolve by time, every time cal_fixed_v() is called, istep++
104122 // ------------------------
105123 static int istep;
124+ static bool is_initialized; // static flag variable, used to ensure initialization only once
106125
107126 static double amp;
108127
@@ -111,9 +130,12 @@ class H_TDDFT_pw : public PotBase
111130
112131 const UnitCell* ucell_ = nullptr ;
113132
133+ // Obtain the current MD step information, used for restart calculation
134+ void current_step_info (const std::string& file_dir, int & istep);
135+
114136 // potential of electric field in space domain : length gauge and velocity gauge
115- void cal_v_space (std::vector<double > & vext_space, int direc);
116- void cal_v_space_length (std::vector<double > & vext_space, int direc);
137+ void cal_v_space (std::vector<double >& vext_space, int direc);
138+ void cal_v_space_length (std::vector<double >& vext_space, int direc);
117139 double cal_v_space_length_potential (double i);
118140
119141 // potential of electric field in time domain : Gauss , trapezoid, trigonometric, heaviside, HHG
@@ -124,7 +146,7 @@ class H_TDDFT_pw : public PotBase
124146 static double cal_v_time_heaviside ();
125147 // double cal_v_time_HHG();
126148
127- // get ncut number for At integral
149+ // get ncut number for At integral
128150 static int check_ncut (int t_type);
129151
130152 void prepare (const ModuleBase::Matrix3& G, int & dir);
0 commit comments