47 |
|
#include "nonbonded/Electrostatic.hpp" |
48 |
|
#include "utils/simError.h" |
49 |
|
#include "types/NonBondedInteractionType.hpp" |
50 |
< |
#include "types/DirectionalAtomType.hpp" |
50 |
> |
#include "types/FixedChargeAdapter.hpp" |
51 |
> |
#include "types/MultipoleAdapter.hpp" |
52 |
|
#include "io/Globals.hpp" |
53 |
+ |
#include "nonbonded/SlaterIntegrals.hpp" |
54 |
+ |
#include "utils/PhysicalConstants.hpp" |
55 |
+ |
|
56 |
|
|
57 |
|
namespace OpenMD { |
58 |
|
|
284 |
|
electrostaticAtomData.is_SplitDipole = false; |
285 |
|
electrostaticAtomData.is_Quadrupole = false; |
286 |
|
|
287 |
< |
if (atomType->isCharge()) { |
284 |
< |
GenericData* data = atomType->getPropertyByName("Charge"); |
287 |
> |
FixedChargeAdapter fca = FixedChargeAdapter(atomType); |
288 |
|
|
289 |
< |
if (data == NULL) { |
287 |
< |
sprintf( painCave.errMsg, "Electrostatic::addType could not find " |
288 |
< |
"Charge\n" |
289 |
< |
"\tparameters for atomType %s.\n", |
290 |
< |
atomType->getName().c_str()); |
291 |
< |
painCave.severity = OPENMD_ERROR; |
292 |
< |
painCave.isFatal = 1; |
293 |
< |
simError(); |
294 |
< |
} |
295 |
< |
|
296 |
< |
DoubleGenericData* doubleData = dynamic_cast<DoubleGenericData*>(data); |
297 |
< |
if (doubleData == NULL) { |
298 |
< |
sprintf( painCave.errMsg, |
299 |
< |
"Electrostatic::addType could not convert GenericData to " |
300 |
< |
"Charge for\n" |
301 |
< |
"\tatom type %s\n", atomType->getName().c_str()); |
302 |
< |
painCave.severity = OPENMD_ERROR; |
303 |
< |
painCave.isFatal = 1; |
304 |
< |
simError(); |
305 |
< |
} |
289 |
> |
if (fca.isFixedCharge()) { |
290 |
|
electrostaticAtomData.is_Charge = true; |
291 |
< |
electrostaticAtomData.charge = doubleData->getData(); |
291 |
> |
electrostaticAtomData.charge = fca.getCharge(); |
292 |
|
} |
293 |
|
|
294 |
< |
if (atomType->isDirectional()) { |
295 |
< |
DirectionalAtomType* daType = dynamic_cast<DirectionalAtomType*>(atomType); |
296 |
< |
|
313 |
< |
if (daType->isDipole()) { |
314 |
< |
GenericData* data = daType->getPropertyByName("Dipole"); |
315 |
< |
|
316 |
< |
if (data == NULL) { |
317 |
< |
sprintf( painCave.errMsg, |
318 |
< |
"Electrostatic::addType could not find Dipole\n" |
319 |
< |
"\tparameters for atomType %s.\n", |
320 |
< |
daType->getName().c_str()); |
321 |
< |
painCave.severity = OPENMD_ERROR; |
322 |
< |
painCave.isFatal = 1; |
323 |
< |
simError(); |
324 |
< |
} |
325 |
< |
|
326 |
< |
DoubleGenericData* doubleData = dynamic_cast<DoubleGenericData*>(data); |
327 |
< |
if (doubleData == NULL) { |
328 |
< |
sprintf( painCave.errMsg, |
329 |
< |
"Electrostatic::addType could not convert GenericData to " |
330 |
< |
"Dipole Moment\n" |
331 |
< |
"\tfor atom type %s\n", daType->getName().c_str()); |
332 |
< |
painCave.severity = OPENMD_ERROR; |
333 |
< |
painCave.isFatal = 1; |
334 |
< |
simError(); |
335 |
< |
} |
294 |
> |
MultipoleAdapter ma = MultipoleAdapter(atomType); |
295 |
> |
if (ma.isMultipole()) { |
296 |
> |
if (ma.isDipole()) { |
297 |
|
electrostaticAtomData.is_Dipole = true; |
298 |
< |
electrostaticAtomData.dipole_moment = doubleData->getData(); |
298 |
> |
electrostaticAtomData.dipole_moment = ma.getDipoleMoment(); |
299 |
|
} |
300 |
< |
|
340 |
< |
if (daType->isSplitDipole()) { |
341 |
< |
GenericData* data = daType->getPropertyByName("SplitDipoleDistance"); |
342 |
< |
|
343 |
< |
if (data == NULL) { |
344 |
< |
sprintf(painCave.errMsg, |
345 |
< |
"Electrostatic::addType could not find SplitDipoleDistance\n" |
346 |
< |
"\tparameter for atomType %s.\n", |
347 |
< |
daType->getName().c_str()); |
348 |
< |
painCave.severity = OPENMD_ERROR; |
349 |
< |
painCave.isFatal = 1; |
350 |
< |
simError(); |
351 |
< |
} |
352 |
< |
|
353 |
< |
DoubleGenericData* doubleData = dynamic_cast<DoubleGenericData*>(data); |
354 |
< |
if (doubleData == NULL) { |
355 |
< |
sprintf( painCave.errMsg, |
356 |
< |
"Electrostatic::addType could not convert GenericData to " |
357 |
< |
"SplitDipoleDistance for\n" |
358 |
< |
"\tatom type %s\n", daType->getName().c_str()); |
359 |
< |
painCave.severity = OPENMD_ERROR; |
360 |
< |
painCave.isFatal = 1; |
361 |
< |
simError(); |
362 |
< |
} |
300 |
> |
if (ma.isSplitDipole()) { |
301 |
|
electrostaticAtomData.is_SplitDipole = true; |
302 |
< |
electrostaticAtomData.split_dipole_distance = doubleData->getData(); |
302 |
> |
electrostaticAtomData.split_dipole_distance = ma.getSplitDipoleDistance(); |
303 |
|
} |
304 |
< |
|
367 |
< |
if (daType->isQuadrupole()) { |
368 |
< |
GenericData* data = daType->getPropertyByName("QuadrupoleMoments"); |
369 |
< |
|
370 |
< |
if (data == NULL) { |
371 |
< |
sprintf( painCave.errMsg, |
372 |
< |
"Electrostatic::addType could not find QuadrupoleMoments\n" |
373 |
< |
"\tparameter for atomType %s.\n", |
374 |
< |
daType->getName().c_str()); |
375 |
< |
painCave.severity = OPENMD_ERROR; |
376 |
< |
painCave.isFatal = 1; |
377 |
< |
simError(); |
378 |
< |
} |
379 |
< |
|
304 |
> |
if (ma.isQuadrupole()) { |
305 |
|
// Quadrupoles in OpenMD are set as the diagonal elements |
306 |
|
// of the diagonalized traceless quadrupole moment tensor. |
307 |
|
// The column vectors of the unitary matrix that diagonalizes |
308 |
|
// the quadrupole moment tensor become the eFrame (or the |
309 |
|
// electrostatic version of the body-fixed frame. |
385 |
– |
|
386 |
– |
Vector3dGenericData* v3dData = dynamic_cast<Vector3dGenericData*>(data); |
387 |
– |
if (v3dData == NULL) { |
388 |
– |
sprintf( painCave.errMsg, |
389 |
– |
"Electrostatic::addType could not convert GenericData to " |
390 |
– |
"Quadrupole Moments for\n" |
391 |
– |
"\tatom type %s\n", daType->getName().c_str()); |
392 |
– |
painCave.severity = OPENMD_ERROR; |
393 |
– |
painCave.isFatal = 1; |
394 |
– |
simError(); |
395 |
– |
} |
310 |
|
electrostaticAtomData.is_Quadrupole = true; |
311 |
< |
electrostaticAtomData.quadrupole_moments = v3dData->getData(); |
311 |
> |
electrostaticAtomData.quadrupole_moments = ma.getQuadrupoleMoments(); |
312 |
|
} |
313 |
|
} |
314 |
|
|
315 |
< |
AtomTypeProperties atp = atomType->getATP(); |
315 |
> |
FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atomType); |
316 |
|
|
317 |
+ |
if (fqa.isFluctuatingCharge()) { |
318 |
+ |
electrostaticAtomData.is_FluctuatingCharge = true; |
319 |
+ |
electrostaticAtomData.electronegativity = fca.getElectronegativity(); |
320 |
+ |
electrostaticAtomData.hardness = fca.getHardness(); |
321 |
+ |
electrostaticAtomData.slaterN = fca.getSlaterN(); |
322 |
+ |
electrostaticAtomData.slaterZeta = fca.getSlaterZeta(); |
323 |
+ |
} |
324 |
+ |
|
325 |
|
pair<map<int,AtomType*>::iterator,bool> ret; |
326 |
< |
ret = ElectrostaticList.insert( pair<int,AtomType*>(atp.ident, atomType) ); |
326 |
> |
ret = ElectrostaticList.insert( pair<int,AtomType*>(atomType->getIdent(), |
327 |
> |
atomType) ); |
328 |
|
if (ret.second == false) { |
329 |
|
sprintf( painCave.errMsg, |
330 |
|
"Electrostatic already had a previous entry with ident %d\n", |
331 |
< |
atp.ident); |
331 |
> |
atomType->getIdent() ); |
332 |
|
painCave.severity = OPENMD_INFO; |
333 |
|
painCave.isFatal = 0; |
334 |
|
simError(); |
335 |
|
} |
336 |
|
|
337 |
< |
ElectrostaticMap[atomType] = electrostaticAtomData; |
337 |
> |
ElectrostaticMap[atomType] = electrostaticAtomData; |
338 |
> |
|
339 |
> |
// Now, iterate over all known types and add to the mixing map: |
340 |
> |
|
341 |
> |
map<AtomType*, ElectrostaticAtomData>::iterator it; |
342 |
> |
for( it = ElectrostaticMap.begin(); it != ElectrostaticMap.end(); ++it) { |
343 |
> |
AtomType* atype2 = (*it).first; |
344 |
> |
|
345 |
> |
if ((*it).is_FluctuatingCharge && electrostaticAtomData.is_FluctuatingCharge) { |
346 |
> |
|
347 |
> |
RealType a = electrostaticAtomData.slaterZeta; |
348 |
> |
RealType b = (*it).slaterZeta; |
349 |
> |
int m = electrostaticAtomData.slaterN; |
350 |
> |
int n = (*it).slaterN; |
351 |
> |
|
352 |
> |
// Create the spline of the coulombic integral for s-type |
353 |
> |
// Slater orbitals. Add a 2 angstrom safety window to deal |
354 |
> |
// with cutoffGroups that have charged atoms longer than the |
355 |
> |
// cutoffRadius away from each other. |
356 |
> |
|
357 |
> |
RealType dr = (cutoffRadius_ + 2.0) / RealType(np_ - 1); |
358 |
> |
vector<RealType> rvals; |
359 |
> |
vector<RealType> J1vals; |
360 |
> |
vector<RealType> J2vals; |
361 |
> |
for (int i = 0; i < np_; i++) { |
362 |
> |
rval = RealType(i) * dr; |
363 |
> |
rvals.push_back(rval); |
364 |
> |
J1vals.push_back( sSTOCoulInt( a, b, m, n, rval * PhysicalConstants::angstromsToBohr ) ); |
365 |
> |
J2vals.push_back( sSTOCoulInt( b, a, n, m, rval * PhysicalConstants::angstromsToBohr ) ); |
366 |
> |
} |
367 |
> |
|
368 |
> |
CubicSpline J1 = new CubicSpline(); |
369 |
> |
J1->addPoints(rvals, J1vals); |
370 |
> |
CubicSpline J2 = new CubicSpline(); |
371 |
> |
J2->addPoints(rvals, J2vals); |
372 |
> |
|
373 |
> |
pair<AtomType*, AtomType*> key1, key2; |
374 |
> |
key1 = make_pair(atomType, atype2); |
375 |
> |
key2 = make_pair(atype2, atomType); |
376 |
> |
|
377 |
> |
Jij[key1] = J1; |
378 |
> |
Jij[key2] = J2; |
379 |
> |
} |
380 |
> |
} |
381 |
> |
|
382 |
|
return; |
383 |
|
} |
384 |
|
|