From 5afd9346a834fcb91ae1650d25b9ebbae72ac0f8 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 20 Oct 2024 17:10:59 -0400 Subject: [PATCH] Use ternary config to generate extra lines and skip files with error --- core/configs/ternary.py | 2 ++ core/site/handler.py | 9 ++++++--- core/system/ternary.py | 29 ++++++++++++++--------------- main.py | 4 ---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/core/configs/ternary.py b/core/configs/ternary.py index 454c437..dd374ae 100644 --- a/core/configs/ternary.py +++ b/core/configs/ternary.py @@ -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"] diff --git a/core/site/handler.py b/core/site/handler.py index e6371a6..d31d573 100644 --- a/core/site/handler.py +++ b/core/site/handler.py @@ -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 = {} diff --git a/core/system/ternary.py b/core/system/ternary.py index b22c621..8c9397a 100644 --- a/core/system/ternary.py +++ b/core/system/ternary.py @@ -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): @@ -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 @@ -358,16 +363,14 @@ 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) @@ -375,32 +378,28 @@ def draw_extra_frame(pair, p1_x, p1_y, p2_x, p2_y): # 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) diff --git a/main.py b/main.py index 16c3c4a..a083c51 100644 --- a/main.py +++ b/main.py @@ -5,10 +5,6 @@ python main.py Author: Sangjoon Bob Lee - -Last update: June 23, 2024 -Release date: Mar 10, 2024 - """ import os