3.1.1.6. c3po.couplers.JFNKCoupler module
Contain the class JFNKCoupler.
- class c3po.couplers.JFNKCoupler.JFNKCoupler(physics, exchangers, dataManagers)
Bases:
CouplerJFNKCouplerinherits fromCouplerand proposes a Jacobian-Free Newton Krylov coupling algorithm.This is a Newton algorithm using a Krylov (GMRES) method for the linear system solving.
The Jacobian matrix is not computed, but the product of the jacobian matrix with a vector \(v\) is approximated by a Taylor formula (\(J_u\) is the jacobian of \(F\) at the point \(u\)):
\[J_u v \approx (F(u + \varepsilon v) - F(u))/\varepsilon\]\(\varepsilon\) is a parameter of the algorithm. Its default value is 1E-4. Call
setEpsilon()to change itJFNKCoupler is a Coupler working with :
A single
PhysicsDriver(possibly a Coupler) defining the calculations to be made each time \(F\) is called.A list of
DataManagerallowing to manipulate the data in the coupling.Two
Exchangerallowing to go from thePhysicsDriverto theDataManagerand vice versa.
Each
DataManageris normalized with its own norm got after the first iteration. They are then used as a singleDataManager| using :class:.CollaborativeDataManager`.As the Newton algorithm solves for \(F(X) = 0\), in order to be coherent with the fixed point coupling algorithms, \(F(x)\) is defined as \(F(X) = f(X) - X\), where \(f\) is the output of the physicsDriver.
The convergence criteria is : \(||f(X^{n}) - X^{n}|| / ||f(X^{n})|| < \rm{tolerance}\). The default norm used is the infinite norm.
Coupler.setNormChoice()allows to choose another one.The default Newton tolerance is 1.E-6. Call
setConvergenceParameters()to change it.The default maximum Newton number of iterations is 10. Call
setConvergenceParameters()to change it.The default Krylov tolerance is 1.E-4. Call
setKrylovConvergenceParameters()to change it.The default maximum Krylov iteration is 100. Call
setKrylovConvergenceParameters()to change it.- __init__(physics, exchangers, dataManagers)
Build a
JFNKCouplerobject.- Parameters:
physics (list[PhysicsDriver]) – List of only one
PhysicsDriver(possibly aCoupler).exchangers (list[Exchanger]) – List of exactly two
Exchangerallowing to go from thePhysicsDriverto theDataManagerand vice versa.dataManagers (list[DataManager]) – List of
DataManager.
- getSolveStatus()
- setConvergenceParameters(tolerance, maxiter)
Set the convergence parameters (tolerance and maximum number of iterations).
- Parameters:
tolerance – The convergence threshold in \(||f(X^{n}) - X^{n}|| / ||f(X^{n})|| < \rm{tolerance}\).
maxiter – The maximal number of iterations.
- setEpsilon(epsilon)
Set the
epsilonvalue of the method.- Parameters:
epsilon – The
epsilonvalue in the formula \(J_u v \approx (F(u + \varepsilon v) - F(u))/\varepsilon\).
- 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.
- setKrylovConvergenceParameters(tolerance, maxiter)
Set the convergence parameters (tolerance and maximum number of iterations) of the Krylov method.
- Parameters:
tolerance – The convergence threshold of the Krylov method.
maxiter – The maximal number of iterations of the Krylov method.
- 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()
Solve a time step using Jacobian-Free Newton Krylov algorithm.
- c3po.couplers.JFNKCoupler.solveTriang(matrixA, vectorB)
INTERNAL.
Solves a triangular linear system.