def main(): Tr = 750.0 # Experimental variance is known in this problem, # it can be estimated if not provided noise = 0.05 # ndata = 10 in publication example ndata = 30 ns = 9 # Define temperature bounds Tlo = 500 Tup = 1000 # Define range of inlet concentrations lb = [0, 0, 0, 0, 0, 1, 0, 0, 1] ub = [3] * ns gc = .008314 Temp = np.linspace(Tlo, Tup, ndata) # Initialize concentration data # Inlet concentrations are fixed in publication example # cdata0 = [[.5,0,0,0,0,4.5,0,0,4.5]]*ndata cdata0 = np.zeros([ndata, ns]) for i in range(ndata): for j in range(ns): cdata0[i, j] = random.uniform(lb[j], ub[j]) # Calculate steady-state concentration values from simulator cracsim.py cdata = cracsim.sim(np.hstack((cdata0, np.expand_dims(Temp, axis=1)))) # In this example, we know the true stoichiometries. Lets define them first for clarity t_stoich = [[-1, 1, 0, 0, 0, 0, 1, 0, 0], [-1, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, -1, 2, 0, -2, 0, 0], [0, 0, 0, 0, -1, -2, 4, 1, 0]] # Additional considered stoichiometries are defined a_stoich = [[-1, 0, 0, 0, 0, -16, 21, 8, 0], [-1, 0, 0, 4, 0, 0, -3, 0, 0], [0, 0, 0, -1, 0, -4, 6, 2, 0], [-1, 0, 1, 0, 2, 0, -2, 0, 0]] # Index 0-3 are the true reactions, 4-7 are considered reactions stoichs = t_stoich + a_stoich # Define kinetic mechanisms, adsorption parameters must be known a-priori kco = 35 kst = 1.5 # Mechanisms can be defined for each stoichiometry using a list-of-list mechs = [[[0, 1, 3, 4, 7], eb_dep], [[0], [t_st_prod, cat_st_prod_t1]], [[0, 1], cat_ben_prod_t2], [[2, 3], meth_prod_t3], [[2, 3], ch4_to_co_t4], [[2, 3, 4, 5, 6, 7], [ma_g, ma_h]]] # Experimental variance is known in this case sigma = np.multiply(noise**2, cdata) results = ripe.ripemodel(cdata, stoich=stoichs, mechanisms=mechs, x0=cdata0, temp=Temp, sigma=sigma, tref=Tr)
def main(): spec = ['X'] # Import data from csv data = np.genfromtxt('clc.csv', delimiter=',') t = data[:, 0] xdata = data[:, 1] stoich = [1] # User pre-defined clc rate forms found in RIPE mechs = ripe.clcforms # Identify optimal kinetic mechanism results = ripe.ripemodel(xdata, stoichiometry=stoich, mechanisms=mechs, time=t)
def main(): spec = ['X'] # Import data from csv data = np.genfromtxt('clc.csv', delimiter=',') t = data[:, 0] xdata = data[:, 1] stoich = [1] # User pre-defined clc rate forms found in RIPE # mechs = ripe.clcforms clc_mechs = [ mechs.powerlawp5, mechs.powerlaw2, mechs.powerlaw3, mechs.powerlaw4, mechs.avrami2, mechs.avrami3, mechs.avrami4, mechs.avrami5, mechs.randomnuc, mechs.ptompkins, mechs.jander, mechs.antijander, mechs.valensi, mechs.parabolic, mechs.gb3d, mechs.zlt, mechs.grain ] # Identify optimal kinetic mechanism results = ripe.ripemodel(xdata, stoichiometry=stoich, mechanisms=clc_mechs, time=t)
def main(): #ndata = 100 noise = 0.1 ns = 5 lb_conc = [0, 0, 0, 0, 0] ub_conc = [10, 10, 0, 0, 0] # Initialize concentration arrays # initial concentrations - only 2 data points at bounds cdata0 = [[1, 1, 0, 0, 0], [10, 10, 0, 0, 0]] cdata = isotsim.sim(cdata0) nd = len(cdata0) # Considered reaction stoichiometries stoich = [[-1, -1, 1, 0, 0], [0, -1, -1, 1, 0], [-1, 0, 0, -1, 1], [-1, -2, 0, 1, 0], [-2, -2, 0, 0, 1], [-1, -1, -1, 0, 1], [-2, -1, 1, -1, 1]] # IRIPE internal mass action kinetics are specified rxn_mechs = [['all', 'massact']] # Use expected variance - estimated from data if not provided sigma = np.multiply(noise**2, np.array(cdata)) # Call to RIPE results = ripe.ripemodel(cdata, stoich=stoich, mechanisms=rxn_mechs, x0=cdata0, hide_output=False, sigma=sigma, deltaterm=0, expand_output=True) # Adaptive experimental design using error maximization sampling [new_points, err] = ripe.ems(results, isotsim.sim, lb_conc, ub_conc, 5, x=cdata, x0=cdata0) # Implement EMS as described in the RIPE publication new_res = isotsim.sim(new_points)[0] ite = 0 # print 'maximum allowable tolerances : ', [noise*s for s in new_res] while any(err > [2 * noise * s for s in new_res]): # print 'Which concentrations violate error (True=violation) : ', err > [noise*s for s in new_res] results = {} ite += 1 # Data updated explicitly so RBFopt subroutines produce consistent results new_cdata0 = np.zeros([nd + ite, ns]) new_cdata = np.zeros([nd + ite, ns]) new_cdata0[:-1][:] = cdata0[:][:] new_cdata[:-1][:] = cdata[:][:] new_cdata0[-1][:] = new_points[:] res = isotsim.sim(new_points)[0] for j in range(len(res)): new_cdata[-1][j] = res[j] #Update weight parameters sigma = np.multiply(noise**2, np.array(new_cdata)) # Build updated RIPE model results = ripe.ripemodel(new_cdata, stoich=stoich, mechanisms=rxn_mechs, x0=new_cdata0, sigma=sigma, expand_output=True) # Another call to EMS [new_points, err] = ripe.ems(results, isotsim.sim, lb_conc, ub_conc, 5, x=cdata, x0=cdata0) # Update results new_res = isotsim.sim(new_points)[0] cdata0 = new_cdata0 cdata = new_cdata # Final call to RIPE to get concise output results = ripe.ripemodel(cdata, stoich=stoich, mechanisms=rxn_mechs, x0=cdata0, sigma=sigma, expand_output=False)