def check_body_data(self): mesh_body = self.mesh_f_t3.text() if not os.path.isfile(mesh_body): mesh_body = os.path.join(self._prj, self._raw, os.path.basename(mesh_body)) id_body = split_string(self.id_body_t3.text(), int) cog_body = split_string(self.cog_body_t3.text(), sep=',') cs_body = split_string(self.cs_body_t3.text(), sep=',') dof_body = split_string_multilist(self.dof_body_t3.text(), sep=',', sep_multi=';') chil_body = split_string_multilist(self.chil_body_t3.text(), sep=',', sep_multi=';') parent_body = split_string(self.parent_body_t3.text(), int) mass_body = split_string(self.mass_body_t3.text(), float) inertia_body = split_string_multilist(self.inertia_body_t3.text(), float, sep=',', sep_multi=';') data = [id_body, mass_body, inertia_body, mesh_body, cog_body, cs_body, dof_body, chil_body, parent_body] data_st = [] data_st.append(raise_error([el for el in range(1) if os.path.isfile(mesh_body)], self.mesh_f_t3, 1, self.add_err_t3)) data_st.append(raise_error(id_body, self.id_body_t3, 1, self.add_err_t3)) data_st.append(raise_error(cog_body, self.cog_body_t3, 3, self.add_err_t3)) data_st.append(raise_error(cs_body, self.cs_body_t3, 3, self.add_err_t3)) data_st.append(raise_error(dof_body, self.dof_body_t3, 0, self.add_err_t3, gt=True)) data_st.append(raise_error(chil_body, self.chil_body_t3, 0, self.add_err_t3, gt=True)) data_st.append(raise_error(parent_body, self.parent_body_t3, 1, self.add_err_t3)) data_st.append(raise_error(mass_body, self.mass_body_t3, 1, self.add_err_t3)) data_st.append(raise_error([item for sublist in inertia_body for item in sublist], self.inertia_body_t3, 9, self.add_err_t3)) return data, data_st
def pull_data_from_form(self): get_array_mat = self.cb_gen_array_mat_t4.isChecked() input_type = 4 ndof = split_string(self.ndof_t4.text(), int) pto_dof = split_string(self.pto_dof_t4.text(), int, sep=',') moor_dof = split_string(self.moor_dof_t4.text(), int, sep=',') data_f = self.le_data_t4.text() mesh_f = self.mesh_f_t4.text() general_inputs = { 'ndof': ndof, 'pto_dof': pto_dof, 'mooring_dof': moor_dof, 'frequency_def': [], 'angle_def': [], 'data_folder': data_f, 'water_depth': [], 'get_array_mat': int(get_array_mat), 'cyl_nzeta': [], 'cyl_ntheta': [], 'input_type': input_type } body0 = {'body0': {'mesh': mesh_f}} body_inputs = {'local_cs': [], 'shared_dof': [], 'body': body0} inputs_hydrodynamic = { 'general_input': general_inputs, 'body_inputs': body_inputs } return inputs_hydrodynamic
def check(self): if os.path.isdir(self.le_data_t4.text()): data_folder = self.le_data_t4.text() status = in_ck.check_wamit_results( data_folder, get_array_mat=self.cb_gen_array_mat_t4.isChecked()) if status[0]: ndof = split_string(self.ndof_t4.text(), int) pto_dof = split_string(self.pto_dof_t4.text(), int, sep=',') mooring_dof = split_string(self.moor_dof_t4.text(), int, sep=',') if not ndof: print("Missing number of independent dof") return False else: return True else: print(status[1]) return False else: print("The specified path is not a valid folder") return False
def submit_input_data(self): self.save_project() status = self.check_input_data() if status[0]: self.btn_load_data_t3.setEnabled(True) self._data['inputs_hydrodynamic']['general_input']['ndof'] = split_string(self.ndof_t3.text(), int) self._data['inputs_hydrodynamic']['general_input']['pto_dof'] = split_string(self.pto_dof_t3.text(), int) self._data['inputs_hydrodynamic']['general_input']['mooring_dof'] = split_string(self.moor_dof_t3.text(), int) self._data['inputs_hydrodynamic']['general_input']['input_type'] = 3 self._data['inputs_hydrodynamic']['general_input']['data_folder'] = self.le_data_t3.text() self._data['inputs_hydrodynamic']['general_input']['get_array_mat'] = int(self.cb_gen_array_mat_t3.isChecked()) else: self.btn_load_data_t3.setEnabled(False)
def pull_data_from_form(self): bodies = {} for el in range(self.tab_body_t3.rowCount()): id_body = split_string(self.tab_body_t3.item(el,0).text(), int) mass_body = split_string(self.tab_body_t3.item(el,1).text()) inertia_body = split_string_multilist(self.tab_body_t3.item(el,2).text(), float, sep=',', sep_multi=';') mesh_body = self.tab_body_t3.item(el,3).text() cog_body = split_string(self.tab_body_t3.item(el,4).text(), float, sep=',') cs_body = split_string(self.tab_body_t3.item(el,5).text(), float, sep=',') dof_body = split_string_multilist(self.tab_body_t3.item(el,6).text(), float, sep=',', sep_multi=';') if not dof_body[0]: dof_body = -1 chil_body = split_string_multilist(self.tab_body_t3.item(el,7).text(), float, sep=',', sep_multi=';') if not chil_body[0]: chil_body = -1 parent_body = split_string(self.tab_body_t3.item(el,8).text(), int) str_bi = 'body{}'.format(id_body[0]) bodies[str_bi] = {'mass': mass_body, 'inertia': inertia_body, 'ID': id_body, 'mesh': mesh_body, 'cog': cog_body, 'child_dof_position': chil_body, 'dof_with_parent': dof_body, 'number_child':1, 'axis_angles':cs_body, 'parent_body': parent_body} ndof = split_string(self.ndof_t3.text(), int) pto_dof = split_string(self.pto_dof_t3.text(), int, sep=',') moor_dof = split_string(self.moor_dof_t3.text(), int) local_cs = split_string(self.local_cs_t3.text(), float, sep=',') shared_dof = list(self._data['inputs_hydrodynamic']['body_inputs']['shared_dof']) get_array_mat = self.cb_gen_array_mat_t3.isChecked() input_type = 3 data_f = self.le_data_t3.text() general_inputs = {'ndof': ndof, 'pto_dof': pto_dof, 'mooring_dof': moor_dof, 'frequency_def': [], 'angle_def': [], 'data_folder': data_f, 'water_depth': [], 'get_array_mat': int(get_array_mat), 'cyl_nzeta': [], 'cyl_ntheta': [],'input_type':input_type} body_inputs = {'local_cs': local_cs, 'shared_dof': shared_dof, 'body': bodies} inputs_hydrodynamic = {'general_input': general_inputs, 'body_inputs': body_inputs} return inputs_hydrodynamic
def __read_mds(self, run_fl=True): file_name = [ el for el in os.listdir(self.data_folder) if el.endswith('.pot') ][0] f_mds = f_util.load_file(self.data_folder, file_name)[-1] modes = f_util.split_string(f_mds, int) full_list = [[1, 1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0, 0], [2, 1, 0, 0, 0, 0, 0], [2, 0, 1, 0, 0, 0, 0], [2, 0, 0, 1, 0, 0, 0]] return [el for ind, el in enumerate(full_list) if modes[ind] == 1]
def get_cylinder_dimension(self): with open(os.path.join(self._path_prj_hdy, 'nemoh.cal'), 'r') as fid: lines = fid.readlines() # TODO: this is a weak point, increase the realiability of this search for i_lin in range(len(lines)): if not lines[-i_lin - 1] == '\n': break cylinder = f_util.split_string(lines[-i_lin - 2]) cyl_nzeta = int(cylinder[2]) cyl_ntheta = int(cylinder[1]) cyl_radius = cylinder[0] return cyl_radius