3.1.1.1. c3po.couplers.AdaptiveResidualBalanceCoupler module
Contains the class AdaptiveResidualBalanceCoupler.
- class c3po.couplers.AdaptiveResidualBalanceCoupler.AdaptiveResidualBalanceCoupler(physics, exchangers, dataManagers)
Bases:
CouplerAdaptiveResidualBalanceCouplerinherits fromCouplerand 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).
AdaptiveResidualBalanceCouplerworks with :Two
PhysicsDriver, one for each solver. They must implement theiterateTimeStep()method, together with the possibilities to get residual and set target accuracy.Four
Exchanger: two for exchanges between thePhysicsDriver, and two to get residuals.One
LocalDataManager(not just aDataManager) which contains the residuals got with the last two exchangers.
Note
Two
Exchangerand aDataManagerare 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
FixedPointCouplerto add a damping factor and to control the coupling error.In this case :
The option
setUseIterate(True)ofFixedPointCouplermust be used.The maximal number of iterations provided to
AdaptiveResidualBalanceCoupler.setTargetResidualsis ignored.The exchanger ‘2to1’ is also probably redondant with the
FixedPointCouplerexchangers and, in this case, can be set to do nothing.
- __init__(physics, exchangers, dataManagers)
Build a
AdaptiveResidualBalanceCouplerobject.- Parameters:
physics (list, dict) – List (or dict with keys
['Solver1', 'Solver2']) of twoPhysicsDriver. If a list is used, it has to be provided in the same order than the keys here. The providedPhysicsDrivermust implement theiterateTimeStep()method (together withsolveTimeStep()) and accept new accuracy (for thesolveTimeStep()method) throughsetInputDoubleValue('Accuracy', value).exchangers (list, dict) – List (or dict with keys
['1to2', '2to1', 'Residual1', 'Residual2']) of fourExchanger. 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 oneLocalDataManager(not just aDataManager). The residuals must be stored in thisDataManageras double values under the names'Residual1'and'Residual2'.
- getIterateStatus()
- getSolveStatus()
- initTimeStep(dt)
- 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()