Load output of PyMechanical Script to PyDyna

I have a .mechdat file output from a previous sim in PyMechanical. How can I load it as an input mesh for subsequent simulation in PyDyna?
Thanks in advance
Comments
-
Hello
One approach is in Pymechanical to generate the k file (also define all of the LS-Dyna loads/bc if one wants), which you can then import into pyDyna.
To generate the k file in pymechanical use:
analysis = Model.AddLSDynaAnalysis() analysis.WriteInputFile('D:\\mypymechkfile.k')
Then import the k file into PyDyna
Thank you
Erik
1 -
Hi Erik,
So construct a model from the mechdat file within PyMechanical with the deformed geometry. Then save that as .k file with the lines above.
Have I understood you correctly?
Cheers
0 -
Just because I want to use the deformed geometry from the result of the PyMechanical script as the starting geometry for the PyDyna script.
0 -
I realised an oversight on my part.
I need the .rst file.
However, I am struggling to load the .rst file with PyMechanical. Once in PyMechanical its easy to then follow your instructions.
Would you suggest opening in pyDPF? I was thinking to go down this route, but I can't find documentation of then saving in PyDyna format.
Ben
0 -
I am struggling to load the .rst file with PyMechanical.
You might find this discussion useful:
https://discuss.ansys.com/discussion/3460/which-scripting-part-or-pyansys-modules-can-i-use-to-obtain-results-in-the-avz-format1 -
Hi Landon,
Thanks for this.
I have downloaded the library and tried the method.
It worked, thank you Erik and Landon.
```python
from ansys.mechanical.core import App
import sys
import os
from ansys.mechanical.core import global_variableslibrary = r"C:\Users\XXX\Scripts\ResultsFileMechReader"
result_file = r"C:\Users\XXX\StaticStructural\file.rst"outfolder = os.path.split(result_file)[0]
app = App()
globals().update(global_variables(app))sys.path.append(library)
sys.path.append(r'C:\Program Files\ANSYS Inc\v242\aisol\DesignSpace\DSPages\Python'.format(app.version))import RunAPDL
RunAPDL.Initialize(ExtAPI, Ansys)
SI, CdbPath = RunAPDL.GetCdbFileFromResultFile(result_file)import RunMech
RunMech.Initialize(ExtAPI, Ansys)
RunMech.ImportResultsToCurrentSession(CdbPath, result_file, library)results =ExtAPI.DataModel.GetObjectsByType(Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Result)
Set units
ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardNMMdat
analysis = Model.AddLSDynaAnalysis()
dyna_file = r"C:\Users\XXX\stress_free_mesh.k"
analysis.WriteInputFile(dyna_file)
1 -
That is great.
In this way do you export to the LS-Dyna k file a deformed geometry (as per rst file)?
Erik
0 -
Hi Erik,
Yes I can. Works well.
1