Discussion:
[petsc-users] How do I know it is steady state?
Zou (Non-US), Ling
2015-10-30 17:23:02 UTC
Permalink
Hi All,

From physics point of view, I know my simulation converges if nothing
changes any more.

I wonder how normally you do to detect if your simulation reaches steady
state from numerical point of view.
Is it a good practice to use SNES convergence as a criterion, i.e.,
SNES converges and it takes 0 iteration(s)

Thanks,

Ling
Barry Smith
2015-11-03 01:29:23 UTC
Permalink
Post by Zou (Non-US), Ling
Hi All,
From physics point of view, I know my simulation converges if nothing changes any more.
I wonder how normally you do to detect if your simulation reaches steady state from numerical point of view.
Is it a good practice to use SNES convergence as a criterion, i.e.,
SNES converges and it takes 0 iteration(s)
Depends on the time integrator and SNES tolerance you are using. If you use a -snes_rtol 1.e-5 it will always try to squeeze 5 MORE digits out of the residual so won't take 0 iterations even if there is only a small change in the solution.
Post by Zou (Non-US), Ling
Thanks,
Ling
Matthew Knepley
2015-11-03 12:25:25 UTC
Permalink
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Hi All,
From physics point of view, I know my simulation converges if nothing
changes any more.
Post by Zou (Non-US), Ling
I wonder how normally you do to detect if your simulation reaches steady
state from numerical point of view.
Post by Zou (Non-US), Ling
Is it a good practice to use SNES convergence as a criterion, i.e.,
SNES converges and it takes 0 iteration(s)
Depends on the time integrator and SNES tolerance you are using. If you
use a -snes_rtol 1.e-5 it will always try to squeeze 5 MORE digits out of
the residual so won't take 0 iterations even if there is only a small
change in the solution.
There are two different situations here:

1) Solving for a mathematical steady state. You remove the time
derivative and solve the algebraic system with SNES. Then
the SNES tolerance is a good measure.

2) Use timestepping to advance until nothing looks like it is changing.
This is a "physical" steady state.

You can use 1) with a timestepping preconditioner TSPSEUDO, which is what I
would recommend if you
want a true steady state.

Thanks,

Matt
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Thanks,
Ling
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
Zou (Non-US), Ling
2015-11-03 15:12:50 UTC
Permalink
Matt, thanks for the reply.
The simulation is a transient simulation, which eventually converges to a
steady-state solution, given enough simulation time.
My code runs fine and I could tell the simulation reaches steady state by
looking at the residual monitored by SNES monitor function.

See an example screen output

Solving time step 90, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 8.85.

NL step = 0, SNES Function norm = 1.47538E-02

NL step = 1, SNES Function norm = 8.06971E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 91, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 8.95.

NL step = 0, SNES Function norm = 1.10861E-02

NL step = 1, SNES Function norm = 6.26584E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 92, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.05.

NL step = 0, SNES Function norm = 7.21253E-03

NL step = 1, SNES Function norm = 9.93402E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 93, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.15.

NL step = 0, SNES Function norm = 5.40260E-03

NL step = 1, SNES Function norm = 6.21162E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 94, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.25.

NL step = 0, SNES Function norm = 3.40214E-03

NL step = 1, SNES Function norm = 6.16805E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 95, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.35.

NL step = 0, SNES Function norm = 2.29656E-03

NL step = 1, SNES Function norm = 6.19337E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 96, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.45.

NL step = 0, SNES Function norm = 1.53218E-03

NL step = 1, SNES Function norm = 5.94845E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 97, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.55.

NL step = 0, SNES Function norm = 1.32136E-03

NL step = 1, SNES Function norm = 6.19933E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 98, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.65.

NL step = 0, SNES Function norm = 7.09342E-04

NL step = 1, SNES Function norm = 6.18694E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 99, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.75.

NL step = 0, SNES Function norm = 5.49192E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 100, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.85.

NL step = 0, SNES Function norm = 5.49192E-04

total_FunctionCall_number: 0

converged, time step increased = 0.1

Solving time step 101, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 9.95.

NL step = 0, SNES Function norm = 5.49192E-04

total_FunctionCall_number: 0

I observed that after time step 99, the residual never changed, so I
believe the transient simulation converges at time step 99.
I wonder can I use the criterion "SNES converges and it takes 0 iteration"
to say the simulation reaches a steady state. Such that I don't have to
look at the screen and the code knows it converges and should stop.

Put it another way, what's the common way people would implement a scheme
to detect a transient simulation reaches steady state.

Thanks,

Ling
Post by Matthew Knepley
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Hi All,
From physics point of view, I know my simulation converges if nothing
changes any more.
Post by Zou (Non-US), Ling
I wonder how normally you do to detect if your simulation reaches
steady state from numerical point of view.
Post by Zou (Non-US), Ling
Is it a good practice to use SNES convergence as a criterion, i.e.,
SNES converges and it takes 0 iteration(s)
Depends on the time integrator and SNES tolerance you are using. If
you use a -snes_rtol 1.e-5 it will always try to squeeze 5 MORE digits out
of the residual so won't take 0 iterations even if there is only a small
change in the solution.
1) Solving for a mathematical steady state. You remove the time
derivative and solve the algebraic system with SNES. Then
the SNES tolerance is a good measure.
2) Use timestepping to advance until nothing looks like it is changing.
This is a "physical" steady state.
You can use 1) with a timestepping preconditioner TSPSEUDO, which is what
I would recommend if you
want a true steady state.
Thanks,
Matt
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Thanks,
Ling
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
Matthew Knepley
2015-11-03 15:24:52 UTC
Permalink
Post by Zou (Non-US), Ling
Matt, thanks for the reply.
The simulation is a transient simulation, which eventually converges to a
steady-state solution, given enough simulation time.
My code runs fine and I could tell the simulation reaches steady state by
looking at the residual monitored by SNES monitor function.
See an example screen output
Solving time step 90, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 8.85.
NL step = 0, SNES Function norm = 1.47538E-02
NL step = 1, SNES Function norm = 8.06971E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 91, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 8.95.
NL step = 0, SNES Function norm = 1.10861E-02
NL step = 1, SNES Function norm = 6.26584E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 92, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.05.
NL step = 0, SNES Function norm = 7.21253E-03
NL step = 1, SNES Function norm = 9.93402E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 93, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.15.
NL step = 0, SNES Function norm = 5.40260E-03
NL step = 1, SNES Function norm = 6.21162E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 94, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.25.
NL step = 0, SNES Function norm = 3.40214E-03
NL step = 1, SNES Function norm = 6.16805E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 95, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.35.
NL step = 0, SNES Function norm = 2.29656E-03
NL step = 1, SNES Function norm = 6.19337E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 96, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.45.
NL step = 0, SNES Function norm = 1.53218E-03
NL step = 1, SNES Function norm = 5.94845E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 97, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.55.
NL step = 0, SNES Function norm = 1.32136E-03
NL step = 1, SNES Function norm = 6.19933E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 98, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.65.
NL step = 0, SNES Function norm = 7.09342E-04
NL step = 1, SNES Function norm = 6.18694E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 99, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.75.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 100, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.85.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 101, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.95.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
I observed that after time step 99, the residual never changed, so I
believe the transient simulation converges at time step 99.
I wonder can I use the criterion "SNES converges and it takes 0 iteration"
to say the simulation reaches a steady state. Such that I don't have to
look at the screen and the code knows it converges and should stop.
Put it another way, what's the common way people would implement a scheme
to detect a transient simulation reaches steady state.
I don't think so. The above makes no sense to me. You are signaling SNES
convergence with a relative
residual norm of 5e-4? That does not sound precise enough to me.

As I said, I think the believable way to find steady states is to look for
solutions to the algebraic equations,
perhaps by using timestepping as a preconditioner.

Thanks,

Matt
Post by Zou (Non-US), Ling
Thanks,
Ling
Post by Matthew Knepley
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Hi All,
From physics point of view, I know my simulation converges if nothing
changes any more.
Post by Zou (Non-US), Ling
I wonder how normally you do to detect if your simulation reaches
steady state from numerical point of view.
Post by Zou (Non-US), Ling
Is it a good practice to use SNES convergence as a criterion, i.e.,
SNES converges and it takes 0 iteration(s)
Depends on the time integrator and SNES tolerance you are using. If
you use a -snes_rtol 1.e-5 it will always try to squeeze 5 MORE digits out
of the residual so won't take 0 iterations even if there is only a small
change in the solution.
1) Solving for a mathematical steady state. You remove the time
derivative and solve the algebraic system with SNES. Then
the SNES tolerance is a good measure.
2) Use timestepping to advance until nothing looks like it is changing.
This is a "physical" steady state.
You can use 1) with a timestepping preconditioner TSPSEUDO, which is what
I would recommend if you
want a true steady state.
Thanks,
Matt
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Thanks,
Ling
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
Zou (Non-US), Ling
2015-11-03 15:38:35 UTC
Permalink
Post by Matthew Knepley
Post by Zou (Non-US), Ling
Matt, thanks for the reply.
The simulation is a transient simulation, which eventually converges to a
steady-state solution, given enough simulation time.
My code runs fine and I could tell the simulation reaches steady state by
looking at the residual monitored by SNES monitor function.
See an example screen output
Solving time step 90, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 8.85.
NL step = 0, SNES Function norm = 1.47538E-02
NL step = 1, SNES Function norm = 8.06971E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 91, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 8.95.
NL step = 0, SNES Function norm = 1.10861E-02
NL step = 1, SNES Function norm = 6.26584E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 92, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.05.
NL step = 0, SNES Function norm = 7.21253E-03
NL step = 1, SNES Function norm = 9.93402E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 93, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.15.
NL step = 0, SNES Function norm = 5.40260E-03
NL step = 1, SNES Function norm = 6.21162E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 94, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.25.
NL step = 0, SNES Function norm = 3.40214E-03
NL step = 1, SNES Function norm = 6.16805E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 95, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.35.
NL step = 0, SNES Function norm = 2.29656E-03
NL step = 1, SNES Function norm = 6.19337E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 96, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.45.
NL step = 0, SNES Function norm = 1.53218E-03
NL step = 1, SNES Function norm = 5.94845E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 97, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.55.
NL step = 0, SNES Function norm = 1.32136E-03
NL step = 1, SNES Function norm = 6.19933E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 98, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.65.
NL step = 0, SNES Function norm = 7.09342E-04
NL step = 1, SNES Function norm = 6.18694E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 99, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.75.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 100, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.85.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 101, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.95.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
I observed that after time step 99, the residual never changed, so I
believe the transient simulation converges at time step 99.
I wonder can I use the criterion "SNES converges and it takes 0
iteration" to say the simulation reaches a steady state. Such that I don't
have to look at the screen and the code knows it converges and should stop.
Put it another way, what's the common way people would implement a scheme
to detect a transient simulation reaches steady state.
I don't think so. The above makes no sense to me. You are signaling SNES
convergence with a relative
residual norm of 5e-4? That does not sound precise enough to me.
I would argue that number (5.e-4) depends on the problem you are solving
(actually I am solving).
The initial residual of the problem starts at ~1e8.
But you might be right, and I have to think about this issue more carefully.
Post by Matthew Knepley
As I said, I think the believable way to find steady states is to look for
solutions to the algebraic equations,
perhaps by using timestepping as a preconditioner.
You still need a numerical criterion to let the code understand it
converges, right? For example, "a set of solutions have already been found
to satisfy the algebraic equations because ___residuals drops below (a
number here)__".

Thanks,

Ling
Post by Matthew Knepley
Thanks,
Matt
Post by Zou (Non-US), Ling
Thanks,
Ling
Post by Matthew Knepley
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Hi All,
From physics point of view, I know my simulation converges if nothing
changes any more.
Post by Zou (Non-US), Ling
I wonder how normally you do to detect if your simulation reaches
steady state from numerical point of view.
Post by Zou (Non-US), Ling
Is it a good practice to use SNES convergence as a criterion, i.e.,
SNES converges and it takes 0 iteration(s)
Depends on the time integrator and SNES tolerance you are using. If
you use a -snes_rtol 1.e-5 it will always try to squeeze 5 MORE digits out
of the residual so won't take 0 iterations even if there is only a small
change in the solution.
1) Solving for a mathematical steady state. You remove the time
derivative and solve the algebraic system with SNES. Then
the SNES tolerance is a good measure.
2) Use timestepping to advance until nothing looks like it is
changing. This is a "physical" steady state.
You can use 1) with a timestepping preconditioner TSPSEUDO, which is
what I would recommend if you
want a true steady state.
Thanks,
Matt
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Thanks,
Ling
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
Barry Smith
2015-11-03 18:55:20 UTC
Permalink
Post by Zou (Non-US), Ling
Matt, thanks for the reply.
The simulation is a transient simulation, which eventually converges to a steady-state solution, given enough simulation time.
My code runs fine and I could tell the simulation reaches steady state by looking at the residual monitored by SNES monitor function.
See an example screen output
Solving time step 90, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 8.85.
NL step = 0, SNES Function norm = 1.47538E-02
NL step = 1, SNES Function norm = 8.06971E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 91, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 8.95.
NL step = 0, SNES Function norm = 1.10861E-02
NL step = 1, SNES Function norm = 6.26584E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 92, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.05.
NL step = 0, SNES Function norm = 7.21253E-03
NL step = 1, SNES Function norm = 9.93402E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 93, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.15.
NL step = 0, SNES Function norm = 5.40260E-03
NL step = 1, SNES Function norm = 6.21162E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 94, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.25.
NL step = 0, SNES Function norm = 3.40214E-03
NL step = 1, SNES Function norm = 6.16805E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 95, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.35.
NL step = 0, SNES Function norm = 2.29656E-03
NL step = 1, SNES Function norm = 6.19337E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 96, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.45.
NL step = 0, SNES Function norm = 1.53218E-03
NL step = 1, SNES Function norm = 5.94845E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 97, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.55.
NL step = 0, SNES Function norm = 1.32136E-03
NL step = 1, SNES Function norm = 6.19933E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 98, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.65.
NL step = 0, SNES Function norm = 7.09342E-04
NL step = 1, SNES Function norm = 6.18694E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 99, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.75.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 100, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.85.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 101, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.95.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
I observed that after time step 99, the residual never changed, so I believe the transient simulation converges at time step 99.
I wonder can I use the criterion "SNES converges and it takes 0 iteration" to say the simulation reaches a steady state. Such that I don't have to look at the screen and the code knows it converges and should stop.
Put it another way, what's the common way people would implement a scheme to detect a transient simulation reaches steady state.
I don't think so. The above makes no sense to me. You are signaling SNES convergence with a relative
residual norm of 5e-4? That does not sound precise enough to me.
I would argue that number (5.e-4) depends on the problem you are solving (actually I am solving).
The initial residual of the problem starts at ~1e8.
But you might be right, and I have to think about this issue more carefully.
As I said, I think the believable way to find steady states is to look for solutions to the algebraic equations,
perhaps by using timestepping as a preconditioner.
You still need a numerical criterion to let the code understand it converges, right? For example, "a set of solutions have already been found to satisfy the algebraic equations because ___residuals drops below (a number here)__".
After each SNESSolve you could call SNESGetConvergedReason() and if the number of iterations was 0 and the reason was snorm then declare it steady state.

Barry
Post by Zou (Non-US), Ling
Thanks,
Ling
Thanks,
Matt
Thanks,
Ling
Post by Zou (Non-US), Ling
Hi All,
From physics point of view, I know my simulation converges if nothing changes any more.
I wonder how normally you do to detect if your simulation reaches steady state from numerical point of view.
Is it a good practice to use SNES convergence as a criterion, i.e.,
SNES converges and it takes 0 iteration(s)
Depends on the time integrator and SNES tolerance you are using. If you use a -snes_rtol 1.e-5 it will always try to squeeze 5 MORE digits out of the residual so won't take 0 iterations even if there is only a small change in the solution.
1) Solving for a mathematical steady state. You remove the time derivative and solve the algebraic system with SNES. Then
the SNES tolerance is a good measure.
2) Use timestepping to advance until nothing looks like it is changing. This is a "physical" steady state.
You can use 1) with a timestepping preconditioner TSPSEUDO, which is what I would recommend if you
want a true steady state.
Thanks,
Matt
Post by Zou (Non-US), Ling
Thanks,
Ling
--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener
--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener
Zou (Non-US), Ling
2015-11-03 19:05:09 UTC
Permalink
Barry, thanks for the discussion and help.

Ling
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Matt, thanks for the reply.
The simulation is a transient simulation, which eventually converges to
a steady-state solution, given enough simulation time.
Post by Zou (Non-US), Ling
My code runs fine and I could tell the simulation reaches steady state
by looking at the residual monitored by SNES monitor function.
Post by Zou (Non-US), Ling
See an example screen output
Solving time step 90, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 8.85.
NL step = 0, SNES Function norm = 1.47538E-02
NL step = 1, SNES Function norm = 8.06971E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 91, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 8.95.
NL step = 0, SNES Function norm = 1.10861E-02
NL step = 1, SNES Function norm = 6.26584E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 92, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.05.
NL step = 0, SNES Function norm = 7.21253E-03
NL step = 1, SNES Function norm = 9.93402E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 93, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.15.
NL step = 0, SNES Function norm = 5.40260E-03
NL step = 1, SNES Function norm = 6.21162E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 94, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.25.
NL step = 0, SNES Function norm = 3.40214E-03
NL step = 1, SNES Function norm = 6.16805E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 95, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.35.
NL step = 0, SNES Function norm = 2.29656E-03
NL step = 1, SNES Function norm = 6.19337E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 96, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.45.
NL step = 0, SNES Function norm = 1.53218E-03
NL step = 1, SNES Function norm = 5.94845E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 97, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.55.
NL step = 0, SNES Function norm = 1.32136E-03
NL step = 1, SNES Function norm = 6.19933E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 98, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.65.
NL step = 0, SNES Function norm = 7.09342E-04
NL step = 1, SNES Function norm = 6.18694E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 99, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.75.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 100, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.85.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
converged, time step increased = 0.1
Solving time step 101, using BDF1, dt = 0.1.
Current time (the starting time of this time step) = 9.95.
NL step = 0, SNES Function norm = 5.49192E-04
total_FunctionCall_number: 0
I observed that after time step 99, the residual never changed, so I
believe the transient simulation converges at time step 99.
Post by Zou (Non-US), Ling
I wonder can I use the criterion "SNES converges and it takes 0
iteration" to say the simulation reaches a steady state. Such that I don't
have to look at the screen and the code knows it converges and should stop.
Post by Zou (Non-US), Ling
Put it another way, what's the common way people would implement a
scheme to detect a transient simulation reaches steady state.
Post by Zou (Non-US), Ling
I don't think so. The above makes no sense to me. You are signaling SNES
convergence with a relative
Post by Zou (Non-US), Ling
residual norm of 5e-4? That does not sound precise enough to me.
I would argue that number (5.e-4) depends on the problem you are solving
(actually I am solving).
Post by Zou (Non-US), Ling
The initial residual of the problem starts at ~1e8.
But you might be right, and I have to think about this issue more
carefully.
Post by Zou (Non-US), Ling
As I said, I think the believable way to find steady states is to look
for solutions to the algebraic equations,
Post by Zou (Non-US), Ling
perhaps by using timestepping as a preconditioner.
You still need a numerical criterion to let the code understand it
converges, right? For example, "a set of solutions have already been found
to satisfy the algebraic equations because ___residuals drops below (a
number here)__".
After each SNESSolve you could call SNESGetConvergedReason() and if the
number of iterations was 0 and the reason was snorm then declare it steady
state.
Barry
Post by Zou (Non-US), Ling
Thanks,
Ling
Thanks,
Matt
Thanks,
Ling
Post by Zou (Non-US), Ling
Hi All,
From physics point of view, I know my simulation converges if nothing
changes any more.
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
I wonder how normally you do to detect if your simulation reaches
steady state from numerical point of view.
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Is it a good practice to use SNES convergence as a criterion, i.e.,
SNES converges and it takes 0 iteration(s)
Depends on the time integrator and SNES tolerance you are using. If
you use a -snes_rtol 1.e-5 it will always try to squeeze 5 MORE digits out
of the residual so won't take 0 iterations even if there is only a small
change in the solution.
Post by Zou (Non-US), Ling
1) Solving for a mathematical steady state. You remove the time
derivative and solve the algebraic system with SNES. Then
Post by Zou (Non-US), Ling
the SNES tolerance is a good measure.
2) Use timestepping to advance until nothing looks like it is
changing. This is a "physical" steady state.
Post by Zou (Non-US), Ling
You can use 1) with a timestepping preconditioner TSPSEUDO, which is
what I would recommend if you
Post by Zou (Non-US), Ling
want a true steady state.
Thanks,
Matt
Post by Zou (Non-US), Ling
Thanks,
Ling
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
Post by Zou (Non-US), Ling
-- Norbert Wiener
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
Post by Zou (Non-US), Ling
-- Norbert Wiener
Zou (Non-US), Ling
2015-11-03 15:19:54 UTC
Permalink
Barry, thanks. True and not true.
SNES can converge under other conditions, such as SNORM condition, e.g.,

Solving time step 300, using BDF1, dt = 0.1.

Current time (the starting time of this time step) = 29.85.

NL step = 0, SNES Function norm = 5.49192E-04

Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 0

In this case, snes_rtol is ignored.

Ling
Post by Zou (Non-US), Ling
Post by Zou (Non-US), Ling
Hi All,
From physics point of view, I know my simulation converges if nothing
changes any more.
Post by Zou (Non-US), Ling
I wonder how normally you do to detect if your simulation reaches steady
state from numerical point of view.
Post by Zou (Non-US), Ling
Is it a good practice to use SNES convergence as a criterion, i.e.,
SNES converges and it takes 0 iteration(s)
Depends on the time integrator and SNES tolerance you are using. If you
use a -snes_rtol 1.e-5 it will always try to squeeze 5 MORE digits out of
the residual so won't take 0 iterations even if there is only a small
change in the solution.
Post by Zou (Non-US), Ling
Thanks,
Ling
Continue reading on narkive:
Loading...