diff --git a/Readme.md b/Readme.md
index e2ebb54..0f493ae 100644
--- a/Readme.md
+++ b/Readme.md
@@ -4,7 +4,7 @@ This is a python wrapper for [MECSim](http://www.garethkennedy.net/MECSim.html)
It works completely in python in a Linux environment. I wrote this while working on [GPCV](https://github.com/kiranvad/gpcv) related work.
If you use this software in your work please cite the original MECSim software along with this repository:
-```
+```bibtex
@misc{pymecsim,
author = {Kiran Vaddi},
title = {{pyMECSim: A Python wrapper for MECSim}},
@@ -15,17 +15,17 @@ If you use this software in your work please cite the original MECSim software a
url = {https://github.com/kiranvad/pyMECSim}
}
```
-
-This repository is arranged as follows:
-1. src : Contains the original MECSim software distributed under the same license as MECSim
-2. notebooks : An example usage of pyMECSim is shown.
-3. mechanisms : Folder where you can host a original mechanism as an input file
+To install as a package, run
+```bash
+pip install git+https://github.com/kiranvad/pyMECSim#egg=pyMECSIM.`
+```
+Dependencies will be checked and installed from the setup.py file.
A sample usage is as follows:
Import `pymecsim` using the following:
```python
-from src.pymecsim import MECSIM, pysed, plotcv
+from pymecsim import MECSIM, pysed
```
We can perform a simulation on a one electron transfer mechanism and visualize the effect of changing the formal potential using the following code:
@@ -42,8 +42,8 @@ dirname = os.getcwd()
for i,e0 in enumerate(E0):
outfile = dirname + '/outfile.sk'
pysed('$E0', str(e0), configfile, outfile)
- out = MECSIM(outfile)
- ax = plotcv(out['current'],out['voltage'], ax = ax)
+ model = MECSIM(outfile)
+ ax = model.plot(ax = ax)
ax.set_label("E0 = "+str(e0))
plt.legend([r'$E_0=0.5$',r'$E_0=0.1$',r'$E_0=1e-2$'],loc='lower right')
#plt.savefig('cvexample.png',dpi=500,bbox_inches='tight')
@@ -51,17 +51,23 @@ plt.show()
```
This will plot the following:
-
+
Naturally, you would want to be able to run simulations for different mechanisms and confgurations. You can do that by just defining a mechanism that MECSim can model(see examples for some possible reaction mechanisms [here](http://www.garethkennedy.net/MECSimScripts.html)).
Once you have the mechanism file in say `/path/to/folder/mechanism.sk` format, turn it in as an input to pyMECSim using the following:
```python
-out = MECSIM('/path/to/folder/mechanism.sk')
-plotcv(out['current'],out['voltage'])
+model = MECSIM('/path/to/folder/mechanism.sk')
+model.plot()
+plt.show()
```
+One can also get concentration profiles by first indicating `MECSIM` to return concentration profiles in the configuration file by setting `1 ! show debug output files as well as MECSimOutput.txt (1=yes; 0=no)`. `pymecsim` will then be able to return concentration profiles as numpy arrays. see `notebooks/Cyclic Voltammetry Simulation Example for Single Electron Transfer Mechanism.ipynb` for an example use case.
+
+
+## Notes
+Please free to contribute to this repository both interms of code and documetation or simple example use cases in jupyter notebook. Submit a pull request and I would be happy to integrate into this repository.
diff --git a/__init__.py b/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/mechanisms/cvexamples.sk b/mechanisms/cvexamples.sk
index 4472c4d..dbffdac 100644
--- a/mechanisms/cvexamples.sk
+++ b/mechanisms/cvexamples.sk
@@ -15,7 +15,7 @@
10.0 ! Dstar_min
0.005e0 ! max voltage step
25.6e0 ! time resolution experimentally to correct vscan/f (us)
-0 ! show debug output files as well as MECSimOutput.txt (1=yes; 0=no)
+1 ! show debug output files as well as MECSimOutput.txt (1=yes; 0=no)
0 ! use advanced voltage ramp (0 = E_start=E_end, 1 = use advanced ramp below, 2=From file "EInput.txt")
2 ! number of E_rev lines for advanced ramp (if enter 0 then first E_rev value is the final time
0.0 ! E_start (V)
diff --git a/notebooks/.ipynb_checkpoints/Cyclic Voltammetry Simulation Example for Single Electron Transfer Mechanism-checkpoint.ipynb b/notebooks/.ipynb_checkpoints/Cyclic Voltammetry Simulation Example for Single Electron Transfer Mechanism-checkpoint.ipynb
index 6583564..027fca5 100644
--- a/notebooks/.ipynb_checkpoints/Cyclic Voltammetry Simulation Example for Single Electron Transfer Mechanism-checkpoint.ipynb
+++ b/notebooks/.ipynb_checkpoints/Cyclic Voltammetry Simulation Example for Single Electron Transfer Mechanism-checkpoint.ipynb
@@ -5,7 +5,7 @@
"metadata": {},
"source": [
"## Using MECSim\n",
- "To be finished soon"
+ "In this example we look at a simple example case of single electron trasnfer mechanism. We simulate Cyclic Voltametry response of this particualr mechanism with a planar electrode assumption."
]
},
{
@@ -14,27 +14,12 @@
"metadata": {},
"outputs": [],
"source": [
- "%load_ext autoreload\n",
- "%autoreload 2"
+ "from pymecsim import pysed, MECSIM"
]
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "import sys\n",
- "if '../' not in sys.path:\n",
- " sys.path.insert(0,'../')\n",
- "import os\n",
- "\n",
- "from src.pymecsim import pysed, MECSIM, plotcv"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
+ "execution_count": 2,
"metadata": {},
"outputs": [
{
@@ -74,14 +59,14 @@
" \n",
" \n",
+ "\" id=\"mb92f4f7d36\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" \n",
" \n",
- " \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -209,11 +194,11 @@
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -224,11 +209,11 @@
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -396,14 +381,14 @@
" \n",
" \n",
+ "\" id=\"macca456a85\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -417,11 +402,11 @@
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -471,11 +456,11 @@
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -488,11 +473,11 @@
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -503,7 +488,7 @@
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
- " \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -602,14 +566,13 @@
" \n",
" \n",
" \n",
- " \n",
- " \n",
- " \n",
+ " \n",
+ " \n",
" \n",
" \n",
" \n",
" \n",
- " \n",
" \n",
" \n",
- " \n",
" \n",
" \n",
- " \n",
" \n",
" \n",
- " \n",
- " \n",
- " \n",
- " \n",
- " \n",
- " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -1120,12 +1083,12 @@
" \n",
" \n",
" \n",
- " \n",
- " \n",
- " \n",
- " \n",
- " \n",
- " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -1158,20 +1121,20 @@
"\" id=\"CMMI12-101\"/>\n",
" \n",
" \n",
- " \n",
- " \n",
- " \n",
- " \n",
- " \n",
- " \n",
- " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
- " \n",
+ " \n",
" \n",
" \n",
" \n",
@@ -1192,6 +1155,9 @@
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"%config InlineBackend.figure_formats = ['svg']\n",
+ "import os\n",
+ "import warnings\n",
+ "warnings.filterwarnings(\"ignore\")\n",
"\n",
"configfile = '../mechanisms/cvexamples.sk'\n",
"E0 = [-0.25,0.0,0.25]\n",
@@ -1201,16 +1167,2369 @@
"for i,e0 in enumerate(E0):\n",
" outfile = dirname + '/outfile.sk'\n",
" pysed('$E0', str(e0), configfile, outfile)\n",
- " out = MECSIM(outfile)\n",
- " T = out['time']\n",
+ " model = MECSIM(outfile)\n",
+ " T = model.T\n",
" forward_sweep = np.arange(len(T)/2,len(T)).astype(int)\n",
- " ax = plotcv(out['current'],out['voltage'], ax = ax)\n",
+ " model.plot(ax=ax)\n",
" ax.set_label(\"E0 = \"+str(e0))\n",
"plt.legend([r'$E_0=0.5$',r'$E_0=0.1$',r'$E_0=1e-2$'],loc='lower right')\n",
"#plt.savefig('cvexample.png',dpi=500,bbox_inches='tight')\n",
"plt.show()"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We can visualize the concentration profiles of the species in the bulk and at the surface. In this example, we simulated `A +1e = B` thus we have two species. Since this is a simple one step reaction mechanism and diffusin driven, we should see that increase in concentration of species `A` should lead to decrease in concentration of species `B` at the surface where the electron transfer takes place. Similarily in the bulk, one should observe similar behavior upuntil a `diffusion layer` length scale."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "text/plain": [
+ "