Numerical Code for calculating Pressurized Hydrogen Storage

From ccitonlinewiki
Revision as of 22:05, 4 June 2023 by Farieedn (talk | contribs) (Created page with "<syntaxhighlight lang="xml"> from math import pi import pprint ''' r = radius circle_area = pi * r**2 circle_circumference = 2 * pi * r h = height cylinder_volume = pi *...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
from math import pi

import pprint


'''

r = radius
circle_area = pi * r**2
circle_circumference = 2 * pi * r

h = height
cylinder_volume = pi * r**2 * h

cylinder_surface = 2 * (pi * r**2) + (2 * pi * r * h)

constraint for cylinder_volume be a constant of 1 liter (cubic centimeter)
cylinder_volume = 1000
h in terms of r
h = 1000/(pi * r**2)

substitute in
cylinder_surface = 2 * (pi * r**2) + (2 * pi * r * 1000/(pi * r**2))

'''

mylist = []               # create a list of (surface area, radius)
for r in range(1, 21):    # assume a maximum of 20cm radius
    cylinder_surface = 2 * (pi * r**2) + (2 * pi * r * 1000/(pi * r**2))
    mylist.append((cylinder_surface, r))

# test
pprint.pprint(mylist)