FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
abacus-develop/source/source_relax/relax_nsync.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_nsync.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
148 lines (142 loc) · 4.39 KB
Breadcrumbs
abacus-develop
/
source
/
source_relax
/
relax_nsync.cpp
Copy path
File metadata and controls
148 lines (142 loc) · 4.39 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
#
include
"
relax_nsync.h
"
#
include
"
source_base/global_function.h
"
#
include
"
source_base/global_variable.h
"
#
include
"
source_io/module_parameter/parameter.h
"
#
include
"
source_cell/update_cell.h
"
void
Relax_old::init_relax
(
const
int
& natom)
{
//
Geometry optimization algorithm setup.
if
(
PARAM
.
inp
.
calculation
==
"
relax
"
)
{
//
Ions_Move_Methods
IMM
.
allocate
(natom);
}
if
(
PARAM
.
inp
.
calculation
==
"
cell-relax
"
)
{
//
Ions_Move_Methods
IMM
.
allocate
(natom);
//
allocate arrays related to changes of lattice vectors
LCM
.
allocate
();
}
}
//
The interface for relaxation
bool
Relax_old::relax_step
(
const
int
& istep,
const
double
& energy,
UnitCell& ucell,
ModuleBase::matrix force,
ModuleBase::matrix stress,
int
& force_step,
int
& stress_step)
{
ModuleBase::TITLE
(
"
Relax_old
"
,
"
relax_step
"
);
//
should not do it this way, will change after the refactor of ucell class
ucell.
ionic_position_updated
=
false
;
ucell.
cell_parameter_updated
=
false
;
//
stop in last step
if
(istep ==
PARAM
.
inp
.
relax_nmax
)
{
return
true
;
}
//
choose what to do next
if
(
PARAM
.
inp
.
calculation
!=
"
cell-relax
"
) {
force_step = istep;
}
if
(
this
->
if_do_relax
(ucell))
{
//
do relax calculation and generate next structure
bool
converged =
false
;
converged =
this
->
do_relax
(istep, force, energy, ucell, force_step);
if
(!converged)
{
ucell.
ionic_position_updated
=
true
;
return
converged;
}
else
if
(
PARAM
.
inp
.
calculation
!=
"
cell-relax
"
)
{
return
converged;
}
}
if
(
this
->
if_do_cellrelax
(ucell))
{
//
do cell relax calculation and generate next structure
bool
converged =
false
;
converged =
this
->
do_cellrelax
(istep, stress_step, stress, energy, ucell);
if
(!converged)
{
force_step =
1
;
stress_step++;
ucell.
cell_parameter_updated
=
true
;
unitcell::setup_cell_after_vc
(ucell,GlobalV::ofs_running);
ModuleBase::GlobalFunc::DONE
(GlobalV::ofs_running,
"
SETUP UNITCELL
"
);
}
return
converged;
}
return
true
;
}
bool
Relax_old::if_do_relax
(
const
UnitCell& ucell)
{
ModuleBase::TITLE
(
"
Relax_old
"
,
"
if_do_relax
"
);
if
(
PARAM
.
inp
.
calculation
==
"
relax
"
||
PARAM
.
inp
.
calculation
==
"
cell-relax
"
)
{
if
(!ucell.
if_atoms_can_move
())
{
ModuleBase::WARNING
(
"
Ions
"
,
"
No atom is allowed to move!
"
);
return
false
;
}
//
if(!IMM.get_converged()) return 1;
else
{
assert
(
PARAM
.
inp
.
cal_force
==
1
);
return
true
;
}
}
else
{
return
false
;
}
}
bool
Relax_old::if_do_cellrelax
(
const
UnitCell& ucell)
{
ModuleBase::TITLE
(
"
Relax_old
"
,
"
if_do_cellrelax
"
);
if
(
PARAM
.
inp
.
calculation
==
"
cell-relax
"
)
{
if
(!ucell.
if_cell_can_change
())
{
ModuleBase::WARNING
(
"
Ions
"
,
"
Lattice vectors are not allowed to change!
"
);
return
false
;
}
else
if
(ucell.
if_atoms_can_move
() && !
IMM
.
get_converged
())
{
GlobalV::ofs_running <<
"
Note: Need to wait for atomic relaxation first!
"
;
return
false
;
}
else
{
assert
(
PARAM
.
inp
.
cal_stress
==
1
);
return
true
;
}
}
else
{
return
false
;
}
}
bool
Relax_old::do_relax
(
const
int
& istep,
const
ModuleBase::matrix& ionic_force,
const
double
& total_energy,
UnitCell& ucell,
int
& jstep)
{
ModuleBase::TITLE
(
"
Relax_old
"
,
"
do_relax
"
);
IMM
.
cal_movement
(istep, jstep, ionic_force, total_energy, ucell);
++jstep;
return
IMM
.
get_converged
();
}
bool
Relax_old::do_cellrelax
(
const
int
& istep,
const
int
& stress_step,
const
ModuleBase::matrix& stress,
const
double
& total_energy,
UnitCell& ucell)
{
ModuleBase::TITLE
(
"
Relax_old
"
,
"
do_cellrelax
"
);
LCM
.
cal_lattice_change
(istep, stress_step, stress, total_energy, ucell);
return
LCM
.
get_converged
();
}
Back
|
FazBrowse Home
|
New Git URL