Skip to content

Commit

Permalink
Merge pull request #8 from IdahoLabResearch/HyPAT_v2.0
Browse files Browse the repository at this point in the history
Updating HyPAT to v2.0. This primarily adds the "Absorption Plots" tab. It also fixes bug, performs smalls cosmetic changes, cleans up the code, improves error handling, and adds some small functionality in/on/to the other tabs.
  • Loading branch information
GeorgeEvans0 authored Dec 21, 2022
2 parents 1ff0881 + 0a324df commit a16c310
Show file tree
Hide file tree
Showing 32 changed files with 3,007 additions and 301 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ default_entry_vars and o-ring_data are used for some variables on the Permeation
material_data and melting_tempK are used primarily in the Overview Plots tab, although they also provide the information used in the Permeation Estimates menu for sample material

persistent_permeation_input_variables is used in the Permeation Plots tab

persistent_absorption_input_variables is used in the Absorption Plots tab
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added HyPAT/data_files/default_entry_vals.xlsx
Binary file not shown.
Binary file added HyPAT/data_files/material_data.xlsx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed HyPAT/datafiles/default_entry_vals.xlsx
Binary file not shown.
Binary file removed HyPAT/datafiles/default_entry_vars.xlsx
Binary file not shown.
Binary file removed HyPAT/datafiles/material_data.xlsx
Binary file not shown.
6 changes: 3 additions & 3 deletions HyPAT/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
""" Hydrogen Permeation Analysis Tool (HyPAT)
""" Hydrogen Permeation and Absorption Tool (HyPAT)
Python Interpreter: 3.8, 3.9, or 3.10
Python Packages: matplotlib, pandas, numpy, tkmacosx, mplcursors, scipy, and openpyxl
Python Packages: Matplotlib, Pandas, NumPy, tkmacosx, mplcursors, SciPy, and openpyxl
compatible: macOS and Windows 10 """
compatible: macOS 12 and Windows 10 """
from source_code.application import Application


Expand Down
2,339 changes: 2,339 additions & 0 deletions HyPAT/source_code/absorption_plots.py

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions HyPAT/source_code/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
from . import permeation_estimates
from . import overview_plots
from . import permeation_plots
from . import absorption_plots


class Application(tk.Tk):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Change the default font for text boxes to TkDefaultFont. This mostly affects
# the help window of the permeation_plot.py's settings, but may affect other places
# the help window of the permeation_plot.py's and absorption_plot.py's settings, but may affect other places
default_font = font.nametofont("TkFixedFont")
default_font.configure(family=font.nametofont("TkDefaultFont").cget("family"),
size=font.nametofont("TkDefaultFont").cget("size"))

self.title("Hydrogen Permeation Analysis Tool")
self.title("Hydrogen Permeation and Absorption Tool")
self.resizable(width=None, height=None)
self.minsize(900, 600)

# size of gui based of size of widgets
# size of gui based off size of widgets
# this could be calculated later but would result in the gui appearing then moving to the center.
width = 1429
height = 750
Expand All @@ -34,7 +35,7 @@ def __init__(self, *args, **kwargs):
self.geometry("{}x{}+{}+{}".format(width, height, pos_right, pos_down))

# Ensure the program stops when the window is closed (counteracts a bug brought in from using
# constrained_layouts = True in the permeation_plots.py code)
# constrained_layouts = True in the permeation_plots.py and absorption_plots.py code)
self.protocol("WM_DELETE_WINDOW", self.quit_me)

self.storage = data_storage.Storage()
Expand All @@ -48,7 +49,7 @@ def __init__(self, *args, **kwargs):

def quit_me(self):
""" Ensure the program ends when window is closed """
# This counteracts a bug brought in by constrained_layout=True in the permeation_plots code
# This counteracts a bug brought in by constrained_layout=True in the permeation_plots and absorption_plots code
# Function found at https://stackoverflow.com/a/55206851
self.quit()
self.destroy()
Expand All @@ -57,7 +58,9 @@ def load_pages(self):
""" Load the GUI with the pages containing the calculations """
front_page = permeation_estimates.InputForm(self.notebook, self.storage) # Permeation estimates
experiment_plots_page = permeation_plots.PermeationPlots(self.notebook, self.storage) # Permeation plots
absorption_plots_page = absorption_plots.AbsorptionPlots(self.notebook, self.storage) # Absorption plots
overview_plots_page = overview_plots.Plots(self.notebook, self.storage) # Theoretical plots (Overview)
self.notebook.add(front_page, text="Permeation Estimates")
self.notebook.add(experiment_plots_page, text="Permeation Plots")
self.notebook.add(absorption_plots_page, text="Absorption Plots")
self.notebook.add(overview_plots_page, text="Overview Plots")
32 changes: 17 additions & 15 deletions HyPAT/source_code/data_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pandas as pd
import os
import platform # allows for Mac vs Windows adaptions
import platform # allows for Mac vs. Windows adaptions


class Storage:
Expand All @@ -16,21 +16,21 @@ def __init__(self):

# Create dataframes to store values for updating source spreadsheets.
# First the material_data spreadsheet
filename = os.path.join('datafiles', 'material_data.xlsx')
filename = os.path.join('data_files', 'material_data.xlsx')
self.material_data = pd.read_excel(filename, header=[0, 1],
engine="openpyxl") # openpyxl supports .xlsx but not .xls
# set up the index using material names
self.material_data.set_index(('Unnamed: 0_level_0', "Material"), inplace=True)
self.material_data.rename_axis("Material", axis="index", inplace=True)
# Next for the melting_tempK file
melt_filename = os.path.join('datafiles', 'melting_tempK.xlsx')
melt_filename = os.path.join('data_files', 'melting_tempK.xlsx')
self.melting_tempK = pd.read_excel(melt_filename, engine="openpyxl")
self.melting_tempK.set_index("Material", inplace=True)

# Read the o-ring data off an Excel sheet into a convenient dataframe.
# (1/2, 1/4 VCR data comes from https://www.swagelok.com/downloads/webcatalogs/en/ms-01-24.pdf,
# page 17 Silver Plated Nonretained)
self.oring_filename = os.path.join('datafiles', 'o-ring_data.xlsx')
self.oring_filename = os.path.join('data_files', 'o-ring_data.xlsx')
self.oring_info = pd.read_excel(self.oring_filename, header=0, index_col=0)
self.oring_info_4file = self.oring_info.copy() # Duplicate used exclusively for saving to the o-ring file

Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(self):
self.sample_material.trace_add("write", self.update_properties)

# Read the file for some default values
self.defaults_filename = os.path.join('datafiles', 'default_entry_vals.xlsx')
self.defaults_filename = os.path.join('data_files', 'default_entry_vals.xlsx')
self.defaults_info = pd.read_excel(self.defaults_filename, header=0)

# Calibrated Leak Rate
Expand All @@ -91,8 +91,8 @@ def __init__(self):
self.t_L = tk.DoubleVar(value=0) # Estimated time lag
self.Phi = tk.DoubleVar(value=0) # Estimated permeability
self.flux = tk.DoubleVar(value=0) # Estimated molar flux
self.flux_atoms = tk.DoubleVar(value=0) # Estimated atomic flux
self.Q = tk.DoubleVar(value=0) # Estimated permeation rate
self.flux_atoms = tk.DoubleVar(value=0) # Estimated atomic flux
self.Q = tk.DoubleVar(value=0) # Estimated molecular permeation rate
self.del_sP = tk.DoubleVar(value=0) # Estimated rate of pressure increase, Torr/s
self.del_sP_Pa = tk.DoubleVar(value=0) # /\, Pa/s
self.sP_final = tk.DoubleVar(value=0) # Estimated final secondary side pressure, Torr
Expand All @@ -104,13 +104,15 @@ def __init__(self):

# tolerance used for finding steady state during permeation data analysis
self.tol = tk.DoubleVar(value=1e-6)
# minimum number of seconds following t0 before finding a steady state
self.t_del = tk.DoubleVar(value=100)
# default number of data points used in determining leak and/or steady state
# minimum number of seconds following t0 before finding a steady state or equilibrium
self.t_del = tk.DoubleVar(value=100) # Note, as of 5/28/22, this isn't used in absorption_plots.py
# default number of data points used in determining leak, steady state, and/or equilibrium
self.gen_dp_range = tk.IntVar(value=30)

# store the permeation calculations
self.PermeationParameters = pd.DataFrame()
# store the transport properties calculations
self.TransportParameters = pd.DataFrame()
self.PTransportParameters = pd.DataFrame()
self.ATransportParameters = pd.DataFrame()

def connect_variables(self):
""" Set up variables so that functions are triggered if they are changed"""
Expand Down Expand Up @@ -146,10 +148,10 @@ def load_data():
diffusivity and solubility. Use that information to calculate those respective number for permeability.
Read in the melting temp if available. Combine this all into a dataframe and return that dataframe """
# read in diffusivity and solubility data
# todo It'd be nice to have the user select a file similar to "SaveFileExample.xlsx" in the datafiles folder
# todo It'd be nice to have the user select a file similar to "SaveFileExample.xlsx" in the data_files folder
# then if two of the three quantities (diffusivity, solubility, permeability) are present, the third
# will be calculated. This can be similar to how it is done in overview_plots.py - EditMaterials class.
filename = os.path.join('datafiles', 'material_data.xlsx')
filename = os.path.join('data_files', 'material_data.xlsx')
df = pd.read_excel(filename, header=[0, 1], engine="openpyxl") # openpyxl supports .xlsx file format, not .xls
# set up the index using material names
df.set_index(('Unnamed: 0_level_0', "Material"), inplace=True)
Expand All @@ -170,7 +172,7 @@ def round_to_13(df_col):
df[("Permeability", "max. temp. [K]")] = [min((df[col[3]][i], df[col[7]][i])) for i in range(len(df))]

# read in melting temp data
melt_filename = os.path.join('datafiles', 'melting_tempK.xlsx')
melt_filename = os.path.join('data_files', 'melting_tempK.xlsx')
df2 = pd.read_excel(melt_filename, engine="openpyxl")
df2.set_index("Material", inplace=True)

Expand Down
Loading

0 comments on commit a16c310

Please sign in to comment.