From f57023a0827c8313332e44bc4f241fe66cdf2253 Mon Sep 17 00:00:00 2001 From: L-RuiHao <874800796@qq.com> Date: Wed, 26 Jul 2023 16:49:35 +0800 Subject: [PATCH 01/13] new feature DFTB+ --- .../dftbplus.py => dftb_plus/__init__.py} | 0 dpdata/dftb_plus/inout.py | 49 +++++ dpdata/plugins/dftb_plus.py | 33 ++++ tests/dftb_plus/input.out | 186 ++++++++++++++++++ tests/test_dftb_plus.py | 60 ++++++ 5 files changed, 328 insertions(+) rename dpdata/{plugins/dftbplus.py => dftb_plus/__init__.py} (100%) create mode 100644 dpdata/dftb_plus/inout.py create mode 100644 dpdata/plugins/dftb_plus.py create mode 100644 tests/dftb_plus/input.out create mode 100644 tests/test_dftb_plus.py diff --git a/dpdata/plugins/dftbplus.py b/dpdata/dftb_plus/__init__.py similarity index 100% rename from dpdata/plugins/dftbplus.py rename to dpdata/dftb_plus/__init__.py diff --git a/dpdata/dftb_plus/inout.py b/dpdata/dftb_plus/inout.py new file mode 100644 index 000000000..bc51791e2 --- /dev/null +++ b/dpdata/dftb_plus/inout.py @@ -0,0 +1,49 @@ +import numpy as np + +from typing import Tuple + + +def read_dftb_plus(fn: str) -> Tuple[str, np.ndarray, float, np.ndarray]: + with open(fn) as f: + flag = 0 + for line in f: + if flag ==1: + flag +=1 + elif flag == 2: + components = line.split() + flag +=1 + elif line.startswith("Geometry"): + flag = 1 + coord = [] + symbols = [] + elif flag in (3,4,5,6): + s = line.split() + components_num = int(s[1]) + symbols.append(components[components_num-1]) + coord.append([float(s[2]), float(s[3]), float(s[4])]) + flag +=1 + if flag == 7: + flag = 0 + elif line.startswith("Total Forces"): + flag = 8 + forces = [] + elif flag in (8,9,10,11): + s = line.split() + forces.append([float(s[1]), float(s[2]), float(s[3])]) + flag +=1 + if flag == 12: + flag = 0 + elif line.startswith("Total energy:"): + s = line.split() + energy = float(s[2]) + + symbols = np.array(symbols) + forces = -np.array(forces) + coord = np.array(coord) + assert coord.shape == forces.shape + + return symbols, coord, energy, forces + + + + \ No newline at end of file diff --git a/dpdata/plugins/dftb_plus.py b/dpdata/plugins/dftb_plus.py new file mode 100644 index 000000000..58b579a52 --- /dev/null +++ b/dpdata/plugins/dftb_plus.py @@ -0,0 +1,33 @@ +import numpy as np +from dpdata.format import Format +from dpdata.dftb_plus.inout import read_dftb_plus +from dpdata.unit import LengthConversion, EnergyConversion, ForceConversion + + +length_convert = LengthConversion("bohr", "angstrom").value() +energy_convert = EnergyConversion("hartree", "eV").value() +force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value() + + + +@Format.register("dftb_plus") +class DFTBplusFormat(Format): + def from_labeled_system(self, file_name, **kwargs): + symbols, coord, energy, forces = read_dftb_plus(file_name) + last_occurrence = {v: i for i, v in enumerate(symbols)} + atom_names = np.array(sorted(np.unique(symbols), key=last_occurrence.get)) + atom_types = np.array([np.where(atom_names == s)[0][0] for s in symbols]) + atom_numbs = np.array([np.sum(atom_types == i) for i in range(len(atom_names))]) + natoms = coord.shape[0] + + return { + "atom_types": atom_types, + "atom_names": list(atom_names), + "atom_numbs": list(atom_numbs), + "coords": (coord * length_convert).reshape((1, natoms, 3)), + "energies": np.array([energy*energy_convert]), + "forces": (forces * force_convert).reshape((1, natoms, 3)), + "cells": np.zeros((1, 3, 3)), + "orig": np.zeros(3), + "nopbc": True, + } diff --git a/tests/dftb_plus/input.out b/tests/dftb_plus/input.out new file mode 100644 index 000000000..30d5ebf0c --- /dev/null +++ b/tests/dftb_plus/input.out @@ -0,0 +1,186 @@ + ==> Input File <== + +-------------------------------------------------------------------------- +Geometry = GenFormat { +4 C +N H +1 1 1.014150 0.112320 0.047370 +2 2 3.909390 0.037985 -0.101159 +3 2 0.702550 -0.851820 -0.060860 +4 2 0.702550 0.603740 -0.789160 +} +Driver = {} +Hamiltonian = DFTB { + SCC = Yes + MaxAngularMomentum = { + N = "p" + H = "p" + } + SlaterKosterFiles = { + N-N = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/N-N.skf" + H-H = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/H-H.skf" + H-N = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/H-N.skf" + N-H = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/N-H.skf" + } + ThirdOrderFull = Yes + HubbardDerivs = { + H = -0.1857 + N = -0.1535 + } + HCorrection = Damping { + Exponent = 4.0 + } + PolynomialRepulsive = {} + ShellResolvedSCC = No + OldSKInterpolation = No + RangeSeparated = None {} + ReadInitialCharges = No + InitialCharges = {} + SCCTolerance = 1.0000000000000001E-005 + ConvergentSCCOnly = Yes + SpinPolarisation = {} + ElectricField = {} + Solver = RelativelyRobust {} + Charge = 0.0000000000000000 + MaxSCCIterations = 100 + OnSiteCorrection = {} + Dispersion = {} + Solvation = {} + Electrostatics = GammaFunctional {} + ThirdOrder = No + Differentiation = FiniteDiff { + Delta = 1.2207031250000000E-004 + } + ForceEvaluation = "Traditional" + Mixer = Broyden { + MixingParameter = 0.20000000000000001 + InverseJacobiWeight = 1.0000000000000000E-002 + MinimalWeight = 1.0000000000000000 + MaximalWeight = 100000.00000000000 + WeightFactor = 1.0000000000000000E-002 + } + Filling = Fermi { + Temperature = 0.0000000000000000 + } +} +Options = { + WriteDetailedOut = Yes + WriteAutotestTag = No + WriteDetailedXML = No + WriteResultsTag = No + RestartFrequency = 20 + RandomSeed = 0 + WriteHS = No + WriteRealHS = No + MinimiseMemoryUsage = No + ShowFoldedCoords = No + TimingVerbosity = 1 + WriteChargesAsText = No +} +Analysis = { + CalculateForces = Yes + ProjectStates = {} + WriteEigenvectors = No + WriteBandOut = Yes + MullikenAnalysis = Yes + WriteNetCharges = No + AtomResolvedEnergies = No +} +ParserOptions = { + ParserVersion = 11 + WriteHSDInput = Yes + StopAfterParsing = No + IgnoreUnprocessedNodes = No +} +Reks = None {} +ExcitedState = {} + + ==> Output File <== + +-------------------------------------------------------------------------- + Fermi distribution function + +Calculation with static geometry + + +******************************************************************************** + iSCC Total electronic Diff electronic SCC error + 88 -0.33554958E+01 -0.31884693E-07 0.11352275E-06 +******************************************************************************** + + Total charge: -0.00000000 + + Atomic gross charges (e) + Atom Charge + 1 -0.48336965 + 2 0.03575828 + 3 0.22380553 + 4 0.22380583 + +Nr. of electrons (up): 8.00000000 +Atom populations (up) + Atom Population + 1 5.48336965 + 2 0.96424172 + 3 0.77619447 + 4 0.77619417 + +l-shell populations (up) + Atom Sh. l Population + 1 1 0 1.65733979 + 1 2 1 3.82602986 + 2 1 0 0.96424172 + 2 2 1 0.00000000 + 3 1 0 0.77619447 + 3 2 1 0.00000000 + 4 1 0 0.77619417 + 4 2 1 0.00000000 + +Orbital populations (up) + Atom Sh. l m Population Label + 1 1 0 0 1.65733979 s + 1 2 1 -1 1.21678996 p_y + 1 2 1 0 1.46556336 p_z + 1 2 1 1 1.14367654 p_x + 2 1 0 0 0.96424172 s + 2 2 1 -1 0.00000000 p_y + 2 2 1 0 0.00000000 p_z + 2 2 1 1 0.00000000 p_x + 3 1 0 0 0.77619447 s + 3 2 1 -1 0.00000000 p_y + 3 2 1 0 0.00000000 p_z + 3 2 1 1 0.00000000 p_x + 4 1 0 0 0.77619417 s + 4 2 1 -1 0.00000000 p_y + 4 2 1 0 0.00000000 p_z + 4 2 1 1 0.00000000 p_x + +Fermi level: -0.2370222488 H -6.4497 eV +Band energy: -3.2187242078 H -87.5859 eV +TS: 0.0000000000 H 0.0000 eV +Band free energy (E-TS): -3.2187242078 H -87.5859 eV +Extrapolated E(0K): -3.2187242078 H -87.5859 eV +Input / Output electrons (q): 8.0000000000 8.0000000000 + +Energy H0: -3.3599884076 H -91.4299 eV +Energy SCC: 0.0056352830 H 0.1533 eV +Energy 3rd: -0.0011426808 H -0.0311 eV +Total Electronic energy: -3.3554958054 H -91.3077 eV +Repulsive energy: 0.0590974170 H 1.6081 eV +Total energy: -3.2963983884 H -89.6996 eV +Extrapolated to 0: -3.2963983884 H -89.6996 eV +Total Mermin free energy: -3.2963983884 H -89.6996 eV +Force related energy: -3.2963983884 H -89.6996 eV + +SCC converged + +Total Forces + 1 0.016567056203 0.002817951422 0.005634574270 + 2 -0.018803818530 -0.000002880649 -0.000006015442 + 3 0.001118562874 -0.005291070259 -0.000870711110 + 4 0.001118199454 0.002475999486 -0.004757847718 + +Maximal derivative component: 0.188038E-01 au + +Dipole moment: -0.06792979 -0.20495079 -0.40960550 au +Dipole moment: -0.17266032 -0.52093298 -1.04111341 Debye diff --git a/tests/test_dftb_plus.py b/tests/test_dftb_plus.py new file mode 100644 index 000000000..034f8e794 --- /dev/null +++ b/tests/test_dftb_plus.py @@ -0,0 +1,60 @@ +import unittest + +import numpy as np +from comp_sys import CompLabeledSys, IsNoPBC +from context import dpdata + +class TestDeepmdLoadAmmonia(unittest.TestCase, CompLabeledSys, IsNoPBC): + def setUp(self): + length_convert = dpdata.unit.LengthConversion("bohr", "angstrom").value() + energy_convert = dpdata.unit.EnergyConversion("hartree", "eV").value() + force_convert = dpdata.unit.ForceConversion( + "hartree/bohr", "eV/angstrom" + ).value() + + self.system_1 = dpdata.LabeledSystem("dftb_plus/input.out", fmt="dftb_plus") + + + self.system_2 = dpdata.LabeledSystem( + data={ + "atom_types": np.array([0, 1, 1, 1]), + "atom_names": ["N", "H"], + "atom_numbs": [1, 3], + "coords": np.array( + [ + [ + [1.014150, 0.112320 , 0.047370], + [3.909390, 0.037985, -0.101159], + [0.702550, -0.851820, -0.060860], + [0.702550, 0.603740 , -0.789160], + ] + ] + ) + * length_convert, + "energies": np.array([-3.2963983884]) * energy_convert, + "forces": -np.array( + [ + [ + [0.016567056203, 0.002817951422, 0.005634574270], + [-0.018803818530, -0.000002880649, -0.000006015442], + [0.001118562874, -0.005291070259, -0.000870711110], + [0.001118199454 , 0.002475999486, -0.004757847718] + ] + ] + ) + * force_convert, + "cells": np.zeros((1, 3, 3)), + "orig": np.zeros(3), + "nopbc": True, + } + ) + self.places = 6 + self.e_places = 6 + self.f_places = 6 + self.v_places = 6 + + +if __name__ == "__main__": + unittest.main() + + From e68207f738361f3712b7d38ca9f83def941f892e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 26 Jul 2023 08:53:12 +0000 Subject: [PATCH 02/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpdata/dftb_plus/inout.py | 44 +++++++++++++++++-------------------- dpdata/plugins/dftb_plus.py | 9 ++++---- tests/test_dftb_plus.py | 12 +++++----- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/dpdata/dftb_plus/inout.py b/dpdata/dftb_plus/inout.py index bc51791e2..0d72ba4f1 100644 --- a/dpdata/dftb_plus/inout.py +++ b/dpdata/dftb_plus/inout.py @@ -1,49 +1,45 @@ -import numpy as np - from typing import Tuple +import numpy as np + -def read_dftb_plus(fn: str) -> Tuple[str, np.ndarray, float, np.ndarray]: +def read_dftb_plus(fn: str) -> Tuple[str, np.ndarray, float, np.ndarray]: with open(fn) as f: flag = 0 for line in f: - if flag ==1: - flag +=1 + if flag == 1: + flag += 1 elif flag == 2: - components = line.split() - flag +=1 + components = line.split() + flag += 1 elif line.startswith("Geometry"): flag = 1 coord = [] - symbols = [] - elif flag in (3,4,5,6): - s = line.split() - components_num = int(s[1]) - symbols.append(components[components_num-1]) + symbols = [] + elif flag in (3, 4, 5, 6): + s = line.split() + components_num = int(s[1]) + symbols.append(components[components_num - 1]) coord.append([float(s[2]), float(s[3]), float(s[4])]) - flag +=1 + flag += 1 if flag == 7: - flag = 0 + flag = 0 elif line.startswith("Total Forces"): flag = 8 forces = [] - elif flag in (8,9,10,11): - s = line.split() + elif flag in (8, 9, 10, 11): + s = line.split() forces.append([float(s[1]), float(s[2]), float(s[3])]) - flag +=1 + flag += 1 if flag == 12: - flag = 0 + flag = 0 elif line.startswith("Total energy:"): - s = line.split() + s = line.split() energy = float(s[2]) - + symbols = np.array(symbols) forces = -np.array(forces) coord = np.array(coord) assert coord.shape == forces.shape return symbols, coord, energy, forces - - - - \ No newline at end of file diff --git a/dpdata/plugins/dftb_plus.py b/dpdata/plugins/dftb_plus.py index 58b579a52..3f41d850f 100644 --- a/dpdata/plugins/dftb_plus.py +++ b/dpdata/plugins/dftb_plus.py @@ -1,15 +1,14 @@ import numpy as np -from dpdata.format import Format -from dpdata.dftb_plus.inout import read_dftb_plus -from dpdata.unit import LengthConversion, EnergyConversion, ForceConversion +from dpdata.dftb_plus.inout import read_dftb_plus +from dpdata.format import Format +from dpdata.unit import EnergyConversion, ForceConversion, LengthConversion length_convert = LengthConversion("bohr", "angstrom").value() energy_convert = EnergyConversion("hartree", "eV").value() force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value() - @Format.register("dftb_plus") class DFTBplusFormat(Format): def from_labeled_system(self, file_name, **kwargs): @@ -25,7 +24,7 @@ def from_labeled_system(self, file_name, **kwargs): "atom_names": list(atom_names), "atom_numbs": list(atom_numbs), "coords": (coord * length_convert).reshape((1, natoms, 3)), - "energies": np.array([energy*energy_convert]), + "energies": np.array([energy * energy_convert]), "forces": (forces * force_convert).reshape((1, natoms, 3)), "cells": np.zeros((1, 3, 3)), "orig": np.zeros(3), diff --git a/tests/test_dftb_plus.py b/tests/test_dftb_plus.py index 034f8e794..31eced9e2 100644 --- a/tests/test_dftb_plus.py +++ b/tests/test_dftb_plus.py @@ -4,6 +4,7 @@ from comp_sys import CompLabeledSys, IsNoPBC from context import dpdata + class TestDeepmdLoadAmmonia(unittest.TestCase, CompLabeledSys, IsNoPBC): def setUp(self): length_convert = dpdata.unit.LengthConversion("bohr", "angstrom").value() @@ -13,7 +14,6 @@ def setUp(self): ).value() self.system_1 = dpdata.LabeledSystem("dftb_plus/input.out", fmt="dftb_plus") - self.system_2 = dpdata.LabeledSystem( data={ @@ -23,10 +23,10 @@ def setUp(self): "coords": np.array( [ [ - [1.014150, 0.112320 , 0.047370], + [1.014150, 0.112320, 0.047370], [3.909390, 0.037985, -0.101159], [0.702550, -0.851820, -0.060860], - [0.702550, 0.603740 , -0.789160], + [0.702550, 0.603740, -0.789160], ] ] ) @@ -35,10 +35,10 @@ def setUp(self): "forces": -np.array( [ [ - [0.016567056203, 0.002817951422, 0.005634574270], + [0.016567056203, 0.002817951422, 0.005634574270], [-0.018803818530, -0.000002880649, -0.000006015442], [0.001118562874, -0.005291070259, -0.000870711110], - [0.001118199454 , 0.002475999486, -0.004757847718] + [0.001118199454, 0.002475999486, -0.004757847718], ] ] ) @@ -56,5 +56,3 @@ def setUp(self): if __name__ == "__main__": unittest.main() - - From aa2500ebc3d326e09e94e9c0913cf785feece287 Mon Sep 17 00:00:00 2001 From: L-RuiHao <874800796@qq.com> Date: Mon, 31 Jul 2023 10:35:19 +0800 Subject: [PATCH 03/13] Modified DFTB+ --- tests/dftb_plus/{input.out => detailed.out} | 102 +------------------- tests/dftb_plus/dftb_pin.hsd | 93 ++++++++++++++++++ tests/test_amber_sqm.py | 3 + tests/test_dftb_plus.py | 5 +- 4 files changed, 101 insertions(+), 102 deletions(-) rename tests/dftb_plus/{input.out => detailed.out} (56%) create mode 100644 tests/dftb_plus/dftb_pin.hsd diff --git a/tests/dftb_plus/input.out b/tests/dftb_plus/detailed.out similarity index 56% rename from tests/dftb_plus/input.out rename to tests/dftb_plus/detailed.out index 30d5ebf0c..21fe93fc5 100644 --- a/tests/dftb_plus/input.out +++ b/tests/dftb_plus/detailed.out @@ -1,103 +1,3 @@ - ==> Input File <== - --------------------------------------------------------------------------- -Geometry = GenFormat { -4 C -N H -1 1 1.014150 0.112320 0.047370 -2 2 3.909390 0.037985 -0.101159 -3 2 0.702550 -0.851820 -0.060860 -4 2 0.702550 0.603740 -0.789160 -} -Driver = {} -Hamiltonian = DFTB { - SCC = Yes - MaxAngularMomentum = { - N = "p" - H = "p" - } - SlaterKosterFiles = { - N-N = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/N-N.skf" - H-H = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/H-H.skf" - H-N = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/H-N.skf" - N-H = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/N-H.skf" - } - ThirdOrderFull = Yes - HubbardDerivs = { - H = -0.1857 - N = -0.1535 - } - HCorrection = Damping { - Exponent = 4.0 - } - PolynomialRepulsive = {} - ShellResolvedSCC = No - OldSKInterpolation = No - RangeSeparated = None {} - ReadInitialCharges = No - InitialCharges = {} - SCCTolerance = 1.0000000000000001E-005 - ConvergentSCCOnly = Yes - SpinPolarisation = {} - ElectricField = {} - Solver = RelativelyRobust {} - Charge = 0.0000000000000000 - MaxSCCIterations = 100 - OnSiteCorrection = {} - Dispersion = {} - Solvation = {} - Electrostatics = GammaFunctional {} - ThirdOrder = No - Differentiation = FiniteDiff { - Delta = 1.2207031250000000E-004 - } - ForceEvaluation = "Traditional" - Mixer = Broyden { - MixingParameter = 0.20000000000000001 - InverseJacobiWeight = 1.0000000000000000E-002 - MinimalWeight = 1.0000000000000000 - MaximalWeight = 100000.00000000000 - WeightFactor = 1.0000000000000000E-002 - } - Filling = Fermi { - Temperature = 0.0000000000000000 - } -} -Options = { - WriteDetailedOut = Yes - WriteAutotestTag = No - WriteDetailedXML = No - WriteResultsTag = No - RestartFrequency = 20 - RandomSeed = 0 - WriteHS = No - WriteRealHS = No - MinimiseMemoryUsage = No - ShowFoldedCoords = No - TimingVerbosity = 1 - WriteChargesAsText = No -} -Analysis = { - CalculateForces = Yes - ProjectStates = {} - WriteEigenvectors = No - WriteBandOut = Yes - MullikenAnalysis = Yes - WriteNetCharges = No - AtomResolvedEnergies = No -} -ParserOptions = { - ParserVersion = 11 - WriteHSDInput = Yes - StopAfterParsing = No - IgnoreUnprocessedNodes = No -} -Reks = None {} -ExcitedState = {} - - ==> Output File <== - --------------------------------------------------------------------------- Fermi distribution function Calculation with static geometry @@ -184,3 +84,5 @@ Maximal derivative component: 0.188038E-01 au Dipole moment: -0.06792979 -0.20495079 -0.40960550 au Dipole moment: -0.17266032 -0.52093298 -1.04111341 Debye + + diff --git a/tests/dftb_plus/dftb_pin.hsd b/tests/dftb_plus/dftb_pin.hsd new file mode 100644 index 000000000..02e0ed228 --- /dev/null +++ b/tests/dftb_plus/dftb_pin.hsd @@ -0,0 +1,93 @@ +Geometry = GenFormat { +4 C +N H +1 1 1.014150 0.112320 0.047370 +2 2 3.909390 0.037985 -0.101159 +3 2 0.702550 -0.851820 -0.060860 +4 2 0.702550 0.603740 -0.789160 +} +Driver = {} +Hamiltonian = DFTB { + SCC = Yes + MaxAngularMomentum = { + N = "p" + H = "p" + } + SlaterKosterFiles = { + N-N = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/N-N.skf" + H-H = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/H-H.skf" + H-N = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/H-N.skf" + N-H = "/home/jz748/devel/git/Programs/Amber18/dat/slko/3ob-3-1/N-H.skf" + } + ThirdOrderFull = Yes + HubbardDerivs = { + H = -0.1857 + N = -0.1535 + } + HCorrection = Damping { + Exponent = 4.0 + } + PolynomialRepulsive = {} + ShellResolvedSCC = No + OldSKInterpolation = No + RangeSeparated = None {} + ReadInitialCharges = No + InitialCharges = {} + SCCTolerance = 1.0000000000000001E-005 + ConvergentSCCOnly = Yes + SpinPolarisation = {} + ElectricField = {} + Solver = RelativelyRobust {} + Charge = 0.0000000000000000 + MaxSCCIterations = 100 + OnSiteCorrection = {} + Dispersion = {} + Solvation = {} + Electrostatics = GammaFunctional {} + ThirdOrder = No + Differentiation = FiniteDiff { + Delta = 1.2207031250000000E-004 + } + ForceEvaluation = "Traditional" + Mixer = Broyden { + MixingParameter = 0.20000000000000001 + InverseJacobiWeight = 1.0000000000000000E-002 + MinimalWeight = 1.0000000000000000 + MaximalWeight = 100000.00000000000 + WeightFactor = 1.0000000000000000E-002 + } + Filling = Fermi { + Temperature = 0.0000000000000000 + } +} +Options = { + WriteDetailedOut = Yes + WriteAutotestTag = No + WriteDetailedXML = No + WriteResultsTag = No + RestartFrequency = 20 + RandomSeed = 0 + WriteHS = No + WriteRealHS = No + MinimiseMemoryUsage = No + ShowFoldedCoords = No + TimingVerbosity = 1 + WriteChargesAsText = No +} +Analysis = { + CalculateForces = Yes + ProjectStates = {} + WriteEigenvectors = No + WriteBandOut = Yes + MullikenAnalysis = Yes + WriteNetCharges = No + AtomResolvedEnergies = No +} +ParserOptions = { + ParserVersion = 11 + WriteHSDInput = Yes + StopAfterParsing = No + IgnoreUnprocessedNodes = No +} +Reks = None {} +ExcitedState = {} diff --git a/tests/test_amber_sqm.py b/tests/test_amber_sqm.py index 7f14ff84c..81f5d3682 100644 --- a/tests/test_amber_sqm.py +++ b/tests/test_amber_sqm.py @@ -79,3 +79,6 @@ def test_sqm_in(self): def tearDown(self): if os.path.isfile("amber/sqm_test.in"): os.remove("amber/sqm_test.in") + +#print(dpdata.LabeledSystem("amber/sqm_forces.out", fmt="sqm/out")) +print(dpdata.LabeledSystem("amber/sqm.in", fmt="sqm/in")) \ No newline at end of file diff --git a/tests/test_dftb_plus.py b/tests/test_dftb_plus.py index 31eced9e2..c6f3aef71 100644 --- a/tests/test_dftb_plus.py +++ b/tests/test_dftb_plus.py @@ -13,7 +13,8 @@ def setUp(self): "hartree/bohr", "eV/angstrom" ).value() - self.system_1 = dpdata.LabeledSystem("dftb_plus/input.out", fmt="dftb_plus") + self.system_1 = dpdata.LabeledSystem(("dftb_plus/dftb_pin.hsd",'dftb_plus/detailed.out'), fmt="dftb_plus") + self.system_2 = dpdata.LabeledSystem( data={ @@ -32,7 +33,7 @@ def setUp(self): ) * length_convert, "energies": np.array([-3.2963983884]) * energy_convert, - "forces": -np.array( + "forces": np.array( [ [ [0.016567056203, 0.002817951422, 0.005634574270], From 943dcfb95359499cd9f32069073037cbf0468b66 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 02:39:28 +0000 Subject: [PATCH 04/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_amber_sqm.py | 5 +++-- tests/test_dftb_plus.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_amber_sqm.py b/tests/test_amber_sqm.py index 81f5d3682..b355e65ef 100644 --- a/tests/test_amber_sqm.py +++ b/tests/test_amber_sqm.py @@ -80,5 +80,6 @@ def tearDown(self): if os.path.isfile("amber/sqm_test.in"): os.remove("amber/sqm_test.in") -#print(dpdata.LabeledSystem("amber/sqm_forces.out", fmt="sqm/out")) -print(dpdata.LabeledSystem("amber/sqm.in", fmt="sqm/in")) \ No newline at end of file + +# print(dpdata.LabeledSystem("amber/sqm_forces.out", fmt="sqm/out")) +print(dpdata.LabeledSystem("amber/sqm.in", fmt="sqm/in")) diff --git a/tests/test_dftb_plus.py b/tests/test_dftb_plus.py index c6f3aef71..eed269ec8 100644 --- a/tests/test_dftb_plus.py +++ b/tests/test_dftb_plus.py @@ -13,8 +13,9 @@ def setUp(self): "hartree/bohr", "eV/angstrom" ).value() - self.system_1 = dpdata.LabeledSystem(("dftb_plus/dftb_pin.hsd",'dftb_plus/detailed.out'), fmt="dftb_plus") - + self.system_1 = dpdata.LabeledSystem( + ("dftb_plus/dftb_pin.hsd", "dftb_plus/detailed.out"), fmt="dftb_plus" + ) self.system_2 = dpdata.LabeledSystem( data={ From 23ec004b09d0dbecc61dbecca85833b83af78e70 Mon Sep 17 00:00:00 2001 From: L-RuiHao <874800796@qq.com> Date: Mon, 31 Jul 2023 11:01:36 +0800 Subject: [PATCH 05/13] Modified DFTB+ --- tests/test_amber_sqm.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_amber_sqm.py b/tests/test_amber_sqm.py index 81f5d3682..0df83bde2 100644 --- a/tests/test_amber_sqm.py +++ b/tests/test_amber_sqm.py @@ -80,5 +80,3 @@ def tearDown(self): if os.path.isfile("amber/sqm_test.in"): os.remove("amber/sqm_test.in") -#print(dpdata.LabeledSystem("amber/sqm_forces.out", fmt="sqm/out")) -print(dpdata.LabeledSystem("amber/sqm.in", fmt="sqm/in")) \ No newline at end of file From 22bc851f8f982e997af8ae966927ebd030c7829c Mon Sep 17 00:00:00 2001 From: L-RuiHao <874800796@qq.com> Date: Mon, 31 Jul 2023 11:37:10 +0800 Subject: [PATCH 06/13] New Modification --- dpdata/dftb_plus/inout.py | 45 --------------------- dpdata/dftb_plus/output.py | 80 +++++++++++++++++++++++++++++++++++++ dpdata/plugins/dftb_plus.py | 12 ++++-- 3 files changed, 89 insertions(+), 48 deletions(-) delete mode 100644 dpdata/dftb_plus/inout.py create mode 100644 dpdata/dftb_plus/output.py diff --git a/dpdata/dftb_plus/inout.py b/dpdata/dftb_plus/inout.py deleted file mode 100644 index 0d72ba4f1..000000000 --- a/dpdata/dftb_plus/inout.py +++ /dev/null @@ -1,45 +0,0 @@ -from typing import Tuple - -import numpy as np - - -def read_dftb_plus(fn: str) -> Tuple[str, np.ndarray, float, np.ndarray]: - with open(fn) as f: - flag = 0 - for line in f: - if flag == 1: - flag += 1 - elif flag == 2: - components = line.split() - flag += 1 - elif line.startswith("Geometry"): - flag = 1 - coord = [] - symbols = [] - elif flag in (3, 4, 5, 6): - s = line.split() - components_num = int(s[1]) - symbols.append(components[components_num - 1]) - coord.append([float(s[2]), float(s[3]), float(s[4])]) - flag += 1 - if flag == 7: - flag = 0 - elif line.startswith("Total Forces"): - flag = 8 - forces = [] - elif flag in (8, 9, 10, 11): - s = line.split() - forces.append([float(s[1]), float(s[2]), float(s[3])]) - flag += 1 - if flag == 12: - flag = 0 - elif line.startswith("Total energy:"): - s = line.split() - energy = float(s[2]) - - symbols = np.array(symbols) - forces = -np.array(forces) - coord = np.array(coord) - assert coord.shape == forces.shape - - return symbols, coord, energy, forces diff --git a/dpdata/dftb_plus/output.py b/dpdata/dftb_plus/output.py new file mode 100644 index 000000000..6bb31d68a --- /dev/null +++ b/dpdata/dftb_plus/output.py @@ -0,0 +1,80 @@ +import numpy as np + +from typing import Tuple +import os + +def read_dftb_plus(fn_1: str, fn_2: str) -> Tuple[str, np.ndarray, float, np.ndarray]: + """Read from DFTB+ input and output. + + Parameters + ---------- + fn_1 : str + DFTB+ input file name + fn_2 : str + DFTB+ output file name + + Returns + ------- + str + atomic symbols + np.ndarray + atomic coordinates + float + total potential energy + np.ndarray + atomic forces + + + """ + coord = None + symbols = None + forces = None + energy = None + with open(fn_1) as f: + flag = 0 + for line in f: + if flag ==1: + flag +=1 + elif flag == 2: + components = line.split() + flag +=1 + elif line.startswith("Geometry"): + flag = 1 + coord = [] + symbols = [] + elif flag in (3,4,5,6): + s = line.split() + components_num = int(s[1]) + symbols.append(components[components_num-1]) + coord.append([float(s[2]), float(s[3]), float(s[4])]) + flag +=1 + if flag == 7: + flag = 0 + with open(fn_2) as f: + flag = 0 + for line in f: + if line.startswith("Total Forces"): + flag = 8 + forces = [] + elif flag in (8,9,10,11): + s = line.split() + forces.append([float(s[1]), float(s[2]), float(s[3])]) + flag +=1 + if flag == 12: + flag = 0 + elif line.startswith("Total energy:"): + s = line.split() + energy = float(s[2]) + flag = 0 + + symbols = np.array(symbols) + forces = np.array(forces) + coord = np.array(coord) + assert coord.shape == forces.shape + + return symbols, coord, energy, forces + + + + + \ No newline at end of file diff --git a/dpdata/plugins/dftb_plus.py b/dpdata/plugins/dftb_plus.py index 3f41d850f..a3d28c3a7 100644 --- a/dpdata/plugins/dftb_plus.py +++ b/dpdata/plugins/dftb_plus.py @@ -1,6 +1,6 @@ import numpy as np -from dpdata.dftb_plus.inout import read_dftb_plus +from dpdata.dftb_plus.output import read_dftb_plus from dpdata.format import Format from dpdata.unit import EnergyConversion, ForceConversion, LengthConversion @@ -11,8 +11,9 @@ @Format.register("dftb_plus") class DFTBplusFormat(Format): - def from_labeled_system(self, file_name, **kwargs): - symbols, coord, energy, forces = read_dftb_plus(file_name) + def from_labeled_system(self, file_paths, **kwargs): + file_in, file_out = file_paths + symbols, coord, energy, forces = read_dftb_plus(file_in,file_out) last_occurrence = {v: i for i, v in enumerate(symbols)} atom_names = np.array(sorted(np.unique(symbols), key=last_occurrence.get)) atom_types = np.array([np.where(atom_names == s)[0][0] for s in symbols]) @@ -30,3 +31,8 @@ def from_labeled_system(self, file_name, **kwargs): "orig": np.zeros(3), "nopbc": True, } + + + + + \ No newline at end of file From 5ebe52bd0979fc013888f5279f4d6fd92b3a307d Mon Sep 17 00:00:00 2001 From: L-RuiHao <874800796@qq.com> Date: Mon, 31 Jul 2023 19:27:36 +0800 Subject: [PATCH 07/13] modify the length unit of DFTB+, add doc to the DFTBplusFormat class, rename dftb_plus to dftbplus --- tests/{test_dftb_plus.py => test_dftbplus.py} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename tests/{test_dftb_plus.py => test_dftbplus.py} (93%) diff --git a/tests/test_dftb_plus.py b/tests/test_dftbplus.py similarity index 93% rename from tests/test_dftb_plus.py rename to tests/test_dftbplus.py index eed269ec8..f8a22841c 100644 --- a/tests/test_dftb_plus.py +++ b/tests/test_dftbplus.py @@ -7,7 +7,6 @@ class TestDeepmdLoadAmmonia(unittest.TestCase, CompLabeledSys, IsNoPBC): def setUp(self): - length_convert = dpdata.unit.LengthConversion("bohr", "angstrom").value() energy_convert = dpdata.unit.EnergyConversion("hartree", "eV").value() force_convert = dpdata.unit.ForceConversion( "hartree/bohr", "eV/angstrom" @@ -31,8 +30,7 @@ def setUp(self): [0.702550, 0.603740, -0.789160], ] ] - ) - * length_convert, + ), "energies": np.array([-3.2963983884]) * energy_convert, "forces": np.array( [ From 049827fe63750c35513410a5c3e809485f0990a0 Mon Sep 17 00:00:00 2001 From: L-RuiHao <874800796@qq.com> Date: Mon, 31 Jul 2023 22:50:40 +0800 Subject: [PATCH 08/13] new modification --- dpdata/{dftb_plus => dftbplus}/__init__.py | 0 dpdata/{dftb_plus => dftbplus}/output.py | 0 dpdata/plugins/{dftb_plus.py => dftbplus.py} | 33 ++++++++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) rename dpdata/{dftb_plus => dftbplus}/__init__.py (100%) rename dpdata/{dftb_plus => dftbplus}/output.py (100%) rename dpdata/plugins/{dftb_plus.py => dftbplus.py} (52%) diff --git a/dpdata/dftb_plus/__init__.py b/dpdata/dftbplus/__init__.py similarity index 100% rename from dpdata/dftb_plus/__init__.py rename to dpdata/dftbplus/__init__.py diff --git a/dpdata/dftb_plus/output.py b/dpdata/dftbplus/output.py similarity index 100% rename from dpdata/dftb_plus/output.py rename to dpdata/dftbplus/output.py diff --git a/dpdata/plugins/dftb_plus.py b/dpdata/plugins/dftbplus.py similarity index 52% rename from dpdata/plugins/dftb_plus.py rename to dpdata/plugins/dftbplus.py index a3d28c3a7..b6c0d0142 100644 --- a/dpdata/plugins/dftb_plus.py +++ b/dpdata/plugins/dftbplus.py @@ -1,17 +1,44 @@ import numpy as np -from dpdata.dftb_plus.output import read_dftb_plus +from dpdata.dftbplus.output import read_dftb_plus from dpdata.format import Format from dpdata.unit import EnergyConversion, ForceConversion, LengthConversion -length_convert = LengthConversion("bohr", "angstrom").value() energy_convert = EnergyConversion("hartree", "eV").value() force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value() @Format.register("dftb_plus") class DFTBplusFormat(Format): + """ + The DFTBplusFormat class handles files in the DFTB+ format. + + This class provides a method to read DFTB+ files from a labeled system and + returns a dictionary containing various properties of the system.For more + information, please refer to the official documentation at the following URL: + https://dftbplus.org/documentation + + Attributes: + None + + Methods: + from_labeled_system(file_paths, **kwargs): Reads system information from files. + + + """ + def from_labeled_system(self, file_paths, **kwargs): + """ + Reads system information from the given DFTB+ file paths. + + Parameters: + file_paths (tuple): A tuple containing the input and output file paths. + the input file path should be a .hsd file and the output file path should be a .out file. + - Input file (file_in): Contains information about symbols and coord. + - Output file (file_out): Contains information about energy and force. + + **kwargs: Additional optional keyword arguments. + """ file_in, file_out = file_paths symbols, coord, energy, forces = read_dftb_plus(file_in,file_out) last_occurrence = {v: i for i, v in enumerate(symbols)} @@ -24,7 +51,7 @@ def from_labeled_system(self, file_paths, **kwargs): "atom_types": atom_types, "atom_names": list(atom_names), "atom_numbs": list(atom_numbs), - "coords": (coord * length_convert).reshape((1, natoms, 3)), + "coords": coord.reshape((1, natoms, 3)), "energies": np.array([energy * energy_convert]), "forces": (forces * force_convert).reshape((1, natoms, 3)), "cells": np.zeros((1, 3, 3)), From 5e4581565576df337b6a2a8939a3d325936dc5a0 Mon Sep 17 00:00:00 2001 From: L-RuiHao <874800796@qq.com> Date: Mon, 31 Jul 2023 23:04:36 +0800 Subject: [PATCH 09/13] modify the doc format --- dpdata/plugins/dftbplus.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dpdata/plugins/dftbplus.py b/dpdata/plugins/dftbplus.py index b6c0d0142..56708d4cc 100644 --- a/dpdata/plugins/dftbplus.py +++ b/dpdata/plugins/dftbplus.py @@ -31,13 +31,12 @@ def from_labeled_system(self, file_paths, **kwargs): """ Reads system information from the given DFTB+ file paths. - Parameters: - file_paths (tuple): A tuple containing the input and output file paths. - the input file path should be a .hsd file and the output file path should be a .out file. - - Input file (file_in): Contains information about symbols and coord. - - Output file (file_out): Contains information about energy and force. + file_paths (tuple): A tuple containing the input and output file paths. + - Input file (file_in): Contains information about symbols and coord. + - Output file (file_out): Contains information about energy and force. + + **kwargs: Additional optional keyword arguments. - **kwargs: Additional optional keyword arguments. """ file_in, file_out = file_paths symbols, coord, energy, forces = read_dftb_plus(file_in,file_out) From bd47346d3ee9914bfc0fef4aa93f72716dd83f7b Mon Sep 17 00:00:00 2001 From: L-RuiHao <874800796@qq.com> Date: Mon, 31 Jul 2023 23:13:43 +0800 Subject: [PATCH 10/13] modify the doc format --- dpdata/plugins/dftbplus.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dpdata/plugins/dftbplus.py b/dpdata/plugins/dftbplus.py index 56708d4cc..78cffda0f 100644 --- a/dpdata/plugins/dftbplus.py +++ b/dpdata/plugins/dftbplus.py @@ -31,11 +31,15 @@ def from_labeled_system(self, file_paths, **kwargs): """ Reads system information from the given DFTB+ file paths. - file_paths (tuple): A tuple containing the input and output file paths. + Parameters + ---------- + file_paths: tuple + A tuple containing the input and output file paths. - Input file (file_in): Contains information about symbols and coord. - Output file (file_out): Contains information about energy and force. - **kwargs: Additional optional keyword arguments. + **kwargs : dict + other parameters """ file_in, file_out = file_paths From ba77f8698a79a217b6aaad9978969a120d39b838 Mon Sep 17 00:00:00 2001 From: L-RuiHao <874800796@qq.com> Date: Mon, 31 Jul 2023 23:23:19 +0800 Subject: [PATCH 11/13] change doc format --- dpdata/plugins/dftbplus.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dpdata/plugins/dftbplus.py b/dpdata/plugins/dftbplus.py index 78cffda0f..7414b8ba8 100644 --- a/dpdata/plugins/dftbplus.py +++ b/dpdata/plugins/dftbplus.py @@ -23,8 +23,7 @@ class DFTBplusFormat(Format): Methods: from_labeled_system(file_paths, **kwargs): Reads system information from files. - - + """ def from_labeled_system(self, file_paths, **kwargs): From df15e7e0a0350f8b552b7f1fb56c459f20d30f71 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:25:20 +0000 Subject: [PATCH 12/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpdata/dftbplus/output.py | 46 +++++++++++++++++--------------------- dpdata/plugins/dftbplus.py | 30 ++++++++++--------------- tests/test_amber_sqm.py | 3 --- 3 files changed, 32 insertions(+), 47 deletions(-) diff --git a/dpdata/dftbplus/output.py b/dpdata/dftbplus/output.py index 6bb31d68a..ba8f6c840 100644 --- a/dpdata/dftbplus/output.py +++ b/dpdata/dftbplus/output.py @@ -1,7 +1,7 @@ +from typing import Tuple + import numpy as np -from typing import Tuple -import os def read_dftb_plus(fn_1: str, fn_2: str) -> Tuple[str, np.ndarray, float, np.ndarray]: """Read from DFTB+ input and output. @@ -24,57 +24,51 @@ def read_dftb_plus(fn_1: str, fn_2: str) -> Tuple[str, np.ndarray, float, np.nda np.ndarray atomic forces - - """ + """ coord = None symbols = None forces = None - energy = None + energy = None with open(fn_1) as f: flag = 0 for line in f: - if flag ==1: - flag +=1 + if flag == 1: + flag += 1 elif flag == 2: - components = line.split() - flag +=1 + components = line.split() + flag += 1 elif line.startswith("Geometry"): flag = 1 coord = [] symbols = [] - elif flag in (3,4,5,6): - s = line.split() - components_num = int(s[1]) - symbols.append(components[components_num-1]) + elif flag in (3, 4, 5, 6): + s = line.split() + components_num = int(s[1]) + symbols.append(components[components_num - 1]) coord.append([float(s[2]), float(s[3]), float(s[4])]) - flag +=1 + flag += 1 if flag == 7: - flag = 0 + flag = 0 with open(fn_2) as f: flag = 0 for line in f: if line.startswith("Total Forces"): flag = 8 forces = [] - elif flag in (8,9,10,11): - s = line.split() + elif flag in (8, 9, 10, 11): + s = line.split() forces.append([float(s[1]), float(s[2]), float(s[3])]) - flag +=1 + flag += 1 if flag == 12: - flag = 0 + flag = 0 elif line.startswith("Total energy:"): - s = line.split() + s = line.split() energy = float(s[2]) flag = 0 - + symbols = np.array(symbols) forces = np.array(forces) coord = np.array(coord) assert coord.shape == forces.shape return symbols, coord, energy, forces - - - - - \ No newline at end of file diff --git a/dpdata/plugins/dftbplus.py b/dpdata/plugins/dftbplus.py index 7414b8ba8..a774d4762 100644 --- a/dpdata/plugins/dftbplus.py +++ b/dpdata/plugins/dftbplus.py @@ -2,7 +2,7 @@ from dpdata.dftbplus.output import read_dftb_plus from dpdata.format import Format -from dpdata.unit import EnergyConversion, ForceConversion, LengthConversion +from dpdata.unit import EnergyConversion, ForceConversion energy_convert = EnergyConversion("hartree", "eV").value() force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value() @@ -10,39 +10,38 @@ @Format.register("dftb_plus") class DFTBplusFormat(Format): - """ - The DFTBplusFormat class handles files in the DFTB+ format. + """The DFTBplusFormat class handles files in the DFTB+ format. This class provides a method to read DFTB+ files from a labeled system and - returns a dictionary containing various properties of the system.For more + returns a dictionary containing various properties of the system.For more information, please refer to the official documentation at the following URL: https://dftbplus.org/documentation - Attributes: + Attributes + ---------- None - Methods: + Methods + ------- from_labeled_system(file_paths, **kwargs): Reads system information from files. - + """ - + def from_labeled_system(self, file_paths, **kwargs): - """ - Reads system information from the given DFTB+ file paths. + """Reads system information from the given DFTB+ file paths. Parameters ---------- - file_paths: tuple + file_paths : tuple A tuple containing the input and output file paths. - Input file (file_in): Contains information about symbols and coord. - Output file (file_out): Contains information about energy and force. - **kwargs : dict other parameters """ file_in, file_out = file_paths - symbols, coord, energy, forces = read_dftb_plus(file_in,file_out) + symbols, coord, energy, forces = read_dftb_plus(file_in, file_out) last_occurrence = {v: i for i, v in enumerate(symbols)} atom_names = np.array(sorted(np.unique(symbols), key=last_occurrence.get)) atom_types = np.array([np.where(atom_names == s)[0][0] for s in symbols]) @@ -60,8 +59,3 @@ def from_labeled_system(self, file_paths, **kwargs): "orig": np.zeros(3), "nopbc": True, } - - - - - \ No newline at end of file diff --git a/tests/test_amber_sqm.py b/tests/test_amber_sqm.py index 814852fde..7f14ff84c 100644 --- a/tests/test_amber_sqm.py +++ b/tests/test_amber_sqm.py @@ -79,6 +79,3 @@ def test_sqm_in(self): def tearDown(self): if os.path.isfile("amber/sqm_test.in"): os.remove("amber/sqm_test.in") - - - From ff0638866fa8335e9b7f34289583de57e0df6441 Mon Sep 17 00:00:00 2001 From: liaoruihao Date: Wed, 2 Aug 2023 23:36:23 +0800 Subject: [PATCH 13/13] add DFTB+ info to readme file --- README.md | 3 ++- dpdata/plugins/dftbplus.py | 2 +- tests/{dftb_plus => dftbplus}/detailed.out | 0 tests/{dftb_plus => dftbplus}/dftb_pin.hsd | 0 tests/test_dftbplus.py | 2 +- 5 files changed, 4 insertions(+), 3 deletions(-) rename tests/{dftb_plus => dftbplus}/detailed.out (100%) rename tests/{dftb_plus => dftbplus}/dftb_pin.hsd (100%) diff --git a/README.md b/README.md index 828223e5d..1e86a7196 100644 --- a/README.md +++ b/README.md @@ -88,11 +88,12 @@ The `System` or `LabeledSystem` can be constructed from the following file forma | Amber | multi | True | True | LabeledSystem | 'amber/md' | | Amber/sqm | sqm.out | False | False | System | 'sqm/out' | | Gromacs | gro | True | False | System | 'gromacs/gro' | -| ABACUS | STRU | False | False | System | 'abacus/stru' | +| ABACUS | STRU | False | False | System | 'abacus/stru' | | ABACUS | STRU | False | True | LabeledSystem | 'abacus/scf' | | ABACUS | cif | True | True | LabeledSystem | 'abacus/md' | | ABACUS | STRU | True | True | LabeledSystem | 'abacus/relax' | | ase | structure | True | True | MultiSystems | 'ase/structure' | +| DFTB+ | dftbplus | False | True | LabeledSystem | 'dftbplus' | The Class `dpdata.MultiSystems` can read data from a dir which may contains many files of different systems, or from single xyz file which contains different systems. diff --git a/dpdata/plugins/dftbplus.py b/dpdata/plugins/dftbplus.py index a774d4762..5c8b46828 100644 --- a/dpdata/plugins/dftbplus.py +++ b/dpdata/plugins/dftbplus.py @@ -8,7 +8,7 @@ force_convert = ForceConversion("hartree/bohr", "eV/angstrom").value() -@Format.register("dftb_plus") +@Format.register("dftbplus") class DFTBplusFormat(Format): """The DFTBplusFormat class handles files in the DFTB+ format. diff --git a/tests/dftb_plus/detailed.out b/tests/dftbplus/detailed.out similarity index 100% rename from tests/dftb_plus/detailed.out rename to tests/dftbplus/detailed.out diff --git a/tests/dftb_plus/dftb_pin.hsd b/tests/dftbplus/dftb_pin.hsd similarity index 100% rename from tests/dftb_plus/dftb_pin.hsd rename to tests/dftbplus/dftb_pin.hsd diff --git a/tests/test_dftbplus.py b/tests/test_dftbplus.py index f8a22841c..2a2913a52 100644 --- a/tests/test_dftbplus.py +++ b/tests/test_dftbplus.py @@ -13,7 +13,7 @@ def setUp(self): ).value() self.system_1 = dpdata.LabeledSystem( - ("dftb_plus/dftb_pin.hsd", "dftb_plus/detailed.out"), fmt="dftb_plus" + ("dftbplus/dftb_pin.hsd", "dftbplus/detailed.out"), fmt="dftbplus" ) self.system_2 = dpdata.LabeledSystem(