{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 二维胶粒的耗尽力\n",
"+ slug: two-dimension-depletion-force-between-colloids\n",
"+ date: 2015-09-15\n",
"+ tags: soft matter"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 基本数据结构\n",
"+ 曲线由分段圆弧组成\n",
"+ 直线可以看作是一种特殊的半径为无穷大的圆弧"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 优良性质\n",
"__引理__ 分段圆弧扩展之后的曲线依然是分段圆弧\n",
"+ 直线扩展后还是直线\n",
"+ 半径为$R$的圆扩展$d$后是半径为$R+d$的圆\n",
"+ 转接点扩展$d$后产生的新的曲线是圆$d$\n",
"+ 综上,无论怎么扩展,扩展前后曲线类型不变"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from deplete.colloids import *\n",
"L, C = Line([0,2], [3,5]), Circle(3, [0,0], [0, pi/2])\n",
"subplot(121)\n",
"L.draw()\n",
"L.extend(0.1).draw()\n",
"axis('square');\n",
"subplot(122)\n",
"C.draw()\n",
"C.extend(0.1).draw()\n",
"axis('square');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 扩展曲线\n",
"### Naive的扩展方式\n",
"+ 设定好定向,对应图像轮廓由一系列矢量弧段$a_1, a_2,\\ldots a_n$组成\n",
"+ 普通段普通扩展$a_i\\rightarrow a_i'$\n",
" + 区分角度增加/减少的区别\n",
" - 角度**增加**的时候半径为正$r=|r|$\n",
" - 角度**减少**的时候半径为负$r=-|r|$\n",
" + 做变换$r\\rightarrow r'=r+d$"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"c=triangloid(1, 1, 0.2, -0.4)\n",
"c.draw(label='colloid')\n",
"title('Naive idea')\n",
"for seg in c:\n",
" seg.extend(0.1).draw()\n",
"axis('equal');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 处理转折点\n",
"+ 如果顺拐,即$a_i\\times a_{i+1}>0$,转折段扩展出圆弧\n",
"+ 如果逆拐,即$a_i\\times a_{i+1}<0$,转折段可以扩展出圆弧,但是直线更适合处理,因为终究需要剪除"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"c.draw(label='colloid')\n",
"title('Considering Turning points')\n",
"c.offset_raw(0.1).draw_each()\n",
"axis('equal');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 终极扩展方式\n",
"+ __问题__:我们现在的曲线,已经包含了扩展后的边界,但是有部分面积被环绕了多次\n",
"+ __解决方法__:剪除重复的正面积,保留真正的边界\n",
"+ __简化__方法:即最大的正边界\n",
"+ __BUG__: 某些凹陷严重情形下扩展会有bug,蚀刻时也会有bug"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"off=linspace(0, 0.4, 5)\n",
"for o in off:\n",
" c.offset(o).draw(label='Offset {:.1f}'.format(o))\n",
"legend(loc=\"upper right\")\n",
"axis('equal');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 曲线相交\n",
"Depletion把两个当成一个整体"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Area | \n",
" Offset | \n",
" Perimeter | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 2.423661 | \n",
" 0.0 | \n",
" 7.423733 | \n",
"
\n",
" \n",
" | 1 | \n",
" 3.170664 | \n",
" 0.1 | \n",
" 7.516340 | \n",
"
\n",
" \n",
" | 2 | \n",
" 3.926929 | \n",
" 0.2 | \n",
" 7.608948 | \n",
"
\n",
" \n",
" | 3 | \n",
" 4.699730 | \n",
" 0.3 | \n",
" 7.938916 | \n",
"
\n",
" \n",
" | 4 | \n",
" 5.521669 | \n",
" 0.4 | \n",
" 8.510362 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Area Offset Perimeter\n",
"0 2.423661 0.0 7.423733\n",
"1 3.170664 0.1 7.516340\n",
"2 3.926929 0.2 7.608948\n",
"3 4.699730 0.3 7.938916\n",
"4 5.521669 0.4 8.510362"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"area=[c.offset(o).area() for o in off]\n",
"peri=[c.offset(o).perimeter() for o in off]\n",
"pd.DataFrame({\"Offset\": off, \"Area\": area, \"Perimeter\": peri})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}