-
Hi everyone, I would like to get the detailed information of the composition of a material, and here are my codes: The error encountered is as follows: Does anyone know the cause and the solution of this problem? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Dear Ni Yang, So in short, the assertion is triggered when you are asking an element (oxygen, which has more than one natural isotope) for it's A value (number of nucleons). Although in some contexts one can talk about A values of elements (i.e. number of nucleons averaged over the isotopes present in the element), the function you are calling is returning an integral value and is only meant to be used for actual isotopes, like O16, O18, etc. If you look at the documentation (the comments in the header file class NCRYSTAL_API AtomData : public UniqueID {
public:
//...
//Type (as boolean check or as enum):
enum class AtomDataType { NatElem, SingleIsotope, Composite };
AtomDataType getType() const;
bool isNaturalElement() const;
bool isSingleIsotope() const;
bool isComposite() const;
//A collection of atoms is considered an element, if all atoms share the same Z value:
bool isElement() const;
//Only call these after checking that isElement() is true:
std::string elementName() const;
unsigned Z() const;
//Only call after checking that isSingleIsotope() is true:
unsigned A() const;
//...
In other words, What you can do with these NCrystal::MatCfg matcfg("LiquidHeavyWaterD2O_T293.6K.ncmat" );
auto info = NCrystal::createInfo(matcfg);
const NCrystal::Info::Composition & comp = info->getComposition();
for(const NCrystal::Info::CompositionEntry &v : comp) {
double frac = v.fraction;
const auto& atom = v.atom.data();
std::cout << atom << ", fraction " << frac << std::endl;
} which produces the output:
I hope this clarifies the issue :-) Cheers, |
Beta Was this translation helpful? Give feedback.
Dear Ni Yang,
So in short, the assertion is triggered when you are asking an element (oxygen, which has more than one natural isotope) for it's A value (number of nucleons). Although in some contexts one can talk about A values of elements (i.e. number of nucleons averaged over the isotopes present in the element), the function you are calling is returning an integral value and is only meant to be used for actual isotopes, like O16, O18, etc.
If you look at the documentation (the comments in the header file
NCAtomData.hh
) for the method in question, you will see that this is indeed mentioned: