ExecutePostCommands Execute Post Commands after solution is done
Hello
Mechanical scripting: thanks to the previous effort described in this forum the simple script below runs the solving process and gets the results (from remote machine). Now, I would like to run the post APDL snippets. There is well documented "ExecutePostCommands" command, which unfortunately do nothing in my script. Any advice on how to set-up the environment to make it run the apdl snippets? So far, it looks like running this command have no effect:
1) After running the whole script below, the post command objects have green ticks but there is no any post command gistory nor files that should be results of the post command script in the solver directory.
2) If the post command object has a lighting icon, there is no response after issuing the single ExecutePostCommands.
analysis_number = 1
analysis = Model.Analyses[analysis_number]
print("*** solving: " + str(analysis.Name) + " ")
analysis.Solve()
print(' solved ')
print(' getting results ')
analysis.Solution.GetResults()
print(' results got ')
print(' executing post commands ')
analysis.Solution.ExecutePostCommands
print(' post commands executed ***')
The other issue is that I have no idea how to insert code in this forum in a neat form.
Answers
-
Hi @total_obliteration APDL postprocessing command snippet objects can be run 2 different ways. When you solve your model, your APDL command objects will be run in the same session of APDL as the solve command (immediately after the solve completes). In this case, you can see the APDL snippets in the ds.dat file and the output will be in the Solver Output file:
Alternatively, if you add/modify APDL postprocessing objects after the model solved, a new instance of APDL will be launched to run just the postprocessing APDL script. In this case, the APDL snippets will appear in the post.dat file and the output will be in the Post Output file:
Coming to your code, note that
ExecutePostCommands
is method and needs parentheses to run:analysis.Solution.ExecutePostCommands()
In your code, I would not expect
GetResults()
orExecutePostCommands()
to do anything, because everything will already be up to date after the Solve() command. But if you modify the APDL snippet after Solve(), then the ExecutePostCommands() can be used to run the APDL snippet(s) using the 2nd method described above.Note that the above two methods of running APDL snippets can behavior very differently. In the first case, the model and .rst file will already be loaded. In the second case, they will not be.
Attached is a video to show how to format code in this forum.
0 -
Many thanks, Landon Mitchell Kanner.
The problem here is that I can't run post commands directly after solving. The job is being run remotely (@ hpc machines). Unfortunately, there is not enough storage over there to host solution .rst and additional files there are the output of the post commands. The flow I would like to achieve is something like this:
1) Run solution @ hpc (this can be done by issuing "analysis.Solve()")
2) Get the results from remote job (analysis.Solution.GetResults())
3) Run post-commands locallyLooks like it is not possible to achieve behaviour explained. But what about:
1) Suprresing post commands
2) running job remotely as described above, getting the results
3) After the results are loaded, unsuppressed wanted post command
4) run post command object with "ExecutePostCommands()"Not sure but it should be possible to unsuppress post command object in Mechanical scripting. Unsuppress command will be issued after GetResults() and before ExecutePostCommands(), can this works?
0