Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.12 #203

Merged
merged 21 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macOS-latest]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0, 3.12.0]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -22,8 +22,7 @@ jobs:
- name: Installation
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
pip install .
- name: First test
run: |
opem test
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- License updated
- `Python 3.10` added to `test.yml`
- `Python 3.11` added to `test.yml`
- `Python 3.12` added to `test.yml`
- Logo updated
- `AUTHORS.md` updated
- `README.md` modified
- `INSTALL.md` modified
Comment on lines +15 to +19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • test modified

- Test system modified
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sadrasabouri Mentioned here 🔥

- Setup system modified
- CLI mode updated
Expand Down
17 changes: 4 additions & 13 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,17 @@
- [x] Select `Add to PATH` option
- [x] Select `Install pip` option
- Download [Version 1.3](https://github.com/ecsim/opem/archive/v1.3.zip) or [Latest Source ](https://github.com/ecsim/opem/archive/master.zip)
- Run `pip install -r requirements.txt` or `pip3 install -r requirements.txt` (Need root access)
- Run `python3 setup.py install` or `python setup.py install` (Need root access)
- Run `pip install .`

### PyPI


- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
- Run `pip install opem` or `pip3 install opem` (Need root access)

### Easy Install

- Run `easy_install --upgrade opem` (Need root access)
- Run `pip install opem==1.3`

### Conda

- Check [Conda Managing Package](https://conda.io)
- `conda install -c ecsim opem` (Need root access)
- `conda install -c ecsim opem`

### GUI

- OPEM GUI is available [here](https://github.com/ECSIM/gopem)

### Exe Version (Only Windows)
Expand All @@ -43,7 +34,7 @@
- Download and install [Python3.x](https://www.python.org/downloads/) (>=3.5, 64/32 bit)
- [x] Select `Add to PATH` option
- [x] Select `Install pip` option
- Run `pip install opem` or `pip3 install opem` (Need root access)
- Run `pip install .`
- Configure Python interpreter
```matlab
>> pyversion PYTHON_EXECUTABLE_FULL_PATH
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1553,10 +1553,6 @@ Download [OPEM.bib](http://www.ecsim.ir/opem/OPEM.bib)(BibTeX Format)
<td align="center">Zenodo</td>
<td align="center"><a href="https://doi.org/10.5281/zenodo.1133110"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.1133110.svg" alt="DOI"></a></td>
</tr>
<tr>
<td align="center">Researchgate</td>
<td align="center"><a href="https://www.researchgate.net/project/Open-Source-Electrochemistry-Simulation-Toolbox"><img src="https://img.shields.io/badge/Researchgate-OPEM-yellow.svg"></a></td>
</tr>
</table>


Expand Down
51 changes: 19 additions & 32 deletions opem/Test/test_Amphlett.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-
'''
>>> import os
>>> from math import isclose
>>> from opem.Static.Amphlett import *
>>> import random
>>> import shutil
>>> ABS_TOL = 1e-12
>>> REL_TOL = 0
>>> T=343.15
>>> PH2=1
>>> PO2=1
Expand All @@ -14,16 +17,11 @@
>>> N=1
>>> Jn=0.003
>>> JMax=0.469
>>> Enernst_Calc(T,PH2,PO2)
1.19075
>>> CH2_Calc(PH2,T)
7.330294784824117e-07
>>> CO2_Calc(PO2,T)
8.402541445801334e-07
>>> Rho_Calc(i,A,T,lambda_param)
4.978789826264977
>>> Xi2_Calc(A,PH2,T)
0.0030373688787134006
>>> assert isclose(Enernst_Calc(T,PH2,PO2), 1.19075, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(CH2_Calc(PH2,T), 7.330294784824117e-07, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(CO2_Calc(PO2,T), 8.402541445801334e-07, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Rho_Calc(i,A,T,lambda_param), 4.978789826264977, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Xi2_Calc(A,PH2,T), 0.0030373688787134006, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Eta_Conc_Calc(i,A,Jn,JMax)
0
>>> Eta_Ohmic_Calc(i,l,A,T,lambda_param)
Expand Down Expand Up @@ -613,28 +611,17 @@
Done!
>>> Amphlett_Data["Status"]
True
>>> Amphlett_Data["P"][5]
0.4825573089702401
>>> Amphlett_Data["I"][5]
0.5
>>> Amphlett_Data["V"][5]
0.9651146179404801
>>> Amphlett_Data["EFF"][5]
0.6186632166285129
>>> Amphlett_Data["Ph"][5]
0.13244269102975992
>>> Amphlett_Data["V0"]
1.004092712293457
>>> Amphlett_Data["K"]
-0.055817073316848265
>>> Amphlett_Data["Eta_Active"][5]
0.22466052101362555
>>> Amphlett_Data["Eta_Conc"][5]
9.772219884285375e-05
>>> Amphlett_Data["Eta_Ohmic"][5]
0.0008771388470514419
>>> Amphlett_Data["VE"][5]
0.9761841756350329
>>> assert isclose(Amphlett_Data["P"][5], 0.4825573089702401, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["I"][5], 0.5, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["V"][5], 0.9651146179404801, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["EFF"][5], 0.6186632166285129, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["Ph"][5], 0.13244269102975992, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["V0"], 1.004092712293457, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["K"], -0.055817073316848265, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["Eta_Active"][5], 0.22466052101362555, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["Eta_Conc"][5], 9.772219884285375e-05, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["Eta_Ohmic"][5], 0.0008771388470514419, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Amphlett_Data["VE"][5], 0.9761841756350329, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Test_Vector={"T":3432222.15,"PH2":1,"PO2":1,"i-start":5,"i-stop":0,"i-step":-2,"A":50.6,"l":0.0178,"lambda":23,"N":1,"R":0,"JMax":1.5,"Name":"test1"}
>>> Amphlett_Data=Static_Analysis(InputMethod=Test_Vector,TestMode=True)
###########
Expand Down
63 changes: 23 additions & 40 deletions opem/Test/test_Chakraborty.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
'''
>>> from opem.Dynamic.Chakraborty import *
>>> import os
>>> from math import isclose
>>> import shutil
>>> ABS_TOL = 1e-12
>>> REL_TOL = 0
>>> Test_Vector=Chakraborty_Standard_Vector = {"T": 1273,"E0": 0.6,"u":0.8,"N0": 1,"R": 3.28125 * 10**(-3),"KH2O": 0.000281,"KH2": 0.000843,"KO2": 0.00252,"rho": 1.145,"i-start": 245,"i-stop": 250,"i-step": 0.1,"Name": "test1"}
>>> Chakraborty_Data=Dynamic_Analysis(InputMethod=Test_Vector, TestMode=True)
###########
Expand Down Expand Up @@ -613,65 +616,45 @@
Done!
>>> Chakraborty_Data["Status"]
True
>>> Chakraborty_Data["P"][5]
74.69521188767807
>>> Chakraborty_Data["I"][5]
245.5
>>> Chakraborty_Data["V"][5]
0.3042574822308679
>>> Chakraborty_Data["EFF"][5]
0.16424155586011763
>>> Chakraborty_Data["PO2"][5]
0.0002987217000167565
>>> Chakraborty_Data["PH2"][5]
0.0003772905557065783
>>> Chakraborty_Data["PH2O"][5]
0.0045274866684789404
>>> Chakraborty_Data["Ph"][5]
227.26978811232192
>>> Chakraborty_Data["VE"][5]
0.3042574822308455
>>> Chakraborty_Data["V0"]
1.109804357228015
>>> Chakraborty_Data["K"]
-0.0032812499999884705
>>> Chakraborty_Data["Nernst Gain"][5]
0.1509273439765929
>>> Chakraborty_Data["Ohmic Loss"][5]
0.805546875
>>> assert isclose(Chakraborty_Data["P"][5], 74.69521188767807, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["I"][5], 245.5, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["V"][5], 0.3042574822308679, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["EFF"][5], 0.16424155586011763, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["PO2"][5], 0.0002987217000167565, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["PH2"][5], 0.0003772905557065783, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["PH2O"][5], 0.0045274866684789404, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["Ph"][5], 227.26978811232192, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["VE"][5], 0.3042574822308455, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["V0"], 1.109804357228015, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["K"], -0.0032812499999884705, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["Nernst Gain"][5], 0.1509273439765929, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chakraborty_Data["Ohmic Loss"][5], 0.805546875, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Chakraborty_Data=Dynamic_Analysis(InputMethod={}, TestMode=True, PrintMode=False)
>>> Chakraborty_Data["Status"]
False
>>> Vcell_Calc(Enernst = 0.6, Nernst_Gain=0.2, Ohmic_Loss=0.1, N=1)
0.7
>>> assert isclose(Vcell_Calc(Enernst = 0.6, Nernst_Gain=0.2, Ohmic_Loss=0.1, N=1), 0.7, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Vcell_Calc(Enernst = 0.6, Nernst_Gain=0.2, Ohmic_Loss=0.1, N=None)
[Error] Vcell Calculation Error (Enernst:0.6, Nernst_Gain:0.2, Ohmic_Loss:0.1, N:None)
>>> Enernst_Calc(E0=0.6, N0=2, T=1273, PH2=1, PO2=1, PH2O=1)
1.2
>>> assert isclose(Enernst_Calc(E0=0.6, N0=2, T=1273, PH2=1, PO2=1, PH2O=1), 1.2, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Enernst_Calc(E0=0.6, N0=2, T=1273, PH2=1, PO2=1, PH2O=None)
[Error] Enernst Calculation Failed (E0:0.6, N0:2, T:1273, PH2:1, PO2:1, PH2O:None)
>>> PH2_Calc(KH2=0.0000002, u=0.8, I=1)
0.006477717687589522
>>> assert isclose(PH2_Calc(KH2=0.0000002, u=0.8, I=1), 0.006477717687589522, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> PH2_Calc(KH2=0.0000002, u=0.8, I=None)
[Error] PH2 Calculation Failed (KH2:2e-07, u:0.8, I:None)
>>> PO2_Calc(KO2=0.00002, u=0.8, rHO=1.1145, I=1)
0.00016105657884531684
>>> assert isclose(PO2_Calc(KO2=0.00002, u=0.8, rHO=1.1145, I=1), 0.00016105657884531684, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> PO2_Calc(KO2=0.00002, u=0.8, rHO=1.1145, I=None)
[Error] PO2 Calculation Failed (KO2:2e-05, u:0.8, rHO:1.1145, I:None)
>>> PH2O_Calc(KH2O=0.000002, I=1)
0.002591087075035809
>>> assert isclose(PH2O_Calc(KH2O=0.000002, I=1), 0.002591087075035809, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> PH2O_Calc(KH2O=0.000002, I=None)
[Error] PH2O Calculation Failed (KH2O:2e-06, I:None)
>>> Nernst_Gain_Calc(T=1273, I=10)
0.06314815567790123
>>> assert isclose(Nernst_Gain_Calc(T=1273, I=10), 0.06314815567790123, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Nernst_Gain_Calc(T=1273, I=None)
[Error] Nernst Gain Calculation Error (T:1273, I:None)
>>> Ohmic_Loss_Calc(Rint=2, I=10)
20
>>> Ohmic_Loss_Calc(Rint=None, I=10)
[Error] Ohmic Loss Calculation Error (Rint:None, I:10)
>>> Efficiency_Calc(0.7,0.8,1)
0.3778677462887989
>>> assert isclose(Efficiency_Calc(0.7,0.8,1), 0.3778677462887989, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Efficiency_Calc(0.7,None,1)
[Error] PEM Efficiency Calculation Failed (Vcell:0.7, u:None, N:1)
>>> Test_Vector={"T": 1273,"E0": 0.6,"u":0.8,"N0": 1,"R": 3.28125 * 10**(-3),"KH2O": 0.000281,"KH2": 0.000843,"KO2": 0.00252,"rho": 1.145,"i-start": 250,"i-stop":249 ,"i-step": -0.1,"Name": "test1"}
Expand Down
30 changes: 12 additions & 18 deletions opem/Test/test_Chamberline_Kim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
'''
>>> import os
>>> from math import isclose
>>> from opem.Static.Chamberline_Kim import *
>>> import shutil
>>> E0=0.982
Expand All @@ -10,8 +11,9 @@
>>> n=9.45
>>> i=1
>>> A=50.0
>>> Vcell_Calc(E0,b,R,m,n,i,A)
1.244827379954939
>>> ABS_TOL = 1e-12
>>> REL_TOL = 0
>>> assert isclose(Vcell_Calc(E0,b,R,m,n,i,A), 1.244827379954939, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Vcell_Calc(None,b,R,m,n,i,A)
[Error] Vcell Calculation Error (E0:None, b:0.0689, R:0.328, m:0.000125, n:9.45, i:1, A:50.0)
>>> Chamberline_Data=Static_Analysis(InputMethod={}, TestMode=True,PrintMode=False)
Expand Down Expand Up @@ -265,24 +267,16 @@
###########
Report is generating ...
Done!
>>> Chamberline_Kim_Data["P"][5]
1.820393802022961
>>> assert isclose(Chamberline_Kim_Data["P"][5], 1.820393802022961, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Chamberline_Kim_Data["Status"]
True
>>> Chamberline_Kim_Data["I"][5]
1.5
>>> Chamberline_Kim_Data["V"][5]
1.2135958680153074
>>> Chamberline_Kim_Data["EFF"][5]
0.7779460692405816
>>> Chamberline_Kim_Data["Ph"][5]
0.02460619797703889
>>> Chamberline_Kim_Data["V0"]
1.2696835857181188
>>> Chamberline_Kim_Data["K"]
-0.0372516118425709
>>> Chamberline_Kim_Data["VE"][5]
1.2138061679542624
>>> assert isclose(Chamberline_Kim_Data["I"][5], 1.5, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chamberline_Kim_Data["V"][5], 1.2135958680153074, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chamberline_Kim_Data["EFF"][5], 0.7779460692405816, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chamberline_Kim_Data["Ph"][5], 0.02460619797703889, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chamberline_Kim_Data["V0"], 1.2696835857181188, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chamberline_Kim_Data["K"], -0.0372516118425709, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Chamberline_Kim_Data["VE"][5], 1.2138061679542624, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Test_Vector={"A":50.0,"E0":-5,"b":0.0689,"R":0.328,"m":0.000125,"n":9.45,"N":1,"i-start":5,"i-stop":1,"i-step":-1,"Name":"test1"}
>>> Chamberline_Kim_Data=Static_Analysis(InputMethod=Test_Vector, TestMode=True)
###########
Expand Down
30 changes: 12 additions & 18 deletions opem/Test/test_Larminie_Dicks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
'''
>>> import os
>>> from math import isclose
>>> from opem.Static.Larminie_Dicks import *
>>> import shutil
>>> ABS_TOL = 1e-12
>>> REL_TOL = 0
>>> E0=1.178
>>> A=0.0587
>>> B=0.0517
Expand All @@ -11,8 +14,7 @@
>>> i_L=100
>>> i_n=0.23
>>> N=23
>>> Vcell_Calc(E0=E0, i=1,i_0=i_0,i_n=i_n,i_L=i_L,R_M=RM,A=A,B=B)
0.8677440917797067
>>> assert isclose(Vcell_Calc(E0=E0, i=1,i_0=i_0,i_n=i_n,i_L=i_L,R_M=RM,A=A,B=B), 0.8677440917797067, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Vcell_Calc(E0=None, i=1,i_0=i_0,i_n=i_n,i_L=i_L,R_M=RM,A=A,B=B)
[Error] Vcell Calculation Error (E0:None, i:1, i_0:0.00654, i_n:0.23, i_L:100, R_M:0.0018, A:0.0587, B:0.0517)
>>> Larminie_Dicks_Data=Static_Analysis(InputMethod={}, TestMode=True,PrintMode=False)
Expand Down Expand Up @@ -340,22 +342,14 @@
Done!
>>> Larminie_Dicks_Data["Status"]
True
>>> Larminie_Dicks_Data["P"][5]
12.223748052345787
>>> Larminie_Dicks_Data["I"][5]
0.6
>>> Larminie_Dicks_Data["V"][5]
20.37291342057631
>>> Larminie_Dicks_Data["EFF"][5]
0.5678069515210789
>>> Larminie_Dicks_Data["Ph"][5]
4.750251947654213
>>> Larminie_Dicks_Data["V0"]
20.823811410978124
>>> Larminie_Dicks_Data["K"]
-0.8163936642494803
>>> Larminie_Dicks_Data["VE"][5]
20.333975212428435
>>> assert isclose(Larminie_Dicks_Data["P"][5], 12.223748052345787, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Larminie_Dicks_Data["I"][5], 0.6, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Larminie_Dicks_Data["V"][5], 20.37291342057631, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Larminie_Dicks_Data["EFF"][5], 0.5678069515210789, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Larminie_Dicks_Data["Ph"][5], 4.750251947654213, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Larminie_Dicks_Data["V0"], 20.823811410978124, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Larminie_Dicks_Data["K"], -0.8163936642494803, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> assert isclose(Larminie_Dicks_Data["VE"][5], 20.333975212428435, abs_tol=ABS_TOL, rel_tol=REL_TOL)
>>> Test_Vector={"A":0.06,"E0":-1.178,"T":328.15,"RM":0.0018,"i_0":0.00654,"i_L":100.0,"i_n":0.23,"N":23,"i-start":5,"i-stop":0.1,"i-step":-2,"Name":"test1"}
>>> Larminie_Dicks_Data=Static_Analysis(InputMethod=Test_Vector, TestMode=True)
###########
Expand Down
Loading