Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
gduscher committed Jan 27, 2024
1 parent f3b325a commit 58cc9e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
Expand Down
41 changes: 21 additions & 20 deletions pyTEMlib/crystal_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,26 @@ def get_projection(crystal, layers=1):
for pro in projected:
atomic_numbers.append(projected_crystal.get_atomic_numbers()[pro].sum())

projected_crystal.rotate(np.degrees(angle)%360, 'z', rotate_cell=True)
projected_crystal.rotate(np.degrees(angle) % 360, 'z', rotate_cell=True)

near_base = np.array([projected_crystal.cell[0,:2], -projected_crystal.cell[0,:2],
projected_crystal.cell[1,:2], -projected_crystal.cell[1,:2],
projected_crystal.cell[0,:2] + projected_crystal.cell[1,:2],
-(projected_crystal.cell[0,:2] + projected_crystal.cell[1,:2])])
lines = np.array( [[[0, near_base[0,0]],[0, near_base[0,1]]],
[[0, near_base[2,0]],[0, near_base[2,1]]],
[[near_base[0,0], near_base[4,0]],[near_base[0,1], near_base[4,1]]],
[[near_base[2,0], near_base[4,0]],[near_base[2,1], near_base[4,1]]]])
near_base = np.array([projected_crystal.cell[0, :2], -projected_crystal.cell[0, :2],
projected_crystal.cell[1, :2], -projected_crystal.cell[1, :2],
projected_crystal.cell[0, :2] + projected_crystal.cell[1, :2],
-(projected_crystal.cell[0, :2] + projected_crystal.cell[1, :2])])
lines = np.array([[[0, near_base[0, 0]], [0, near_base[0, 1]]],
[[0, near_base[2, 0]], [0, near_base[2, 1]]],
[[near_base[0, 0], near_base[4, 0]], [near_base[0, 1], near_base[4, 1]]],
[[near_base[2, 0], near_base[4, 0]], [near_base[2, 1], near_base[4, 1]]]])
projected_atoms = []
for index in projected:
projected_atoms.append(index[0])
projected_atoms.append(index[0])

projected_crystal.info['projection']={'indices': projected,
'projected': projected_atoms,
'projected_Z': atomic_numbers,
'angle': np.degrees(angle)+180%360,
'near_base': near_base,
'lines': lines}
projected_crystal.info['projection'] = {'indices': projected,
'projected': projected_atoms,
'projected_Z': atomic_numbers,
'angle': np.degrees(angle)+180 % 360,
'near_base': near_base,
'lines': lines}
return projected_crystal


Expand Down Expand Up @@ -287,7 +287,8 @@ def ball_and_stick(atoms, extend=1, max_bond_length=0.):
for (k, s) in bond_matrix.keys():
if k > s:
del_double.append((k, s))
for key in del_double[::-1]:
del_double.sort(reverse=False)
for key in del_double:
bond_matrix.pop(key)

if super_cell.info is None:
Expand All @@ -298,7 +299,7 @@ def ball_and_stick(atoms, extend=1, max_bond_length=0.):
return super_cell


def plot_unit_cell(atoms, extend=1, max_bond_length=1.0, ax = None):
def plot_unit_cell(atoms, extend=1, max_bond_length=1.0, ax=None):
"""
Simple plot of unit cell
"""
Expand All @@ -309,8 +310,8 @@ def plot_unit_cell(atoms, extend=1, max_bond_length=1.0, ax = None):
positions = super_cell.positions - super_cell.cell.lengths()/2

if ax is None:
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# draw unit_cell

for line in super_cell.info['plot_cell']['corner_matrix'].keys():
Expand Down

0 comments on commit 58cc9e6

Please sign in to comment.