Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split sim.py into two and move some bits closer to the objects they relate to #663

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading