Skip to content

Commit

Permalink
Write Square_OneSpecies example; Fix plotter; Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hedi-sel committed Feb 18, 2021
1 parent 5a15dbb commit eb7672f
Show file tree
Hide file tree
Showing 20 changed files with 152 additions and 132 deletions.
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The documentation can be found in: docs/_build/html/index.html
Or can be accessed online at: https://ardis.readthedocs.io/en/latest
Binary file modified docs/_build/doctrees/content/examples.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/content/started.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
18 changes: 16 additions & 2 deletions docs/_build/html/_sources/content/examples.rst.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
Tutorial
#######################################
Examples
#######################################


One species in a square
=========================

In this simulation, we use a single species (no reactions) placed in a square-shaped reactor.

We place an initial concentration of the species in a corner of the reactor.

.. image:: images/square_onespecies_t=0.png

Here is what the siulation should output after a few iterations of diffusion.

.. image:: images/square_onespecies_t=10.png
7 changes: 5 additions & 2 deletions docs/_build/html/_sources/content/started.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ Requirements
* CMake (3.10+), g++-7 (C++ 11 standard)
* CUDA Compatible Graphics card, and CUDA toolkit (10.2+).
* Python 3.6+, with the following modules:
* Numpy
* Matplotlib
* wheel
* setuptools
* pybind11[global]

Optional
-------------

* WolframScript (1.3.0+)
* (for building your own reactor shape)
* ImageMagick
* (to make gif clips)

Building
**************
Expand Down
21 changes: 16 additions & 5 deletions docs/_build/html/content/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>Tutorial &mdash; ARDiS documentation</title>
<title>Examples &mdash; ARDiS documentation</title>



Expand Down Expand Up @@ -87,7 +87,10 @@
<p class="caption"><span class="caption-text">Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="started.html">Getting started</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Tutorial</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Examples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#one-species-in-a-square">One species in a square</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="completedoc.html">Complete documentation</a></li>
</ul>

Expand Down Expand Up @@ -137,7 +140,7 @@

<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>

<li>Tutorial</li>
<li>Examples</li>


<li class="wy-breadcrumbs-aside">
Expand All @@ -156,8 +159,16 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<div class="section" id="tutorial">
<h1>Tutorial<a class="headerlink" href="#tutorial" title="Permalink to this headline"></a></h1>
<div class="section" id="examples">
<h1>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h1>
<div class="section" id="one-species-in-a-square">
<h2>One species in a square<a class="headerlink" href="#one-species-in-a-square" title="Permalink to this headline"></a></h2>
<p>In this simulation, we use a single species (no reactions) placed in a square-shaped reactor.</p>
<p>We place an initial concentration of the species in a corner of the reactor.</p>
<img alt="../_images/square_onespecies_t=0.png" src="../_images/square_onespecies_t=0.png" />
<p>Here is what the siulation should output after a few iterations of diffusion.</p>
<img alt="../_images/square_onespecies_t=10.png" src="../_images/square_onespecies_t=10.png" />
</div>
</div>


Expand Down
13 changes: 8 additions & 5 deletions docs/_build/html/content/started.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Tutorial" href="examples.html" />
<link rel="next" title="Examples" href="examples.html" />
<link rel="prev" title="Documentation and tutorial for ARDiS" href="../index.html" />
</head>

Expand Down Expand Up @@ -100,7 +100,7 @@
<li class="toctree-l2"><a class="reference internal" href="#license">License</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="completedoc.html">Complete documentation</a></li>
</ul>

Expand Down Expand Up @@ -180,8 +180,9 @@ <h3>Requirements<a class="headerlink" href="#requirements" title="Permalink to t
<li><p>CMake (3.10+), g++-7 (C++ 11 standard)</p></li>
<li><p>CUDA Compatible Graphics card, and CUDA toolkit (10.2+).</p></li>
<li><p>Python 3.6+, with the following modules:
* Numpy
* Matplotlib</p></li>
* wheel
* setuptools
* pybind11[global]</p></li>
</ul>
</div></blockquote>
<div class="section" id="optional">
Expand All @@ -190,6 +191,8 @@ <h4>Optional<a class="headerlink" href="#optional" title="Permalink to this head
<div><ul class="simple">
<li><p>WolframScript (1.3.0+)
* (for building your own reactor shape)</p></li>
<li><p>ImageMagick
* (to make gif clips)</p></li>
</ul>
</div></blockquote>
</div>
Expand Down Expand Up @@ -253,7 +256,7 @@ <h2>License<a class="headerlink" href="#license" title="Permalink to this headli
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="examples.html" class="btn btn-neutral float-right" title="Tutorial" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="examples.html" class="btn btn-neutral float-right" title="Examples" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="../index.html" class="btn btn-neutral float-left" title="Documentation and tutorial for ARDiS" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<p class="caption"><span class="caption-text">Contents</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="content/started.html">Getting started</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/examples.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/completedoc.html">Complete documentation</a></li>
</ul>

Expand Down
7 changes: 5 additions & 2 deletions docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<p class="caption"><span class="caption-text">Contents</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="content/started.html">Getting started</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/examples.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/completedoc.html">Complete documentation</a></li>
</ul>

Expand Down Expand Up @@ -166,7 +166,10 @@ <h1>Documentation and tutorial for ARDiS<a class="headerlink" href="#documentati
<li class="toctree-l2"><a class="reference internal" href="content/started.html#license">License</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="content/examples.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/examples.html">Examples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="content/examples.html#one-species-in-a-square">One species in a square</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="content/completedoc.html">Complete documentation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="content/completedoc.html#system">System</a></li>
</ul>
Expand Down
Binary file modified docs/_build/html/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<p class="caption"><span class="caption-text">Contents</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="content/started.html">Getting started</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/examples.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="content/completedoc.html">Complete documentation</a></li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions docs/content/examples.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
Tutorial
#######################################
Examples
#######################################


One species in a square
=========================

In this simulation, we use a single species (no reactions) placed in a square-shaped reactor.

We place an initial concentration of the species in a corner of the reactor.

.. image:: images/square_onespecies_t=0.png

Here is what the siulation should output after a few iterations of diffusion.

.. image:: images/square_onespecies_t=10.png
2 changes: 2 additions & 0 deletions docs/content/started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Optional

* WolframScript (1.3.0+)
* (for building your own reactor shape)
* ImageMagick
* (to make gif clips)

Building
**************
Expand Down
3 changes: 1 addition & 2 deletions example/BeadsModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
dampingPath, read_type.Symetric), matrix_type.CSR)
print("Dampness matrix loaded ...")

st = state(d_D.shape[0])
n = len(Mesh.x)


Expand All @@ -43,7 +42,7 @@
uprightcorner = dg.rect_zone(dg.point2d(9, 9), dg.point2d(10, 10))


simu = simulation(d_D.shape[0])
simu = simulation(n)
import_crn(simu, "chemicalReactionNetworks/bottomMETI.json")

simu.drain = drain
Expand Down
98 changes: 0 additions & 98 deletions example/Curve.py

This file was deleted.

69 changes: 69 additions & 0 deletions example/Square_OneSpecies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from ardis import *
import ardis.d_geometry as dg
import ardis.geometry as geo
import numpy as np
import os


#Set paths and locations
matrixFolder = "data"
outputFolder = "output"

dataName = "coarse_square"

dampingPath = matrixFolder+"/"+dataName+"_damping.mtx"
stiffnessPath = matrixFolder+"/"+dataName+"_stiffness.mtx"
meshPath = matrixFolder + "/" + dataName + "_mesh.dat"

#Load the mesh
Mesh = dg.read_mesh(meshPath)
#Copy the mesh to the GPU
d_Mesh = dg.d_mesh(Mesh.x, Mesh.y)

#Load Damping and stiffness matrices
S = read_spmatrix(stiffnessPath, read_type.Symetric)
D = read_spmatrix(dampingPath, read_type.Symetric)

#Copy the matrices to the GPU)
d_S = to_d_spmatrix(S, matrix_type.CSR)
d_D = to_d_spmatrix(D, matrix_type.CSR)

#Create a simulation
n = len(Mesh.x) #Number of nodes
simu = simulation(n)

#Set parameters
simu.drain = 0
simu.epsilon = 1.e-3

#Load matrices into the simulation
simu.load_stiffness_matrix(d_S)
simu.load_dampness_matrix(d_D)

#Create a species and set its concentration to zero
simu.add_species("A")
simu.set_species("A", np.zeros(n))

#Set the concentration of species A to 10 in the upper-left corner
upleftcorner = dg.rect_zone(dg.point2d(0, 7), dg.point2d(3, 10))
dg.fill_zone(simu.get_species("A"), d_Mesh, upleftcorner, 10)

#Plot the initial state of the simulation
fig = plot_state(simu.state, Mesh, title="square_onespecies", listSpecies=["A"], colors={"background": (0,0,0,0), "A": (0.8, 0.2, 0, 1)})
plt.show()
fig.savefig(outputFolder +"/square_onespecies_t=0.png")
plt.close(fig)

#Iterate diffusion
dt = 1
for i in range(0, 10):
simu.iterate_diffusion(dt)

#Plot the final state of the simulation
fig = plot_state(simu.state, Mesh, title="square_onespecies", listSpecies=["A"], colors={"background": (0,0,0,0), "A": (0.8, 0.2, 0, 1)})
plt.show()
fig.savefig(outputFolder +"/square_onespecies_t=10.png")
plt.close(fig)

print("Simulation completed!")
print("Figures saved in '" + outputFolder + "'")

0 comments on commit eb7672f

Please sign in to comment.