Updating Fenics Vol 1 Demos

Hi all, I am currently going through all the annotated examples. Like many have already stated, a lot of the code is outdated but I have managed to find answers for these issues up to this point. I am currently on the “Poisson Extended” (example 10 which is available on the Fenics site) and have managed to clear some of the code that will throw errors such as:

Removing the
Interactive()
line at the bottom of the code

Changing
nr = input('Pick a demo: ') to nr = int(input('Pick a demo: '))
this line is located very close to the bottom of the code

And have even found an updated version of the
boxfield
library

However, even with all this, when I try to run the code I get this error:
AttributeError: ‘dolfin.cpp.parameter.Parameters’ object has no attribute ‘linear_solver’

If anyone has done this example or knows how to fix this issue I’d appreciate the help, thank you.

Dear Erik,

Next time you post here, please provide the link to the given demo you are modifying (or post the code here.
I am guessing you are referring to: https://fenicsproject.org/pub/tutorial/sphinx1/._ftut1006.html
The issue you have in the demo can be fixed by:

    prm = LinearVariationalSolver.default_parameters()
    if linear_solver == 'Krylov':
        prm["linear_solver"] = 'gmres'
        prm["preconditioner"] = 'ilu'
        prm["krylov_solver.absolute_tolerance"] = abs_tol
        prm["krylov_solver.relative_tolerance"] = rel_tol
        prm["krylov_solver.maximum_iterations"] = max_iter
    else:
        prm["linear_solver"] = 'lu'

These has been quite a few changes since the demos were released, and many of the changes are listed in the Changelog

1 Like

Total newbie here: I’m working through the tutorial vol.1 demos and dealing with issues as they arise. The fix given above is incorrect; the correct one is given here:

RuntimeError: Parameter krylov_solver.absolute_tolerance not found in Parameters object

Also: the link to the Changelog is broken.

An updated link to the changelog can be found here: Bitbucket