Skip to content
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

Merged
merged 15 commits into from
Oct 15, 2024
Merged

feat: Phantom atoms #1953

merged 15 commits into from
Oct 15, 2024

Conversation

trisyoungs
Copy link
Member

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 a Species, connected to other SpeciesAtoms, 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.

@trisyoungs trisyoungs mentioned this pull request Jun 27, 2024
1 task
@trisyoungs trisyoungs added this to the Release 1.6 milestone Jul 27, 2024
@trisyoungs trisyoungs marked this pull request as ready for review October 14, 2024 10:12
Copy link
Contributor

@rprospero rprospero left a 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

src/classes/atomTypeMix.cpp Outdated Show resolved Hide resolved
src/classes/atomTypeMix.cpp Outdated Show resolved Hide resolved
src/classes/configuration_contents.cpp Outdated Show resolved Hide resolved
Comment on lines +169 to +198
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;
});
Copy link
Contributor

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.

Copy link
Member Author

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.

src/classes/neutronWeights.cpp Outdated Show resolved Hide resolved
Comment on lines +45 to +47
Phantom = -1,
Physical,
Any
Copy link
Contributor

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)

Copy link
Member Author

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.

src/classes/species_atomic.cpp Show resolved Hide resolved
trisyoungs and others added 2 commits October 14, 2024 15:55
Co-authored-by: Adam Washington <adam.washington@stfc.ac.uk>
@trisyoungs trisyoungs merged commit 2c07de1 into develop Oct 15, 2024
10 checks passed
@trisyoungs trisyoungs deleted the phantom-atoms branch October 15, 2024 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Artificial Atoms
2 participants