コード例 #1
0
 def final(self, state_alg_vars): 
     ''' 
     Display and save simulation results. 
     This function will be called once; after the simulation results 
     have been computed. 
     ''' 
     #Make parameters visible in final method. 
     param = self.param 
     #take take state and algebraic variables out of their array. 
     S = state_alg_vars[0] 
     X = state_alg_vars[1] 
     mu = state_alg_vars[2] 
     time = state_alg_vars[3] 
     #Create time derivatives with value 0.
     X_Dtime = 0.0 
     S_Dtime = 0.0 
     #the final method's statements 
     self.graph(["mu","X","S",], title="Batch Reactor",)
     debug_print("final-values:", str(X, ), str(S, ), str(time, ), )
     debug_print('simulation Batch finished.') 
コード例 #2
0
ファイル: bioreactor.py プロジェクト: gmassei/bastelpython
 def final(self, state_alg_vars): 
     ''' 
     Display and save simulation results. 
     This function will be called once; after the simulation results 
     have been computed. 
     ''' 
     #Make parameters visible in final method. 
     param = self.param 
     #take take state and algebraic variables out of their array. 
     r_S = state_alg_vars[0] 
     r_X = state_alg_vars[1] 
     r_D = state_alg_vars[2] 
     r_STY = state_alg_vars[3] 
     r_S_pos = state_alg_vars[4] 
     r_mu = state_alg_vars[5] 
     time = state_alg_vars[6] 
     #Create time derivatives with value 0.
     r_X_Dtime = 0.0 
     r_S_Dtime = 0.0 
     #the final method's statements 
     self.graph(["r.mu","r.X","r.S",], title="Batch",)
     debug_print("final-values-batch:", str(r_X, ), str(r_S, ), )
     debug_print('simulation Batch finished.') 
コード例 #3
0
ファイル: bioreactor.py プロジェクト: gmassei/bastelpython
 def initialize(self,  ): 
     ''' 
     Compute parameter values and 
     compute initial values of state variables 
     ''' 
     #Make parameters visible in initialize method. 
     param = self.param 
     #create all variables with value 0; to prevent runtime errors.
     time = 0.0 
     r_mu = 0.0 
     r_D = 0.0 
     r_S_pos = 0.0 
     r_STY = 0.0 
     r_S = 0.0 
     r_X = 0.0 
     r_X_Dtime = 0.0 
     r_S_Dtime = 0.0 
     #do computations 
     self.set_solution_parameters(duration = 30.0, reporting_interval = 0.1, )
     param.r_mu_max = 0.32
     param.r_Ks = 0.01
     param.r_Yxs = 0.5
     param.r_Sf = 20.0
     param.D = 0.0
     param.r_ms = 0.02
     r_X = 0.1
     r_S = 20.0
     debug_print("initial-values-batch:", str(r_X, ), str(r_S, ), )
     
     #assemble initial values to array and store them 
     self.initialValues = array([r_S, r_X, ], 'float64') 
     self.stateVectorLen = len(self.initialValues) 
     #put algebraic variables into array, only to compute its size 
     algVars = array([r_D, r_STY, r_S_pos, r_mu, time, ], 'float64') 
     self.algVectorLen = len(algVars) 
     #Create mapping between variable names and array indices 
     self.variableNameMap = {'r.S':0, 'r.X':1, 'r.D':2, 'r.STY':3, 'r.S_pos':4, 'r.mu':5, 'time':6, }