Skip to content

Commit

Permalink
add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyizheng1112 committed Mar 20, 2021
1 parent 448366b commit 40d0b44
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tardis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ def run_tardis(
the atomic data. Atomic data to use for this TARDIS simulation. If set to None, the
atomic data will be loaded according to keywords set in the configuration
[default=None]
virtual_packet_logging : bool
option to enable virtual packet logging
[default=False]
Returns
-------
Simulation
"""
from tardis.io.config_reader import Configuration
from tardis.io.atom_data.base import AtomData
Expand Down
45 changes: 45 additions & 0 deletions tardis/montecarlo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,18 @@ def montecarlo_virtual_luminosity(self):
def calculate_emitted_luminosity(
self, luminosity_nu_start, luminosity_nu_end
):
"""
Calculate emitted luminosity.
Parameters
----------
luminosity_nu_start : astropy.units.Quantity
luminosity_nu_end : astropy.units.Quantity
Returns
-------
astropy.units.Quantity
"""
luminosity_wavelength_filter = (
self.emitted_packet_nu > luminosity_nu_start
) & (self.emitted_packet_nu < luminosity_nu_end)
Expand All @@ -439,7 +450,18 @@ def calculate_emitted_luminosity(
def calculate_reabsorbed_luminosity(
self, luminosity_nu_start, luminosity_nu_end
):
"""
Calculate reabsorbed luminosity.
Parameters
----------
luminosity_nu_start : astropy.units.Quantity
luminosity_nu_end : astropy.units.Quantity
Returns
-------
astropy.units.Quantity
"""
luminosity_wavelength_filter = (
self.reabsorbed_packet_nu > luminosity_nu_start
) & (self.reabsorbed_packet_nu < luminosity_nu_end)
Expand Down Expand Up @@ -484,6 +506,17 @@ def calculate_radiationfield_properties(self):
return t_rad * u.K, w

def calculate_luminosity_inner(self, model):
"""
Calculate inner luminosity.
Parameters
----------
model : model.Radial1DModel
Returns
-------
astropy.units.Quantity
"""
return (
4
* np.pi
Expand All @@ -493,6 +526,17 @@ def calculate_luminosity_inner(self, model):
).to("erg/s")

def calculate_time_of_simulation(self, model):
"""
Calculate time of montecarlo simulation.
Parameters
----------
model : model.Radial1DModel
Returns
-------
float
"""
return 1.0 * u.erg / self.calculate_luminosity_inner(model)

def calculate_f_nu(self, frequency):
Expand All @@ -509,6 +553,7 @@ def from_config(cls, config, packet_source=None, virtual_packet_logging=False):
Parameters
----------
config : tardis.io.config_reader.Configuration
virtual_packet_logging : bool
Returns
-------
Expand Down
4 changes: 4 additions & 0 deletions tardis/simulation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ def iterate(self, no_of_packets, no_of_virtual_packets=0, last_run=False):
self.iterations_executed += 1

def run(self):
"""
run the simulation
"""
start_time = time.time()
while self.iterations_executed < self.iterations - 1:
self.store_plasma_state(
Expand Down Expand Up @@ -509,6 +512,7 @@ def from_config(cls, config, packet_source=None, virtual_packet_logging=False, *
Parameters
----------
config : tardis.io.config_reader.Configuration
**kwargs
Allow overriding some structures, such as model, plasma, atomic data
and the runner, instead of creating them from the configuration
Expand Down

0 comments on commit 40d0b44

Please sign in to comment.