示例#1
0
	def CreateLoadSets(self):
		NumberOfUserDefinedSets=[0,0,0]
		buffer=(guitk.UserInput("Please specify the number of pressure areas,couplings and MPCs"))
		if buffer==None:
			print("Cancel is selected,no sets generated!")
		else:
			buffer=re.split(',|,',buffer)
			for i in range(0,min(len(buffer),3)):
				if buffer[i].isdecimal():
					NumberOfUserDefinedSets[i]=int(buffer[i])
				else:
					print("input error, please use the format XX,XX,XX to input, no user defined sets are generated.")
					return
			for i in range(NumberOfUserDefinedSets[0]):
				d={}
				d['Name']='PressureArea'+str(i+1)
				self.PressureSets.append(base.CreateEntity(constants.ABAQUS, "SET", d))
			for i in range(NumberOfUserDefinedSets[1]):
				d={}
				d['Name']='Coupling'+str(i+1)
				self.CouplingSets.append(base.CreateEntity(constants.ABAQUS, "SET", d))
			for i in range(NumberOfUserDefinedSets[2]):
				d={}
				d['Name']='MPC'+str(i+1)
				self.MPCSets.append(base.CreateEntity(constants.ABAQUS, "SET", d))	
			print("Sucessful!The sets are created!")
示例#2
0
    def create(self):

        self.originCoords = np.array(
            self.parentClip.geomType().centerCoordPointCoords)

        self.vectorZ = np.array(self.parentClip.geomType().largeFaceNormal)
        self.vectorX = np.array(
            self.parentClip.geomType().sideProjectionVectorPlus)
        self.vectorY = np.cross(self.vectorX, self.vectorZ)

        xAxisPointCoords = self.originCoords + self.vectorX
        zAxisPointCoords = self.originCoords + self.vectorZ

        # create coordinate system
        vals = {
            'Name': 'CLIP_COOR_SYS',
            'A1': self.originCoords[0],
            'A2': self.originCoords[1],
            'A3': self.originCoords[2],
            'B1': zAxisPointCoords[0],
            'B2': zAxisPointCoords[1],
            'B3': zAxisPointCoords[2],
            'C1': xAxisPointCoords[0],
            'C2': xAxisPointCoords[1],
            'C3': xAxisPointCoords[2]
        }
        self.coorSysEntity = base.CreateEntity(constants.ABAQUS,
                                               "ORIENTATION_R", vals)
        self.id = self.coorSysEntity._id
示例#3
0
def ConstrainedJointRevolute(Include='None', PutInInclude='0'):
    dogy = list()
    if (Include == 'None'):
        Joints = base.CollectEntities(constants.LSDYNA, None,
                                      "CONSTRAINED_JOINT_REVOLUTE", False)
    else:
        Joints = base.CollectEntities(constants.LSDYNA, Include,
                                      "CONSTRAINED_JOINT_REVOLUTE", False)

    PBUSH = base.CreateEntity(constants.NASTRAN, 'PBUSH', {
        'K1': '1E6',
        'K2': '1E6',
        'K3': '1E6',
        'K4': '0',
        'K5': '0',
        'K6': '0'
    })
    print("    Starting ConstrainedJointRevolute To CBUSH %s" %
          (datetime.datetime.now()))
    print("        Proccesing %s entities" % (len(Joints)))
    for Joint in Joints:
        N1 = base.GetEntityCardValues(constants.LSDYNA, Joint, ('N1', ))['N1']
        N2 = base.GetEntityCardValues(constants.LSDYNA, Joint, ('N2', ))['N2']
        N3 = base.GetEntityCardValues(constants.LSDYNA, Joint, ('N3', ))['N3']
        N4 = base.GetEntityCardValues(constants.LSDYNA, Joint, ('N4', ))['N4']
        CBUSH = base.CreateEntity(
            constants.NASTRAN, 'CBUSH', {
                'PID': PBUSH._id,
                'GA': N1,
                'GB': N2,
                'Orient': 'With Cord',
                'CID': '0'
            })
        CBUSH = base.CreateEntity(
            constants.NASTRAN, 'CBUSH', {
                'PID': PBUSH._id,
                'GA': N3,
                'GB': N4,
                'Orient': 'With Cord',
                'CID': '0'
            })
        dogy.append(CBUSH)
    print("    Finished ConstrainedJointSpherical To CBUSH %s" %
          (datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)
示例#4
0
	def CreateCouplingAndMPCs(self):
		self.CouplingSets=[i for i in self.CouplingSets if str(i).find('id:0>')==-1 and i!=None]
		self.MPCSets=[i for i in self.MPCSets if str(i).find('id:0>')==-1 and i!=None]
		for LoadSets in [self.CouplingSets,self.MPCSets]:
			for i in LoadSets:
				BoundaryArea = base.CollectEntities(constants.ABAQUS,i,{'SHELL','FACE','CONS','NODE','SOLIDFACET','SOLID',})
				BoundaryHotPoints = base.CollectEntities(constants.ABAQUS,BoundaryArea,{'NODE','HOT POINT'})
				BoundaryNodes=base.CollectEntities(constants.ABAQUS,i,{'NODE',})
#				print(BoundaryNodes+BoundaryHotPoints)
				if BoundaryNodes+BoundaryHotPoints==[]:
#					print("The contents in the sets are not supported to create coupling and MPC automatically!")
					continue
				else:
#					print(BoundaryHotPoints)
					CardVals=('X','Y','Z')
					PointTempX=[]
					PointTempY=[]
					PointTempZ=[]
			
					for BHP in BoundaryNodes+BoundaryHotPoints:
						CardValues=base.GetEntityCardValues(constants.ABAQUS, BHP,CardVals)
						PointTempX.append(CardValues['X'])
						PointTempY.append(CardValues['Y'])
						PointTempZ.append(CardValues['Z'])
					BoundaryNodeCoord=[sum(PointTempX)/len(PointTempX),sum(PointTempY)/len(PointTempY),sum(PointTempZ)/len(PointTempZ)]
					RefNode=base.CreateEntity(constants.ABAQUS, "NODE",{'X':BoundaryNodeCoord[0],'Y':BoundaryNodeCoord[1],'Z':BoundaryNodeCoord[2]})
#					print("RefNode=",RefNode)
					if LoadSets==self.CouplingSets:		
						CRCP={'COUPLING':'*DISTRIBUTING','REF NODE':base.GetEntityCardValues(constants.ABAQUS,RefNode,{'ID'})['ID'],'SURF.TYPE':'NODE-BASED','DOF':123,'NSET':base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'],'Name': 'FromSet'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])}
						base.CreateEntity(constants.ABAQUS,"COUPLING",CRCP)
						CRRNS1={'Name':'RefNode'+str(base.GetEntityCardValues(constants.ABAQUS,RefNode,{'ID'})['ID'])+'For'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name']),}
						RNS1Set=base.CreateEntity(constants.ABAQUS,"SET",CRRNS1)
#						print('CRRNS1=',CRRNS1)
						base.AddToSet(RNS1Set,RefNode)
						self.RefNodesSets.append(RNS1Set)
					elif LoadSets==self.MPCSets:
						base.AddToSet(i,RefNode)
						CRMPC={'TYPE': 'BEAM', 'NSET': base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'], 'NODE0': base.GetEntityCardValues(constants.ABAQUS,RefNode,{'ID'})['ID'],'Name': 'FromSet'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name']),}
						base.CreateEntity(constants.ABAQUS,"MPC",CRMPC)
						CRRNS2={'Name':'RefNode'+str(base.GetEntityCardValues(constants.ABAQUS,RefNode,{'ID'})['ID'])+'For'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name']),}
						RNS2Set=base.CreateEntity(constants.ABAQUS,"SET",CRRNS2)
						base.AddToSet(RNS2Set,RefNode)
						self.RefNodesSets.append(RNS2Set)
		return 0
示例#5
0
def ConstrainedRigidBodies(Include='None', PutInInclude=0):
    dogy = list()
    if (Include == 'None'):
        RigidBodies = base.CollectEntities(constants.LSDYNA, None,
                                           "CONSTRAINED_RIGID_BODIES", False)
    else:
        RigidBodies = base.CollectEntities(constants.LSDYNA, Include,
                                           "CONSTRAINED_RIGID_BODIES", False)
    print("    Starting ConstrainedRigidBodies To RBE2 %s" %
          (datetime.datetime.now()))
    print("        Proccesing %s entities" % (len(RigidBodies)))
    for RigidBody in RigidBodies:
        PIDM = base.GetEntityCardValues(constants.LSDYNA, RigidBody,
                                        ('PIDM', ))['PIDM']
        PartEntity = base.GetEntity(constants.LSDYNA, '__PROPERTIES__', PIDM)
        PartNodes = base.CollectEntities(constants.LSDYNA,
                                         PartEntity,
                                         "NODE",
                                         recursive=True)
        if (len(PartNodes) == 0):
            print("            ***Warning: Part %s has no nodes" %
                  (PartEntity._id))
            continue
        PartMNode1 = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                   entity=PartNodes[0],
                                                   fields=('NID', ))['NID']
        PIDS = base.GetEntityCardValues(constants.LSDYNA, RigidBody,
                                        ('PIDS', ))['PIDS']
        PartEntity = base.GetEntity(constants.LSDYNA, '__PROPERTIES__', PIDS)
        PartNodes = base.CollectEntities(constants.LSDYNA,
                                         PartEntity,
                                         "NODE",
                                         recursive=True)
        if (len(PartNodes) == 0):
            print("            ***Warning: Part %s has no nodes" %
                  (PartEntity._id))
            continue
        PartSNode1 = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                   entity=PartNodes[0],
                                                   fields=('NID', ))['NID']
        RBE2 = base.CreateEntity(
            constants.NASTRAN, "RBE2", {
                'GN': PartMNode1,
                'GM1': PartSNode1,
                'No.of.Nodes': '2',
                'CM': '123456'
            })
        dogy.append(RBE2)
    print("    Finished ConstrainedRigidBodies To RBE2 %s" %
          (datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)
示例#6
0
def MatRigid(Include='None', PutInInclude='0'):
    dogy = list()
    Mat20 = base.CollectEntities(constants.LSDYNA, None, 'MAT20 MAT_RIGID',
                                 False)
    PartsMat20 = Parts = base.CollectEntities(constants.LSDYNA,
                                              Mat20,
                                              '__PROPERTIES__',
                                              prop_from_entities=True)
    if (Include == 'None'):
        PartsInclude = base.CollectEntities(constants.LSDYNA, None,
                                            '__PROPERTIES__', False)
    else:
        PartsInclude = base.CollectEntities(constants.LSDYNA, Include,
                                            '__PROPERTIES__', False)
    Parts = list(set(PartsMat20) & set(PartsInclude))
    print("    Starting MatRigid To RBE2 %s" % (datetime.datetime.now()))
    print("        Proccesing %s entities" % (len(Parts)))
    for Part in Parts:
        # MatType = base.GetEntityCardValues(constants.LSDYNA,Part,('MID->__type__',)) # See page 27
        PartNodes = base.CollectEntities(constants.LSDYNA,
                                         Part,
                                         "NODE",
                                         recursive=True)
        NodeSet = base.CreateEntity(constants.LSDYNA, "SET",
                                    {'OUTPUT TYPE': 'SET_NODE'})
        base.AddToSet(NodeSet, PartNodes)
        if (len(PartNodes) == 0):
            print("            ***Warning: Part %s has no nodes" % (Part._id))
            continue
        RBE2 = base.CreateEntity(constants.NASTRAN, "RBE2", {
            'GN': PartNodes[0]._id,
            'GM NSET': NodeSet._id,
            'CM': '123456'
        })
        dogy.append(RBE2)
    print("    Finished MatRigid To RBE2 %s" % (datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)
示例#7
0
	def CreateFixSets(self):
		buffer=(guitk.UserInput("Please specify the DOFs you want to fix, use , to seperate different sets"))
		if buffer==None:
			print("Cancel is selected,no sets generated!")
		else:
			buffer=re.split(',|,',buffer)
			for i in range(0,len(buffer)):
				if buffer[i].isdecimal():
					d={}
					d['Name']='Fix'+str(buffer[i])
					self.FixSets.append(base.CreateEntity(constants.ABAQUS, "SET", d))
				else:
					print("input error, please use the format XX,XX,XX to input, no user defined sets are generated.")
					return			
		return
示例#8
0
    def createEntity(self):

        fields = {
            'Name': self.getName(False),
            'Output as:': 'Set',
            'OUTPUT TYPE': 'ELSET'
        }
        self.setEntity = base.CreateEntity(
            constants.ABAQUS,
            'SET',
            fields,
            include=self.parentApplication.include)

        if self.setEntity is not None:
            base.SetEntityId(self.setEntity, self.id)
示例#9
0
	def CreateStepOutPut(self):
		if base.GetEntity(constants.ABAQUS, "STEP", 1) ==None:
			WorkStep=base.CreateEntity(constants.ABAQUS, "STEP",{'STEP ID':'1','Name':'Work Step 1',})
		else:
			vals={'Name':'WorkStep'}
			WorkStep=base.GetEntity(constants.ABAQUS, "STEP", 1)
			base.SetEntityCardValues(constants.ABAQUS,WorkStep,vals)
#		if base.AbqStepCollectOutputRequests(WorkStep)==None:
			base.AbqStepInsertOutputRequest(WorkStep, "*OUTPUT",)
			base.AbqStepInsertOutputRequest(WorkStep, "*ELEMENT OUTPUT", "Identifying Keys","S,E","SECTION POINTS", "all")
			base.AbqStepInsertOutputRequest(WorkStep, "*NODE OUTPUT", "Identifying Keys","U","SECTION POINTS", "all")
			base.AbqStepInsertOutputRequest(WorkStep, "*CONTACT OUTPUT", "Identifying Keys","CFORCE",)
			base.AbqStepInsertOutputRequest(WorkStep, "*OUTPUT","PARAMETER","HISTORY",)
			NSETID=[]
			for i in range(len(self.RefNodesSets)):
				NSETID.append(base.GetEntityCardValues(constants.ABAQUS,self.RefNodesSets[i],{'SID'})['SID'])	
			base.AbqStepInsertOutputRequest(WorkStep, "*NODE OUTPUT","NSET",NSETID,"Identifying Keys","RF",)
		print("Your step and output has been created! Please create output after the ref node sets are created if the outputs for them are wanted be automatically generated!")
示例#10
0
def ConstrainedExtraNodesNode(Include='None', PutInInclude='0'):
    print("Inlude File Name:%s ,ID:%s" % (Include._name, Include._id))

    dogy = list()
    if (Include == 'None'):
        ExtraNodes = base.CollectEntities(constants.LSDYNA, None,
                                          "CONSTRAINED_EXTRA_NODES_NODE",
                                          False)
    else:
        ExtraNodes = base.CollectEntities(constants.LSDYNA, Include,
                                          "CONSTRAINED_EXTRA_NODES_NODE",
                                          False)
    print("    Starting ConstrainedExtraNodesNode To RBE2 %s" %
          (datetime.datetime.now()))
    print("        Proccesing %s entities" % (len(ExtraNodes)))
    for ExtraNode in ExtraNodes:
        PID = base.GetEntityCardValues(constants.LSDYNA, ExtraNode,
                                       ('PID', ))['PID']
        NID = base.GetEntityCardValues(constants.LSDYNA, ExtraNode,
                                       ('NID', ))['NID']
        PartEntity = base.GetEntity(constants.LSDYNA, '__PROPERTIES__', PID)
        PartNodes = base.CollectEntities(constants.LSDYNA,
                                         PartEntity,
                                         "NODE",
                                         recursive=True)
        if (len(PartNodes) == 0):
            print("            ***Warning: Part %s has no nodes" %
                  (PartEntity._id))
            continue
        PartNode1 = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                  entity=PartNodes[0],
                                                  fields=('NID', ))['NID']
        RBE2 = base.CreateEntity(constants.NASTRAN, "RBE2", {
            'GN': PartNode1,
            'GM1': NID,
            'No.of.Nodes': '2',
            'CM': '123456'
        })
        dogy.append(RBE2)
    print("    Finished ConstrainedExtraNodesNode To RBE2 %s" %
          (datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)
示例#11
0
def Free_Edge():
    '''
	Name: Free_Edge
	Description: Creates a set of elements having more than 1 free edge
	'''

    deck = constants.NASTRAN
    set_check = base.CollectEntities(deck, None, "SET")
    for set in set_check:
        if set.get_entity_values(deck, {'Name'}) == {'Name': 'Free Edge'}:
            guitk.UserWarning("SET named Free Edge already exists")
            return 1
        else:
            continue
    parts = base.CollectEntities(deck, None, "ANSAPART", filter_visible=True)
    idlist = []
    element_list = []
    final = []

    # Collect node ids of first order boundary elements from visible parts
    for part in parts:
        nodes = base.CollectBoundaryNodes(part, False)
        ids = nodes.perimeters
        for id in ids:
            for x in id:
                idlist.append(x._id)

    # collect elements from node list
    for id in idlist:
        ans = base.NodesToElements(id)
        for key, data in ans.items():
            for x in data:
                element_list.append(x)

    # remove duplicate elements
    for element in sorted(element_list):
        while element_list.count(element) > 1:
            element_list.remove(element)

    # collect nodes of each element
    # collect all the elements attached to each node
    # create a list of no.of elements attached to each node
    for element in element_list:
        G1_elements = []
        G2_elements = []
        G3_elements = []
        G4_elements = []
        G_elements = []
        card = element.get_entity_values(deck, {'G1', 'G2', 'G3', 'G4'})
        for key, data in (base.NodesToElements(card['G1']._id)).items():
            for x in data:
                G1_elements.append(x)
        for key, data in (base.NodesToElements(card['G2']._id)).items():
            for x in data:
                G2_elements.append(x)
        for key, data in (base.NodesToElements(card['G3']._id)).items():
            for x in data:
                G3_elements.append(x)
        # element type 517 is tria, ignore fourth node
        if element._type == 517:
            pass
        else:
            for key, data in (base.NodesToElements(card['G4']._id)).items():
                for x in data:
                    G4_elements.append(x)
            G4_elements.remove(element)
            G_elements.append(len(G4_elements))
        G1_elements.remove(element)
        G_elements.append(len(G1_elements))
        G2_elements.remove(element)
        G_elements.append(len(G2_elements))
        G3_elements.remove(element)
        G_elements.append(len(G3_elements))

        # element has free edge if two adj nodes have no common elements
        # store elements with more than two free edges in final list
        result = []
        for val in G1_elements:
            if G2_elements.count(val) >= 1:
                Edge1 = 0
                break
            else:
                Edge1 = 1
        result.append(Edge1)
        for val in G2_elements:
            if G3_elements.count(val) >= 1:
                Edge2 = 0
                break
            else:
                Edge2 = 1
        result.append(Edge2)
        if element._type == 517:
            for val in G3_elements:
                if G1_elements.count(val) >= 1:
                    Edge3 = 0
                    break
                else:
                    Edge3 = 1
            result.append(Edge3)
        else:
            for val in G3_elements:
                if G4_elements.count(val) >= 1:
                    Edge3 = 0
                    break
                else:
                    Edge3 = 1
            result.append(Edge3)
            for val in G4_elements:
                if G1_elements.count(val) >= 1:
                    Edge4 = 0
                    break
                else:
                    Edge4 = 1
            result.append(Edge4)
        if result.count(1) >= 2:
            final.append(element)

        # no.of elements attached to a node is 0, then node has two free edges
        elif element._type == 513 and G_elements.count(0) >= 1:
            final.append(element)

        # Trias have G4 value as zero
        elif element._type == 517 and G_elements.count(0) >= 2:
            final.append(element)
        else:
            pass

    set = base.CreateEntity(deck, 'SET', {'Name': 'Free Edge'})
    base.AddToSet(set, final)
    return 1
示例#12
0
	def CreateFixForFixSets(self):
		self.FixSets=[i for i in self.FixSets if str(i).find('id:0>')==-1 and i!=None]
		for i in self.FixSets:
			print(str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])[3:])
			BoundaryVals={ 'by': 'set','NSET':base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'],'DOF': str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])[3:],'Magn(N)': '0','Name':'BoundaryOf'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name']),'TYPE':'DISPLACEMENT',}
			base.CreateEntity(constants.ABAQUS,"BOUNDARY",BoundaryVals)
示例#13
0
	def CreateDloadForPressureSets(self):
		self.PressureSets=[i for i in self.PressureSets if str(i).find('id:0>')==-1 and i!=None]
		for i in self.PressureSets:
			if base.CollectEntities(constants.ABAQUS, i, "__ALL_ENTITIES__",True)!=[]:
				PressureVals={ 'by': 'set','STEP':1,'ELSET':base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'],'LOAD TYPE':'P','magn(EID)':0,'Name':'DloadOf'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])}
				base.CreateEntity(constants.ABAQUS,"DLOAD",PressureVals)
示例#14
0
	def CreateCloadForRefNodes(self):
		self.RefNodesSets=[i for i in self.RefNodesSets if str(i).find('id:0>')==-1 and i!=None]
		for i in self.RefNodesSets:
			CloadVals={ 'by': 'set','STEP':1,'NSET':base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'],'DOF': '1: Fx','magn(N)': '0','Name':'CloadOf'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])}
			base.CreateEntity(constants.ABAQUS,"CLOAD",CloadVals)
		self.PressureSets=[i for i in self.PressureSets if str(i).find('id:0>')==-1 and i!=None]
def main():
    created_forces = list()
    solver = constants.NASTRAN
    print("Please select the FORCE CSV file...")
    filename = utils.SelectOpenFile(0, "csv file (*.csv)")
    if not filename[0]:
        return
    fileopen = open(filename[0], "r")
    for line in fileopen:
        if "Channel" not in line[:7]:
            columns = line.replace("\n", "").split(",")
            sid = columns[0]

            name = columns[1]

            grid = columns[2]

            axis = columns[3]

            if columns[3] == "FX":
                n1 = 1
                n2 = 0
                n3 = 0
                typ = "FORCE"
            if columns[3] == "FY":
                n1 = 0
                n2 = 1
                n3 = 0
                typ = "FORCE"
            if columns[3] == "FZ":
                n1 = 0
                n2 = 0
                n3 = 1
                typ = "FORCE"
            if columns[3] == "MX":
                n1 = 1
                n2 = 0
                n3 = 0
                typ = "MOMENT"
            if columns[3] == "MY":
                n1 = 0
                n2 = 1
                n3 = 0
                typ = "MOMENT"
            if columns[3] == "MZ":
                n1 = 0
                n2 = 0
                n3 = 1
                typ = "MOMENT"

            cid = columns[4]
            magn = columns[5]

            created_forces.append(
                base.CreateEntity(
                    solver, "FORCE", {
                        "TYPE": typ,
                        "Name": name,
                        "SID": sid,
                        "by": "node",
                        "G": grid,
                        "CID": cid,
                        "F": magn,
                        "N1": n1,
                        "N2": n2,
                        "N3": n3
                    }))

            bc = base.GetEntity(solver, "LOAD_SET", int(sid))
            base.SetEntityCardValues(solver, bc, {
                "Name": name,
            })

    total_forces = len(created_forces)
    print(total_forces, "forces and moments created successfully!")

    #Creating Nastran Header with Subcases...#

    header = base.CreateEntity(solver, "Nastran Header")

    text = "SOL 101\n" + "TIME = 3.15E7\n" + "CEND\n" + "$\n" + "$\n"
    text += "DISPLACEMENT(PLOT) = ALL\n" + "STRESS(PLOT) = ALL\n" + "$\n" + "$\n"

    #Creating Subcases for the different loads#
    for f in created_forces:

        name = base.GetEntityCardValues(solver, f, ("Name", ))["Name"]
        force_id = base.GetEntityCardValues(solver, f, ("SID", ))["SID"]

        text += "Subcase " + str(force_id) + "\n"
        text += "Load = " + str(
            force_id) + "\n" + "Label = " + name + "\n" + "$\n"

    #Setting the rest of the header
    text += "BEGIN BULK\n"
    text += "PARAM, AUTOSPC, YES\n" + "PARAM, GRDPNT,0\n" + "PARAM, INREL,-2\n" + "PARAM, K6ROT, 100.\n" + "PARAM, MAXRATIO,1.E8\n" + "PARAM, POST, -2\n"
    text += "$\n" + "$\n"

    base.SetNastranHeaderText(header, text)

    fileopen.close()
    print("Done!!!")
示例#16
0
def fix(issues):
    for issue in issues:
        # print(issue.has_fix)
        problem_description = issue.description
        ents = issue.entities
        print(problem_description)
        print(ents)

        if 'Component number vs. name of COMBINE GROUP' in problem_description:
            group_combine = ents[0]
            name_list = text_analyse.analyse(
                text=problem_description,
                delimiter='\'',
                start='Component number vs. name of COMBINE GROUP')
            lenght = len(name_list['text_list'])
            name_list_n = text_analyse.analyse(text=group_combine._name,
                                               delimiter='_|-',
                                               start='Scr',
                                               special='Scr',
                                               special_inv=True)
            print('name_list_n:  ', name_list_n)
            text = 'Scr' + str(name_list_n['special_list_inv'][0]) + '_'
            ran = range(1, lenght, 2)

            for i in ran:
                print('name_list[i]:    ', name_list['text_list'][i])
                text = text + str(name_list['text_list'][i]) + '-'
            text = text[:-1]
            field = {'Name': text}
            success = group_combine.set_entity_values(constants.PAMCRASH,
                                                      field)
            if success == 0:
                ic = include_comment()
                ic.add_comment_change(group_combine)
                issue.is_fixed = True
                issue.update()

        if 'Missing reference RBODY' in problem_description:
            success = None
            vals = {
                'Name': name_group,
                'NSET': group._id,
                'ITRB': 0
            }  # , 'NCOG': node._id
            rbody = base.CreateEntity(constants.PAMCRASH, "RBODY", vals)
            if rbody:
                success = 0
            if success == 0:
                ic = include_comment()
                ic.add_comment_change(rbody)
                issue.is_fixed = True
                issue.update()

        if 'Different name COMBINE GROUP' in problem_description:
            group_entity = ents[0]
            rbody_entity = ents[1]
            for e in ents:
                if e.ansa_type(constants.PAMCRASH) == "GROUP":
                    group_entity = e
                if e.ansa_type(constants.PAMCRASH) == "RBODY":
                    rbody_entity = e

            field = {'Name': group_entity._name}
            success = rbody_entity.set_entity_values(constants.PAMCRASH, field)
            if success == 0:
                ic = include_comment()
                ic.add_comment_change(rbody_entity)
                issue.is_fixed = True
                issue.update()

        if 'Different number of screw' in problem_description:
            for e in ents:
                if 'Scr' in e._name and '-' in e._name:
                    group_combine = e
                else:
                    groups_mesh = e
            name_list = text_analyse.analyse(text=group_combine._name,
                                             delimiter='_',
                                             start='Scr',
                                             special='Scr',
                                             special_inv=True,
                                             Exclude='vs')
            name_ids = name_list['special_list_inv'][0]
            success = list()

            gr_mesh_name = groups_mesh._name
            if not ("Scr" in gr_mesh_name):
                gr_mesh_name = "Scr01_" + gr_mesh_name
            name_list_g = text_analyse.analyse(text=gr_mesh_name,
                                               delimiter='_',
                                               start='Scr',
                                               special='Scr',
                                               special_inv=True,
                                               Exclude='vs')
            name_id = name_list_g['special_list_inv'][0]

            new_group_name = gr_mesh_name.replace("Scr" + str(name_id),
                                                  "Scr" + str(name_ids))
            print('new_group_name:  ', new_group_name)
            field = {'Name': new_group_name}
            success = groups_mesh.set_entity_values(constants.PAMCRASH, field)
            if success == 0:
                ic = include_comment()
                ic.add_comment_change(groups_mesh)
                issue.is_fixed = True
                issue.update()

        # name COMBINE GROUP vs. MESH GROUP name
        if 'Different name COMBINE GROUP' in problem_description and 'MESH GROUP' in problem_description:
            for e in ents:
                if 'Scr' in e._name and '-' in e._name:
                    group_combine = e
                else:
                    groups_mesh = e

            name_list = text_analyse.analyse(text=group_combine._name,
                                             delimiter='_|-',
                                             start='Scr')
            name_list_c = name_list['text_list']
            success = list()
            i = 0
            new_group_name = ''
            for conp in name_list_c:
                if i == 1:
                    new_group_name = new_group_name + str(conp) + '_vs_'
                else:
                    new_group_name = new_group_name + str(conp) + '_'
                i = i + 1

            new_group_name = new_group_name[:-1]
            field = {'Name': new_group_name}
            success = groups_mesh.set_entity_values(constants.PAMCRASH, field)
            if success == 0:
                ic = include_comment()
                ic.add_comment_change(groups_mesh)
                issue.is_fixed = True
                issue.update()

        # name order componets in MESH GROUP name
        if 'the first component' in problem_description and 'MESH GROUP' in problem_description:
            groups_mesh = ents[0]
            name_list = text_analyse.analyse(text=groups_mesh._name,
                                             delimiter='_',
                                             start='Scr',
                                             exclude='vs')
            name_list_m = name_list['text_list']
            name_list_c = text_analyse.analyse(text=problem_description,
                                               delimiter='\"',
                                               start='')
            name_list_1 = name_list_c['text_list'][1]
            success = list()

            i = 0
            new_group_name = ''
            index = name_list_m.index(name_list_1)
            del name_list_m[index]
            name_list_m.insert(1, name_list_1)
            for conp in name_list_m:
                if i == 1:
                    new_group_name = new_group_name + str(conp) + '_vs_'
                else:
                    new_group_name = new_group_name + str(conp) + '_'
                i = i + 1

            new_group_name = new_group_name[:-1]
            field = {'Name': new_group_name}
            success = groups_mesh.set_entity_values(constants.PAMCRASH, field)
            if success == 0:
                ic = include_comment()
                ic.add_comment_change(groups_mesh)
                issue.is_fixed = True
                issue.update()
示例#17
0
def TiedContacts(TiedConvertionType='RBE3',
                 Tol=50,
                 FileAppend=0,
                 Include='None',
                 PutInInclude='0',
                 WorkDir="./"):
    dogy = list()
    if (TiedConvertionType == 'CGAPG'):
        if (Include == 'None'):
            FileName = 'None'
        else:
            FileName = Include._name
        OutFile = open(WorkDir + FileName + '.CGAPG', 'w+')

    if (Include == 'None'):
        Contacts = base.CollectEntities(constants.LSDYNA, None, "CONTACT",
                                        False)
    else:
        Contacts = base.CollectEntities(constants.LSDYNA, Include, "CONTACT",
                                        False)
    print("    Starting Contact To %s %s" %
          (TiedConvertionType, datetime.datetime.now()))
    ents = list()
    grid_coords = list()
    new_grids_list = list()
    parts_list = list()
    connections_list = list()
    refgrid_list = list()
    for Contact in Contacts:
        Counter = 0
        #contact = ansa.base.GetEntity(constants.LSDYNA, "CONTACT", contact_id)
        contact = Contact
        contact_card = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                     entity=contact,
                                                     fields=('SSID', 'MSID',
                                                             'SSTYP', 'MSTYP'))
        # Master
        if not ('MSTYP' in contact_card and 'SSTYP' in contact_card):
            continue
        if (contact_card['MSTYP'] == '2: Part  set'):
            MasterEntities = ansa.base.GetEntity(constants.LSDYNA, "SET",
                                                 contact_card['MSID'])
            biw_containers = ansa.base.CollectEntities(constants.NASTRAN,
                                                       MasterEntities,
                                                       "__PROPERTIES__",
                                                       recursive=True)
            elems = ansa.base.CollectEntities(constants.NASTRAN,
                                              biw_containers,
                                              "__ELEMENTS__",
                                              recursive=True)
        if (contact_card['MSTYP'] == '3: Part  id'):
            biw_containers = base.GetEntity(constants.LSDYNA, "__PROPERTIES__",
                                            contact_card['MSID'])
            elems = ansa.base.CollectEntities(constants.NASTRAN,
                                              biw_containers,
                                              "__ELEMENTS__",
                                              recursive=True)
        if (contact_card['SSTYP'] == '2: Part  set') or (contact_card['SSTYP']
                                                         == '4: Node  set'):
            SlaveEntities = ansa.base.GetEntity(constants.LSDYNA, "SET",
                                                contact_card['SSID'])
            grids = ansa.base.CollectEntities(constants.NASTRAN,
                                              SlaveEntities,
                                              "GRID",
                                              recursive=True)
        if (contact_card['SSTYP'] == '3: Part  id'):
            SlaveEntities = ansa.base.GetEntity(constants.LSDYNA,
                                                "__PROPERTIES__",
                                                contact_card['SSID'])
            grids = ansa.base.CollectEntities(constants.NASTRAN,
                                              SlaveEntities,
                                              "GRID",
                                              recursive=True)
        print(
            "        Contact ID = %s, Slave nodes = %s, Master elements = %s, Tol = %s"
            % (contact._id, len(grids), len(elems), Tol))
        grid_coords_list = list()
        for grid in grids:
            grid_card = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                      entity=grid,
                                                      fields=('NID', 'X', 'Y',
                                                              'Z'))
            grid_coords = (grid_card['X'], grid_card['Y'], grid_card['Z'])
            grid_coords_list.append(grid_coords)
        NearestElements = ansa.base.NearestShell(
            search_entities=biw_containers,
            tolerance=Tol,
            coordinates=grid_coords_list)
        if (TiedConvertionType == 'CGAPG'):
            val = {'KA': '1E6', 'KB': '1E6', 'Kt': '1E6'}
            PGAP = base.CreateEntity(constants.NASTRAN, "PGAP", val)
            CONM1 = base.CreateEntity(constants.NASTRAN, "CONM1",
                                      {'GA': grids[0]._id})
            MaxID = CONM1._id
            base.DeleteEntity(CONM1, True)
            i = 0
            for i in range(len(NearestElements)):
                if (NearestElements[i]):
                    OutFile.write("\nCGAPG,%s,%s,%s,ELEM\n,%s" %
                                  (i + MaxID, PGAP._id, grids[i]._id,
                                   NearestElements[i]._id))
                    Counter = Counter + 1

        if (TiedConvertionType == 'RBE3'):
            i = 0
            refc = '123456'
            for i in range(len(NearestElements)):
                if (NearestElements[i]):
                    elem_type = base.GetEntityCardValues(
                        constants.NASTRAN,
                        entity=NearestElements[i],
                        fields=('EID', 'type'))
                    if "QUAD" in elem_type['type']:
                        elem_ret = ansa.base.GetEntityCardValues(
                            constants.NASTRAN,
                            entity=NearestElements[i],
                            fields=('G1', 'G2', 'G3', 'G4'))
                        vals = {
                            'REFGRID': grids[i]._id,
                            'REFC': refc,
                            'WT1': 1.0,
                            'C1': '123',
                            'G1': elem_ret['G1'],
                            'G2': elem_ret['G2'],
                            'G3': elem_ret['G3'],
                            'G4': elem_ret['G4'],
                            'No.of.Nodes': 5
                        }
                        RBE3 = ansa.base.CreateEntity(constants.NASTRAN,
                                                      "RBE3", vals)
                        dogy.append(RBE3)
                    if "TRIA" in elem_type['type']:
                        elem_ret = ansa.base.GetEntityCardValues(
                            constants.NASTRAN,
                            entity=NearestElements[i],
                            fields=('G1', 'G2', 'G3'))
                        vals = {
                            'REFGRID': grids[i]._id,
                            'REFC': refc,
                            'WT1': 1.0,
                            'C1': '123',
                            'G1': elem_ret['G1'],
                            'G2': elem_ret['G2'],
                            'G3': elem_ret['G3'],
                            'No.of.Nodes': 4
                        }
                        RBE3 = ansa.base.CreateEntity(constants.NASTRAN,
                                                      "RBE3", vals)
                        dogy.append(RBE3)
                    Counter = Counter + 1
        print("            %s out of %s nodes succesfuly projected" %
              (Counter, len(grids)))
    print("    Finished Contact To %s %s" %
          (TiedConvertionType, datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)
示例#18
0
    def createInclude(self):

        fields = {'Name': 'sets_for_schutzklasse'}
        self.include = base.CreateEntity(constants.ABAQUS, 'INCLUDE', fields)
示例#19
0
 def create(entity_type, deck=base.CurrentDeck(), **card_properties):
     return QDEntity.convert(
         base.CreateEntity(deck, entity_type, card_properties))