Skip to content
Snippets Groups Projects
Commit 17692469 authored by adaramo2's avatar adaramo2
Browse files

Edit glass.py

parent 6d14a8fb
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,19 @@ plt.rcParams.update({ ...@@ -23,7 +23,19 @@ plt.rcParams.update({
'axes.labelweight': 'bold' 'axes.labelweight': 'bold'
}) })
######################################
# Helper Function to Get Project Root
######################################
def get_project_root():
"""
Returns the project root directory.
Assumes this file is in a container inside the project.
"""
return os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
######################################
# --- Utility Functions for GR Files --- # --- Utility Functions for GR Files ---
######################################
def read_gr_file(file_path): def read_gr_file(file_path):
""" """
Read a GR file and return: Read a GR file and return:
...@@ -54,7 +66,9 @@ def find_cutoff_distance(r, gr): ...@@ -54,7 +66,9 @@ def find_cutoff_distance(r, gr):
return r[i] return r[i]
return 3.0 return 3.0
######################################
# --- Helper Function to Draw a Closed Cube --- # --- Helper Function to Draw a Closed Cube ---
######################################
def draw_closed_cube(ax, x_min, x_max, y_min, y_max, z_min, z_max): def draw_closed_cube(ax, x_min, x_max, y_min, y_max, z_min, z_max):
""" """
Draw a closed cube (with 12 edges) on the given 3D axis. Draw a closed cube (with 12 edges) on the given 3D axis.
...@@ -80,16 +94,19 @@ def draw_closed_cube(ax, x_min, x_max, y_min, y_max, z_min, z_max): ...@@ -80,16 +94,19 @@ def draw_closed_cube(ax, x_min, x_max, y_min, y_max, z_min, z_max):
[p1[2], p2[2]], [p1[2], p2[2]],
color='black', linestyle='-', linewidth=2) color='black', linestyle='-', linewidth=2)
######################################
# --- Main Application Class --- # --- Main Application Class ---
######################################
class SilicaNetworkAnalyzer(QMainWindow): class SilicaNetworkAnalyzer(QMainWindow):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.setWindowTitle("Silica Glass Network Analyzer") self.setWindowTitle("Silica Glass Network Analyzer")
self.setGeometry(100, 100, 500, 800) # reduced width since plot area is removed self.setGeometry(100, 100, 500, 800) # reduced width since plot area is removed
# Directories for GR and XYZ files: # Directories for GR and XYZ files are now built relative to the project root.
self.gr_directory = "Large_box/Large/Accumulation_dependence/" root = get_project_root()
self.xyz_directory = "Large_box/Large/Accumulation_dependence/DFT_box/" self.gr_directory = os.path.join(root, "Large_box", "Large", "Accumulation_dependence")
self.xyz_directory = os.path.join(root, "Large_box", "Large", "Accumulation_dependence", "DFT_box")
# Data storage # Data storage
self.atoms = [] # List of tuples: (element, np.array([x,y,z])) self.atoms = [] # List of tuples: (element, np.array([x,y,z]))
...@@ -144,8 +161,6 @@ class SilicaNetworkAnalyzer(QMainWindow): ...@@ -144,8 +161,6 @@ class SilicaNetworkAnalyzer(QMainWindow):
self.ring_example_btn.clicked.connect(self.show_ring_example) self.ring_example_btn.clicked.connect(self.show_ring_example)
control_layout.addWidget(self.ring_example_btn) control_layout.addWidget(self.ring_example_btn)
# Removed the "Save Current Plot" button since plots are external
# Input for maximum number of Si atoms to plot (to avoid overcrowding) # Input for maximum number of Si atoms to plot (to avoid overcrowding)
control_layout.addWidget(QLabel("Max Si atoms to plot:")) control_layout.addWidget(QLabel("Max Si atoms to plot:"))
self.max_atoms_input = QLineEdit("500") self.max_atoms_input = QLineEdit("500")
...@@ -613,5 +628,4 @@ if __name__ == "__main__": ...@@ -613,5 +628,4 @@ if __name__ == "__main__":
app = QApplication(sys.argv) app = QApplication(sys.argv)
window = SilicaNetworkAnalyzer() window = SilicaNetworkAnalyzer()
window.show() window.show()
sys.exit(app.exec_()) sys.exit(app.exec_())
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment