md_relax_job.structure = gt_gs md_relax_job.forcefield = ezff.generate_forcefield(template, rr, FFtype = 'reaxff') md_relax_job.options['pbc'] = False md_relax_job.options['relax_atoms'] = True md_relax_job.options['relax_cell'] = False md_relax_job.options['atomic_charges'] = True # Run GULP calculation md_relax_job.run(command='gulp') # Read output from completed GULP job and clean-up md_relax = md_relax_job.read_structure() md_relax_job.cleanup() # Calculate error charg_error = ezff.error_atomic_charges(MD=md_gs_atomic_charges, GT=gt_gs_atomic_charges) disp_error = ezff.error_structure_distortion(MD=md_relax, GT=gt_gs) return [charg_error, disp_error] # Generate forcefield template and variable ranges FF = reax_forcefield('ffield') FF.make_template_qeq('S') FF.generate_templates() # Read template and variable ranges bounds = ezff.read_variable_bounds('param_ranges', verbose=False) template = ezff.read_forcefield_template('ff.template.generated') problem = ezff.OptProblem(num_errors = 2, variable_bounds = bounds, error_function = my_error_function, template = template) algorithm = ezff.Algorithm(problem, 'NSGAII', population = 16, mutation_probability = 0.4) ezff.optimize(problem, algorithm, iterations = 4)
import ezff from ezff.interfaces import gulp, vasp import numpy as np bounds = ezff.read_variable_bounds('variable_bounds', verbose=False) template = ezff.read_forcefield_template('template') # DEFINE GROUND TRUTHS gt_bulk_modulus = 1.1236 #GPa gt_structure = vasp.read_atomic_structure('ground_truths/POSCAR') def my_error_function(variable_values): # Get rank from pool try: myrank = pool.rank except: myrank = 0 # Configure GULP job. path = str(myrank) md_job = gulp.job(path=path) md_job.structure = gt_structure md_job.forcefield = ezff.generate_forcefield(template, variable_values, FFtype='SW') md_job.options['pbc'] = True md_job.options['relax_atoms'] = True md_job.options['relax_cell'] = True # Submit job and read output