def TPR_simulationFunctionWrapperPiecewise(discreteParameterVector): global times discreteParameterVectorList = list(discreteParameterVector) #converting to list so can use list expansion in arguments. tpr_theta_Arguments = [tprequation, initial_concentrations_array, times, (*discreteParameterVectorList,beta_dTdt,T_0) ] tpr_theta = odeint(*tpr_theta_Arguments) # [0.5, 0.5] are the initial theta's. simulationInputArguments = [tpr_theta, times, *discreteParameterVectorList, beta_dTdt,T_0] simulationOutput = tprequation(*simulationInputArguments) return simulationOutput
def TPR_simulationFunctionWrapperRatioFirst(discreteParameterVectorRatioFirst): global times discreteParameterVectorList = list( discreteParameterVectorRatioFirst ) #converting to list so can use pop and also list expansion in arguments. initial_concentrations_array[0] = 1 - discreteParameterVectorRatioFirst[0] initial_concentrations_array[1] = discreteParameterVectorRatioFirst[0] discreteParameterVectorList.pop(0) tpr_theta_Arguments = [ tprequation, initial_concentrations_array, times, (*discreteParameterVectorList, beta_dTdt, T_0) ] tpr_theta = odeint( *tpr_theta_Arguments) # [0.5, 0.5] are the initial theta's. simulationInputArguments = [ tpr_theta, times, *discreteParameterVectorList, beta_dTdt, T_0 ] simulationOutput = tprequation(*simulationInputArguments) return simulationOutput
######################## Import experimental data experiments_df = pd.read_csv( '../ExperimentalDataAcetaldehydeTPDCeO2111MullinsTruncatedLargerErrors.csv' ) dT = experiments_df['dT'][0] # assuming dT and dt are constant throughout dt = experiments_df['dt'][0] start_T = experiments_df['AcH - T'][0] theta_1_t0 = 0.5 # half of the surface initially coverered with theta_1 theta_2_t0 = 0.5 tpr_theta = odeint(tprequation, [theta_1_t0, theta_2_t0], experiments_df['time'].to_numpy(), args=(Ea1_mean, Ea2_mean, log_A1_mean, log_A2_mean, gamma_1_mean, gamma_2_mean, dT, dt, start_T)) rate = tprequation(tpr_theta, experiments_df['time'].to_numpy(), Ea1_mean, Ea2_mean, log_A1_mean, log_A2_mean, gamma_1_mean, gamma_2_mean, dT, dt, start_T) print(rate) rate = np.asarray(rate) print(rate.shape) rate_tot = -np.sum(rate, axis=0) fig1, ax1 = plt.subplots() ax1.plot(experiments_df['AcH - T'].to_numpy(), rate_tot, 'r') ax1.set_xlabel('T (K)') ax1.set_ylabel(r'$rate (s^{-1})$') ax1.legend(['model prior']) fig1.tight_layout() fig1.savefig('twocomponent.png', dpi=220) fig2, ax2 = plt.subplots() ax2.plot(experiments_df['AcH - T'].to_numpy(),