Python package to read in a star formation history file, input galaxy parameters and run a chemical evolution model to determine the evolution of gas, metals and dust in galaxies.
Running the script following the instructions below will produce:
- a results data file with galaxy parameters in (filename.dat with name provided by user from inits file - see instructions below)
The code is based on Morgan & Edmunds 2003 (MNRAS, 343, 427) and described in detail in Rowlands et al 2014 (MNRAS, 441, 1040), with latest features discussed in De Vis et al 2017b. The version of this code used for De Vis et al 2017b is in release v_de_vis2017.
If you use this code, please do cite the above papers. The license is provided with this package.
Download this repository and do the following:
python setup.py install
- numpy
- astropy
- matplotlib [Not a strict requirement]
The code reads in a star formation history from a file called filename.sfh. This needs to be in the form: time (yr), SFR (Msolar/yr) and in the directory where you are running the code. An example is provided with this code Milkyway.sfh
based on the SFH for the Milky Way in Yin et al 2009 (A & A, 505, 497).
The code also requires a dictionary of initial parameters. This can be done by providing a .json or .csv file and using the package installed, or by running the example python script provided with this package.
There are example data files in the folder <Download Dir>/chemevol/chemevol/examples/
which show the correct format of each type of file. Feel free to copy these example data files into the directory where you wish to run the code and follow the instructions. A detailed breakdown of the parameter files and inputs needed are found at the bottom of this readme.
There are helper functions for loading batch files in CSV and valid JSON format.
Note: Valid JSON uses double quotes for definitions and lower case for booleans, e.g. "myvalue" : false
import chemevol as ch
galaxies = ch.BulkEvolve('<File directory>/data.json')
galaxies.upload_json()
galaxies.evolve_all()
Or for CSV files:
import chemevol as ch
galaxies = ch.BulkEvolve('data.csv')
galaxies.upload_csv()
galaxies.evolve_all()
See the files in <Download Dir>/chemevol/chemevol/examples/
for the correct format of each type of file (.py, .json, .csv examples are provided).
Once the code is run you will have an array called galaxies.results
with all the parameters in. To look at this data try:
[g['dust_all'] for g in galaxies.results] #will print out the dust_all
[g['mgas'] for g in galaxies.results] #will print out all the gasmasses
gasmass = galaxies.results[0]['mgas'] #etc
The code writes data to a file (if you use the example in <Download Dir>/chemevol/chemevol/examples/data.json
the code writes out two files called Model_A.dat
and Model_B.dat
). To read in this data for plotting or playing with you can use astropy.table
:
from astropy.table import Table
import matplotlib.pyplot as plt
t = Table.read('Model_A.dat', format='ascii')
plt.semilogy(t['fg'],t['dustmass']/(t['mgas']+t['mstars']))
Alternatively you can run the code without the bulkevolve class above:
Copy the example_multi.py file to the desired directory (where your .sfh file is and where you want to have your results). Then edit the parameters in the init dictionaries within this script.
python example_multi.py
Parameter Name | Description | If not specified, will revert to default |
---|---|---|
name | to identify your galaxy/run, output file will be called this | None |
gasmass_init | initial gas mass in solar masses | None |
SFH | filename for star formation history file (filename.sfh) | MilkyWay.sfh : MW-like SFH |
t_end | end of time array for chemical integrals in Gyrs, try 20Gyrs | None |
gamma | power law for extrapolation of SFH if using SFH generated by MAGPHYS code, otherwise set to zero | None |
IMF_fn | choice of IMF function: Chab/chab/c, TopChab/topchab/tc, Kroup/kroup/k or Salp/salp/s | None |
dust_source | choice of dust sources to be included in run: SN: supernova dust only; LIMS: low intermediate mass stars dust only; LIMS+SN: both SN and LIMS included; ALL: includes supernovae, LIMS and grain growth combined | None |
delta_lims_fresh | efficiency of fresh metals from low intermediate mass stars (LIMS: 1 < m_i < 8Msun) condensing into dust grains. This value ranges from 0.15-0.4 in Morgan & Edmunds 2003 (MNRAS, 343, 427); is ~0.8 in Dwek et al 1998; 0.15 in De Vis et al 2017b; ~0.2 in Rowlands et al 2014b; De Vis et al 2017b | None |
reduce_sn_dust | reduce the contribution from SN dust (currently based on Todinin & Ferrara 2001). If leave as is, specify False or factor = 0. To reduce dust mass, quote number to reduce by eg factor = 5 | None |
destroy | add dust destruction from SN shocks: True or False mass: amount of ISM material destroyed by each SN: typically 1000 or 100Msun for diffuse or dense interstellar gas |
None |
inflows | turn inflows on or off: input Yes or No inflows_metals, yes or no? Include metallicity of inflow: input a number appropriate for the metallicity of gas inflows eg 1e-3 to 1e-4 (Rubin et al 2012, Peng & Maiolino 2013) inflows_xSFR = inflow rate of gas is X * SFR: input a number (typically 0-3 * SFR) X inflows_dust = amount of dust inflow: input a number appropriate for dust inflows eg 0.4 x the metallicity (Edmunds 2000) |
None |
outflows | turn outflows on or off: input Yes or No outflows_metals = metallicity of outflow: input True or False where True = current metallicity of system, False = 0 outflows_dust = amount of dust in outflow: input True of False where True = dust/gas of system, False = 0 The equation for outflows is take from simulations of feedback in Hopkins et al 2012, see Eq 27 in Feldmann et al 2015 |
None |
cold_gas_fraction | fraction of gas in cold dense state for grain growth, typically 0.5 (eg Asano et al 2013) | None |
available_metal_fraction | fraction of metals that can accrete onto dust grains, typically 0.6 (eg Jones et al 2017) | None |
effective_snrate_factor | correction factor to obtain the effective SN rate for dust destruction (to account for previous SN clearing out dust in the vicinity), typically 0.36 (eg McKee 89) | None |
epsilon_grain | grain growth parameter from Mattsson & Andersen 2012, typically 500 for t_grow ~ 10Myr consistent with MW | None |