from kmos.run import KMC_Model model = KMC_Model(banner=False) model.parameters.p_COgas = 2.e-1 model.parameters.p_O2gas = 1.e-1 nrel = 1e7 nsample = 1e7 # numerical parameters Ts = range(450, 650, 20) # 20 values between 450 and 650 K TOFs = [] # empty list for output # Loop over the temperature for T in Ts: model.parameters.T = T # Set the temperature model.do_steps(nrel) # Relax the system # Sample the reactivity output = model.get_std_sampled_data(1, nsample, output='dict') # Collect output TOFs.append(output['CO_oxidation']) # Transform the variables invTs = [1 / float(T) for T in Ts] logTOFs = [math.log(TOF, 10.) for TOF in TOFs] # and plot import matplotlib.pyplot as plt plt.plot(invTs, logTOFs, '-o') plt.xlabel('1/T [1/K]') plt.ylabel('log(TOF) / events (sites s)^-1') plt.savefig('arrhenius.pdf') # Optionally, save plot plt.show()
from kmos.run import KMC_Model model = KMC_Model(banner = False) model.parameters.p_COgas = 2.e-1 model.parameters.p_O2gas = 1.e-1 nrel = 1e7; nsample = 1e7 # numerical parameters Ts = range(450,650,20) # 20 values between 450 and 650 K TOFs = [] # empty list for output # Loop over the temperature for T in Ts: model.parameters.T = T # Set the temperature model.do_steps(nrel) # Relax the system # Sample the reactivity output = model.get_std_sampled_data(1, nsample, output='dict') # Collect output TOFs.append(output['CO_oxidation']) # Transform the variables invTs = [1/float(T) for T in Ts] logTOFs = [math.log(TOF,10.) for TOF in TOFs] # and plot import matplotlib.pyplot as plt plt.plot(invTs, logTOFs, '-o') plt.xlabel('1/T [1/K]') plt.ylabel('log(TOF) / events (sites s)^-1') plt.savefig('arrhenius.pdf') # Optionally, save plot plt.show()
from kmos.run import KMC_Model model = KMC_Model(banner = False) model.parameters.p_COgas = 2.e-1 model.parameters.p_O2gas = 1.e-1 nrel = 1e7; nsample = 1e7 # numerical parameters Ts = range(450,650,20) # 20 values between 450 and 650 K fout = open('arrhenius.dat', 'w') # open an output file fout.write(model.get_std_header()) # print the header # Loop over the temperature for T in Ts: model.parameters.T = T # Set the desired temperature model.do_steps(nrel) # Relax the system # Sample the reactivity and print data to file output = model.get_std_sampled_data(1, nsample) fout.write(output) fout.close() # Close output file # We can read the file with numpy... import numpy as np data = np.loadtxt('arrhenius.dat') iT = 0; iTOF = 3 # columns for each variable # ... and then plot import matplotlib.pyplot as plt # numpy arrays can be transformed much more easily plt.plot(1/data[:,iT], np.log10(data[:,iTOF]), '-o') plt.xlabel('1/T [1/K]') plt.ylabel('log(TOF) / events (sites s)^-1') # plt.savefig('arrhenius.pdf') # Optionally, save plot plt.show()
#sample_steps sample_steps = 1e7 #relax model model.do_steps(relax_steps) atoms = model.get_atoms(geometry=False) #get rate constant k = float(model.rate_constants(process).split('=')[1][1:-8]) #get initial TOF k_ini = k * (1 - delta) model.rate_constants.set("CO_adsorption_cus", k_ini) data = model.get_std_sampled_data(samples=1, sample_size=sample_steps, tof_method="integ") tof_ini = float(data.split(' ')[3]) #get final TOF k_fin = k * (1 + delta) model.rate_constants.set("CO_adsorption_cus", k_fin) data = model.get_std_sampled_data(samples=1, sample_size=sample_steps, tof_method="integ") tof_fin = float(data.split(' ')[3]) delta_TOF = tof_fin - tof_ini delta_k = k_fin - k_ini DRC = (k_ini / tof_ini) * (delta_TOF / delta_k)
model = KMC_Model(banner=False) model.parameters.p_COgas = 2.e-1 model.parameters.p_O2gas = 1.e-1 nrel = 1e7 nsample = 1e7 # numerical parameters Ts = range(450, 650, 20) # 20 values between 450 and 650 K fout = open('arrhenius.dat', 'w') # open an output file fout.write(model.get_std_header()) # print the header # Loop over the temperature for T in Ts: model.parameters.T = T # Set the desired temperature model.do_steps(nrel) # Relax the system # Sample the reactivity and print data to file output = model.get_std_sampled_data(1, nsample) fout.write(output) fout.close() # Close output file # We can read the file with numpy... import numpy as np data = np.loadtxt('arrhenius.dat') iT = 0 iTOF = 3 # columns for each variable # ... and then plot import matplotlib.pyplot as plt # numpy arrays can be transformed much more easily plt.plot(1 / data[:, iT], np.log10(data[:, iTOF]), '-o') plt.xlabel('1/T [1/K]') plt.ylabel('log(TOF) / events (sites s)^-1') # plt.savefig('arrhenius.pdf') # Optionally, save plot
relax_steps = 1e6 #sample_steps sample_steps = 1e7 #relax model model.do_steps(relax_steps) atoms = model.get_atoms(geometry=False) #get rate constant k = float(model.rate_constants(process).split('=')[1][1:-8]) #get initial TOF k_ini = k*(1-delta) model.rate_constants.set("CO_adsorption_cus", k_ini) data = model.get_std_sampled_data(samples=1,sample_size=sample_steps,tof_method="integ") tof_ini = float(data.split(' ')[3]) #get final TOF k_fin = k*(1+delta) model.rate_constants.set("CO_adsorption_cus", k_fin) data = model.get_std_sampled_data(samples=1,sample_size=sample_steps,tof_method="integ") tof_fin = float(data.split(' ')[3]) delta_TOF = tof_fin - tof_ini delta_k = k_fin - k_ini DRC = (k_ini / tof_ini) * (delta_TOF / delta_k) print 'delta: ',delta print 'sample_steps: ',sample_steps print 'DRC: ',DRC