#Biological reactor with no inflow or outflow class Batch: #Define values that stay constant during the simulation. data mu_max, Ks, Yxs: Float param #Define values that change during the simulation. data mu, X, S: Float #Initialize the simulation. func initialize(this): #Specify options for the simulation algorithm. solution_parameters(duration=20, reporting_interval=0.1) #Give values to the parameters mu_max = 0.32 #[1/h] max growth speed Ks = 0.01 #[g/l] at this lactate concentration growth speed is 0.5*mu_max Yxs = 0.5 #[g/g] one g lactate gives this much biomass #Give initial values to the state variables. X = 0.1 #[g/l] initial biomass concentration S = 20 #[g/l] initial sugar concentration #compute dynamic behavior - the system's 'equations' func dynamic(this): mu = mu_max * S/(S+Ks) #growth speed (of biomass) [1/h] $X = mu*X #change of biomass concentration [g/l/h] $S = -1/Yxs*mu*X #change of sugar concentration [g/l/h] #show results func final(this): graph(mu, X, S, title="Batch Reactor"); #For the test scripts print("final-values:", X, S, time) compile Batch