From 0fc432434043b09b11aa9972fa1c6cc3e95bfdc3 Mon Sep 17 00:00:00 2001 From: Akhil Raju Date: Thu, 25 Apr 2024 06:44:14 -0700 Subject: [PATCH] Move more config params to ProfileConditions. After this change, the `Config` object is fully organized. There aren't extraneous params at the top level anymore. PiperOrigin-RevId: 628058985 --- torax/config.py | 22 +++++----- torax/config_slice.py | 25 ++++++------ torax/core_profile_setters.py | 22 ++++++---- torax/sources/tests/formulas.py | 2 +- torax/tests/sim_custom_sources.py | 2 +- torax/tests/state.py | 40 ++++++++++++------- .../tests/test_data/compilation_benchmark.py | 2 +- torax/tests/test_data/test_absolute_jext.py | 6 +-- .../test_all_transport_crank_nicolson.py | 6 +-- .../test_all_transport_fusion_qlknn.py | 6 +-- torax/tests/test_data/test_bootstrap.py | 6 +-- torax/tests/test_data/test_exact_finaltime.py | 6 +-- torax/tests/test_data/test_fusion_power.py | 6 +-- .../test_data/test_ne_qlknn_deff_veff.py | 6 +-- .../test_data/test_ne_qlknn_defromchie.py | 6 +-- .../test_data/test_newton_raphson_zeroiter.py | 6 +-- .../test_data/test_optimizer_zeroiter.py | 6 +-- .../test_data/test_particle_sources_cgm.py | 6 +-- .../test_particle_sources_constant.py | 6 +-- torax/tests/test_data/test_pc_method_ne.py | 6 +-- torax/tests/test_data/test_psi_and_heat.py | 6 +-- torax/tests/test_data/test_psi_heat_dens.py | 6 +-- .../test_psichease_prescribed_johm.py | 6 +-- .../test_psichease_prescribed_jtot.py | 6 +-- torax/tests/test_data/test_psiequation.py | 6 +-- torax/tests/test_lib/torax_refs.py | 7 ++-- 26 files changed, 124 insertions(+), 106 deletions(-) diff --git a/torax/config.py b/torax/config.py index c084ea97..76e279a0 100644 --- a/torax/config.py +++ b/torax/config.py @@ -153,6 +153,17 @@ class ProfileConditions: # Set ped top location. Ped_top: TimeDependentField = 0.91 + # current profiles (broad "Ohmic" + localized "external" currents) + # peaking factor of "Ohmic" current: johm = j0*(1 - r^2/a^2)^nu + nu: float = 3.0 + # toggles if "Ohmic" current is treated as total current upon initialization, + # or if non-inductive current should be included in initial jtot calculation + initial_j_is_total_current: bool = False + # toggles if the initial psi calculation is based on the "nu" current formula, + # or from the psi available in the numerical geometry file. This setting is + # ignored for the ad-hoc circular geometry, which has no numerical geometry. + initial_psi_from_j: bool = False + @chex.dataclass class Numerics: @@ -233,17 +244,6 @@ class Config: ) numerics: Numerics = dataclasses.field(default_factory=Numerics) - # current profiles (broad "Ohmic" + localized "external" currents) - # peaking factor of "Ohmic" current: johm = j0*(1 - r^2/a^2)^nu - nu: float = 3.0 - # toggles if "Ohmic" current is treated as total current upon initialization, - # or if non-inductive current should be included in initial jtot calculation - initial_j_is_total_current: bool = False - # toggles if the initial psi calculation is based on the "nu" current formula, - # or from the psi available in the numerical geometry file. This setting is - # ignored for the ad-hoc circular geometry, which has no numerical geometry. - initial_psi_from_j: bool = False - # solver parameters solver: SolverConfig = dataclasses.field(default_factory=SolverConfig) diff --git a/torax/config_slice.py b/torax/config_slice.py index fafa5f48..48801c6a 100644 --- a/torax/config_slice.py +++ b/torax/config_slice.py @@ -78,19 +78,6 @@ class DynamicConfigSlice: numerics: DynamicNumerics sources: Mapping[str, sources_params.DynamicRuntimeParams] - # current profiles (broad "Ohmic" + localized "external" currents) - - # peaking factor of prescribed (initial) "Ohmic" current: - # johm = j0*(1 - r^2/a^2)^nu - nu: float - # toggles if "Ohmic" current is treated as total current upon initialization, - # or if non-inductive current should be included in initial jtot calculation - initial_j_is_total_current: bool - # toggles if the initial psi calculation is based on the "nu" current formula, - # or from the psi available in the numerical geometry file. This setting is - # ignored for the ad-hoc circular geometry, which has no numerical geometry. - initial_psi_from_j: bool - @chex.dataclass(frozen=True) class DynamicSolverConfigSlice: @@ -167,6 +154,18 @@ class DynamicProfileConditions: # Set ped top location. Ped_top: float + # current profiles (broad "Ohmic" + localized "external" currents) + # peaking factor of prescribed (initial) "Ohmic" current: + # johm = j0*(1 - r^2/a^2)^nu + nu: float + # toggles if "Ohmic" current is treated as total current upon initialization, + # or if non-inductive current should be included in initial jtot calculation + initial_j_is_total_current: bool + # toggles if the initial psi calculation is based on the "nu" current formula, + # or from the psi available in the numerical geometry file. This setting is + # ignored for the ad-hoc circular geometry, which has no numerical geometry. + initial_psi_from_j: bool + @chex.dataclass class DynamicNumerics: diff --git a/torax/core_profile_setters.py b/torax/core_profile_setters.py index 5545bcce..d51cbcfa 100644 --- a/torax/core_profile_setters.py +++ b/torax/core_profile_setters.py @@ -211,10 +211,12 @@ def _prescribe_currents_no_bootstrap( ) # construct prescribed current formula on grid. - jformula_face = (1 - geo.r_face_norm**2) ** dynamic_config_slice.nu + jformula_face = ( + 1 - geo.r_face_norm**2 + ) ** dynamic_config_slice.profile_conditions.nu # calculate total and Ohmic current profiles denom = _trapz(jformula_face * geo.spr_face, geo.r_face) - if dynamic_config_slice.initial_j_is_total_current: + if dynamic_config_slice.profile_conditions.initial_j_is_total_current: Ctot = Ip * 1e6 / denom jtot_face = jformula_face * Ctot johm_face = jtot_face - jext_face @@ -318,10 +320,12 @@ def _prescribe_currents_with_bootstrap( ) # construct prescribed current formula on grid. - jformula_face = (1 - geo.r_face_norm**2) ** dynamic_config_slice.nu + jformula_face = ( + 1 - geo.r_face_norm**2 + ) ** dynamic_config_slice.profile_conditions.nu denom = _trapz(jformula_face * geo.spr_face, geo.r_face) # calculate total and Ohmic current profiles - if dynamic_config_slice.initial_j_is_total_current: + if dynamic_config_slice.profile_conditions.initial_j_is_total_current: Ctot = Ip * 1e6 / denom jtot_face = jformula_face * Ctot johm_face = jtot_face - jext_face - bootstrap_profile.j_bootstrap_face @@ -548,7 +552,7 @@ def initial_core_profiles( # set up initial psi profile based on current profile if ( isinstance(geo, geometry.CircularGeometry) - or dynamic_config_slice.initial_psi_from_j + or dynamic_config_slice.profile_conditions.initial_psi_from_j ): # set up initial current profile without bootstrap current, to get # q-profile approximation (needed for bootstrap) @@ -593,7 +597,7 @@ def initial_core_profiles( elif ( isinstance(geo, geometry.CHEASEGeometry) - and not dynamic_config_slice.initial_psi_from_j + and not dynamic_config_slice.profile_conditions.initial_psi_from_j ): # psi is already provided from the CHEASE equilibrium, so no need to first # calculate currents. However, non-inductive currents are still calculated @@ -868,9 +872,11 @@ def _get_jtot_hires( ) # calculate high resolution jtot and Ohmic current profile - jformula_hires = (1 - geo.r_hires_norm**2) ** dynamic_config_slice.nu + jformula_hires = ( + 1 - geo.r_hires_norm**2 + ) ** dynamic_config_slice.profile_conditions.nu denom = _trapz(jformula_hires * geo.spr_hires, geo.r_hires) - if dynamic_config_slice.initial_j_is_total_current: + if dynamic_config_slice.profile_conditions.initial_j_is_total_current: Ctot_hires = dynamic_config_slice.profile_conditions.Ip * 1e6 / denom jtot_hires = jformula_hires * Ctot_hires else: diff --git a/torax/sources/tests/formulas.py b/torax/sources/tests/formulas.py index 25c99ac3..70a0c813 100644 --- a/torax/sources/tests/formulas.py +++ b/torax/sources/tests/formulas.py @@ -52,6 +52,7 @@ def test_custom_exponential_source_can_replace_puff_source(self): profile_conditions=config_lib.ProfileConditions( set_pedestal=True, nbar=0.85, + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -61,7 +62,6 @@ def test_custom_exponential_source_can_replace_puff_source(self): resistivity_mult=100, t_final=2, ), - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, ), diff --git a/torax/tests/sim_custom_sources.py b/torax/tests/sim_custom_sources.py index 3a00c2e7..75bfeae3 100644 --- a/torax/tests/sim_custom_sources.py +++ b/torax/tests/sim_custom_sources.py @@ -159,6 +159,7 @@ def custom_source_formula( profile_conditions=config_lib.ProfileConditions( set_pedestal=True, nbar=0.85, + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -168,7 +169,6 @@ def custom_source_formula( resistivity_mult=100, t_final=2, ), - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, ), diff --git a/torax/tests/state.py b/torax/tests/state.py index 7e6280b6..9faa4bec 100644 --- a/torax/tests/state.py +++ b/torax/tests/state.py @@ -186,25 +186,33 @@ def test_initial_psi_from_j( ): """Tests expected behaviour of initial psi and current options.""" config1 = config_lib.Config( - initial_j_is_total_current=True, - initial_psi_from_j=True, - nu=2, + profile_conditions=config_lib.ProfileConditions( + initial_j_is_total_current=True, + initial_psi_from_j=True, + nu=2, + ), ) config2 = config_lib.Config( - initial_j_is_total_current=False, - initial_psi_from_j=True, - nu=2, + profile_conditions=config_lib.ProfileConditions( + initial_j_is_total_current=False, + initial_psi_from_j=True, + nu=2, + ), ) config3 = config_lib.Config( - initial_j_is_total_current=False, - initial_psi_from_j=True, - nu=2, + profile_conditions=config_lib.ProfileConditions( + initial_j_is_total_current=False, + initial_psi_from_j=True, + nu=2, + ), ) # Needed to generate psi for bootstrap calculation config3_helper = config_lib.Config( - initial_j_is_total_current=True, - initial_psi_from_j=True, - nu=2, + profile_conditions=config_lib.ProfileConditions( + initial_j_is_total_current=True, + initial_psi_from_j=True, + nu=2, + ), ) geo = geo_builder(config1) source_models = source_models_lib.SourceModels() @@ -325,13 +333,17 @@ def test_initial_psi_from_geo_noop_circular(self): """Tests expected behaviour of initial psi and current options.""" source_models = source_models_lib.SourceModels() config1 = config_lib.Config( - initial_psi_from_j=False, + profile_conditions=config_lib.ProfileConditions( + initial_psi_from_j=False, + ), ) dcs1 = config_slice.build_dynamic_config_slice( config1, sources=source_models.runtime_params ) config2 = config_lib.Config( - initial_psi_from_j=True, + profile_conditions=config_lib.ProfileConditions( + initial_psi_from_j=True, + ), ) dcs2 = config_slice.build_dynamic_config_slice( config2, sources=source_models.runtime_params diff --git a/torax/tests/test_data/compilation_benchmark.py b/torax/tests/test_data/compilation_benchmark.py index 2a0a6426..95a2664a 100644 --- a/torax/tests/test_data/compilation_benchmark.py +++ b/torax/tests/test_data/compilation_benchmark.py @@ -40,6 +40,7 @@ def get_config() -> config_lib.Config: nbar=0.85, # initial density (Greenwald fraction units) ne_bound_right=0.2, neped=1.0, + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -49,7 +50,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=0.0007944 * 2, ), - nu=0, solver=config_lib.SolverConfig( use_pereverzev=False, ), diff --git a/torax/tests/test_data/test_absolute_jext.py b/torax/tests/test_data/test_absolute_jext.py index 0978bbde..a0037487 100644 --- a/torax/tests/test_data/test_absolute_jext.py +++ b/torax/tests/test_data/test_absolute_jext.py @@ -36,15 +36,15 @@ def get_config() -> config_lib.Config: profile_conditions=config_lib.ProfileConditions( Ti_bound_left=8, Te_bound_left=8, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( current_eq=True, resistivity_mult=100, # to shorten current diffusion time t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_all_transport_crank_nicolson.py b/torax/tests/test_data/test_all_transport_crank_nicolson.py index 1c31cec0..7a9f7f83 100644 --- a/torax/tests/test_data/test_all_transport_crank_nicolson.py +++ b/torax/tests/test_data/test_all_transport_crank_nicolson.py @@ -37,6 +37,9 @@ def get_config() -> config_lib.Config: nbar=0.85, # initial density (using Greenwald fraction default) ne_bound_right=0.2, neped=1.0, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -47,9 +50,6 @@ def get_config() -> config_lib.Config: t_final=2, largeValue_n=1.0e5, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_all_transport_fusion_qlknn.py b/torax/tests/test_data/test_all_transport_fusion_qlknn.py index 08effacd..99e72402 100644 --- a/torax/tests/test_data/test_all_transport_fusion_qlknn.py +++ b/torax/tests/test_data/test_all_transport_fusion_qlknn.py @@ -36,6 +36,9 @@ def get_config() -> config_lib.Config: nbar=0.85, # initial density (Greenwald fraction units) ne_bound_right=0.2, neped=1.0, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -45,9 +48,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_bootstrap.py b/torax/tests/test_data/test_bootstrap.py index c67ea724..433c52b0 100644 --- a/torax/tests/test_data/test_bootstrap.py +++ b/torax/tests/test_data/test_bootstrap.py @@ -32,6 +32,9 @@ def get_config() -> config_lib.Config: profile_conditions=config_lib.ProfileConditions( set_pedestal=False, nbar=0.85, # initial density (in Greenwald fraction units) + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -41,9 +44,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=1, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, ), diff --git a/torax/tests/test_data/test_exact_finaltime.py b/torax/tests/test_data/test_exact_finaltime.py index 6b563a64..0a3fb182 100644 --- a/torax/tests/test_data/test_exact_finaltime.py +++ b/torax/tests/test_data/test_exact_finaltime.py @@ -29,6 +29,9 @@ def get_config() -> config_lib.Config: profile_conditions=config_lib.ProfileConditions( Ti_bound_left=8, Te_bound_left=8, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( current_eq=True, @@ -36,9 +39,6 @@ def get_config() -> config_lib.Config: t_final=2, exact_t_final=True, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_fusion_power.py b/torax/tests/test_data/test_fusion_power.py index 3c401b77..0531cf61 100644 --- a/torax/tests/test_data/test_fusion_power.py +++ b/torax/tests/test_data/test_fusion_power.py @@ -36,6 +36,9 @@ def get_config() -> config_lib.Config: nbar=0.85, # initial density (in Greenwald fraction units) ne_bound_right=0.2, neped=1.0, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -45,9 +48,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=1, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_ne_qlknn_deff_veff.py b/torax/tests/test_data/test_ne_qlknn_deff_veff.py index ae26d42d..4364163b 100644 --- a/torax/tests/test_data/test_ne_qlknn_deff_veff.py +++ b/torax/tests/test_data/test_ne_qlknn_deff_veff.py @@ -36,6 +36,9 @@ def get_config() -> config_lib.Config: nbar=0.85, # initial density (in Greenwald fraction units) ne_bound_right=0.2, neped=1.0, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -45,9 +48,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_ne_qlknn_defromchie.py b/torax/tests/test_data/test_ne_qlknn_defromchie.py index 8ad0dcd4..0e36107d 100644 --- a/torax/tests/test_data/test_ne_qlknn_defromchie.py +++ b/torax/tests/test_data/test_ne_qlknn_defromchie.py @@ -36,6 +36,9 @@ def get_config() -> config_lib.Config: nbar=0.85, # initial density (using default Greenwald fraction) ne_bound_right=0.2, neped=1.0, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -45,9 +48,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_newton_raphson_zeroiter.py b/torax/tests/test_data/test_newton_raphson_zeroiter.py index 47896bae..7b86e452 100644 --- a/torax/tests/test_data/test_newton_raphson_zeroiter.py +++ b/torax/tests/test_data/test_newton_raphson_zeroiter.py @@ -73,6 +73,9 @@ def get_config() -> config_lib.Config: profile_conditions=config_lib.ProfileConditions( Ti_bound_left=8, Te_bound_left=8, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( current_eq=True, @@ -81,9 +84,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_optimizer_zeroiter.py b/torax/tests/test_data/test_optimizer_zeroiter.py index 446cd17c..0a44c50a 100644 --- a/torax/tests/test_data/test_optimizer_zeroiter.py +++ b/torax/tests/test_data/test_optimizer_zeroiter.py @@ -66,6 +66,9 @@ def get_config() -> config_lib.Config: profile_conditions=config_lib.ProfileConditions( Ti_bound_left=8, Te_bound_left=8, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( current_eq=True, @@ -74,9 +77,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_particle_sources_cgm.py b/torax/tests/test_data/test_particle_sources_cgm.py index 3a284d8d..4ed483f8 100644 --- a/torax/tests/test_data/test_particle_sources_cgm.py +++ b/torax/tests/test_data/test_particle_sources_cgm.py @@ -34,6 +34,9 @@ def get_config() -> config_lib.Config: nbar=0.85, # initial density (in Greenwald fraction units) ne_bound_right=0.2, neped=1.0, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -43,9 +46,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_particle_sources_constant.py b/torax/tests/test_data/test_particle_sources_constant.py index 97456bb9..d99411ef 100644 --- a/torax/tests/test_data/test_particle_sources_constant.py +++ b/torax/tests/test_data/test_particle_sources_constant.py @@ -32,6 +32,9 @@ def get_config() -> config_lib.Config: profile_conditions=config_lib.ProfileConditions( set_pedestal=True, nbar=0.85, # initial density (Greenwald fraction units) + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -42,9 +45,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, ), diff --git a/torax/tests/test_data/test_pc_method_ne.py b/torax/tests/test_data/test_pc_method_ne.py index 2cb315ef..3ea256cd 100644 --- a/torax/tests/test_data/test_pc_method_ne.py +++ b/torax/tests/test_data/test_pc_method_ne.py @@ -39,6 +39,9 @@ def get_config() -> config_lib.Config: nbar=0.85, # initial density (in Greenwald fraction units) ne_bound_right=0.2, neped=1.0, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -49,9 +52,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, t_final=2.0, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_psi_and_heat.py b/torax/tests/test_data/test_psi_and_heat.py index b029ffcc..da481480 100644 --- a/torax/tests/test_data/test_psi_and_heat.py +++ b/torax/tests/test_data/test_psi_and_heat.py @@ -33,15 +33,15 @@ def get_config() -> config_lib.Config: profile_conditions=config_lib.ProfileConditions( Ti_bound_left=8, Te_bound_left=8, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( current_eq=True, resistivity_mult=100, # to shorten current diffusion time t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, use_pereverzev=True, diff --git a/torax/tests/test_data/test_psi_heat_dens.py b/torax/tests/test_data/test_psi_heat_dens.py index a238edb3..881140b7 100644 --- a/torax/tests/test_data/test_psi_heat_dens.py +++ b/torax/tests/test_data/test_psi_heat_dens.py @@ -32,6 +32,9 @@ def get_config() -> config_lib.Config: profile_conditions=config_lib.ProfileConditions( set_pedestal=True, nbar=0.85, # initial density (in Greenwald fraction units) + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=True, @@ -41,9 +44,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=2, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, ), diff --git a/torax/tests/test_data/test_psichease_prescribed_johm.py b/torax/tests/test_data/test_psichease_prescribed_johm.py index f4757bc0..d443f907 100644 --- a/torax/tests/test_data/test_psichease_prescribed_johm.py +++ b/torax/tests/test_data/test_psichease_prescribed_johm.py @@ -31,6 +31,9 @@ def get_config() -> config_lib.Config: return config_lib.Config( profile_conditions=config_lib.ProfileConditions( set_pedestal=False, + initial_psi_from_j=True, + initial_j_is_total_current=False, + nu=2, ), numerics=config_lib.Numerics( ion_heat_eq=False, @@ -39,9 +42,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=3, ), - initial_psi_from_j=True, - initial_j_is_total_current=False, - nu=2, solver=config_lib.SolverConfig( predictor_corrector=False, ), diff --git a/torax/tests/test_data/test_psichease_prescribed_jtot.py b/torax/tests/test_data/test_psichease_prescribed_jtot.py index d39737fc..26413524 100644 --- a/torax/tests/test_data/test_psichease_prescribed_jtot.py +++ b/torax/tests/test_data/test_psichease_prescribed_jtot.py @@ -31,6 +31,9 @@ def get_config() -> config_lib.Config: return config_lib.Config( profile_conditions=config_lib.ProfileConditions( set_pedestal=False, + initial_psi_from_j=True, + initial_j_is_total_current=True, + nu=2, ), numerics=config_lib.Numerics( ion_heat_eq=False, @@ -39,9 +42,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=3, ), - initial_psi_from_j=True, - initial_j_is_total_current=True, - nu=2, solver=config_lib.SolverConfig( predictor_corrector=False, ), diff --git a/torax/tests/test_data/test_psiequation.py b/torax/tests/test_data/test_psiequation.py index 7a2de056..42eebcec 100644 --- a/torax/tests/test_data/test_psiequation.py +++ b/torax/tests/test_data/test_psiequation.py @@ -28,6 +28,9 @@ def get_config() -> config_lib.Config: return config_lib.Config( profile_conditions=config_lib.ProfileConditions( set_pedestal=False, + # set flat Ohmic current to provide larger range of current evolution + # for test + nu=0, ), numerics=config_lib.Numerics( ion_heat_eq=False, @@ -36,9 +39,6 @@ def get_config() -> config_lib.Config: resistivity_mult=100, # to shorten current diffusion time t_final=3, ), - # set flat Ohmic current to provide larger range of current evolution for - # test - nu=0, solver=config_lib.SolverConfig( predictor_corrector=False, ), diff --git a/torax/tests/test_lib/torax_refs.py b/torax/tests/test_lib/torax_refs.py index 0c4bb77e..a08a1710 100644 --- a/torax/tests/test_lib/torax_refs.py +++ b/torax/tests/test_lib/torax_refs.py @@ -53,12 +53,12 @@ def circular_references() -> References: **{ 'profile_conditions': { 'Ip': 15, + 'nu': 3, }, 'numerics': { 'nr': 25, 'q_correction_factor': 1.0, }, - 'nu': 3, }, ) geo = geometry.build_circular_geometry( @@ -205,12 +205,12 @@ def chease_references_Ip_from_chease() -> References: # pylint: disable=invalid **{ 'profile_conditions': { 'Ip': 15, + 'nu': 3, }, 'numerics': { 'nr': 25, 'q_correction_factor': 1.0, }, - 'nu': 3, }, ) geo = geometry.build_chease_geometry( @@ -358,12 +358,12 @@ def chease_references_Ip_from_config() -> References: # pylint: disable=invalid **{ 'profile_conditions': { 'Ip': 15, + 'nu': 3, }, 'numerics': { 'nr': 25, 'q_correction_factor': 1.0, }, - 'nu': 3, }, ) geo = geometry.build_chease_geometry( @@ -520,5 +520,6 @@ def setUp(self): ) # pylint: enable=invalid-name + if __name__ == '__main__': absltest.main()