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

Edit Hydrogen.py

parent 6356ba5c
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,16 @@ plt.rcParams.update({
'axes.labelweight': 'bold'
})
######################################
# Helper function: Project Root
######################################
def get_project_root():
"""
Returns the project root directory.
Assumes this file is in a container (e.g., 'src') inside the project.
"""
return os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
######################################
# Data Reading and Analysis Functions
######################################
......@@ -292,7 +302,7 @@ def plot_ring_clusters_detail_3d(hbonds, molecules, selected_clusters=None, crop
legend_added[ring_size] = True
else:
ax.plot(x, y, z, color=color_map[ring_size], linewidth=3)
# NEW: Highlight the water molecules that form this ring.
# Highlight the water molecules that form this ring.
for i_node in ring:
ax.scatter(coords[i_node, 0], coords[i_node, 1], coords[i_node, 2],
color=color_map[ring_size], s=300, edgecolors='black', zorder=5)
......@@ -602,9 +612,8 @@ class MainWindow(QMainWindow):
cutoffGroup.setLayout(cutoffLayout)
control_layout.addWidget(cutoffGroup)
# File paths (adjust if necessary)
self.xyz_directory = "Large_box/Large/Accumulation_dependence/DFT_box/"
# GR file directory removed since not used.
# Set xyz_directory using the absolute project root path.
self.xyz_directory = os.path.join(get_project_root(), "Large_box", "Large", "Accumulation_dependence", "DFT_box")
# Plot style parameters
self.plot_params = {
......@@ -884,7 +893,7 @@ class MainWindow(QMainWindow):
f.write("Bar Plot Raw Data\n")
f.write("-----------------\n")
f.write(f"Plot type: {self.last_bar_plot_data.get('plot_type','')}\n")
f.write("H-bond-per-molecules\percentage (%) \n")
f.write("H-bond-per-molecules\tpercentage (%) \n")
for x, y in zip(self.last_bar_plot_data.get("x", []), self.last_bar_plot_data.get("y", [])):
f.write(f"{x}\t{y}\n")
QMessageBox.information(self, "Saved", f"Bar plot raw data saved as {fname}")
......
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