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

Functionality for setting nuclei targets abundances in mol (volume) and as chemical compound #11

Merged
merged 7 commits into from
Nov 30, 2023

Conversation

AlvaroEzq
Copy link
Contributor

@AlvaroEzq AlvaroEzq commented Nov 7, 2023

AlvaroEzq Large: 272 Powered by Pull Request Badge

Adding other ways to define the target material. Now it is possible to define (chemical) compounds. Also, the abundances can be given in mol (or volume) using the parameter abundanceInMol instead of abundance. Examples for an Ar+Isobutane mixture at 99% in volume can be found inside the files 'REST_PATH/source/libraries/wimp/examples/WIMP_compound_1.rml' and 'REST_PATH/source/libraries/wimp/examples/WIMP_compound_2.rml'.

So now, there are three ways of setting the abundance with rml files:

  1. Old way, by only setting 'abundance' for each nucleus. The behaviour of the code in this case doesn't change respect to before this PR. The abundance is directly put into (no normalization) and fAbundanceInMol is just fAbundance/fAnum
  2. New way, by setting abundanceInMol for each nucleus or compound. In this case, the fAbundance will be the relative amount of mass of each nucleus (normalized to 1).
  3. Other ways where some elements (or compounds) abundances are given with abundance and others with abundanceInMol are not recommended, although they can be handled. In this cases, abundance is then understood as the absolute mass (in grams) and the abundanceInMol as the absolute number of moles of their corresponding element or compound. Finally, fAbundance is normalized, so the fAbundance of each nucleus is the relative amount of mass of that nucleus.

The new addCompound structure

Compounds are meant to be written in the following way

<addCompound compoundName="C4H10" abundanceInMol="0.01">
            <addElement nucleusName="C" anum="12.0107" znum="6" />
            <addElement nucleusName="H" anum="1.00784" znum="1" />
</addCompound>

Where compoundName is the chemical formula and abundance or abundanceInMol the corresponding abundance of the whole compound. Inside the addCompound structure, there must be defined each element of the chemical formula, where the nucleusName must match with the one of the chemical formula and their anum and znum must be provided (even if there have been previously given in other compounds or standalone elements).

There is no problem on adding the same nucleus within different addElement or addCompound. If there are several TRestWimpNucleus with the same fNucleusName, fAnum and fZnum, they will be merged by summing their fAbundance and fAbundanceInMol.

The new abundanceInMol parameter

To add the possibility of descrbing the gas mixture in volume terms, the abundanceInMol parameter should be use. For this, the new member fAbundanceInMol of TRestWimpNucleus is proposed. The purpose of this member is double:

  1. To store this parameter abundanceInMol given in the rml file (so the sensitivity calculated can be reproduced by inspecting the TRestWimpSensitivity metadata)
  2. To serve as bridge between abundances given with abundance and abundanceInMol.

It is important to notice that for all calculations, fAbundance remains the member to be used in the sensitivity (and recoil spectra) functions.

Although fAbundance meaning is the relative amount of mass of the corresponding nucleus in the mixture, it is useful to do not normalize it, so it can be used as absolute mass (in kg) of that nucleus inside the function GetRecoilSpectra() to generate the independent spectrum of several nuclei ( idem, in units of c/keV/day/kg where kg is kg of each nucleus and not of the mixture of all the nuclei). To mantain this option available, fAbundance is not normalize if ALL the abundances in the rml file are set through the abundance paremeter. If any element or compound has abundanceInMol, then anyGivenAbundanceInMol=true inside TRestWimpSensitivity::ReadNuclei() and fAbundance will be normalized.

@AlvaroEzq AlvaroEzq marked this pull request as draft November 7, 2023 13:12
@AlvaroEzq AlvaroEzq marked this pull request as ready for review November 8, 2023 10:08
@AlvaroEzq AlvaroEzq requested a review from juanangp November 21, 2023 09:19
Comment on lines -48 to +55
TRestWimpNucleus::TRestWimpNucleus() {}
TRestWimpNucleus::TRestWimpNucleus() {
fNucleusName = "";
fAnum = 0;
fZnum = 0;
fAbundance = 0;
fAbundanceMol = 0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general is a better practise to initialize these variables in the header.

@@ -161,23 +169,123 @@ void TRestWimpSensitivity::InitFromConfigFile() {
///
void TRestWimpSensitivity::ReadNuclei() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be better to move this function inside TRestWimpNucleus.

@AlvaroEzq AlvaroEzq merged commit 8dc47c0 into master Nov 30, 2023
63 checks passed
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.

2 participants