Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
initial repo commit
  • Loading branch information
rcc02007 committed Nov 15, 2019
0 parents commit 3115ca2
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
@@ -0,0 +1,31 @@
# Convert parallipiped dimesions to equivalent axisymmetric cylinder dimensions

## For a given w x t x L block

## Return the equivalent r x h cylinder

## maintaining surface area and volume

Running the code (2 options):

1. open a terminal and type:

$ `python solve_cylinder_rt 1 2 3`

returns

`A 1.00 x 2.00 x 3.00 parallelipiped
has the same surface area and volume as a cylinder
that is r=0.6104 and t=5.1257`

2. In a jupyter notebook,

a. `import solve_cylinder_rt as sc`

b. `sc.solve_cylinder(1,2,3)`

`output: A 1.00 x 2.00 x 3.00 parallelipiped
has the same surface area and volume as a cylinder
that is r=0.6104 and t=5.1257`


41 changes: 41 additions & 0 deletions solve_cylinder_rt.py
@@ -0,0 +1,41 @@
#!/opt/miniconda3/bin/python
import numpy as np
from scipy.optimize import fsolve
import sys

def parapiped(w,h,L):
A=2*(w*h+w*L+h*L)
V=w*h*L
return np.array([A,V])
def cylinder(r,t):
A=2*np.pi*r*(r+t)
V=np.pi*r**2*t
return np.array([A,V])

def matchAV(dim_cyl,dims):
r,t=dim_cyl
w,h,L=dims
AVp=parapiped(w,h,L)
AVc=cylinder(r,t)
return AVp-AVc

def return_hr(w,h,L):
r,t=fsolve(matchAV,[1,2],args=[w,h,L])
print('A %1.2f x %1.2f x %1.2f parallelipiped'%(w,h,L) )
print('has the same surface area and volume as a cylinder')
print('that is r=%1.4f and t=%1.4f'%(r,t))


if __name__=='__main__':
if len(sys.argv)<=3:
print('error, please enter w-by-t-by-L dimensions of parallelipiped as w t L')
else:
print(sys.argv)
w=float(sys.argv[1])
h=float(sys.argv[2])
L=float(sys.argv[3])
r,t=fsolve(matchAV,[1,2],args=[w,h,L])
print('A %1.2f x %1.2f x %1.2f parallelipiped'%(w,h,L) )
print('has the same surface area and volume as a cylinder')
print('that is r=%1.4f and t=%1.4f'%(r,t))

0 comments on commit 3115ca2

Please sign in to comment.