I am trying to develop an algorithm (use scipy.integrate.odeint()) that predicts the changing concentration of cells, substrate and product (i.e., π, π, π) over time until the system reaches steady- state (~100 or 200 hours). The initial concentration of cells in the bioreactor is 0.1 π/πΏ and there is no glucose or product in the reactor initially. I want to test the algorithm for a range of different flow rates, π, between 0.01 πΏ/β and 0.25 πΏ/β and analyze the impact of the flow rate on product production (i.e., π β π in π/β). Eventually, I would like to generate a plot that shows product production rate (y-axis) versus flow rate, π, on the x-axis. My goal is to estimate the flow rate that results in the maximum (or critical) production rate. This is my code so far:
from scipy.integrate import odeint import numpy as np # Constants u_max = 0.65 K_s = 0.14 K_1 = 0.48 V = 2 X_in = 0 S_in = 4 Y_s = 0.38 Y_p = 0.2 # Variables # Q - Flow Rate (L/h), value between 0.01 and 0.25 that produces best Q * P # X - Cell Concentration (g/L) # S - The glucose concentration (g/L) # P - Product Concentration (g/L) # Equations def func_dX_dt(X, t, S): u = (u_max) / (1 + (K_s / S)) dX_dt = (((Q * S_in) - (Q * S)) / V) + (u * X) return dX_dt def func_dS_dt(S, t, X): u = (u_max) / (1 + (K_s / S)) dS_dt = (((Q * S_in) - (Q * S)) / V) - (u * (X / Y_s)) return dS_dt def func_dP_dt(P, t, X, S): u = (u_max) / (1 + (K_s / S)) dP_dt = ((-Q * P) / V) - (u * (X / Y_p)) return dP_dt t = np.linspace(0, 200, 200) # Q placeholder Q = 0.01 # Attempt to solve the Ordinary differential equations sol_dX_dt = odeint(func_dX_dt, 0.1, t, args=(S,)) sol_dS_dt = odeint(func_dS_dt, 0.1, t, args=(X,)) sol_dP_dt = odeint(func_dP_dt, 0.1, t, args=(X,S)) In the programs current state there does not seem to be be a way to generate the steady state value for P. I attempted to make this modification to get the value of X.
sol_dX_dt = odeint(func_dX_dt, 0.1, t, args=(odeint(func_dS_dt, 0.1, t, args=(X,)),)) It produces the error:
NameError: name 'X' is not defined At this point I am not sure how to move forward.
(Edit 1: Added Original Equations)
First Equation

Second Equation and Third Equation

