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

Upload New File

parent fda46fc8
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 2 11:40:38 2023
@author: delvigne
"""
'''
Exercice 2.7 - Simulation of a continuous bioreactor
'''
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 Continuous(t, state):
X = state[0]
S = state[1]
mumax = 0.6 #in h-1
Ks = 0.01 #in g/L
Yxs = 0.5 #in g per g
D = 0.8 #Dilution rate in h-1
Sin = 15
rx = mumax*(S/(Ks+S))*X
if t<10:
D=0
dXdt = rx -D*X
dSdt = -rx/Yxs - D*S + D*Sin
state = [dXdt,dSdt]
return state
'''Specify the time range for running the simulation'''
t = np.linspace(0,30)
'''Specify the initial conditions'''
state0 = [0.1,5] #We have 0.1 g/L of biomass and 5 g/L of substrate at the beginning of the simulation
'''Solve the ODEs'''
r = solve_ivp(fun=Continuous, 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 (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