Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Atoms.cluster_from_file() in io.feff.inputs giving wrong number of atoms #3426

Merged
merged 51 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1dc8c43
Update test_sets.py
kaifengZheng Aug 19, 2023
bb74a32
add test file
kaifengZheng Aug 19, 2023
fac911d
fix a bug in inputs.py
kaifengZheng Aug 19, 2023
0018837
pre-commit auto-fixes
pre-commit-ci[bot] Aug 19, 2023
8112068
files
kaifengZheng Aug 19, 2023
943cbd4
Revert "files"
kaifengZheng Aug 19, 2023
46fbf47
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 19, 2023
09f0642
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 19, 2023
2550e26
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 20, 2023
d2c35c2
Merge branch 'master' into master
kaifengZheng Aug 20, 2023
c5020c1
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 20, 2023
18e23bd
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 20, 2023
1679411
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 21, 2023
ae62a3a
Merge branch 'master' into master
janosh Aug 21, 2023
3fd1904
remove test file and modify the test method
kaifengZheng Aug 22, 2023
84392b8
pre-commit auto-fixes
pre-commit-ci[bot] Aug 22, 2023
81c1ac5
Merge branch 'master' of https://github.com/materialsproject/pymatgen
kaifengZheng Aug 22, 2023
ccb5106
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 22, 2023
19896dc
Merge branch 'master' of https://github.com/kaifengZheng/pymatgen
kaifengZheng Aug 22, 2023
91fab3c
i->idx
janosh Aug 22, 2023
ebcedfe
Merge branch 'master' into master
kaifengZheng Aug 22, 2023
f036f0a
Merge branch 'master' into master
kaifengZheng Aug 22, 2023
00da9c8
forgot to negate check_occu after inverting semantics from skip_occu_…
janosh Aug 22, 2023
cde0422
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 22, 2023
bd25993
Update test_sets.py
kaifengZheng Aug 22, 2023
95c0b56
pre-commit auto-fixes
pre-commit-ci[bot] Aug 22, 2023
80b2ad4
Merge branch 'master' into master
kaifengZheng Aug 22, 2023
c915adb
pre-commit auto-fixes
pre-commit-ci[bot] Aug 22, 2023
844336e
Update testing.py resolve conflict
kaifengZheng Aug 22, 2023
61b5914
Merge branch 'master' into master
kaifengZheng Aug 22, 2023
6607fa7
add PR link to new test
janosh Aug 22, 2023
e9c3d82
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 22, 2023
f8ef114
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 22, 2023
d2cfa6a
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 28, 2023
cb05b84
fix Atom.input miss atoms problem
kaifengZheng Oct 26, 2023
6b14744
Merge branch 'master' of https://github.com/kaifengZheng/pymatgen
kaifengZheng Oct 26, 2023
432a166
pre-commit auto-fixes
pre-commit-ci[bot] Oct 26, 2023
4a03535
Update inputs.py
kaifengZheng Oct 26, 2023
9151dbd
Update inputs.py
kaifengZheng Oct 26, 2023
fcc2751
Update inputs.py
kaifengZheng Oct 26, 2023
4417107
Merge branch 'master' into master
kaifengZheng Oct 27, 2023
9f40a5b
Merge branch 'materialsproject:master' into master
kaifengZheng Oct 27, 2023
bae05b1
Update test_inputs.py
kaifengZheng Oct 27, 2023
0d3846a
pre-commit auto-fixes
pre-commit-ci[bot] Oct 27, 2023
47022dc
Merge branch 'master' into master
kaifengZheng Oct 27, 2023
883deeb
Merge branch 'master' into master
kaifengZheng Oct 31, 2023
dcf190c
Merge branch 'master' into master
kaifengZheng Oct 31, 2023
614cc85
Update test_inputs.py
kaifengZheng Oct 31, 2023
1d5214b
fix AttributeError: 'list' object has no attribute 'startswith'
janosh Nov 2, 2023
c346c00
gzip tests/files/ATOMS_test.inp
janosh Nov 2, 2023
dc1b939
improve test
janosh Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pymatgen/io/feff/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,11 @@ def cluster_from_file(filename):
is the one at the origin.
"""
atoms_string = Atoms.atoms_string_from_file(filename)
lines = [line.split() for line in atoms_string.splitlines()[3:]]
lines = [line.split() for line in atoms_string.splitlines()[1:]]
coords = []
symbols = []
for line in lines:
if line:
if line and line[0].__contains__("*"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if line and line[0].__contains__("*"):
if line and line.startswith("*"):

coords.append([float(val) for val in line[:3]])
symbols.append(line[4])
return Molecule(symbols, coords)
Expand Down
64 changes: 64 additions & 0 deletions tests/files/ATOMS_test.inp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have 6 or more existing .inp files. Can you reuse those for testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every updated feff.inp file has the same format. My input file deletes the * lines under ATOMS, which can be used for the test.
image

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
TITLE COC_O3_cut_ori_100_l_5_19_site_0_n_4
EDGE L3
S02 0.9

COREHOLE FSR
CONTROL 1 1 1 1 1 1

FMS 7 0
EXCHANGE 0 1 0 2
SCF 7 0 100 0.1 1
DEBYE 80 230 0


XANES 20 0.05 0.1

POTENTIALS
0 78 Pt
1 78 Pt


POTENTIALS
* ipot Z element l_scmt l_fms stoichiometry
0 78 Pt -1 -1 0.001 0
1 78 Pt -1 -1 37 0

ATOMS
0 0 0 0 Pt 0 0
-1.386 -1.386 1.96 1 Pt 2.77193 16
1.386 1.386 1.96 1 Pt 2.77193 17
1.386 -1.386 1.96 1 Pt 2.77193 21
0 -2.772 0 1 Pt 2.772 1
2.772 0 0 1 Pt 2.772 3
2.772 -2.772 0 1 Pt 3.9202 4
4.158 1.386 1.96 1 Pt 4.8012 23
4.158 -1.386 1.96 1 Pt 4.8012 22
1.386 -4.158 1.96 1 Pt 4.8012 20
-1.386 -4.158 1.96 1 Pt 4.8012 19
5.544 0 0 1 Pt 5.544 5
0 -5.544 0 1 Pt 5.544 2
4.158 -4.158 1.96 1 Pt 6.19835 28
2.772 -5.544 0 1 Pt 6.19838 7
5.544 -2.772 0 1 Pt 6.19838 9
-1.386 -6.93 1.96 1 Pt 7.334 18
6.93 1.386 1.96 1 Pt 7.334 24
1.386 -6.93 1.96 1 Pt 7.334 26
6.93 -1.386 1.96 1 Pt 7.334 30
5.544 -5.544 0 1 Pt 7.8404 10
4.158 -6.93 1.96 1 Pt 8.31598 27
6.93 -4.158 1.96 1 Pt 8.31598 29
0 -8.316 0 1 Pt 8.316 6
8.316 0 0 1 Pt 8.316 11
8.316 -2.772 0 1 Pt 8.76583 12
2.772 -8.316 0 1 Pt 8.76583 8
6.93 -6.93 1.96 1 Pt 9.99457 34
9.702 -1.386 1.96 1 Pt 9.99457 31
1.386 -9.702 1.96 1 Pt 9.99457 25
8.316 -5.544 0 1 Pt 9.99459 14
5.544 -8.316 0 1 Pt 9.99459 13
4.158 -9.702 1.96 1 Pt 10.7359 32
9.702 -4.158 1.96 1 Pt 10.7359 36
8.316 -8.316 0 1 Pt 11.7606 15
9.702 -6.93 1.96 1 Pt 12.0829 35
6.93 -9.702 1.96 1 Pt 12.0829 33
END
6 changes: 6 additions & 0 deletions tests/io/feff/test_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,9 @@ def test_paths_string(self):
]
answer = "\n".join(lines)
assert answer == str(self.paths)


def test_atom_num(self):
atoms = Atoms.cluster_from_file("ATOMS_test.inp")
num_atom = 37
assert len(atoms) != num_atom
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not test for the expected number of atoms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Janosh,
The expected number of atoms is 37; how should I specify this value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is != a typo?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing one level of indentation to make it a method of the test class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me fix it. sorry to confuse you. I want it to pass when the expected number of atoms is equal to num_atom and throw an error when the numbers are not equal.

Loading