Skip to content

Commit 1b4a330

Browse files
author
Fei Yang
committed
fix INPUT problem
1 parent eb176cc commit 1b4a330

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

source/source_io/module_parameter/input_parameter.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
#include <string>
77
#include <vector>
88

9-
struct RelaxMethodParam {
10-
std::string method;
11-
std::string param;
12-
};
139

1410
// It stores all input parameters both defined in INPUT file and not defined in
1511
// INPUT file
@@ -154,7 +150,7 @@ struct Input_para
154150

155151
// ============== #Parameters (4.Relaxation) ===========================
156152
std::string relax_method = "cg"; ///< methods to move_ion: sd, bfgs, cg...
157-
RelaxMethodParam relax_method_param={"cg","1"};
153+
std::string relax_method_param = "1";
158154
bool relax_new = true;
159155
bool relax = false; ///< allow relaxation along the specific direction
160156
double relax_scale_force = 0.5;

source/source_io/read_input_item_relax.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,18 @@ void ReadInput::item_relax()
1616
item.read_value = [](const Input_Item& item, Parameter& para) {
1717
if(item.get_size()==1)
1818
{
19-
para.input.relax_method_param.method=item.str_values[0];
20-
para.input.relax_method = para.input.relax_method_param.method;
21-
para.input.relax_method_param.param = "1";
19+
para.input.relax_method = item.str_values[0];
20+
para.input.relax_method_param = "1";
2221
}
2322
else if(item.get_size()==2)
2423
{
25-
para.input.relax_method_param.method=item.str_values[0];
26-
para.input.relax_method = para.input.relax_method_param.method;
27-
para.input.relax_method_param.param = item.str_values[1];
24+
para.input.relax_method = item.str_values[0];
25+
para.input.relax_method_param = item.str_values[1];
2826
}
2927
};
3028
item.check_value = [](const Input_Item& item, const Parameter& para) {
31-
const std::vector<std::string> relax_methods = {"cg", "sd", "cg_bfgs","bfgs","lbfgs"};
32-
if (std::find(relax_methods.begin(), relax_methods.end(), para.input.relax_method_param.method) == relax_methods.end()) {
29+
const std::vector<std::string> relax_methods = {"cg", "sd", "cg_bfgs","lbfgs","bfgs"};
30+
if (std::find(relax_methods.begin(), relax_methods.end(), para.input.relax_method) == relax_methods.end()) {
3331
const std::string warningstr = nofound_str(relax_methods, "relax_method");
3432
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
3533
}

source/source_relax/ions_move_basic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ double Ions_Move_Basic::best_xxx = 1.0;
2424

2525
int Ions_Move_Basic::out_stru = 0;
2626
std::string Ions_Move_Basic::relax_method = "bfgs";
27-
RelaxMethodParam Ions_Move_Basic::relax_method_param;
27+
std::string Ions_Move_Basic::relax_method_param = "1";
2828

2929
void Ions_Move_Basic::setup_gradient(const UnitCell &ucell, const ModuleBase::matrix &force, double *pos, double *grad)
3030
{

source/source_relax/ions_move_basic.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "source_base/matrix.h"
55
#include "source_cell/unitcell.h"
6-
#include "source_io/module_parameter/input_parameter.h"
76

87
namespace Ions_Move_Basic
98
{
@@ -24,7 +23,7 @@ extern double relax_bfgs_init; // initial value of trust radius,
2423
extern double best_xxx; // the last step length of cg , we use it as bfgs`s initial step length
2524
extern std::string relax_method; // relaxation method,
2625
extern int out_stru; // output the structure or not
27-
extern RelaxMethodParam relax_method_param;
26+
extern std::string relax_method_param;
2827
// funny way to pass this parameter, but nevertheless
2928

3029
//----------------------------------------------------------------------------

source/source_relax/ions_move_methods.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void Ions_Move_Methods::allocate(const int &natom)
1616
{
1717
Ions_Move_Basic::dim = natom * 3;
1818

19-
if (Ions_Move_Basic::relax_method_param.method == "bfgs"&&Ions_Move_Basic::relax_method_param.param != "1")
19+
if (Ions_Move_Basic::relax_method == "bfgs"&&Ions_Move_Basic::relax_method_param != "1")
2020
{
2121
this->bfgs.allocate();
2222
}
@@ -33,7 +33,7 @@ void Ions_Move_Methods::allocate(const int &natom)
3333
this->cg.allocate();
3434
this->bfgs.allocate(); // added by pengfei 13-8-8
3535
}
36-
else if(Ions_Move_Basic::relax_method_param.method == "bfgs"&&Ions_Move_Basic::relax_method_param.param == "1")
36+
else if(Ions_Move_Basic::relax_method == "bfgs"&&Ions_Move_Basic::relax_method_param == "1")
3737
{
3838
this->bfgs_trad.allocate(natom);
3939
}
@@ -56,10 +56,9 @@ void Ions_Move_Methods::cal_movement(const int &istep,
5656
UnitCell &ucell)
5757
{
5858
ModuleBase::TITLE("Ions_Move_Methods", "init");
59-
6059
// Ions_Move_Basic::istep = istep;
6160
Ions_Move_Basic::istep = force_step;
62-
if (Ions_Move_Basic::relax_method_param.method == "bfgs"&&Ions_Move_Basic::relax_method_param.param != "1")
61+
if (Ions_Move_Basic::relax_method == "bfgs"&&Ions_Move_Basic::relax_method_param != "1")
6362
{
6463
// move_ions
6564
// output tau
@@ -78,7 +77,7 @@ void Ions_Move_Methods::cal_movement(const int &istep,
7877
{
7978
cg.start(ucell, f, etot); // added by pengfei 13-8-10
8079
}
81-
else if(Ions_Move_Basic::relax_method_param.method == "bfgs"&&Ions_Move_Basic::relax_method_param.param == "1")
80+
else if(Ions_Move_Basic::relax_method == "bfgs"&&Ions_Move_Basic::relax_method_param == "1")
8281
{
8382
bfgs_trad.relax_step(f,ucell);
8483
}

0 commit comments

Comments
 (0)