diff --git a/src/mindlessgen/molecules/molecule.py b/src/mindlessgen/molecules/molecule.py index e497962..1feb89f 100644 --- a/src/mindlessgen/molecules/molecule.py +++ b/src/mindlessgen/molecules/molecule.py @@ -519,11 +519,11 @@ def write_xyz_to_file(self, filename: str | Path | None = None): with open(filename, "w", encoding="utf8") as f: f.write(self.get_xyz_str()) # if the charge is set, write it to a '.CHRG' file - if self._charge is not None: + if self._charge is not None and self._charge != 0: with open(filename.with_suffix(".CHRG"), "w", encoding="utf8") as f: f.write(f"{self.charge}\n") # if the UHF is set, write it to a '.UHF' file - if self._uhf is not None: + if self._uhf is not None and self._uhf > 0: with open(filename.with_suffix(".UHF"), "w", encoding="utf8") as f: f.write(f"{self.uhf}\n")