Commit 13e55597 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Add initial/dual to percolation

notebook
parent 7f51e129
......@@ -40,12 +40,16 @@
"rcParams['figure.figsize'] = (8., 6.) # Enlarge figure\n",
"rcParams['animation.html'] = 'html5' # to render animation in notebook\n",
"\n",
"from percolation import PercolationRect, PercolationHex, percolation_vs_p"
"from percolation import PercolationRect, PercolationHex, percolation_vs_p, PercolationRectDual"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Rectangular lattice"
]
......@@ -62,7 +66,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Hexagonal lattice"
]
......@@ -81,16 +89,24 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"percohex15 = PercolationHex(15, 15)\n",
"percohex15 = PercolationHex(30, 30)\n",
"interact(percohex15.plot, p=widgets.FloatSlider(min=0., max=1., step=0.1, value=0.5));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Probability of crossing as a function of $p$\n",
"\n",
......@@ -110,6 +126,28 @@
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Initial and dual graph for a rectangular percolation\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"perco = PercolationRectDual(5)\n",
"interact(perco.plot_graph, p=widgets.FloatSlider(min=0., max=1., step=0.1, value=0.5),\n",
" graph_type=widgets.RadioButtons(options=['initial', 'dual', 'both']));"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Todo\n",
"\n",
......@@ -130,6 +168,7 @@
}
],
"metadata": {
"celltoolbar": "Format de la Cellule Texte Brut",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
......
......@@ -346,7 +346,7 @@ class PercolationRectDual(PercolationRect):
self.p = None
self.rand_array = self._get_rand_array()
self.suptitle = f'Percolation on a {self.grid_type} grid'
self.ax = self.create_figure()
self.ax = None
self.handles = []
def _get_rand_array(self):
......@@ -359,7 +359,9 @@ class PercolationRectDual(PercolationRect):
def plot_graph(self, p, graph_type='initial'):
"""Plot graph using matplotlib"""
n = self.n
self.handles = [] # Reinitialize legend handles
self.sample = self._get_sample(p)
self.ax = self.create_figure()
self.ax.set_title(f'{self.n} x {self.n - 1}-grid, $p = {p}$',
fontsize=10)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment