Skip to content

Commit

Permalink
Convert dshellvol to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
timothy-nunn committed Jan 8, 2025
1 parent 1dbcea4 commit f8eb257
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 72 deletions.
52 changes: 48 additions & 4 deletions process/blanket_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
error_handling,
fwbs_variables,
heat_transport_variables,
maths_library,
pfcoil_variables,
physics_variables,
primary_pumping_variables,
Expand Down Expand Up @@ -194,7 +193,7 @@ def dshaped_component(self, icomponent: int):
fwbs_variables.volblkti,
fwbs_variables.volblkto,
fwbs_variables.volblkt,
) = maths_library.dshellvol(
) = dshellvol(
r1,
r2,
blanket_library.hblnkt,
Expand All @@ -207,7 +206,7 @@ def dshaped_component(self, icomponent: int):
blanket_library.volshldi,
blanket_library.volshldo,
fwbs_variables.volshld,
) = maths_library.dshellvol(
) = dshellvol(
r1,
r2,
blanket_library.hshld,
Expand All @@ -220,7 +219,7 @@ def dshaped_component(self, icomponent: int):
blanket_library.volvvi,
blanket_library.volvvo,
fwbs_variables.vdewin,
) = maths_library.dshellvol(
) = dshellvol(
r1,
r2,
blanket_library.hvv,
Expand Down Expand Up @@ -2814,3 +2813,48 @@ def eshellvol(rshell, rmini, rmino, zminor, drin, drout, dz):
vout = v2 - v1

return vin, vout, vin + vout


def dshellvol(rmajor, rminor, zminor, drin, drout, dz):
"""Routine to calculate the inboard, outboard and total volumes
of a D-shaped toroidal shell
author: P J Knight, CCFE, Culham Science Centre
rmajor : input real : major radius to outer point of inboard
straight section of shell (m)
rminor : input real : horizontal internal width of 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 straight section (m3)
vout : output real : volume of outboard curved section (m3)
vtot : output real : total volume of shell (m3)
This routine calculates the volume of the inboard and outboard sections
of a D-shaped toroidal shell defined by the above input parameters.
The inboard section is assumed to be a cylinder of uniform thickness.
The outboard section's internal and external surfaces are defined
by two semi-ellipses, centred on the outer edge of the inboard section;
its volume is calculated as the difference in those of the volumes of
revolution enclosed by the two surfaces.
"""
# Volume of inboard cylindrical shell
vin = 2.0 * (zminor + dz) * np.pi * (rmajor**2 - (rmajor - drin) ** 2)

# Volume enclosed by inner surface of elliptical outboard section
# and the vertical straight line joining its ends
a = rminor
b = zminor
elong = b / a
v1 = 2.0 * np.pi * elong * (0.5 * np.pi * rmajor * a**2 + (2.0 / 3.0) * a**3)

# Volume enclosed by outer surface of elliptical outboard section
# and the vertical straight line joining its ends
a = rminor + drout
b = zminor + dz
elong = b / a
v2 = 2.0 * np.pi * elong * (0.5 * np.pi * rmajor * a**2 + (2.0 / 3.0) * a**3)

# Volume of elliptical outboard shell
vout = v2 - v1

return vin, vout, vin + vout
68 changes: 0 additions & 68 deletions source/fortran/maths_library.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,74 +26,6 @@ module maths_library

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

subroutine dshellvol(rmajor,rminor,zminor,drin,drout,dz,vin,vout,vtot)

!! Routine to calculate the inboard, outboard and total volumes
!! of a D-shaped toroidal shell
!! author: P J Knight, CCFE, Culham Science Centre
!! rmajor : input real : major radius to outer point of inboard
!! straight section of shell (m)
!! rminor : input real : horizontal internal width of 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 straight section (m3)
!! vout : output real : volume of outboard curved section (m3)
!! vtot : output real : total volume of shell (m3)
!! This routine calculates the volume of the inboard and outboard sections
!! of a D-shaped toroidal shell defined by the above input parameters.
!! The inboard section is assumed to be a cylinder of uniform thickness.
!! The outboard section's internal and external surfaces are defined
!! by two semi-ellipses, centred on the outer edge of the inboard section;
!! its volume is calculated as the difference in those of the volumes of
!! revolution enclosed by the two surfaces.
!! <P>See also <A HREF="dshellarea.html"><CODE>dshellarea</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) :: rmajor, rminor, 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

! Volume of inboard cylindrical shell
vin = 2.0D0*(zminor+dz) * pi*(rmajor**2 - (rmajor-drin)**2)

! Volume enclosed by inner surface of elliptical outboard section
! and the vertical straight line joining its ends
a = rminor ; b = zminor ; elong = b/a
v1 = twopi * elong * (0.5D0*pi*rmajor*a*a + 2.0D0/3.0D0*a*a*a)

! Volume enclosed by outer surface of elliptical outboard section
! and the vertical straight line joining its ends
a = rminor+drout ; b = zminor+dz ; elong = b/a
v2 = twopi * elong * (0.5D0*pi*rmajor*a*a + 2.0D0/3.0D0*a*a*a)

! Volume of elliptical outboard shell
vout = v2 - v1

! Total shell volume
vtot = vin + vout

end subroutine dshellvol

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

! ------------------------------------------------------------------------
pure function variable_error(variable)
real(dp), intent(in) ::variable
Expand Down

0 comments on commit f8eb257

Please sign in to comment.