Last Time Step of Solution

Unknown
edited August 2022 in Community Q&A

Hi experts,

In my UDF, I want to print some results when it is the last time step of the solution. I found this one:

https://2022.help.altair.com/2022/hwcfdsolvers/acusolve/topics/acusolve/udfgetlaststepflag_acusolve_udf.htm

And, I have set up steady maximum time step to 100.

image

In my code, I think the solution is found in 10th time step. Currently, to print the result I manually have to get the timestep of 10 using udfGetTimeStep() and then print the final result. The following line of the code is NEVER executed and I never got a file from it.

image

Is there any way, to find when the result is converged or the solution has been found. I have attached the log file.

Best Answer

  • acupro
    acupro
    Altair Employee
    edited August 2022 Answer ✓

    I would assume that only is 1 when it's the maximum time step indicated for the run.  The convergence-based stop likely doesn't set that flag.

    If you assume that convergence is always reached by time step 20, for example, you can set max time steps to 20, and use a very low convergence tolerance - like 1.e-12 - such that the stop will always be at the max time step, rather than based on convergence.

    I would still wonder if that's going to again write multiple times, as the UDF will get called multiple times.

    The other option would be simply to lower the convergence tolerance a bit, maybe to 5.e-4 instead of 1.e-3, such that the last few steps don't have much change in value - and just the UDF from before.

Answers

  • acupro
    acupro
    Altair Employee
    edited August 2022 Answer ✓

    I would assume that only is 1 when it's the maximum time step indicated for the run.  The convergence-based stop likely doesn't set that flag.

    If you assume that convergence is always reached by time step 20, for example, you can set max time steps to 20, and use a very low convergence tolerance - like 1.e-12 - such that the stop will always be at the max time step, rather than based on convergence.

    I would still wonder if that's going to again write multiple times, as the UDF will get called multiple times.

    The other option would be simply to lower the convergence tolerance a bit, maybe to 5.e-4 instead of 1.e-3, such that the last few steps don't have much change in value - and just the UDF from before.

  • Unknown
    edited August 2022

    I would assume that only is 1 when it's the maximum time step indicated for the run.  The convergence-based stop likely doesn't set that flag.

    If you assume that convergence is always reached by time step 20, for example, you can set max time steps to 20, and use a very low convergence tolerance - like 1.e-12 - such that the stop will always be at the max time step, rather than based on convergence.

    I would still wonder if that's going to again write multiple times, as the UDF will get called multiple times.

    The other option would be simply to lower the convergence tolerance a bit, maybe to 5.e-4 instead of 1.e-3, such that the last few steps don't have much change in value - and just the UDF from before.

    I found this one:

    https://2022.help.altair.com/2022/hwcfdsolvers/acusolve/topics/acusolve/udfgetsolutionratio_acusolve_udf.htm

    I have questions about solution ratio/solution norm and residual ratio/residual norm.

    image 

    What is the relation of solution ratio or residual ratio with convergence tolerance? Are they same?

    Can I get the solution ratio or residual ratio equal to 1e-3? I ran the code as given in the example but I never got that value--the value is 1 in the beginning and 0 everywhere.

    My code:

    image

    Result:

    image

    Results are same for udfGetResidualRatio and udfGetResidualNorm. 

    Can i track when the convergence tolerance reaches 1e-3 using UDF? Does acuSolve have a udf to extract current convergence ?

  • acupro
    acupro
    Altair Employee
    edited August 2022

    I found this one:

    https://2022.help.altair.com/2022/hwcfdsolvers/acusolve/topics/acusolve/udfgetsolutionratio_acusolve_udf.htm

    I have questions about solution ratio/solution norm and residual ratio/residual norm.

    image 

    What is the relation of solution ratio or residual ratio with convergence tolerance? Are they same?

    Can I get the solution ratio or residual ratio equal to 1e-3? I ran the code as given in the example but I never got that value--the value is 1 in the beginning and 0 everywhere.

    My code:

    image

    Result:

    image

    Results are same for udfGetResidualRatio and udfGetResidualNorm. 

    Can i track when the convergence tolerance reaches 1e-3 using UDF? Does acuSolve have a udf to extract current convergence ?

    Residual Ratio is a global measure of how well the solution matches the equations.
    Solution Ratio is a global measure of the change in solution from step to step.

    You can look at the <problem>.ss.inc file, or in the CONVERGENCE_CHECK_PARAMETERS command in Command Reference Manual, to see how the various quantities are checked against the given convergence_tolerance value.  Standard means same value as convergence tolerance, looser_by_10 means 10X convergence tolerance, etc.