  We present a methodology combining neural networks with physical principle
constraints in the form of partial differential equations (PDEs). The approach
allows to train neural networks while respecting the PDEs as a strong
constraint in the optimisation as apposed to making them part of the loss
function. The resulting models are discretised in space by the finite element
method (FEM). The methodology applies to both stationary and transient as well
as linear/nonlinear PDEs. We describe how the methodology can be implemented as
an extension of the existing FEM framework FEniCS and its algorithmic
differentiation tool dolfin-adjoint. Through series of examples we demonstrate
capabilities of the approach to recover coefficients and missing PDE operators
from observations. Further, the proposed method is compared with alternative
methodologies, namely, physics informed neural networks and standard
PDE-constrained optimisation. Finally, we demonstrate the method on a complex
cardiac cell model problem using deep neural networks.
