Skip to content

How to call the mean-squared displacement of atoms within NCrystal #83

Answered by tkittel
XuShuqi7 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @XuShuqi7 ,

As you can see on NCInfoTypes.hh the msd() method returns an Optional<double> rather than a raw double. The Optional class is our C++11 compatible version of std::optional which is defined in NCDefs.hh. This is a simple container class which may or may not contain an actual value. One can use the .has_value() method to check if there is a value (although in your case the check for hasAtomMSD() already did the .has_value() check internally. If there is a value, the .value() method can be used to access it.

Long story short, instead of:

double msd = 0;
if ( info.hasAtomMSD() )
  msd = info.getAtomInfos().front().msd(); //Wrong, won't compile!

you can write:

double msd = 0;
if

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@XuShuqi7
Comment options

Answer selected by XuShuqi7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants