From a1e87b0bfabe67f411d0b6aae48ea9f8b39894d3 Mon Sep 17 00:00:00 2001 From: Marvin Friede <51965259+marvinfriede@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:23:52 -0500 Subject: [PATCH] Add example for challenging SCF convergence (#173) --- .gitignore | 6 ++--- examples/issues/123/coord | 13 +++++++++ examples/issues/123/run.py | 54 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 examples/issues/123/coord create mode 100644 examples/issues/123/run.py diff --git a/.gitignore b/.gitignore index ff179797..1aea78cd 100644 --- a/.gitignore +++ b/.gitignore @@ -208,11 +208,9 @@ data/*/processed* data/misc # exclude some sample and reaction files for tests -!data/GMTKN55/samples_ACONF.json -!data/GMTKN55/reactions_ACONF.json - !test/test_singlepoint/**/coord -!test/test_singlepoint/**/.CHRG +!examples/issues/**/coord +!examples/issues/**/*.xyz !test/test_io/**/*.json !test/test_io/**/coord diff --git a/examples/issues/123/coord b/examples/issues/123/coord new file mode 100644 index 00000000..ef449506 --- /dev/null +++ b/examples/issues/123/coord @@ -0,0 +1,13 @@ +$coord + 0.03579425573719 -0.09112374056391 0.89335307999458 cr + 5.42783204665614 -2.17294661121026 0.65916514368075 o + 3.40375271909106 -1.38928570065300 0.82378719806096 c + -0.04074270812561 -0.17596705876656 -2.57265467283161 c + -0.08912415394703 -0.22969604472894 -4.75994430975133 o + -3.33299931144879 1.20626988769390 0.90894089019304 c + -5.36291624030506 1.98396405987989 0.79581613233819 o + 1.33083886695733 3.27583741049000 0.75516281864174 c + 2.10688687476585 5.29904198098028 0.54889443619263 o + -1.26102459345897 -3.45925462128772 0.97643580779788 c + -2.04398697392212 -5.48898687883367 0.90363185868314 o +$end diff --git a/examples/issues/123/run.py b/examples/issues/123/run.py new file mode 100644 index 00000000..a169692a --- /dev/null +++ b/examples/issues/123/run.py @@ -0,0 +1,54 @@ +# This file is part of dxtb. +# +# SPDX-Identifier: Apache-2.0 +# Copyright (C) 2024 Grimme Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +https://github.com/grimme-lab/dxtb/issues/123 +""" +from __future__ import annotations + +from pathlib import Path + +import torch +from tad_mctc.io import read + +import dxtb + + +def main() -> int: + dd = {"device": torch.device("cpu"), "dtype": torch.double} + dxtb.timer.cuda_sync = False + + # read molecule from file + f = Path(__file__).parent / "coord" + numbers, positions = read.read_from_path(f, **dd) + charge = read.read_chrg_from_path(f, **dd) + + opts = {"verbosity": 6, "scp_mode": dxtb.labels.SCP_MODE_CHARGE} + calc = dxtb.calculators.GFN1Calculator(numbers, opts=opts, **dd) + + ref = -35.800705002354 + energy = calc.get_energy(positions, chrg=charge) + + print("\nComparison to xtb:") + print(f" - xtb (6.7.1) : {ref: .12f}") + print(f" - dxtb (0.1.0): {energy: .12f}") + print(f" - diff : {energy - ref: .12f}") + + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())