Skip to content

Commit

Permalink
Atoms class update with props.
Browse files Browse the repository at this point in the history
  • Loading branch information
knc6 committed Sep 21, 2023
1 parent 157995a commit 6693721
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion jarvis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Version number."""
__version__ = "2023.08.10"
__version__ = "2023.09.20"

import os

Expand Down
23 changes: 17 additions & 6 deletions jarvis/core/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,7 @@ def atomwise_angle_and_radial_distribution(
and nbor_info["dist"][in1][i] * nbor_info["dist"][in2][i] != 0
]
ang_hist, ang_bins = np.histogram(
angles,
bins=np.arange(1, nbins + 2, 1),
density=False,
angles, bins=np.arange(1, nbins + 2, 1), density=False,
)
for jj, j in enumerate(angles):
actual_pangs[i, jj] = j
Expand Down Expand Up @@ -944,7 +942,7 @@ def center(self, axis=2, vacuum=18.0, about=None):
"""
cell = self.lattice_mat
p = self.cart_coords

props = self.props
dirs = np.zeros_like(cell)
for i in range(3):
dirs[i] = np.cross(cell[i - 1], cell[i - 2])
Expand Down Expand Up @@ -998,6 +996,7 @@ def center(self, axis=2, vacuum=18.0, about=None):
elements=self.elements,
coords=new_coords,
cartesian=True,
props=props,
)
return atoms

Expand Down Expand Up @@ -1066,6 +1065,7 @@ def center_around_origin(self, new_origin=[0.0, 0.0, 0.5]):
lat = self.lattice_mat
typ_sp = self.elements
natoms = self.num_atoms
props = self.props
# abc = self.lattice.lat_lengths()
COM = self.get_origin()
# COM = self.get_center_of_mass()
Expand All @@ -1080,7 +1080,11 @@ def center_around_origin(self, new_origin=[0.0, 0.0, 0.5]):
z[i] = self.frac_coords[i][2] - COM[2] + new_origin[2]
coords.append([x[i], y[i], z[i]])
struct = Atoms(
lattice_mat=lat, elements=typ_sp, coords=coords, cartesian=False
lattice_mat=lat,
elements=typ_sp,
coords=coords,
cartesian=False,
props=props,
)
return struct

Expand Down Expand Up @@ -1604,7 +1608,9 @@ def fix_pbc(atoms):
)


def add_atoms(top, bottom, distance=[0, 0, 1], apply_strain=False):
def add_atoms(
top, bottom, distance=[0, 0, 1], apply_strain=False, add_tags=True
):
"""
Add top and bottom Atoms with a distance array.
Expand All @@ -1623,10 +1629,12 @@ def add_atoms(top, bottom, distance=[0, 0, 1], apply_strain=False):
# print("strain_x,strain_y", strain_x, strain_y)
elements = []
coords = []
props = []
lattice_mat = bottom.lattice_mat
for i, j in zip(bottom.elements, bottom.frac_coords):
elements.append(i)
coords.append(j)
props.append("bottom")
top_cart_coords = lattice_coords_transformer(
new_lattice_mat=top.lattice_mat,
old_lattice_mat=bottom.lattice_mat,
Expand All @@ -1636,6 +1644,7 @@ def add_atoms(top, bottom, distance=[0, 0, 1], apply_strain=False):
for i, j in zip(top.elements, top_frac_coords):
elements.append(i)
coords.append(j)
props.append("top")

order = np.argsort(np.array(elements))
elements = np.array(elements)[order]
Expand All @@ -1651,8 +1660,10 @@ def add_atoms(top, bottom, distance=[0, 0, 1], apply_strain=False):
lattice_mat=lattice_mat,
coords=coords,
elements=elements,
props=props,
cartesian=False,
).center_around_origin()
###print('combined props',combined)
return combined


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="jarvis-tools",
version="2023.08.10",
version="2023.09.20",
long_description=long_d,
install_requires=[
"numpy>=1.20.1",
Expand Down

0 comments on commit 6693721

Please sign in to comment.