components['AH'] = 0.395555 components['B'] = 0.0351202 components['C'] = 0.0 components['BH+'] = 0.0 components['A-'] = 0.0 components['AC-'] = 0.0 components['P'] = 0.0 builder.add_mixture_component(components) # add algebraics algebraics = ['0', '1', '2', '3', '4', '5', 'k4T', 'Temp'] # the indices of the rate rxns # note the fifth, sixth and seventh components. Which basically work as inputs builder.add_algebraic_variable(algebraics) #Load Temp data: dataDirectory = os.path.abspath( os.path.join( os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))), 'data_sets')) Ttraj = os.path.join(dataDirectory, 'Tempvalues.csv') fixed_Ttraj = read_absorption_data_from_csv(Ttraj) params = dict() params['k0'] = 49.7796 params['k1'] = 8.93156 params['k2'] = 1.31765 params['k3'] = 0.310870
from kipet.library.CasadiSimulator import * import matplotlib.pyplot as plt import sys if __name__ == "__main__": with_plots = True if len(sys.argv) == 2: if int(sys.argv[1]): with_plots = False # create template model builder = TemplateBuilder() builder.add_mixture_component('A', 1) builder.add_mixture_component('B', 0) builder.add_algebraic_variable('ra') builder.add_parameter('k', 0.01) # define explicit system of ODEs def rule_odes(m, t): exprs = dict() exprs['A'] = -m.Y[t, 'ra'] exprs['B'] = m.Y[t, 'ra'] return exprs builder.set_odes_rule(rule_odes) def rule_algebraics(m, t): algebraics = list() algebraics.append(m.Y[t, 'ra'] - m.P['k'] * m.Z[t, 'A']) return algebraics