LeHaMoC is a leptohadronic modeling code designed for simulating high-energy astrophysical sources. It simulates the behavior of relativistic pairs, protons interacting with magnetic fields and photons in a spherical region. The physical processes that are included are:
- Synchrotron emission and self-absorption
- Inverse Compton scattering
- Photon-photon pair production
- Adiabatic losses
- Proton-photon pion production
- Proton-photon (Bethe-Heitler) pair production
- Proton-proton collisions
The user can also model expanding spherical sources with a variable magnetic field strength. The user can also define 3 types of external radiation fields:
-Grey body or black body
-Power-law
-Tabulated
-
LeHaMoC.py: This file contains the main code for the LeMoC simulation. It takes user-defined parameters from
Parameters*.txt
to set up the simulation. -
Parameters.txt: Users should edit this file to specify the parameters for their simulation. This includes setting up the initial conditions, time interval, and other relevant parameters. There are currently two input files ready for use that correspond to Tests 1 and 3 described in Stathopoulos et al.
-
LeHaMoC_f.py: This file includes all the necessary formulas for calculating emissivities and energy loss rates for various processes such as Synchrotron, Inverse Compton (IC), gamma-gamma absorption, pair creation, and Synchrotron self-absorption.
i. Clone this repository to your local machine using git clone <repository-url>
ii. Edit the Parameters.txt
file to set up the initial conditions and simulation parameters according to your needs.
To configure the LeHaMoC simulation, you can customize various parameters in the Parameters.txt
file:
-
time_init: Initial time of the simulation, measured in units of the initial radius over the speed of light (R0/c).
-
time_end: The final time of the simulation, also measured in units of the initial radius over the speed of light (R0/c).
-
step_alg: Step size used in the algorithm, expressed in units of the initial radius over the speed of light (R0/c).
-
PL_inj: Power law injection flag (1 to include, 0 to use distribution with exponential cut-offs).
-
g_min_el: Minimum Lorentz factor of electrons on the grid in log10.
-
g_max_el: Maximum Lorentz factor of electrons on the grid in log10.
-
g_el_PL_min: Minimum Lorentz factor of power-law electrons in log10.
-
g_el_PL_max: Maximum Lorentz factor of power-law electrons in log10.
-
grid_g_el: Number of grid points between g_min_el and g_max_el.
-
g_min_pr: Minimum Lorentz factor of protons on the grid in log10.
-
g_max_pr: Maximum Lorentz factor of protons on the grid in log10.
-
g_pr_PL_min: Minimum Lorentz factor of power-law protons in log10.
-
g_pr_PL_max: Maximum Lorentz factor of power-law protons in log10.
-
grid_g_pr: Number of grid points between g_min_pr and g_max_pr.
-
grid_nu: Number of grid points for photons' frequency.
-
p_el: Power-law index of the electron distribution.
-
L_el: Log10 of luminosity of electrons in erg s^{-1}.
-
p_pr: Power-law index of the proton distribution.
-
L_pr: Log10 of luminosity of protons in erg s^{-1}.
-
Vexp: Expansion velocity in units of the speed of light (c).
-
R0: Log10 of the initial radius of the spherical blob in centimeters (cm).
-
B0: Magnetic field intensity in Gauss (G).
-
m: Power-law index of the magnetic field due to source expansion.
-
delta: Doppler factor.
-
inj_flag: Electron injection profile (1 for continuous, 0 for instantaneous).
-
Ad_l_flag: Adiabatic losses flag (1 to include, 0 to exclude).
-
Syn_l_flag: Synchrotron losses flag (1 to include, 0 to exclude).
-
Syn_emis_flag: Synchrotron emission flag (1 to include, 0 to exclude).
-
IC_l_flag: Inverse Compton scattering losses flag (1 to include, 0 to exclude).
-
IC_emis_flag: Inverse Compton scattering emission flag (1 to include, 0 to exclude).
-
SSA_l_flag: Synchrotron Self-absorption losses flag (1 to include, 0 to exclude).
-
gg_flag: Gamma-gamma absorption-emission flag (1 to include, 0 to exclude).
-
pg_pi_l_flag: Photopion losses flag (1 to include, 0 to exclude).
-
pg_pi_emis_flag: Photopion emission flag (1 to include, 0 to exclude).
-
pg_BH_l_flag: Bethe-Heitler losses flag (1 to include, 0 to exclude).
-
pg_BH_emis_flag: Bethe-Heitler losses flag (1 to include, 0 to exclude).
-
n_H: Number density of cold protons in #/cm^{3}.
-
pp_l_flag: Proton-proton (pp) losses flag (1 to include, 0 to exclude).
-
pp_ee_emis_flag: Pairs emission from pp interactions flag (1 to include, 0 to exclude).
-
pp_g_emis_flag: Photon emission from pp interactions flag (1 to include, 0 to exclude).
-
pp_nu_emis_flag: Neutrino emission from pp interactions flag (1 to include, 0 to exclude).
-
neutrino_flag: Neutrino flag for photopion interactions flag (1 to include, 0 to exclude).
-
esc_flag_el: Escape of pairs flag (1 to include, 0 to exclude).
-
esc_flag_pr: Escape of protons flag (1 to include, 0 to exclude).
-
BB_flag: Black body flag (1 to include, 0 to exclude).
-
BB_temperature: Black body temperature in Kelvin (K).
-
GB_ext: External Grey Body photon field flag (1 to include, 0 to exclude).
-
PL_flag: External power-law photon field flag.
-
dE_dV_ph: Energy density in erg cm^{-3} of the external power-law photon field.
-
nu_min_ph: Minimum frequency of the power-law photon field.
-
nu_max_ph: Maximum frequency of the power-law photon field.
-
s_ph: Power-law index of the power-law photon field.
-
User_ph: External user photon field flag (1 to include, 0 to exclude). If included, provide a .txt file named 'Photons_spec_user.txt' with columns (log(nu[Hz]),log(dN/dVdnu[cm^{-3}Hz^{-1}])).
iii. Run the LeHaMoC.py
code using a compatible Python interpreter. Make sure to have all necessary dependencies installed. Example:
- python LeHaMoC.py Parameters_Test3.txt Test3
iv. Once the simulation is complete, open the Plotting_Tool.ipynb
notebook to visualize and analyze the simulation results. Follow the instructions provided in the notebook.
The default output files are:
- Pairs_Distribution.txt (1st col: log10(gamma_e), 2nd col: log10(dN_e/(dV dgamma_e)) [cm^(-3)]
- Photons_Distribution.txt (1st col: log10(v), 2nd col: log10(dL_ph/(dv)) [erg s^(-1)]
- Protons_Distribution.txt (1st col: log10(gamma_p), 2nd col: log10(dN_p/(dV dgamma_p)) [cm^(-3)]
- Neutrinos_Distribution.txt (1st col: log10(v), 2nd col: log10(dN_nu/(dv dV)) [neutrinos cm^(-3) Hz^(-1)]
- Python 3 (check also the .yml file)
If you'd like to contribute to this project, feel free to fork the repository and submit pull requests.
This project is licensed under the [GNU GPLv3]