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

move users of build_sim_object to use create method #661

Merged
merged 1 commit into from
Jan 17, 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
12 changes: 2 additions & 10 deletions docs/model_integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,6 @@ the |torax.sim.Sim|_ object.

.. code-block:: python

# in sim.py. Copied here for reference, no need to modify this.

def build_sim_object(
...
transport_model_builder: transport_model_lib.TransportModelBuilder,
...
) -> Sim:

# in your TORAX configuration or run file .py

my_custom_transport_builder = MyCustomTransportModelBuilder()
Expand All @@ -334,7 +326,7 @@ the |torax.sim.Sim|_ object.
my_custom_transport_builder.runtime_params.bar = 4.0

# Build the Sim object.
sim_object = sim_lib.build_sim_object(
sim_object = sim_lib.Sim.create(
...,
transport_model_builder=my_custom_transport_builder,
...
Expand All @@ -348,7 +340,7 @@ As of 7 June 2024, you cannot instantiate and configure a custom transport model
via the config dictionary. You may still configure the other components of your
TORAX simulation via the config dict and use other functions in
|torax.config.build_sim|_ to convert those to the objects you can pass into
``build_sim_object()``. We are working on making this easier, but reach out
``Sim.create()``. We are working on making this easier, but reach out
if this is something you need.


Expand Down
2 changes: 1 addition & 1 deletion torax/config/build_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def build_sim_from_config(
else:
file_restart = None

return sim_lib.build_sim_object(
return sim_lib.Sim.create(
runtime_params=runtime_params,
geometry_provider=geo_provider,
source_models_builder=build_sources_builder_from_config(
Expand Down
23 changes: 0 additions & 23 deletions torax/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,29 +1042,6 @@ def _override_initial_state_post_processed_outputs_from_file(
return post_processed_outputs


def build_sim_object(
runtime_params: general_runtime_params.GeneralRuntimeParams,
geometry_provider: geometry_provider_lib.GeometryProvider,
stepper_builder: stepper_lib.StepperBuilder,
transport_model_builder: transport_model_lib.TransportModelBuilder,
source_models_builder: source_models_lib.SourceModelsBuilder,
pedestal_model_builder: pedestal_model_lib.PedestalModelBuilder,
time_step_calculator: Optional[ts.TimeStepCalculator] = None,
file_restart: Optional[general_runtime_params.FileRestart] = None,
) -> Sim:
"""Builds a Sim object from the input runtime params and sim components."""
return Sim.create(
runtime_params=runtime_params,
geometry_provider=geometry_provider,
stepper_builder=stepper_builder,
transport_model_builder=transport_model_builder,
source_models_builder=source_models_builder,
pedestal_model_builder=pedestal_model_builder,
time_step_calculator=time_step_calculator,
file_restart=file_restart,
)


def _run_simulation(
static_runtime_params_slice: runtime_params_slice.StaticRuntimeParamsSlice,
dynamic_runtime_params_slice_provider: runtime_params_slice.DynamicRuntimeParamsSliceProvider,
Expand Down
2 changes: 1 addition & 1 deletion torax/tests/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def test_no_op(self):
geometry.build_circular_geometry()
)

sim = sim_lib.build_sim_object(
sim = sim_lib.Sim.create(
runtime_params=runtime_params,
geometry_provider=geo_provider,
stepper_builder=linear_theta_method.LinearThetaMethodBuilder(),
Expand Down
2 changes: 1 addition & 1 deletion torax/tests/sim_custom_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def custom_source_formula(
geo_provider = geometry_provider.ConstantGeometryProvider(
geometry.build_circular_geometry()
)
sim = sim_lib.build_sim_object(
sim = sim_lib.Sim.create(
runtime_params=self.test_particle_sources_constant_runtime_params,
geometry_provider=geo_provider,
stepper_builder=self.stepper_builder,
Expand Down
2 changes: 1 addition & 1 deletion torax/tests/sim_time_dependence.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_time_dependent_params_update_in_adaptive_dt(
# max combined value of Ti_bound_right should be 2.5. Higher will make the
# error state from the stepper be 1.
time_calculator = fixed_time_step_calculator.FixedTimeStepCalculator()
sim = sim_lib.build_sim_object(
sim = sim_lib.Sim.create(
runtime_params=runtime_params,
geometry_provider=geometry_provider,
stepper_builder=FakeStepperBuilder(
Expand Down
2 changes: 1 addition & 1 deletion torax/tests/test_data/test_explicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_sim() -> sim_lib.Sim:
# config taking place via constructor args in this function.
runtime_params = get_runtime_params()
geo_provider = get_geometry_provider()
return sim_lib.build_sim_object(
return sim_lib.Sim.create(
runtime_params=runtime_params,
geometry_provider=geo_provider,
source_models_builder=get_sources_builder(),
Expand Down
Loading