forked from ucl-cssb/colony-com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBacteria_nutrient.py
70 lines (60 loc) · 1.83 KB
/
Bacteria_nutrient.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
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 15 12:32:07 2021
@author: savan
"""
#Basic model, Nutrient and Sender bacteria
# plots simulation
# plot growth rate graph
from plate import Plate
from species import Species
import numpy as np
import helper_functions as hf
def main():
## experimental parameters
D = 0.03
rho_n = 0.5
rc = 3.33e-2 #3.33e-2 #6e-4
Dc = 1e-5
w = 0.75
environment_size = (59, 59)
plate = Plate(environment_size)
## add nutrient to the plate
U_N = np.zeros(environment_size)
for i in np.linspace(0, 58, 59):
for j in np.linspace(0,58,59):
U_N[int(i),int(j)]=100
N = Species("N", U_N)
def N_behaviour(species, params):
## unpack params
D, rho_n, Dc, rc, w = params
n = D * hf.ficks(species['N'], w) - species['S'] * rho_n * hf.leaky_hill(s=species['N'], K=80, lam=1, max=rc, min=0)
return n
N.set_behaviour(N_behaviour)
plate.add_species(N)
## add sender strain to the plate
U_S = np.zeros(environment_size)
for i in np.linspace(29, 29, 1):
for j in np.linspace(29,29,1):
U_S[int(i), int(j)] = 0.001
S = Species("S", U_S)
def S_behaviour(species, params):
## unpack params
D, rho_n, Dc, rc, w = params
s = Dc * hf.ficks(species['S'], w) + species['S'] * hf.leaky_hill(s=species['N'], K=80, lam=1, max=rc, min=0)
return s
S.set_behaviour(S_behaviour)
plate.add_species(S)
## run the experiment
params = (D, rho_n, Dc, rc, w)
sim = plate.run(t_final = 200*60,
dt = 1.,
params = params)
#6
plate.plot_simulation(sim, 3)
#7
idx = 0
S = plate.get_all_species()
plate.compare_species(sim, S, 10, idx)
#plate.plot_conc_target(sim, S, 10, idx)
main()