Skip to content
 
 

Repository files navigation

Electron Scattering Monte Carlo Routine

A Monte Carlo codebase for modelling electron-scattering effects on emission lines of a compact nebular object in a spherical geometry. It takes an input spectrum, keeps track of original source photons and produces output photon counts.

The source code is written by Dr Stuard Sim.

The code is parallelized with numba for efficient computation and modularized by Rasmus Damgaard.

Caution!

This routine assumes a purely electron scattering spherical geometry. It is not guaranteed to work outside of these conditions.

This code is provided as-is with no guarantees. Use at your own risk for your use cases.

Usage

The scripts e_scatt_sims_*.py demonstrate usage patterns.

  • An Environment object represents the physical conditions of the simulation (photons initialized at centre/volumetrically, density, temperature, initial line properties etc).
  • propagate_photons and propagate_photons_binned use this environment, and generate n_pkts MCMC samples.

Note: the runtime scales roughly as number of scatterings + number of photons. For high tau, this goes exponentially. If using JupyterNotebook, only killing the kernel can stop the Numba function. For testing, you might therefore might want to decrease batch_size.

The structure of this repository

electron_scattering.py - Core module you want to "import" - all simulation in here.

correctness_tests.ipynb - A few simple corectness tests

e_scatt_sims_*.py - Scripts for running simulations at various temperatures. ..._10K.py and ..._30K.py initialize packets at the origin, while ..._volumetric.py initializes them throughout the scattering volume. To run these, make sure to make the corresponding output directories.

tau_velocity_relation.ipynb - Analyzes the packets generated by the above mentioned scripts.

About

Optimization of code by Stuart Sim

Resources

Code of conduct

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages