3.1.1.1. c3po.couplers.AdaptiveResidualBalanceCoupler module

Inheritance diagram of c3po.couplers.AdaptiveResidualBalanceCoupler

Contains the class AdaptiveResidualBalanceCoupler.

class c3po.couplers.AdaptiveResidualBalanceCoupler.AdaptiveResidualBalanceCoupler(physics, exchangers, dataManagers)

Bases: Coupler

AdaptiveResidualBalanceCoupler inherits from Coupler and proposes a adaptive residual balance algorithm.

This algorithm is designed to coupled two solvers using an iterative procedure. It controls the accuracy required to each solver in order to limit over-solving and make them converge together.

See Senecal J. “Development of an efficient tightly coupled method for multiphysics reactor transient analysis” for details (for instance: https://www.sciencedirect.com/science/article/pii/S0149197017302676).

AdaptiveResidualBalanceCoupler works with :

Note

Two Exchanger and a DataManager are used to access the residuals in order to support all possible MPI schemes.

The default target accuracies are 1e-4 and the default maximum number of iterations is 100. Use setConvergenceParameters() to change these values.

The algorithm takes one parameter per solver, called initial convergence rate. They are set to 0.1 by default. Use setConvRateInit() to change them.

It may be interesting to use a FixedPointCoupler to add a damping factor and to control the coupling error.

In this case :

  • The option setUseIterate(True) of FixedPointCoupler must be used.

  • The maximal number of iterations provided to AdaptiveResidualBalanceCoupler.setTargetResiduals is ignored.

  • The exchanger ‘2to1’ is also probably redondant with the FixedPointCoupler exchangers and, in this case, can be set to do nothing.

__init__(physics, exchangers, dataManagers)

Build a AdaptiveResidualBalanceCoupler object.

Parameters:
  • physics (list, dict) – List (or dict with keys ['Solver1', 'Solver2']) of two PhysicsDriver. If a list is used, it has to be provided in the same order than the keys here. The provided PhysicsDriver must implement the iterateTimeStep() method (together with solveTimeStep()) and accept new accuracy (for the solveTimeStep() method) through setInputDoubleValue('Accuracy', value).

  • exchangers (list, dict) – List (or dict with keys ['1to2', '2to1', 'Residual1', 'Residual2']) of four Exchanger. If a list is used, it has to be provided in the same order than the keys here.

  • dataManagers (list, dict) – List (or dict with keys ['Residuals']) of one LocalDataManager (not just a DataManager). The residuals must be stored in this DataManager as double values under the names 'Residual1' and 'Residual2'.

getIterateStatus()

See c3po.PhysicsDriver.PhysicsDriver.getSolveStatus().

getSolveStatus()

See c3po.PhysicsDriver.PhysicsDriver.getSolveStatus().

initTimeStep(dt)

See c3po.PhysicsDriver.PhysicsDriver.initTimeStep().

iterateTimeStep()

See c3po.PhysicsDriver.PhysicsDriver.iterateTimeStep().

setConvRateInit(convRateSolver1Initial, convRateSolver2Initial)

Set the initial convergence rates.

Parameters:
  • convRateSolver1Initial – Initial convergence rate for solver 1. Default value: 0.1

  • convRateSolver2Initial – Initial convergence rate for solver 2. Default value: 0.1

setConvergenceParameters(targetResidualSolver1, targetResidualSolver2, maxiter)

Set the convergence parameters (target residuals for each solver and maximum number of iterations).

Parameters:
  • targetResidualSolver1 – Target residual for solver 1. Default value: 1.E-4.

  • targetResidualSolver2 – Target residual for solver 2. Default value: 1.E-4.

  • maxiter – The maximal number of iterations. Default value: 100.

setFailureManagement(leaveIfSolvingFailed)

Set if iterations should continue or not in case of solver failure (solveTimeStep() returns False).

Parameters:

leaveIfSolvingFailed (bool) – Set False to continue the iterations, True to stop. Default: False.

setPrintLevel(level)

Set the print level during iterations (0=None, 1 keeps last iteration, 2 prints every iteration).

Parameters:

level (int) – Integer in range [0;2]. Default: 2.

solveTimeStep()

See c3po.PhysicsDriver.PhysicsDriver.solveTimeStep().