def init_fractions(self): """ Adds component fraction widgets to window, depending on how many components are chosen """ components = self.component_data["Names"] self.component_data["Fractions"] = [0.00] * len(components) float_validator = FloatValidator() for i in range(len(components)): component = components[i] line_edit = QLineEdit() line_edit.setValidator(float_validator) line_edit.setText("0.00") line_edit.setObjectName(component) line_edit.editingFinished.connect( lambda comp=component: self.change_fraction(comp)) if len(components) == 1: line_edit.setText("1.00") line_edit.setEnabled(False) self.component_data["Fractions"][i] = 1.00 else: self.component_data["Fractions"][i] = 0.00 self.fractions_layout.addRow(components[i], line_edit)
def __init__(self, data, settings_name, parent=None): super().__init__(data, settings_name, parent) loadUi("gui/layouts/saftvrmie_parameters.ui", self) self.tab_stack_indices = {} self.list_name = None self.component_id = None self.pure_param_m_label.setText("m:") self.pure_param_sigma_label.setText("\u03C3:") self.pure_param_epsilon_label.setText("\u03B5 / k:") self.pure_param_lambda_a_label.setText("\u03BB a:") self.pure_param_lambda_r_label.setText("\u03BB r:") # Validators for input self.float_validator = FloatValidator() self.set_validators() self.pure_param_m_edit.editingFinished.connect(self.save_pure_fluid_params) self.pure_param_sigma_edit.editingFinished.connect(self.save_pure_fluid_params) self.pure_param_epsilon_edit.editingFinished.connect(self.save_pure_fluid_params) self.pure_param_lambda_a_edit.editingFinished.connect(self.save_pure_fluid_params) self.pure_param_lambda_r_edit.editingFinished.connect(self.save_pure_fluid_params) self.component_btngroup = QButtonGroup() self.component_btngroup.buttonClicked.connect(self.show_component_pure_params) self.pure_params_frame.hide() self.composition_list.currentItemChanged.connect(self.on_chosen_composition_list)
def __init__(self, plotting_preferences, default): QDialog.__init__(self) loadUi("gui/layouts/global_binary_options.ui", self) self.setWindowTitle("Global binary options") self.calc_settings = plotting_preferences["Global binary"]["Calc"] self.plotting_options = plotting_preferences["Global binary"]["Plotting"] self.default = default # Set initial data self.p_min.setText(str(self.calc_settings["Minimum pressure"])) self.t_min.setText(str(self.calc_settings["Minimum temperature"])) self.azeotropes_checkbox.setChecked(self.calc_settings["Azeotropes"]) self.set_line_color_1(self.plotting_options["Colors"][0]) self.set_line_color_2(self.plotting_options["Colors"][1]) self.set_line_color_3(self.plotting_options["Colors"][2]) self.set_line_color_4(self.plotting_options["Colors"][3]) self.grid_checkbox.setChecked(self.plotting_options["Grid on"]) if not self.plotting_options["Title"]: self.plotting_options["Title"] = "van Konyenburg and Scott type: " self.title.setText(self.plotting_options["Title"]) self.xlabel.setText(self.plotting_options["x label"]) self.ylabel.setText(self.plotting_options["y label"]) self.setFocus() # Validators for input float_validator = FloatValidator() locale = QLocale(QLocale.English) float_validator.setLocale(locale) self.p_min.setValidator(float_validator) self.t_min.setValidator(float_validator) # Action handling self.line_color_1_tool_btn.clicked.connect(self.set_line_color_1) self.line_color_2_tool_btn.clicked.connect(self.set_line_color_2) self.line_color_3_tool_btn.clicked.connect(self.set_line_color_3) self.line_color_4_tool_btn.clicked.connect(self.set_line_color_4) self.save_btn.clicked.connect(self.save) self.cancel_btn.clicked.connect(self.close) self.restore_defaults_btn.clicked.connect(self.restore_defaults)
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)
def __init__(self, plotting_preferences, default): QDialog.__init__(self) loadUi("gui/layouts/bin_pxy_options.ui", self) self.setWindowTitle("Binary pxy options") self.calc_settings = plotting_preferences["Binary pxy"]["Calc"] self.plotting_options = plotting_preferences["Binary pxy"]["Plotting"] self.default = default # Set initial data self.temp.setText(str(self.calc_settings["Temperature"])) self.p_max.setText(str(self.calc_settings["Maximum pressure"])) self.p_min.setText(str(self.calc_settings["Minimum pressure"])) self.dz_max.setText(str(self.calc_settings["Maximum dz"])) self.dlns_max.setText(str(self.calc_settings["Maximum dlns"])) self.set_line_color(self.plotting_options["Colors"][0]) self.grid_checkbox.setChecked(self.plotting_options["Grid on"]) self.title.setText(self.plotting_options["Title"]) self.xlabel.setText(self.plotting_options["x label"]) self.ylabel.setText(self.plotting_options["y label"]) self.setFocus() # Validators for input float_validator = FloatValidator() self.temp.setValidator(float_validator) self.p_max.setValidator(float_validator) self.p_min.setValidator(float_validator) self.dz_max.setValidator(float_validator) self.dlns_max.setValidator(float_validator) # Action handling self.line_color_tool_btn.clicked.connect(self.set_line_color) self.save_btn.clicked.connect(self.save) self.cancel_btn.clicked.connect(self.close) self.restore_defaults_btn.clicked.connect(self.restore_defaults)
def __init__(self, plotting_preferences, default): QDialog.__init__(self) loadUi("gui/layouts/pressure_density_options.ui", self) self.setWindowTitle("Pressure density options") self.new_temp_btn.setStyleSheet("padding: 3px 7px;") self.calc_settings = plotting_preferences["Pressure density"]["Calc"] self.tpv_settings = plotting_preferences["Pressure density"]["TPV"] self.crit_point_settings = plotting_preferences["Pressure density"]["Critical"] self.plotting_options = plotting_preferences["Pressure density"]["Plotting"] self.default = default # Set initial data temperatures = self.calc_settings["Temperatures"] self.float_validator = FloatValidator() for i in range(len(temperatures)): line_edit = QLineEdit() line_edit.setValidator(self.float_validator) line_edit.setText(str(temperatures[i])) self.isotherm_layout.addRow("Temperature " + str(i + 1) + " [K]:", line_edit) self.v_start.setText(str(self.calc_settings["Volume range start"])) self.v_end.setText(str(self.calc_settings["Volume range end"])) self.v_num_points.setText(str(self.calc_settings["Num points"])) self.p_0.setText(str(self.tpv_settings["Initial pressure"])) self.p_max.setText(str(self.tpv_settings["Maximum pressure"])) self.t_min.setText(str(self.tpv_settings["Minimum temperature"])) self.step_size.setText(str(self.tpv_settings["Step size"])) self.crit_t.setText(str(self.crit_point_settings["Temperature"])) self.crit_v.setText(str(self.crit_point_settings["Volume"])) self.crit_tol.setText(str(self.crit_point_settings["Error tolerance"])) self.grid_checkbox.setChecked(self.plotting_options["Grid on"]) self.title.setText(self.plotting_options["Title"]) self.xlabel.setText(self.plotting_options["x label"]) self.ylabel.setText(self.plotting_options["y label"]) self.setFocus() # Setting validators for input int_validator = QIntValidator() self.v_start.setValidator(self.float_validator) self.v_end.setValidator(self.float_validator) self.v_num_points.setValidator(int_validator) self.p_0.setValidator(self.float_validator) self.p_max.setValidator(self.float_validator) self.t_min.setValidator(self.float_validator) self.step_size.setValidator(self.float_validator) self.crit_t.setValidator(self.float_validator) self.crit_v.setValidator(self.float_validator) self.crit_tol.setValidator(self.float_validator) # Action handling self.new_temp_btn.clicked.connect(self.add_new_temperature) self.save_btn.clicked.connect(self.save) self.cancel_btn.clicked.connect(self.close) self.restore_defaults_btn.clicked.connect(self.restore_defaults)
def __init__(self, plotting_preferences, default): QDialog.__init__(self) loadUi("gui/layouts/ph_env_options.ui", self) self.setWindowTitle("Phase envelope options") self.plotting_preferences = plotting_preferences self.calc_pvt_settings = self.plotting_preferences["Phase envelope"]["TPV"] self.isopleth_settings = self.plotting_preferences["Phase envelope"]["Isopleths"] self.crit_point_settings = self.plotting_preferences["Phase envelope"]["Critical"] self.plotting_options = self.plotting_preferences["Phase envelope"]["Plotting"] self.default = default # Set initial data self.p_0.setText(str(self.calc_pvt_settings["Initial pressure"])) self.p_max.setText(str(self.calc_pvt_settings["Maximum pressure"])) self.t_min.setText(str(self.calc_pvt_settings["Minimum temperature"])) self.step_size.setText(str(self.calc_pvt_settings["Step size"])) self.crit_t.setText(str(self.crit_point_settings["Temperature"])) self.crit_v.setText(str(self.crit_point_settings["Volume"])) self.crit_tol.setText(str(self.crit_point_settings["Error tolerance"])) self.iso_p_min.setText(str(self.isopleth_settings["Minimum pressure"])) self.iso_p_max.setText(str(self.isopleth_settings["Maximum pressure"])) self.iso_t_min.setText(str(self.isopleth_settings["Minimum temperature"])) self.iso_t_max.setText(str(self.isopleth_settings["Maximum temperature"])) self.n_isopleths.setText(str(self.isopleth_settings["Number of isopleths"])) self.n_max.setText(str(self.isopleth_settings["N max"])) self.set_line_color(self.plotting_options["Colors"][0]) self.set_point_color(self.plotting_options["Colors"][1]) self.set_isopleth_1_color(self.plotting_options["Colors"][2]) self.set_isopleth_2_color(self.plotting_options["Colors"][3]) self.grid_checkbox.setChecked(self.plotting_options["Grid on"]) self.title.setText(self.plotting_options["Title"]) self.xlabel.setText(self.plotting_options["x label"]) self.ylabel.setText(self.plotting_options["y label"]) self.setFocus() # Validators for input float_validator = FloatValidator() int_validator = QIntValidator() self.p_0.setValidator(float_validator) self.p_max.setValidator(float_validator) self.t_min.setValidator(float_validator) self.step_size.setValidator(float_validator) self.crit_t.setValidator(float_validator) self.crit_v.setValidator(float_validator) self.crit_tol.setValidator(float_validator) self.iso_p_min.setValidator(float_validator) self.iso_p_max.setValidator(float_validator) self.iso_t_min.setValidator(float_validator) self.iso_t_max.setValidator(float_validator) self.n_isopleths.setValidator(int_validator) self.n_max.setValidator(int_validator) # Action handling self.line_color_tool_btn.clicked.connect(self.set_line_color) self.point_color_tool_btn.clicked.connect(self.set_point_color) self.isopleth_1_color_tool_btn.clicked.connect(self.set_isopleth_1_color) self.isopleth_2_color_tool_btn.clicked.connect(self.set_isopleth_2_color) self.save_btn.clicked.connect(self.save) self.cancel_btn.clicked.connect(self.close) self.restore_defaults_btn.clicked.connect(self.restore_defaults)