soupy.solver module
soupy.solver.nonlinearVariationalSolver
- class soupy.solver.nonlinearVariationalSolver.NonlinearVariationalSolver(parameters=None)[source]
Bases:
objectSolver for the nonlinear variational problem
\[\text{Find } u \in U \qquad r(u,v) = 0 \quad \forall v \in V\]The user must provide the variational forms for the residual form, an initial guess, boundary conditions, and optionally, variational forms for the Jacobian and backtracking cost functional.
This wraps the dolfin.NonlinearVariationalProblem and dolfin.NonlinearVariationalSolver classes using a different function signature
Constructor:
- Parameters:
parameters (dict) – Solver parameters for the dolfin.NonlinearVariationalSolver class
Class will update the default dolfin.NonlinearVariationalSolver parameters with the data in
parametersif it is provided. Otherwise, default parameters will be used- solve(residual_form, u, bcs, J_form, form_compiler_parameters=None)[source]
Solve the nonlinear variational system
\[\text{Find } u \in U \qquad r(u,v) = 0 \quad \forall v \in V\]given using the dolfin.NonlinearVariationalSolver with a supplied initial guess
- Parameters:
residual_form – Variational form for the residual
u (
dolfin.Function) – Initial guess for the solution and function used inresidual_formbcs (list) – List of boundary conditions
J_form – Variational form for the Jacobian of the residual
energy_form – Optional variational form for the energy functional. If supplied, uses this as the backtracking cost
form_compiler_parameters – Optional form compiler_parameters
soupy.solver.newtonBacktrackSolver
- class soupy.solver.newtonBacktrackSolver.NewtonBacktrackSolver[source]
Bases:
objectBacktracking Newton solver for the nonlinear variational system
\[\text{Find } u \in U \qquad r(u,v) = 0 \quad \forall v \in V\]The user must provide the variational forms for the residual form, an initial guess, boundary conditions, and optionally, variational forms for the Jacobian and backtracking cost functional.
Initializes the
NewtonBacktrackSolverwith the following parameters.rel_tolerance–> we converge when \(\|r\|_2/\|r_0\|_2 \leq\)rel_toleranceabs_tolerance–> we converge when \(\|r\|_2 \leq\)abs_tolerancemaxximum_iterations–> maximum number of iterationsc_armijo–> Armijo constant for sufficient reductionmax_backtracking_iter–> Maximum number of backtracking iterationsprint_level–> Print info on screen
- solve(residual_form, u, bcs=None, J_form=None, energy_form=None, solver=None)[source]
Solve the nonlinear variational system
\[\text{Find } u \in U \qquad r(u,v) = 0 \quad \forall v \in V\]given using a backtracking Newton method with supplied initial guess
- Parameters:
residual_form – Variational form for the residual
u (
dolfin.Function) – Initial guess for the solution and funciton used inresidual_formbcs (list) – List of boundary conditions
J_form – Variational form for the Jacobian of the residual
energy_form – Optional variational form for the energy functional. If supplied, uses this as the backtracking cost
solver – Optional linear solver with method
solve(A, x, b)Will initialize a solver ifsolverisNone.
- termination_reasons = ['Maximum number of Iteration reached', 'Norm of the gradient less than tolerance', 'Maximum number of backtracking reached', 'Norm of (g, da) less than tolerance']
soupy.solver.PETScLUSolver
- class soupy.solver.PETScLUSolver.PETScLUSolver(mpi_comm=mpi4py.MPI.COMM_WORLD, method='mumps')[source]
Bases:
objectLU solver for linear systems \(Ax = b\) and \(A^Tx = b\). It is a wrapper for
dolfin.PETScLUSolverproviding custom implementations for methodssolve_transposeandset_operatorif they are unavailable in thedolfinversion being used.Constructor:
- Parameters:
mpi_comm (
MPI.Comm) – MPI Communicator for the linear systemmethod (str) – LU method
- set_operator(A)[source]
Set the linear operator
- Parameters:
A (
dolfin.Matrixordolfin.PETScMatrix) – Matrix for the solves