-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write Square_OneSpecies example; Fix plotter; Update docs
- Loading branch information
Showing
20 changed files
with
152 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + "'") |
Oops, something went wrong.