Skip to content

Commit

Permalink
Add support for multiple networks
Browse files Browse the repository at this point in the history
  • Loading branch information
manuvarkey committed Jun 19, 2022
1 parent f43e8de commit 9c4f2b9
Show file tree
Hide file tree
Showing 3 changed files with 499 additions and 143 deletions.
71 changes: 47 additions & 24 deletions Earth design simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@
"cell_type": "code",
"execution_count": 2,
"id": "76f6960d",
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/eee/Projects/Earthing/earthing/__init__.py:614: RuntimeWarning: divide by zero encountered in true_divide\n",
" COEF = self.rho/(4*pi*AA)*np.arctan(AA/ALPHA)\n"
"/home/eee/Projects/Earthing/earthing/__init__.py:692: RuntimeWarning: divide by zero encountered in true_divide\n",
" COEF = self.rho/(4*pi*a)*np.arctan(a/ALPHA)\n"
]
}
],
Expand All @@ -63,12 +65,19 @@
"Ig = 1000\n",
"\n",
"# Define network\n",
"network = Network(rho)\n",
"network.add_mesh([0,0,-h], Lx, Ly, Nx, Ny, strip_width)\n",
"network.add_rod([0,0,-h], radius_rod, Lr)\n",
"network.add_rod([Lx,0,-h], radius_rod, Lr)\n",
"network.add_rod([0,Ly,-h], radius_rod, Lr)\n",
"network.add_rod([Lx,Ly,-h], radius_rod, Lr)\n",
"network1 = Network(rho, Ig)\n",
"network1.add_mesh([0,0,-h], Lx, Ly, Nx, Ny, strip_width)\n",
"network1.add_rod([0,0,-h], radius_rod, Lr)\n",
"network1.add_rod([Lx,0,-h], radius_rod, Lr)\n",
"network1.add_rod([0,Ly,-h], radius_rod, Lr)\n",
"network1.add_rod([Lx,Ly,-h], radius_rod, Lr)\n",
"\n",
"# Add fence ring and electrode\n",
"network2 = Network(rho, 0)\n",
"network2.add_mesh([-2,-2,-h], Lx+4, Ly+4, 2, 2, strip_width)\n",
"network2.add_rod([-2,-2,-h], radius_rod, Lr)\n",
"\n",
"network = network1 + network2\n",
"\n",
"# Alternate network elements\n",
"# network.add_plate([0,0,-h_p], 0.6, 0.6, n_cap=[0,1,0], h_cap=[0,0,1]) # Vertical plate\n",
Expand All @@ -89,7 +98,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Value of earth resistance = 4.926 Ohm\n"
"Value of earth resistance = [4.901 inf] Ohm\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/eee/Projects/Earthing/earthing/__init__.py:730: RuntimeWarning: divide by zero encountered in true_divide\n",
" res = self.V / self.Ig\n"
]
}
],
Expand All @@ -108,7 +125,7 @@
"outputs": [],
"source": [
"# Plot surface potential\n",
"network.solve_surface_potential_fast(Ig, grid=grid, xlim=xlim, ylim=ylim)\n",
"network.solve_surface_potential_fast(grid=grid, xlim=xlim, ylim=ylim)\n",
"network.plot_geometry_3d(xlim=xlim, ylim=ylim, zlim=zlim, ground=False, ground_pot=True, current_distribution=True)\n",
"network.plot_surface_potential(xlim=xlim, ylim=ylim, plot_type='fill')\n",
"# network.plot_surface_potential(xlim=xlim, ylim=ylim, plot_type='contour') # Contour plot\n",
Expand All @@ -124,7 +141,7 @@
{
"data": {
"text/plain": [
"4926.0"
"array([4901.104, 2511.734])"
]
},
"execution_count": 5,
Expand All @@ -133,12 +150,12 @@
}
],
"source": [
"network.gpr(Ig)"
"network.gpr()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 6,
"id": "4b18a55d-8846-4537-989d-419c28a6c467",
"metadata": {
"tags": []
Expand All @@ -148,14 +165,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"1612.384 @ [5. 2.5]\n"
"1618.714 @ [5. 2.5]\n"
]
}
],
"source": [
"# Mesh voltage\n",
"polygon = [(0,0),(Lx,0),(Lx,Ly),(0,Ly),(0,0)]\n",
"Em_loc, Em = network.mesh_voltage(Ig, polygon, plot=True)\n",
"Em_loc, Em = network.mesh_voltage(polygon, plot=True, subnet=0)\n",
"print(Em, ' @ ', Em_loc)"
]
},
Expand All @@ -169,14 +186,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"833.171 @ [-0.657 -0.734]\n"
"817.389 @ [9.961 5.043]\n"
]
}
],
"source": [
"# Step voltage\n",
"polygon = rectangle((-1,-1), Lx+2, Ly+2)\n",
"Es_loc, Es = network.step_voltage(Ig, polygon, plot=True)\n",
"polygon = rectangle((-3,-3), Lx+6, Ly+6)\n",
"Es_loc, Es = network.step_voltage(polygon, plot=True)\n",
"print(Es, ' @ ', Es_loc)"
]
},
Expand All @@ -189,7 +206,7 @@
{
"data": {
"text/plain": [
"372.14632549416"
"445.0587225606989"
]
},
"execution_count": 8,
Expand All @@ -198,11 +215,17 @@
}
],
"source": [
"# Touch voltage at fence 2m away\n",
"loc = np.array([-Lx, -Ly, 0])\n",
"loc = loc/norm(loc)\n",
"network.get_point_potential(loc*2, Ig) - network.get_point_potential(loc*3, Ig)"
"# Touch voltage at fence\n",
"network.get_point_potential((-2,-2,0)) - network.get_point_potential((-3,-3,0))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "33c965a3",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 9c4f2b9

Please sign in to comment.