How can I automatically setup the imported load data from Maxwell inside mechanical thermal analysis
Erik Kostson
Member, Employee Posts: 210
✭✭✭✭
So say we have a transient thermal analysis with imported load data (say heat generation) from Maxwell (Electronic/Magnetic Transient analysis). One needs then to manually add rows, then enter all the time steps from Maxwell (source start and end times), and finally insert the corresponding analysis time steps. This can be very tedious and possibly take long time especially if we have many time steps in the Maxwell analysis.
Could this be perhaps automated?
0
Comments
-
Below is a mechanical script, that reads the time steps from a Maxwell file (AnsoftTransferData.xml), creates an imported load (heat gen.), and then adds all of the rows + corresponding input data (source and analysis times - taken from the Maxwell file).
model = ExtAPI.DataModel.Project.Model Parts = model.Geometry.GetChildren(DataModelObjectCategory.Part,True) first_analysis = ExtAPI.DataModel.Project.Model.Analyses[0] solver_directory = first_analysis.WorkingDir file = solver_directory+"Maxwell3DSolution\AnsoftTransferData.xml" # this folder might need change, so we should find the Ansoft xml file SolveOutLines = [] #Declare an empty list mytime=[] myind=[] with open(file, "r") as in_file: for line in in_file: #For each line of text store in a string variable named "SolveOutLines", and SolveOutLines.append(line) #add that line to list of lines. myind=SolveOutLines[0].split("<TIME>") myind.pop(0) for myt in myind: mytime.append(myt.split("</TIME>")[0]) impLoadGrp = ExtAPI.DataModel.GetObjectsByName('Imported Load (B4) ')[0] # change as needed heatGen=impLoadGrp.AddImportedHeatGeneration() selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) bolist=[] ids=[] for Part in Parts: for Body in Part.Children: bolist.append(Body.GetGeoBody().Id) selection.Ids=bolist heatGen.Location = selection for myrow in range(0,len(mytime)-1): table=heatGen.GetTableByName("") # get the worksheet table if float(mytime[myrow])>0.005: # change as needed - get times above 0.005 sec, to avoid initial small time steps NewRow = Ansys.ACT.Automation.Mechanical.WorksheetRow() table.Add(NewRow) NewRow[0]=mytime[myrow] NewRow[1]=mytime[myrow+1] NewRow[2]=mytime[myrow+1] NewRow[3]=1 table.RemoveAt(0) ExtAPI.DataModel.Tree.Refresh() heatGen.ImportLoad()
1
This discussion has been closed.