{{{id=159| %auto reset() forget() /// }}} {{{id=369| f(y) = 2 * sqrt((2-y)*y) ay = [] ai = [] n = 400 for i in range(n+1): y = i*2/n ai += [y] ay += [f(y)] p = list_plot(zip(ay,ai),figsize=(2.5,4),axes_labels=['Width (w)','Height (y)'],plotjoined=True) p += text('$w = 2\ \sqrt{(2-y)y}$',(1,1),fontsize=12,color='black') save(p,'/netbackup/data/Network/arachnoid/TankCalc/volumes_resources/cylindrical_tank_equation_plot.png') show(p) /// }}} {{{id=371| forget() var('y,z') assume(y > 0) fi(y) = integrate(f(z),(z,0,y)) show(f(y)) show(fi(y)) ///
\newcommand{\Bold}[1]{\mathbf{#1}}2 \, \sqrt{-{\left(y - 2\right)} y}
\newcommand{\Bold}[1]{\mathbf{#1}}\pi + \sqrt{-y + 2} {\left(y - 1\right)} \sqrt{y} - 2 \, \arctan\left(\frac{\sqrt{-y + 2}}{\sqrt{y}}\right)
}}} {{{id=372| fi(2) /// pi }}} {{{id=373| p2 = plot(fi(y),(y,0,2),figsize=(3,3),axes_labels=['Height (y)','Area (a)']) p2 += text('$a = ' + latex(fi(y)) + '$',(1.5,1.5),fontsize=11,color='black') save(p2,'/netbackup/data/Network/arachnoid/TankCalc/volumes_resources/cylindrical_tank_integral_plot.png') show(p2) /// }}} {{{id=378| # bucket (conical frustum) equation var('r_a,r_b,h_b,h_c') show(latex(1/3 * pi * (r_b^2 * h_c - r_a^2 * (h_c-h_b)))) h_c = h_b * r_b / (r_b-r_a) vv = 1/3 * pi * r_b^2 * h_c - 1/3 * pi * r_a^2 * (h_c-h_b) bv(h_b,r_b,r_a) = vv show(bv(h_b,r_b,r_a)) show(latex(bv(h_b,r_b,r_a))) latex(vv) vvfs = vv.full_simplify() show(vvfs) latex(vvfs) ///
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{\frac{1}{3} \, {\left({\left(h_{b} - h_{c}\right)} r_{a}^{2} + h_{c} r_{b}^{2}\right)} \pi}
\newcommand{\Bold}[1]{\mathbf{#1}}-\frac{\pi h_{b} r_{b}^{3}}{3 \, {\left(r_{a} - r_{b}\right)}} + \frac{1}{3} \, {\left(\frac{h_{b} r_{b}}{r_{a} - r_{b}} + h_{b}\right)} \pi r_{a}^{2}
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{-\frac{\pi h_{b} r_{b}^{3}}{3 \, {\left(r_{a} - r_{b}\right)}} + \frac{1}{3} \, {\left(\frac{h_{b} r_{b}}{r_{a} - r_{b}} + h_{b}\right)} \pi r_{a}^{2}}
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{3} \, \pi h_{b} r_{a}^{2} + \frac{1}{3} \, \pi h_{b} r_{a} r_{b} + \frac{1}{3} \, \pi h_{b} r_{b}^{2}
\frac{1}{3} \, \pi h_{b} r_{a}^{2} + \frac{1}{3} \, \pi h_{b} r_{a} r_{b} + \frac{1}{3} \, \pi h_{b} r_{b}^{2} }}} {{{id=379| show(bv(h_b,r_b,r_a)) latex(bv(h_b,r_b,r_a)) ///
\newcommand{\Bold}[1]{\mathbf{#1}}-\frac{\pi h_{b} r_{b}^{3}}{3 \, {\left(r_{a} - r_{b}\right)}} + \frac{1}{3} \, {\left(\frac{h_{b} r_{b}}{r_{a} - r_{b}} + h_{b}\right)} \pi r_{a}^{2}
-\frac{\pi h_{b} r_{b}^{3}}{3 \, {\left(r_{a} - r_{b}\right)}} + \frac{1}{3} \, {\left(\frac{h_{b} r_{b}}{r_{a} - r_{b}} + h_{b}\right)} \pi r_{a}^{2} }}} {{{id=380| bv(10,10,9.9999999) /// 999.999988555908*pi }}} {{{id=389| # bucket (conical frustum) incremental volume equation var('r_a,r_b,y,h,q') vf(r_a,r_b,h,y) = pi * (r_a + (r_b - r_a)*(y/h))^2 vi(r_a,r_b,h,y) = integrate(pi * (r_a + (r_b - r_a)*(q/h))^2, (q, 0, y)) show(latex(vf(r_a,r_b,h,y))) show(vf(r_a,r_b,h,y)) show(latex(vi(r_a,r_b,h,y))) show(vi(r_a,r_b,h,y)) print(vi(r_a,r_b,h,y)) ///
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{{\left(\frac{{\left(r_{a} - r_{b}\right)} y}{h} - r_{a}\right)}^{2} \pi}
\newcommand{\Bold}[1]{\mathbf{#1}}{\left(\frac{{\left(r_{a} - r_{b}\right)} y}{h} - r_{a}\right)}^{2} \pi
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{\frac{{\left(3 \, h^{2} r_{a}^{2} y + {\left(r_{a}^{2} - 2 \, r_{a} r_{b} + r_{b}^{2}\right)} y^{3} - 3 \, {\left(h r_{a}^{2} - h r_{a} r_{b}\right)} y^{2}\right)} \pi}{3 \, h^{2}}}
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{{\left(3 \, h^{2} r_{a}^{2} y + {\left(r_{a}^{2} - 2 \, r_{a} r_{b} + r_{b}^{2}\right)} y^{3} - 3 \, {\left(h r_{a}^{2} - h r_{a} r_{b}\right)} y^{2}\right)} \pi}{3 \, h^{2}}
1/3*(3*h^2*r_a^2*y + (r_a^2 - 2*r_a*r_b + r_b^2)*y^3 - 3*(h*r_a^2 - h*r_a*r_b)*y^2)*pi/h^2 }}} {{{id=390| vi(5,10,10,1) /// 331/12*pi }}} {{{id=391| # test results for i in range(11): print '%8.2f %8.2f' % (i,vi(5,10,10,i)) /// 0.00 0.00 1.00 86.66 2.00 190.59 3.00 313.37 4.00 456.58 5.00 621.77 6.00 810.53 7.00 1024.42 8.00 1265.01 9.00 1533.88 10.00 1832.60 }}} {{{id=392| # compare to original equation print(N(bv(1,5.5,5))) print(N(bv(5,7.5,5))) print(N(bv(10,10,5))) /// 86.6555973615184 621.773546022980 1832.59571459405 }}} {{{id=394| # now the inverse case -- height for volume var('r_a,r_b,h,v,y') yf(r_a,r_b,h,v) = solve(vi(r_a,r_b,h,y) - v == 0,y)[2].rhs() /// }}} {{{id=396| show(yf(r_a,r_b,h,v)) show(latex(yf(r_a,r_b,h,v))) print(yf(r_a,r_b,h,v)) ///
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{h r_{a}}{r_{a} - r_{b}} - \frac{{\left(\pi h r_{a}^{3} - 3 \, {\left(r_{a} - r_{b}\right)} v\right)}^{\left(\frac{1}{3}\right)} {\left(h^{2}\right)}^{\left(\frac{1}{3}\right)}}{{\left(r_{a} - r_{b}\right)} \pi^{\left(\frac{1}{3}\right)}}
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{\frac{h r_{a}}{r_{a} - r_{b}} - \frac{{\left(\pi h r_{a}^{3} - 3 \, {\left(r_{a} - r_{b}\right)} v\right)}^{\left(\frac{1}{3}\right)} {\left(h^{2}\right)}^{\left(\frac{1}{3}\right)}}{{\left(r_{a} - r_{b}\right)} \pi^{\left(\frac{1}{3}\right)}}}
h*r_a/(r_a - r_b) - (pi*h*r_a^3 - 3*(r_a - r_b)*v)^(1/3)*(h^2)^(1/3)/((r_a - r_b)*pi^(1/3)) }}} {{{id=397| # generate some test results -- create volume from height, then height from volume import re txt = '' html = '' for i in range(1,11): vv = vi(5,10,10,i) yy = yf(5,10,10,vv) s = '%10.4f %10.4f %10.4f\n' % (i,vv,yy) txt += s hs = '' + re.sub('\s*(\S+)\s*','\\1 ',s) + '\n' html += hs print (txt) print (html) /// 1.0000 86.6556 1.0000 2.0000 190.5900 2.0000 3.0000 313.3739 3.0000 4.0000 456.5781 4.0000 5.0000 621.7735 5.0000 6.0000 810.5309 6.0000 7.0000 1024.4210 7.0000 8.0000 1265.0146 8.0000 9.0000 1533.8826 9.0000 10.0000 1832.5957 10.0000 1.0000 86.6556 1.0000 2.0000 190.5900 2.0000 3.0000 313.3739 3.0000 4.0000 456.5781 4.0000 5.0000 621.7735 5.0000 6.0000 810.5309 6.0000 7.0000 1024.4210 7.0000 8.0000 1265.0146 8.0000 9.0000 1533.8826 9.0000 10.0000 1832.5957 10.0000 }}} {{{id=400| /// }}}