1################################################################## 2## (c) Copyright 2018- by Jaron T. Krogel ## 3################################################################## 4 5 6#====================================================================# 7# pyscf_sim.py # 8# Nexus interface for the PySCF simulation framework. # 9# # 10# Content summary: # 11# Pyscf # 12# Simulation class for PySCF # 13# # 14# generate_pyscf # 15# User-facing function to generate Pyscf simulation objects. # 16#====================================================================# 17 18 19import os 20from generic import obj 21from execute import execute 22from simulation import Simulation 23from pyscf_input import PyscfInput,generate_pyscf_input 24from pyscf_analyzer import PyscfAnalyzer 25from developer import ci 26 27 28 29class Pyscf(Simulation): 30 input_type = PyscfInput 31 analyzer_type = PyscfAnalyzer 32 generic_identifier = 'pyscf' 33 infile_extension = '.py' 34 application = 'python' 35 application_properties = set(['serial','mpi']) 36 application_results = set(['orbitals','wavefunction']) 37 38 39 def check_result(self,result_name,sim): 40 calculating_result = False 41 if result_name=='orbitals': 42 conv_requested = self.input.save_qmc 43 prefix_provided = self.input.prefix is not None 44 calculating_result = conv_requested and prefix_provided 45 elif result_name=='wavefunction': 46 calculating_result = self.input.checkpoint 47 #end if 48 return calculating_result 49 #end def check_result 50 51 52 def get_result(self,result_name,sim): 53 result = obj() 54 if result_name=='orbitals': 55 h5_file = self.input.prefix+'.h5' 56 result.h5_file = os.path.join(self.locdir,h5_file) 57 elif result_name=='wavefunction': 58 result.chkfile = os.path.join(self.locdir,self.input.chkfile) 59 else: 60 self.error('ability to get result '+result_name+' has not been implemented') 61 #end if 62 return result 63 #end def get_result 64 65 66 def incorporate_result(self,result_name,result,sim): 67 not_implemented = False 68 if not_implemented: 69 self.error('ability to incorporate result '+result_name+' has not been implemented') 70 #end if 71 #end def incorporate_result 72 73 74 def check_sim_status(self): 75 # success of a generic pyscf script is too hard to assess 76 # burden of when to initiate dependent simulations left to user 77 self.failed = False 78 self.finished = self.job.finished 79 #end def check_sim_status 80 81 82 def get_output_files(self): 83 output_files = [] 84 return output_files 85 #end def get_output_files 86 87 88 def app_command(self): 89 app_command = self.app_name+' '+self.infile 90 return app_command 91 #end def app_command 92 93#end class Pyscf 94 95 96 97def generate_pyscf(**kwargs): 98 sim_args,inp_args = Pyscf.separate_inputs(kwargs) 99 100 if not 'input' in sim_args: 101 if 'input_type' in inp_args: 102 input_type = inp_args.input_type 103 del inp_args.input_type 104 #end if 105 if 'prefix' not in inp_args and 'identifier' in sim_args: 106 inp_args['prefix'] = sim_args['identifier'] 107 #end if 108 sim_args.input = generate_pyscf_input(**inp_args) 109 #end if 110 py = Pyscf(**sim_args) 111 112 return py 113#end def generate_pyscf 114 115