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

improvement: add Atoms.clone() and remove sites by indices, including in-place. Use develop branch for the PR. #315

Merged
merged 369 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
369 commits
Select commit Hold shift + click to select a range
a4e0e03
Fix phonopy requirements.
knc6 Dec 19, 2021
a6e81d6
Fix all requirements.
knc6 Dec 19, 2021
5d2196b
Fix phonopy requirements.
knc6 Dec 19, 2021
8f5644c
QE test.
knc6 Dec 20, 2021
686f26b
QE test.
knc6 Dec 20, 2021
77823cd
Update action_build.
knc6 Dec 20, 2021
54e86ab
Try other python versions.
knc6 Dec 20, 2021
e97ab43
Try other python versions.
knc6 Dec 20, 2021
adf9d2d
README updates.
knc6 Dec 20, 2021
b4ef951
Merge branch 'master' into develop
knc6 Dec 20, 2021
62a4abd
Adding nexus. (#197)
wines1 Dec 20, 2021
37a6a73
Revert back.
knc6 Dec 20, 2021
b19e00c
Update .readthedocs.yaml
knc6 Dec 20, 2021
966fde9
Update dev-requirements.txt
knc6 Dec 20, 2021
d5aa091
Docs requirements update.
knc6 Dec 20, 2021
19d87d1
Update .readthedocs.yaml
knc6 Dec 20, 2021
2aec2f1
Update requirements.txt
knc6 Dec 20, 2021
e42d5d7
Update .readthedocs.yaml
knc6 Dec 20, 2021
c8be140
Update requirements.txt
knc6 Dec 20, 2021
a9b5ba6
Update .readthedocs.yaml
knc6 Dec 20, 2021
b71787a
Update requirements.txt
knc6 Dec 20, 2021
1f3080f
Update requirements.txt
knc6 Dec 20, 2021
383ef4a
Update requirements.txt
knc6 Dec 20, 2021
85daf0e
Update requirements.txt
knc6 Dec 20, 2021
8c7844c
Update requirements.txt
knc6 Dec 20, 2021
163c47f
Update atoms.py
knc6 Dec 20, 2021
0cb61d0
Fixe pbc in ase_to_Atoms.
knc6 Dec 20, 2021
88139a6
Add installation tests (#214)
SauravMaheshkar Dec 28, 2021
891621d
Adding QE super.
knc6 Jan 11, 2022
7d3d96d
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 Jan 11, 2022
14f3dc7
Minor changes to QE module, atoms xyz fix.
knc6 Jan 11, 2022
8b0e3ef
Adding qe_tb info, and version update.
knc6 Jan 12, 2022
f24d948
Merge branch 'master' into develop
knc6 Jan 12, 2022
3b37a00
Update __init__.py
knc6 Jan 12, 2022
2484f85
WIP super QE.
knc6 Jan 25, 2022
6de9c63
Working version of ScSi.
knc6 Jan 26, 2022
87683e2
QE inputs and task update.
knc6 Jan 28, 2022
b810256
Add master super.
knc6 Jan 28, 2022
8f82ef0
Add master super.
knc6 Jan 28, 2022
e3c5458
Lint fix.
knc6 Jan 28, 2022
7ef4382
Lint fix.
knc6 Jan 28, 2022
b714e4c
Minor fix.
knc6 Jan 28, 2022
b8e198c
ET update.
knc6 Jan 30, 2022
10e7549
Fix ET test.
knc6 Jan 30, 2022
e07587e
Update sanitize atoms.
knc6 Feb 9, 2022
195c8dd
Additonal checks on supercond.
knc6 Feb 17, 2022
9c4b27b
Debye bug fix.
knc6 Mar 10, 2022
438be9c
Pressure in QE Super.
knc6 Apr 3, 2022
bf1ec93
Version fix, publication update, supercond workflow update.
knc6 May 6, 2022
aa0e4bf
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 May 6, 2022
4606643
Lint fix.
knc6 May 6, 2022
df68f73
Tensorboard fix.
knc6 May 6, 2022
6ab83f1
Tensorboard fix.
knc6 May 6, 2022
e508317
Tensorboard fix.
knc6 May 6, 2022
14ec9d5
Melting temp fix.
knc6 May 6, 2022
b3ac2ad
Update vasp.py (#234)
wines1 May 6, 2022
0459156
Local tetra tmp.
knc6 May 6, 2022
7f29ffa
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 May 6, 2022
ded0cb0
Version update.
knc6 May 6, 2022
27365a8
Merge branch 'master' into develop
knc6 May 7, 2022
fad7aea
Lint fix.
knc6 May 7, 2022
304d411
HSE06
knc6 May 7, 2022
dd5ca8c
Tmp.
knc6 May 11, 2022
ca42f2c
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 May 11, 2022
8780e43
Vacancy update, Optimade structureand other minor lint updates.
knc6 May 21, 2022
ea609a5
STEM pytest fix.
knc6 May 21, 2022
2338d18
Merge branch 'master' into develop
knc6 May 21, 2022
bd6935f
Minor lint fix.
knc6 May 21, 2022
684f662
Fixed selectrive dynamics issue in Poscar, force reading for single a…
knc6 Jul 18, 2022
0a9e7ad
Merge branch 'master' into develop
knc6 Jul 18, 2022
b1d82bd
Lint fix.
knc6 Jul 18, 2022
9a0be74
Added phononDos class.
knc6 Aug 23, 2022
d0eb71d
fix pytorch UserWarning in build_undirected_edgedata() (#243)
janosh Aug 25, 2022
e081c62
Add PhaseDiagram.
knc6 Aug 28, 2022
f2ea684
Add PhaseDiagram.
knc6 Aug 28, 2022
5e8fa2e
PhaseDiagram update.
knc6 Aug 28, 2022
76514c1
STM image pytest increase, requirements upgrade.
knc6 Aug 28, 2022
fdf773b
STM image pytest increase, requirements upgrade.
knc6 Aug 28, 2022
04b18ef
STM image pytest increase, requirements upgrade.
knc6 Aug 28, 2022
34a547d
Compare atoms, get spg info directly from atoms.
knc6 Aug 28, 2022
e903e15
Merge branch 'master' into develop
knc6 Aug 28, 2022
27f5982
Flake8 fix.
knc6 Aug 28, 2022
238d4f0
Update publications.rst
knc6 Aug 28, 2022
33bbf5c
Update qiskit.
knc6 Sep 17, 2022
a24453f
Update qiskit.
knc6 Sep 17, 2022
0a82c1e
Update test_hermsolver.py
knc6 Sep 17, 2022
8ebf208
FIix qiskit DOS.
knc6 Sep 17, 2022
a0830e5
Update test_hermsolver.py
knc6 Sep 17, 2022
e51c1ce
Merge branch 'master' into develop
knc6 Sep 17, 2022
65b1251
Fix linting.
knc6 Sep 17, 2022
85c1b58
Develop og (#257)
RamyaGuru Sep 26, 2022
b8cf557
Add QE convergence.
knc6 Dec 6, 2022
baf83b9
Update converg.py.
knc6 Dec 7, 2022
c3740ad
Nexus.
knc6 Dec 7, 2022
b232e3d
Super with converg.
knc6 Dec 10, 2022
d071d2d
Super with converg.
knc6 Dec 10, 2022
bf535b0
SuperCon QE update.
knc6 Dec 11, 2022
d481e95
Figshare DB update.
knc6 Dec 12, 2022
28c0b1a
Figshare DB update.
knc6 Dec 12, 2022
4c7a15d
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 Dec 12, 2022
a1db354
Update alignn ff link.
knc6 Dec 12, 2022
7e0c105
Lint fix.
knc6 Dec 12, 2022
f31d913
Merge branch 'master' into develop
knc6 Dec 12, 2022
2beb1fb
DB docs update.
knc6 Dec 13, 2022
8f70400
Minor fixes: delete agg in figshare, add destination path in figshare…
knc6 Jan 9, 2023
4a01ad9
Merge branch 'master' into develop
knc6 Jan 9, 2023
5fabeb3
Lint fix.
knc6 Jan 9, 2023
cfefb6f
Supercon workflow fix.
knc6 Mar 24, 2023
3855a0e
Add extra db entires, fix chem in cfid_chem.
knc6 Mar 24, 2023
91c56d5
Version update.
knc6 Apr 7, 2023
4b2ecf3
Merge branch 'master' into develop
knc6 Apr 7, 2023
0c162b8
Add figshare datasets.
knc6 May 29, 2023
00b534f
Update databases.rst
knc6 May 29, 2023
34dd120
codecov fix.
knc6 May 29, 2023
fb9ebd4
Version update.
knc6 May 29, 2023
f33a079
Merge branch 'master' into develop
knc6 May 29, 2023
30eae92
Lint fix.
knc6 May 29, 2023
4477c4a
Add FigShare datasets, DOS in QE, Uncertainty.
knc6 Aug 11, 2023
e3fb456
Add python 3.9.
knc6 Aug 11, 2023
03f31f2
Create README.md
knc6 Aug 11, 2023
c7666a2
Update README.
knc6 Aug 11, 2023
a8dd2bc
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 Aug 11, 2023
884089c
Add README.md.
knc6 Aug 11, 2023
ba13e07
Update action_build.yml
knc6 Aug 11, 2023
e89fa1a
Update action_lint.yml
knc6 Aug 11, 2023
905a898
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 Aug 11, 2023
374d0c1
Allow md file, add mode databases.
knc6 Aug 11, 2023
c188641
Create NISTtheDocs2Death.yml
knc6 Aug 11, 2023
59ade1c
Merge branch 'master' into develop
knc6 Aug 11, 2023
20b029c
Allow md file, add mode databases.
knc6 Aug 11, 2023
f374e80
Add publications.
knc6 Aug 11, 2023
3c65bc2
Update publications.rst
knc6 Aug 11, 2023
2f6812a
Update requirements.txt
knc6 Aug 11, 2023
c4e413b
Update requirements.txt
knc6 Aug 11, 2023
5fb1224
Update requirements.txt
knc6 Aug 11, 2023
1b79f3e
Update requirements.txt
knc6 Aug 11, 2023
f578c3e
Create deploy_nist_pages.yml
knc6 Aug 11, 2023
3a5e2d5
Add mkdocs.
knc6 Aug 11, 2023
e16a0d6
Update deploy_nist_pages.yml
knc6 Aug 11, 2023
deb6940
Update md.
knc6 Aug 11, 2023
4dcd573
Update setup.py
knc6 Aug 11, 2023
4c62b15
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 Aug 11, 2023
17f31e8
Update readme.
knc6 Aug 11, 2023
305a995
Update setup.py
knc6 Aug 11, 2023
c845c80
Remove absl.
knc6 Aug 11, 2023
725eb8e
Update dev-requirements.txt
knc6 Aug 11, 2023
b3bd0a2
Update index.md
knc6 Aug 11, 2023
70b6312
Update deploy_nist_pages.yml
knc6 Aug 11, 2023
19f802f
Update index.rst
knc6 Aug 11, 2023
480ece5
Add redirect.
knc6 Aug 11, 2023
580dbf3
Update action_build.yml
knc6 Aug 11, 2023
057b485
Update dev-requirements.txt
knc6 Aug 11, 2023
6682b07
Update dev-requirements.txt
knc6 Aug 11, 2023
9026f4d
Update setup.py
knc6 Aug 11, 2023
3574c37
Update dev-requirements.txt
knc6 Aug 11, 2023
5da17b6
Fix __repr__ for Atoms.
knc6 Aug 18, 2023
e3c2c85
Update requirements.
knc6 Aug 18, 2023
84dcdb6
Update requirements.
knc6 Aug 18, 2023
ad33618
Update requirements.
knc6 Aug 18, 2023
bfa6065
Update requirements.
knc6 Aug 18, 2023
aaa3a1d
Update requirements.
knc6 Aug 18, 2023
9d1c3c9
Update requirements.
knc6 Aug 18, 2023
3c9bfc2
Update requirements.
knc6 Aug 18, 2023
94b4546
Update requirements.
knc6 Aug 18, 2023
0292f80
Fix requirements.
knc6 Aug 18, 2023
898cd93
Fix requirements.
knc6 Aug 18, 2023
532cb38
Fix requirements.
knc6 Aug 18, 2023
0ed4183
Fix requirements.
knc6 Aug 18, 2023
5a74ee3
Use poscar write as string.
knc6 Aug 19, 2023
95cf5f7
Use poscar write as string.
knc6 Aug 19, 2023
245466c
Use poscar write as string.
knc6 Aug 19, 2023
ab6404a
Update action_build.yml
knc6 Aug 19, 2023
5487484
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 Aug 19, 2023
e170728
Use poscar write as string.
knc6 Aug 19, 2023
8817fea
Use poscar write as string.
knc6 Aug 19, 2023
e994185
Update action_build.yml
knc6 Aug 19, 2023
f4f487e
Use poscar write as string.
knc6 Aug 19, 2023
7ce0ca5
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 Aug 19, 2023
5df0915
Use poscar write as string.
knc6 Aug 19, 2023
3f28136
Delete NISTtheDocs2Death.yml
knc6 Aug 19, 2023
caff38a
Delete action_lint.yml
knc6 Aug 19, 2023
c796a63
Use poscar write as string.
knc6 Aug 19, 2023
a48b14d
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 Aug 19, 2023
2c43595
Fix phonopy.
knc6 Aug 19, 2023
f74ee28
Update dev-requirements.txt
knc6 Aug 19, 2023
327b834
Update databases.
knc6 Aug 19, 2023
e652525
Merge branch 'develop' of https://github.com/usnistgov/jarvis into de…
knc6 Aug 19, 2023
a331b28
Add eigs.
knc6 Aug 19, 2023
80e4807
Add eigs.
knc6 Aug 19, 2023
97eaf5f
Add eigs.
knc6 Aug 19, 2023
73439f0
Fix STM test.
knc6 Aug 19, 2023
7deda85
Delete .travis.yml
knc6 Aug 19, 2023
55c3dac
Merge conflict.
knc6 Aug 19, 2023
31c7d65
Update README.
knc6 Aug 20, 2023
cfe0e42
Add python docs.
knc6 Aug 20, 2023
83976a0
GA
knc6 Aug 20, 2023
02973aa
Update action_build.yml
knc6 Aug 20, 2023
157995a
Merge branch 'master' into develop
knc6 Aug 20, 2023
6693721
Atoms class update with props.
knc6 Sep 21, 2023
ecab334
Atoms class update with props.
knc6 Sep 21, 2023
dbd31d7
Delete .readthedocs.yaml
knc6 Sep 21, 2023
92ec114
Update README.md
knc6 Sep 21, 2023
3b30568
Merge branch 'master' into develop
knc6 Sep 22, 2023
bc3f03c
QEjob fix.
knc6 Oct 14, 2023
ff4ae5b
Chang poscar write.
knc6 Oct 18, 2023
c59e122
Add check_polar update, locpot update.
knc6 Dec 27, 2023
b4b4583
Locpot pytest.
knc6 Dec 27, 2023
5848753
X locpot.
knc6 Dec 27, 2023
a9b358b
Merge branch 'master' into develop
knc6 Dec 27, 2023
fb6ee04
Lint.
knc6 Dec 27, 2023
b3cc4d5
Update figshare.py
knc6 Jan 4, 2024
a5ebbcc
Update tutorials.md for get_chem_only_descriptors (#309)
bobleesj Feb 23, 2024
4338922
Qsiqskit dversion and CFID chemical feature doc issue.
knc6 Feb 23, 2024
c361367
Update dev-requirements.txt
knc6 Feb 23, 2024
80e3a3f
Update dev-requirements.txt
knc6 Feb 23, 2024
881769b
Update dev-requirements.txt
knc6 Feb 23, 2024
0c3947e
Update inputs.py
knc6 Feb 23, 2024
b9b50a7
Update figshare.py
knc6 Feb 27, 2024
ee52d55
Update figshare.py
knc6 Mar 6, 2024
da06e54
chore: update .gitignore to add pycharm .idea
timurbazhirov Mar 14, 2024
fa34558
improvements: clone method and remove multiple sites, including in place
timurbazhirov Mar 14, 2024
dbc7075
tests: attempt adding tests for the new functionality
timurbazhirov Mar 14, 2024
d0fdc26
Merge pull request #1 from Exabyte-io/improvement/atoms-clone-remove-…
timurbazhirov Mar 14, 2024
d124ffb
Flake8 fix.
knc6 Mar 19, 2024
fe89b4e
Add pydantic.
knc6 Mar 19, 2024
f00616a
wien2k fix.
knc6 Mar 19, 2024
b9fbc07
Comment out qiskit related tests.
knc6 Mar 20, 2024
e0419b2
Fix OneHotEncoder.
knc6 Mar 20, 2024
6733a9b
Check conda
knc6 Mar 20, 2024
7ea36a9
Update action_build.yml
knc6 Mar 20, 2024
4ce18a0
Update action_build.yml
knc6 Mar 20, 2024
c367f2e
Update action_build.yml
knc6 Mar 20, 2024
cd7dc67
Update action_build.yml
knc6 Mar 20, 2024
f29dfca
Update action_build.yml
knc6 Mar 20, 2024
8819263
Update action_build.yml
knc6 Mar 20, 2024
eb750d9
Update action_build.yml
knc6 Mar 20, 2024
d040e31
Update action_build.yml
knc6 Mar 20, 2024
1966e45
Update action_build.yml
knc6 Mar 20, 2024
fecb22b
Update action_build.yml
knc6 Mar 20, 2024
d8569f4
Update action_build.yml
knc6 Mar 20, 2024
650a00e
Update docs.
knc6 Mar 20, 2024
9201217
Update index.md
knc6 Mar 20, 2024
8baa9dd
Update index.md
knc6 Mar 20, 2024
30bbc0e
Merge branch 'master' into develop
knc6 Mar 20, 2024
e2aebfc
Minor lint fix.
knc6 Mar 20, 2024
fff2bc5
Update deploy_nist_pages.yml
knc6 Mar 20, 2024
4a1b2b5
Merge pull request #2 from usnistgov/master
timurbazhirov Mar 20, 2024
67e6dbe
Merge pull request #3 from usnistgov/develop
timurbazhirov Mar 20, 2024
17deed0
fix: lint
timurbazhirov Mar 22, 2024
01e91fc
Fix bug in the PR.
knc6 Mar 28, 2024
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@ ENV/
# mypy
.mypy_cache/

.pytest_cache/
.pytest_cache/

# pycharm
.idea

122 changes: 72 additions & 50 deletions jarvis/core/atoms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module provides classes to specify atomic structure."""

import numpy as np
from jarvis.core.composition import Composition
from jarvis.core.specie import Specie, atomic_numbers_to_symbols
Expand Down Expand Up @@ -698,14 +699,23 @@ def from_dict(self, d={}):

def remove_site_by_index(self, site=0):
"""Remove an atom by its index number."""
return self.remove_sites_by_indices(indices=[site])

def remove_sites_by_indices(self, indices=[0], in_place=False):
"""Remove multiple atoms by their corresponding indices number."""
new_els = []
new_coords = []
new_props = []
for ii, i in enumerate(self.frac_coords):
if ii != site:
if ii not in indices:
new_els.append(self.elements[ii])
new_coords.append(self.frac_coords[ii])
new_props.append(self.props[ii])
if in_place:
self.elements = new_els
self.coords = new_coords
self.props = new_props
return self
return Atoms(
lattice_mat=self.lattice_mat,
elements=new_els,
Expand Down Expand Up @@ -1268,49 +1278,50 @@ def make_supercell(self, dim=[2, 2, 2]):
dim = np.array(dim)
if dim.shape == (3, 3):
dim = np.array([int(np.linalg.norm(v)) for v in dim])
coords = self.frac_coords
all_symbs = self.elements # [i.symbol for i in s.species]
nat = len(coords)

new_nat = nat * dim[0] * dim[1] * dim[2]
new_coords = np.zeros((new_nat, 3))
new_symbs = [] # np.chararray((new_nat))
props = [] # self.props

ct = 0
for i in range(nat):
for j in range(dim[0]):
for k in range(dim[1]):
for m in range(dim[2]):
props.append(self.props[i])
new_coords[ct][0] = (coords[i][0] + j) / float(dim[0])
new_coords[ct][1] = (coords[i][1] + k) / float(dim[1])
new_coords[ct][2] = (coords[i][2] + m) / float(dim[2])
new_symbs.append(all_symbs[i])
ct = ct + 1

nat = new_nat

nat = len(coords) # int(s.composition.num_atoms)
lat = np.zeros((3, 3))
box = self.lattice_mat
lat[0][0] = dim[0] * box[0][0]
lat[0][1] = dim[0] * box[0][1]
lat[0][2] = dim[0] * box[0][2]
lat[1][0] = dim[1] * box[1][0]
lat[1][1] = dim[1] * box[1][1]
lat[1][2] = dim[1] * box[1][2]
lat[2][0] = dim[2] * box[2][0]
lat[2][1] = dim[2] * box[2][1]
lat[2][2] = dim[2] * box[2][2]
super_cell = Atoms(
lattice_mat=lat,
coords=new_coords,
elements=new_symbs,
props=props,
cartesian=False,
)
return super_cell
return self.make_supercell_matrix(dim)
# coords = self.frac_coords
# all_symbs = self.elements # [i.symbol for i in s.species]
# nat = len(coords)

# new_nat = nat * dim[0] * dim[1] * dim[2]
# new_coords = np.zeros((new_nat, 3))
# new_symbs = [] # np.chararray((new_nat))
# props = [] # self.props

# ct = 0
# for i in range(nat):
# for j in range(dim[0]):
# for k in range(dim[1]):
# for m in range(dim[2]):
# props.append(self.props[i])
# new_coords[ct][0] = (coords[i][0] + j) / float(dim[0])
# new_coords[ct][1] = (coords[i][1] + k) / float(dim[1])
# new_coords[ct][2] = (coords[i][2] + m) / float(dim[2])
# new_symbs.append(all_symbs[i])
# ct = ct + 1

# nat = new_nat

# nat = len(coords) # int(s.composition.num_atoms)
# lat = np.zeros((3, 3))
# box = self.lattice_mat
# lat[0][0] = dim[0] * box[0][0]
# lat[0][1] = dim[0] * box[0][1]
# lat[0][2] = dim[0] * box[0][2]
# lat[1][0] = dim[1] * box[1][0]
# lat[1][1] = dim[1] * box[1][1]
# lat[1][2] = dim[1] * box[1][2]
# lat[2][0] = dim[2] * box[2][0]
# lat[2][1] = dim[2] * box[2][1]
# lat[2][2] = dim[2] * box[2][2]
# super_cell = Atoms(
# lattice_mat=lat,
# coords=new_coords,
# elements=new_symbs,
# props=props,
# cartesian=False,
# )
# return super_cell

def get_lll_reduced_structure(self):
"""Get LLL algorithm based reduced structure."""
Expand Down Expand Up @@ -1431,6 +1442,17 @@ def get_string(self, cart=True, sort_order="X"):
result = header + middle + rest
return result

def clone(self):
"""Clones the class instance."""
return Atoms(
lattice_mat=self.lattice_mat,
elements=self.elements,
coords=self.frac_coords,
props=self.props,
cartesian=self.cartesian,
show_props=self.show_props,
)


class VacuumPadding(object):
"""Adds vaccum padding to make 2D structure or making molecules."""
Expand Down Expand Up @@ -1860,18 +1882,18 @@ def to_optimade(
info_at["cartesian_site_positions"] = atoms.cart_coords[order].tolist()
info_at["nperiodic_dimensions"] = 3
# info_at["species"] = atoms.elements
info_at[
"species"
] = self.get_optimade_species() # dict(atoms.composition.to_dict())
info_at["species"] = (
self.get_optimade_species()
) # dict(atoms.composition.to_dict())
info_at["elements_ratios"] = list(
atoms.composition.atomic_fraction.values()
)
info_at["structure_features"] = []
info_at["last_modified"] = str(now)
# info_at["more_data_available"] = True
info_at[
"chemical_formula_descriptive"
] = atoms.composition.reduced_formula
info_at["chemical_formula_descriptive"] = (
atoms.composition.reduced_formula
)
info_at["dimension_types"] = [1, 1, 1]
info["attributes"] = info_at
return info
Expand Down
82 changes: 68 additions & 14 deletions jarvis/tests/testfiles/core/test_atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
OptimadeAdaptor,
)


import numpy as np
import os
from jarvis.db.figshare import get_jid_data, data
import tarfile
import tempfile

FIXTURES = {
"lattice_mat": [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]],
"coords": [[0, 0, 0], [0.25, 0.2, 0.25]],
"elements": ["Si", "Si"],
}

new_file, filename = tempfile.mkstemp()


Expand Down Expand Up @@ -55,11 +61,26 @@
"POSCAR",
)

cif_example = os.path.join(os.path.dirname(__file__), "1000052.cif",)
cif_example2 = os.path.join(os.path.dirname(__file__), "Bacomp.cif",)
cif_example3 = os.path.join(os.path.dirname(__file__), "mock.cif",)
cif_example4 = os.path.join(os.path.dirname(__file__), "exp_000034.cif",)
cif_example5 = os.path.join(os.path.dirname(__file__), "1000000.cif",)
cif_example = os.path.join(
os.path.dirname(__file__),
"1000052.cif",
)
cif_example2 = os.path.join(
os.path.dirname(__file__),
"Bacomp.cif",
)
cif_example3 = os.path.join(
os.path.dirname(__file__),
"mock.cif",
)
cif_example4 = os.path.join(
os.path.dirname(__file__),
"exp_000034.cif",
)
cif_example5 = os.path.join(
os.path.dirname(__file__),
"1000000.cif",
)


def test_from_cif():
Expand All @@ -76,10 +97,11 @@ def test_from_cif():

def test_basic_atoms():

box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
coords = [[0, 0, 0], [0.25, 0.2, 0.25]]
elements = ["Si", "Si"]
Si = Atoms(lattice_mat=box, coords=coords, elements=elements)
Si = Atoms(
lattice_mat=FIXTURES["lattice_mat"],
coords=FIXTURES["coords"],
elements=FIXTURES["elements"],
)
dim = get_supercell_dims(Si)
build_xanes_poscar(atoms=Si, filename_with_prefix=True)
assert dim == [3, 3, 3]
Expand Down Expand Up @@ -109,8 +131,8 @@ def test_basic_atoms():
prim = Si.get_primitive_atoms
print(prim.cart_coords)
conv = Si.get_conventional_atoms
spgn=Si.get_spacegroup
comp=compare_atoms(atoms1=prim,atoms2=conv)
spgn = Si.get_spacegroup
comp = compare_atoms(atoms1=prim, atoms2=conv)
assert round(prim.cart_coords[0][0], 2) == round(4.37815150, 2)
# print ('raw_distance_matrix', prim.raw_distance_matrix)
# print ('raw_distance_matrix', Si.raw_distance_matrix)
Expand Down Expand Up @@ -209,5 +231,37 @@ def test_basic_atoms():
os.system(cmd)


# test_basic_atoms()
# def test_basic_atoms():
def test_clone():
Si = Atoms(
lattice_mat=FIXTURES["lattice_mat"],
coords=FIXTURES["coords"],
elements=FIXTURES["elements"],
)
Si2 = Si.clone()
np.testing.assert_array_equal(Si2.lattice_mat, Si.lattice_mat)
np.testing.assert_array_equal(Si2.coords, Si.coords)
assert Si2.props == Si.props
assert Si2.elements == Si.elements
assert Si2.cartesian == Si.cartesian
assert Si2.show_props == Si.show_props


def test_remove_sites_by_indices():
Si = Atoms(
lattice_mat=FIXTURES["lattice_mat"],
coords=FIXTURES["coords"],
elements=FIXTURES["elements"],
)
Si_supercell = Si.make_supercell([2, 2, 2])
print("Si_supercell", Si_supercell)
Si2_supercell_without_two_atoms = Si_supercell.remove_sites_by_indices(
indices=[0, 1]
)
print(
"Si2_supercell_without_two_atoms.num_atoms",
Si2_supercell_without_two_atoms.num_atoms,
)
assert Si2_supercell_without_two_atoms.num_atoms == 14


# test_remove_sites_by_indices()
Loading