def run(self): """Run the calculation using ADF.""" # path needed for the calculation wd = ''.join(self.atoms) + '_' + self.basis_name t21_name = wd + '.t21' plams_wd = './plams_workdir' t21_path = os.path.join(plams_wd, os.path.join(wd, t21_name)) # configure plams and run the calculation self.init_plams() mol = self.get_plams_molecule() sett = self.get_plams_settings() job = plams.ADFJob(molecule=mol, settings=sett, name=wd) job.run() # extract the data to hdf5 basis = self.get_basis_data(t21_path) # remove adf data if self.savefile: shutil.copyfile(t21_path, t21_name) self.savefile = t21_name shutil.rmtree(plams_wd) return basis
def run_job(cls, settings: Settings, mol: plams.Molecule, job_name: str = 'ADFjob', nproc: Optional[int] = None, validate_output: bool = True, **kwargs: Any) -> ADF_Result: """Execute ADF job. :param settings: user input settings. :type settings: |Settings| :param mol: Molecule to run the simulation :type mol: Plams Molecule :parameter input_file_name: The user can provide a name for the job input. :type input_file_name: String :parameter out_file_name: The user can provide a name for the job output. :type out_file_name: String :returns: :class:`~qmflows.packages.SCM.ADF_Result` """ adf_settings = Settings() if nproc: adf_settings.runscript.nproc = nproc adf_settings.input = settings.specific.adf job = plams.ADFJob(name=job_name, molecule=mol, settings=adf_settings) result = job.run() # Relative job path relative_plams_path = join(*str(result.job.path).split(os.sep)[-2:]) # Absolute path to the .dill file dill_path = join(job.path, f'{job.name}.dill') adf_result = cls.result_type(adf_settings, mol, result.job.name, dill_path, plams_dir=relative_plams_path, work_dir=result.job.path, status=job.status) return adf_result
def run(self, init=True, path=None): ''' Method that runs this job ''' if init: if path is None: plams.init(path=os.getcwd() + r'\RUNS', folder=time.strftime("[%H:%M](%d-%m-%Y)", time.localtime())) else: plams.init(path=path) s = self.settings job = plams.ADFJob(molecule=self.mol, name=self.job_name, settings=s) results = job.run() results.dir = '\\'.join(results._kfpath().split('\\')[:-2]) results.KFPATH = results._kfpath() if init: plams.finish() return results._kfpath()
def run_job(settings, mol, job_name='ADFjob', nproc=None): """ Execute ADF job. :param settings: user input settings. :type settings: |Settings| :param mol: Molecule to run the simulation :type mol: Plams Molecule :parameter input_file_name: The user can provide a name for the job input. :type input_file_name: String :parameter out_file_name: The user can provide a name for the job output. :type out_file_name: String :returns: :class:`~qmflows.packages.SCM.ADF_Result` """ adf_settings = Settings() if nproc: adf_settings.runscript.nproc = nproc adf_settings.input = settings.specific.adf job = plams.ADFJob(name=job_name, molecule=mol, settings=adf_settings) result = job.run() # Path to the tape 21 file path_t21 = result._kf.path # Relative path to the CWD relative_path_t21 = '/'.join(path_t21.split('/')[-3:]) # Relative job path relative_plams_path = '/'.join(result.job.path.split('/')[-2:]) adf_result = ADF_Result(adf_settings, mol, result.job.name, relative_path_t21, plams_dir=relative_plams_path, status=job.status) return adf_result
def run(self): """Run the calculation Raises: ValueError: [description] Returns: np.ndarray -- molecular orbital matrix """ wd = ''.join(self.atoms) + '_' + self.basis_name t21_name = wd + '.t21' plams_wd = './plams_workdir' t21_path = os.path.join(plams_wd, os.path.join(wd, t21_name)) if os.path.isfile(t21_name): print('Reusing previous calculation from ', t21_name) kf = plams.KFFile(t21_name) e = kf.read('Total Energy', 'Total energy') else: # init PLAMS plams.init() plams.config.log.stdout = -1 plams.config.erase_workdir = True # create the molecule mol = plams.Molecule() for at, xyz in zip(self.atoms, self.atom_coords): mol.add_atom(plams.Atom(symbol=at, coords=tuple(xyz))) # settings in PLAMS sett = plams.Settings() sett.input.basis.type = self.basis_name.upper() sett.input.basis.core = 'None' sett.input.symmetry = 'nosym' sett.input.XC.HartreeFock = '' # correct unit if self.units == 'angs': sett.input.units.length = 'Angstrom' elif self.units == 'bohr': sett.input.units.length = 'Bohr' # total energy sett.input.totalenergy = True # run the ADF job job = plams.ADFJob(molecule=mol, settings=sett, name=wd) job.run() # read the energy from the t21 file e = job.results.readkf('Total Energy', 'Total energy') # make a copy of the t21 file shutil.copyfile(t21_path, t21_name) shutil.rmtree(plams_wd) # print energy print('== SCF Energy : ', e) self.out_file = t21_name
print("max_norm", max_norm) print("scaling", scaling) # Creates two structures with + and - displacements mol_plus = mol.copy() for at, i in zip(mol_plus, vec): at.translate(i * scaling) mol_less = mol.copy() for at, i in zip(mol_less, vec): at.translate(-i * scaling) # Run the jobs with + displaced geometries adf_job = plams.ADFJob(name='grad+_' + str(mode), molecule=mol_plus, settings=adf_grads()) jobres = adf_job.run() # Retrieve the gradients and dipoles grad_plus = np.asarray(jobres.readkf('GeoOpt', 'Gradients_InputOrder')) pol_plus = np.asarray(jobres.readkf('Properties', 'Polarizability')) # Run the jobs with - displaced geometries adf_job = plams.ADFJob(name='grad-_' + str(mode), molecule=mol_less, settings=adf_grads()) jobres = adf_job.run() # Retrieve the gradients and dipoles grad_less = np.asarray(jobres.readkf('GeoOpt', 'Gradients_InputOrder')) pol_less = np.asarray(jobres.readkf('Properties', 'Polarizability'))