47#include "brains/ForceModifier.hpp"
48#include "nonbonded/NonBondedInteraction.hpp"
50#include "types/FixedChargeAdapter.hpp"
51#include "types/MultipoleAdapter.hpp"
52#include "utils/Constants.hpp"
56 MagneticField::MagneticField(SimInfo* info) :
57 ForceModifier {info}, initialized {false}, doMagneticField {false} {
58 simParams = info_->getSimParams();
61 void MagneticField::initialize() {
62 std::vector<RealType> mf;
64 if (simParams->haveMagneticField()) {
65 doMagneticField =
true;
66 mf = simParams->getMagneticField();
69 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
70 "MagneticField: Incorrect number of parameters specified.\n"
71 "\tthere should be 3 parameters, but %lu were specified.\n",
83 void MagneticField::modifyForces() {
84 if (!initialized) initialize();
86 SimInfo::MoleculeIterator i;
87 Molecule::AtomIterator j;
104 if (doMagneticField) {
105 for (mol = info_->beginMolecule(i); mol != NULL;
106 mol = info_->nextMolecule(i)) {
107 for (atom = mol->beginAtom(j); atom != NULL; atom = mol->nextAtom(j)) {
111 atype = atom->getAtomType();
115 FixedChargeAdapter fca = FixedChargeAdapter(atype);
116 if (fca.isFixedCharge()) {
121 C *= Constants::chargeFieldConvert;
124 f =
cross(v, MF) * C * Constants::magneticFieldConvert;
128 MultipoleAdapter ma = MultipoleAdapter(atype);
130 D = atom->getDipole() * Constants::dipoleFieldConvert;
135 AngMomentum = atom->getJ();
137 if (atom->isLinear()) {
138 l = atom->linearAxis();
142 omega[m] = AngMomentum[m] / I(m, m);
143 omega[n] = AngMomentum[n] / I(n, n);
145 omega = I.inverse() * AngMomentum;
Uniform Magnetic Field perturbation.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Vector3< Real > cross(const Vector3< Real > &v1, const Vector3< Real > &v2)
Returns the cross product of two Vectors.