Closed TomTranter closed 3 weeks ago
In general it would be nice to have more information about how to run the examples and how to view the output
I will keep the conversation about improving the examples in Issue #11 . I will focus here on these specific errors.
(closed by mistake)
I am not sure about the first error. It is probably due to h5py installation. Let me look into it with a fresh firedrake install.
The paper_test.py
example will probably need to be run in parallel on most machines to get to the finest mesh. It looks like you ran out of memory. As you mentioned, the examples should be better documented so I will add something about the memory requirements of this example.
In terms of output, do you mean what is being printed? In terms of visualization, the solution fields are being stored in results/collection.pvd (and vtu files). Some 1D examples also have custom matplotlib plotting. Again, this will be better documented.
I added something about memory requirements related to default docker allocation as well as information about visualization in the QuickStart guide.
I came across issues with some examples as well that seem to be issues with the scripts themselves rather than installation or configuration. Using the Docker linked in the documentation, the simple_flow_battery
example results in the following error:
Traceback (most recent call last):
File "/home/firedrake/echemfem/examples/simple_flow_battery.py", line 117, in <module>
solver = FlowBatterySolver()
File "/home/firedrake/echemfem/examples/simple_flow_battery.py", line 83, in __init__
super().__init__(
File "/home/firedrake/echemfem/echemfem/solver.py", line 388, in __init__
self.setup_forms(us, v)
File "/home/firedrake/echemfem/echemfem/solver.py", line 397, in setup_forms
self.Form, self.bcs = self.steady_forms(us, v)
File "/home/firedrake/echemfem/echemfem/solver.py", line 460, in steady_forms
a, bc = self.potential_poisson_form(us,
File "/home/firedrake/echemfem/echemfem/solver.py", line 2191, in potential_poisson_form
U_0 = self.U_app
AttributeError: 'FlowBatterySolver' object has no attribute 'U_app'
Additionally, when running catalyst_layer_Cu_full.py
, I receive the following error:
Nonlinear echem_system_ solve did not converge due to DIVERGED_DTOL iterations 1
Traceback (most recent call last):
File "/home/firedrake/echemfem/examples/catalyst_layer_Cu_full.py", line 247, in <module>
solver.solve()
File "/home/firedrake/echemfem/echemfem/solver.py", line 717, in solve
self.echem_solver.solve()
File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/home/firedrake/firedrake/src/firedrake/firedrake/adjoint_utils/variational_solver.py", line 89, in wrapper
out = solve(self, **kwargs)
File "/home/firedrake/firedrake/src/firedrake/firedrake/variational_solver.py", line 321, in solve
solving_utils.check_snes_convergence(self.snes)
File "/home/firedrake/firedrake/src/firedrake/firedrake/solving_utils.py", line 138, in check_snes_convergence
raise ConvergenceError(r"""Nonlinear solve failed to converge after %d nonlinear iterations.
firedrake.exceptions.ConvergenceError: Nonlinear solve failed to converge after 1 nonlinear iterations.
Reason:
DIVERGED_DTOL
@alizma Thanks for bringing this to my attention. I just pushed a commit to main to fix the U_app
bug with simple_flow_battery.py
.
For catalyst_layer_Cu_full.py
, it looks like a difference was introduced in a recent firedrake or petsc update. On a new install (not docker), I am getting these values for the nonlinear residuals:
0 SNES Function norm 2.883957200450e-03
1 SNES Function norm 1.572419903653e+01
2 SNES Function norm 5.269680158967e+01
Nonlinear echem_system_ solve did not converge due to DIVERGED_DTOL iterations 2
whereas in a docker container from March I am getting this:
0 SNES Function norm 2.883957200450e-03
1 SNES Function norm 4.878061152760e-03
2 SNES Function norm 5.171149830053e-01
3 SNES Function norm 1.308949961681e+01
4 SNES Function norm 7.758895362718e+00
5 SNES Function norm 3.502470383063e+00
6 SNES Function norm 2.603075365207e-03
7 SNES Function norm 1.474182974622e-03
8 SNES Function norm 1.890120789850e-03
Nonlinear echem_system_ solve converged due to CONVERGED_SNORM_RELATIVE iterations
I'm asking the firedrake devs about this. In the meantime, you can get convergence by adding this line
solver.solver_parameters["snes_divergence_tolerance"] = -1
on line 238 of the example, before the solver setup.
@alizma So I ended up changing the values for the bulk concentrations used in catalyst_layer_Cu_full.py
. The ones from the paper are approximations that don't solve the reaction system exactly. This means the initial guess does not solve the bulk reactions exactly and there is a mild discontinuity at the boundary, both of which could affect the convergence. So now I simply solve the system to get actual equilibrium values for the bulk concentrations. It improves the convergence.
I am running on linux Ubuntu 22.04.4 LTS I installed firedrake successfully using the install script here https://www.firedrakeproject.org/download.html I activated the firedrake virtualenv and tried importing it into a python terminal but got an h5py import error So I uninstalled it and reinstalled the latest version and import error went away I installed the latest echemfem code and tried this example but got another error possibly related to H5py
(firedrake) tom@tom:~/code/echemfem/examples$ python simple_flow_battery.py firedrake:WARNING OMP_NUM_THREADS is not set or is set to a value greater than 1, we suggest setting OMP_NUM_THREADS=1 to improve performance Using dimensional Navier-Stokes-Brinkman 0 SNES Function norm 3.719318934070e-09 1 SNES Function norm 2.221647403080e-23 /home/tom/code/firedrake/src/firedrake/firedrake/_deprecation.py:65: UserWarning: The use of
Filefor output is deprecated, please update your code to use
VTKFilefrom
firedrake.output. warn( Traceback (most recent call last): File "simple_flow_battery.py", line 109, in <module> solver = FlowBatterySolver() File "simple_flow_battery.py", line 75, in __init__ super().__init__( File "/home/tom/code/echemfem/echemfem/solver.py", line 383, in __init__ self.set_velocity() File "simple_flow_battery.py", line 105, in set_velocity NSB_solver.solve() File "/home/tom/code/echemfem/echemfem/flow_solver.py", line 109, in solve with CheckpointFile('Velocity_field'+'.h5', 'w') as afile: File "/home/tom/code/firedrake/src/firedrake/firedrake/checkpointing.py", line 538, in __init__ self.set_attr_byte_string("/", "dmplex_storage_version", version) File "/home/tom/code/firedrake/src/firedrake/firedrake/checkpointing.py", line 1692, in set_attr_byte_string grp = self.require_group(path) File "/home/tom/code/firedrake/src/firedrake/firedrake/checkpointing.py", line 1772, in require_group _self = self.h5pyfile File "/home/tom/code/firedrake/src/firedrake/firedrake/checkpointing.py", line 1645, in h5pyfile self._h5pyfile = h5i.get_h5py_file(self.viewer) File "firedrake/cython/hdf5interface.pyx", line 35, in firedrake.cython.hdf5interface.get_h5py_file File "h5py/h5i.pyx", line 33, in h5py.h5i.wrap_identifier File "h5py/h5i.pyx", line 38, in h5py.h5i.wrap_identifier File "h5py/defs.pyx", line 1240, in h5py.defs.H5Iget_type RuntimeError: Unspecified error in H5Iget_type (return value <0)
running another example gives slightly different errors