From 424987714fcc536a09df97e48a00ec82141e397f Mon Sep 17 00:00:00 2001 From: root Date: Tue, 13 Dec 2022 13:26:47 +0800 Subject: [PATCH] Fix: remove the reading of `ntype` in the parsing of abacus structure --- dpdata/abacus/scf.py | 10 ++-------- tests/abacus.md.nostress/INPUT | 3 +-- tests/abacus.md.unconv/INPUT | 1 - tests/abacus.md/INPUT | 1 - tests/abacus.relax/INPUT | 1 - tests/abacus.scf/INPUT.fail | 1 - tests/abacus.scf/INPUT.ok | 1 - 7 files changed, 3 insertions(+), 15 deletions(-) diff --git a/dpdata/abacus/scf.py b/dpdata/abacus/scf.py index 45ca9a663..0283025a7 100644 --- a/dpdata/abacus/scf.py +++ b/dpdata/abacus/scf.py @@ -59,7 +59,7 @@ def get_cell(geometry_inlines): cell = celldm*np.array(cell) return celldm, cell -def get_coords(celldm, cell, geometry_inlines, inlines): +def get_coords(celldm, cell, geometry_inlines, inlines=None): coords_lines = get_block(geometry_inlines, "ATOMIC_POSITIONS", skip=0) # assuming that ATOMIC_POSITIONS is at the bottom of the STRU file coord_type = coords_lines[0].split()[0].lower() # cartisan or direct @@ -67,13 +67,7 @@ def get_coords(celldm, cell, geometry_inlines, inlines): atom_types = [] # index of atom_names of each atom in the geometry atom_numbs = [] # of atoms for each element coords = [] # coordinations of atoms - ntype = 0 - for line in inlines: - if "ntype" in line and "ntype"==line.split()[0]: - ntype = int(line.split()[1]) - break - if ntype <= 0: - raise RuntimeError('ntype cannot be found in INPUT file.') + ntype = get_nele_from_stru(geometry_inlines) line_idx = 1 # starting line of first element for it in range(ntype): atom_names.append(coords_lines[line_idx].split()[0]) diff --git a/tests/abacus.md.nostress/INPUT b/tests/abacus.md.nostress/INPUT index 4dd5c0fa6..7d3bc83e8 100644 --- a/tests/abacus.md.nostress/INPUT +++ b/tests/abacus.md.nostress/INPUT @@ -1,8 +1,7 @@ INPUT_PARAMETERS #Parameters (General) suffix autotest -pseudo_dir ./ -ntype 1 +pseudo_dir ./ nbands 8 calculation md diff --git a/tests/abacus.md.unconv/INPUT b/tests/abacus.md.unconv/INPUT index d4f1574ec..b4864e138 100644 --- a/tests/abacus.md.unconv/INPUT +++ b/tests/abacus.md.unconv/INPUT @@ -1,6 +1,5 @@ INPUT_PARAMETERS calculation md -ntype 2 nbands 8 ecutwfc 50.000000 diff --git a/tests/abacus.md/INPUT b/tests/abacus.md/INPUT index 5986c0ba5..28532ea22 100644 --- a/tests/abacus.md/INPUT +++ b/tests/abacus.md/INPUT @@ -2,7 +2,6 @@ INPUT_PARAMETERS #Parameters (1.General) suffix abacus calculation md -ntype 2 nbands 6 symmetry 0 diff --git a/tests/abacus.relax/INPUT b/tests/abacus.relax/INPUT index 46ab55eac..a67e51868 100644 --- a/tests/abacus.relax/INPUT +++ b/tests/abacus.relax/INPUT @@ -2,7 +2,6 @@ INPUT_PARAMETERS #Parameters (1.General) suffix abacus calculation cell-relax -ntype 2 nbands 6 symmetry 1 diff --git a/tests/abacus.scf/INPUT.fail b/tests/abacus.scf/INPUT.fail index d9fcc9378..a5e310709 100644 --- a/tests/abacus.scf/INPUT.fail +++ b/tests/abacus.scf/INPUT.fail @@ -4,7 +4,6 @@ suffix ch4fail stru_file STRU.ch4 #the filename of file containing atom positions kpoint_file KPT.ch4 #the name of file containing k points pseudo_dir ./ -ntype 2 nbands 8 #Parameters (Accuracy) ecutwfc 100 diff --git a/tests/abacus.scf/INPUT.ok b/tests/abacus.scf/INPUT.ok index 0281c22df..8395e029c 100644 --- a/tests/abacus.scf/INPUT.ok +++ b/tests/abacus.scf/INPUT.ok @@ -4,7 +4,6 @@ suffix ch4 stru_file STRU.ch4 #the filename of file containing atom positions kpoint_file KPT.ch4 #the name of file containing k points pseudo_dir ./ -ntype 2 nbands 8 #Parameters (Accuracy) ecutwfc 100