From 1dbcea417a43cdd110840f2e9e3122410ff71fed Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Wed, 11 Dec 2024 11:23:09 +0000 Subject: [PATCH] Convert eshellvol to Python --- process/blanket_library.py | 70 +++++++++++++++++++++++++-- source/fortran/maths_library.f90 | 82 -------------------------------- 2 files changed, 67 insertions(+), 85 deletions(-) diff --git a/process/blanket_library.py b/process/blanket_library.py index 1d7def32..60d1c6c2 100644 --- a/process/blanket_library.py +++ b/process/blanket_library.py @@ -282,7 +282,7 @@ def elliptical_component(self, icomponent: int): fwbs_variables.volblkti, fwbs_variables.volblkto, fwbs_variables.volblkt, - ) = maths_library.eshellvol( + ) = eshellvol( r1, r2, r3, @@ -296,7 +296,7 @@ def elliptical_component(self, icomponent: int): blanket_library.volshldi, blanket_library.volshldo, fwbs_variables.volshld, - ) = maths_library.eshellvol( + ) = eshellvol( r1, r2, r3, @@ -310,7 +310,7 @@ def elliptical_component(self, icomponent: int): blanket_library.volvvi, blanket_library.volvvo, fwbs_variables.vdewin, - ) = maths_library.eshellvol( + ) = eshellvol( r1, r2, r3, @@ -2750,3 +2750,67 @@ def dshellarea(rmajor, rminor, zminor): aout = 2.0 * np.pi * elong * (np.pi * rmajor * rminor + 2.0 * rminor * rminor) return ain, aout, ain + aout + + +def eshellvol(rshell, rmini, rmino, zminor, drin, drout, dz): + """Routine to calculate the inboard, outboard and total volumes + of a toroidal shell comprising two elliptical sections + author: P J Knight, CCFE, Culham Science Centre + rshell : input real : major radius of centre of both ellipses (m) + rmini : input real : horizontal distance from rshell to outer edge + of inboard elliptical shell (m) + rmino : input real : horizontal distance from rshell to inner edge + of outboard elliptical shell (m) + zminor : input real : vertical internal half-height of shell (m) + drin : input real : horiz. thickness of inboard shell at midplane (m) + drout : input real : horiz. thickness of outboard shell at midplane (m) + dz : input real : vertical thickness of shell at top/bottom (m) + vin : output real : volume of inboard section (m3) + vout : output real : volume of outboard section (m3) + vtot : output real : total volume of shell (m3) + This routine calculates the volume of the inboard and outboard sections + of a toroidal shell defined by two co-centred semi-ellipses. + Each section's internal and external surfaces are in turn defined + by two semi-ellipses. The volumes of each section are calculated as + the difference in those of the volumes of revolution enclosed by their + inner and outer surfaces. + """ + # Inboard section + + # Volume enclosed by outer (higher R) surface of elliptical section + # and the vertical straight line joining its ends + a = rmini + b = zminor + elong = b / a + v1 = 2.0 * np.pi * elong * (0.5 * np.pi * rshell * a**2 - (2.0 / 3.0) * a**3) + + # Volume enclosed by inner (lower R) surface of elliptical section + # and the vertical straight line joining its ends + a = rmini + drin + b = zminor + dz + elong = b / a + v2 = 2.0 * np.pi * elong * (0.5 * np.pi * rshell * a**2 - (2.0 / 3.0) * a**3) + + # Volume of inboard section of shell + vin = v2 - v1 + + # Outboard section + + # Volume enclosed by inner (lower R) surface of elliptical section + # and the vertical straight line joining its ends + a = rmino + b = zminor + elong = b / a + v1 = 2.0 * np.pi * elong * (0.5 * np.pi * rshell * a**2 + (2.0 / 3.0) * a**3) + + # Volume enclosed by outer (higher R) surface of elliptical section + # and the vertical straight line joining its ends + a = rmino + drout + b = zminor + dz + elong = b / a + v2 = 2.0 * np.pi * elong * (0.5 * np.pi * rshell * a**2 + (2.0 / 3.0) * a**3) + + # Volume of outboard section of shell + vout = v2 - v1 + + return vin, vout, vin + vout diff --git a/source/fortran/maths_library.f90 b/source/fortran/maths_library.f90 index 9b6dfc9c..266c83f5 100644 --- a/source/fortran/maths_library.f90 +++ b/source/fortran/maths_library.f90 @@ -23,88 +23,6 @@ module maths_library implicit none contains - ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - subroutine eshellvol(rshell,rmini,rmino,zminor,drin,drout,dz,vin,vout,vtot) - - !! Routine to calculate the inboard, outboard and total volumes - !! of a toroidal shell comprising two elliptical sections - !! author: P J Knight, CCFE, Culham Science Centre - !! rshell : input real : major radius of centre of both ellipses (m) - !! rmini : input real : horizontal distance from rshell to outer edge - !! of inboard elliptical shell (m) - !! rmino : input real : horizontal distance from rshell to inner edge - !! of outboard elliptical shell (m) - !! zminor : input real : vertical internal half-height of shell (m) - !! drin : input real : horiz. thickness of inboard shell at midplane (m) - !! drout : input real : horiz. thickness of outboard shell at midplane (m) - !! dz : input real : vertical thickness of shell at top/bottom (m) - !! vin : output real : volume of inboard section (m3) - !! vout : output real : volume of outboard section (m3) - !! vtot : output real : total volume of shell (m3) - !! This routine calculates the volume of the inboard and outboard sections - !! of a toroidal shell defined by two co-centred semi-ellipses. - !! Each section's internal and external surfaces are in turn defined - !! by two semi-ellipses. The volumes of each section are calculated as - !! the difference in those of the volumes of revolution enclosed by their - !! inner and outer surfaces. - !!

See also eshellarea - !! Internal CCFE note T&M/PKNIGHT/PROCESS/009, P J Knight: - !! Surface Area and Volume Calculations for Toroidal Shells - ! - ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - use constants, only: pi, twopi - implicit none - - ! Arguments - real(kind=dp), intent(in) :: rshell, rmini, rmino, zminor, drin, drout, dz - real(kind=dp), intent(out) :: vin, vout, vtot - - ! Local variables - real(kind=dp) :: a, b, elong, v1, v2 - - ! Global shared variables - ! Input: pi,twopi - ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - ! #TODO - Review both equations containing dz and attempt to separate - ! top and bottom of vacuum vessel thickness - ! See issue #433 for explanation - - ! Inboard section - - ! Volume enclosed by outer (higher R) surface of elliptical section - ! and the vertical straight line joining its ends - a = rmini ; b = zminor ; elong = b/a - v1 = twopi * elong * (0.5D0*pi*rshell*a*a - 2.0D0/3.0D0*a*a*a) - - ! Volume enclosed by inner (lower R) surface of elliptical section - ! and the vertical straight line joining its ends - a = rmini+drin ; b = zminor+dz ; elong = b/a - v2 = twopi * elong * (0.5D0*pi*rshell*a*a - 2.0D0/3.0D0*a*a*a) - - ! Volume of inboard section of shell - vin = v2 - v1 - - ! Outboard section - - ! Volume enclosed by inner (lower R) surface of elliptical section - ! and the vertical straight line joining its ends - a = rmino ; b = zminor ; elong = b/a - v1 = twopi * elong * (0.5D0*pi*rshell*a*a + 2.0D0/3.0D0*a*a*a) - - ! Volume enclosed by outer (higher R) surface of elliptical section - ! and the vertical straight line joining its ends - a = rmino+drout ; b = zminor+dz ; elong = b/a - v2 = twopi * elong * (0.5D0*pi*rshell*a*a + 2.0D0/3.0D0*a*a*a) - - ! Volume of outboard section of shell - vout = v2 - v1 - - ! Total shell volume - vtot = vin + vout - - end subroutine eshellvol ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!