Skip to content

Commit ae440ec

Browse files
committed
More checks in ALB
1 parent a5fab30 commit ae440ec

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

src/colvarbias_alb.cpp

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ colvarbias_alb::colvarbias_alb(char const *key)
3939
int colvarbias_alb::init(std::string const &conf)
4040
{
4141
colvarproxy *proxy = cvm::main()->proxy;
42-
int err = colvarbias::init(conf);
43-
if (err != COLVARS_OK) {
44-
return err;
42+
int error_code = colvarbias::init(conf);
43+
if (error_code != COLVARS_OK) {
44+
return error_code;
4545
}
46+
4647
cvm::main()->cite_feature("ALB colvar bias implementation");
4748

4849
enable(f_cvb_scalar_variables);
@@ -80,21 +81,34 @@ int colvarbias_alb::init(std::string const &conf)
8081
}
8182
} else {
8283
colvar_centers.clear();
83-
cvm::error("Error: must define the initial centers of adaptive linear bias .\n");
84+
error_code |= cvm::error("Error: must define the initial centers of adaptive linear bias.\n",
85+
COLVARS_INPUT_ERROR);
8486
}
8587

86-
if (colvar_centers.size() != num_variables())
87-
cvm::error("Error: number of centers does not match "
88-
"that of collective variables.\n");
88+
if (colvar_centers.size() != num_variables()) {
89+
error_code |=
90+
cvm::error("Error: number of centers does not match that of collective variables.\n");
91+
}
8992

90-
if (!get_keyval(conf, "UpdateFrequency", update_freq, 0))
91-
cvm::error("Error: must set updateFrequency for adaptive linear bias.\n");
93+
if (!get_keyval(conf, "updateFrequency", update_freq, 0)) {
94+
error_code |= cvm::error("Error: must set updateFrequency for adaptive linear bias.\n",
95+
COLVARS_INPUT_ERROR);
96+
}
97+
98+
if (update_freq % time_step_factor != 0) {
99+
error_code |= cvm::error("updateFrequency (currently " + cvm::to_str(update_freq) +
100+
") must be a multiple of timeStepFactor (" +
101+
cvm::to_str(time_step_factor) + ").\n",
102+
COLVARS_INPUT_ERROR);
103+
}
92104

93105
//we split the time between updating and equilibrating
94106
update_freq /= 2;
95107

96-
if (update_freq <= 1)
97-
cvm::error("Error: must set updateFrequency to greater than 2.\n");
108+
if (update_freq <= 1) {
109+
error_code |=
110+
cvm::error("Error: must set updateFrequency to greater than 2.\n", COLVARS_INPUT_ERROR);
111+
}
98112

99113
enable(f_cvb_history_dependent);
100114

@@ -136,7 +150,7 @@ int colvarbias_alb::init(std::string const &conf)
136150
if (cvm::debug())
137151
cvm::log(" bias.\n");
138152

139-
return COLVARS_OK;
153+
return error_code;
140154
}
141155

142156

0 commit comments

Comments
 (0)