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

Upload New File

parent 2bd8dd5b
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 15 21:11:16 2023
@author: delvigne
"""
'''
Exercice 2.10 - Simulation of a fed-batch bioreactor with oxygen transfer
'''
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]
CL = state[2]
V = state[3]
mumax = 0.6 #in h-1
Ks = 0.01 #in g/L
Yxs = 0.5 #in g per g
D = 0.01 #Dilution rate in h-1
Sin = 500
Yxo = 1
Ko = 0.001
KLa = 350
C0L = 0.01
rx = mumax*(S/(Ks+S))*X*(CL/(Ko+CL))
if t<5:
D=0
dXdt = rx -D*X
dSdt = -rx/Yxs - D*S + D*Sin
dCLdt = KLa * (C0L - CL)- (rx/Yxo)-D*CL
dVdt = D*V
state = [dXdt,dSdt,dCLdt,dVdt]
return state
'''Specify the time range for running the simulation'''
t = np.linspace(0,30)
'''Specify the initial conditions'''
state0 = [0.1,5,0.01,10] #We have 0.1 g/L of biomass, 5 g/L of substrate, 10 mg/L of dissolved oxygen
#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('CL (g/L)')
figure(3)
plot(r.t,a[:,3])
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