Skip to content

Commit

Permalink
insert radiation_field
Browse files Browse the repository at this point in the history
  • Loading branch information
wkerzendorf committed Jul 20, 2023
1 parent 6cd2ba0 commit a76c5c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
19 changes: 8 additions & 11 deletions tardis/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from tardis.io.decay import IsotopeAbundances
from tardis.model.density import HomologousDensity

from tardis.radiation_field.base import convert_config_to_radiationfield_state

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -431,7 +433,6 @@ def r_middle(self):

@property
def velocity(self):

if self._velocity is None:
self._velocity = self.raw_velocity[
self.v_boundary_inner_index : self.v_boundary_outer_index + 1
Expand Down Expand Up @@ -631,15 +632,9 @@ def from_config(cls, config, atom_data=None):
# Note: This is the number of shells *without* taking in mind the
# v boundaries.
no_of_shells = len(velocity) - 1

if temperature:
t_radiative = temperature
elif config.plasma.initial_t_rad > 0 * u.K:
t_radiative = (
np.ones(no_of_shells + 1) * config.plasma.initial_t_rad
)
else:
t_radiative = None
radiation_field_state = convert_config_to_radiationfield_state(
config, no_of_shells, temperature
)

if config.plasma.initial_t_inner < 0.0 * u.K:
luminosity_requested = config.supernova.luminosity_requested
Expand Down Expand Up @@ -692,7 +687,7 @@ def from_config(cls, config, atom_data=None):
abundance=abundance,
isotope_abundance=isotope_abundance,
time_explosion=time_explosion,
t_radiative=t_radiative,
t_radiative=radiation_field_state.t_radiative,
t_inner=t_inner,
elemental_mass=elemental_mass,
luminosity_requested=luminosity_requested,
Expand All @@ -702,6 +697,8 @@ def from_config(cls, config, atom_data=None):
electron_densities=electron_densities,
)

####################### FROM CSVY ##############

@classmethod
def from_csvy(cls, config, atom_data=None):
"""
Expand Down
16 changes: 14 additions & 2 deletions tardis/radiation_field/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
from astropy import units as u

from tardis.montecarlo.packet_source import BasePacketSource
from tardis.montecarlo.montecarlo_numba.numba_interface import OpacityState
Expand All @@ -20,7 +21,6 @@ class RadiationField:
"""

def __init__(self, t_rad, w, opacities, source_function):

self.t_rad = t_rad
self.w = w
self.opacities = opacities
Expand Down Expand Up @@ -49,10 +49,22 @@ def __init__(
opacities: OpacityState,
packet_source: BasePacketSource,
):

self.t_radiative = t_radiative
self.dilution_factor = dilution_factor
self.t_rad = self.t_radiative
self.w = self.dilution_factor
self.opacities = opacities
self.source_function = packet_source


def convert_config_to_radiationfield_state(
config, no_of_shells, temperature=None
): ### make it a to_method in the end
if temperature:
t_radiative = temperature
elif config.plasma.initial_t_rad > 0 * u.K:
t_radiative = np.ones(no_of_shells + 1) * config.plasma.initial_t_rad
else:
t_radiative = None

return MonteCarloRadiationFieldState(t_radiative, None, None, None)

0 comments on commit a76c5c4

Please sign in to comment.