Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

colvarproxy_system.C

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 
00003 // This file is part of the Collective Variables module (Colvars).
00004 // The original version of Colvars and its updates are located at:
00005 // https://github.com/Colvars/colvars
00006 // Please update all Colvars source files before making any changes.
00007 // If you wish to distribute your changes, please submit them to the
00008 // Colvars repository at GitHub.
00009 
00010 
00011 #include "colvarmodule.h"
00012 #include "colvartypes.h"
00013 #include "colvarproxy_system.h"
00014 
00015 
00016 
00017 colvarproxy_system::colvarproxy_system()
00018 {
00019   angstrom_value_ = 0.0;
00020   kcal_mol_value_ = 0.0;
00021   target_temperature_ = 0.0;
00022   boltzmann_ = 0.001987191; // Default: kcal/mol/K
00023   boundaries_type = boundaries_unsupported;
00024   total_force_requested = false;
00025   indirect_lambda_biasing_force = 0.0;
00026   cached_alch_lambda_changed = false;
00027   cached_alch_lambda = -1.0;
00028   reset_pbc_lattice();
00029 }
00030 
00031 
00032 colvarproxy_system::~colvarproxy_system() {}
00033 
00034 
00035 int colvarproxy_system::set_unit_system(std::string const & /* units */,
00036                                         bool /* check_only */)
00037 {
00038   return COLVARS_NOT_IMPLEMENTED;
00039 }
00040 
00041 
00042 int colvarproxy_system::set_target_temperature(cvm::real T)
00043 {
00044   target_temperature_ = T;
00045   return COLVARS_OK;
00046 }
00047 
00048 
00049 cvm::real colvarproxy_system::dt()
00050 {
00051   // TODO define, document and implement a user method to set the value of this
00052   return 1.0;
00053 }
00054 
00055 
00056 cvm::real colvarproxy_system::rand_gaussian()
00057 {
00058   // TODO define, document and implement a user method to set the value of this
00059   return 0.0;
00060 }
00061 
00062 
00063 void colvarproxy_system::add_energy(cvm::real /* energy */) {}
00064 
00065 
00066 void colvarproxy_system::request_total_force(bool yesno)
00067 {
00068   if (yesno == true)
00069     cvm::error("Error: total forces are currently not implemented.\n",
00070                COLVARS_NOT_IMPLEMENTED);
00071 }
00072 
00073 
00074 bool colvarproxy_system::total_forces_enabled() const
00075 {
00076   return false;
00077 }
00078 
00079 
00080 bool colvarproxy_system::total_forces_same_step() const
00081 {
00082   return false;
00083 }
00084 
00085 
00086 inline int round_to_integer(cvm::real x)
00087 {
00088   return int(cvm::floor(x+0.5));
00089 }
00090 
00091 
00092 void colvarproxy_system::update_pbc_lattice()
00093 {
00094   // Periodicity is assumed in all directions
00095 
00096   if (boundaries_type == boundaries_unsupported ||
00097       boundaries_type == boundaries_non_periodic) {
00098     cvm::error("Error: setting PBC lattice with unsupported boundaries.\n",
00099                COLVARS_BUG_ERROR);
00100     return;
00101   }
00102 
00103   {
00104     cvm::rvector const v = cvm::rvector::outer(unit_cell_y, unit_cell_z);
00105     reciprocal_cell_x = v/(v*unit_cell_x);
00106   }
00107   {
00108     cvm::rvector const v = cvm::rvector::outer(unit_cell_z, unit_cell_x);
00109     reciprocal_cell_y = v/(v*unit_cell_y);
00110   }
00111   {
00112     cvm::rvector const v = cvm::rvector::outer(unit_cell_x, unit_cell_y);
00113     reciprocal_cell_z = v/(v*unit_cell_z);
00114   }
00115 }
00116 
00117 
00118 void colvarproxy_system::reset_pbc_lattice()
00119 {
00120   unit_cell_x.reset();
00121   unit_cell_y.reset();
00122   unit_cell_z.reset();
00123   reciprocal_cell_x.reset();
00124   reciprocal_cell_y.reset();
00125   reciprocal_cell_z.reset();
00126 }
00127 
00128 
00129 cvm::rvector colvarproxy_system::position_distance(cvm::atom_pos const &pos1,
00130                                                    cvm::atom_pos const &pos2)
00131   const
00132 {
00133   if (boundaries_type == boundaries_unsupported) {
00134     cvm::error("Error: unsupported boundary conditions.\n", COLVARS_INPUT_ERROR);
00135   }
00136 
00137   cvm::rvector diff = (pos2 - pos1);
00138 
00139   if (boundaries_type == boundaries_non_periodic) return diff;
00140 
00141   cvm::real const x_shift = round_to_integer(reciprocal_cell_x*diff);
00142   cvm::real const y_shift = round_to_integer(reciprocal_cell_y*diff);
00143   cvm::real const z_shift = round_to_integer(reciprocal_cell_z*diff);
00144 
00145   diff.x -= x_shift*unit_cell_x.x + y_shift*unit_cell_y.x +
00146     z_shift*unit_cell_z.x;
00147   diff.y -= x_shift*unit_cell_x.y + y_shift*unit_cell_y.y +
00148     z_shift*unit_cell_z.y;
00149   diff.z -= x_shift*unit_cell_x.z + y_shift*unit_cell_y.z +
00150     z_shift*unit_cell_z.z;
00151 
00152   return diff;
00153 }
00154 
00155 
00156 int colvarproxy_system::get_molid(int &)
00157 {
00158   cvm::error("Error: only VMD allows the use of multiple \"molecules\", "
00159              "i.e. multiple molecular systems.", COLVARS_NOT_IMPLEMENTED);
00160   return -1;
00161 }
00162 
00163 
00164 int colvarproxy_system::get_alch_lambda(cvm::real * /* lambda */)
00165 {
00166   return cvm::error("Error in get_alch_lambda: alchemical lambda dynamics is not supported by this build.",
00167     COLVARS_NOT_IMPLEMENTED);
00168 }
00169 
00170 
00171 void colvarproxy_system::set_alch_lambda(cvm::real lambda)
00172 {
00173   cached_alch_lambda = lambda;
00174   cached_alch_lambda_changed = true;
00175 }
00176 
00177 
00178 int colvarproxy_system::send_alch_lambda()
00179 {
00180   return cvm::error("Error in set_alch_lambda: alchemical lambda dynamics is not supported by this build.",
00181     COLVARS_NOT_IMPLEMENTED);
00182 }
00183 
00184 
00185 int colvarproxy_system::get_dE_dlambda(cvm::real * /* force */)
00186 {
00187   return cvm::error("Error in get_dE_dlambda: alchemical lambda dynamics is not supported by this build.",
00188     COLVARS_NOT_IMPLEMENTED);
00189 }
00190 
00191 
00192 int colvarproxy_system::apply_force_dE_dlambda(cvm::real* /* force */)
00193 {
00194   return cvm::error("Error in apply_force_dE_dlambda: function is not implemented by this build.",
00195     COLVARS_NOT_IMPLEMENTED);
00196 }
00197 
00198 
00199 int colvarproxy_system::get_d2E_dlambda2(cvm::real*)
00200 {
00201   return cvm::error("Error in get_d2E_dlambda2: function is not implemented by this build.",
00202     COLVARS_NOT_IMPLEMENTED);
00203 }

Generated on Sun Apr 28 02:43:20 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002