git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13670 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -845,6 +845,7 @@ void colvar::calc()
|
||||
// prepare atom groups for calculation
|
||||
if (cvm::debug())
|
||||
cvm::log("Collecting data from atom groups.\n");
|
||||
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
for (ig = 0; ig < cvcs[i]->atom_groups.size(); ig++) {
|
||||
cvm::atom_group &atoms = *(cvcs[i]->atom_groups[ig]);
|
||||
@ -856,6 +857,7 @@ void colvar::calc()
|
||||
// each atom group will take care of its own ref_pos_group, if defined
|
||||
}
|
||||
}
|
||||
|
||||
//// Don't try to get atom velocities, as no back-end currently implements it
|
||||
// if (tasks[task_output_velocity] && !tasks[task_fdiff_velocity]) {
|
||||
// for (i = 0; i < cvcs.size(); i++) {
|
||||
@ -864,6 +866,7 @@ void colvar::calc()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (tasks[task_system_force]) {
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
for (ig = 0; ig < cvcs[i]->atom_groups.size(); ig++) {
|
||||
@ -880,6 +883,7 @@ void colvar::calc()
|
||||
|
||||
// First, update component values
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
cvm::increase_depth();
|
||||
(cvcs[i])->calc_value();
|
||||
cvm::decrease_depth();
|
||||
@ -905,6 +909,7 @@ void colvar::calc()
|
||||
} else if (x.type() == colvarvalue::type_scalar) {
|
||||
// polynomial combination allowed
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
x += (cvcs[i])->sup_coeff *
|
||||
( ((cvcs[i])->sup_np != 1) ?
|
||||
std::pow((cvcs[i])->value().real_value, (cvcs[i])->sup_np) :
|
||||
@ -913,6 +918,7 @@ void colvar::calc()
|
||||
} else {
|
||||
// only linear combination allowed
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
x += (cvcs[i])->sup_coeff * (cvcs[i])->value();
|
||||
}
|
||||
}
|
||||
@ -928,17 +934,15 @@ void colvar::calc()
|
||||
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
// calculate the gradients of each component
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
cvm::increase_depth();
|
||||
|
||||
(cvcs[i])->calc_gradients();
|
||||
|
||||
// if requested, propagate (via chain rule) the gradients above
|
||||
// to the atoms used to define the roto-translation
|
||||
for (ig = 0; ig < cvcs[i]->atom_groups.size(); ig++) {
|
||||
if (cvcs[i]->atom_groups[ig]->b_fit_gradients)
|
||||
cvcs[i]->atom_groups[ig]->calc_fit_gradients();
|
||||
}
|
||||
|
||||
cvm::decrease_depth();
|
||||
}
|
||||
|
||||
@ -958,6 +962,7 @@ void colvar::calc()
|
||||
atomic_gradients[a].reset();
|
||||
}
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
// Coefficient: d(a * x^n) = a * n * x^(n-1) * dx
|
||||
cvm::real coeff = (cvcs[i])->sup_coeff * cvm::real((cvcs[i])->sup_np) *
|
||||
std::pow((cvcs[i])->value().real_value, (cvcs[i])->sup_np-1);
|
||||
@ -1123,19 +1128,23 @@ cvm::real colvar::update()
|
||||
|
||||
if (tasks[task_Jacobian_force]) {
|
||||
size_t i;
|
||||
cvm::increase_depth();
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
cvm::increase_depth();
|
||||
(cvcs[i])->calc_Jacobian_derivative();
|
||||
cvm::decrease_depth();
|
||||
}
|
||||
cvm::decrease_depth();
|
||||
|
||||
size_t ncvc = 0;
|
||||
fj.reset();
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
// linear combination is assumed
|
||||
fj += 1.0 / ( cvm::real(cvcs.size()) * cvm::real((cvcs[i])->sup_coeff) ) *
|
||||
fj += 1.0 / cvm::real((cvcs[i])->sup_coeff) *
|
||||
(cvcs[i])->Jacobian_derivative();
|
||||
ncvc++;
|
||||
}
|
||||
fj *= cvm::boltzmann() * cvm::temperature();
|
||||
fj *= (1.0/cvm::real(ncvc)) * cvm::boltzmann() * cvm::temperature();
|
||||
|
||||
// the instantaneous Jacobian force was not included in the reported system force;
|
||||
// instead, it is subtracted from the applied force (silent Jacobian correction)
|
||||
@ -1196,6 +1205,7 @@ void colvar::communicate_forces()
|
||||
if (tasks[task_scripted]) {
|
||||
std::vector<cvm::matrix2d<cvm::real> > func_grads;
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
func_grads.push_back(cvm::matrix2d<cvm::real> (x.size(),
|
||||
cvcs[i]->value().size()));
|
||||
}
|
||||
@ -1211,6 +1221,7 @@ void colvar::communicate_forces()
|
||||
}
|
||||
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
cvm::increase_depth();
|
||||
// cvc force is colvar force times colvar/cvc Jacobian
|
||||
// (vector-matrix product)
|
||||
@ -1221,6 +1232,7 @@ void colvar::communicate_forces()
|
||||
} else if (x.type() == colvarvalue::type_scalar) {
|
||||
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
cvm::increase_depth();
|
||||
(cvcs[i])->apply_force(f * (cvcs[i])->sup_coeff *
|
||||
cvm::real((cvcs[i])->sup_np) *
|
||||
@ -1232,6 +1244,7 @@ void colvar::communicate_forces()
|
||||
} else {
|
||||
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
cvm::increase_depth();
|
||||
(cvcs[i])->apply_force(f * (cvcs[i])->sup_coeff);
|
||||
cvm::decrease_depth();
|
||||
@ -1243,6 +1256,25 @@ void colvar::communicate_forces()
|
||||
}
|
||||
|
||||
|
||||
int colvar::set_cvc_flags(std::vector<bool> const &flags) {
|
||||
|
||||
size_t i;
|
||||
if (flags.size() != cvcs.size()) {
|
||||
cvm::error("ERROR: Wrong number of CVC flags provided.");
|
||||
return COLVARS_ERROR;
|
||||
}
|
||||
bool e = false;
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
cvcs[i]->b_enabled = flags[i];
|
||||
e = e || flags[i];
|
||||
}
|
||||
if (!e) {
|
||||
cvm::error("ERROR: All CVCs are disabled for this colvar.");
|
||||
return COLVARS_ERROR;
|
||||
}
|
||||
return COLVARS_OK;
|
||||
}
|
||||
|
||||
|
||||
// ******************** METRIC FUNCTIONS ********************
|
||||
// Use the metrics defined by \link cvc \endlink objects
|
||||
|
||||
Reference in New Issue
Block a user