git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12811 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2014-12-02 02:09:53 +00:00
parent 9c0f849594
commit c4af1cdbbd
34 changed files with 5927 additions and 4786 deletions

View File

@ -7,48 +7,48 @@
#include <cmath>
colvar::angle::angle (std::string const &conf)
: cvc (conf)
colvar::angle::angle(std::string const &conf)
: cvc(conf)
{
function_type = "angle";
b_inverse_gradients = true;
b_Jacobian_derivative = true;
parse_group (conf, "group1", group1);
parse_group (conf, "group2", group2);
parse_group (conf, "group3", group3);
atom_groups.push_back (&group1);
atom_groups.push_back (&group2);
atom_groups.push_back (&group3);
if (get_keyval (conf, "oneSiteSystemForce", b_1site_force, false)) {
cvm::log ("Computing system force on group 1 only");
parse_group(conf, "group1", group1);
parse_group(conf, "group2", group2);
parse_group(conf, "group3", group3);
atom_groups.push_back(&group1);
atom_groups.push_back(&group2);
atom_groups.push_back(&group3);
if (get_keyval(conf, "oneSiteSystemForce", b_1site_force, false)) {
cvm::log("Computing system force on group 1 only");
}
x.type (colvarvalue::type_scalar);
x.type(colvarvalue::type_scalar);
}
colvar::angle::angle (cvm::atom const &a1,
colvar::angle::angle(cvm::atom const &a1,
cvm::atom const &a2,
cvm::atom const &a3)
: group1 (std::vector<cvm::atom> (1, a1)),
group2 (std::vector<cvm::atom> (1, a2)),
group3 (std::vector<cvm::atom> (1, a3))
: group1(std::vector<cvm::atom> (1, a1)),
group2(std::vector<cvm::atom> (1, a2)),
group3(std::vector<cvm::atom> (1, a3))
{
function_type = "angle";
b_inverse_gradients = true;
b_Jacobian_derivative = true;
b_1site_force = false;
atom_groups.push_back (&group1);
atom_groups.push_back (&group2);
atom_groups.push_back (&group3);
atom_groups.push_back(&group1);
atom_groups.push_back(&group2);
atom_groups.push_back(&group3);
x.type (colvarvalue::type_scalar);
x.type(colvarvalue::type_scalar);
}
colvar::angle::angle()
{
function_type = "angle";
x.type (colvarvalue::type_scalar);
x.type(colvarvalue::type_scalar);
}
@ -62,14 +62,14 @@ void colvar::angle::calc_value()
cvm::atom_pos const g2_pos = group2.center_of_mass();
cvm::atom_pos const g3_pos = group3.center_of_mass();
r21 = cvm::position_distance (g2_pos, g1_pos);
r21 = cvm::position_distance(g2_pos, g1_pos);
r21l = r21.norm();
r23 = cvm::position_distance (g2_pos, g3_pos);
r23 = cvm::position_distance(g2_pos, g3_pos);
r23l = r23.norm();
cvm::real const cos_theta = (r21*r23)/(r21l*r23l);
x.real_value = (180.0/PI) * std::acos (cos_theta);
x.real_value = (180.0/PI) * std::acos(cos_theta);
}
@ -77,7 +77,7 @@ void colvar::angle::calc_gradients()
{
size_t i;
cvm::real const cos_theta = (r21*r23)/(r21l*r23l);
cvm::real const dxdcos = -1.0 / std::sqrt (1.0 - cos_theta*cos_theta);
cvm::real const dxdcos = -1.0 / std::sqrt(1.0 - cos_theta*cos_theta);
dxdr1 = (180.0/PI) * dxdcos *
(1.0/r21l) * ( r23/r23l + (-1.0) * cos_theta * r21/r21l );
@ -132,56 +132,56 @@ void colvar::angle::calc_Jacobian_derivative()
}
void colvar::angle::apply_force (colvarvalue const &force)
void colvar::angle::apply_force(colvarvalue const &force)
{
if (!group1.noforce)
group1.apply_colvar_force (force.real_value);
group1.apply_colvar_force(force.real_value);
if (!group2.noforce)
group2.apply_colvar_force (force.real_value);
group2.apply_colvar_force(force.real_value);
if (!group3.noforce)
group3.apply_colvar_force (force.real_value);
group3.apply_colvar_force(force.real_value);
}
colvar::dihedral::dihedral (std::string const &conf)
: cvc (conf)
colvar::dihedral::dihedral(std::string const &conf)
: cvc(conf)
{
function_type = "dihedral";
period = 360.0;
b_periodic = true;
b_inverse_gradients = true;
b_Jacobian_derivative = true;
if (get_keyval (conf, "oneSiteSystemForce", b_1site_force, false)) {
cvm::log ("Computing system force on group 1 only");
if (get_keyval(conf, "oneSiteSystemForce", b_1site_force, false)) {
cvm::log("Computing system force on group 1 only");
}
parse_group (conf, "group1", group1);
parse_group (conf, "group2", group2);
parse_group (conf, "group3", group3);
parse_group (conf, "group4", group4);
atom_groups.push_back (&group1);
atom_groups.push_back (&group2);
atom_groups.push_back (&group3);
atom_groups.push_back (&group4);
parse_group(conf, "group1", group1);
parse_group(conf, "group2", group2);
parse_group(conf, "group3", group3);
parse_group(conf, "group4", group4);
atom_groups.push_back(&group1);
atom_groups.push_back(&group2);
atom_groups.push_back(&group3);
atom_groups.push_back(&group4);
x.type (colvarvalue::type_scalar);
x.type(colvarvalue::type_scalar);
}
colvar::dihedral::dihedral (cvm::atom const &a1,
colvar::dihedral::dihedral(cvm::atom const &a1,
cvm::atom const &a2,
cvm::atom const &a3,
cvm::atom const &a4)
: group1 (std::vector<cvm::atom> (1, a1)),
group2 (std::vector<cvm::atom> (1, a2)),
group3 (std::vector<cvm::atom> (1, a3)),
group4 (std::vector<cvm::atom> (1, a4))
: group1(std::vector<cvm::atom> (1, a1)),
group2(std::vector<cvm::atom> (1, a2)),
group3(std::vector<cvm::atom> (1, a3)),
group4(std::vector<cvm::atom> (1, a4))
{
if (cvm::debug())
cvm::log ("Initializing dihedral object from atom groups.\n");
cvm::log("Initializing dihedral object from atom groups.\n");
function_type = "dihedral";
period = 360.0;
@ -190,15 +190,15 @@ colvar::dihedral::dihedral (cvm::atom const &a1,
b_Jacobian_derivative = true;
b_1site_force = false;
atom_groups.push_back (&group1);
atom_groups.push_back (&group2);
atom_groups.push_back (&group3);
atom_groups.push_back (&group4);
atom_groups.push_back(&group1);
atom_groups.push_back(&group2);
atom_groups.push_back(&group3);
atom_groups.push_back(&group4);
x.type (colvarvalue::type_scalar);
x.type(colvarvalue::type_scalar);
if (cvm::debug())
cvm::log ("Done initializing dihedral object from atom groups.\n");
cvm::log("Done initializing dihedral object from atom groups.\n");
}
@ -209,7 +209,7 @@ colvar::dihedral::dihedral()
b_periodic = true;
b_inverse_gradients = true;
b_Jacobian_derivative = true;
x.type (colvarvalue::type_scalar);
x.type(colvarvalue::type_scalar);
}
@ -226,28 +226,28 @@ void colvar::dihedral::calc_value()
cvm::atom_pos const g4_pos = group4.center_of_mass();
// Usual sign convention: r12 = r2 - r1
r12 = cvm::position_distance (g1_pos, g2_pos);
r23 = cvm::position_distance (g2_pos, g3_pos);
r34 = cvm::position_distance (g3_pos, g4_pos);
r12 = cvm::position_distance(g1_pos, g2_pos);
r23 = cvm::position_distance(g2_pos, g3_pos);
r34 = cvm::position_distance(g3_pos, g4_pos);
cvm::rvector const n1 = cvm::rvector::outer (r12, r23);
cvm::rvector const n2 = cvm::rvector::outer (r23, r34);
cvm::rvector const n1 = cvm::rvector::outer(r12, r23);
cvm::rvector const n2 = cvm::rvector::outer(r23, r34);
cvm::real const cos_phi = n1 * n2;
cvm::real const sin_phi = n1 * r34 * r23.norm();
x.real_value = (180.0/PI) * std::atan2 (sin_phi, cos_phi);
this->wrap (x);
x.real_value = (180.0/PI) * std::atan2(sin_phi, cos_phi);
this->wrap(x);
}
void colvar::dihedral::calc_gradients()
{
cvm::rvector A = cvm::rvector::outer (r12, r23);
cvm::rvector A = cvm::rvector::outer(r12, r23);
cvm::real rA = A.norm();
cvm::rvector B = cvm::rvector::outer (r23, r34);
cvm::rvector B = cvm::rvector::outer(r23, r34);
cvm::real rB = B.norm();
cvm::rvector C = cvm::rvector::outer (r23, A);
cvm::rvector C = cvm::rvector::outer(r23, A);
cvm::real rC = C.norm();
cvm::real const cos_phi = (A*B)/(rA*rB);
@ -258,7 +258,7 @@ void colvar::dihedral::calc_gradients()
rB = 1.0/rB;
B *= rB;
if (std::fabs (sin_phi) > 0.1) {
if (std::fabs(sin_phi) > 0.1) {
rA = 1.0/rA;
A *= rA;
cvm::rvector const dcosdA = rA*(cos_phi*A-B);
@ -267,10 +267,10 @@ void colvar::dihedral::calc_gradients()
cvm::real const K = (1.0/sin_phi) * (180.0/PI);
f1 = K * cvm::rvector::outer (r23, dcosdA);
f3 = K * cvm::rvector::outer (dcosdB, r23);
f2 = K * (cvm::rvector::outer (dcosdA, r12)
+ cvm::rvector::outer (r34, dcosdB));
f1 = K * cvm::rvector::outer(r23, dcosdA);
f3 = K * cvm::rvector::outer(dcosdB, r23);
f2 = K * (cvm::rvector::outer(dcosdA, r12)
+ cvm::rvector::outer(r34, dcosdB));
}
else {
rC = 1.0/rC;
@ -291,7 +291,7 @@ void colvar::dihedral::calc_gradients()
- r23.z*r23.x*dsindC.x
- r23.z*r23.y*dsindC.y);
f3 = cvm::rvector::outer (dsindB, r23);
f3 = cvm::rvector::outer(dsindB, r23);
f3 *= K;
f2.x = K*(-(r23.y*r12.y + r23.z*r12.z)*dsindC.x
@ -332,14 +332,14 @@ void colvar::dihedral::calc_force_invgrads()
cvm::real const d12 = r12.norm();
cvm::real const d34 = r34.norm();
cvm::rvector const cross1 = (cvm::rvector::outer (u23, u12)).unit();
cvm::rvector const cross4 = (cvm::rvector::outer (u23, u34)).unit();
cvm::rvector const cross1 = (cvm::rvector::outer(u23, u12)).unit();
cvm::rvector const cross4 = (cvm::rvector::outer(u23, u34)).unit();
cvm::real const dot1 = u23 * u12;
cvm::real const dot4 = u23 * u34;
cvm::real const fact1 = d12 * std::sqrt (1.0 - dot1 * dot1);
cvm::real const fact4 = d34 * std::sqrt (1.0 - dot4 * dot4);
cvm::real const fact1 = d12 * std::sqrt(1.0 - dot1 * dot1);
cvm::real const fact4 = d34 * std::sqrt(1.0 - dot4 * dot4);
group1.read_system_forces();
if ( b_1site_force ) {
@ -361,19 +361,19 @@ void colvar::dihedral::calc_Jacobian_derivative()
}
void colvar::dihedral::apply_force (colvarvalue const &force)
void colvar::dihedral::apply_force(colvarvalue const &force)
{
if (!group1.noforce)
group1.apply_colvar_force (force.real_value);
group1.apply_colvar_force(force.real_value);
if (!group2.noforce)
group2.apply_colvar_force (force.real_value);
group2.apply_colvar_force(force.real_value);
if (!group3.noforce)
group3.apply_colvar_force (force.real_value);
group3.apply_colvar_force(force.real_value);
if (!group4.noforce)
group4.apply_colvar_force (force.real_value);
group4.apply_colvar_force(force.real_value);
}