forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_update.cpp
More file actions
302 lines (282 loc) · 8.17 KB
/
input_update.cpp
File metadata and controls
302 lines (282 loc) · 8.17 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
//==========================================================
// Author: Lixin He,mohan
// DATE : 2008-11-6
//==========================================================
#include "input_update.h"
#include "src_pw/global.h"
#include "module_base/global_function.h"
#include "module_base/global_variable.h"
#include "input.h"
#include "module_relaxation/ions_move_basic.h"
#include "src_io/optical.h"
#ifdef __LCAO
#include "src_lcao/FORCE_STRESS.h"
#include "src_lcao/local_orbital_charge.h"
#include "src_lcao/global_fp.h" // mohan update 2021-01-30
#endif
Update_input::Update_input() {}
Update_input::~Update_input() {}
void Update_input::init(const std::string &fn)
{
GlobalV::ofs_warning << "\n CHECK UPDATE INPUT INFORMATION" << std::endl;
this->Read(fn);
#ifdef __MPI
Bcast();
#endif
return;
}
bool Update_input::Read(const std::string &fn)
{
if (GlobalV::MY_RANK!=0) return false;
std::ifstream ifs(fn.c_str(), ios::in); // "in_datas/input_parameters"
if (!ifs)
{
return false;
}
ifs.clear();
ifs.seekg(0);
char word[80];
char word1[80];
int ierr = 0;
//ifs >> std::setiosflags(ios::uppercase);
ifs.rdstate();
while (ifs.good())
{
ifs >> word;
ifs.ignore(150, '\n');
if (strcmp(word , "INPUT_PARAMETERS") == 0)
{
ierr = 1;
break;
}
ifs.rdstate();
}
if (ierr == 0)
{
std::cout << " Error parameter list." << std::endl;
return false;// return error : false
}
ifs.rdstate();
while (ifs.good())
{
ifs >> word1;
INPUT.strtolower(word1, word);
// 1
if (strcmp("cal_force", word) == 0)
{
read_value(ifs, cal_force);
if(cal_force!=GlobalV::CAL_FORCE)
{
this->change(GlobalV::ofs_warning,"CAL_FORCE",GlobalV::CAL_FORCE, cal_force);
GlobalV::CAL_FORCE = this->cal_force;
}
}
// 2
else if (strcmp("force_thr", word) == 0)
{
read_value(ifs, force_thr);
if(force_thr!=GlobalV::FORCE_THR)
{
this->change(GlobalV::ofs_warning,"forth_thr(Ry/Bohr)",GlobalV::FORCE_THR,force_thr);
GlobalV::FORCE_THR = this->force_thr;
}
}
// 2
else if (strcmp("force_thr_ev", word) == 0)
{
read_value(ifs, force_thr);
force_thr = force_thr / 13.6058 * 0.529177;
if(force_thr!=GlobalV::FORCE_THR)
{
this->change(GlobalV::ofs_warning,"force_thr(Ry/Bohr)",GlobalV::FORCE_THR,force_thr);
GlobalV::FORCE_THR = this->force_thr;
}
}
// 3
#ifdef __LCAO
else if (strcmp("force_thr_ev2", word) == 0)
{
read_value(ifs, force_thr_ev2);
if(force_thr_ev2!=Force_Stress_LCAO::force_invalid_threshold_ev)
{
this->change(GlobalV::ofs_warning,"force_thr threshold(Ry/Bohr)",Force_Stress_LCAO::force_invalid_threshold_ev,force_thr_ev2);
Force_Stress_LCAO::force_invalid_threshold_ev = this->force_thr_ev2;
}
}
#endif
// 4
else if (strcmp("scf_thr", word) == 0)
{
read_value(ifs, scf_thr);
if(scf_thr!=GlobalV::SCF_THR)
{
this->change(GlobalV::ofs_warning,"scf_thr",GlobalV::SCF_THR,scf_thr);
GlobalV::SCF_THR = this->scf_thr;
}
}
// 5
else if (strcmp("scf_nmax", word) == 0)
{
read_value(ifs, scf_nmax);
if(scf_nmax!=GlobalV::SCF_NMAX)
{
this->change(GlobalV::ofs_warning,"scf_nmax",GlobalV::SCF_NMAX,scf_nmax);
GlobalV::SCF_NMAX = this->scf_nmax;
}
}
// 6
else if (strcmp("relax_nmax", word) == 0)
{
read_value(ifs, relax_nmax);
if(relax_nmax!=GlobalV::RELAX_NMAX)
{
this->change(GlobalV::ofs_warning,"relax_nmax",GlobalV::RELAX_NMAX,relax_nmax);
GlobalV::RELAX_NMAX = this->relax_nmax;
}
}
else if (strcmp("md_nstep", word) == 0)
{
read_value(ifs, md_nstep);
if(md_nstep!=GlobalV::MD_NSTEP)
{
this->change(GlobalV::ofs_warning, "md_nstep", GlobalV::MD_NSTEP, md_nstep);
GlobalV::MD_NSTEP = this->md_nstep;
}
}
// 7
else if (strcmp("mixing_beta", word) == 0)
{
read_value(ifs, mixing_beta);
if(mixing_beta!=GlobalC::CHR.mixing_beta)
{
this->change(GlobalV::ofs_warning,"mixing_beta",GlobalC::CHR.mixing_beta,mixing_beta);
GlobalC::CHR.mixing_beta = mixing_beta;
}
}
// 8
else if (strcmp("printe", word) == 0)
{
read_value(ifs, printe);
if(printe!=GlobalC::en.printe)
{
this->change(GlobalV::ofs_warning,"printe",GlobalC::en.printe,printe);
GlobalC::en.printe = this->printe; // mohan add 2011-03-16
}
}
// 9
else if (strcmp("chg_extrap", word) == 0)//xiaohui modify 2015-02-01
{
read_value(ifs, chg_extrap);
if(chg_extrap!=GlobalC::pot.chg_extrap)
{
this->change(GlobalV::ofs_warning,"chg_extrap",GlobalC::pot.chg_extrap,chg_extrap);
GlobalC::pot.chg_extrap = this->chg_extrap;
if(out_dm==0)
{
out_dm = 10000;
#ifdef __LCAO
this->change(GlobalV::ofs_warning,"out_dm",Local_Orbital_Charge::out_dm, out_dm);
Local_Orbital_Charge::out_dm=out_dm;
#endif
}
}
}
// 10
else if (strcmp("out_chg", word) == 0)
{
read_value(ifs, out_chg);
if(out_chg!=GlobalC::CHR.out_chg)
{
this->change(GlobalV::ofs_warning,"out_chg",GlobalC::CHR.out_chg,out_chg);
GlobalC::CHR.out_chg = this->out_chg;
}
}
// 11
else if (strcmp("out_dm", word) == 0)
{
read_value(ifs, out_dm);
#ifdef __LCAO
if(out_dm!=Local_Orbital_Charge::out_dm)
{
this->change(GlobalV::ofs_warning,"out_dm",Local_Orbital_Charge::out_dm,out_dm);
Local_Orbital_Charge::out_dm = this->out_dm;
}
#endif
}
// 12
else if (strcmp("out_dos", word) == 0)
{
read_value(ifs, out_dos);
if(out_dos!=GlobalC::en.out_dos)
{
this->change(GlobalV::ofs_warning,"out_dos",GlobalC::en.out_dos,out_dos);
GlobalC::en.out_dos = this->out_dos;
}
}
// 13
else if (strcmp("out_wfc_lcao", word) == 0)
{
read_value(ifs, out_wfc_lcao);
#ifdef __LCAO
//if(out_wfc_lcao!=out_wfc_lcao)
if(out_wfc_lcao!=Pdiag_Double::out_wfc_lcao) // Peize Lin change out_wfc_lcao to GlobalC::ParaO.out_wfc_lcao at 2020.01.31
{
this->change(GlobalV::ofs_warning,"out_wfc_lcao",Pdiag_Double::out_wfc_lcao,out_wfc_lcao);
Pdiag_Double::out_wfc_lcao = this->out_wfc_lcao;
}
#endif
}
else
{
//std::cout << " THE PARAMETER NAME '" << word
// << "' IS NOT USED!" << std::endl;
ifs.ignore(150, '\n');
}
ifs.rdstate();
if (ifs.eof() != 0)
{
break;
}
else if (ifs.bad() != 0)
{
std::cout << " Bad input parameters. " << std::endl;
return false;
}
else if (ifs.fail() != 0)
{
std::cout << " word = " << word << std::endl;
std::cout << " Fail to read parameters. " << std::endl;
ifs.clear();
return false;
}
else if (ifs.good() == 0)
{
break;
}
}
return true;
}//end read_parameters
#include "src_parallel/parallel_common.h"
#ifdef __MPI
void Update_input::Bcast()
{
Parallel_Common::bcast_int( GlobalV::CAL_FORCE );
Parallel_Common::bcast_double( GlobalV::FORCE_THR);
#ifdef __LCAO
Parallel_Common::bcast_double( Force_Stress_LCAO::force_invalid_threshold_ev);
Parallel_Common::bcast_int( Local_Orbital_Charge::out_dm );
Parallel_Common::bcast_int( Pdiag_Double::out_wfc_lcao );
#endif
Parallel_Common::bcast_double( GlobalV::SCF_THR );
Parallel_Common::bcast_int( GlobalV::SCF_NMAX );
Parallel_Common::bcast_int( GlobalV::RELAX_NMAX );
Parallel_Common::bcast_double( GlobalC::CHR.mixing_beta );
Parallel_Common::bcast_int( GlobalC::en.printe );
Parallel_Common::bcast_string( GlobalC::pot.chg_extrap );//xiaohui modify 2015-02-01
Parallel_Common::bcast_int( GlobalC::CHR.out_chg );
Parallel_Common::bcast_int( GlobalC::en.out_dos );
Parallel_Common::bcast_double( GlobalC::CHR.nelec );
Parallel_Common::bcast_int( GlobalV::MD_NSTEP );
return;
}
#endif