Skip to content

Commit

Permalink
Add example for challenging SCF convergence (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinfriede authored Sep 24, 2024
1 parent 9c4af05 commit a1e87b0
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions examples/issues/123/coord
Original file line number Diff line number Diff line change
@@ -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
54 changes: 54 additions & 0 deletions examples/issues/123/run.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit a1e87b0

Please sign in to comment.