Skip to content

Commit

Permalink
Split sim.py into two and move some bits closer to the objects they r…
Browse files Browse the repository at this point in the history
…elate to

PiperOrigin-RevId: 715742159
  • Loading branch information
tamaranorman authored and Torax team committed Jan 21, 2025
1 parent 3b1857e commit ebaf4af
Show file tree
Hide file tree
Showing 8 changed files with 935 additions and 902 deletions.
18 changes: 18 additions & 0 deletions torax/config/runtime_params_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from torax.config import profile_conditions
from torax.config import runtime_params as general_runtime_params_lib
from torax.geometry import geometry
from torax.geometry import geometry_provider as geometry_provider_lib
from torax.pedestal_model import runtime_params as pedestal_model_params
from torax.sources import runtime_params as sources_params
from torax.stepper import runtime_params as stepper_params
Expand Down Expand Up @@ -354,6 +355,23 @@ def __call__(
)


def get_consistent_dynamic_runtime_params_slice_and_geometry(
*,
t: chex.Numeric,
dynamic_runtime_params_slice_provider: DynamicRuntimeParamsSliceProvider,
geometry_provider: geometry_provider_lib.GeometryProvider,
) -> tuple[DynamicRuntimeParamsSlice, geometry.Geometry]:
"""Returns the dynamic runtime params and geometry for a given time."""
geo = geometry_provider(t)
dynamic_runtime_params_slice = dynamic_runtime_params_slice_provider(
t=t,
)
dynamic_runtime_params_slice, geo = make_ip_consistent(
dynamic_runtime_params_slice, geo
)
return dynamic_runtime_params_slice, geo


def make_ip_consistent(
dynamic_runtime_params_slice: DynamicRuntimeParamsSlice,
geo: geometry.Geometry,
Expand Down
12 changes: 6 additions & 6 deletions torax/config/tests/build_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,12 @@ def test_chease_geometry_updates_Ip(self):
torax_mesh=geo_provider.torax_mesh,
)
)
geo = geo_provider(t=0)
dynamic_runtime_params_slice = runtime_params_provider(
t=0,
)
dynamic_slice, geo = runtime_params_slice.make_ip_consistent(
dynamic_runtime_params_slice, geo
dynamic_slice, geo = (
runtime_params_slice.get_consistent_dynamic_runtime_params_slice_and_geometry(
t=0,
dynamic_runtime_params_slice_provider=runtime_params_provider,
geometry_provider=geo_provider,
)
)
self.assertIsInstance(geo, geometry.StandardGeometry)
self.assertIsNotNone(dynamic_slice)
Expand Down
Loading

0 comments on commit ebaf4af

Please sign in to comment.