Source code for scine_puffin.jobs.templates.turbomole_job
# -*- coding: utf-8 -*-from__future__importannotations__copyright__=""" This code is licensed under the 3-clause BSD license.Copyright ETH Zurich, Department of Chemistry and Applied Biosciences, Reiher Group.See LICENSE.txt for details."""importosimportsubprocessfromtypingimportList,TYPE_CHECKINGfromscine_puffin.configimportConfigurationfromscine_puffin.jobs.templates.jobimportJobfromscine_puffin.utilities.importsimportmodule_exists,requires,MissingDependencyifmodule_exists("scine_database")orTYPE_CHECKING:importscine_databaseasdbelse:db=MissingDependency("scine_database")ifmodule_exists("scine_utilities")orTYPE_CHECKING:importscine_utilitiesasutilselse:utils=MissingDependency("scine_utilities")
[docs]classTurbomoleJob(Job):""" A common interface for all jobs in Puffin that use Turbomole. """def__init__(self)->None:super().__init__()self.input_structure="system.xyz"env=os.environ.copy()self.turboexe=""self.turboscripts=""self.smp_turboexe=""if"TURBODIR"inenv.keys():ifenv["TURBODIR"]:ifos.environ.get("PARA_ARCH")isnotNone:delos.environ["PARA_ARCH"]ifos.path.exists(os.path.join(env["TURBODIR"],"scripts","sysname")):self.sysname=(subprocess.check_output(os.path.join(env["TURBODIR"],"scripts","sysname")).decode("utf-8",errors='replace').rstrip())self.sysname_parallel=self.sysname+"_smp"self.turboexe=os.path.join(env["TURBODIR"],"bin",self.sysname)self.smp_turboexe=os.path.join(env["TURBODIR"],"bin",self.sysname_parallel)self.turboscripts=os.path.join(env["TURBODIR"],"scripts")else:raiseRuntimeError("TURBODIR not assigned correctly. Check spelling or empty the env variable.")
[docs]@requires("utilities")defprepare_calculation(self,structure:db.Structure,calculation_settings:utils.ValueCollection,model:db.Model,job:db.Job)->None:fromscine_puffin.utilities.turbomole_helperimportTurbomoleHelpertm_helper=TurbomoleHelper()# Write xyz fileutils.io.write(self.input_structure,structure.get_atoms())# Write coord filetm_helper.write_coord_file(calculation_settings)# Check if settings are availabletm_helper.check_settings_availability(job,calculation_settings)# Generate input file for preprocessing tool 'define'tm_helper.prepare_define_session(structure,model,calculation_settings,job)# Initialize via definetm_helper.initialize(model,calculation_settings)