Skip to content

Commit

Permalink
Add HDF output capability to solver
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewfullard committed Aug 12, 2024
1 parent a521c10 commit 8f4955e
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions tardis/workflows/standard_simulation_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

from tardis import constants as const
from tardis.io.atom_data.base import AtomData
from tardis.io.util import HDFWriterMixin
from tardis.model import SimulationState
from tardis.plasma.radiation_field import DilutePlanckianRadiationField
from tardis.plasma.standard_plasmas import assemble_plasma
from tardis.simulation.base import PlasmaStateStorerMixin
from tardis.simulation.convergence import ConvergenceSolver
from tardis.spectrum.base import SpectrumSolver
from tardis.spectrum.formal_integral import FormalIntegrator
Expand All @@ -25,7 +27,20 @@
logger = logging.getLogger(__name__)

Check warning on line 27 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L27

Added line #L27 was not covered by tests


class StandardSimulationSolver(WorkflowLogging):
class StandardSimulationSolver(

Check warning on line 30 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L30

Added line #L30 was not covered by tests
WorkflowLogging, PlasmaStateStorerMixin, HDFWriterMixin
):
hdf_properties = [

Check warning on line 33 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L33

Added line #L33 was not covered by tests
"simulation_state",
"plasma_solver",
"transport_solver",
"iterations_w",
"iterations_t_rad",
"iterations_electron_densities",
"iterations_t_inner",
"spectrum_solver",
]

def __init__(

Check warning on line 44 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L44

Added line #L44 was not covered by tests
self,
configuration,
Expand All @@ -37,11 +52,13 @@ def __init__(
convergence_plots_kwargs={},
):
# set up logging
super().__init__(
configuration,
WorkflowLogging.__init__(

Check warning on line 55 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L55

Added line #L55 was not covered by tests
self,
configuration=configuration,
log_level=log_level,
specific_log_level=specific_log_level,
)

self.show_progress_bars = show_progress_bars

Check warning on line 62 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L62

Added line #L62 was not covered by tests

atom_data = self._get_atom_data(configuration)

Check warning on line 64 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L64

Added line #L64 was not covered by tests
Expand Down Expand Up @@ -101,6 +118,13 @@ def __init__(
configuration.montecarlo.no_of_virtual_packets
)

# set up plasma storage
PlasmaStateStorerMixin.__init__(

Check warning on line 122 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L122

Added line #L122 was not covered by tests
self,
iterations=self.total_iterations,
no_of_shells=self.simulation_state.no_of_shells,
)

# spectrum settings
self.integrated_spectrum_settings = configuration.spectrum.integrated
self.spectrum_solver = SpectrumSolver.from_config(configuration)

Check warning on line 130 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L129-L130

Added lines #L129 - L130 were not covered by tests
Expand Down Expand Up @@ -512,6 +536,13 @@ def solve(self):
logger.info(

Check warning on line 536 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L534-L536

Added lines #L534 - L536 were not covered by tests
f"\n\tStarting iteration {(self.completed_iterations + 1):d} of {self.total_iterations:d}"
)
self.store_plasma_state(

Check warning on line 539 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L539

Added line #L539 was not covered by tests
self.completed_iterations,
self.simulation_state.dilution_factor,
self.simulation_state.t_radiative,
self.plasma_solver.electron_densities,
self.simulation_state.t_inner,
)
transport_state, virtual_packet_energies = self.solve_montecarlo(

Check warning on line 546 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L546

Added line #L546 was not covered by tests
self.real_packet_count
)
Expand All @@ -538,6 +569,14 @@ def solve(self):
transport_state, virtual_packet_energies = self.solve_montecarlo(

Check warning on line 569 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L568-L569

Added lines #L568 - L569 were not covered by tests
self.final_iteration_packet_count, self.virtual_packet_count
)
self.store_plasma_state(

Check warning on line 572 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L572

Added line #L572 was not covered by tests
self.completed_iterations,
self.simulation_state.dilution_factor,
self.simulation_state.t_radiative,
self.plasma_solver.electron_densities,
self.simulation_state.t_inner,
)
self.reshape_plasma_state_store(self.completed_iterations)
if self.convergence_plots is not None:
self.get_convergence_estimates(transport_state)
self.convergence_plots.update(

Check warning on line 582 in tardis/workflows/standard_simulation_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/standard_simulation_solver.py#L579-L582

Added lines #L579 - L582 were not covered by tests
Expand Down

0 comments on commit 8f4955e

Please sign in to comment.