Skip to content
Snippets Groups Projects
Commit 6b88e04c authored by Delvigne Frank's avatar Delvigne Frank
Browse files

Upload New File

parent 182f1374
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 29 10:38:19 2024
@author: delvigne
"""
'''
Additional exercice 3
'''
import numpy as np
from scipy.integrate import solve_ivp
from matplotlib.pyplot import figure
from matplotlib.pyplot import plot
from matplotlib.pyplot import xlabel
from matplotlib.pyplot import ylabel
def Fedbatch(t, state):
X = state[0]
S = state[1]
V = state[2]
mumax = 0.7 #in h-1
Ks = 0.01 #in g/L
Yxs = 0.46 #in g per g
D = 0.1/10 #Dilution rate in h-1 (D = Q/V)
Sin = 200
rx = mumax*(S/(Ks+S))*X
if t<5:
D=0
dXdt = rx -D*X
dSdt = -rx/Yxs - D*S + D*Sin
dVdt = D*V
state = [dXdt,dSdt,dVdt]
return state
'''Specify the time range for running the simulation'''
t = np.linspace(0,30)
'''Specify the initial conditions'''
state0 = [0.2,10,10] #We have 0.2 g/L of biomass, 10 g/L of substrate
#and a volume of 10L at the beginning of the simulation
'''Solve the ODEs'''
r = solve_ivp(fun=Fedbatch, t_span=[t[0],max(t)],y0=state0, t_eval=t, method='LSODA')
a = r.y.T
figure(1)
plot(r.t,a[:,0],r.t,a[:,1])
xlabel('Time (h)')
ylabel('X, S (g/L)')
figure(2)
plot(r.t,a[:,2])
xlabel('Time (h)')
ylabel('V (L)')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment