Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
initial repo commit
- Loading branch information
0 parents
commit 3115ca2
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
|