# yade-users team mailing list archive

## Re: The convergence criterion in YADE

```Bruno Chareyre said:     (by the date of Tue, 29 Nov 2005 12:17:13 +0100)

> >I'm not sure if I understand
> I suspect you don't ;).

I was afraid of that :)

> Let us not CC = convergence criteria, so that CC=0 <=> static equilibrium.

so CC is used to determine whether the calculations can be stopped,
because nothing is moving, right?

> How to define such a CC?
> Simply compute the sum of all forces on a body.

OK, this is stored in PhysicalActionContainer (sum of all forces on each body)

> At equilibrium, sum of all Fi on body Bk is 0. If you sum now on all bodies,
> you still have sum of F over all i and k equal to 0 (SFik = 0).
> If SFik != 0, you are not at equilibrium.
> If you normalize SFik dividing it by the mean value of F, you have
> the classical definition of CC.

so you mean that we need to calculate a sum of all Forces in
PhysicalActionContainer, and also calculate their mean value.
And momentum is ignored?

> CC is often used to verify that (1) a collection of bodies as reached a
> stable state (e.g. spheres of the ImpactTest) or (2) a simulation is not
> far from quasi-static conditions. And it is very easy to compute!

ok. So now I understand. That should be a class ConverganceCriterion
derived from StandAloneEngine. It can loop over all PhysicalAction-s to
determine the convergance criterion.

But then - if it determines that the simulation is
finished=stable=all_forces_are_in_equilibrum - then I guess that we want
to simulation to be automatically stopped :) This is currently not
possible, I must add another class, say - SimulationStopper, which will
be able to stop the simulation. And then ConverganceCriterion will not
be derived from StandAloneEngine, but from SimulationStopper.

I will add this SimulationStopper very soon, because I need it also for
my lattice model :)

But for now - you can just make a ConverganceCriterion derived from
StandAloneEngine, and when it detects a stability, it can print a
message to the console, like this:

std::cerr << "Simulation in equilibrum!\n";

exit(0); // I doubt that you will like this solution ;)

Soon I will make that SimulationStopper :)

--
Janek Kozicki                                                         |
_______________________________________________