pyC\(^2\)Ray Parameter FileΒΆ

Here, we will illustrate the content of pyC\(^2\)Ray parameter file and how you can extend it to add more astrophysical models and variables.

[2]:
import pyc2ray as pc2r
import numpy as np, yaml
import matplotlib.pyplot as plt

import astropy.units as u

The variables employed in a pyC\(^2\)Ray run are defined in a YAML file, e.g. parameters.yml. The variables are grouped in cathegories and the basic requirement are:

  • Grid: Parameters to set up the simulation volume (e.g. boxsize, mesh-size,

  • Material: Initial properties of physical quantities in the simulation volume (neutral fraction, temperature and density)

  • CGS: Miscellaneous physical constant (do not require modification).

  • Abundaces: Cosmological element abundances (do not require modification).

  • Photo: Control parameters for the photo-ionization rate and the proprieties of the sources.

  • BlackBodySource: Parameters for the Black Body source (standard source model).

  • Cosmology: Cosmological paramerters, at the moment only standard \(\Lambda\)CDM is implemented.

  • Output: Paths of the input/output directories.

  • Raytracing: Parameters for the raytracing, the only tunable parameter is the source batch size (see :math:S` source_batch_size.ipynb <source_batch_size.ipynb>`__ tutorial).

Based on the need of your simulation, you can add new cathegories. For instance, in the :math:S` make_sim.ipynb <make_sim.ipynb>`__ tutorial, we will have a look at the Sources and Sinks cathegories for the source and sink models that are already implemented in pyC\(^2\)Ray.

[3]:
paramfile = 'parameters.yml'

with open(paramfile,'r') as f:
    params = yaml.load(f, yaml.CSafeLoader)

print(params.keys())
dict_keys(['Grid', 'Material', 'CGS', 'Abundances', 'Photo', 'Sinks', 'BlackBodySource', 'Cosmology', 'Output', 'Raytracing'])

Most of the cathegories do not require any substantial modification as these are standard value, for instance the group CGS contain miscellaneous defined physical constants.

[4]:
params['CGS']
[4]:
{'albpow': -0.7,
 'bh00': 2.59e-13,
 'alcpow': -0.672,
 'eth0': 13.598,
 'ethe0': 24.587,
 'ethe1': 54.416,
 'xih0': 1.0,
 'fh0': 0.83,
 'colh0_fact': 1.3e-08}
[5]:
# ionizing energy [eV] of hydrogen
print('Ionizing energy for HI:', params['CGS']['eth0'] * u.eV)

# energy of the first ionization of helium [eV]
print('Ionizing energy for HeI:', params['CGS']['ethe0'] * u.eV)

# energy of the second ionization of helium [eV]
print('Ionizing energy for HeII', params['CGS']['ethe1'] * u.eV)
Ionizing energy for HI: 13.598 eV
Ionizing energy for HeI: 24.587 eV
Ionizing energy for HeII 54.416 eV

On the other hand, you are required to modify the I/O directories in the Output cathegory or the cosmological parameter, Cosmology.

[6]:
params['Output']
[6]:
{'results_basename': './test_results/',
 'inputs_basename': './',
 'sources_basename': './',
 'density_basename': './',
 'logfile': 'pyC2Ray.log'}
[7]:
params['Cosmology']
[7]:
{'cosmological': 0,
 'h': 0.6766,
 'Omega0': 0.30966,
 'Omega_B': 0.04897,
 'cmbtemp': 2.7255,
 'zred_0': 9.0}