def __init__(self, joint_type, body_id_i, body_id_j, u_iP_CAD=np.array([0, 0]), u_jP_CAD=np.array([0, 0]), u_iQ_CAD=np.array([0, 0]), parent=None): """ :param joint_type: :param body_id_i: :param body_id_j: :param u_iP_CAD: :param u_jP_CAD: :param u_iQ: :param parent: :return: """ self.joint_type = "prismatic" super(JointPrismatic, self).__init__(joint_type, body_id_i, body_id_j, u_iP_CAD=u_iP_CAD, u_jP_CAD=u_jP_CAD, u_iQ_CAD=u_iQ_CAD, parent=parent) # joint DOF self.joint_DOF = 1 # evaluate initial angle between connected bodies self.theta0 = self.evaluate_C0(self.q0) # add point u_iQ to an extended list self.u_iQ_LCS = u_P_cad2cm_lcs(self.body_id_i, self._parent._parent.bodies[self.body_id_i], self.u_iQ_CAD) # this extended list has elements in form of: # [uiP, ujP, uiQ] self.u_QP_LCS_list = self.u_P_LCS_list self.u_QP_LCS_list.append(self.u_iQ_LCS) # vector h_i self.h_i_LCS = self.u_iP_LCS - self.u_iQ_LCS # markers self.markers = self._create_markers()
def __init__(self, joint_type, body_id_i, body_id_j, u_iP_CAD=np.array([0, 0]), u_jP_CAD=np.array([0, 0]), u_iQ_CAD=np.array([0, 0]), properties_dict={}, parent=None): """ :param joint_type: :param body_id_i: :param body_id_j: :param u_iP_CAD: :param u_jP_CAD: :param u_iQ: :param parent: :return: """ self.joint_type = "prismatic" super(JointPrismatic, self).__init__(joint_type, body_id_i, body_id_j, u_iP_CAD=u_iP_CAD, u_jP_CAD=u_jP_CAD, u_iQ_CAD=u_iQ_CAD, properties_dict=properties_dict, parent=parent) # auto generated name by type and consecutive number self.prismatic_joint_id = (sum(1 for joint in self.joints_list if joint.joint_type == "prismatic") - 1) + 1 self._name = self.joint_type + "_" + str(self.prismatic_joint_id) # joint DOF self.joint_DOF = 1 # number of constrained (nodal) coordinates self.n_CNC = 3 - self.joint_DOF # C_q matrix dimensions [rows, cols] self.C_q_dim = [self.n_CNC, 3] # evaluate initial angle between connected bodies self.theta0 = self.evaluate_C0(self.q0) # add point u_iQ to an extended list self.u_iQ_LCS = u_P_cad2cm_lcs(self.body_id_i, self._parent._parent.bodies[self.body_id_i], self.u_iQ_CAD) # this extended list has elements in form of: # [uiP, ujP, uiQ] self.u_QP_LCS_list = self.u_P_LCS_list self.u_QP_LCS_list.append(self.u_iQ_LCS) # vector h_i self.h_i_LCS = self.u_iP_LCS - self.u_iQ_LCS
def __init__(self, body_id, force_name=None, Fx=0., Fy=0., Mz=0., u_iP_f=np.array([0., 0., 0.]), r_P_GCS=np.zeros(2), node_id=None, element_id=None, element_ksi=None, L_i=None, filename=None, data=None, visible=False, scale=1E-3, dict={}, parent=None): """ Constructor of force object :param body_id: number of body on which the force is applied as int :param force_name: force name as string :param F_x: component of force :param F_y: component of force :param M_z: component of moment :param u_iP_f: vector of acting force in CAD LCS of a body """ # body id self.body_id = body_id # parent self._element = None self.created_automatically = True self.remove = False # initial conditions self.q0 = [] if hasattr(parent, "_type") and isinstance(self.body_id, int): # force object is created from input file before simulation if parent._name.lower() == "forces": self._parent = parent self.created_automatically = False # body handle self._body = self._parent._parent.bodies[self.body_id] self._parent._parent.evaluate_q() self.q0 = self._parent._parent.q0 elif parent._typeInfo in ["spring", "joint"]: self._parent = parent if hasattr(self._parent._parent._parent, "bodies"): self._body = self._parent._parent._parent.bodies[ self.body_id] elif self._parent._parent._typeInfo in ["joint"]: # print "TESTING =", self._parent._parent, self._parent._parent._typeInfo self._body = self._parent._parent._parent._parent.bodies[ self.body_id] # self._body = self._parent._parent._parent._name, self._parent._parent._parent.bodies[self.body_id] # time.sleep(100) # if parent._parent._typeInfo in ["joint"]: # print "parent._parent =", parent._parent._parent._typeInfo # else: # self._body = self._parent._parent.bodies[self.body_id] elif hasattr(parent, "_parent"): if parent._parent._name.lower() == "contacts": self._parent = parent._parent._parent.forces # self._parent = None if parent._parent._name.lower() == "springs": self._parent = parent # self._body = parent._parent._parent.ground # body handle if isinstance(self.body_id, int): if hasattr(parent._parent._parent, "bodies"): self._body = parent._parent._parent.bodies[ self.body_id] else: self._body = parent._parent._parent.ground else: # body handle if isinstance(self.body_id, int): self._body = parent._parent._parent.bodies[self.body_id] else: self._body = parent._parent._parent.ground # self._parent = parent._parent._parent.forces # print "created automatically at contact!" # print "parent =", parent else: self._parent = None self._body = None # print "self._parent =", self._parent # if hasattr(self._parent, "_name"): # print "name =", self._parent._name # print "--------------------------------------------" # if not inspect.isclass(self._parent): # self._parent = None super(Force, self).__init__(force_name, parent=self._parent) # number self.force_id = self.__id.next() # additional user input comments self._comments = "" # name as string if force_name is None: self._name = "Force_" + str(self.force_id) else: self._name = force_name # additional force object property self._body_assigned = False # force components Fx, Fy, Mz self.Fx = Fx self.Fy = Fy self.F = np.array([self.Fx, self.Fy]) self.F_e = np.linalg.norm(self.F, ord=2) self.Mz = Mz # generalized force vector self.Q_e = np.zeros(3) # current step of integration self.step = 0 # user sub-routine as filename attribute self.filename = filename # function of time self._Fx_t = 0. self._Fy_t = 0. self._Mz_t = 0. # coordinate system, options: # LCS - force is applied in body LCS coordinates # GCS - force is applied in GCS coordinates self.CS = "GCS" # rigid body # position of acting force in CAD LCS of a body self.u_iP_f = u_iP_f[0:2] # position of force vector in CS # LCS self.u_P_LCS = np.zeros(2) # GCS self.r_P_GCS = r_P_GCS # flexible body self.node_id = node_id self.element_id = element_id self.element_ksi = element_ksi self.L_i = L_i if self.node_id == -1: self.element_id = self._body.mesh.elements[-1].element_id # z dimension if len(u_iP_f) == 2: self.z_dim_lcs = 0. else: self.z_dim_lcs = u_iP_f[2] # force data from file - matrix F(t) self.data = data # visualization properties self.vtk_mapper = None self.vtk_actor = None self.force = None self.renderer = None self.scale = scale self.color = np.array([1, 0, 0], dtype="float32") self._visible = visible self.P1 = None self.P2 = None # force position in body LCS (center of mass) if self._body is not None: self.u_P_LCS = u_P_cad2cm_lcs(self.body_id, self._body, self.u_iP_f) else: self.u_P_LCS = self.u_iP_f # init solution containers self._solution_containers() # add extra attributes from dictionary if dict is not None: self.add_attributes_from_dict(dict) if self.filename: self.file, extension = os.path.split(self.filename) self.filepath = None if self.filename is not None: if hasattr(GlobalVariables, "MBDsystem_folder"): self.filepath = os.path.join(GlobalVariables.MBDsystem_folder, self.filename) # add force object to body list of forces # if hasattr(self._parent, "_typeInfo"): # if self._parent._typeInfo == "group": # self._parent._parent.bodies[self.body_id].forces.append(self) # self.markers = self._create_markers() # create vtk data for visualization automatically during simulation when force object is created atomatically # e.g. when contact is detected and contact forces are present # if self._parent is None: # if self._parent.typeInfo() == "group": # self.set_vtk_data() self._update_count = 0