def _create_Q_e(self): """ Function creates Q_e list of generalized external forces :return: """ Q_e_list = [] for i, body_id in enumerate(self.body_id_list): if isinstance(body_id, int): # size of vector Q_e n_Q_e = GlobalVariables.q_i_dim[body_id] # rigid body if n_Q_e == 3: Q_e = Force_Q_e_vector(n=n_Q_e) # flexible body else: name = "spring_force_on_flexible_body_of_" + self._parent._name # if parent is object - group of springs, than use this object properties if isinstance(self._parent, GroupItem): Q_e = Force(body_id, force_name=name, node_id=self.node_id_list[i], element_id=self.element_id_list[i], element_ksi=self.element_ksi_list[i], parent=self) else: Q_e = Force( body_id, force_name=name, node_id=self._parent.node_id_list[i], element_id=self._parent.element_id_list[i], element_ksi=self._parent.element_ksi_list[i], parent=self) else: Q_e = Force_Q_e_vector() Q_e_list.append(Q_e) return Q_e_list
def _save(self, item=None): """ """ _force_name = self.ui.name_lineEdit.text() # try: _body_id = int(self.ui.bodyID_lineEdit.text()) try: _Fx = float(self.ui.Fx_lineEdit.text()) except: _Fx = self.ui.Fx_lineEdit.text() try: _Fy = float(self.ui.Fy_lineEdit.text()) except: _Fy = self.ui.Fy_lineEdit.text() try: _Mz = float(self.ui.Mz_lineEdit.text()) except: _Mz = self.ui.Mz_lineEdit.text() _u_iP_f = string2array(self.ui.uPi_lineEdit.text()) # save tzo existing object if self.item is not None: self.item.body_id = _body_id self.item.force_name = _force_name self.item.Fx = _Fx self.item.Fy = _Fy self.item.Mz = _Mz self.item.u_iP_f = _u_iP_f self.item._scale_GL, status = self.ui.scale_lineEdit.text( ).toFloat() # create new object with user specified properties else: _force = Force(body_id=_body_id, force_name=_force_name, Fx=_Fx, Fy=_Fy, Mz=_Mz, u_iP_f=_u_iP_f) pos = len(self.parent_node._children) self.parent_node._parent.forces.append(_force) self._parent.ui.treeView.model().insertRow(pos, _force, self.parent_node) self.close()
def _create_forces(self, direction=""): """ Method creates forces objects for each body in contact :return: """ F_list = [] if hasattr(self._parent, "body_id_list"): # create force object if direction == "normal": d = "n" elif direction == "tangent": d = "t" else: d = direction # for body_id, visibility in zip(self._parent.body_id_list, self._parent._visible_F_list): for body_id, visibility in zip( self.body_id_list, self._parent._visible_F_list ): # corrected from self._parent.body_id_list, self._parent._visible_F_list to self.body_id_list, self._parent._visible_F_list F = Force(body_id, force_name=self._parent._name + "_F" + d + "_on_body_" + str(body_id), visible=visibility, scale=self.scale, parent=self._parent) F_list.append(F) # create force visualization data ren = self._parent._parent._parent._parent.dys.simulation_control_widget.vtkWidget.renderer F.set_vtk_data(renderer=ren) # append force object to list of forces of MBD system object self._parent._parent._parent.forces.append(F) # append force object to list of forces of body object # self._parent._parent._parent.bodies[body_id].forces.append(F) return F_list
def _create_Fn_forces(self): """ Function creates list of contact forces as objects :return: """ self.Fn = 0 self._Fn_list = [] if self._parent is not None: for body_id in self.body_id_list: if body_id != "ground" and body_id is not None: _Fn = Force(body_id, force_name=self._name + "_Fn_on_body_" + str(body_id), parent=self) # add pair of contact forces to forces list of MBD system self._parent._parent.forces.append(_Fn) # add pair of contact forces to forces list of contact self._Fn_list.append(_Fn) self._parent._parent.bodies[body_id].forces.append(_Fn) self._Fn_list[0]._visible = False self.list_of_contact_force_objects_constructed = True
def _create_Fn_forces(self): """ :return: """ Fn_list = [] for body_id, _u_P in zip(self.body_id_list, self.u_P_CAD_list): if body_id == "ground" or body_id == -1: u_P_LCS = u_P_cad2cm_lcs(body_id, self._parent._parent.ground, _u_P=_u_P) body = self._parent._parent.ground else: # create pointer to body if self._parent is not None: body = self._parent._parent.bodies[body_id] # calculate point vector in body LCS (center of gravity) u_P_LCS = u_P_cad2cm_lcs(body_id, body, _u_P=_u_P) else: body = None u_P_LCS = np.zeros(2, dtype=float) # create force object if body is not None: force = Force(body_id, force_name=self._name + "_on_body_" + str(body_id), u_iP_f=u_P_LCS, parent=self) # add pair of contact forces to forces list of MBD system # self._parent._parent.forces.append(force) # add pair of contact forces to forces list of spring Fn_list.append(force) if body_id != "ground": self._parent._parent.bodies[body_id].forces.append(force) else: self._parent._parent.ground.forces.append(force) return Fn_list
def _create_Fn_forces(self): """ :return: """ Fn_list = [] for body_id, rP in zip(self.body_id_list, self.r_P_list): # create force object force = Force(body_id, force_name=self._name + "_on_body_" + str(body_id), r_P_GCS=rP, parent=self) # add pair of contact forces to forces list of MBD system # self._parent._parent.forces.append(force) # add pair of contact forces to forces list of spring Fn_list.append(force) return Fn_list