def load_saved_data(): # File names for loading/saving parameters tg_load_file = 'test_reaction_throttling_parameters.txt' tg_save_file = 'test_reaction_throttling_parameters.txt' sg_load_file = 'test_reaction_snapshots_parameters.txt' sg_save_file = 'test_reaction_snapshots_parameters.txt' # Export/import module objects for saving/loading data tg_eil_object = eil.module_export_import(tg_save_file, tg_load_file, tg) sg_eil_object = eil.module_export_import(sg_save_file, sg_load_file, sg) # Load modules sg_eil_object.load_params() tg_eil_object.load_params() # Reset number of steps and time sg.model.base.set_kmc_time(sg.kmc_time) sg.model.base.set_kmc_step(sg.steps_so_far) sg.atoms.kmc_step = sg.steps_so_far # Load the lattice sg.model._set_configuration(np.array(sg.config)) sg.model._adjust_database() # Update the snapshot number tg.current_snapshot += 1
#If you need to change a parameter after each snapshot, only do 1 snapshot at a time with n_snapshots=1. Ti = 300 #initial temperature Tf = 325 #final temperature beta = 5 #beta, heating rate in Kelvin per second. load_simulation_state = False # File names for loading/saving parameters tg_load_file = sg.simulation_name + 'throttling_parameters.txt' tg_save_file = sg.simulation_name + 'throttling_parameters.txt' sg_load_file = sg.simulation_name + 'snapshots_parameters.txt' sg_save_file = sg.simulation_name + 'snapshots_parameters.txt' # Export/import module objects for saving/loading data tg_module = eil.module_export_import(tg_save_file, tg_load_file, tg) sg_module = eil.module_export_import(sg_save_file, sg_load_file, sg) if load_simulation_state: # Load modules sg_module.load_params() tg_module.load_params() # Reset number of steps and time sg.model.base.set_kmc_time(sg.kmc_time) sg.model.base.set_kmc_step(sg.steps_so_far) sg.atoms.kmc_step = sg.steps_so_far # Load the lattice sg.model._set_configuration(np.array(sg.config))
import kmcos.runfile_init as runfile_init except: import snapshots_globals as sg import snapshots import throttling_globals as tg import throttling import runfile_init #This is optional. import export_import_library as eil #optional, but useful. # Initialize variables # File names for loading/saving parameters (optional, but useful). tg_load_file = 'test_reaction_throttling_parameters.txt' tg_save_file = 'test_reaction_throttling_parameters.txt' sg_load_file = 'test_reaction_snapshots_parameters.txt' sg_save_file = 'test_reaction_snapshots_parameters.txt' tg_eil_object = eil.module_export_import(tg_save_file, tg_load_file, tg) sg_eil_object = eil.module_export_import(sg_save_file, sg_load_file, sg) eic_module_objects = [tg_eil_object, sg_eil_object] sg.model.parameters.T = 600 #If you want to set the random seed: random_seed = -731543675 runfile_init.set_PRNG_state(load_saved_parameters_on=True, random_seed=random_seed) # The number of snapshots Nsnapshots = 100 # Number of snapshots to run # The total steps per snapshot (sps) and time per snapshot (tps). Values of None # mean to use tg.throttling_sps and tg.throttling_tps instead.