3232from torax ._src .geometry import standard_geometry
3333from torax ._src .neoclassical import neoclassical_models as neoclassical_models_lib
3434from torax ._src .neoclassical .bootstrap_current import base as bootstrap_current_base
35+ from torax ._src .physics import formulas
3536from torax ._src .physics import psi_calculations
3637from torax ._src .sources import source_models as source_models_lib
3738from torax ._src .sources import source_profile_builders
@@ -69,7 +70,9 @@ def initial_core_profiles(
6970 runtime_params .profile_conditions , geo
7071 )
7172 ions = getters .get_updated_ions (runtime_params , geo , n_e , T_e )
72-
73+ toroidal_velocity = getters .get_updated_toroidal_velocity (
74+ runtime_params .profile_conditions , geo
75+ )
7376 # Set v_loop_lcfs. Two branches:
7477 # 1. Set the v_loop_lcfs from profile_conditions if using the v_loop BC option
7578 # 2. Initialize v_loop_lcfs to 0 if using the Ip boundary condition for psi.
@@ -95,6 +98,20 @@ def initial_core_profiles(
9598 dr = geo .drho_norm ,
9699 )
97100
101+ poloidal_velocity = cell_variable .CellVariable (
102+ value = jnp .zeros_like (geo .rho ),
103+ dr = geo .drho_norm ,
104+ right_face_constraint = 0.0 ,
105+ right_face_grad_constraint = None ,
106+ )
107+
108+ radial_electric_field = cell_variable .CellVariable (
109+ value = jnp .zeros_like (geo .rho ),
110+ dr = geo .drho_norm ,
111+ right_face_constraint = 0.0 ,
112+ right_face_grad_constraint = None ,
113+ )
114+
98115 core_profiles = state .CoreProfiles (
99116 T_i = T_i ,
100117 T_e = T_e ,
@@ -121,6 +138,9 @@ def initial_core_profiles(
121138 j_total = jnp .zeros_like (geo .rho , dtype = jax_utils .get_dtype ()),
122139 j_total_face = jnp .zeros_like (geo .rho_face , dtype = jax_utils .get_dtype ()),
123140 Ip_profile_face = jnp .zeros_like (geo .rho_face , dtype = jax_utils .get_dtype ()),
141+ toroidal_velocity = toroidal_velocity ,
142+ poloidal_velocity = poloidal_velocity ,
143+ radial_electric_field = radial_electric_field ,
124144 )
125145
126146 return _init_psi_and_psi_derived (
@@ -434,6 +454,12 @@ def _calculate_all_psi_dependent_profiles(
434454 core_profiles ,
435455 )
436456
457+ # TODO(b/456456279): Make sure poloidal_velocity has been updated.
458+ # Calculate radial electric field
459+ radial_electric_field = formulas .calculate_radial_electric_field (
460+ core_profiles , geo
461+ )
462+
437463 # Calculate sources if they have not already been calculated.
438464 if not sources_are_calculated :
439465 source_profiles = _get_bootstrap_and_standard_source_profiles (
@@ -485,6 +511,7 @@ def _calculate_all_psi_dependent_profiles(
485511 psidot = psidot ,
486512 sigma = conductivity .sigma ,
487513 sigma_face = conductivity .sigma_face ,
514+ radial_electric_field = radial_electric_field ,
488515 )
489516 return core_profiles
490517
0 commit comments