Skip to content

Commit

Permalink
Fixes error with density time point and black
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewfullard committed Jun 12, 2024
1 parent ed0b6e5 commit 850ded4
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
16 changes: 10 additions & 6 deletions tardis/io/model/parse_composition_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ def parse_composition_from_config(atom_data, config, time_explosion, geometry):
raw_isotope_mass_fractions,
) = parse_mass_fractions_from_config(config, geometry, time_explosion)

return Composition(
density,
nuclide_mass_fractions,
raw_isotope_mass_fractions,
atom_data.atom_data.mass.copy(),
), electron_densities
return (
Composition(
density,
nuclide_mass_fractions,
raw_isotope_mass_fractions,
atom_data.atom_data.mass.copy(),
),
electron_densities,
)


def parse_composition_from_csvy(
atom_data, csvy_model_config, csvy_model_data, time_explosion, geometry
Expand Down
19 changes: 15 additions & 4 deletions tardis/io/model/parse_density_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
Configuration,
ConfigurationNameSpace,
)
from tardis.io.model.parse_geometry_configuration import parse_structure_from_config
from tardis.io.model.parse_geometry_configuration import (
parse_structure_from_config,
)
from tardis.util.base import quantity_linspace

logger = logging.getLogger(__name__)


def parse_density_section_config(
density_configuration: ConfigurationNameSpace,
v_middle: u.Quantity,
Expand Down Expand Up @@ -85,17 +88,25 @@ def parse_density_from_config(config: Configuration) -> u.Quantity:
"""
time_explosion = config.supernova.time_explosion.cgs
velocity, density, electron_densities, temperature = parse_structure_from_config(config)
(
density_time,
velocity,
density,
electron_densities,
temperature,
) = parse_structure_from_config(config)

if density is None:
adjusted_velocity = velocity.insert(0, 0)
v_middle = adjusted_velocity[1:] * 0.5 + adjusted_velocity[:-1] * 0.5
d_conf = config.model.structure.density
density, time_0 = parse_density_section_config(
density, density_time = parse_density_section_config(
d_conf, v_middle, time_explosion
)

density = calculate_density_after_time(density, time_0, time_explosion)
density = calculate_density_after_time(
density, density_time, time_explosion
)

# Note: This is the number of shells *without* taking in mind the
# v boundaries.
Expand Down
17 changes: 12 additions & 5 deletions tardis/io/model/parse_geometry_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def parse_structure_from_config(config):
NotImplementedError
For structure types that are not "specific" or "file"
"""
density_time = None
velocity = None
density = None
electron_densities = None
Expand All @@ -46,7 +47,7 @@ def parse_structure_from_config(config):
)

(
time_0,
density_time,
velocity,
density,
electron_densities,
Expand All @@ -56,7 +57,7 @@ def parse_structure_from_config(config):
else:
raise NotImplementedError

return velocity, density, electron_densities, temperature
return density_time, velocity, density, electron_densities, temperature


def parse_geometry_from_config(config, time_explosion):
Expand All @@ -75,13 +76,19 @@ def parse_geometry_from_config(config, time_explosion):
HomologousRadial1DGeometry
The parsed geometry
"""
velocity, density, electron_densities, temperature = parse_structure_from_config(config)
(
density_time,
velocity,
density,
electron_densities,
temperature,
) = parse_structure_from_config(config)

return HomologousRadial1DGeometry(
velocity[:-1], # v_inner
velocity[1:], # v_outer
v_inner_boundary= config.model.structure.get("v_inner_boundary", None),
v_outer_boundary= config.model.structure.get("v_outer_boundary", None),
v_inner_boundary=config.model.structure.get("v_inner_boundary", None),
v_outer_boundary=config.model.structure.get("v_outer_boundary", None),
time_explosion=time_explosion,
)

Expand Down
12 changes: 10 additions & 2 deletions tardis/io/model/parse_radiation_field_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
from astropy import units as u

from tardis import constants as const
from tardis.io.model.parse_geometry_configuration import parse_structure_from_config
from tardis.io.model.parse_geometry_configuration import (
parse_structure_from_config,
)
from tardis.model.radiation_field_state import (
DiluteBlackBodyRadiationFieldState,
)
Expand Down Expand Up @@ -40,7 +42,13 @@ def parse_radiation_field_state_from_config(
AssertionError
If the length of t_radiative or dilution_factor is not compatible with the geometry.
"""
velocity, density, electron_densities, temperature = parse_structure_from_config(config)
(
density_time,
velocity,
density,
electron_densities,
temperature,
) = parse_structure_from_config(config)

if temperature is None:
if config.plasma.initial_t_rad > 0 * u.K:
Expand Down

0 comments on commit 850ded4

Please sign in to comment.