Calculates atomic concentrations from chemical formula or material description.
This code uses a NIST table of Atomic Weights and Isotopic Compositions of naturally occurring isotopes to create material descriptions for later use in MonteCarlo codes.
material_Id $ material_name; density=value
isotope_code_1 atomic_concentration_1
isotope_code_2 atomic_concentration_2
...
Where:
- Part after the
$symbol is a Fortran comment isotope_codeconsists of the atomic number and mass number (e.g. 1H -> 1001, 16O -> 8016)atomic_concentrationis in units of 1 x 1024 atoms/cc
Elements or compounds (e.g. O2, Pb, C10H8O4)
Input:
Chemical composition(e.g. 'H2O', 'C2H4 B0.2'):
---> "H2O"
Density (g / cc): "0.998"
ChemicalCompound name(leave blank to use chemical formula):Output:
m1 $ H2O; 0.998 g/cc
1001 6.669056E-02
1002 7.670297E-06
8016 3.326808E-02
8017 1.267266E-05
8018 6.836569E-05E.g. steel grades, concrete mixes.
Input:
Chemical composition(e.g. 'H2O', 'C2H4 B0.2'):
---> "Fe0.988 C0.001 Mn0.0045 Si0.0025 S0.0002 P0.0002"
Density (g / cc): "7.87"
ChemicalCompound name(leave blank to use chemical formula): "Steel 10 (AISI 1010)"Output:
m1 $ Steel 10 (AISI 1010); 7.87 g/cc
6012 3.902425E-04
6013 4.220756E-06
14028 3.889341E-04
14029 1.975816E-05
14030 1.303996E-05
15031 3.059196E-05
25055 3.880704E-04
16032 2.806816E-05
16033 2.216141E-07
16034 1.255813E-06
16036 2.954855E-09
26054 4.899236E-03
26056 7.690753E-02
26057 1.776130E-03
26058 2.363703E-04Chemical compounds with additives/impurities (e.g. 'H2O Mg0.002')
Input:
Chemical composition(e.g. 'H2O', 'C2H4 B0.2'):
---> "C2H4 B0.2"
Density (g / cc): "0.99"
ChemicalCompound name(leave blank to use chemical formula): "Borated polyethylene 20%"Output:
m1 $ Borated polyethylene 20%; 0.99 g/cc
1001 8.496907E-02
1002 9.772567E-06
5010 2.193555E-03
5011 8.829333E-03
6012 4.203479E-02
6013 4.546368E-04A class to calculate atomic concentrations of isotopes in a material based on its chemical composition and density.
AVOGADRO(float): Avogadro's number in units of 1/(mol * g/cc).data(pd.DataFrame): DataFrame containing isotopic data from the NIST table.formula(str): Chemical formula of the material.density(float): Density of the material in g/cc.material_name(str): Name of the material, either user-provided or derived from the formula.
Initializes the ConcentrationConvertor by loading isotopic data, prompting the user for input, and performing the
initial calculation.
AVOGADRO(float): Avogadro's number in units of 1/(mol * g/cc).data(pd.DataFrame): DataFrame containing isotopic data from the NIST table.formula(str): Chemical formula of the material.density(float): Density of the material in g/cc.material_name(str): Name of the material, either user-provided or derived from the formula.
Parses a material definition into its constituent elements and their quantities.
formula(str): The chemical formula as a string (e.g., 'H2O', 'C2H4 B0.2').
list[dict[str, float]]: A list of dictionaries where each dictionary represents a component of the material, consisting of separate chemical elements and their quantities.
- Input:
'C2H4 B0.2' - Output:
[{'C': 2.0, 'H': 4.0}, {'B': 0.2}]
Generates a unique isotope code based on the atomic number and mass number.
atomic_number(int): The atomic number of the element.mass_number(int): The mass number of the isotope.
str: A string representing the isotope code, formatted as a concatenation of the atomic number and the mass number.
- Input:
atomic_number=1, mass_number=2 - Output:
'1002'
Calculates the atomic concentrations of isotopes in a material based on its element composition and density.
formula(str): The formula of the material (e.g., 'Al2O3', 'C2H4 B0.2').density(float): The density of the material in g/cc.threshold(float): Minimum concentration threshold for isotopes to be included in the output.
None: The results are printed to the console.
- First line: ChemicalCompound name and density.
- Subsequent lines: Isotope codes and their atomic concentrations in decimal notation.
- Input:
formula='H2O', density=1.0 - Output:
m1 $ H2O; 1.0 g/cc 1001 6.674E-02 1002 3.326E-02 - Input:
formula="Fe0.988 C0.001 Mn0.0045 Si0.0025 S0.0002 P0.0002", density=7.87 - Output:
m1 $ Steel 10; 7.87 g/cc 6012 3.902425E-04 6013 4.220756E-06 14028 3.889341E-04 14029 1.975816E-05 ...
Loads isotopic composition data from a CSV file into a pandas DataFrame.
file_path(str): The path to the CSV file containing isotopic data.
pd.DataFrame: A DataFrame containing the isotopic composition data.
FileNotFoundError: If the specified file does not exist.pd.errors.EmptyDataError: If the file is empty.pd.errors.ParserError: If the file cannot be parsed as a CSV.
- Input:
file_path='data/isotopes.csv' - Output: A DataFrame with columns such as 'Element', 'AtomicNumber', 'MassNumber', etc.