15
15
from absl .testing import absltest
16
16
from absl .testing import parameterized
17
17
from torax .config import build_runtime_params
18
- from torax .config import numerics as numerics_lib
19
- from torax .config import profile_conditions as profile_conditions_lib
20
- from torax .config import runtime_params as general_runtime_params
21
18
from torax .core_profiles import initialization
22
19
from torax .fvm import calc_coeffs
23
- from torax .geometry import pydantic_model as geometry_pydantic_model
24
- from torax .pedestal_model import pydantic_model as pedestal_pydantic_model
25
- from torax .sources import pydantic_model as sources_pydantic_model
26
20
from torax .sources import runtime_params as source_runtime_params
27
21
from torax .sources import source_models as source_models_lib
28
22
from torax .sources import source_profile_builders
29
- from torax .stepper import pydantic_model as stepper_pydantic_model
30
23
from torax .tests .test_lib import default_sources
31
- from torax .transport_model import pydantic_model as transport_pydantic_model
24
+ from torax .torax_pydantic import model_config
32
25
33
26
34
27
class CoreProfileSettersTest (parameterized .TestCase ):
@@ -42,66 +35,55 @@ class CoreProfileSettersTest(parameterized.TestCase):
42
35
def test_calc_coeffs_smoke_test (
43
36
self , num_cells , theta_imp , set_pedestal
44
37
):
45
- runtime_params = general_runtime_params .GeneralRuntimeParams (
46
- profile_conditions = profile_conditions_lib .ProfileConditions (
47
- set_pedestal = set_pedestal ,
48
- ),
49
- numerics = numerics_lib .Numerics (
50
- el_heat_eq = False ,
51
- ),
52
- )
53
- stepper_params = stepper_pydantic_model .Stepper .from_dict (
54
- dict (
55
- predictor_corrector = False ,
56
- theta_imp = theta_imp ,
57
- )
58
- )
59
- geo = geometry_pydantic_model .CircularConfig (
60
- n_rho = num_cells
61
- ).build_geometry ()
62
-
63
- transport = transport_pydantic_model .Transport .from_dict (
64
- {'transport_model' : 'constant' , 'chimin' : 0 , 'chii_const' : 1 }
65
- )
66
- pedestal = pedestal_pydantic_model .Pedestal ()
67
- pedestal_model = pedestal .build_pedestal_model ()
68
- transport_model = transport .build_transport_model ()
69
- sources = default_sources .get_default_sources ()
70
- sources_dict = sources .to_dict ()
71
- sources_dict ['qei_source' ]['Qei_mult' ] = 0.0
72
- sources_dict ['generic_ion_el_heat_source' ]['Ptot' ] = (
73
- 0.0
74
- )
75
- sources_dict ['fusion_heat_source' ]['mode' ] = (
38
+ sources_config = default_sources .get_default_source_config ()
39
+ sources_config ['qei_source' ]['Qei_mult' ] = 0.0
40
+ sources_config ['generic_ion_el_heat_source' ]['Ptot' ] = 0.0
41
+ sources_config ['fusion_heat_source' ]['mode' ] = (
76
42
source_runtime_params .Mode .ZERO
77
43
)
78
- sources_dict ['ohmic_heat_source' ]['mode' ] = (
44
+ sources_config ['ohmic_heat_source' ]['mode' ] = (
79
45
source_runtime_params .Mode .ZERO
80
46
)
81
- sources = sources_pydantic_model .Sources .from_dict (sources_dict )
47
+ torax_config = model_config .ToraxConfig .from_dict (
48
+ dict (
49
+ runtime_params = dict (
50
+ profile_conditions = dict (set_pedestal = set_pedestal ),
51
+ numerics = dict (el_heat_eq = False ),
52
+ ),
53
+ geometry = dict (geometry_type = 'circular' , n_rho = num_cells ),
54
+ pedestal = dict (),
55
+ sources = sources_config ,
56
+ stepper = dict (predictor_corrector = False , theta_imp = theta_imp ),
57
+ transport = dict (transport_model = 'constant' , chimin = 0 , chii_const = 1 ),
58
+ time_step_calculator = dict (),
59
+ )
60
+ )
82
61
source_models = source_models_lib .SourceModels (
83
- sources = sources .source_model_config
62
+ sources = torax_config . sources .source_model_config
84
63
)
85
64
dynamic_runtime_params_slice = (
86
65
build_runtime_params .DynamicRuntimeParamsSliceProvider (
87
- runtime_params ,
88
- transport = transport ,
89
- sources = sources ,
90
- stepper = stepper_params ,
91
- pedestal = pedestal ,
92
- torax_mesh = geo .torax_mesh ,
66
+ torax_config . runtime_params ,
67
+ transport = torax_config . transport ,
68
+ sources = torax_config . sources ,
69
+ stepper = torax_config . stepper ,
70
+ pedestal = torax_config . pedestal ,
71
+ torax_mesh = torax_config . geometry . build_provider .torax_mesh ,
93
72
)(
94
- t = runtime_params .numerics .t_initial ,
73
+ t = torax_config .numerics .t_initial ,
95
74
)
96
75
)
97
76
static_runtime_params_slice = (
98
77
build_runtime_params .build_static_runtime_params_slice (
99
- runtime_params = runtime_params ,
100
- sources = sources ,
101
- torax_mesh = geo .torax_mesh ,
102
- stepper = stepper_params ,
78
+ profile_conditions = torax_config .profile_conditions ,
79
+ numerics = torax_config .numerics ,
80
+ plasma_composition = torax_config .plasma_composition ,
81
+ sources = torax_config .sources ,
82
+ torax_mesh = torax_config .geometry .build_provider .torax_mesh ,
83
+ stepper = torax_config .stepper ,
103
84
)
104
85
)
86
+ geo = torax_config .geometry .build_provider (torax_config .numerics .t_initial )
105
87
core_profiles = initialization .initial_core_profiles (
106
88
static_runtime_params_slice ,
107
89
dynamic_runtime_params_slice ,
@@ -117,6 +99,8 @@ def test_calc_coeffs_smoke_test(
117
99
core_profiles = core_profiles ,
118
100
explicit = True ,
119
101
)
102
+ pedestal_model = torax_config .pedestal .build_pedestal_model ()
103
+ transport_model = torax_config .transport .build_transport_model ()
120
104
calc_coeffs .calc_coeffs (
121
105
static_runtime_params_slice = static_runtime_params_slice ,
122
106
dynamic_runtime_params_slice = dynamic_runtime_params_slice ,
0 commit comments