def get_version(self) -> str: self.found(raise_error=True) # Get the node configuration config = get_config() # Run NWChem which_prog = which("nwchem") if config.use_mpiexec: command = create_mpi_invocation(which_prog, config) else: command = [which_prog] command.append("v.nw") if which_prog not in self.version_cache: success, output = execute(command, {"v.nw": ""}, scratch_directory=config.scratch_directory) if success: for line in output["stdout"].splitlines(): if "nwchem branch" in line: branch = line.strip().split()[-1] if "nwchem revision" in line: revision = line.strip().split()[-1] self.version_cache[which_prog] = safe_version(branch + "+" + revision) else: raise UnknownError(output["stderr"]) return self.version_cache[which_prog]
def get_version(self) -> str: self.found(raise_error=True) # Get the node configuration config = get_config() # Run MADNESS which_prog = which("moldft") if config.use_mpiexec: command = create_mpi_invocation(which_prog, config) else: command = [which_prog] command.append("v.moldft") if which_prog not in self.version_cache: success, output = execute( command, { "v.moldft": "dft\nxc lda\nend\ngeometry\nBe 0.0 0.0 0.0\n\nend\n" }, scratch_directory=config.scratch_directory, ) if success: for line in output["stdout"].splitlines(): if "multiresolution suite" in line: version = line.strip().split()[1] self.version_cache[which_prog] = safe_version(version) else: raise UnknownError(output["stderr"]) return self.version_cache[which_prog]
def test_gaussian_solvent_template(tmpdir, water): """ Make sure that the template rendered with solvent settings matches what we expect. """ with tmpdir.as_cwd(): # get the charge method and implicit solvent engine charge_engine = DDECCharges() solvent_settings = charge_engine._get_calculation_settings() # now make an atomic input for the harness task = AtomicInput( molecule=water.to_qcschema(), driver="energy", model={ "method": "b3lyp-d3bj", "basis": "6-311G" }, keywords=solvent_settings, ) # we need the harness as this will render the template gaussian_harness = GaussianHarness() config = get_config(task_config={"ncores": 1, "memory": 1}) job_inputs = gaussian_harness.build_input(task, config) # make sure the job file matches or expected reference with open(get_data("gaussian_solvent_example.com")) as g_out: assert g_out.read() == job_inputs["infiles"]["gaussian.com"]
def get_version(self) -> str: # excuse missing Q-Chem for QCEngineRecords tests found = self.found() if not found: return safe_version("0.0.0") self.found(raise_error=True) # Get the node configuration config = get_config() which_prog = which("qchem") if which_prog not in self.version_cache: success, exc = execute( [which_prog, "v.in"], {"v.in": "$rem\n"}, scratch_directory=config.scratch_directory, environment=self._get_qc_path(), timeout=15, ) mobj = re.search(r"Q-Chem\s+([\d.]+)\s+for", exc["stdout"]) if not mobj: mobj = re.search(r"Q-Chem version:\s+([\d.]+)\s+", exc["stdout"]) if mobj: self.version_cache[which_prog] = safe_version(mobj.group(1)) # if "QC not defined" in exc["stdout"]: else: return safe_version("0.0.0") return self.version_cache[which_prog]
def test_gaussian_no_solvent_template(tmpdir, water): """ Make sure that we can calculate the electron density with no implicit solvent. """ with tmpdir.as_cwd(): # get the charge method and implicit solvent engine charge_engine = DDECCharges(solvent_settings=None) settings = charge_engine._get_calculation_settings() task = AtomicInput( molecule=water.to_qcschema(), driver="energy", model={ "method": "b3lyp-d3bj", "basis": "6-311G" }, keywords=settings, ) # we need the harness as this will render the template gaussian_harness = GaussianHarness() config = get_config(task_config={"ncores": 1, "memory": 1}) job_inputs = gaussian_harness.build_input(task, config) with open(get_data("gaussian_gas_example.com")) as g_out: assert g_out.read() == job_inputs["infiles"]["gaussian.com"]
def psi4(input_data): """ Runs Psi4 in API mode """ # Insert API path if needed psiapi = config.get_config("psi_path") if (psiapi is not None) and (psiapi not in sys.path): sys.path.insert(1, psiapi) try: import psi4 except ImportError: raise ImportError("Could not find Psi4 in the Python path.") # Setup the job input_data["nthreads"] = config.get_config("nthreads_per_job") input_data["memory"] = int( config.get_config("memory_per_job") * 1024 * 1024 * 1024 * 0.95) input_data["success"] = False scratch = config.get_config("scratch_directory") if scratch is not None: input_data["scratch_location"] = scratch psi_version = _parse_psi_version(psi4.__version__) if psi_version > parse_version("1.2rc2.dev500"): # Handle slight RC2 weirdness psi_12rc2_tweak = (psi_version == parse_version("1.2rc2")) psi_12rc2_tweak &= psi4.metadata.version_formatter("") != '(inplace)' if psi_12rc2_tweak: input_data["schema_name"] = "QC_JSON" input_data["schema_version"] = 0 psi4.set_num_threads(input_data["nthreads"], quiet=True) mol = psi4.core.Molecule.from_schema(input_data) if mol.multiplicity() != 1: input_data["keywords"]["reference"] = "uks" output_data = psi4.json_wrapper.run_json(input_data) # Handle slight RC2 weirdness once more if psi_12rc2_tweak: output_data["schema_name"] = "qc_schema_output" output_data["schema_version"] = 1 else: raise TypeError("Psi4 version '{}' not understood".format(psi_version)) # Dispatch errors, PSIO Errors are not recoverable for future runs if output_data["success"] is False: if "PSIO Error" in output_data["error"]: raise ValueError(output_data["error"]) # Move several pieces up a level if output_data["success"]: output_data["provenance"]["memory"] = round( input_data["memory"] / (1024**3), 3) output_data["provenance"]["nthreads"] = input_data["nthreads"] del output_data["memory"], input_data["nthreads"] return output_data