{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Volume/Height relationship in wells with square cross-section"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The width of the well at the bottom is 2.67 mm. and at the top (height, $H$, of 11.43 mm.) is\n",
"3.63 mm.\n",
"\n",
"At a height, $H$, the cross section is a square of size $2.67 + (3.63 - 2.67)H/11.43$ mm."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"┌ Info: Loading DataFrames support into Gadfly.jl\n",
"└ @ Gadfly /home/bates/.julia/packages/Gadfly/09PWZ/src/mapping.jl:228\n"
]
},
{
"data": {
"text/html": [
"2.67 + 0.08398950131233596∙x"
],
"text/latex": [
"$2.67 + 0.08398950131233596\\cdot x$"
],
"text/plain": [
"Poly(2.67 + 0.08398950131233596*x)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using Polynomials, DataFrames, Gadfly\n",
"plen = Poly([2.67, 0.96 / 11.43]) # polynomial representing size of square"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"7.1289 + 0.448503937007874∙x + 0.007054236330694883∙x^2"
],
"text/latex": [
"$7.1289 + 0.448503937007874\\cdot x + 0.007054236330694883\\cdot x^{2}$"
],
"text/plain": [
"Poly(7.1289 + 0.448503937007874*x + 0.007054236330694883*x^2)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"parea = plen * plen"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The volume will be the integral from $0$ to $H$ of `parea`"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"7.1289∙x + 0.224251968503937∙x^2 + 0.002351412110231628∙x^3"
],
"text/latex": [
"$7.1289\\cdot x + 0.224251968503937\\cdot x^{2} + 0.002351412110231628\\cdot x^{3}$"
],
"text/plain": [
"Poly(7.1289*x + 0.224251968503937*x^2 + 0.002351412110231628*x^3)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pvol = polyint(parea)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A plot of this function is"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"┌ Warning: `head(df::AbstractDataFrame)` is deprecated, use `first(df, 6)` instead.\n",
"│ caller = top-level scope at In[4]:4\n",
"└ @ Core In[4]:4\n"
]
},
{
"data": {
"text/html": [
"
| H | V |
---|
| Float64 | Float64 |
---|
6 rows × 2 columns
1 | 0.0 | 0.0 |
---|
2 | 0.01 | 0.0713114 |
---|
3 | 0.02 | 0.142668 |
---|
4 | 0.03 | 0.214069 |
---|
5 | 0.04 | 0.285515 |
---|
6 | 0.05 | 0.357006 |
---|
"
],
"text/latex": [
"\\begin{tabular}{r|cc}\n",
"\t& H & V\\\\\n",
"\t\\hline\n",
"\t& Float64 & Float64\\\\\n",
"\t\\hline\n",
"\t1 & 0.0 & 0.0 \\\\\n",
"\t2 & 0.01 & 0.0713114 \\\\\n",
"\t3 & 0.02 & 0.142668 \\\\\n",
"\t4 & 0.03 & 0.214069 \\\\\n",
"\t5 & 0.04 & 0.285515 \\\\\n",
"\t6 & 0.05 & 0.357006 \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"6×2 DataFrame\n",
"│ Row │ H │ V │\n",
"│ │ \u001b[90mFloat64\u001b[39m │ \u001b[90mFloat64\u001b[39m │\n",
"├─────┼─────────┼───────────┤\n",
"│ 1 │ 0.0 │ 0.0 │\n",
"│ 2 │ 0.01 │ 0.0713114 │\n",
"│ 3 │ 0.02 │ 0.142668 │\n",
"│ 4 │ 0.03 │ 0.214069 │\n",
"│ 5 │ 0.04 │ 0.285515 │\n",
"│ 6 │ 0.05 │ 0.357006 │"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"H = 0.:0.01:11.43;\n",
"d = DataFrame(H=H);\n",
"d[:V] = polyval(pvol,d[:H]);\n",
"first(d, 6)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
" | H | V |
---|
| Float64 | Float64 |
---|
6 rows × 2 columns
1 | 11.38 | 113.634 |
---|
2 | 11.39 | 113.765 |
---|
3 | 11.4 | 113.897 |
---|
4 | 11.41 | 114.029 |
---|
5 | 11.42 | 114.16 |
---|
6 | 11.43 | 114.292 |
---|
"
],
"text/latex": [
"\\begin{tabular}{r|cc}\n",
"\t& H & V\\\\\n",
"\t\\hline\n",
"\t& Float64 & Float64\\\\\n",
"\t\\hline\n",
"\t1 & 11.38 & 113.634 \\\\\n",
"\t2 & 11.39 & 113.765 \\\\\n",
"\t3 & 11.4 & 113.897 \\\\\n",
"\t4 & 11.41 & 114.029 \\\\\n",
"\t5 & 11.42 & 114.16 \\\\\n",
"\t6 & 11.43 & 114.292 \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"6×2 DataFrame\n",
"│ Row │ H │ V │\n",
"│ │ \u001b[90mFloat64\u001b[39m │ \u001b[90mFloat64\u001b[39m │\n",
"├─────┼─────────┼─────────┤\n",
"│ 1 │ 11.38 │ 113.634 │\n",
"│ 2 │ 11.39 │ 113.765 │\n",
"│ 3 │ 11.4 │ 113.897 │\n",
"│ 4 │ 11.41 │ 114.029 │\n",
"│ 5 │ 11.42 │ 114.16 │\n",
"│ 6 │ 11.43 │ 114.292 │"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"last(d, 6)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
],
"text/html": [
"\n",
"\n"
],
"text/plain": [
"Plot(...)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(d,x=\"H\",y=\"V\",Geom.line)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-48.357046148247086"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"real(roots(pvol - 10.)[1])"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-48.48516975908005"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"real(roots(pvol -12.)[1])"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-48.97899098468442"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"real(roots(pvol - 20.)[1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Calculations for a cylindrical well"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The cylindrical wells have a depth of 11.47 mm and a diameter (top/bottom) of 5.0/4.5 mm., corresponding to a radius of 2.5/2.25 mm.\n",
"\n",
"The radius $r$ at a height $H$ will be $2.25 + (0.25)*H/11.47$ mm"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"2.25 + 0.021795989537925022∙x"
],
"text/latex": [
"$2.25 + 0.021795989537925022\\cdot x$"
],
"text/plain": [
"Poly(2.25 + 0.021795989537925022*x)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pradius = Poly([2.25, (0.25)/(11.47)])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Just to make sure that I got that right."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2-element Array{Float64,1}:\n",
" 2.25\n",
" 2.5 "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"polyval(pradius,[0.,11.47])"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"15.904312808798327 + 0.3081335427452936∙x + 0.001492461216435598∙x^2"
],
"text/latex": [
"$15.904312808798327 + 0.3081335427452936\\cdot x + 0.001492461216435598\\cdot x^{2}$"
],
"text/plain": [
"Poly(15.904312808798327 + 0.3081335427452936*x + 0.001492461216435598*x^2)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"parea = π * pradius * pradius"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2-element Array{Float64,1}:\n",
" 15.904312808798327\n",
" 19.634954084936208"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"polyval(parea,[0.,11.47])"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"15.904312808798327∙x + 0.1540667713726468∙x^2 + 0.0004974870721451993∙x^3"
],
"text/latex": [
"$15.904312808798327\\cdot x + 0.1540667713726468\\cdot x^{2} + 0.0004974870721451993\\cdot x^{3}$"
],
"text/plain": [
"Poly(15.904312808798327*x + 0.1540667713726468*x^2 + 0.0004974870721451993*x^3)"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pvol = polyint(parea)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"H = collect(0.:0.01:12.);"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
],
"text/html": [
"\n",
"\n"
],
"text/plain": [
"Plot(...)"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(x=H,y=polyval(pvol,H),Geom.line,\n",
"Guide.XLabel(\"Height above well bottom (mm)\"),\n",
"Guide.YLabel(\"Volume (cubic mm)\"))"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-156.37132054994754"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"real(roots(pvol - 50.)[1])"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-157.81466509468657"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"real(roots(pvol - 100.)[1])"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-159.18546710697348"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"real(roots(pvol - 150.)[1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As a table"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"121×2 Array{Float64,2}:\n",
" 0.0 0.0 \n",
" 0.1 1.59197\n",
" 0.2 3.18703\n",
" 0.3 4.78517\n",
" 0.4 6.38641\n",
" 0.5 7.99074\n",
" 0.6 9.59816\n",
" 0.7 11.2087 \n",
" 0.8 12.8223 \n",
" 0.9 14.439 \n",
" 1.0 16.0589 \n",
" 1.1 17.6818 \n",
" 1.2 19.3079 \n",
" ⋮ \n",
" 10.9 192.306 \n",
" 11.0 194.252 \n",
" 11.1 196.201 \n",
" 11.2 198.153 \n",
" 11.3 200.109 \n",
" 11.4 202.069 \n",
" 11.5 204.032 \n",
" 11.6 205.998 \n",
" 11.7 207.967 \n",
" 11.8 209.941 \n",
" 11.9 211.917 \n",
" 12.0 213.897 "
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"H = 0.0:0.1:12.0;\n",
"[H polyval(pvol,H)]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.1.0",
"language": "julia",
"name": "julia-1.1"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.1.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}