Skip to content

Commit

Permalink
Add option for both IPF triangle up and down
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysgt committed Dec 3, 2024
1 parent bb80dbf commit b299f35
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 26 deletions.
57 changes: 40 additions & 17 deletions defdap/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,23 +1011,46 @@ def add_axis(self):
pad_y=0.005, va='bottom', ha='center', fontsize=12)

elif self.plot_type == "IPF" and self.crystal_sym == "hexagonal":
# line between [0001] and [10-10] ([001] and [210])
# converted to cubic axes
self.add_line([0, 0, 1], [np.sqrt(3), 1, 0], c='k', lw=2)

# line between [0001] and [2-1-10] ([001] and [100])
self.add_line([0, 0, 1], [1, 0, 0], c='k', lw=2)

# line between [2-1-10] and [10-10] ([100] and [210])
self.add_line([1, 0, 0], [np.sqrt(3), 1, 0], c='k', lw=2)

# label poles
self.label_point([0, 0, 1], '0001',
pad_y=-0.012, va='top', ha='center', fontsize=12)
self.label_point([1, 0, 0], r'$2\bar{1}\bar{1}0$',
pad_y=-0.012, va='top', ha='center', fontsize=12)
self.label_point([np.sqrt(3), 1, 0], r'$10\bar{1}0$',
pad_y=0.009, va='bottom', ha='center', fontsize=12)

triangle = 'aztec'

if triangle == 'aztec':
# line between [0001] and [01-10] ([001] and [2-10])
# converted to cubic axes
self.add_line([0, 0, 1], [np.sqrt(3), -1, 0], c='k', lw=2)

# line between [0001] and [-12-10] ([001] and [100])
self.add_line([0, 0, 1], [1, 0, 0], c='k', lw=2)

# line between [-12-10] and [01-10] ([100] and [2-10])
self.add_line([1, 0, 0], [np.sqrt(3), -1, 0], c='k', lw=2)

# label poles
self.label_point([0, 0, 1], '0001',
pad_y=0.012, va='bottom', ha='center', fontsize=12)
self.label_point([1, 0, 0], r'$\bar{1}2\bar{1}0$',
pad_y=0.012, va='bottom', ha='center', fontsize=12)
self.label_point([np.sqrt(3), -1, 0], r'$01\bar{1}0$',
pad_y=-0.006, va='top', ha='center', fontsize=12)

elif triangle == 'mtex':
# line between [0001] and [10-10] ([001] and [210])
# converted to cubic axes
self.add_line([0, 0, 1], [np.sqrt(3), 1, 0], c='k', lw=2)

# line between [0001] and [2-1-10] ([001] and [100])
self.add_line([0, 0, 1], [1, 0, 0], c='k', lw=2)

# line between [2-1-10] and [10-10] ([100] and [210])
self.add_line([1, 0, 0], [np.sqrt(3), 1, 0], c='k', lw=2)

# label poles
self.label_point([0, 0, 1], '0001',
pad_y=-0.012, va='top', ha='center', fontsize=12)
self.label_point([1, 0, 0], r'$2\bar{1}\bar{1}0$',
pad_y=-0.012, va='top', ha='center', fontsize=12)
self.label_point([np.sqrt(3), 1, 0], r'$10\bar{1}0$',
pad_y=0.009, va='bottom', ha='center', fontsize=12)

else:
raise NotImplementedError("Only works for cubic and hexagonal.")
Expand Down
35 changes: 26 additions & 9 deletions defdap/quat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,15 +1052,32 @@ def calc_fund_dirs(
alpha_fund = alpha[min_alpha_idx, np.arange(len(min_alpha_idx))]

elif sym_group == "hexagonal":
# first beta should be between 0 and 30 deg leaving 1
# symmetric equivalent per orientation
trial_poles = np.logical_and(beta >= 0, beta <= np.pi / 6)
# if less than 1 left need to expand search slightly to
# catch edge cases
if np.any(np.sum(trial_poles, axis=0) < 1):
delta_beta = 1e-8
trial_poles = np.logical_and(beta >= -delta_beta,
beta <= np.pi / 6 + delta_beta)

triangle = 'aztec'

if triangle == 'aztec':

# first beta should be between 0 and 30 deg leaving 1
# symmetric equivalent per orientation
trial_poles = np.logical_and(beta <= 0, beta >= -np.pi / 6)
# if less than 1 left need to expand search slightly to
# catch edge cases
if np.any(np.sum(trial_poles, axis=0) < 1):
delta_beta = 1e-8
trial_poles = np.logical_and(beta >= delta_beta,
beta <= - (np.pi / 6 + delta_beta))

if triangle == 'mtex':

# first beta should be between -30 and 0 deg leaving 1
# symmetric equivalent per orientation
trial_poles = np.logical_and(beta >= 0, beta <= np.pi / 6)
# if less than 1 left need to expand search slightly to
# catch edge cases
if np.any(np.sum(trial_poles, axis=0) < 1):
delta_beta = 1e-8
trial_poles = np.logical_and(beta >= -delta_beta,
beta <= np.pi / 6 + delta_beta)

# non-indexed points cause more than 1 symmetric equivalent, use this
# to pick one and filter non-indexed points later
Expand Down

0 comments on commit b299f35

Please sign in to comment.