-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSurfacePourbaixGenerator.py
54 lines (36 loc) · 1.6 KB
/
SurfacePourbaixGenerator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import numpy as np
class SurfacePourbaixDiagramGenerator():
"""
Class for generating 1-D (fixed pH or potential) and 2-D Surface Pourbaix Diagram Data
Attributes:
@TwoDGibbsEnergy(pH,U_she): determine the excess Gibbs free surface energy of different surfaces at different pH and U
@TwoDPhaseDetermination(lowpH,highpH,lowU,highU,pHgrids,Ugrids): determine the most stable surface phase at certain pH and U
"""
def __init__(self,SurfSet):
self.surfaceset = SurfSet
self.k = 8.617333262e-5
self.T = 298.15
self.const = self.k * self.T * np.log(10)
return
def TwoDGibbsEnergy(self,pH,U_she):
G = []
surface = locals()
for i in range(len(self.surfaceset)):
name = str(self.surfaceset[i]["Name"])
surface[name] = self.surfaceset[i]["G_constant"] - self.surfaceset[i]["k_index"] * U_she - self.surfaceset[i]["k_index"] * pH * self.const
G.append([i+1,surface[name]])
Gmin = 0
index = 0
for k in range(len(G)):
if G[k][1] <= Gmin:
Gmin = G[k][1]
index = G[k][0]
return(index)
def TwoDPhaseDetermination(self,lowpH,highpH,lowU,highU,pHgrids,Ugrids):
self.pH = np.linspace(lowpH,highpH,pHgrids)
self.U_she = np.linspace(lowU,highU,Ugrids)
self.Phase = []
for i in range(len(self.pH)):
for j in range(len(self.U_she)):
self.Phase.append([self.pH[i],self.U_she[i],self.TwoDGibbsEnergy(self.pH[i],self.U_she[j])])
return