def make_plate(params, inducer_conc): amount = inducer_conc * 1e-6 #milli moles agar_thickness = 3.12 # mm init_conc = amount / (w**2 * agar_thickness) #mol/mm^3 init_conc *= 1e6 # mM A_0 = init_conc D_N, mu_max, K_mu, gamma, D_A, \ alpha_T, beta_T, K_IT, n_IT, K_lacT, T7_0, \ alpha_R, beta_R, K_IR, n_IR, K_lacR, R_0, \ alpha_G, beta_G, n_A, K_A, n_R, K_R, X_0, G_s = params ## Create our environment plate = Plate(environment_size) dist = 4.5 # mm centre = plate_width / 2 receiver_radius = 2 receiver_pos = [[centre - i * dist, centre] for i in range(1, 4)] receiver_pos.extend([[centre + i * dist, centre] for i in range(1, 4)]) receiver_pos.extend([[centre, centre + i * dist] for i in range(1, 4)]) receiver_pos.extend([[centre, centre - i * dist] for i in range(1, 4)]) receiver_coordinates = get_node_coordinates(receiver_pos, receiver_radius, environment_size[0], environment_size[1], w) rows = receiver_coordinates[:, 0] cols = receiver_coordinates[:, 1] receiver_flags = np.zeros(environment_size) receiver_flags[rows, cols] = 1 ## add nutrient to the plate U_N = np.ones(environment_size) * N_0 N = Species("N", U_N) def N_behaviour(t, species, params): ## unpack params D_N, mu_max, K_mu, gamma, D_A, \ alpha_T, beta_T, K_IT, n_IT, K_lacT, T7_0, \ alpha_R, beta_R, K_IR, n_IR, K_lacR, R_0, \ alpha_G, beta_G, n_A, K_A, n_R, K_R, X_0, G_s = params #mu = mu_max * np.maximum(0, species['N']) / (K_mu + np.maximum(0,species['N'])) * np.maximum(0,species['X']) #print(np.max(mu)) mu = dx(t, species) * receiver_flags #print('mu', mu) n = D_N * hf.ficks(np.maximum(0, species['N']), w) - mu / gamma return n N.set_behaviour(N_behaviour) plate.add_species(N) ## add one strain to the plate U_X = np.zeros(environment_size) U_X[rows, cols] = X_0 strain = Species("X", U_X) def X_behaviour(t, species, params): ## unpack params #mu = mu_max * np.maximum(0, species['N']) / (K_mu + np.maximum(0, species['N'])) * np.maximum(0,species['X']) mu = dx(t, species) * receiver_flags return mu strain.set_behaviour(X_behaviour) plate.add_species(strain) ## add IPTG to plate #inducer_position = [[int(j * (4.5/w)) for j in i] for i in inducer_positions # convert position to specified dims U_A = np.zeros(environment_size) U_A[inducer_position[0], inducer_position[1]] = A_0 A = Species("A", U_A) def A_behaviour(t, species, params): ## unpack params D_N, mu_max, K_mu, gamma, D_A, \ alpha_T, beta_T, K_IT, n_IT, K_lacT, T7_0, \ alpha_R, beta_R, K_IR, n_IR, K_lacR, R_0, \ alpha_G, beta_G, n_A, K_A, n_R, K_R, X_0, G_s = params a = D_A * hf.ficks(np.maximum(0, species['A']), w) return a A.set_behaviour(A_behaviour) plate.add_species(A) #add T7 to the plate U_T7 = np.ones(environment_size) * T7_0 T7 = Species("T7", U_T7) def T7_behaviour(t, species, params): D_N, mu_max, K_mu, gamma, D_A, \ alpha_T, beta_T, K_IT, n_IT, K_lacT, T7_0, \ alpha_R, beta_R, K_IR, n_IR, K_lacR, R_0, \ alpha_G, beta_G, n_A, K_A, n_R, K_R, X_0, G_s = params mu = dx(t, species) * receiver_flags dT7 = (alpha_T * mu * (1 + (np.maximum(0, species['A']) / K_IT)**n_IT)) / ( 1 + (np.maximum(0, species['A']) / K_IT)**n_IT + K_lacT) + beta_T * mu - mu * np.maximum(0, species['T7']) return dT7 T7.set_behaviour(T7_behaviour) plate.add_species(T7) ## add GFP to plate U_G = np.ones(environment_size) * GFP_0 G = Species("G", U_G) def G_behaviour(t, species, params): ## unpack params D_N, mu_max, K_mu, gamma, D_A, \ alpha_T, beta_T, K_IT, n_IT, K_lacT, T7_0, \ alpha_R, beta_R, K_IR, n_IR, K_lacR, R_0,\ alpha_G, beta_G, n_A, K_A, n_R, K_R, X_0, G_s = params #mu = mu_max * np.maximum(0, species['N']) / (K_mu + np.maximum(0, species['N'])) * np.maximum(0,species['X']) mu = dx(t, species) * receiver_flags #T7 = alpha_T + beta_T - alpha_T * K_lacT / (1 + (np.maximum(0, species['A']) / K_IT)**n_IT + K_lacT) + T7_0 * np.exp(-mu * t) #T7 = alpha_T + beta_T - alpha_T * K_lacT / (1 + (np.maximum(0, species['A']) / K_IT)**n_IT + K_lacT) + T7_0 * np.exp(-mu * t) #rescaled T7 = np.maximum(0, species['T7']) #print(np.max(T7)) #R = alpha_R + beta_R - alpha_R * K_lacR / (1 + (np.maximum(0, species['A']) / K_IR)**n_IR + K_lacR) + R_0 * np.exp(-mu * t) #R = alpha_R + beta_R - alpha_R * K_lacR / (1 + (np.maximum(0, species['A']) / K_IR)**n_IR + K_lacR) + R_0 * np.exp(-mu * 1e8 * t) #rescaled R = 0 # produces treshold T7**n_A / (K_A**n_A + T7**n_A) K_R**n_R / (K_R**n_R + R**n_R) #dGFP = alpha_G * mu * T7**n_A / (K_A**n_A + T7**n_A) * K_R**n_R / (K_R**n_R + R**n_R) + beta_G * mu - np.maximum(0, species['G']) * mu*G_s dGFP = alpha_G * mu * T7**n_A / (K_A**n_A + T7**n_A) + beta_G * mu - np.maximum( 0, species['G']) * mu * G_s return dGFP G.set_behaviour(G_behaviour) plate.add_species(G) return plate