Skip to content

Commit

Permalink
Convert eshellvol to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
timothy-nunn committed Jan 8, 2025
1 parent 4e9af07 commit 1dbcea4
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 85 deletions.
70 changes: 67 additions & 3 deletions process/blanket_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
82 changes: 0 additions & 82 deletions source/fortran/maths_library.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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.
!! <P>See also <A HREF="eshellarea.html"><CODE>eshellarea</CODE></A>
!! Internal CCFE note T&amp;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

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Expand Down

0 comments on commit 1dbcea4

Please sign in to comment.