defect.params['core'] = np.array([98.0, 98.0, 1.49]) defect = set_quantum(defect, params.n_core) MaxwellBoltzmannDistribution(defect, 2.0 * sim_T) if dyn_type == 'eam': dynamics = VelocityVerlet(defect, timestep) dynamics.attach(pass_print_context(defect, dynamics)) elif dyn_type == 'LOTF': defect.info['core'] = np.array([98.0, 98.0, 1.49]) print 'Initializing LOTFDynamics' verbosity_push(PRINT_VERBOSE) dynamics = LOTFDynamics(defect, timestep, params.extrapolate_steps, check_force_error=False) dynamics.set_qm_update_func(update_qm_region) dynamics.attach(pass_print_context(defect, dynamics)) dynamics.attach(traj_writer, print_interval, defect) else: print 'No dyn_type chosen', 1 / 0 trajectory = AtomsWriter('{0}.traj.xyz'.format(input_file)) print 'Running Crack Simulation' dynamics.run(nsteps) #Write cooked i.e. thermalized ceel to file. defect.set_cutoff(3.0) defect.calc_connect() new_core = pp_nye_tensor(defect, dis_type=dis_type) defect.info['core'] = new_core defect.write('{0}_therm.xyz'.format(input_file)) print 'Crack Simulation Finished'
if args.check_force: pred_corr_logfile = open('pred-corr-error.txt','w') dynamics.attach(log_pred_corr_errors, 1, dynamics, pred_corr_logfile) # array to store time averaged stress field avg_sigma = np.zeros((len(atoms), 3, 3)) def update_qm_region(atoms): crack_pos = find_crack_tip_stress_field(atoms, calc=mm_pot, avg_sigma=avg_sigma) qm_list = qmmm_pot.get_qm_atoms(atoms) qm_list = update_hysteretic_qm_region(atoms, qm_list, crack_pos, qm_inner_radius, qm_outer_radius) qmmm_pot.set_qm_atoms(qm_list, atoms) print "Initialising Dynamics" dynamics.set_qm_update_func(update_qm_region) def print_context(ats=atoms, dyn=dynamics): print 'steps, T', dyn.nsteps, ats.get_kinetic_energy()/(1.5*units.kB*len(ats)) print 'G', get_energy_release_rate(ats)/(units.J/units.m**2) print 'strain', get_strain(ats) print 'state', dynamics.state def write_slab(dynamics=dynamics): if dynamics.state == LOTFDynamics.Interpolation: dynamics.atoms.set_array('avg_sigma', avg_sigma.reshape((len(atoms), 9))) write_xyz('crack_slab.xyz', dynamics.atoms, append=True) dynamics.attach(print_context, interval=1) dynamics.attach(write_slab, interval=1) print 'Running Dynamics'
else: print 'Initializing LOTF Dynamics' dynamics = LOTFDynamics(atoms, timestep, extrapolate_steps, check_force_error=check_force_error) system_timer('init_dynamics') # Function to update the QM region at the beginning of each extrapolation cycle if not check_force_error: if extrapolate_steps == 1: if not classical: dynamics.attach(update_qm_region, 1, dynamics.atoms) else: # Choose appropriate update function for defects or crack or grainboundary print 'Setting Update Function' if geom =='disloc': dynamics.set_qm_update_func(update_qm_region) elif geom =='crack': if quantumregion == 'Crack': dynamics.set_qm_update_func(update_qm_region_crack) elif quantumregion =='Hydrogen': dynamics.set_qm_update_func(set_qm_H(h_list)) else: sys.exit("No quantum region chosen") else: print 'No geometry chosen', 1/0 if check_force_error: pred_corr_logfile = open(os.path.join(rundir, 'pred-corr-error.txt'), 'w') dynamics.attach(log_pred_corr_errors, 1, dynamics, pred_corr_logfile) dynamics.attach(traj_writer, traj_interval, dynamics)