Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

colvarcomp.C

Go to the documentation of this file.
00001 #include "colvarmodule.h"
00002 #include "colvarvalue.h"
00003 #include "colvar.h"
00004 #include "colvarcomp.h"
00005 
00006 
00007 
00008 colvar::cvc::cvc()
00009   : sup_coeff (1.0), sup_np (1),
00010     b_periodic (false),
00011     b_debug_gradients (false),
00012     b_inverse_gradients (false),
00013     b_Jacobian_derivative (false)
00014 {}
00015 
00016 
00017 colvar::cvc::cvc (std::string const &conf)
00018   : sup_coeff (1.0), sup_np (1),
00019     b_periodic (false),
00020     b_debug_gradients (false),
00021     b_inverse_gradients (false),
00022     b_Jacobian_derivative (false)
00023 {
00024   if (cvm::debug())
00025     cvm::log ("Initializing cvc base object.\n");
00026 
00027   get_keyval (conf, "name", this->name, std::string (""), parse_silent);
00028 
00029   get_keyval (conf, "componentCoeff", sup_coeff, 1.0);
00030   get_keyval (conf, "componentExp", sup_np, 1);
00031 
00032   get_keyval (conf, "period", period, 0.0);
00033   get_keyval (conf, "wrapAround", wrap_center, 0.0);
00034 
00035   get_keyval (conf, "debugGradients", b_debug_gradients, false, parse_silent);
00036 
00037   if (cvm::debug())
00038     cvm::log ("Done initializing cvc base object.\n");
00039 }
00040 
00041 
00042 void colvar::cvc::parse_group (std::string const &conf, 
00043                                char const *group_key,
00044                                cvm::atom_group &group,
00045                                bool optional)
00046 {
00047   if (key_lookup (conf, group_key)) {
00048     group.parse (conf, group_key);
00049   } else {
00050     if (! optional) {
00051       cvm::fatal_error ("Error: definition for atom group \""+
00052                       std::string (group_key)+"\" not found.\n");
00053     }
00054   }
00055 }
00056 
00057 
00058 colvar::cvc::~cvc()
00059 {}
00060 
00061 
00062 void colvar::cvc::calc_force_invgrads()
00063 {
00064   cvm::fatal_error ("Error: calculation of inverse gradients is not implemented "
00065                     "for colvar components of type \""+function_type+"\".\n");
00066 }
00067 
00068 
00069 void colvar::cvc::calc_Jacobian_derivative()
00070 {
00071   cvm::fatal_error ("Error: calculation of inverse gradients is not implemented "
00072                     "for colvar components of type \""+function_type+"\".\n");
00073 }
00074 
00075 
00076 colvarvalue colvar::cvc::fdiff_change (cvm::atom_group &group)
00077 {  
00078   colvarvalue change (x.type());
00079 
00080   if (group.old_pos.size()) {
00081     for (size_t i = 0; i < group.size(); i++) {
00082       cvm::rvector const &pold = group.old_pos[i];
00083       cvm::rvector const &p = group[i].pos;
00084       change += group[i].grad * (p - pold);
00085     }
00086   }
00087 
00088   // save for next step
00089   group.old_pos = group.positions();
00090   return change;
00091 }

Generated on Sun Feb 12 04:07:53 2012 for NAMD by  doxygen 1.3.9.1