Script for Ansys LS-Dyna / Mechanical
Ansys LS-Dyna / Mechanical 2023R1
How could I use script and/or ACT to
- Generate CFL time-step in Ansys LS-Dyna
- Get its Minimum CFL value and Maximum CFL value
Best Answer
-
Some calls seem to be asynchronous. For instance, when scoping the bodies to the CFL object, it appears to still be under-defined. For this reason I create a dummy comment object and delete it which will update the comment object.
the import() method initiates the cfl generation but this too seem to have issues, which is why i activate the model object and then the cfl object again.
for larger models i would maybe try putting in a time.sleep(x) after the x.Import()
msscl = ExtAPI.DataModel.CreateObject("TimeStepCalc",'LSDYNA') allbodies = Model.Geometry.GetChildren[Ansys.ACT.Automation.Mechanical.Body](True) bodies = [x.GetGeoBody().Id for x in allbodies if x.Suppressed == False] sel = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) sel.Ids = bodies msscl.Properties['Geometry/DefineBy/Geo'].Value = sel temp = Model.AddComment() temp.Delete() msscl.Import() Model.Activate() msscl.Activate() print msscl.Properties['Minimum CFL value'].Value.ToString() print msscl.Properties['Maximum CFL value'].Value.ToString()
1
Answers
-
Aria,
It works. Thank you very much!
This challenge has bothered me for a long time. Finally got this fixed.
0 -
One further question -
if this CFL Time Step object has been already created. How to get it and activate this existing CFL object?
I tried to get this object by ExtAPI.DataModel......as below, but got error.
ExtAPI.DataModel.Project.Children[0].Children[9].Import()
'DataModelObject' object has no attribute 'Import'
0 -
Aria,
This could be closed.
Thanks a lot for the answering.
0