-
-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Restructure/plasma] Refactor the simulation state initialization (#2664
) * change numberdensity to input * fixed number density * some fixes * removing density * remove atomic and isotope mass * add isotopic_number_density * add opacities package * Update imports in property_collections.py, base.py, test_numba_interface.py, transport_montecarlo_numba_interface.py, conftest.py, formal_integral.py, base.py, and macro_atom.py * Add calculate_transition_probabilities function to util.py in macro_atom package * Add calculate_transition_probabilities function to util.py in macro_atom package * Remove unused imports and update plasma properties * add __init__ to macroatom * blackify tardis * blackified * chore: Update imports and remove unused code * chore: Add PlanckRadiationField and DilutePlanckRadiationField classes * chore: Update imports and remove unused code * removed density * ruff output * cleanup and adding object mode * starting to make radiation_field a thing * switched over to old tau_sobolev calculation * renamed function to indicate numba use * address comments * added dilute planckian radiation field * refactor: Convert species lists to proper format in assemble_plasma function * moved radiation field into plasma. Resulting in some renames * some fixes * black montecarlo * chore: Initialize atom data and simulation state in `initialization.py` * updating the documentation * remove parse_input.py * chore: Refactor radiation field configuration parsing and state creation Refactor the `parse_radiation_field_configuration.py` module to improve code organization and readability. Update the import statements to reflect the changes in the module structure. Replace the deprecated `DiluteBlackBodyRadiationFieldState` class with the new `DilutePlanckianRadiationField` class from the `tardis.plasma.radiation_field` module. This change ensures consistency and compatibility with the latest codebase. Also, update the `tardis/simulation/base.py` module to import the `DilutePlanckianRadiationField` class from the `tardis.plasma.radiation_field` module. This change ensures that the correct class is used for creating the radiation field in the simulation. * revert astropy_helpers * remove astropy_helpers * removed test.txt * blackified code * cleanup simulation from merges * fix * remove unused Input * added description * blackiefied codebase * blackify code * chore: Refactor atom data parsing and simulation state initialization * restructure logger * merge changes * blackify * ruffify
- Loading branch information
1 parent
375dd5b
commit 2766edd
Showing
6 changed files
with
155 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import logging | ||
from pathlib import Path | ||
|
||
from tardis.io.atom_data.base import AtomData | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def parse_atom_data(config, atom_data=None): | ||
""" | ||
Parse atom data for the simulation. | ||
Parameters | ||
---------- | ||
config : object | ||
The configuration object containing information about the atom data. | ||
atom_data : object, optional | ||
Existing atom data to be used, if provided. | ||
Returns | ||
------- | ||
object | ||
The initialized atom data. | ||
Raises | ||
------ | ||
ValueError | ||
If no atom_data option is found in the configuration. | ||
""" | ||
if atom_data is None: | ||
if "atom_data" in config: | ||
if Path(config.atom_data).is_absolute(): | ||
atom_data_fname = Path(config.atom_data) | ||
else: | ||
atom_data_fname = Path(config.config_dirname) / config.atom_data | ||
|
||
else: | ||
raise ValueError("No atom_data option found in the configuration.") | ||
|
||
logger.info(f"\n\tReading Atomic Data from {atom_data_fname}") | ||
|
||
try: | ||
atom_data = AtomData.from_hdf(atom_data_fname) | ||
except TypeError as e: | ||
print( | ||
e, | ||
"Error might be from the use of an old-format of the atomic database, \n" | ||
"please see https://github.com/tardis-sn/tardis-refdata/tree/master/atom_data" | ||
" for the most recent version.", | ||
) | ||
raise | ||
|
||
return atom_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from tardis.io.model.parse_packet_source_configuration import ( | ||
initialize_packet_source, | ||
) | ||
from tardis.model import SimulationState | ||
|
||
|
||
def parse_simulation_state( | ||
config, packet_source, enable_legacy_mode, kwargs, atom_data | ||
): | ||
""" | ||
Initialize the simulation state. | ||
Parameters | ||
---------- | ||
config : object | ||
The configuration object for the simulation. | ||
packet_source : object | ||
The packet source for the simulation. | ||
legacy_mode_enabled : bool | ||
Flag indicating if legacy mode is enabled. | ||
kwargs : dict | ||
Additional keyword arguments. | ||
atom_data : object | ||
The atom data for the simulation. | ||
Returns | ||
------- | ||
object | ||
The initialized simulation state. | ||
""" | ||
if "model" in kwargs: | ||
simulation_state = kwargs["model"] | ||
else: | ||
if hasattr(config, "csvy_model"): | ||
simulation_state = SimulationState.from_csvy( | ||
config, | ||
atom_data=atom_data, | ||
legacy_mode_enabled=enable_legacy_mode, | ||
) | ||
else: | ||
simulation_state = SimulationState.from_config( | ||
config, | ||
atom_data=atom_data, | ||
legacy_mode_enabled=enable_legacy_mode, | ||
) | ||
if packet_source is not None: | ||
simulation_state.packet_source = initialize_packet_source( | ||
config, | ||
simulation_state.geometry, | ||
packet_source, | ||
enable_legacy_mode, | ||
) | ||
|
||
return simulation_state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters