-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Phantom atoms #1953
feat: Phantom atoms #1953
Conversation
314fdbe
to
36b734a
Compare
…ndices for NeutronSQ.
36b734a
to
e76602a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some stylic suggestions, but all are optional
dissolve::for_each_pair(ParallelPolicies::seq, speciesAtomTypes.begin(), speciesAtomTypes.end(), | ||
[&](int spTypeI, const AtomTypeData &atd1, int spTypeJ, const AtomTypeData &atd2) | ||
{ | ||
// First, check that both of atom types used in the species are present in the weights | ||
// atomTypes_. They may legitimately not be if, for example, they are phantom atoms. | ||
auto optPairIndex = atomTypes_.indexOf(atd1.atomType(), atd2.atomType()); | ||
if (!optPairIndex) | ||
return; | ||
auto &[typeI, typeJ] = *optPairIndex; | ||
|
||
auto &localI = atomTypes_[typeI]; | ||
auto &localJ = atomTypes_[typeJ]; | ||
|
||
// If an AtomType is exchangeable, add the averaged scattering length from the local | ||
// AtomTypesList instead of its actual isotopic length. | ||
bi = localI.exchangeable() | ||
? bi = localI.boundCoherent() | ||
: Sears91::boundCoherent(tope->atomTypeIsotope(atd1.atomType())); | ||
bj = localJ.exchangeable() | ||
? localJ.boundCoherent() | ||
: Sears91::boundCoherent(tope->atomTypeIsotope(atd2.atomType())); | ||
|
||
// Convert from fm to barns | ||
bi *= 0.1; | ||
bj *= 0.1; | ||
|
||
intramolecularWeights_[{typeI, typeJ}] += weight * bi * bj; | ||
intraNorm[{typeI, typeJ}] += weight; | ||
globalFlag[{typeI, typeJ}] = true; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a way to do all of this in parallel with the PairIterator and std::transform_reduce, but it's probably not worth the trouble unless this is a serious bottleneck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be as it's called once per module per iteration, so I'm inclined to leave it as-is.
Phantom = -1, | ||
Physical, | ||
Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A possible suggestion here would be to assign Any
the value of zero. The could change a bunch of conditionals from
if (presence == SpeciesAtom::Presence::Any)
to merely being
if (presence)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity (and my own sanity when I look back at this in six months and don't understand what I've written) I think we should keep the explicit comparison and enum as they are.
Co-authored-by: Adam Washington <adam.washington@stfc.ac.uk>
This PR completes #1900 although the final product is to introduce "phantom" rather than "artificial" atoms.
Briefy, a phantom atom is a normal
SpeciesAtom
and is part of aSpecies
, connected to otherSpeciesAtom
s, and is evolved by MC / MD in the standard way. However, it makes no contribution to correlation functions or weights as calculated by the various correlation modules. Thus, they can affect the behaviour of a species / system but are invisible to structural probes.Closes #1900.
Follow-on issue #1952 captures further work.