FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
abacus-develop/source/source_relax/relax_driver.cpp at develop · pplab/abacus-develop · GitHub
pplab
/
abacus-develop
Public
forked from
deepmodeling/abacus-develop
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
abacus-develop
/
source
/
source_relax
/
relax_driver.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
211 lines (183 loc) · 7.03 KB
Breadcrumbs
abacus-develop
/
source
/
source_relax
/
relax_driver.cpp
Copy path
File metadata and controls
211 lines (183 loc) · 7.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
"
relax_driver.h
"
#
include
"
source_base/global_file.h
"
#
include
"
source_pw/module_pwdft/global.h
"
//
use chr.
#
include
"
source_io/cif_io.h
"
#
include
"
source_io/json_output/output_info.h
"
#
include
"
source_io/output_log.h
"
#
include
"
source_io/print_info.h
"
#
include
"
source_io/read_exit_file.h
"
#
include
"
source_io/module_parameter/parameter.h
"
#
include
"
source_cell/print_cell.h
"
void
Relax_Driver::relax_driver
(
ModuleESolver::ESolver* p_esolver,
UnitCell& ucell,
const
Input_para& inp)
{
ModuleBase::TITLE
(
"
Relax_Driver
"
,
"
relax_driver
"
);
ModuleBase::timer::tick
(
"
Relax_Driver
"
,
"
relax_driver
"
);
if
(inp.
calculation
==
"
relax
"
|| inp.
calculation
==
"
cell-relax
"
)
{
if
(!inp.
relax_new
)
//
traditional relax
{
rl_old.
init_relax
(ucell.
nat
);
}
else
//
relax new
{
rl.
init_relax
(ucell.
nat
);
}
}
this
->
istep
=
1
;
int
force_step =
1
;
int
stress_step =
1
;
bool
stop =
false
;
while
(istep <= inp.
relax_nmax
&& !stop)
{
time_t
estart =
time
(
nullptr
);
if
(inp.
out_level
==
"
ie
"
&& (inp.
calculation
==
"
relax
"
|| inp.
calculation
==
"
cell-relax
"
|| inp.
calculation
==
"
scf
"
|| inp.
calculation
==
"
nscf
"
)
&& (inp.
esolver_type
!=
"
lr
"
))
{
ModuleIO::print_screen
(stress_step, force_step, istep);
}
#
ifdef
__RAPIDJSON
Json::init_output_array_obj
();
#
endif
//
__RAPIDJSON
//
mohan added eiter to count for the electron iteration number, 2021-01-28
p_esolver->
runner
(ucell, istep -
1
);
time_t
eend =
time
(
nullptr
);
time_t
fstart =
time
(
nullptr
);
ModuleBase::matrix force;
ModuleBase::matrix stress;
//
I'm considering putting force and stress
//
as part of ucell and use ucell to pass information
//
back and forth between esolver and relaxation
//
but I'll use force and stress explicitly here for now
//
calculate the total energy
this
->
etot
= p_esolver->
cal_energy
();
//
calculate and gather all parts of total ionic forces
if
(inp.
cal_force
)
{
p_esolver->
cal_force
(ucell, force);
}
else
{
//
do nothing
}
//
calculate and gather all parts of stress
if
(inp.
cal_stress
)
{
p_esolver->
cal_stress
(ucell, stress);
}
else
{
//
do nothing
}
if
(inp.
calculation
==
"
relax
"
|| inp.
calculation
==
"
cell-relax
"
)
{
if
(inp.
relax_new
)
{
stop = rl.
relax_step
(ucell, force, stress,
this
->
etot
);
//
mohan added 2025-07-14
stress_step = istep+
1
;
force_step =
1
;
}
else
{
stop = rl_old.
relax_step
(istep,
this
->
etot
,
ucell,
force,
stress,
force_step,
stress_step);
}
bool
need_orb = inp.
basis_type
==
"
pw
"
;
need_orb = need_orb && inp.
init_wfc
.
substr
(
0
,
3
) ==
"
nao
"
;
need_orb = need_orb || inp.
basis_type
==
"
lcao
"
;
need_orb = need_orb || inp.
basis_type
==
"
lcao_in_pw
"
;
std::stringstream ss, ss1;
ss <<
PARAM
.
globalv
.
global_out_dir
<<
"
STRU_ION_D
"
;
unitcell::print_stru_file
(ucell,
ucell.
atoms
,
ucell.
latvec
,
ss.
str
(),
inp.
nspin
,
true
,
inp.
calculation
==
"
md
"
,
inp.
out_mul
,
need_orb,
PARAM
.
globalv
.
deepks_setorb
,
GlobalV::
MY_RANK
);
if
(Ions_Move_Basic::out_stru)
{
ss1 <<
PARAM
.
globalv
.
global_out_dir
<<
"
STRU_ION
"
;
ss1 << istep <<
"
_D
"
;
unitcell::print_stru_file
(ucell,
ucell.
atoms
,
ucell.
latvec
,
ss1.
str
(),
inp.
nspin
,
true
,
inp.
calculation
==
"
md
"
,
inp.
out_mul
,
need_orb,
PARAM
.
globalv
.
deepks_setorb
,
GlobalV::
MY_RANK
);
ModuleIO::CifParser::write
(
PARAM
.
globalv
.
global_out_dir
+
"
STRU_NOW.cif
"
,
ucell,
"
# Generated by ABACUS ModuleIO::CifParser
"
,
"
data_?
"
);
}
ModuleIO::output_after_relax
(stop, p_esolver->
conv_esolver
, GlobalV::ofs_running);
}
//
end relax or cell_relax
#
ifdef
__RAPIDJSON
//
add the energy to outout
Json::add_output_energy
(p_esolver->
cal_energy
() * ModuleBase::Ry_to_eV);
//
add Json of cell coo stress force
double
unit_transform = ModuleBase::
RYDBERG_SI
/
pow
(ModuleBase::
BOHR_RADIUS_SI
,
3
) *
1.0e-8
;
double
fac = ModuleBase::Ry_to_eV /
0.529177
;
Json::add_output_cell_coo_stress_force
(&ucell, force, fac, stress, unit_transform);
#
endif
//
__RAPIDJSON
if
(stop ==
false
)
{
stop =
ModuleIO::read_exit_file
(GlobalV::
MY_RANK
,
"
EXIT
"
, GlobalV::ofs_running);
}
time_t
fend =
time
(
nullptr
);
++istep;
}
//
end while (istep <= inp.relax_nmax && !stop)
if
(inp.
calculation
==
"
relax
"
|| inp.
calculation
==
"
cell-relax
"
)
{
if
(istep-
1
== inp.
relax_nmax
)
{
std::cout <<
"
\n
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
<< std::endl;
std::cout <<
"
Geometry relaxation stops here due to reaching the maximum
"
<< std::endl;
std::cout <<
"
relaxation steps. More steps are needed to converge the results
"
<< std::endl;
std::cout <<
"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
<< std::endl;
}
else
{
std::cout <<
"
\n
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
<< std::endl;
std::cout <<
"
Geometry relaxation thresholds are reached within
"
<< istep-
1
<<
"
steps.
"
<< std::endl;
std::cout <<
"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
<< std::endl;
}
}
else
{
//
do nothing
}
if
(inp.
relax_nmax
==
0
)
{
std::cout <<
"
-----------------------------------------------
"
<< std::endl;
std::cout <<
"
relax_nmax = 0, DRY RUN TEST SUCCEEDS :)
"
<< std::endl;
std::cout <<
"
-----------------------------------------------
"
<< std::endl;
}
else
{
//
do nothing
}
ModuleBase::timer::tick
(
"
Relax_Driver
"
,
"
relax_driver
"
);
return
;
}
Back
|
FazBrowse Home
|
New Git URL