# Use of Optimica to run generalized formulation of the bottle-neck model # typical for FBA. # Follow manual 1.17 pg 60 and on # Framework # import os import matplotlib.pyplot as plt import numpy as np from pymodelica import compile_fmu from pyfmi import load_fmu #from pyjmi import transfer_optimization_problem # Compile and load FMU, which is used for simulation model = load_fmu(compile_fmu('FBA.Reactor', 'fba1.mo')) # Simulate sim_res = model.simulate(final_time=10.0); # Get simulation result res = sim_res.result_data; #VG = res.get_variable_data('Reactor.VG'); G = res.get_variable_data('G'); E = res.get_variable_data('E'); X = res.get_variable_data('X'); qGr = res.get_variable_data('qGr'); qEr = res.get_variable_data('qEr'); qO2 = res.get_variable_data('qO2'); mu = res.get_variable_data('mu'); kog = 2.3; koe = 1.6; YGr = 3.5; YEr = 1.32; MwX = 24.6; # Plot results plt.figure() plt.subplot(2,1,1) plt.title('Batch cultivation - using analytical solution to maximize cell growth'); plt.plot(G.t,G.x,'b') plt.plot(E.t,E.x,'r') plt.grid() plt.legend(['G','E']) plt.ylabel('G and E [g/L]') plt.subplot(2,1,2) plt.plot(X.t,X.x) plt.grid() plt.ylabel('X [g/L]') plt.xlabel('Time [h]') plt.show() plt.figure() plt.subplot(3,1,1) plt.title('Batch cultivation - using analytical solution to maximize cell growth'); plt.plot(mu.t,MwX*mu.x,'b') plt.plot(qGr.t,MwX*YGr*qGr.x,'b--') plt.plot(qEr.t,MwX*YEr*qEr.x,'r--') plt.grid() plt.legend(['mu','qGr','qEr']) plt.ylabel('mu') plt.subplot(3,1,2) plt.plot(qEr.t,qEr.x,'r') plt.grid() plt.ylabel('qEr') plt.subplot(3,1,3) plt.plot(qO2.t,qO2.x) plt.plot(qGr.t,kog*qGr.x,'b--') plt.plot(qEr.t,koe*qEr.x,'r--') plt.grid() plt.legend(['qO2','qGr','qEr']) plt.axis([0,10,-0.001,0.008]) plt.ylabel('qO2') plt.xlabel('Time [h]') plt.show()