diff --git a/process/pfcoil.py b/process/pfcoil.py index c239b42b..20e0ceec 100644 --- a/process/pfcoil.py +++ b/process/pfcoil.py @@ -2779,7 +2779,7 @@ def deltaj_nbti(temperature): :return: difference in current density :rtype: float """ - jcrit0, t = sc.jcrit_nbti(temperature, bmax, c0, bc20m, tc0m) + jcrit0, _ = superconductors.jcrit_nbti(temperature, bmax, c0, bc20m, tc0m) if ml.variable_error(jcrit0): # superconductors.jcrit_nbti has failed. print(f"superconductors.jcrit_nbti: {bmax=} {temperature=} {jcrit0=}") @@ -2879,14 +2879,14 @@ def deltaj_hijc_rebco(temperature): bc20m = 15.0e0 tc0m = 9.3e0 c0 = 1.0e10 - jcritsc, tcrit = sc.jcrit_nbti(thelium, bmax, c0, bc20m, tc0m) + jcritsc, _ = superconductors.jcrit_nbti(thelium, bmax, c0, bc20m, tc0m) jcritstr = jcritsc * (1.0e0 - fcu) elif isumat == 4: # As (1), but user-defined parameters bc20m = bcritsc tc0m = tcritsc - jcritsc, bcrit, tcrit = sc.itersc(thelium, bmax, strain, bc20m, tc0m) + jcritsc, _, _ = superconductors.itersc(thelium, bmax, strain, bc20m, tc0m) jcritstr = jcritsc * (1.0e0 - fcu) elif isumat == 5: @@ -2980,14 +2980,20 @@ def deltaj_hijc_rebco(temperature): ttestp = ttest + delt if isumat in [1, 4]: - jcrit0, b, t = sc.itersc(ttest, bmax, strain, bc20m, tc0m) + jcrit0, _, _ = superconductors.itersc( + ttest, bmax, strain, bc20m, tc0m + ) if (abs(jsc - jcrit0) <= jtol) and ( abs((jsc - jcrit0) / jsc) <= 0.01 ): break - jcritm, b, t = sc.itersc(ttestm, bmax, strain, bc20m, tc0m) - jcritp, b, t = sc.itersc(ttestp, bmax, strain, bc20m, tc0m) + jcritm, _, _ = superconductors.itersc( + ttestm, bmax, strain, bc20m, tc0m + ) + jcritp, _, _ = superconductors.itersc( + ttestp, bmax, strain, bc20m, tc0m + ) # Kludge to avoid divide by 0 if jcritm == jcritp: @@ -3006,7 +3012,9 @@ def deltaj_hijc_rebco(temperature): deltaj_nbti, x1, x2, 100e0 ) tmarg = current_sharing_t - thelium - jcrit0, t = sc.jcrit_nbti(current_sharing_t, bmax, c0, bc20m, tc0m) + jcrit0, _ = superconductors.jcrit_nbti( + current_sharing_t, bmax, c0, bc20m, tc0m + ) if ml.variable_error( current_sharing_t ): # current sharing secant solver has failed. diff --git a/process/sctfcoil.py b/process/sctfcoil.py index 0479bdcb..3607f33f 100644 --- a/process/sctfcoil.py +++ b/process/sctfcoil.py @@ -671,9 +671,7 @@ def supercon( bc20m = 15.0e0 tc0m = 9.3e0 c0 = 1.0e10 - jcritsc, tcrit = superconductorsf90.jcrit_nbti( - thelium, bmax, c0, bc20m, tc0m - ) + jcritsc, _ = superconductors.jcrit_nbti(thelium, bmax, c0, bc20m, tc0m) jcritstr = jcritsc * (1.0e0 - fcu) # Critical current in cable icrit = jcritstr * acs * fcond @@ -823,31 +821,27 @@ def supercon( # Issue #483 to be on the safe side, check the fractional as well as the absolute error if isumat in (1, 4): - jcrit0, b, t = superconductorsf90.itersc( + jcrit0, _, _ = superconductors.itersc( ttest, bmax, strain, bc20m, tc0m ) if (abs(jsc - jcrit0) <= jtol) and ( abs((jsc - jcrit0) / jsc) <= 0.01 ): break - jcritm, b, t = superconductorsf90.itersc( + jcritm, _, _ = superconductors.itersc( ttestm, bmax, strain, bc20m, tc0m ) - jcritp, b, t = superconductorsf90.itersc( + jcritp, _, _ = superconductors.itersc( ttestp, bmax, strain, bc20m, tc0m ) elif isumat == 3: - jcrit0, t = superconductorsf90.jcrit_nbti( - ttest, bmax, c0, bc20m, tc0m - ) + jcrit0, _ = superconductors.jcrit_nbti(ttest, bmax, c0, bc20m, tc0m) if (abs(jsc - jcrit0) <= jtol) and ( abs((jsc - jcrit0) / jsc) <= 0.01 ): break - jcritm, t = superconductorsf90.jcrit_nbti( - ttestm, bmax, c0, bc20m, tc0m - ) - jcritp, t = superconductorsf90.jcrit_nbti( + jcritm, _ = super.jcrit_nbti(ttestm, bmax, c0, bc20m, tc0m) + jcritp, _ = superconductors.jcrit_nbti( ttestp, bmax, c0, bc20m, tc0m ) elif isumat == 5: diff --git a/process/superconductors.py b/process/superconductors.py index 60e4c349..d16c52fc 100644 --- a/process/superconductors.py +++ b/process/superconductors.py @@ -101,3 +101,43 @@ def itersc(thelium, bmax, strain, bc20max, tc0max): jcrit = jc1 * jc2 * jc3 / scalefac return jcrit, bcrit, tcrit + + +def jcrit_nbti(temperature, bmax, c0, bc20max, tc0max): + """Critical current density in a NbTi superconductor strand + author: P J Knight, CCFE, Culham Science Centre + temperature : input real : SC temperature (K) + bmax : input real : Magnetic field at conductor (T) + c0 : input real : Scaling constant (A/m2) + bc20max : input real : Upper critical field (T) for superconductor + at zero temperature and strain + tc0max : input real : Critical temperature (K) at zero field and strain + jcrit : output real : Critical current density in superconductor (A/m2) + tcrit : output real : Critical temperature (K) + This routine calculates the critical current density and + temperature in superconducting TF coils using NbTi + as the superconductor. + """ + + bratio = bmax / bc20max + + if bmax < bc20max: + # Critical temperature (K) + tcrit = tc0max * (1.0 - bratio) ** 0.59 + else: + # Allow bmax > bc20max but set error flag + # Fudge to give real (negative) value if bratio < 1 + tcrit = tc0max * (1.0 - bratio) + + # Allow tbar to be negative but set error flag + tbar = 1.0 - temperature / tcrit + + # Critical current density (A/m2) + jcrit = c0 * (1.0 - bratio) * tbar + + # if ((temperature > tcrit).or.(bmax > bc20max))then + # write(*,*)'jcrit_nbti: out of range: ', 'bmax =', bmax, ' bc20max =', bc20max, & + # ' temperature =',temperature, ' tcrit =',tcrit + # end if + + return jcrit, tcrit diff --git a/source/fortran/superconductors.f90 b/source/fortran/superconductors.f90 index 2bc4a54b..afdee234 100755 --- a/source/fortran/superconductors.f90 +++ b/source/fortran/superconductors.f90 @@ -206,59 +206,6 @@ subroutine bi2212(bmax,jstrand,tsc,fhts,jcrit,tmarg) end if end subroutine bi2212 -!------------------------------------------------------------------ -subroutine jcrit_nbti(temperature,bmax,c0,bc20max,tc0max,jcrit,tcrit) - - !! Critical current density in a NbTi superconductor strand - !! author: P J Knight, CCFE, Culham Science Centre - !! temperature : input real : SC temperature (K) - !! bmax : input real : Magnetic field at conductor (T) - !! c0 : input real : Scaling constant (A/m2) - !! bc20max : input real : Upper critical field (T) for superconductor - !! at zero temperature and strain - !! tc0max : input real : Critical temperature (K) at zero field and strain - !! jcrit : output real : Critical current density in superconductor (A/m2) - !! tcrit : output real : Critical temperature (K) - !! This routine calculates the critical current density and - !! temperature in superconducting TF coils using NbTi - !! as the superconductor. - !! None - ! - ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - use constants, only: pi - implicit none - - ! Arguments - real(dp), intent(in) :: temperature, bmax, c0, bc20max, tc0max - real(dp), intent(out) :: jcrit, tcrit - - ! Local variables - real(dp) :: bratio, tbar - !----------------------------------- - bratio = bmax/bc20max - - if (bmax < bc20max) then - ! Critical temperature (K) - tcrit = tc0max * (1.0D0 - bratio)**0.59D0 - else - ! Allow bmax > bc20max but set error flag - ! Fudge to give real (negative) value if bratio < 1 - tcrit = tc0max * (1.0D0 - bratio) - end if - - ! Allow tbar to be negative but set error flag - tbar = 1.0D0 - temperature/tcrit - - ! Critical current density (A/m2) - jcrit = c0 * (1.0D0 - bratio) * tbar - - ! if ((temperature > tcrit).or.(bmax > bc20max))then - ! write(*,*)'jcrit_nbti: out of range: ', 'bmax =', bmax, ' bc20max =', bc20max, & - ! ' temperature =',temperature, ' tcrit =',tcrit - ! end if - -end subroutine jcrit_nbti !-------------------------------------------------------------------- subroutine GL_nbti(thelium,bmax,strain,bc20max,t_c0,jcrit,bcrit,tcrit) diff --git a/tests/unit/test_superconductors.py b/tests/unit/test_superconductors.py index 98536fc6..a6d153c7 100644 --- a/tests/unit/test_superconductors.py +++ b/tests/unit/test_superconductors.py @@ -1,7 +1,6 @@ import pytest from typing import NamedTuple, Any -from process.fortran import superconductors as superconductorsf90 import process.superconductors as superconductors @@ -128,7 +127,7 @@ def test_jcrit_nbti(jcritnbtiparam, monkeypatch): :type monkeypatch: _pytest.monkeypatch.monkeypatch """ - jcrit, tcrit = superconductorsf90.jcrit_nbti( + jcrit, tcrit = superconductors.jcrit_nbti( temperature=jcritnbtiparam.temperature, bmax=jcritnbtiparam.bmax, c0=jcritnbtiparam.c0,