-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglycolysis.py
More file actions
55 lines (45 loc) · 1.13 KB
/
glycolysis.py
File metadata and controls
55 lines (45 loc) · 1.13 KB
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
import time
import random
dG_dt = 1 # µM/ms
dGin_dt = 0 # µM/ms
dATP_dt = 0 # µM/ms
# Initial state vector:
class Conc:
__slots__ = ('G', 'ADP', 'ATP')
def __init__(self, G, ADP, ATP):
self.G = G
self.ADP = ADP
self.ATP = ATP
def __str__(self):
return f'G:{self.G};ADP:{self.ADP},ATP:{self.ATP}'
def check_ATP(self):
if self.ATP < 1:
return False
return True
c = Conc(10.0, 100.0, 1000.0) # µM
ms0 = time.perf_counter_ns()
def loop():
global ms0, dG_dt, dGin_dt, dATP_dt
while True:
ms = (time.perf_counter_ns() - ms0) / 1_000_000
if ms < 1:
continue
ms0 = ms
c.G += dGin_dt
if c.G > dG_dt and c.ADP > dG_dt*2:
c.G -= dG_dt
c.ADP -= dG_dt*2
c.ATP += dG_dt*2
else:
pass
dATP_dt = random.uniform(0.5, 2.0)
dGin_dt = dATP_dt/2
if c.ATP > dATP_dt:
c.ADP += dATP_dt
c.ATP -= dATP_dt
else:
print("Energy Failure")
quit()
print(c)
if __name__ == "__main__":
loop()