Skip to content

Commit 13a0710

Browse files
author
Kiran Vaddi
committed
final finish up for making the repo public
1 parent 0fe0ad1 commit 13a0710

File tree

8 files changed

+65693
-8480
lines changed

8 files changed

+65693
-8480
lines changed

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ This will plot the following:
9191
## Notebooks
9292
This repository is shipped few useful [notebooks](https://github.com/kiranvad/pyMECSim/tree/master/notebooks).
9393
* [Cyclic Voltammetry Simulation Example for Single Electron Transfer Mechanism](https://github.com/kiranvad/pyMECSim/blob/master/notebooks/Cyclic%20Voltammetry%20Simulation%20Example%20for%20Single%20Electron%20Transfer%20Mechanism.ipynb) -- that examplains all the possible use case of the simulator on a simple one electron transfer mehcanism
94-
* [Kinetic Zone Diagram](https://github.com/kiranvad/pyMECSim/blob/master/notebooks/Kinetic%20Zone%20%Diagram.ipynb) -- exmaple explaining how to generate various CV curves in the [kinetic zone diagram](https://www.nature.com/articles/s41570-017-0039/figures/2)
94+
* [Kinetic Zone Diagram](/notebooks/Kinetic%20Zone%20Diagram.ipynb) -- exmaple explaining how to generate various CV curves in the [kinetic zone diagram](https://www.nature.com/articles/s41570-017-0039/figures/2)
9595
9696
9797
## Notes

pymecsim/EC_Model.fin

Lines changed: 61 additions & 181 deletions
Large diffs are not rendered by default.

pymecsim/EC_Model.tvc

Lines changed: 32770 additions & 4098 deletions
Large diffs are not rendered by default.

pymecsim/MECSimOutput_Pot.txt

Lines changed: 32775 additions & 4103 deletions
Large diffs are not rendered by default.

pymecsim/Master.inp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
2.98e+02 !T
22
0.00e+00 !Rh
3-
5.00e-01 !E_start
4-
-5.00e-01 !E_rev
3+
5.10e-01 !E_start
4+
-5.10e-01 !E_rev
55
1 !num_cycles
6-
1.00e+00 !scan_rate
7-
12 !points in time across n cycle
6+
7.50e-02 !scan_rate
7+
15 !points in time across n cycle
88
0 ! correct vscan and freq for DigiPot/FFT
99
1 ! output type: 0=E,i,t; 1=DigiPot compatible
1010
0 ! EC type: 0 = Butler-Volmer, 1 = Marcus theory
@@ -35,18 +35,15 @@
3535
1.00e-05 ! nu_RDE
3636
1 ! number of AC sources to add (keep 1 with zero amplitude if want DC only)
3737
0.00e+00, 1.80e+01 ! AC sin wave: amp (mV), freq(Hz) (REPEAT)
38-
4 ! Number of species
39-
1.00e-06, 1.00e-05, 0 ! P
40-
0.00e+00, 1.00e-05, 0 ! Q
41-
1.00e-05, 1.00e-05, 0 ! A
42-
0.00e+00, 1.00e-05, 0 ! B
38+
3 ! Number of species
39+
1.00e-06, 1.00e-03, 0 ! Cu2O
40+
0.00e+00, 0.00e+00, 0 ! Cu
41+
1.00e-06, 1.00e-02, 0 ! CuO2--
4342
3 ! Number of terms
4443
0 ! E_pzc (V)
4544
0 ! a_0
4645
0 ! a_1
4746
0 ! a_2
4847
0 ! a_3
49-
0, -1, 1, 0, 0, 0.0e0, 0.0e0, 0.00e+00, 1.00e+01, 5.00e-01 !Charge Transfer : 1 P + 1 e <=> 1 Q
50-
2, 1, -1, -1, 1, 3.89e+10, 1.00e-05, 0.0e0, 0.0e0, 0.50 !Chemical Reaction : 1 Q + 1 A <=> 1 P + 1 B
51-
52-
48+
0, -1, 1, 0, 0.0e0, 0.0e0, -5.50e-01, 1.00e-01, 5.00e-01 !Charge Transfer : 1 Cu2O + 1 e <=> 1 Cu
49+
0, 1, 0, -1, 0.0e0, 0.0e0, -1.20e-01, 1.00e+05, 5.00e-01 !Charge Transfer : 1 CuO2-- + 1 e <=> 1 Cu2O

pymecsim/from_expt.inp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
2.98e+02 !T
22
0.00e+00 !Rh
3-
5.00e-01 !E_start
4-
-5.00e-01 !E_rev
3+
5.10e-01 !E_start
4+
-5.10e-01 !E_rev
55
1 !num_cycles
6-
1.00e+00 !scan_rate
7-
12 !points in time across n cycle
6+
7.50e-02 !scan_rate
7+
15 !points in time across n cycle
88
0 ! correct vscan and freq for DigiPot/FFT
99
1 ! output type: 0=E,i,t; 1=DigiPot compatible
1010
0 ! EC type: 0 = Butler-Volmer, 1 = Marcus theory
@@ -35,18 +35,15 @@
3535
1.00e-05 ! nu_RDE
3636
1 ! number of AC sources to add (keep 1 with zero amplitude if want DC only)
3737
0.00e+00, 1.80e+01 ! AC sin wave: amp (mV), freq(Hz) (REPEAT)
38-
4 ! Number of species
39-
1.00e-06, 1.00e-05, 0 ! P
40-
0.00e+00, 1.00e-05, 0 ! Q
41-
1.00e-05, 1.00e-05, 0 ! A
42-
0.00e+00, 1.00e-05, 0 ! B
38+
3 ! Number of species
39+
1.00e-06, 1.00e-03, 0 ! Cu2O
40+
0.00e+00, 0.00e+00, 0 ! Cu
41+
1.00e-06, 1.00e-02, 0 ! CuO2--
4342
3 ! Number of terms
4443
0 ! E_pzc (V)
4544
0 ! a_0
4645
0 ! a_1
4746
0 ! a_2
4847
0 ! a_3
49-
0, -1, 1, 0, 0, 0.0e0, 0.0e0, 0.00e+00, 1.00e+01, 5.00e-01 !Charge Transfer : 1 P + 1 e <=> 1 Q
50-
2, 1, -1, -1, 1, 3.89e+10, 1.00e-05, 0.0e0, 0.0e0, 0.50 !Chemical Reaction : 1 Q + 1 A <=> 1 P + 1 B
51-
52-
48+
0, -1, 1, 0, 0.0e0, 0.0e0, -5.50e-01, 1.00e-01, 5.00e-01 !Charge Transfer : 1 Cu2O + 1 e <=> 1 Cu
49+
0, 1, 0, -1, 0.0e0, 0.0e0, -1.20e-01, 1.00e+05, 5.00e-01 !Charge Transfer : 1 CuO2-- + 1 e <=> 1 Cu2O

pymecsim/input.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def __init__(self, reactants, products, E0, ks=1e4, alpha=0.5):
129129

130130

131131
def get_params_as_string(self):
132-
params = ' ks= {:.2E}, '.format(self.ks)
133-
params += 'E0 = {:.2E}, '.format(self.E0)
134-
params += 'alpha = {:.2f}'.format(self.alpha)
132+
params = ' ks= {}, '.format(process_parameter(self.ks))
133+
params += 'E0 = {}, '.format(process_parameter(self.E0))
134+
params += 'alpha = {}'.format(process_parameter(self.alpha))
135135

136136
return params
137137

@@ -187,8 +187,8 @@ def __init__(self, reactants, products, kf=1e4, kb=1e4):
187187

188188

189189
def get_params_as_string(self):
190-
params = ' kf= {:.2E}, '.format(self.kf)
191-
params += 'kb= {:.2E} '.format(self.kb)
190+
params = ' kf= {}, '.format(process_parameter(self.kf))
191+
params += 'kb= {} '.format(process_parameter(self.kb))
192192

193193
return params
194194

@@ -329,13 +329,16 @@ class Voltammetry:
329329
(This function has not been tested)
330330
331331
"""
332-
def __init__(self, objs=None):
332+
def __init__(self, objs=None, N=12):
333+
"""
334+
N : Number of spatial points as a power of two
335+
"""
336+
self.N = N
333337
self.set_defaults()
334338
self.objs = objs
335339
self.ramp = 0
336340
self._check_objs()
337341

338-
339342
def from_file(self):
340343
dirname = os.path.dirname(__file__)
341344
fname = os.path.join(dirname, 'Einput.txt')
@@ -350,7 +353,7 @@ def get_input(self):
350353
for key, value in self.dcvolt_params.items():
351354
lines.append('{}\t!{}\n'.format(process_parameter(value), key))
352355

353-
lines.append('12\t!points in time across n cycle \n')
356+
lines.append('{}\t!points in time across n cycle \n'.format(process_parameter(self.N)))
354357
lines.append('0\t! correct vscan and freq for DigiPot/FFT \n')
355358
lines.append('1\t! output type: 0=E,i,t; 1=DigiPot compatible \n')
356359
lines.append('0\t! EC type: 0 = Butler-Volmer, 1 = Marcus theory \n')

pymecsim/log.txt

Lines changed: 55 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10,113 +10,105 @@
1010
Uncompensated R = 0.0
1111

1212
Voltage ramp (V):
13-
E_start = 0.5000
14-
E_rev = -0.5000
15-
E_end = 0.5000
13+
E_start = 0.5100
14+
E_rev = -0.5100
15+
E_end = 0.5100
1616
Cycles = 1
17-
Total range = 2.0000
17+
Total range = 2.0400
1818

19-
Scan rate (V/s) = 1.00000000E+00
20-
Final time (s) = 2.00000000E+00
19+
Scan rate (V/s) = 7.50000000E-02
20+
Final time (s) = 2.72000000E+01
2121

2222
Found 1 AC signal(s). Max frequency = 0.0000 Hz
23-
0.0000 mV at 18.0000 Hz
23+
0.0000 mV at 18.0147 Hz
2424

2525
No capacitor requested
2626

27-
Need to enter ghost reaction of the form
28-
C + 1e = D ; E0 = 0.922 , ks = 0.0000E+00 , alpha = 0.500
29-
with E0= 0.92182831236606899
27+
Linked CT reaction at CT reaction number 1
28+
With species numbers: 3 0 0
3029

31-
Found a total of 4 species
30+
Found a total of 3 species
3231

3332
No pre-equilibriation; use entered concentrations
3433

3534
Summary of solution reactions:
36-
Charge transfer = 1
35+
Charge transfer = 2
3736
1st Order Chem = 0
38-
2nd Order Chem = 1
37+
2nd Order Chem = 0
3938
Summary of surface confined reactions:
4039
Charge transfer = 0
4140
1st Order Chem = 0
4241
2nd Order Chem = 0
4342

4443
Charge transfer reaction(s):
45-
A + 1e = B ; E0 = 0.000 , ks = 1.0000E+01 cm/s , alpha = 0.50
46-
; K_eqm = 2.8576E+08
47-
Chemical reaction(s):
48-
B + C = A + D ; kf,kb = 3.890000E+10 1.000000E-05 cm3/(mol.s)
49-
; K_eqm = 3.8900E+15
44+
A + 1e = B ; E0 = -0.550 , ks = 1.0000E-01 cm/s , alpha = 0.50
45+
; K_eqm = 8.4471E+17
46+
C + 1e = A ; E0 = -0.120 , ks = 1.0000E+05 cm/s , alpha = 0.50
47+
; K_eqm = 4.5139E+10
5048

5149
Electrode geometry:
5250
Planar with area = 1.00000000E+00 cm^2
5351

5452
Technical details of simulation
5553
Using Butler-Volmer Theory
56-
Points in time = 2^12 = 4096
57-
delt = 4.8828E-04 and delE = 4.8828E-04
58-
Exponential spatial grid with 180 points and delx(0) = 5.0104E-11
59-
x = 2.4426E-11 7.7099E-11 1.3531E-10 1.9965E-10 | 2.9755E-02
54+
Points in time = 2^15 = 32768
55+
delt = 8.3008E-04 and delE = 6.2256E-05
56+
Exponential spatial grid with 60 points and delx(0) = 9.1109E-03
57+
x = 4.4416E-03 1.4020E-02 2.4605E-02 3.6303E-02 | 3.3158E+01
6058

6159
Solution phase:
6260
Initial scaled concentrations and diffusion coeff (cm2/s)
63-
[A] = 1.00000000E-06 ; D = 1.00000000E-05
64-
(0.09090909)
65-
[B] = 0.00000000E+00 ; D = 1.00000000E-05
66-
(0.00000000)
67-
[C] = 1.00000000E-05 ; D = 1.00000000E-05
68-
(0.90909091)
69-
[D] = 0.00000000E+00 ; D = 1.00000000E-05
61+
[A] = 1.00000000E-06 ; D = 1.00000000E-03
62+
(0.50000000)
63+
[B] = 0.00000000E+00 ; D = 1.00000000E+00
7064
(0.00000000)
71-
Concentrations scaled by 1.10000000E-05 mol/cm3
72-
1.10000000E+01 mM
65+
[C] = 1.00000000E-06 ; D = 1.00000000E-02
66+
(0.50000000)
67+
Concentrations scaled by 2.00000000E-06 mol/cm3
68+
2.00000000E+00 mM
7369

7470

7571
************** Starting Time Loop ******************
7672

77-
Done 10%; t,Eapp,i = 2.00E-01 3.00E-01 -1.58E-06, C_err= 8.19E-09
78-
0.0909 0.0000 0.9090 0.0001 0.0000 0.0000
79-
Done 20%; t,Eapp,i = 4.00E-01 1.00E-01 -3.34E-03, C_err= 9.19E-09
80-
0.0891 0.0018 0.7448 0.1643 0.0000 0.0000
81-
Done 30%; t,Eapp,i = 6.00E-01 -9.96E-02 -4.79E-03, C_err= 1.19E-08
82-
0.0019 0.0890 0.0000 0.9091 0.0000 0.0000
83-
Done 40%; t,Eapp,i = 8.00E-01 -3.00E-01 -3.14E-03, C_err= 1.28E-08
84-
0.0000 0.0909 0.0000 0.9091 0.0000 0.0000
85-
Done 50%; t,Eapp,i = 1.00E+00 -5.00E-01 -2.52E-03, C_err= 1.54E-08
86-
0.0000 0.0909 0.0000 0.9091 0.0000 0.0000
87-
Done 60%; t,Eapp,i = 1.20E+00 -3.00E-01 -2.16E-03, C_err= 1.75E-08
88-
0.0000 0.0909 0.0000 0.9091 0.0000 0.0000
89-
Done 70%; t,Eapp,i = 1.40E+00 -1.00E-01 -1.89E-03, C_err= 1.78E-08
90-
0.0018 0.0891 0.0000 0.9091 0.0000 0.0000
91-
Done 80%; t,Eapp,i = 1.60E+00 9.96E-02 -6.28E-04, C_err= 1.99E-08
92-
0.0891 0.0018 0.0242 0.8849 0.0000 0.0000
93-
Done 90%; t,Eapp,i = 1.80E+00 3.00E-01 -7.34E-07, C_err= 2.08E-08
94-
0.0909 0.0000 0.1878 0.7213 0.0000 0.0000
95-
Done 100%; t,Eapp,i = 2.00E+00 5.00E-01 -3.62E-10, C_err= 2.03E-08
96-
0.0909 0.0000 0.2689 0.6402 0.0000 0.0000
73+
Done 10%; t,Eapp,i = 2.72E+00 3.06E-01 1.05E-03, C_err= -3.42E-01
74+
0.0000 0.0000 0.6581 0.0000 0.0000 0.0000
75+
Done 20%; t,Eapp,i = 5.44E+00 1.02E-01 7.38E-04, C_err= -3.42E-01
76+
0.0001 0.0000 0.6581 0.0000 0.0000 0.0000
77+
Done 30%; t,Eapp,i = 8.16E+00 -1.02E-01 -2.12E-03, C_err= -1.47E-01
78+
0.2828 0.0000 0.5706 0.0000 0.0000 0.0000
79+
Done 40%; t,Eapp,i = 1.09E+01 -3.06E-01 -4.71E-03, C_err= 1.07E+00
80+
2.0722 0.0001 0.0015 0.0000 0.0000 0.0000
81+
Done 50%; t,Eapp,i = 1.36E+01 -5.10E-01 -9.95E-03, C_err= 5.00E-03
82+
0.9702 0.0348 0.0000 0.0000 0.0000 0.0000
83+
Done 60%; t,Eapp,i = 1.63E+01 -3.06E-01 -8.73E-04, C_err= 1.06E+00
84+
2.0540 0.0007 0.0015 0.0000 0.0000 0.0000
85+
Done 70%; t,Eapp,i = 1.90E+01 -1.02E-01 7.73E-03, C_err= -1.51E-01
86+
0.2817 0.0000 0.5671 0.0000 0.0000 0.0000
87+
Done 80%; t,Eapp,i = 2.18E+01 1.02E-01 2.52E-03, C_err= -3.42E-01
88+
0.0001 0.0000 0.6581 0.0000 0.0000 0.0000
89+
Done 90%; t,Eapp,i = 2.45E+01 3.06E-01 1.56E-03, C_err= -3.42E-01
90+
0.0000 0.0000 0.6581 0.0000 0.0000 0.0000
91+
Done 100%; t,Eapp,i = 2.72E+01 5.10E-01 1.16E-03, C_err= -3.42E-01
92+
0.0000 0.0000 0.6581 0.0000 0.0000 0.0000
9793

9894
Concentration min/max values:
99-
0.0000 0.0000 -0.0000 0.0000 0.0000 0.0000
100-
0.0909 0.0909 0.9091 0.9091 0.0000 0.0000
95+
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
96+
2.0722 0.0357 0.6582 0.0000 0.0000 0.0000
10197

10298
****************************************************
10399

104-
Current minimum = -1.13560220E-02 and maximum = 0.00000000E+00
105-
Voltage minimum = 4.49218750E-02 and maximum = 0.00000000E+00
100+
Current minimum = -9.95293401E-03 and maximum = 2.15123940E-02
101+
Voltage minimum = -5.10000000E-01 and maximum = 5.09937744E-01
106102

107103
Average number of iterations at electrode surface = 1.000
108-
Average number of iterations for chemical reactions = 1.683
104+
Average number of iterations for chemical reactions = 1.000
109105
Average ODE calculations for iterating surface conf = 0.000
110106
Average ODE calculations for bounding surface conf = 0.000
111107

112108
Final scaled concentrations on spatial grid
113-
[A] = 9.09090923E-02 9.09090923E-02 9.09090923E-02 | 9.09090909E-02
114-
[B] = 3.18134265E-10 3.18133433E-10 3.18131638E-10 | 1.34485939E-23
115-
[C] = 2.68896937E-01 2.68896937E-01 2.68896937E-01 | 9.09090386E-01
116-
[D] = 6.40193990E-01 6.40193990E-01 6.40193990E-01 | 5.23150001E-07
117-
118-
Error in concentration sum (=0 if D_A = D_B etc)
119-
2.03333324E-08 2.03333321E-08 2.03333319E-08 | 1.64535052E-13
109+
[A] = 1.48432686E-11 2.31381557E-02 7.28518007E-02 | 5.00000000E-01
110+
[B] = 4.24636210E-12 1.73343792E-06 5.47146989E-06 | 4.53996721E-10
111+
[C] = 6.58114176E-01 6.55627017E-01 6.50265599E-01 | 5.00000000E-01
120112

121113

122114
Output file written to MECSimOutput_Pot.txt

0 commit comments

Comments
 (0)