How to extract information aboout converged or unconverged solution
Hello,
I need to extract by means of a Python script the information if a solution is converged or not (i.e.: how to read in the solution object the value for Substep, something like "if Substep equal 999999 not converged...")
Thank you very much
Best Answer
-
Hello Massimo,
I wrote this script couple of weeks back. In this script I am using existing Stress result for checking the time point for last converged result. This is for a python code under results.
def after_solve(this, analysis): # Do not edit this line """ Called after solving the parent analysis. Keyword Arguments: this -- the datamodel object instance of the python code object you are currently editing in the tree analysis -- """ # To access properties created using the Property Provider, please use the following command. # this.GetCustomPropertyByPath("your_property_group_name/your_property_name") # To access scoping properties use the following to access geometry scoping and named selection respectively: # this.GetCustomPropertyByPath("your_property_group_name/your_property_name/Geometry Selection") # this.GetCustomPropertyByPath("your_property_group_name/your_property_name/Named Selection") sp1 = DataModel.GetObjectsByName("Maximum Principal Stress")[0] # Get reaction force object rf = DataModel.GetObjectsByName("Force Reaction")[0] # Get the list of time steps from the analysis results time_steps = list(analysis.GetResultsData().ListTimeFreq) result_position = len(time_steps) # Reverse the time steps list to start from the last time point time_steps.reverse() if rf.ObjectState.ToString() != "Solved": for result_time in time_steps: # Assuming time unit to be seconds rf.DisplayTime = Quantity("{0} [s]".format(result_time)) rf.EvaluateAllResults() # Break the loop if the reaction force object is solved at a particular time step if rf.ObjectState.ToString() == "Solved": break # Set the display time of the maximum principal stress object to the last converged time point sp1.DisplayTime = Quantity("{0} [s]".format(result_time)) sp1.EvaluateAllResults()
5
Answers
-
Are you only wanting to know if the solution converged or not, or do you need information about which step and substep the solution diverged?
If you are only looking for if the solution completed or not you can look at the Solution object ObjectState property
0 -
Hello Mike
Thank you for your reply; I need to extarct which step and substep the simulation diverged
Best
0 -
Hello Mike
Just to clarify my goal; I'm currrently read results from result file and by means of the following script I'm setting the final substep of the final step; but I'm assuming that the final result set is valid (converged); if not (how to know?) I need to read the last but one result
Thank you very much for your help
Massimo
reader = ExtAPI.DataModel.Project.Model.Analyses[0].GetResultsData()
result_sets = reader.ListTimeFreq
lastRes=len(result_sets)-1
reader.CurrentTimeFreq = result_sets[lastRes] # Set last result set
0 -
Hello Rajesh,
thank you very much for your reply, this will be very helpful for my purpose and it solved my issue
Best regards
1