Example #1
0
    def init_widget(self, data, settings_name):
        """
        Populates the list with the available compositions, calculates interaction parameters, and creates a table
        to display the matrix
        :param data: Session data
        :param settings_name: Name of the current model setup
        :return:
        """
        self.settings = data["Model setups"][settings_name]
        self.thermopack = get_thermopack(category=self.settings["Model category"])

        list_names = []
        for i in range(self.composition_list.count()):
            list_names.append(self.composition_list.item(i).text())

        for list_name in self.component_lists.keys():

            if list_name in self.settings["Parameters"].keys():
                if "Pure fluid parameters" not in self.settings["Parameters"][list_name].keys():
                    self.settings["Parameters"][list_name]["Pure fluid parameters"] = {}

            else:
                self.settings["Parameters"][list_name] = {
                    "Coefficient matrices": {},
                    "Pure fluid parameters": {}
                }

            existing_matrices = self.settings["Parameters"][list_name]["Coefficient matrices"].keys()

            if "SAFT-VR Mie Epsilon" not in existing_matrices:
                # Create one tab for each list in QTabWidget
                self.calculate_matrix_data(list_name)

            self.epsilon_table = self.get_table(list_name, "SAFT-VR Mie Epsilon")
            self.sigma_table = self.get_table(list_name, "SAFT-VR Mie Sigma")
            self.gamma_table = self.get_table(list_name, "SAFT-VR Mie Gamma")

            self.epsilon_table.itemChanged.connect(
                lambda item: self.change_coeff(item, "SAFT-VR Mie Epsilon"))
            self.sigma_table.itemChanged.connect(
                lambda item: self.change_coeff(item, "SAFT-VR Mie Sigma"))
            self.gamma_table.itemChanged.connect(
                lambda item: self.change_coeff(item, "SAFT-VR Mie Gamma"))

            tab_widget = SAFTVRMieTabWidget(self.epsilon_table, self.sigma_table, self.gamma_table)

            if list_name not in self.tab_stack_indices.keys():
                index = self.tab_stack.addWidget(tab_widget)
                self.tab_stack_indices[list_name] = index

        self.init_composition_list()
        self.tab_stack.setCurrentIndex(0)
        self.pure_params_frame.hide()
        for button in self.component_btngroup.buttons():
            self.component_btngroup.removeButton(button)
            self.component_btn_layout.removeWidget(button)
            button.hide()
Example #2
0
    def __init__(self,
                 data,
                 json_file,
                 component_list_name,
                 model_settings_name,
                 parent=None):
        super().__init__(parent=parent)

        loadUi("gui/layouts/calc_mode.ui", self)
        self.setWindowTitle("Thermopack - Calculation Mode")
        self.showMaximized()

        self.set_toolbar()

        self.data = data
        self.json_file = json_file

        self.component_data = self.data["Component lists"][component_list_name]
        self.comp_list_name = component_list_name
        self.settings = self.data["Model setups"][model_settings_name]
        self.units_data = self.data["Units"]

        self.tp = get_thermopack(category=self.settings["Model category"])

        self.input_stack_indices = {"TP": 0, "PS": 1, "PH": 2, "UV": 3}

        self.set_units()
        self.set_label_units()

        # Units registry from pint library
        self.ureg = pint.UnitRegistry()

        self.table_indices = self.get_table_indices()

        # Validator for float inputs
        self.float_validator = FloatValidator()

        self.show_input_params()
        self.init_fractions()

        self.set_validators()

        self.flash_mode_selection.currentTextChanged.connect(
            self.show_input_params)
        self.calculate_btn.clicked.connect(self.calculate)
        self.download_csv_btn.clicked.connect(self.export_csv)

        self.ps_initial_guess.stateChanged.connect(self.toggle_initial_guess)
        self.ph_initial_guess.stateChanged.connect(self.toggle_initial_guess)
        self.uv_t_initial_guess.stateChanged.connect(self.toggle_initial_guess)
        self.uv_p_initial_guess.stateChanged.connect(self.toggle_initial_guess)
Example #3
0
    def init_widget(self, data, settings_name):
        """
        Populates the list with the available compositions, calculates interaction parameters, and creates a table
        to display the matrix
        :param data: Session data
        :param settings_name: Name of the current model setup
        :return:
        """
        self.settings = data["Model setups"][settings_name]
        self.thermopack = get_thermopack(category=self.settings["Model category"])

        list_names = []
        for i in range(self.composition_list.count()):
            list_names.append(self.composition_list.item(i).text())

        for list_name in self.component_lists.keys():

            if list_name not in self.settings["Parameters"].keys():
                self.settings["Parameters"][list_name] = {"Coefficient matrices": {}}

            existing_matrices = self.settings["Parameters"][list_name]["Coefficient matrices"].keys()

            if "HV2 Alpha" not in existing_matrices:
                # Create one tab for each list in a tab widget. The dict keeps track of the tab's index
                self.calculate_matrix_data(list_name)

            self.alpha_table = self.get_table(list_name, "HV2 Alpha")
            self.a_table = self.get_table(list_name, "HV2 A")
            self.b_table = self.get_table(list_name, "HV2 B")
            self.c_table = self.get_table(list_name, "HV2 C")

            self.alpha_table.itemChanged.connect(lambda item: self.change_coeff(item, "HV2 Alpha"))
            self.a_table.itemChanged.connect(lambda item: self.change_coeff(item, "HV2 A"))
            self.b_table.itemChanged.connect(lambda item: self.change_coeff(item, "HV2 B"))
            self.c_table.itemChanged.connect(lambda item: self.change_coeff(item, "HV2 C"))

            tab_widget = HV2TabWidget(self.alpha_table, self.a_table, self.b_table, self.c_table)

            if list_name not in self.tab_stack_indices.keys():
                # Keep track of tabs in stack
                index = self.tab_stack.addWidget(tab_widget)
                self.tab_stack_indices[list_name] = index

        self.init_composition_list()
        self.tab_stack.setCurrentIndex(0)
Example #4
0
    def init_widget(self, data, settings_name):
        """
        Populates the list with the available compositions, calculates interaction parameters, and creates a table
        to display the matrix
        :param data: Session data
        :param settings_name: Name of the current model setup
        :return:
        """
        self.settings = data["Model setups"][settings_name]
        self.thermopack = get_thermopack(category=self.settings["Model category"])

        list_names = []
        for i in range(self.composition_list.count()):
            list_names.append(self.composition_list.item(i).text())

        for name in self.component_lists.keys():

            if name not in self.settings["Parameters"].keys():
                self.settings["Parameters"][name] = {"Coefficient matrices": {}}

            existing_matrices = self.settings["Parameters"][name]["Coefficient matrices"].keys()

            if "VDW K" not in existing_matrices:
                # Create one table for each list in a stacked widget if it does not already exist
                # Create table
                self.calculate_matrix_data(name, settings_name)

            table = self.get_table(name, "VDW K")
            table.itemChanged.connect(lambda item: self.change_coeff(item, "VDW K"))

            if name not in self.stack_indices.keys():
                # Keep track of table in stack
                index = self.table_stack.addWidget(table)
                self.stack_indices[name] = index

        self.init_composition_list()
        self.table_stack.setCurrentIndex(0)
Example #5
0
    def __init__(self,
                 data,
                 json_file,
                 component_list_name,
                 model_settings_name,
                 parent=None):
        super().__init__(parent=parent)

        loadUi("gui/layouts/plot_mode.ui", self)
        self.setWindowTitle("Thermopack - Plot Mode")
        self.showMaximized()

        self.data = data
        self.json_file = json_file

        self.component_data = self.data["Component lists"][component_list_name]
        self.comp_list_name = component_list_name
        self.settings = self.data["Model setups"][model_settings_name]
        self.units = self.data["Units"]

        self.set_toolbar()

        if self.data["Plotting preferences"]:
            self.plotting_preferences = self.data["Plotting preferences"]
        else:
            self.plotting_preferences = self.init_plotting_preferences()
            self.data["Plotting preferences"] = self.plotting_preferences

        # In case the user wants to reset settings
        self.default_plotting_preferences = self.init_plotting_preferences()

        self.redraw = True
        self.redraw_checkbox.setChecked(self.redraw)

        self.init_plot_modes()

        self.model_btn_group = QButtonGroup(parent=self.model_box)
        self.init_model_options()

        self.init_fractions()

        # Initiating thermopack
        self.tp = get_thermopack(category=self.settings["Model category"])

        # Init function depends on settings
        init_thermopack(self.tp, self.component_data, self.comp_list_name,
                        self.settings)

        self.ph_env_toolbtn.clicked.connect(self.show_ph_env_options)
        self.bin_pxy_toolbtn.clicked.connect(self.show_bin_pxy_options)
        self.p_rho_toolbtn.clicked.connect(self.show_p_rho_options)
        self.global_binary_toolbtn.clicked.connect(
            self.show_global_binary_options)

        self.plot_type_btn_group.buttonClicked.connect(self.change_plot_type)

        # Setup for plot window
        self.canvas = MplCanvas(self.component_data["Names"],
                                self.plotting_preferences)
        self.mpl_toolbar = NavigationToolbar2QT(self.canvas, self)
        self.mpl_toolbar.hide()
        self.canvas.hide()
        self.plot_layout.addWidget(self.mpl_toolbar)
        self.plot_layout.addWidget(self.canvas)

        self.init_isopleth_btns()
        self.redraw_checkbox.clicked.connect(self.toggle_redraw)
        self.plot_button.clicked.connect(self.plot)
        self.download_csv_btn.clicked.connect(self.export_csv)