Conjugate gradient solver for nonlinear variational Problem

You can change the solver to snes by the following:

solver.parameters["nonlinear_solver"]="snes"
solver.parameters["snes_solver"]["method"] = "ncg"

As mentioned in Solving adaptive nonlinear equation in Vector Space - #11 by dokken you can inspect the parameters object to determine the keys.

For your second problem, you simply need to wrap bcs as a list, i.e. change:

to bcs= [ DirichletBC(V, y_BC, x0_boundary)]

2 Likes