-
Notifications
You must be signed in to change notification settings - Fork 0
/
systemexample.py
52 lines (38 loc) · 1.19 KB
/
systemexample.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
from Biosystem import *
from Part import *
from Rate import *
from Pulse import *
import matplotlib.pyplot as plt
# Create a BioSystem to simulate.
sys = BioSystem()
# Add the constant 'k' with a value 0.05.
# This will be the speed of the chemical reaction.
sys.addConstant('a', 5)
sys.addConstant('b', 0.3)
sys.addConstant('V', 100)
# with initial contration values: 10, 1, 1
dBdt = sys.addCompositor('B', 1) #koncentracija litre
reaction = Part(
'rates',
[dBdt],
[Rate('B * b * ((V + a * t)^(-1) - t*(V + a * t)^(-2))')])
# Add the reaction to the simulation.
sys.addPart(reaction)
# Initialise time points and substance concentration values.
T = None
Y = None
# Simulate system with provid
# d reactions for 25 seconds.
(T, Y) = sys.run([0, 25])
# T - time points of the simulation.
# Y - a matrix, rows shows the substance concentrations at particular time
# point, columns - substance concentrations change in time.
# Plot the simulation data.
plt.figure()
#plt.plot(T, Y[:, sys.compositorIndex('A')], label="A")
plt.plot(T, Y[:, sys.compositorIndex('B')], label="B")
#plt.plot(T, Y[:, sys.compositorIndex('C')], label="C")
plt.legend()
plt.xlabel('Time')
plt.ylabel('Concentration')
plt.show()