git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14829 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -14,15 +14,14 @@ colvar::orientation::orientation(std::string const &conf)
|
||||
: cvc(conf)
|
||||
{
|
||||
function_type = "orientation";
|
||||
parse_group(conf, "atoms", atoms);
|
||||
atom_groups.push_back(&atoms);
|
||||
atoms = parse_group(conf, "atoms");
|
||||
x.type(colvarvalue::type_quaternion);
|
||||
|
||||
ref_pos.reserve(atoms.size());
|
||||
ref_pos.reserve(atoms->size());
|
||||
|
||||
if (get_keyval(conf, "refPositions", ref_pos, ref_pos)) {
|
||||
cvm::log("Using reference positions from input file.\n");
|
||||
if (ref_pos.size() != atoms.size()) {
|
||||
if (ref_pos.size() != atoms->size()) {
|
||||
cvm::fatal_error("Error: reference positions do not "
|
||||
"match the number of requested atoms.\n");
|
||||
}
|
||||
@ -42,10 +41,10 @@ colvar::orientation::orientation(std::string const &conf)
|
||||
"if provided, must be non-zero.\n");
|
||||
} else {
|
||||
// if not, use atom indices
|
||||
atoms.create_sorted_ids();
|
||||
atoms->create_sorted_ids();
|
||||
}
|
||||
ref_pos.resize(atoms.size());
|
||||
cvm::load_coords(file_name.c_str(), ref_pos, atoms.sorted_ids, file_col, file_col_value);
|
||||
ref_pos.resize(atoms->size());
|
||||
cvm::load_coords(file_name.c_str(), ref_pos, atoms->sorted_ids, file_col, file_col_value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,8 +70,8 @@ colvar::orientation::orientation(std::string const &conf)
|
||||
get_keyval(conf, "closestToQuaternion", ref_quat, cvm::quaternion(1.0, 0.0, 0.0, 0.0));
|
||||
|
||||
// initialize rot member data
|
||||
if (!atoms.noforce) {
|
||||
rot.request_group2_gradients(atoms.size());
|
||||
if (!atoms->noforce) {
|
||||
rot.request_group2_gradients(atoms->size());
|
||||
}
|
||||
|
||||
}
|
||||
@ -88,9 +87,9 @@ colvar::orientation::orientation()
|
||||
|
||||
void colvar::orientation::calc_value()
|
||||
{
|
||||
atoms_cog = atoms.center_of_geometry();
|
||||
atoms_cog = atoms->center_of_geometry();
|
||||
|
||||
rot.calc_optimal_rotation(ref_pos, atoms.positions_shifted(-1.0 * atoms_cog));
|
||||
rot.calc_optimal_rotation(ref_pos, atoms->positions_shifted(-1.0 * atoms_cog));
|
||||
|
||||
if ((rot.q).inner(ref_quat) >= 0.0) {
|
||||
x.quaternion_value = rot.q;
|
||||
@ -113,10 +112,10 @@ void colvar::orientation::apply_force(colvarvalue const &force)
|
||||
{
|
||||
cvm::quaternion const &FQ = force.quaternion_value;
|
||||
|
||||
if (!atoms.noforce) {
|
||||
for (size_t ia = 0; ia < atoms.size(); ia++) {
|
||||
if (!atoms->noforce) {
|
||||
for (size_t ia = 0; ia < atoms->size(); ia++) {
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
atoms[ia].apply_force(FQ[i] * rot.dQ0_2[ia][i]);
|
||||
(*atoms)[ia].apply_force(FQ[i] * rot.dQ0_2[ia][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,9 +141,9 @@ colvar::orientation_angle::orientation_angle()
|
||||
|
||||
void colvar::orientation_angle::calc_value()
|
||||
{
|
||||
atoms_cog = atoms.center_of_geometry();
|
||||
atoms_cog = atoms->center_of_geometry();
|
||||
|
||||
rot.calc_optimal_rotation(ref_pos, atoms.positions_shifted(-1.0 * atoms_cog));
|
||||
rot.calc_optimal_rotation(ref_pos, atoms->positions_shifted(-1.0 * atoms_cog));
|
||||
|
||||
if ((rot.q).q0 >= 0.0) {
|
||||
x.real_value = (180.0/PI) * 2.0 * std::acos((rot.q).q0);
|
||||
@ -161,10 +160,10 @@ void colvar::orientation_angle::calc_gradients()
|
||||
((180.0 / PI) * (-2.0) / std::sqrt(1.0 - ((rot.q).q0 * (rot.q).q0))) :
|
||||
0.0 );
|
||||
|
||||
for (size_t ia = 0; ia < atoms.size(); ia++) {
|
||||
atoms[ia].grad = (dxdq0 * (rot.dQ0_2[ia])[0]);
|
||||
for (size_t ia = 0; ia < atoms->size(); ia++) {
|
||||
(*atoms)[ia].grad = (dxdq0 * (rot.dQ0_2[ia])[0]);
|
||||
}
|
||||
if (b_debug_gradients) {
|
||||
if (is_enabled(f_cvc_debug_gradient)) {
|
||||
cvm::log("Debugging orientationAngle component gradients:\n");
|
||||
debug_gradients(atoms);
|
||||
}
|
||||
@ -174,8 +173,8 @@ void colvar::orientation_angle::calc_gradients()
|
||||
void colvar::orientation_angle::apply_force(colvarvalue const &force)
|
||||
{
|
||||
cvm::real const &fw = force.real_value;
|
||||
if (!atoms.noforce) {
|
||||
atoms.apply_colvar_force(fw);
|
||||
if (!atoms->noforce) {
|
||||
atoms->apply_colvar_force(fw);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,8 +198,8 @@ colvar::orientation_proj::orientation_proj()
|
||||
|
||||
void colvar::orientation_proj::calc_value()
|
||||
{
|
||||
atoms_cog = atoms.center_of_geometry();
|
||||
rot.calc_optimal_rotation(ref_pos, atoms.positions_shifted(-1.0 * atoms_cog));
|
||||
atoms_cog = atoms->center_of_geometry();
|
||||
rot.calc_optimal_rotation(ref_pos, atoms->positions_shifted(-1.0 * atoms_cog));
|
||||
x.real_value = 2.0 * (rot.q).q0 * (rot.q).q0 - 1.0;
|
||||
}
|
||||
|
||||
@ -208,10 +207,10 @@ void colvar::orientation_proj::calc_value()
|
||||
void colvar::orientation_proj::calc_gradients()
|
||||
{
|
||||
cvm::real const dxdq0 = 2.0 * 2.0 * (rot.q).q0;
|
||||
for (size_t ia = 0; ia < atoms.size(); ia++) {
|
||||
atoms[ia].grad = (dxdq0 * (rot.dQ0_2[ia])[0]);
|
||||
for (size_t ia = 0; ia < atoms->size(); ia++) {
|
||||
(*atoms)[ia].grad = (dxdq0 * (rot.dQ0_2[ia])[0]);
|
||||
}
|
||||
if (b_debug_gradients) {
|
||||
if (is_enabled(f_cvc_debug_gradient)) {
|
||||
cvm::log("Debugging orientationProj component gradients:\n");
|
||||
debug_gradients(atoms);
|
||||
}
|
||||
@ -222,8 +221,8 @@ void colvar::orientation_proj::apply_force(colvarvalue const &force)
|
||||
{
|
||||
cvm::real const &fw = force.real_value;
|
||||
|
||||
if (!atoms.noforce) {
|
||||
atoms.apply_colvar_force(fw);
|
||||
if (!atoms->noforce) {
|
||||
atoms->apply_colvar_force(fw);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,9 +254,9 @@ colvar::tilt::tilt()
|
||||
|
||||
void colvar::tilt::calc_value()
|
||||
{
|
||||
atoms_cog = atoms.center_of_geometry();
|
||||
atoms_cog = atoms->center_of_geometry();
|
||||
|
||||
rot.calc_optimal_rotation(ref_pos, atoms.positions_shifted(-1.0 * atoms_cog));
|
||||
rot.calc_optimal_rotation(ref_pos, atoms->positions_shifted(-1.0 * atoms_cog));
|
||||
|
||||
x.real_value = rot.cos_theta(axis);
|
||||
}
|
||||
@ -267,14 +266,14 @@ void colvar::tilt::calc_gradients()
|
||||
{
|
||||
cvm::quaternion const dxdq = rot.dcos_theta_dq(axis);
|
||||
|
||||
for (size_t ia = 0; ia < atoms.size(); ia++) {
|
||||
atoms[ia].grad = cvm::rvector(0.0, 0.0, 0.0);
|
||||
for (size_t ia = 0; ia < atoms->size(); ia++) {
|
||||
(*atoms)[ia].grad = cvm::rvector(0.0, 0.0, 0.0);
|
||||
for (size_t iq = 0; iq < 4; iq++) {
|
||||
atoms[ia].grad += (dxdq[iq] * (rot.dQ0_2[ia])[iq]);
|
||||
(*atoms)[ia].grad += (dxdq[iq] * (rot.dQ0_2[ia])[iq]);
|
||||
}
|
||||
}
|
||||
|
||||
if (b_debug_gradients) {
|
||||
if (is_enabled(f_cvc_debug_gradient)) {
|
||||
cvm::log("Debugging tilt component gradients:\n");
|
||||
debug_gradients(atoms);
|
||||
}
|
||||
@ -285,8 +284,8 @@ void colvar::tilt::apply_force(colvarvalue const &force)
|
||||
{
|
||||
cvm::real const &fw = force.real_value;
|
||||
|
||||
if (!atoms.noforce) {
|
||||
atoms.apply_colvar_force(fw);
|
||||
if (!atoms->noforce) {
|
||||
atoms->apply_colvar_force(fw);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,9 +321,9 @@ colvar::spin_angle::spin_angle()
|
||||
|
||||
void colvar::spin_angle::calc_value()
|
||||
{
|
||||
atoms_cog = atoms.center_of_geometry();
|
||||
atoms_cog = atoms->center_of_geometry();
|
||||
|
||||
rot.calc_optimal_rotation(ref_pos, atoms.positions_shifted(-1.0 * atoms_cog));
|
||||
rot.calc_optimal_rotation(ref_pos, atoms->positions_shifted(-1.0 * atoms_cog));
|
||||
|
||||
x.real_value = rot.spin_angle(axis);
|
||||
this->wrap(x);
|
||||
@ -335,10 +334,10 @@ void colvar::spin_angle::calc_gradients()
|
||||
{
|
||||
cvm::quaternion const dxdq = rot.dspin_angle_dq(axis);
|
||||
|
||||
for (size_t ia = 0; ia < atoms.size(); ia++) {
|
||||
atoms[ia].grad = cvm::rvector(0.0, 0.0, 0.0);
|
||||
for (size_t ia = 0; ia < atoms->size(); ia++) {
|
||||
(*atoms)[ia].grad = cvm::rvector(0.0, 0.0, 0.0);
|
||||
for (size_t iq = 0; iq < 4; iq++) {
|
||||
atoms[ia].grad += (dxdq[iq] * (rot.dQ0_2[ia])[iq]);
|
||||
(*atoms)[ia].grad += (dxdq[iq] * (rot.dQ0_2[ia])[iq]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -348,7 +347,7 @@ void colvar::spin_angle::apply_force(colvarvalue const &force)
|
||||
{
|
||||
cvm::real const &fw = force.real_value;
|
||||
|
||||
if (!atoms.noforce) {
|
||||
atoms.apply_colvar_force(fw);
|
||||
if (!atoms->noforce) {
|
||||
atoms->apply_colvar_force(fw);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user