def ComputeQ(self,state_x, #/< state position to evaluate Q state_w): #/< state speed to evaluate Q #chrono.ChVectorD Enode_pos #chrono.ChVectorD Enode_vel #chrono.ChVectorD Fnode_pos #chrono.ChVectorD Fnode_vel if not state_x==None and not state_w==None : Enode_pos = chrono.ChVectorD(state_x[0], state_x[1], state_x[2]) Enode_vel = chrono.ChVectorD(state_w[0], state_w[1], state_w[2]) Fnode_pos = chrono.ChVectorD(state_x[3], state_x[4], state_x[5]) Fnode_vel = chrono.ChVectorD(state_w[3], state_w[4], state_w[5]) else: # explicit integrators might call ComputeQ(0,0), null pointers mean # that we assume current state, without passing state_x for efficiency Enode = fea.CastToChNodeFEAxyz( fea.CastToChNodeFEAbase( chrono.CastToChNodeBase(self.loadables[0]))) Fnode = fea.CastToChNodeFEAxyz( fea.CastToChNodeFEAbase( chrono.CastToChNodeBase(self.loadables[1]))) Enode_pos = Enode.GetPos() Enode_vel = Enode.GetPos_dt() Fnode_pos = Fnode.GetPos() Fnode_vel = Fnode.GetPos_dt() # Just implement two simple force+spring+dampers in xy plane: # ... from node E to ground, Kx1 = 60 Ky1 = 50 Dx1 = 0.3 Dy1 = 0.2 E_x_offset = 2 E_y_offset = 10 spring1 = chrono.ChVectorD(-Kx1 * (Enode_pos.x - E_x_offset) - Dx1 * Enode_vel.x, -Ky1 * (Enode_pos.y - E_y_offset) - Dy1 * Enode_vel.y, 0) # ... from node F to node E, Ky2 = 10 Dy2 = 0.2 EF_dist = 1 spring2 = chrono.ChVectorD (0, -Ky2 * (Fnode_pos.y - Enode_pos.y - EF_dist) - Dy2 * (Enode_vel.y - Fnode_vel.y), 0) Fforcey = 2 # store generalized forces as a contiguous vector in this.load_Q, with same order of state_w self.load_Q[0] = spring1.x - spring2.x # Fx component of force on 1st node self.load_Q[1] = spring1.y - spring2.y # Fy component of force on 1st node self.load_Q[2] = spring1.z - spring2.z # Fz component of force on 1st node self.load_Q[3] = spring2.x # Fx component of force on 2nd node self.load_Q[4] = spring2.y + Fforcey # Fy component of force on 2nd node self.load_Q[5] = spring2.z # Fz component of force on 2nd node
def ComputeQ(self,state_x, #/< state position to evaluate Q state_w): #/< state speed to evaluate Q if not state_x==None and not state_w==None : node_pos = chrono.ChVectorD(state_x[0], state_x[1], state_x[2]) node_vel = chrono.ChVectorD(state_w[0], state_w[1], state_w[2]) else: mynode = fea.CastToChNodeFEAxyz( fea.CastToChNodeFEAbase( chrono.CastToChNodeBase(self.loadable) )) node_pos = mynode.GetPos() node_vel = mynode.GetPos_dt() # Just implement a simple force+spring+damper in xy plane, # for spring&damper connected to absolute reference: Kx = 100 Ky = 400 Dx = 0.6 Dy = 0.9 x_offset = 2 y_offset = 10 x_force = 50 y_force = 0 # Store the computed generalized forces in this.load_Q, same x,y,z order as in state_w self.load_Q[0] = x_force - Kx * (node_pos.x - x_offset) - Dx * node_vel.x self.load_Q[1] = y_force - Ky * (node_pos.y - y_offset) - Dy * node_vel.y self.load_Q[2] = 0
VELCYFlex[i, 2] = 0 # Adding the nodes to the mesh i = 0 while i < TotalNumNodes: node = fea.ChNodeFEAxyz( chrono.ChVectorD(COORDFlex[i, 0], COORDFlex[i, 1], COORDFlex[i, 2])) node.SetMass(0.0) my_mesh.AddNode(node) if (NDR[i, 0] == 1 and NDR[i, 1] == 1 and NDR[i, 2] == 1): node.SetFixed(True) i += 1 nodetip = fea.CastToChNodeFEAxyz( fea.CastToChNodeFEAbase(my_mesh.GetNode(TotalNumNodes - 1))) elemcount = 0 while elemcount < TotalNumElements: element = fea.ChElementBrick() InertFlexVec = chrono.ChVectorD( ElemLengthXY[elemcount, 0], ElemLengthXY[elemcount, 1], ElemLengthXY[elemcount, 2]) # read element length, used in ChElementBrick element.SetInertFlexVec(InertFlexVec) element.SetNodes( fea.CastToChNodeFEAxyz( fea.CastToChNodeFEAbase( my_mesh.GetNode(int(NumNodes[elemcount, 0])))), fea.CastToChNodeFEAxyz( fea.CastToChNodeFEAbase(
def CastNode(nb): feaNB = fea.CastToChNodeFEAbase(nb) nodeFead = fea.CastToChNodeFEAxyzD(feaNB) return nodeFead
# Create the node node = fea.ChNodeFEAxyzD(chrono.ChVectorD(loc_x, loc_y, loc_z), chrono.ChVectorD(dir_x, dir_y, dir_z)) node.SetMass(0) # Fix all nodes along the axis X=0 if (i % (numDiv_x + 1) == 0): node.SetFixed(True) # Add node to mesh my_mesh.AddNode(node) # Get a handle to the tip node. tempnode = my_mesh.GetNode(TotalNumNodes - 1) tempfeanode = fea.CastToChNodeFEAbase(tempnode) nodetip = fea.CastToChNodeFEAxyzD(tempfeanode) # Create an orthotropic material. # All layers for all elements share the same material. rho = 500 E = chrono.ChVectorD(2.1e7, 2.1e7, 2.1e7) nu = chrono.ChVectorD(0.3, 0.3, 0.3) G = chrono.ChVectorD(8.0769231e6, 8.0769231e6, 8.0769231e6) mat = fea.ChMaterialShellANCF(rho, E, nu, G) # Create the elements for i in range(TotalNumElements): # Adjacent nodes node0 = (i // numDiv_x) * N_x + i % numDiv_x node1 = (i // numDiv_x) * N_x + i % numDiv_x + 1 node2 = (i // numDiv_x) * N_x + i % numDiv_x + 1 + N_x