m.set_calculator(calculator) m.get_potential_energy() cmr_params = { "db_keywords": [project_id], # add project_id also as a field to support search across projects "project_id": project_id, "formula": formula, "calculator": calculator.name, } write(filename=('reactions_xsimple.%s.db' % formula), images=m, format='db', cmr_params=cmr_params) # analyse the results with CMR from cmr.ui import DirectoryReader reader = DirectoryReader('.') # read all compounds in the project calculated with EMT all = reader.find(name_value_list=[('calculator', 'EMT')], keyword_list=[project_id]) all.print_table(0, columns=["formula", "ase_potential_energy"]) print group = cmr.create_group() group_vars = {"reaction":reaction, "output":"group.db"} sum = 0.0 for (formula, coef) in reaction: data = all.get("formula", formula) if data is None: print "%s is missing"%formula
"db_keywords": [project_id], # add project_id also as a field to support search across projects "project_id": project_id, "formula": formula, "calculator": calculator.name, } write(filename=('reactions_xsimple.%s.db' % formula), images=m, format='db', cmr_params=cmr_params) # analyse the results with CMR from cmr.ui import DirectoryReader reader = DirectoryReader('.') # read all compounds in the project calculated with EMT all = reader.find(name_value_list=[('calculator', 'EMT')], keyword_list=[project_id]) all.print_table(0, columns=["formula", "ase_potential_energy"]) print group = cmr.create_group() group_vars = {"reaction": reaction, "output": "group.db"} sum = 0.0 for (formula, coef) in reaction: data = all.get("formula", formula) if data is None: print "%s is missing" % formula
# reaction energies on initial, unoptimized geometries cmr_params = {'geometries': 'initial'} re.make_reaction_groups(database=False, index=0, cmr_params=cmr_params) # print re.print_result(database=False) # reaction energies on final, optimized geometries cmr_params = {'geometries': 'final'} re.make_reaction_groups(database=False, index=-1, cmr_params=cmr_params) # print re.print_result(database=False) reader = DirectoryReader('.') # retrieve all reactions (groups) with project_id and optimized geometries from the current directory all = reader.find(name_value_list=[('db_calculator', 'group'), ('geometries', 'final')], keyword_list=[project_id, 'reaction']) print 'reaction_id, calc, ref, calc - ref' # compare with the reference for r in reactions: reaction_id = r[-1][1] res = all.get('reaction_id', reaction_id) if res is None: print "Could not find reaction_id %s in reference" % str(reaction_id) else: calc = res['reaction_energy']
# reaction energies on initial, unoptimized geometries cmr_params = {'geometries': 'initial'} re.make_reaction_groups(database=False, index=0, cmr_params=cmr_params) # print re.print_result(database=False) # reaction energies on final, optimized geometries cmr_params = {'geometries': 'final'} re.make_reaction_groups(database=False, index= -1, cmr_params=cmr_params) # print re.print_result(database=False) reader = DirectoryReader('.') # retrieve all reactions (groups) with project_id and optimized geometries from the current directory all = reader.find(name_value_list=[('db_calculator', 'group'), ('geometries', 'final') ], keyword_list=[project_id, 'reaction']) print 'reaction_id, calc, ref, calc - ref' # compare with the reference for r in reactions: reaction_id = r[-1][1] res = all.get('reaction_id', reaction_id) if res is None: print "Could not find reaction_id %s in reference"%str(reaction_id) else:
data = cmr.read(cmrfile) data.set_user_variable('xc', xc) data.write(cmrfile) # perform PBE calculation on LDA density ediff = calc2.get_xc_difference('PBE') # add new results to the cmrfile data = cmr.read(cmrfile) data.set_user_variable('PBE', data['ase_potential_energy'] + ediff) data.write(cmrfile) # analyze the results with CMR from cmr.ui import DirectoryReader reader = DirectoryReader(directory='.', ext='.cmr') # read all compounds in the project with lcao all = reader.find(name_value_list=[('mode', 'lcao')], keyword_list=[project_id]) results = all.get('formula', formula) print(results['formula'], results['xc'], results['ase_potential_energy']) # column_length=0 aligns data in the table (-1 : data unaligned is default) all.print_table(column_length=0, columns=['formula', 'xc', 'h', 'ase_potential_energy', 'PBE']) equal(results['PBE'], e + ediff, 1e-6) if rank == 0: for file in [formula + '.gpw', formula + '.db', cmrfile]:
data = cmr.read(cmrfile) data.set_user_variable("xc", xc) data.write(cmrfile) # perform PBE calculation on LDA density ediff = calc2.get_xc_difference("PBE") # add new results to the cmrfile data = cmr.read(cmrfile) data.set_user_variable("PBE", data["ase_potential_energy"] + ediff) data.write(cmrfile) # analyze the results with CMR from cmr.ui import DirectoryReader reader = DirectoryReader(directory=".", ext=".cmr") # read all compounds in the project with lcao all = reader.find(name_value_list=[("mode", "lcao")], keyword_list=[project_id]) results = all.get("formula", formula) print results["formula"], results["xc"], results["ase_potential_energy"] # column_length=0 aligns data in the table (-1 : data unaligned is default) all.print_table(column_length=0, columns=["formula", "xc", "h", "ase_potential_energy", "PBE"]) equal(results["PBE"], e + ediff, 1e-6) if rank == 0: for file in [formula + ".gpw", formula + ".db", cmrfile]: if os.path.exists(file): os.unlink(file)
cmrfile = formula + '.cmr' # add new results to the cmrfile data = cmr.read(cmrfile) data.set_user_variable('U_potential_energy_PBE', data['U_potential_energy'] + ediff) data.write(cmrfile) del calc if analyse_from_dir: # analyze the results from cmr files in the local directory from cmr.ui import DirectoryReader # read all compounds in the project with lcao and LDA orbitals reader = DirectoryReader(directory='.', ext='.cmr') all = reader.find(name_value_list=[('U_mode', 'lcao'), ('U_xc', 'LDA')], keyword_list=[project_id]) if rank == 0: print('results from cmr files in the local directory') # print requested results # column_length=0 aligns data in the table (-1 : data unaligned is default) all.print_table(column_length=0, columns=['U_formula', 'U_vacuum', 'U_xc', 'U_h', 'U_hund', 'U_potential_energy', 'U_potential_energy_PBE', 'ase_temperature']) # access the results directly and calculate atomization energies f2 = symbol + '2' f1 = symbol