Skip to content

Commit

Permalink
Use ternary config to generate extra lines and skip files with error
Browse files Browse the repository at this point in the history
  • Loading branch information
bobleesj committed Oct 20, 2024
1 parent a452203 commit 5afd934
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 2 additions & 0 deletions core/configs/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
class TernaryConfig(Enum):
X_SHIFT = 0.0
Y_SHIFT = 0.0
TAGS_IN_FIRST_EXTRA_LINE = ["lt", "ht", "hp", "hp1", "hp2", "hp3"]
TAGS_IN_SECOND_EXTRA_LINE = ["trig", "ht_trig"]
9 changes: 6 additions & 3 deletions core/site/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ def get_site_pair_data_ordered_by_mendeleev(cif_ensemble: CifEnsemble):
start_time = time.perf_counter()

prompt_progress_current(i, cif.file_name, cif.supercell_atom_count, file_count)

mixing_info = cif.mixing_info_per_label_pair_sorted_by_mendeleev
shortest_distances = cif.shortest_site_pair_distance
try:
mixing_info = cif.mixing_info_per_label_pair_sorted_by_mendeleev
shortest_distances = cif.shortest_site_pair_distance
except Exception as e:
print(f"Error occured processing {cif.file_name}: {e}")
continue

# Alphabetically sort the label pair and find min distance per unique pair
unique_label_pair_distances = {}
Expand Down
29 changes: 14 additions & 15 deletions core/system/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from core.system.figure_util import (
shift_points_xy,
)
from core.configs.ternary import TernaryConfig


def get_point_in_triangle(vertices, R_norm_index, M_norm_index):
Expand Down Expand Up @@ -350,6 +351,10 @@ def draw_extra_frame(pair, p1_x, p1_y, p2_x, p2_y):
zorder=2,
lw=extra_edge_line_width,
)

# Get the tags for the first and second extra lines from configs/ternary.py
TAGS_IN_FIRST_EXTRA_LINE = TernaryConfig.TAGS_IN_FIRST_EXTRA_LINE.value
TAGS_IN_SECOND_EXTRA_LINE = TernaryConfig.TAGS_IN_SECOND_EXTRA_LINE.value

if A_label == R and B_label == M:
# ErCo
Expand All @@ -358,49 +363,43 @@ def draw_extra_frame(pair, p1_x, p1_y, p2_x, p2_y):
A_norm_index,
B_norm_index,
)
if tag == "hex" or tag == "rt":
if tag == "hex" or tag == "rt" or is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag == "lt":
elif tag in TAGS_IN_FIRST_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, 0.0, -0.1)
draw_extra_frame("RM", 0.0, -0.1, 0.0, -0.1)
elif tag == "ht":
elif tag in TAGS_IN_SECOND_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, 0.0, -0.2)
draw_extra_frame("RM", 0.0, -0.2, 0.0, -0.2)
elif is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag is not None:
center_pt = shift_points_xy(center_pt, 0.0, -0.3)
draw_extra_frame("RM", 0.0, -0.3, 0.0, -0.3)

# CoIn2
if A_label == M and B_label == X:
center_pt = get_point_in_triangle(vertices, 0, (1 - B_norm_index))
if tag == "hex" or tag == "rt":
if tag == "hex" or tag == "rt" or is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag == "lt":
elif tag in TAGS_IN_FIRST_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, 0.1, 0.0)
draw_extra_frame("MX", 0.1, 0.0, 0.1, 0.0)
elif tag == "ht":
elif tag in TAGS_IN_SECOND_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, 0.2, 0.0)
draw_extra_frame("MX", 0.2, 0.0, 0.2, 0.0)
elif is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag is not None:
center_pt = shift_points_xy(center_pt, 0.3, 0.0)
draw_extra_frame("MX", 0.3, 0.0, 0.3, 0.0)
# ErIn
if A_label == R and B_label == X:
center_pt = get_point_in_triangle(vertices, A_norm_index, 0.0)
if tag == "hex" or tag == "rt":
if tag == "hex" or tag == "rt" or is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag == "lt":
elif tag in TAGS_IN_FIRST_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, -0.1, 0.0)
draw_extra_frame("RX", -0.1, 0.0, -0.1, 0.0)
elif tag == "ht":
elif tag in TAGS_IN_SECOND_EXTRA_LINE:
center_pt = shift_points_xy(center_pt, -0.2, 0.0)
draw_extra_frame("RX", -0.2, 0.0, -0.2, 0.0)
elif is_formula_with_tag_in_main_line:
center_pt = center_pt
elif tag is not None:
center_pt = shift_points_xy(center_pt, -0.3, 0.0)
draw_extra_frame("RX", -0.3, 0.0, -0.3, 0.0)
Expand Down
4 changes: 0 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
python main.py
Author: Sangjoon Bob Lee
Last update: June 23, 2024
Release date: Mar 10, 2024
"""

import os
Expand Down

0 comments on commit 5afd934

Please sign in to comment.