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

Upload New File

parent 3cc7c1ea
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:12:53 2023
@author: delvigne
"""
'''
Exercice 2.8 - Simulation of a 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 Batchoxy(t, state):
X = state[0]
S = state[1]
CL = state[2]
mumax = 0.6 #in h-1
Ks = 0.01 #in g/L
Yxs = 0.5 #in g per g
Yxo = 1
Ko = 0.001
KLa = 350
C0L = 0.01
rx = mumax*(S/(Ks+S))*X*(CL/(Ko+CL))
dXdt = rx
dSdt = -rx/Yxs
dCLdt = KLa * (C0L - CL)- (rx/Yxo)
state = [dXdt,dSdt,dCLdt]
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] #We have 0.1 g/L of biomass, 5 g/L of substrate and 10 mg/L of dissolved oxygen at the beginning of the simulation
'''Solve the ODEs'''
r = solve_ivp(fun=Batchoxy, t_span=[t[0],max(t)],y0=state0, t_eval=t, method='LSODA')
figure(1)
plot(r.t,r.y.T)
xlabel('Time (h)')
ylabel('X, S, CL (g/L)')
a = r.y.T
figure(2)
plot(r.t,a[:,2].T)
xlabel('Time (h)')
ylabel('CL (g/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