-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities.py
174 lines (103 loc) · 3.5 KB
/
utilities.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
## Utility Functions
import numpy as np
import math
def calG(T,C,params):
kg = params["kg"]
Eg = params["Eg"]
g = params["g"]
Cs = 6.29 * (10**-2) + 2.46*(10**-3) * (T-273) - 7.14 * (10**-6) * (T-273)**2
S = (C- Cs)/Cs
##f = open("error_log.txt","a")
#print S**g, S,
growth_rate = kg*np.exp(-Eg/T)*S**g
##np.exp(-Eg/T)
##f.write(str(np.exp(-Eg/T))+"\t"+str(T)+"\n")
#print growth_rate
return growth_rate
def calB(y,T,params) :
kb = params["kb"]
Eb = params["Eb"]
b = params["b"]
Cs = 6.29 * (10**-2) + 2.46*(10**-3) * (T-273) - 7.14 * (10**-6) * (T-273)**2
S = (y[0]- Cs)/Cs
B = (kb*np.exp(-Eb/T))*(S**b)*(y[4]+y[8]) ######
return B
def DG_dy(T,C,params):
kg = params["kg"]
Eg = params["Eg"]
g = params["g"]
Cs = 6.29 * (10**-2) + 2.46*(10**-3) * (T-273) - 7.14 * (10**-6) * (T-273)**2
S = (C- Cs)/Cs
return kg*g*np.exp(-Eg/T)*(S**(g-1))/Cs
def DB_dy(T,C,y,params):
kb = params["kb"]
Eb = params["Eb"]
b = params["b"]
Cs = 6.29 * (10**-2) + 2.46*(10**-3) * (T-273) - 7.14 * (10**-6) * (T-273)**2
S = (C- Cs)/Cs
return kb*b*np.exp(-Eb/T)*(S**(b-1))*(y[3]+y[7])/Cs ###
def DG_dt(theta,T,C,params):
kg = params["kg"]
Eg = params["Eg"]
g = params["g"]
Cs = 6.29 * (10**-2) + 2.46*(10**-3) * (T-273) - 7.14 * (10**-6) * (T-273)**2
S = (C- Cs)/Cs
DCs_dT = 2.46*10**-3 -14.28*(10**-6)*(T-273)
exper = (Cs*(theta[0] - DCs_dT) - DCs_dT * (C - Cs))/Cs**2
A = kg*S**g*np.exp(-Eg/T)*Eg/(T**2)
DelG_dT = A + kg*np.exp(-Eg/T)*g*(S**(g-1))*exper
return DelG_dT
def DB_dt(theta,y,T,params):
Cs = 6.29 * (10**-2) + 2.46*(10**-3) * (T-273) - 7.14 * (10**-6) * (T-273)**2
DCs_dT = 2.46*10**-3 -14.28*10**-6*(T-273)
exper = (Cs*(theta[0] - DCs_dT) - DCs_dT * (y[0] - Cs))/Cs**2
kb = params["kb"]
Eb = params["Eb"]
C = y[0]
S = (C- Cs)/Cs
b = params["b"]
A = kb*np.exp(-Eb/T)*Eb*S**b*(y[4]+y[8])/T**2 #######
B = A + kb*np.exp(-Eb/T)*b*S**(b-1)*exper*(y[4]+y[8]) ####
DelB_dT = kb*np.exp(-Eb/T)*S**b*(theta[4]+theta[8])+B ####
return DelB_dT
def DG_dT(theta,T,C,params):
kg = params["kg"]
Eg = params["Eg"]
g = params["g"]
Cs = 6.29 * (10**-2) + 2.46*(10**-3) * (T-273) - 7.14 * (10**-6) * (T-273)**2
DCs_dT = 2.46*10**-3 -14.28*10**-6*(T-273)
exper = (Cs*(theta[0] - DCs_dT) - DCs_dT * (C - Cs))/Cs**2
S = (C- Cs)/Cs
A = kg*S**g*np.exp(-Eg/T)*Eg/(T**2)
DelG_dT = A + kg*np.exp(-Eg/T)*g*(S**(g-1))*exper
return DelG_dT
def DG_dydT(theta,T,C,params):
Cs = 6.29 * (10**-2) + 2.46*(10**-3) * (T-273) - 7.14 * (10**-6) * (T-273)**2
kg = params["kg"]
Eg = params["Eg"]
g = params["g"]
DCs_dT = 2.46*10**-3 -14.28*10**-6*(T-273)
exper = (Cs*(theta[0] - DCs_dT) - DCs_dT * (C - Cs))/Cs**2
S = (C- Cs)/Cs
A = kg*g*np.exp(-Eg/T)*S**(g-1)*(Eg/T**2)/Cs
B = kg*g*np.exp(-Eg/T)*(g-1)*S**(g-2)*exper/Cs
C = -1*kg*g*np.exp(-Eg/T)*S**(g-1)*DCs_dT/Cs**2
return A+B+C
def DB_dydT(theta,y,T,params):
kb = params["kb"]
Eb = params["Eb"]
b = params["b"]
Cs = 6.29 * (10**-2) + 2.46*(10**-3) * (T-273) - 7.14 * (10**-6) * (T-273)**2
DCs_dT = 2.46*10**-3 -14.28*10**-6*(T-273)
S = (y[0] - Cs)/Cs
exper = (Cs*(theta[0] - DCs_dT) - DCs_dT * (y[0] - Cs))/Cs**2
A = kb*b*np.exp(-Eb/T)*(Eb/T**2)*S**(b-1)*(y[3]+y[7])/Cs
B = kb*b*np.exp(-Eb/T)*(b-1)*S**(b-2)*(y[3]+y[7])*exper
C = -kb*b*np.exp(-Eb/T)*S**(b-1)*DCs_dT*(y[3]+y[7])/Cs**2
D = kb*b*np.exp(-Eb/T)*S**(b-1)*(theta[3]+theta[7])
return A+B+C+D
def solve_quadratic(a,b,c):
d = math.sqrt(b**2 - 4*a*c)
r1 = (-b + d)/(2*a)
r2= (-b -d )/(2*a)
return r1,r2