From 6bb74eaa5491cd7c4b67abdd1a9da9e4fb83491f Mon Sep 17 00:00:00 2001 From: Marcel Mueller Date: Thu, 17 Oct 2024 16:55:18 +0200 Subject: [PATCH] Bunch of technical fixes (#65) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix AutoAUX for Z>86; note regarding basis set choice; missing init entry and linting correction Signed-off-by: Marcel Müller * fix typo Signed-off-by: Marcel Müller --------- Signed-off-by: Marcel Müller --- README.md | 5 +++++ src/mindlessgen/molecules/__init__.py | 2 ++ src/mindlessgen/molecules/molecule.py | 4 +++- src/mindlessgen/qm/orca.py | 3 +++ src/mindlessgen/qm/xtb.py | 8 ++++---- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 307ca17..871d9d2 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,11 @@ There are two related aspects of the element composition: - **Example 1**: `C:1-3, O:1-1, H:1-*` would result in a molecule with 1, 2, or 3 carbon atoms, exactly 1 oxygen atom, and between 1 and an undefined number of hydrogen atoms (i.e., at least 1). - **Example 2**: `Na:10-10, In:10-10, O:20-20`. This example would result in a molecule with exactly 10 sodium atoms, 10 indium atoms, and 20 oxygen atoms. **For a fixed element composition, the number of atoms (40) has to be within the min_num_atoms and max_num_atom interval.** `mindlessgen` will consequently always return a molecule with exactly 40 atoms. +> [!WARNING] +> When using `orca` and specifying elements with `Z > 86`, ensure that the basis set you've selected is compatible with (super-)heavy elements like actinides. +> You can find a list of available basis sets [here](https://www.faccts.de/docs/orca/6.0/manual/contents/detailed/basisset.html#built-in-basis-sets). +> A reliable standard choice that covers the entire periodic table is `def2-mTZVPP`. + ## Citation When using the program for academic purposes, please cite: diff --git a/src/mindlessgen/molecules/__init__.py b/src/mindlessgen/molecules/__init__.py index bed692b..fabdeb8 100644 --- a/src/mindlessgen/molecules/__init__.py +++ b/src/mindlessgen/molecules/__init__.py @@ -17,6 +17,7 @@ get_four_d_metals, get_five_d_metals, get_lanthanides, + get_actinides, get_alkali_metals, get_alkaline_earth_metals, ) @@ -34,6 +35,7 @@ "get_four_d_metals", "get_five_d_metals", "get_lanthanides", + "get_actinides", "get_alkali_metals", "get_alkaline_earth_metals", "PSE_NUMBERS", diff --git a/src/mindlessgen/molecules/molecule.py b/src/mindlessgen/molecules/molecule.py index 33986f8..ed63fa0 100644 --- a/src/mindlessgen/molecules/molecule.py +++ b/src/mindlessgen/molecules/molecule.py @@ -246,8 +246,10 @@ def read_mol_from_file(file: str | Path) -> Molecule: molecule = Molecule() if isinstance(file, str): file_path = Path(file).resolve() - if isinstance(file, Path): + elif isinstance(file, Path): file_path = file.resolve() + else: + raise TypeError("String or Path expected.") molecule.read_xyz_from_file(file_path) if file_path.with_suffix(".CHRG").exists(): molecule.read_charge_from_file(file_path.with_suffix(".CHRG")) diff --git a/src/mindlessgen/qm/orca.py b/src/mindlessgen/qm/orca.py index b8665c4..3225335 100644 --- a/src/mindlessgen/qm/orca.py +++ b/src/mindlessgen/qm/orca.py @@ -165,6 +165,9 @@ def _gen_input( orca_input = f"! {self.cfg.functional} {self.cfg.basis}\n" orca_input += f"! DEFGRID{self.cfg.gridsize}\n" orca_input += "! NoTRAH NoSOSCF SlowConv\n" + # "! AutoAux" keyword for super-heavy elements as def2/J ends at Rn + if any(atom >= 86 for atom in molecule.ati): + orca_input += "! AutoAux\n" if optimization: orca_input += "! OPT\n" if opt_cycles is not None: diff --git a/src/mindlessgen/qm/xtb.py b/src/mindlessgen/qm/xtb.py index f80d2be..ecd238f 100644 --- a/src/mindlessgen/qm/xtb.py +++ b/src/mindlessgen/qm/xtb.py @@ -205,12 +205,12 @@ def _run(self, temp_path: Path, arguments: list[str]) -> tuple[str, str, int]: check=True, ) # get the output of the xtb calculation (of both stdout and stderr) - xtb_log_out = xtb_out.stdout.decode("utf8") - xtb_log_err = xtb_out.stderr.decode("utf8") + xtb_log_out = xtb_out.stdout.decode("utf8", errors="replace") + xtb_log_err = xtb_out.stderr.decode("utf8", errors="replace") return xtb_log_out, xtb_log_err, 0 except sp.CalledProcessError as e: - xtb_log_out = e.stdout.decode("utf8") - xtb_log_err = e.stderr.decode("utf8") + xtb_log_out = e.stdout.decode("utf8", errors="replace") + xtb_log_err = e.stderr.decode("utf8", errors="replace") return xtb_log_out, xtb_log_err, e.returncode