48#include "FluctuatingChargeNVE.hpp"
51#include "utils/simError.h"
55 FluctuatingChargeNVE::FluctuatingChargeNVE(
SimInfo* info) :
57 snap(info->getSnapshotManager()->getCurrentSnapshot()), thermo(info) {}
59 void FluctuatingChargeNVE::initialize() {
60 FluctuatingChargePropagator::initialize();
62 if (info_->getSimParams()->haveDt()) {
63 dt_ = info_->getSimParams()->getDt();
66 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
67 "FluctuatingChargeNVE Error: dt is not set\n");
72 if (!info_->getSimParams()->getUseIntialExtendedSystemState()) {
73 snap->setElectronicThermostat(make_pair(0.0, 0.0));
78 void FluctuatingChargeNVE::moveA() {
79 if (!hasFlucQ_)
return;
81 SimInfo::MoleculeIterator i;
82 Molecule::FluctuatingChargeIterator j;
85 RealType cvel, cpos, cfrc, cmass;
87 for (mol = info_->beginMolecule(i); mol != NULL;
88 mol = info_->nextMolecule(i)) {
89 for (atom = mol->beginFluctuatingCharge(j); atom != NULL;
90 atom = mol->nextFluctuatingCharge(j)) {
91 cvel = atom->getFlucQVel();
92 cpos = atom->getFlucQPos();
93 cfrc = atom->getFlucQFrc();
94 cmass = atom->getChargeMass();
97 cvel += dt2_ * cfrc / cmass;
101 atom->setFlucQVel(cvel);
102 atom->setFlucQPos(cpos);
107 void FluctuatingChargeNVE::moveB() {
108 if (!hasFlucQ_)
return;
109 SimInfo::MoleculeIterator i;
110 Molecule::FluctuatingChargeIterator j;
113 RealType cfrc, cvel, cmass;
115 for (mol = info_->beginMolecule(i); mol != NULL;
116 mol = info_->nextMolecule(i)) {
117 for (atom = mol->beginFluctuatingCharge(j); atom != NULL;
118 atom = mol->nextFluctuatingCharge(j)) {
119 cvel = atom->getFlucQVel();
120 cfrc = atom->getFlucQFrc();
121 cmass = atom->getChargeMass();
124 cvel += dt2_ * cfrc / cmass;
125 atom->setFlucQVel(cvel);
129 void FluctuatingChargeNVE::VelocityStep(RealType dt) {
130 if (!hasFlucQ_)
return;
132 SimInfo::MoleculeIterator i;
133 Molecule::FluctuatingChargeIterator j;
136 RealType cvel, cfrc, cmass;
138 for (mol = info_->beginMolecule(i); mol != NULL;
139 mol = info_->nextMolecule(i)) {
140 for (atom = mol->beginFluctuatingCharge(j); atom != NULL;
141 atom = mol->nextFluctuatingCharge(j)) {
142 cvel = atom->getFlucQVel();
143 cfrc = atom->getFlucQFrc();
144 cmass = atom->getChargeMass();
147 cvel += dt * cfrc / cmass;
148 atom->setFlucQVel(cvel);
153 void FluctuatingChargeNVE::PositionStep(RealType dt) {
154 if (!hasFlucQ_)
return;
156 SimInfo::MoleculeIterator i;
157 Molecule::FluctuatingChargeIterator j;
162 for (mol = info_->beginMolecule(i); mol != NULL;
163 mol = info_->nextMolecule(i)) {
164 for (atom = mol->beginFluctuatingCharge(j); atom != NULL;
165 atom = mol->nextFluctuatingCharge(j)) {
166 cvel = atom->getFlucQVel();
167 cpos = atom->getFlucQPos();
170 atom->setFlucQPos(cpos);
abstract class for propagating fluctuating charge variables
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.