Skip to content

Commit

Permalink
✅ fix unit tests and fix bug in integral
Browse files Browse the repository at this point in the history
  • Loading branch information
apearce committed Nov 22, 2024
1 parent a87fa0f commit 04e936a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions process/sctfcoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -7266,7 +7266,7 @@ def _theta_factor_integral(Ro_vv, Ri_vv, Rm_vv, H_vv, theta1_vv):
lambda_term(tau[1, k], omega[k]) - lambda_term(tau[0, k], omega[k])
)

return (chi1 + chi2) / np.pi
return (chi1 + 2.0 * chi2) / (2.0 * np.pi)


def vv_stress_on_quench(
Expand Down Expand Up @@ -7350,8 +7350,11 @@ def vv_stress_on_quench(
Empirical Formulas for Estimating Self and Mutual Inductances of Toroidal Field Coils and Structures.
Plasma and Fusion Research. 15. 1405078-1405078. 10.1585/pfr.15.1405078.
"""
# Convert angles into radians
theta1_vv_rad = np.pi * (theta1_vv / 180.0)

# Poloidal loop resistance (PLR) in ohms
theta_vv = _theta_factor_integral(Ro_vv, Ri_vv, Rm_vv, H_vv, theta1_vv)
theta_vv = _theta_factor_integral(Ro_vv, Ri_vv, Rm_vv, H_vv, theta1_vv_rad)
plr_coil = ((0.5 * ccl_length_coil) / (n_tf * (S_cc + S_rp))) * 1e-6
plr_vv = ((0.84 / d_vv) * theta_vv) * 1e-6

Expand Down Expand Up @@ -7397,5 +7400,5 @@ def vv_stress_on_quench(
zeta = 1 + ((A_vv - 1) * numpy.log((A_vv + 1) / (A_vv - 1)) / (2 * A_vv))

tresca_stress_vv = zeta * B_vvi * J_vvi * Ri_vv

print(tresca_stress_vv)
return tresca_stress_vv
2 changes: 1 addition & 1 deletion source/fortran/tfcoil_variables.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ subroutine init_tfcoil_variables
i_cp_joints = -1
cryo_cool_req = 0.0D0
theta1_coil = 45.0D0
theta1_vv = 1.0D0
theta1_vv = 1.0D0 ! 1 Deg
max_vv_stress = 143.0D6
end subroutine init_tfcoil_variables
end module tfcoil_variables
4 changes: 2 additions & 2 deletions tests/unit/test_sctfcoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -14031,7 +14031,7 @@ def test_vv_stress_on_quench():
d_vv=0.12, # for 6.6 restistance -> lambda2 = 2.1
)
)
== 56835032.21809308
== 57045874.69917925
)


Expand Down Expand Up @@ -14094,4 +14094,4 @@ def test_vv_stress_on_quench_integration(sctfcoil, monkeypatch):

sctfcoil.vv_stress_on_quench()

assert pytest.approx(sctfcoil_module.vv_stress_quench) == 56834395.24352395
assert pytest.approx(sctfcoil_module.vv_stress_quench) == 56893800.120420754

0 comments on commit 04e936a

Please sign in to comment.