From 59cc25aaf4dac07b18a381d56f4eab15b2ca9ade Mon Sep 17 00:00:00 2001 From: mrcheatak Date: Fri, 12 Jul 2024 14:51:37 +0200 Subject: [PATCH] Changes: - Fixed simulation failing to start when intervals statistics and snapshots are empty. - Fixed statistics and snapshot intervals not being saved into the session file. - The units for intervals are now in seconds and can be input in scientific from, i.e. '1e-5'. - Minor refactoring of file viewers --- README.rst | 2 +- febid/__main__.py | 2 +- .../vtk_rendering/show_animation_new.py | 78 +++++---- febid/libraries/vtk_rendering/show_file.py | 48 +++--- febid/start.py | 14 +- febid/ui/main_window.py | 150 ++++++++---------- febid/ui/main_window.ui | 26 +-- febid/ui/ui_shell.py | 10 +- 8 files changed, 169 insertions(+), 161 deletions(-) diff --git a/README.rst b/README.rst index 51c73d1..b108460 100644 --- a/README.rst +++ b/README.rst @@ -46,7 +46,7 @@ By using the same input data, it is possible to inspect electron scattering prof Installation --------------- -The simulation requires Python 3.7 or later. +The simulation requires Python 3.9 or later. Package is available via PyPi: :code:`pip install febid` diff --git a/febid/__main__.py b/febid/__main__.py index 00a881d..93b8ca7 100644 --- a/febid/__main__.py +++ b/febid/__main__.py @@ -48,7 +48,7 @@ def welcome(): print(intro) command_functions = { 'show_file': febid.show_file.show_structure, - 'show_animation': febid.show_animation.show_animation, + 'show_animation': febid.show_animation.render_animation, 'gui': start_ui, 'no_gui': Starter().start } diff --git a/febid/libraries/vtk_rendering/show_animation_new.py b/febid/libraries/vtk_rendering/show_animation_new.py index 57ab950..50c99e0 100644 --- a/febid/libraries/vtk_rendering/show_animation_new.py +++ b/febid/libraries/vtk_rendering/show_animation_new.py @@ -3,16 +3,17 @@ """ import os, time import sys +import numpy as np +import pyvista as pv +import vtk from datetime import datetime from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QFileDialog as fd -import numpy as np -import vtk - -import febid.libraries.vtk_rendering.VTK_Rendering as vr +from febid.libraries.vtk_rendering.VTK_Rendering import Render, read_field_data from febid.Structure import Structure + def ask_directory(): os.chdir('../../..') init_dir = os.getcwd() @@ -21,6 +22,7 @@ def ask_directory(): app.quit() return directory + def open_file(directory=''): """ Gather files and timestamps sorted in the order of creation @@ -35,7 +37,7 @@ def open_file(directory=''): # directory = '/Users/sandrik1742/Documents/PycharmProjects/FEBID/code/Experiment runs/gr=0' files = sorted(os.listdir(directory))[:] n = 0 - for i in range(len(files)-1, -1, -1): + for i in range(len(files) - 1, -1, -1): if os.path.splitext(files[i])[1] != '.vtk': files.pop(i) n += 1 @@ -51,13 +53,17 @@ def open_file(directory=''): return files, times + def show_animation(directory=None, **kwargs): if not directory: directory = ask_directory() + if not directory: + return result = show_animation(directory, **kwargs) return result -def show_animation(directory, show='precursor'): + +def render_animation(directory, show='precursor'): """ Show animated process from series of vtk files. Files must have consequent creation dates to align correctly @@ -77,14 +83,14 @@ def show_animation(directory, show='precursor'): # Getting data for initialization structure = Structure() - vtk_obj = vr.pv.read(os.path.join(directory, files[0])) + vtk_obj = pv.read(os.path.join(directory, files[0])) structure.load_from_vtk(vtk_obj) cell_size, deposit, precursor, surface_bool, semi_surface_bool, ghosts_bool = structure.cell_size, \ - structure.deposit, \ - structure.precursor, \ - structure.surface_bool, \ - structure.semi_surface_bool, \ - structure.ghosts_bool + structure.deposit, \ + structure.precursor, \ + structure.surface_bool, \ + structure.semi_surface_bool, \ + structure.ghosts_bool # Determining rendered dataset if show not in ['precursor', 'deposit', 'temperature']: raise RuntimeError(f'The specified dataset \'{show}\' is not supported.') @@ -102,7 +108,7 @@ def show_animation(directory, show='precursor'): mask_name = 'deposit' data = structure.__getattribute__(show) mask = structure.__getattribute__(mask_name) - t, sim_time, beam_position = vr.read_field_data(vtk_obj) # getting deposition process features + t, sim_time, beam_position = read_field_data(vtk_obj) # getting deposition process features # Preparing left corner text with times text = '' if t: @@ -111,12 +117,12 @@ def show_animation(directory, show='precursor'): text += f'Simulation time: {sim_time:.7f} s \n' # Setting the setup scene - render = vr.Render(cell_size) + render = Render(cell_size) render.add_3Darray(data) render.p.add_text('Adjust the scene for the animation \n and close the window.', position='upper_edge') cam_pos = render.show() # Setting the first frame - render = vr.Render(cell_size) + render = Render(cell_size) # Creating an arrow at beam position if beam_position is not None: x_pos, y_pos = beam_position @@ -134,7 +140,7 @@ def show_animation(directory, show='precursor'): render.p.mesh.cell_data[vtk.vtkDataSetAttributes.GhostArrayName()] = index.ravel() render.p.mesh.set_active_scalars(data_name) # Adding text - t, sim_time, beam_position = vr.read_field_data(vtk_obj) + t, sim_time, beam_position = read_field_data(vtk_obj) text = '' if t: text += f'Time: {t} \n' @@ -148,14 +154,14 @@ def show_animation(directory, show='precursor'): render.p.add_text(text, position='upper_left', font_size=font_size, name='time') render.p.add_text(stats, font_size=font_size, position='upper_right', name='stats') render.show(interactive_update=True, cam_pos=cam_pos) - init_layer = np.count_nonzero(deposit==-2) # substrate layer - total_dep_cells = [np.count_nonzero(deposit[deposit<0])-init_layer] # total number of fully deposited cells - growth_rate=[] # growth rate on each step + init_layer = np.count_nonzero(deposit == -2) # substrate layer + total_dep_cells = [np.count_nonzero(deposit[deposit < 0]) - init_layer] # total number of fully deposited cells + growth_rate = [] # growth rate on each step # Animation for i in range(1, len(files)): # Reading data - vtk_obj = vr.pv.read(os.path.join(directory, files[i])) + vtk_obj = pv.read(os.path.join(directory, files[i])) # Loading the structure structure.load_from_vtk(vtk_obj) cell_size = structure.cell_size @@ -167,14 +173,14 @@ def show_animation(directory, show='precursor'): if show == 'deposit': mask = surface_bool if show == 'temperature': - mask = deposit<0 + mask = deposit < 0 # Calculating deposition process features total_dep_cells.append(np.count_nonzero(deposit[deposit < 0]) - init_layer) volume = int((total_dep_cells[i] + deposit[surface_bool].sum()) * cell_size ** 3) delta_t = (times[i] - times[i - 1]).total_seconds() if delta_t < 1: delta_t = 1 growth_rate.append(cell_size ** 3 * (total_dep_cells[i] - total_dep_cells[i - 1]) / delta_t * 60 * 60) - t, sim_time, beam_position = vr.read_field_data(vtk_obj) + t, sim_time, beam_position = read_field_data(vtk_obj) # Setting up text # Left corner text = '' @@ -186,7 +192,7 @@ def show_animation(directory, show='precursor'): stats = f'Cells: {total_dep_cells[i]} \n\ Height: {int(np.nonzero(deposit)[0].max() * cell_size)} nm \n\ Volume: {volume} nm^3 \n\ - Frame {i+1}/{len(files)}' + Frame {i + 1}/{len(files)}' # Updating arrow position if beam_position is not None: x_pos, y_pos = beam_position @@ -194,9 +200,9 @@ def show_animation(directory, show='precursor'): max_z = structure.deposit[:, y, x].nonzero()[0].max() render.arrow.SetPosition(x_pos, y_pos, max_z * render.cell_size + 30) # relative to the initial position # Redrawing the 3D object if necessary - if render.p.mesh.n_cells != data.size: # must redraw if shape changes + if render.p.mesh.n_cells != data.size: # must redraw if shape changes data_visibility = render.p.renderer.actors[data_name].GetVisibility() - render.p.remove_actor(data_name+'_caption') + render.p.remove_actor(data_name + '_caption') render.y_pos = 5 render.p.button_widgets.clear() render.p.remove_actor(data_name) @@ -207,7 +213,7 @@ def show_animation(directory, show='precursor'): render.p.mesh.cell_data[vtk.vtkDataSetAttributes.GhostArrayName()] = index.ravel() render.p.mesh.set_active_scalars(data_name) else: - render.p.mesh[data_name] = data.ravel() # new data, ravel() sends a view + render.p.mesh[data_name] = data.ravel() # new data, ravel() sends a view # Updating hidden cells index[mask == 0] = vtk.vtkDataSetAttributes.HIDDENCELL index[mask == 1] = 0 # surface_bool is not bool type and cannot be used directly as index @@ -216,19 +222,20 @@ def show_animation(directory, show='precursor'): render.p.actors['stats'].SetText(3, stats) # render.p.mesh.cell_data[vtk.vtkDataSetAttributes.GhostArrayName()] = index.ravel() - p=data[mask] + p = data[mask] # Updating the scalar bar try: - render.p.update_scalar_bar_range([np.partition(p[p!=p.min()], 4)[2], p.max()]) - except: pass + render.p.update_scalar_bar_range([np.partition(p[p != p.min()], 4)[2], p.max()]) + except: + pass render.update() - else: # finishing with a static scene + else: # finishing with a static scene # Clearing the scene render.y_pos = 5 render.p.button_widgets.clear() render.p.clear() # Reading data - vtk_obj = vr.pv.read(os.path.join(directory, files[-1])) + vtk_obj = pv.read(os.path.join(directory, files[-1])) # Loading the structure structure.load_from_vtk(vtk_obj) cell_size = structure.cell_size @@ -241,18 +248,18 @@ def show_animation(directory, show='precursor'): render.p.update_scalar_bar_range([np.partition(p[p != p.min()], 4)[2], p.max()]) render.p.mesh.cell_data[vtk.vtkDataSetAttributes.GhostArrayName()] = index.ravel() render.p.mesh.set_active_scalars(data_name) - t, sim_time, beam_position = vr.read_field_data(vtk_obj) + t, sim_time, beam_position = read_field_data(vtk_obj) text = '' if t: text += f'Time: {t} \n' if sim_time: text += f'Simulation time: {sim_time:.7f} s \n' render.p.add_text(text, position='upper_left', font_size=font_size) # showing time passed - render.p.add_text(f'Cells: {total_dep_cells[i-1]} \n' # showing total number of deposited cells + render.p.add_text(f'Cells: {total_dep_cells[i - 1]} \n' # showing total number of deposited cells f'Height: {int(np.nonzero(deposit)[0].max() * cell_size)} nm \n' # showing current height of the structure f'Volume: {volume} nm^3 \n' f'Growth rate: {int(np.asarray(growth_rate).mean())} cell/h \n' # showing average growth rate - f'Frame {i+1}/{len(files)} \n', position='upper_right', font_size=font_size) + f'Frame {i + 1}/{len(files)} \n', position='upper_right', font_size=font_size) if beam_position is not None: x_pos, y_pos = beam_position x, y = int(x_pos / render.cell_size), int(y_pos / render.cell_size) @@ -264,6 +271,7 @@ def show_animation(directory, show='precursor'): cam_pos = render.show(interactive_update=False) return cam_pos + if __name__ == '__main__': filenames = None try: @@ -272,4 +280,4 @@ def show_animation(directory, show='precursor'): print(e.args) if not filenames: filenames = ask_directory() - show_animation() \ No newline at end of file + show_animation() diff --git a/febid/libraries/vtk_rendering/show_file.py b/febid/libraries/vtk_rendering/show_file.py index 93cfa1f..9f06061 100644 --- a/febid/libraries/vtk_rendering/show_file.py +++ b/febid/libraries/vtk_rendering/show_file.py @@ -6,25 +6,36 @@ import pyvista as pv from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QFileDialog as fd -from febid.libraries.vtk_rendering import VTK_Rendering as vr + +from febid.libraries.vtk_rendering.VTK_Rendering import Render, read_field_data from febid.Structure import Structure -def ask_filenames(): + +def check_allowed_extensions(filenames, allowed_extensions=['vtk']): + for filename in filenames: + if not any(filename.endswith(ext) for ext in allowed_extensions): + return False + return True + + +def ask_filenames(allowed_extensions=['vtk']): os.chdir('../../..') init_dir = os.getcwd() app = QApplication(sys.argv) - filenames = fd.getOpenFileName(None, 'Select the file to view', init_dir, 'VTK files (*.vtk);;All files (*)')[0] + extensions = ', '.join([f'*.{ext}' for ext in allowed_extensions]) + filenames = fd.getOpenFileName(None, 'Select the file to view', init_dir, f'VTK files ({extensions});;All files (*)')[0] app.quit() return filenames + def show_structure(filenames=None, **kwargs): if not filenames: filenames = ask_filenames() result = render_structure(filenames, **kwargs) return result -def render_structure(filenames, solid=True, deposit=True, precursor=True, surface=True, semi_surface=True, ghost=True): +def render_structure(filenames, solid=True, deposit=True, precursor=True, surface=True, semi_surface=True, ghost=True): font_size = 12 cam_pos = None if type(filenames) not in [list, tuple]: @@ -32,6 +43,7 @@ def render_structure(filenames, solid=True, deposit=True, precursor=True, surfac for filename in filenames: print(f'Opening file {filename}') vtk_obj = pv.read(filename) + print(f'Data arrays: {vtk_obj.array_names}') structure = Structure() structure.load_from_vtk(vtk_obj) d = structure.deposit @@ -47,35 +59,33 @@ def render_structure(filenames, solid=True, deposit=True, precursor=True, surfac if p.min() < 0: p_er += 1 print(f'Checking data.....', end='') - if d_er+p_er: + if d_er + p_er: print(f'bad cells encountered in data arrays!') if d_er: print(f'\t Solid-cell data contains bad cells:') if d.max() > 1: - print(f'\t Found {np.count_nonzero(d>1)} cells above unity, maximum value is {d.max()}') + print(f'\t Found {np.count_nonzero(d > 1)} cells above unity, maximum value is {d.max()}') if d.min() < -2: - print(f'\t Found {np.count_nonzero(d<-2)} cells below zero, minimum value is {d.min()}') + print(f'\t Found {np.count_nonzero(d < -2)} cells below zero, minimum value is {d.min()}') if p_er: print(f'\t Surface precursor density data contains bad cells:') if p.max() > 1: - print(f'\t Found {np.count_nonzero(p>1)} cells above unity, maximum value is {p.max()}') + print(f'\t Found {np.count_nonzero(p > 1)} cells above unity, maximum value is {p.max()}') if p.min() < 0: - print(f'\t Found {np.count_nonzero(p<0)} cells below zero, minimum value is {p.min()}') + print(f'\t Found {np.count_nonzero(p < 0)} cells below zero, minimum value is {p.min()}') else: print('ok!') - t, sim_time, beam_position = vr.read_field_data(vtk_obj) - render = vr.Render(structure.cell_size) - cam_pos = render.show_full_structure(structure, True, solid, deposit, precursor, surface, semi_surface, ghost, t, sim_time, beam_position, cam_pos=cam_pos) + t, sim_time, beam_position = read_field_data(vtk_obj) + render = Render(structure.cell_size) + cam_pos = render.show_full_structure(structure, True, solid, deposit, precursor, surface, semi_surface, ghost, + t, sim_time, beam_position, cam_pos=cam_pos) return cam_pos if __name__ == '__main__': filenames = None - try: - filename = sys.argv[1] - except Exception as e: - print(e.args) - if not filenames: - filenames = ask_filenames() - + if len(sys.argv) > 1: + filenames = sys.argv[1:] + if not check_allowed_extensions(filenames): + raise ValueError('Only .vtk files are allowed!') show_structure(filenames, solid=True, deposit=True, precursor=True, surface=True, semi_surface=True, ghost=True) diff --git a/febid/start.py b/febid/start.py index 6df0328..0200832 100644 --- a/febid/start.py +++ b/febid/start.py @@ -207,13 +207,15 @@ def _run_febid_interface(self): Compile simulation parameters and start the simulation """ sim_volume_params = self.get_simulation_volume_parameters() - saving_params = {'gather_stats': False, 'gather_stats_interval': None, 'save_snapshot': False, 'snapshot_interval': None, - 'filename': None} + saving_params = {'gather_stats': False, 'gather_stats_interval': None, 'save_snapshot': False, 'save_snapshot_interval': None, + 'filename': ''} flag1, flag2 = self._params['save_simulation_data'], self._params['save_structure_snapshot'] - saving_params['gather_stats'] = self._params['save_simulation_data'] - saving_params['gather_stats_interval'] = float(self._params['simulation_data_interval']) - saving_params['save_snapshot'] = self._params['save_structure_snapshot'] - saving_params['save_snapshot_interval'] = float(self._params['structure_snapshot_interval']) + gather_stats = saving_params['gather_stats'] = self._params['save_simulation_data'] + if gather_stats: + saving_params['gather_stats_interval'] = float(self._params['simulation_data_interval']) + save_snapshot = saving_params['save_snapshot'] = self._params['save_structure_snapshot'] + if save_snapshot: + saving_params['save_snapshot_interval'] = float(self._params['structure_snapshot_interval']) flag1, flag2, flag3 = self._params['save_simulation_data'], self._params['save_structure_snapshot'], self._params['show_process'] if flag1 or flag2: try: diff --git a/febid/ui/main_window.py b/febid/ui/main_window.py index ef507f9..2b4783c 100644 --- a/febid/ui/main_window.py +++ b/febid/ui/main_window.py @@ -14,7 +14,7 @@ class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") - MainWindow.resize(605, 698) + MainWindow.resize(605, 745) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) @@ -236,14 +236,16 @@ def setupUi(self, MainWindow): self.l_sim_data_interval_units = QtWidgets.QLabel(self.groupBox_7) self.l_sim_data_interval_units.setGeometry(QtCore.QRect(286, 32, 43, 16)) self.l_sim_data_interval_units.setObjectName("l_sim_data_interval_units") - self.input_sim_data_interval = QtWidgets.QLineEdit(self.groupBox_7) - self.input_sim_data_interval.setGeometry(QtCore.QRect(240, 28, 43, 21)) - self.input_sim_data_interval.setMaxLength(5) - self.input_sim_data_interval.setObjectName("input_sim_data_interval") - self.input_snapshot_interval = QtWidgets.QLineEdit(self.groupBox_7) - self.input_snapshot_interval.setGeometry(QtCore.QRect(240, 56, 43, 21)) - self.input_snapshot_interval.setMaxLength(5) - self.input_snapshot_interval.setObjectName("input_snapshot_interval") + self.input_simulation_data_interval = QtWidgets.QLineEdit(self.groupBox_7) + self.input_simulation_data_interval.setGeometry(QtCore.QRect(240, 28, 43, 21)) + self.input_simulation_data_interval.setText("") + self.input_simulation_data_interval.setMaxLength(6) + self.input_simulation_data_interval.setObjectName("input_simulation_data_interval") + self.input_structure_snapshot_interval = QtWidgets.QLineEdit(self.groupBox_7) + self.input_structure_snapshot_interval.setGeometry(QtCore.QRect(240, 56, 43, 21)) + self.input_structure_snapshot_interval.setText("") + self.input_structure_snapshot_interval.setMaxLength(5) + self.input_structure_snapshot_interval.setObjectName("input_structure_snapshot_interval") self.l_snapshot_interval = QtWidgets.QLabel(self.groupBox_7) self.l_snapshot_interval.setGeometry(QtCore.QRect(202, 60, 39, 16)) self.l_snapshot_interval.setObjectName("l_snapshot_interval") @@ -447,7 +449,7 @@ def setupUi(self, MainWindow): self.verticalLayout.addWidget(self.tabWidget) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 605, 22)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 605, 30)) self.menubar.setObjectName("menubar") self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") @@ -472,72 +474,62 @@ def setupUi(self, MainWindow): self.retranslateUi(MainWindow) self.tabWidget.setCurrentIndex(0) self.pattern_selection.setCurrentIndex(0) - self.connect_signals_to_slots(MainWindow) + self.choice_vtk_file.clicked.connect(MainWindow.vtk_chosen) # type: ignore + self.choice_geom_parameters_file.clicked.connect(MainWindow.geom_parameters_chosen) # type: ignore + self.choice_auto.clicked.connect(MainWindow.auto_chosen) # type: ignore + self.choice_simple_pattern.clicked.connect(MainWindow.simple_pattern_chosen) # type: ignore + self.choice_stream_file.clicked.connect(MainWindow.stream_file_chosen) # type: ignore + self.open_vtk_file_button.clicked.connect(MainWindow.open_vtk_file) # type: ignore + self.open_geom_parameters_file_button.clicked.connect(MainWindow.open_geom_parameters_file) # type: ignore + self.open_stream_file_button.clicked.connect(MainWindow.open_stream_file) # type: ignore + self.open_precursor_parameters_file_button.clicked.connect(MainWindow.open_precursor_parameters_file) # type: ignore + self.open_vtk_file_button_mc.clicked.connect(MainWindow.open_vtk_file) # type: ignore + self.choice_vtk_file_mc.clicked.connect(MainWindow.vtk_chosen) # type: ignore + self.choice_geom_parameters_file_mc.clicked.connect(MainWindow.geom_parameters_chosen) # type: ignore + self.open_beam_parameters_file_button_mc.clicked.connect(MainWindow.open_settings_file) # type: ignore + self.open_precursor_parameters_file_button_mc.clicked.connect(MainWindow.open_precursor_parameters_file) # type: ignore + self.open_geom_parameters_file_button_mc.clicked.connect(MainWindow.open_geom_parameters_file) # type: ignore + self.pattern_selection.currentTextChanged['QString'].connect(MainWindow.pattern_selection_changed) # type: ignore + self.start_mc_button.clicked.connect(MainWindow.start_mc) # type: ignore + self.start_febid_button.clicked.connect(MainWindow.start_febid) # type: ignore + self.input_width.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_height.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_length.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_cell_size.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_substrate_height.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_param2.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_param1.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_width_mc.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_length_mc.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_height_mc.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_cell_size_mc.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_substrate_height_mc.editingFinished.connect(MainWindow.check_input) # type: ignore + self.beam_energy.editingFinished.connect(MainWindow.check_input) # type: ignore + self.energy_cutoff.editingFinished.connect(MainWindow.check_input) # type: ignore + self.number_of_e.editingFinished.connect(MainWindow.check_input) # type: ignore + self.gauss_dev.editingFinished.connect(MainWindow.check_input) # type: ignore + self.x_pos.editingFinished.connect(MainWindow.check_input) # type: ignore + self.y_pos.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_dwell_time.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_pitch.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_repeats.editingFinished.connect(MainWindow.check_input) # type: ignore + self.checkbox_save_simulation_data.stateChanged['int'].connect(MainWindow.change_state_save_sim_data) # type: ignore + self.checkbox_save_snapshots.stateChanged['int'].connect(MainWindow.change_state_save_snapshots) # type: ignore + self.input_simulation_data_interval.editingFinished.connect(MainWindow.check_input) # type: ignore + self.input_structure_snapshot_interval.editingFinished.connect(MainWindow.check_input) # type: ignore + self.tabWidget.currentChanged['int'].connect(MainWindow.tab_switched) # type: ignore + self.open_save_folder_button.clicked.connect(MainWindow.open_save_directory) # type: ignore + self.checkbox_show.stateChanged['int'].connect(MainWindow.change_state_show_process) # type: ignore + self.checkbox_load_last_session.stateChanged['int'].connect(MainWindow.change_state_load_last_session) # type: ignore + self.input_unique_name.editingFinished.connect(MainWindow.unique_name_changed) # type: ignore + self.open_settings_file_button.clicked.connect(MainWindow.open_settings_file) # type: ignore + self.checkbox_temperature_tracking.stateChanged['int'].connect(MainWindow.change_state_temperature_tracking) # type: ignore + self.gauss_order.editingFinished.connect(MainWindow.check_input) # type: ignore + self.checkbox_beam_heating.stateChanged['int'].connect(MainWindow.change_state_temperature_tracking) # type: ignore + self.input_hfw.editingFinished.connect(MainWindow.check_input) # type: ignore + self.actionOpen_session.triggered['bool'].connect(MainWindow.open_new_session) # type: ignore QtCore.QMetaObject.connectSlotsByName(MainWindow) - def connect_signals_to_slots(self, MainWindow): - self.choice_vtk_file.clicked.connect(MainWindow.vtk_chosen) # type: ignore - self.choice_geom_parameters_file.clicked.connect(MainWindow.geom_parameters_chosen) # type: ignore - self.choice_auto.clicked.connect(MainWindow.auto_chosen) # type: ignore - self.choice_simple_pattern.clicked.connect(MainWindow.simple_pattern_chosen) # type: ignore - self.choice_stream_file.clicked.connect(MainWindow.stream_file_chosen) # type: ignore - self.open_vtk_file_button.clicked.connect(MainWindow.open_vtk_file) # type: ignore - self.open_geom_parameters_file_button.clicked.connect(MainWindow.open_geom_parameters_file) # type: ignore - self.open_stream_file_button.clicked.connect(MainWindow.open_stream_file) # type: ignore - self.open_precursor_parameters_file_button.clicked.connect( - MainWindow.open_precursor_parameters_file) # type: ignore - self.open_vtk_file_button_mc.clicked.connect(MainWindow.open_vtk_file) # type: ignore - self.choice_vtk_file_mc.clicked.connect(MainWindow.vtk_chosen) # type: ignore - self.choice_geom_parameters_file_mc.clicked.connect(MainWindow.geom_parameters_chosen) # type: ignore - self.open_beam_parameters_file_button_mc.clicked.connect(MainWindow.open_settings_file) # type: ignore - self.open_precursor_parameters_file_button_mc.clicked.connect( - MainWindow.open_precursor_parameters_file) # type: ignore - self.open_geom_parameters_file_button_mc.clicked.connect(MainWindow.open_geom_parameters_file) # type: ignore - self.pattern_selection.currentTextChanged['QString'].connect( - MainWindow.pattern_selection_changed) # type: ignore - self.start_mc_button.clicked.connect(MainWindow.start_mc) # type: ignore - self.start_febid_button.clicked.connect(MainWindow.start_febid) # type: ignore - self.input_width.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_height.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_length.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_cell_size.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_substrate_height.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_param2.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_param1.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_width_mc.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_length_mc.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_height_mc.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_cell_size_mc.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_substrate_height_mc.editingFinished.connect(MainWindow.check_input) # type: ignore - self.beam_energy.editingFinished.connect(MainWindow.check_input) # type: ignore - self.energy_cutoff.editingFinished.connect(MainWindow.check_input) # type: ignore - self.number_of_e.editingFinished.connect(MainWindow.check_input) # type: ignore - self.gauss_dev.editingFinished.connect(MainWindow.check_input) # type: ignore - self.x_pos.editingFinished.connect(MainWindow.check_input) # type: ignore - self.y_pos.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_dwell_time.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_pitch.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_repeats.editingFinished.connect(MainWindow.check_input) # type: ignore - self.checkbox_save_simulation_data.stateChanged['int'].connect( - MainWindow.change_state_save_sim_data) # type: ignore - self.checkbox_save_snapshots.stateChanged['int'].connect(MainWindow.change_state_save_snapshots) # type: ignore - self.input_sim_data_interval.editingFinished.connect(MainWindow.check_input) # type: ignore - self.input_snapshot_interval.editingFinished.connect(MainWindow.check_input) # type: ignore - self.tabWidget.currentChanged['int'].connect(MainWindow.tab_switched) # type: ignore - self.open_save_folder_button.clicked.connect(MainWindow.open_save_directory) # type: ignore - self.checkbox_show.stateChanged['int'].connect(MainWindow.change_state_show_process) # type: ignore - self.checkbox_load_last_session.stateChanged['int'].connect( - MainWindow.change_state_load_last_session) # type: ignore - self.input_unique_name.editingFinished.connect(MainWindow.unique_name_changed) # type: ignore - self.open_settings_file_button.clicked.connect(MainWindow.open_settings_file) # type: ignore - self.checkbox_temperature_tracking.stateChanged['int'].connect( - MainWindow.change_state_temperature_tracking) # type: ignore - self.gauss_order.editingFinished.connect(MainWindow.check_input) # type: ignore - self.checkbox_beam_heating.stateChanged['int'].connect( - MainWindow.change_state_temperature_tracking) # type: ignore - self.input_hfw.editingFinished.connect(MainWindow.check_input) # type: ignore - self.actionOpen_session.triggered['bool'].connect(MainWindow.open_new_session) # type: ignore - def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) @@ -613,13 +605,11 @@ def retranslateUi(self, MainWindow): self.checkbox_save_simulation_data.setText(_translate("MainWindow", "Save simulation data")) self.checkbox_save_snapshots.setText(_translate("MainWindow", "Save structure snapshots")) self.l_sim_data_interval.setText(_translate("MainWindow", "every")) - self.l_sim_data_interval_units.setText(_translate("MainWindow", "x 0.1 s")) - self.input_sim_data_interval.setText(_translate("MainWindow", "0.1")) - self.input_sim_data_interval.setPlaceholderText(_translate("MainWindow", "1")) - self.input_snapshot_interval.setText(_translate("MainWindow", "1")) - self.input_snapshot_interval.setPlaceholderText(_translate("MainWindow", "10")) + self.l_sim_data_interval_units.setText(_translate("MainWindow", " s")) + self.input_simulation_data_interval.setPlaceholderText(_translate("MainWindow", "1e-2")) + self.input_structure_snapshot_interval.setPlaceholderText(_translate("MainWindow", "1e-1")) self.l_snapshot_interval.setText(_translate("MainWindow", "every")) - self.l_snapshot_interval_units.setText(_translate("MainWindow", "x 0.1 s")) + self.l_snapshot_interval_units.setText(_translate("MainWindow", " s")) self.input_unique_name.setPlaceholderText(_translate("MainWindow", "experiment_1")) self.l_unique_name.setText(_translate("MainWindow", "unique name:")) self.open_save_folder_button.setText(_translate("MainWindow", "Open folder")) diff --git a/febid/ui/main_window.ui b/febid/ui/main_window.ui index 6f9a22b..0445265 100644 --- a/febid/ui/main_window.ui +++ b/febid/ui/main_window.ui @@ -7,7 +7,7 @@ 0 0 605 - 698 + 745 @@ -933,10 +933,10 @@ - x 0.1 s + s - + 240 @@ -946,16 +946,16 @@ - 0.1 + - 5 + 6 - 1 + 1e-2 - + 240 @@ -965,13 +965,13 @@ - 1 + 5 - 10 + 1e-1 @@ -997,7 +997,7 @@ - x 0.1 s + s @@ -1822,7 +1822,7 @@ 0 0 605 - 22 + 30 @@ -2517,7 +2517,7 @@ - input_sim_data_interval + input_simulation_data_interval editingFinished() MainWindow check_input() @@ -2533,7 +2533,7 @@ - input_snapshot_interval + input_structure_snapshot_interval editingFinished() MainWindow check_input() diff --git a/febid/ui/ui_shell.py b/febid/ui/ui_shell.py index 34be988..7178d61 100644 --- a/febid/ui/ui_shell.py +++ b/febid/ui/ui_shell.py @@ -17,8 +17,6 @@ from febid.monte_carlo import etraj3d as e3d from febid.libraries.vtk_rendering.VTK_Rendering import read_field_data -faulthandler.enable(file=sys.stderr) - class SessionHandler: """ @@ -563,8 +561,8 @@ def ui_to_parameters_mapping(self): 'temperature_tracking': self.checkbox_temperature_tracking, 'save_simulation_data': self.checkbox_save_simulation_data, 'save_structure_snapshot': self.checkbox_save_snapshots, - 'simulation_data_interval': self.input_sim_data_interval, - 'structure_snapshot_interval': self.input_snapshot_interval, + 'simulation_data_interval': self.input_simulation_data_interval, + 'structure_snapshot_interval': self.input_structure_snapshot_interval, 'unique_name': self.input_unique_name, 'save_directory': self.save_folder_display, 'show_process': self.checkbox_show @@ -651,9 +649,9 @@ def __group_interface_elements(self): self.ui_hfw = UI_Group(self.l_hfw, self.input_hfw, self.l_hfw_units) - self.ui_sim_data_interval = UI_Group(self.l_sim_data_interval, self.input_sim_data_interval, + self.ui_sim_data_interval = UI_Group(self.l_sim_data_interval, self.input_simulation_data_interval, self.l_sim_data_interval_units) - self.ui_snapshot = UI_Group(self.l_snapshot_interval, self.input_snapshot_interval, + self.ui_snapshot = UI_Group(self.l_snapshot_interval, self.input_structure_snapshot_interval, self.l_snapshot_interval_units) self.ui_unique_name = UI_Group(self.l_unique_name, self.input_unique_name) self.ui_save_folder = UI_Group(self.open_save_folder_button, self.save_folder_display)