Skip to content

Commit

Permalink
rename simulation_state2 (#2421)
Browse files Browse the repository at this point in the history
* fixup of many files to make them pass the tests

* change model for typo
  • Loading branch information
wkerzendorf authored Oct 2, 2023
1 parent aea441c commit f89e125
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"import numpy as np\n",
"\n",
"import matplotlib.pyplot as plt\n",
"from tardis.model import Radial1DModel\n",
"from tardis.model import SimulationState\n",
"from tardis.io.config_reader import Configuration\n",
"\n",
"from tardis.plasma.properties import Density, Abundance, IsotopeAbundance, IsotopeNumberDensity, AtomicData, AtomicMass, IsotopeMass, NumberDensity, SelectedAtoms\n",
Expand All @@ -60,7 +60,7 @@
"\n",
"config.atom_data = \"kurucz_cd23_chianti_H_He.h5\"\n",
"\n",
"model = Radial1DModel.from_config(config)\n",
"model = SimulationState.from_config(config)\n",
"\n",
"# Construct plasma\n",
"input = [Density, Abundance, IsotopeAbundance, AtomicData, AtomicMass, IsotopeNumberDensity, NumberDensity, SelectedAtoms, IsotopeMass]\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/io/grid/TardisGridTutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"source": [
"## TARDIS Grid Functionality\n",
"\n",
"The TARDIS Grid provides a variety of functions for using the grid to generate new Configurations, return new Radial1DModel objects, or directly run simulations using the parameters specified by the grid. This functionality is particularly useful for running large numbers of simulations and easily works with JobArrays where the row_index is the JobArray index."
"The TARDIS Grid provides a variety of functions for using the grid to generate new Configurations, return new SimulationState objects, or directly run simulations using the parameters specified by the grid. This functionality is particularly useful for running large numbers of simulations and easily works with JobArrays where the row_index is the JobArray index."
]
},
{
Expand All @@ -144,7 +144,7 @@
"# In case a user needs to make more complicated changes\n",
"# to the base TARDIS model (i.e. using parameters that \n",
"# are not valid TARDIS Configuration keys), the grid\n",
"# can return a Radial1DModel object for a given row.\n",
"# can return a SimulationState object for a given row.\n",
"model = tg.grid_row_to_model(row_index=0)\n",
"model"
]
Expand Down
4 changes: 2 additions & 2 deletions docs/io/optional/callback_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"outputs": [],
"source": [
"def average_temp(sim):\n",
" t_rads = sim.model.t_rad\n",
" volumes = sim.model.volume\n",
" t_rads = sim.simulation_state.t_rad\n",
" volumes = sim.simulation_state.volume\n",
" avg = sum(t_rads*volumes) / sum(volumes)\n",
" print(f\"Average temperature for iteration {sim.iterations_executed}: {avg}\")"
]
Expand Down
10 changes: 5 additions & 5 deletions docs/io/output/physical_quantities.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Several important quantities that were setup when the model was defined by the configuration file are located in the `model` section of the simulation. For example, the inner and outer velocity boundaries of the zones in the model is given by `simulation.model.v_inner.cgs` and `simulation.model.v_outer.cgs` respectively. These exist as Astropy [Quantities](http://astropy.readthedocs.org/en/v0.2.1/_generated/astropy.units.quantity.Quantity.html)."
"Several important quantities that were setup when the model was defined by the configuration file are located in the `model` section of the simulation. For example, the inner and outer velocity boundaries of the zones in the model is given by `simulation.simulation_state.v_inner.cgs` and `simulation.simulation_state.v_outer.cgs` respectively. These exist as Astropy [Quantities](http://astropy.readthedocs.org/en/v0.2.1/_generated/astropy.units.quantity.Quantity.html)."
]
},
{
Expand All @@ -120,7 +120,7 @@
"metadata": {},
"outputs": [],
"source": [
"simulation.model.v_inner.cgs"
"simulation.simulation_state.v_inner.cgs"
]
},
{
Expand All @@ -129,14 +129,14 @@
"metadata": {},
"outputs": [],
"source": [
"simulation.model.v_outer.cgs"
"simulation.simulation_state.v_outer.cgs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The average density in the zones is given by `simulation.model.density.cgs`. These also exist as Astropy [Quantities](http://astropy.readthedocs.org/en/v0.2.1/_generated/astropy.units.quantity.Quantity.html)."
"The average density in the zones is given by `simulation.simulation_state.density.cgs`. These also exist as Astropy [Quantities](http://astropy.readthedocs.org/en/v0.2.1/_generated/astropy.units.quantity.Quantity.html)."
]
},
{
Expand All @@ -145,7 +145,7 @@
"metadata": {},
"outputs": [],
"source": [
"simulation.model.density.cgs"
"simulation.simulation_state.density.cgs"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions docs/io/output/to_hdf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"metadata": {},
"outputs": [],
"source": [
"print(data['/simulation/model/density'])"
"print(data['/simulation/simulation_state/density'])"
]
},
{
Expand All @@ -127,7 +127,7 @@
"metadata": {},
"outputs": [],
"source": [
"print(data['/simulation/model/scalars']['t_inner'])"
"print(data['/simulation/simulation_state/scalars']['t_inner'])"
]
},
{
Expand Down Expand Up @@ -209,7 +209,7 @@
"metadata": {},
"source": [
"### Model\n",
"The following call will store properties of the `Radial1DModel` to `/tmp/model_output.hdf` under `/model`."
"The following call will store properties of the `SimulationState` to `/tmp/model_output.hdf` under `/simulation_state`."
]
},
{
Expand All @@ -218,7 +218,7 @@
"metadata": {},
"outputs": [],
"source": [
"simulation.model.to_hdf('/tmp/model_output.hdf', overwrite=True)"
"simulation.simulation_state.to_hdf('/tmp/model_output.hdf', overwrite=True)"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions docs/io/visualization/montecarlo_packet_visualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@
"source": [
"# animated plot\n",
"\n",
"v_shells = sim.model.radius.value * 1e-5 / sim.model.time_explosion.value\n",
"xs,ys,ints = get_coordinates_multiple_packets_ints(sim.transport.rpacket_tracker_df,sim.model.time_explosion.value)\n",
"v_shells = sim.simulation_state.radius.value * 1e-5 / sim.simulation_state.time_explosion.value\n",
"xs,ys,ints = get_coordinates_multiple_packets_ints(sim.transport.rpacket_tracker_df,sim.simulation_state.time_explosion.value)\n",
"xs,ys,ints,max_size = get_equal_array_size(xs,ys,ints)\n",
"\n",
"fig = go.Figure()\n",
Expand All @@ -247,7 +247,7 @@
"\n",
"# adding the shells\n",
"shell_shapes={}\n",
"for i in range(len(sim.model.radius.value)-2,-2,-1):\n",
"for i in range(len(sim.simulation_state.radius.value)-2,-2,-1):\n",
" if i==0:\n",
" fig.add_shape(type=\"circle\",\n",
" xref=\"x\", yref=\"y\",\n",
Expand All @@ -256,7 +256,7 @@
" fillcolor=\"darkgrey\",\n",
" opacity=1\n",
" )\n",
" elif i==(len(sim.model.radius.value)-1):\n",
" elif i==(len(sim.simulation_state.radius.value)-1):\n",
" fig.add_shape(type=\"circle\",\n",
" xref=\"x\", yref=\"y\",\n",
" x0=-1*v_shells[i], y0=-1*v_shells[i], x1=v_shells[i], y1=v_shells[i],\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/physics/setup/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Setting Up the Simulation
*************************

The first step executed when TARDIS runs is to call an instance of the ``Simulation`` class. This sets up a lot of
things that TARDIS will need during its run. The main things that are set up are the supernova model (a ``Radial1DModel`` object), the
things that TARDIS will need during its run. The main things that are set up are the supernova model (a ``SimulationState`` object), the
initial plasma state (a ``BasePlasma`` object, which may be updated throughout the simulation, see :doc:`../update_and_conv/update_and_conv`),
and a ``MonteCarloTransport`` object. The pages linked below explain how the former two are calculated (the latter is used mainly in the
:doc:`next step of the calculation <../montecarlo/index>`), as well as showing this in action by calling an instance of the ``Simulation``
Expand Down
32 changes: 16 additions & 16 deletions docs/physics/setup/model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source": [
"# Model\n",
"\n",
"As shown previously, when `Simulation.from_config()` is called, a `Radial1DModel` object is created. This is done via the class method `Radial1DModel.from_config()`. This model object contains important information about the shell structure, density, abundance, radiative temperature, and dilution factor throughout the supernova.\n",
"As shown previously, when `Simulation.from_config()` is called, a `SimulationState` object is created. This is done via the class method `SimulationState.from_config()`. This model object contains important information about the shell structure, density, abundance, radiative temperature, and dilution factor throughout the supernova.\n",
"\n",
"Throughout this notebook, we show various configuration inputs into the TARDIS model and the resulting model. In interactive mode, these parameters can be varied to explore how the model changes. Editing configuration parameters in the notebook is explained [here](../../io/configuration/read_configuration.ipynb).\n",
"\n",
Expand Down Expand Up @@ -53,7 +53,7 @@
"source": [
"# We import the necessary packages\n",
"from tardis.io.configuration.config_reader import Configuration\n",
"from tardis.model import Radial1DModel\n",
"from tardis.model import SimulationState\n",
"from tardis.io.atom_data.util import download_atom_data\n",
"from astropy import units as u\n",
"import matplotlib.pyplot as plt\n",
Expand All @@ -79,7 +79,7 @@
"id": "cee054e9",
"metadata": {},
"source": [
"In the cell below, we set up a model. We use the [specific structure](../../io/configuration/components/models/index.rst#specific-structure) where we supply $t_\\mathrm{explosion}$, the velocity of the inner and outer boundaries of the supernova (labeled `start` and `stop`), and the number of shells (labeled `num`). The shells are then evenly spaced between the inner and outer boundaries of the supernova. The time after the explosion, the inner and outer velocities, and the number of shells can be varied to get different shell structures. The `Radial1DModel` object stores information about the model in the following attributes: `velocity` shows the velocity of the shell boundaries, `v_inner` shows the velocities of the inner boundaries of each shell, `v_outer` shows the velocity of the outer boundaries of each shell, and `v_middle` shows the velocity of the middle of each shell. Similarly, `radius`, `r_inner`, `r_outer`, and `r_middle` show the radii of each shell boundary, the inner boundaries, the outer boundaries, and the middles of each shell, respectively. `v_boundary_inner` shows the velocity of the inner boundary of the computational domain, and `v_boundary_outer` shows the velocity of the outer boundary of the computational domain. Finally, `volume` shows the volume of each shell, calculated via the formula of the volume of a spherical shell: $V=\\frac{4}{3}\\pi (r_\\mathrm{outer}^3-r_\\mathrm{inner}^3)$."
"In the cell below, we set up a model. We use the [specific structure](../../io/configuration/components/models/index.rst#specific-structure) where we supply $t_\\mathrm{explosion}$, the velocity of the inner and outer boundaries of the supernova (labeled `start` and `stop`), and the number of shells (labeled `num`). The shells are then evenly spaced between the inner and outer boundaries of the supernova. The time after the explosion, the inner and outer velocities, and the number of shells can be varied to get different shell structures. The `SimulationState` object stores information about the model in the following attributes: `velocity` shows the velocity of the shell boundaries, `v_inner` shows the velocities of the inner boundaries of each shell, `v_outer` shows the velocity of the outer boundaries of each shell, and `v_middle` shows the velocity of the middle of each shell. Similarly, `radius`, `r_inner`, `r_outer`, and `r_middle` show the radii of each shell boundary, the inner boundaries, the outer boundaries, and the middles of each shell, respectively. `v_boundary_inner` shows the velocity of the inner boundary of the computational domain, and `v_boundary_outer` shows the velocity of the outer boundary of the computational domain. Finally, `volume` shows the volume of each shell, calculated via the formula of the volume of a spherical shell: $V=\\frac{4}{3}\\pi (r_\\mathrm{outer}^3-r_\\mathrm{inner}^3)$."
]
},
{
Expand All @@ -103,7 +103,7 @@
"shell_config.model.structure.velocity.stop = 2000 * u.km/u.s\n",
"shell_config.model.structure.velocity.num = 20\n",
"\n",
"shell_model = Radial1DModel.from_config(shell_config)\n",
"shell_model = SimulationState.from_config(shell_config)\n",
"\n",
"print('velocity:\\n', shell_model.velocity)\n",
"print('v_inner:\\n', shell_model.v_inner)\n",
Expand Down Expand Up @@ -151,7 +151,7 @@
"\n",
"Since the state of the ejecta, including the density, is the same throughout the shell, we determine the shell's density by plugging the velocity/radius at the center of the shell into the density function. We now explore the various built-in density profiles. For each profile, we build an example model using the density profile and example parameters (which can be varied in interactive mode), print the densities in each shell, and show a graph of density versus radius (specifically the radius at the center of each shell).\n",
"\n",
"Note that the density in each shell is stored in the `density` attribute of the `Radial1DModel` object.\n",
"Note that the density in each shell is stored in the `density` attribute of the `SimulationState` object.\n",
"\n",
"### Branch85 W7 Density\n",
"\n",
Expand Down Expand Up @@ -181,7 +181,7 @@
"\n",
"w7_density_config.model.structure.density.type = 'branch85_w7'\n",
"\n",
"w7_density_model = Radial1DModel.from_config(w7_density_config)\n",
"w7_density_model = SimulationState.from_config(w7_density_config)\n",
"\n",
"print('density:\\n', w7_density_model.density)\n",
"\n",
Expand Down Expand Up @@ -209,7 +209,7 @@
"\n",
"w7_modified_config.supernova.time_explosion = 12 * u.day\n",
"\n",
"w7_modified_model = Radial1DModel.from_config(w7_modified_config)\n",
"w7_modified_model = SimulationState.from_config(w7_modified_config)\n",
"\n",
"print('density:\\n', w7_modified_model.density)\n",
"\n",
Expand Down Expand Up @@ -273,7 +273,7 @@
"uni_density_config.model.structure.density.time_0 = 1 * u.day\n",
"uni_density_config.model.structure.density.value = 5e-10 * u.kg/u.cm**3\n",
"\n",
"uni_density_model = Radial1DModel.from_config(uni_density_config)\n",
"uni_density_model = SimulationState.from_config(uni_density_config)\n",
"\n",
"print('density:\\n', uni_density_model.density)\n",
"\n",
Expand Down Expand Up @@ -327,7 +327,7 @@
"pow_density_config.model.structure.density.v_0 = 500 * u.km/u.s\n",
"pow_density_config.model.structure.density.exponent = -2\n",
"\n",
"pow_density_model = Radial1DModel.from_config(pow_density_config)\n",
"pow_density_model = SimulationState.from_config(pow_density_config)\n",
"\n",
"print('density:\\n', pow_density_model.density)\n",
"\n",
Expand Down Expand Up @@ -378,7 +378,7 @@
"exp_density_config.model.structure.density.rho_0 = 5e-10 * u.kg/u.cm**3\n",
"exp_density_config.model.structure.density.v_0 = 500 * u.km/u.s\n",
"\n",
"exp_density_model = Radial1DModel.from_config(exp_density_config)\n",
"exp_density_model = SimulationState.from_config(exp_density_config)\n",
"\n",
"print('density:\\n', exp_density_model.density)\n",
"\n",
Expand All @@ -394,11 +394,11 @@
"source": [
"## Abundance\n",
"\n",
"The `Radial1DModel` also carries important information about elemental abundances in each shell. These are mass abundances -- that is, the abundance of oxygen is the fraction of the shell's mass that is made up of oxygen.\n",
"The `SimulationState` also carries important information about elemental abundances in each shell. These are mass abundances -- that is, the abundance of oxygen is the fraction of the shell's mass that is made up of oxygen.\n",
"\n",
"The only built-in abundance model that TARDIS offers is a uniform abundance, meaning each shell has identical abundances. Like density, however, the [file abundance](../../io/configuration/components/models/index.rst#file-abundance), [CSVY model](../../io/configuration/components/models/index.rst#csvy-model), and [custom abundance widget](../../io/visualization/abundance_widget.ipynb) methods allow users more freedom with assigning different abundances in each shell.\n",
"\n",
"A table of abundances in each shell is stored in the `abundance` attribute of the `Radial1DModel` object.\n",
"A table of abundances in each shell is stored in the `abundance` attribute of the `SimulationState` object.\n",
"\n",
"In this first example, the abundances in each shell do not depend on the time after the explosion and are identical to those provided in the configuration."
]
Expand All @@ -423,7 +423,7 @@
" 'Si':.3,\n",
" 'He': .1}\n",
"\n",
"abund_model = Radial1DModel.from_config(abund_config)\n",
"abund_model = SimulationState.from_config(abund_config)\n",
"\n",
"abund_model.abundance"
]
Expand Down Expand Up @@ -459,7 +459,7 @@
" 'Ni57':.1,\n",
" 'Cr51':.4}\n",
"\n",
"abund_isotopes_model = Radial1DModel.from_config(abund_isotopes_config)\n",
"abund_isotopes_model = SimulationState.from_config(abund_isotopes_config)\n",
"\n",
"abund_isotopes_model.abundance"
]
Expand Down Expand Up @@ -527,7 +527,7 @@
"t_rad_config.model.structure.velocity.stop = 2000 * u.km/u.s\n",
"t_rad_config.model.structure.velocity.num = 20\n",
"\n",
"t_rad_model = Radial1DModel.from_config(t_rad_config)\n",
"t_rad_model = SimulationState.from_config(t_rad_config)\n",
"\n",
"print('t_inner:\\n', t_rad_model.t_inner)\n",
"print('t_rad:\\n', t_rad_model.t_rad)\n",
Expand Down Expand Up @@ -590,7 +590,7 @@
"w_config.model.structure.velocity.stop = 2000 * u.km/u.s\n",
"w_config.model.structure.velocity.num = 20\n",
"\n",
"w_model = Radial1DModel.from_config(w_config)\n",
"w_model = SimulationState.from_config(w_config)\n",
"\n",
"print('w:\\n', w_model.w)\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/physics/setup/setup_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"id": "e3f86364",
"metadata": {},
"source": [
"When the `Simulation` object is created, a `Radial1DModel`, `BasePlasma`, and `MontecarloTransport` object are created and stored as attributes of the `Simulation` object."
"When the `Simulation` object is created, a `SimulationState`, `BasePlasma`, and `MontecarloTransport` object are created and stored as attributes of the `Simulation` object."
]
},
{
Expand All @@ -82,7 +82,7 @@
"metadata": {},
"outputs": [],
"source": [
"sim.model"
"sim.simulation_state"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/physics/update_and_conv/update_and_conv.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
"source": [
"sim = Simulation.from_config(tardis_config)\n",
"\n",
"model = sim.model\n",
"model = sim.simulation_state\n",
"plasma = sim.plasma\n",
"transport = sim.transport"
]
Expand Down
2 changes: 1 addition & 1 deletion tardis/analysis/opacities.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class opacity_calculator(object):
Parameters
----------
mdl : tardis.model.Radial1DModel
mdl : tardis.model.SimulationState
model object of the Tardis run
nbins : int
number of bins of the frequency grid (default 300)
Expand Down
2 changes: 1 addition & 1 deletion tardis/energy_input/gamma_ray_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def main_gamma_ray_loop(
----------
num_decays : int
Number of decays requested
model : tardis.Radial1DModel
model : tardis.SimulationState
The tardis model to calculate gamma ray propagation through
plasma : tardis.plasma.BasePlasma
The tardis plasma with calculated atomic number density
Expand Down
Loading

0 comments on commit f89e125

Please sign in to comment.