Skip to content

Commit

Permalink
Simplify case 2, as psi_from_Ip is already consistent with Ip_tot
Browse files Browse the repository at this point in the history
  • Loading branch information
theo-brown committed Feb 13, 2025
1 parent 986f3ec commit 3816503
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions torax/core_profile_setters.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,26 +577,13 @@ def _init_psi_and_current(
geo,
)

# Set the BCs, with the option of scaling to the given Ip_tot
if use_vloop_bc and geo.Ip_from_parameters:
# Extrapolate the value of psi at the LCFS from the dpsi/drho constraint
right_face_grad_constraint = None
right_face_constraint = (
geo.psi_from_Ip[-1] + dpsi_drhonorm_edge * geo.drho_norm / 2
)
elif use_vloop_bc:
# Use the psi from the equilibrium as the right face constraint
right_face_grad_constraint = None
right_face_constraint = geo.psi_from_Ip[-1]
else:
# Use the dpsi/drho calculated above as the right face gradient constraint
right_face_grad_constraint = dpsi_drhonorm_edge
right_face_constraint = None

# Use the psi from the equilibrium as the right face constraint
# This has already been made consistent with the desired Ip_tot
# by make_ip_consistent
psi = cell_variable.CellVariable(
value=geo.psi_from_Ip, # Use psi from equilibrium
right_face_grad_constraint=right_face_grad_constraint,
right_face_constraint=right_face_constraint,
right_face_grad_constraint=None if use_vloop_bc else dpsi_drhonorm_edge,
right_face_constraint=geo.psi_from_Ip[-1] if use_vloop_bc else None,
dr=geo.drho_norm,
)
core_profiles = dataclasses.replace(core_profiles, psi=psi)
Expand Down

0 comments on commit 3816503

Please sign in to comment.