pysep.newpoly package

Submodules

pysep.newpoly.generateNML module

Author: Thomas M. Boudreaux

Created: April 2021

Last Modified: April 2021

Generate namelist files for the newpoly file from chemical composition files.

pysep.newpoly.generateNML.format_elem(massFracs: dict) Tuple[list, list]

Convert elemental mass fractions to isotope mass fractions for He3, C12, C13, N14, N15, O16, O17, O18, D, and if Litium and Berillium are provided also Li6, Li7, Be9.

Parameters

massFracs (dict of floats) – Dictionary of Hydrogen, metal, Carbon, Nitrogen, and Oxygen mass fractions. Indexed as ‘X’, ‘Z’, ‘C’, ‘N’, and ‘O’ respectivly.

Returns

  • elemSorted (list of floats) – Sorted list of floats of isotopal mass fractions for He3, C12, C13, N14, N15, O16, O17, and O18.

  • extenElemSorted (list of floats) – Sorted list of floats of isotopal mass fractions for D and if Lithium is provided Li6 and Li7 and if Berillium is provided Be9.

Notes

This exists so that this module may be used with versions of python where dictionaries are non ordered.

pysep.newpoly.generateNML.format_percents(massFracs: dict) Tuple[dict, dict]

Format the percenteges of the different isotope of He, C, N, and O for the pre main sequence model.

Parameters

massFracs (dict of floats) – Dictionary of Hydrogen, metal, Carbon, Nitrogen, and Oxygen mass fractions. Indexed as ‘X’, ‘Z’, ‘C’, ‘N’, and ‘O’ respectivly.

Returns

  • isoPercents (dict of tuples) – Dictionary of tuples with one entry for each isotope (He3, C12, C13, N14, N15, O16, O17, O18). Each tuple is formated as (index, elemental mass fraction, isotope abundance). The index is the proper sort order of the isotopes.

  • isoExtendedPercents (dict of tuples) – Dictionary of tuples for the extended isotopes newpoly.f supports. This will always include deuterium. If a lithium mass fraction is provided it will also include Li6 and Li7. If a Berillium mass fraction is provided it will also include Be9. Each tuple is formated as (index, elememental mass fraction, isotope abundance).

Notes

These relative isotope percentages are taken from Table 3 of 1

1

Asplund, M.; Grevesse, N.; Sauval, A.J.; Scott, P. The chemical composition of the Sun. Ann. Rev. Astron. Astrophys.2009, 47, 481–522.

pysep.newpoly.generateNML.generate_nml(nmlArgs: dict, elem: list, extenElem: list, teff: float, lum: float, output: str) dict

Generate the namelist file needed for the newpoly.f program

Parameters
  • nmlArgs (dict) –

    Dictionary of floats to fill in in the DATA card in the namelist file for newpoly.f. This must include the keys:

    • sumass (float)

      Total mass of the model

    • X (float)

      Hydrogen mass fraction

    • Z (float)

      Metal mass fraction

    • CMIXL (float)

      Mixing length

    • BETA (float)

      Beta parameter

    • FMASS1 (float)

      Fmass 1 parameter

    • FMASS2 (float)

      Fmass 2 parameter

    • DDAGE (float)

      Model Age

    • PN (float)

      Polytropic index

    • LEXCOM (bool)

      Logical flag to use EXCOM, inverted

  • elem (list of floats) – List of isotope mass fractions in the order of He3, C12, C13, N14, N15, O16, O17.

  • extenElem (list of floats) – List of isotope mass fractions in the order of D, Li6, Li7, Be9. Li and Be may not be included. These are the extended newpoly isotope mass fractions and are not currenly used at all.

  • teff (float) – Effective temperature of the pre main sequence model.

  • lum (float) – Luminosity of the pre main sequence model.

  • output (str) – Path to save namelist file to.

Returns

polynml – Dictionary representation of the namelist file. There is one outter key, called ‘DATA’. Within ‘DATA’ there are the keys

  • SUMASS (float)

    Total mass of the model

  • TEFFL1 (float)

    Effective temperature of the model

  • X (float)

    Hydrogen mass fraction

  • Z (float)

    Metal mass fraction

  • ELEM (list)

    List of isotopal mass fractions in the order given above.

  • CMIXL (float)

    Mixing length

  • BETA (float)

    Beta parameter

  • FMASS1 (float)

    Fmass 1 parameter

  • FMASS2 (float)

    Fmass 2 parameter

  • DDAGE (float)

    Model age

  • PN (float)

    Polytropic index

  • LEXCOM (bool)

    Logical flag to use EXCOM, inverted

Return type

dict

pysep.newpoly.popFileToPolyModel module

pysep.newpoly.popFileToPolyModel.generate_prems_models(pfc, massArray: list, outputPath, CMIXL=1.9126, BETA=1.0, FMASS1=9.9e-06, FMASS2=0.9999, DDAGE=10000, PN=1.5, LEXCOM=False, compName='comp', fnameT=None)

For a given chemical composition model and an array of masses generate a pre main sequence model for each of those masses.

Parameters
  • pfc (dict) –

    Dictionary of mass fractions which has the following keys. Note that a / denotes two keys, so for example AbundanceRatio/X means pfc[“AbundanceRatio”][“X”].

    • AbundanceRatio/X (float)

      Hydrogen mass fraction

    • AbundanceRatio/Z (float)

      Metal mass fraction

    • RelativeAbundance/C/m_f (float)

      Carbon mass fraction

    • RelativeAbundance/N/m_f (float)

      Nitrogen Mass Fraction

    • RelativeAbundance/O/m_f (float)

      Oxygen Mass Fraction

    • RelativeAbundance/Li/m_f (float)

      Lithium Mass Fraction

    • RelativeAbundance/Be/m_f (float)

      Berillium Mass Fraction

  • massArray (list of floats) – List of initial masses for pre main sequence models.

  • outputPath (str) – Path to save models to. Note that this is not the full path, only the directory to save to. The file name will be determined from the compName and the mass.

  • CMIXL (float, default=1.9126) – Mixing length

  • BETA (float, default=1.0) – Beta parameter

  • FMASS1 (float, defualt=9.9e-6) – Fmass1 parameter

  • FMASS2 (float, default=0.9999) – Fmass2 parameter

  • DDAGE (float, default=10000) – Model age

  • PN (float, defualt = 1.5) – Polytropic index of model to generate.

  • LEXCOM (bool, default=False) – Logical flag controlling EXCOM

  • compName (str, default="comp") – Composition name to build model file names off of. For example a 1 solar mass model with the compName “GS98” would have a prems model file name of m100GS98.nml

  • fnameT (str, default=None) – file name template to save pre main sequence models too. Anyplace %m shows up in file name it will be replaced with the mass of the current model. If that %m is immediatly proceeded by %i then it will be cast to an integer. If it is immediatly followed by a %s before casting it will be scaled by the parameter massMult.

pysep.newpoly.runNewpoly module

Author: Thomas M. Boudreaux

Created: May 2021 Last Modified: May 10th 2021

Python wrapper around newpoly.py fortran file newpoly generates a polytropic model of a star this program takes in command line arguments and formates the namelist file for that program so that it is easier to call

pysep.newpoly.runNewpoly.estimate_teff_lum(zz: float, zsolar: float, mixlen: float, sumass: float) Tuple[float, float]

Empirically calibrat the relation between metal mass fraction, mixing length, mass and Temperature + Luminosity

Parameters
  • zz (float) – Metal Mass Fraction

  • zsolar (float) – Metal mass fraction of the sun

  • mixlen (float) – Mixing length

  • sumass (float) – Mass in solar mass units

Returns

  • teff (float) – Estimated log effective temperature in solar units.

  • lum (float) – Estimated log luminosity in solar units.

Notes

The estimation algorithm used here was written by Brian Chaboyer.

pysep.newpoly.runNewpoly.generate_prems_model(sumass: float, X: float, Z: float, CMIXL: float, BETA: float, FMASS1: float, FMASS2: float, DDAGE: float, PN: float, ELEM: list, LEXCOM: bool, compName: str, outDir: str, fname: Optional[str] = None)

Generate a premain sequence model given some chemical composition, mixing length, and mass. This is then saved to disk so that it can be read in by dsep latter.

Parameters
  • sumass (float) – Total mass of the model

  • X (float) – Hydrogen mass fraction

  • Z (float) – Metal mass fraction

  • CMIXL (float) – Mixing length

  • BETA (float) – Beta parameter

  • FMASS1 (float) – Fmass 1 parameter

  • FMASS2 (float) – Fmass 2 parameter

  • DDAGE (float) – Model Age

  • PN (float) – Polytropic index

  • ELEM (list of floats) – Elemental Composition.

  • LEXCOM (bool) – Logical flag to use EXCOM, inverted

  • compName (str) – Name of the composition used, will be used to format output filenames.

  • fname (str, default=m{round(sumass*1000):0>4}{compName}.prems) – filename to save pre main sequence model to. Argument itself is default None. If the function detects that it is none replace the path with the name above

Module contents

Module to generate pre main sequence models for dsep. This includes actually calling the newpoly.f program as well as formating the namelist file which newpoly.f needs.