easychem.easychem#
Attributes#
Classes#
This is a class that allows to compute the abundances of chemical species in an exoplanet atmosphere for a given |
Functions#
Returns the path to the default thermodynamic data file (which is in CEA format). |
Module Contents#
- easychem.easychem.HOME_PATH#
- easychem.easychem.MODULE_PATH#
- easychem.easychem.DEFAULT_DATAFILE = 'thermo_easy_chem_simp_own.inp'#
- easychem.easychem._find_thermofpath()#
Returns the path to the default thermodynamic data file (which is in CEA format).
- Returns string:
Absolute path to the default thermodynamic data file.
- class easychem.easychem.ExoAtmos(atoms=None, reactants=None, atomAbunds=None, thermofpath=None, metallicity=None, co=None, atmFunc=None, atmArgs=None)#
This is a class that allows to compute the abundances of chemical species in an exoplanet atmosphere for a given elemental composition, temperature and pressure.
- Constant attributes:
ATOM_STR_LEN = 2 Length of the strings for atom names REAC_STR_LEN = 15 Length of the strings for reactant names
Constructor method variables
- param atoms:
Names of the atoms present in the considered atmosphere.
- type atoms:
np.ndarray(str), optional
- param reactants:
Names of the reactants present in the considered atmosphere.
- type reactants:
np.ndarray(str), optional
- param atomAbunds:
Atom abundances in the considered atmosphere (default: stellar abundances).
- type atomAbunds:
np.ndarray(float) with same size as atoms, optional
- param thermofpath:
Path of the file containing all the thermodynamic data
- type thermofpath:
str, optional
- param metallicity:
Global metallicity of the considered atmosphere. If set, will update the atom abundances
accordingly. :type metallicity: float, optional
- param co:
The overall carbon-to-oxygen ratio in the considered atmosphere. If set, will update the oxygen
abundance accordingly. :type co: float, optional
- param atmFunc:
Custom function taking self._atoms and self._atomAbundsOrig as parameters to compute
updated atom abundances stored in self._atomAbunds. :type atmFunc: function taking at least two parameters (np.ndarray(str) and np.ndarray(float) with same size) and returning a np.ndarray(float) of the same size, optional
- param atmArgs:
Additional arguments to provide to atmFunc. If provided, atmFunc must also be provided.
- type atmArgs:
iterative, optional
- ATOM_STR_LEN = 2#
- REAC_STR_LEN = 15#
- _initialized = False#
- _solved = False#
- _valid = True#
- _atomAbunds#
- property atoms#
Type: array of strings. Lists of the atom building blocks considered for the calculation.
- updateAtoms(input)#
Method to set the atoms property to input (i.e., change the atoms to be considered in the calculation).
- Parameters:
input (iterative of strings (list or np.ndarray for example)) – strings representing the atoms considered in the calculation.
- property reactants#
Type: array of strings. Names of the reactants to be considered in the calculation.
- updateReactants(input)#
Method to set the reactants to be considered in the calculation.
- Parameters:
input (iterative of strings (list or np.ndarray for example)) – strings representing the reactants present in the atmosphere.
- property thermofpath#
Type: string. Path of the file containing all the thermodynamic data.
- updateThermofpath(string)#
Method to set the path to the thermodynamic input data file.
- Parameters:
string (string) – path to the new thermodynamic data file.
- property atomAbundsOrig#
Array of floats => elemental abundances of the considered atmosphere, set per default to the solar abundances reported in Aplund+2009; This is the base array used to generate atomAbunds by adjusting to metallicity, co and/or atmFunc
- updateAtomAbundsOrig(tab)#
Method to update the default atomic abundances (these will be normalized to sum to 1 after setting).
- Parameters:
tab (np.ndarray(float)) – array of floats, elemental abundances of the considered atoms (number fractions).
- property atomAbunds#
Array of floats => elemental abundances of the considered atmosphere ; array used in chemistry computation
- updateAtomAbunds(tab)#
Method to update the atomic abundances (these will be normalized to sum to 1 after setting) which define the building blocks from which molecules can be build during the chemistry calculation.
- Parameters:
tab (np.ndarray(float)) – array of floats, elemental abundances of the considered atoms (number fractions).
- property metallicity#
Float => atmosphere’s metallicity ; when set this automatically updates atomAbunds considering atomAbundsOrig as the stellar abundances (incompatible with atmFunc, if atmFunc is set, priority is given to atmFunc)
- updatemetallicity(value)#
Method to update the metallicity, which will automatically update the atomAbunds. Alternatively, the user can set the metallicity by setting eo.metallicity = value, where eo is an ExoAtmos object. This would also automatically update the atomAbunds.
- Parameters:
value – the desired metallicity.
- property co#
Float => C/O number ratio ; automatically updates atomAbunds (if atmFunc is set, atmFunc will be applied first)
Note that the C/O is changed by setting the oxygen abundance to carbon abundance/(C/O). This means that this operation will change the overall atmospheric metallicity, since only the oxygen abundance changes, while all other metal abundances remain the same (but note that all atom abundances, including H/He are normalized to sum to unity after any update step of the atom abundances). To exercise a finer control over the composition, the use of updateAtomAbunds() is recommended, which allows the user to set the abundances of all elements independently. In that case users may renormalize the metal abundances after changing the oxygen (or carbon) abundance for an updated C/O ratio. Options could include conserving the metal atom mass or number, in comparison to H/He.
- Parameters:
value – the desired C/O ratio. Just udpdate by setting eo.co = value, where eo is an ExoAtmos object.
- updateCo(value)#
Method to update the C/O ratio, which will automatically update the atomAbunds. Alternatively, the user can set the C/O ratio by setting eo.co = value, where eo is an ExoAtmos object. This would also automatically update the atomAbunds.
- Parameters:
value – the desired C/O ratio.
- property atmFunc#
Function provided by the user that takes in atomAbundsOrig to generate atomAbunds. The function should take at least two parameters: the first is a list of atom names (self._atoms), the second is the original atom abundances (self._atomAbundsOrig). If a third parameter is provided, it will be passed as the third argument to the function. The third optional parameter must an iterable (e.g., a list, a tuple, or a numpy array) if provided and can contain any parameters that the user wants to use to modify the atom abundances. If just a single value should be applied, make sure to package it as in iterable (e.g., a list or a tuple with just one element). These parameters can be updated by setting the atmArgs property.
- updateAtmFunc(func, args=None)#
Method to update the atmFunc function and apply it to atomAbundsOrig to update atomAbunds.
- Parameters:
func – new atmFunc function.
args – None or iterable => arguments to pass to atmFunc, if required.
- property atmArgs#
None or iterable => arguments to pass to self._atmFunc, containing any parameters that the user wants to use to modify the atom abundances. If just a single value should be applied, make sure to package it as in iterable (e.g., a list or a tuple with just one element). Changing atmArgs will automatically result in applying _atmFunc to the original atom abundances (self._atomAbundsOrig) with the new atmArgs.
- updateAtmArgs(args)#
Function to update the atmArgs, which contains the arguments to be passed to the atmFunc function. If atmFunc is set, this will automatically apply the atmFunc to the original atom abundances, using the new atmArgs.
- Parameters:
args – None or iterable => arguments to pass to atmFunc, if required.
- Returns:
- delAtmFunc()#
- property initialized#
Flag indicating if the Fortran side was initialized (e.g., reading the thermodynamic data for the requested reactants).
- property solved#
Flag indicating if the system with the current given parameters is already solved, i.e., if the object already contains the chemical abundances.
- property valid#
Flag indicating if the last run was successful, i.e., no error occurred in Fortran.
- property reacMols#
result => reactants’ number fractions after the chemistry calculation.
- property reacMass#
result => reactants’ mass fractions after the chemistry calculation.
- property adiabaticGrad#
result => adiabatic gradient, i.e., dlogT/dlogP assuming adiabatic conditions.
- property gamma2#
result => gamma2, i.e., the adiabatic exponent for which it holds that dlogP/dlogT = (gamma2-1) / gamma2.
- property mmw#
result => mean molecular weight, i.e., the mean mass of a molecule in the atmosphere in the reactant gas mixture.
- property density#
result => mean density of the reactant gas mixture.
- property c_pe#
result => specific heat capacity at constant pressure of the reactant mixture. the e in c_pe stands for “equilibrium”, denoting that it assumes that the chemical equilibrium is reached instantaneously when the temperature and pressure are changed adiabatically (it thus contains contributions from considering the current chemical abundances and how these would change under adiabatic changes of temperature and pressure).
- solve(pressure, temperature)#
Method to compute the chemical abundances.
- Parameters:
pressure (float, or np.ndarray of floats) – pressure in the atmosphere. Can be a single value or an array of values.
temperature (float, or np.ndarray of floats) – temperature in the atmosphere (in K). Can be a single value or an array of values.
- result_mol()#
Returns the reactants’ number fractions after the chemistry calculation as a dictionary. The keys are the reactant names and the values are the corresponding number fractions.
- Returns:
dictionary with reactant names as keys and their number fractions as values.
- result_mass()#
Returns the reactants’ mass fractions after the chemistry calculation as a dictionary. The keys are the reactant names and the values are the corresponding mass fractions.
- Returns:
dictionary with reactant names as keys and their mass fractions as values.
- _updatemetallicity()#
- _updateCO()#
- _updadeWithFunc()#
- _normAbunds()#
- _updateAtomAbunds()#
- _getterResults(attName, fullName)#
- print_available_species()#
- static strToBytes(a: str)#
- static strArr_to_bytArr(a, m)#
- static check_co_value_is_valid(co)#
Check if the provided C/O value is valid.
- Parameters:
co (float, int or np.ndarray) – The C/O value to check.
- Raises:
ValueError – If the C/O value is below 0.
- static check_temperature_values_are_valid(temperature)#
Check if the provided temperature value is valid.
- Parameters:
temperature (float, int or np.ndarray) – The temperature value to check.
- Raises:
ValueError – If the temperature value is below 0. K
- static check_pressure_values_are_valid(pressure)#
Check if the provided pressure value is valid.
- Parameters:
pressure (float, int or np.ndarray) – The pressure value to check.
- Raises:
ValueError – If the pressure is below 0.
- static check_atom_abundances_values_are_valid(atom_abunds)#
Check if the provided atom abundances are valid.
- Parameters:
atom_abunds (np.ndarray) – The atom abundances to check.
- Raises:
ValueError – If the atom abundances are below 0.
- static check_if_input_values_are_valid(values, lower_bound=0.0, upper_bound=None)#
Check if the provided values are valid.
- Parameters:
values (float, int or np.ndarray) – The values to check.
lower_bound (float, optional) – The lower bound for the values (default is 0).
upper_bound (float, optional) – The upper bound for the values (default is None, meaning no upper bound).
- Returns bool:
True if all values are within the bounds, False otherwise.