Dolfin version: 2019.1.0
How installed: manual commands from a source repository in terminal
System: Ubuntu 18.04 LTS on Windows Subsystem for Linux. Also replicated in Ubuntu 19.10.
I am solving the heat equation in 1D space, u_t - u_{xx} = f(x,t), on [x_0, X] \times [t_0, T] using space-time CGq (Continuous Galerkin method of degree q) method. I then solve a specific adjoint problem corresponding to a certain quantity of interest that I am interested in using a similar space-time CGq method. Creating the adjoint problem involves choosing right hand side data, initial conditions, and boundary conditions that in the end give me the desired error in the quantity of interest. I then want to calculate the expected error in that quantity of interest.
The way the space-time CGq method works is that we assume the solution can be written as a sum of space-time basis vector functions, which themselves can be written as a product of a scalar spatial function and a scalar time function. In other words, u(x,t) = \sum_{i=0}^q \alpha_i(x)l_i(t), where the l_i(t) are Lagrange polynomials in time. Each subinterval [t_n, t_{n+1}] there are q coupled equations that need to be solved in-tandem to find the spatial coefficient functions. I then update the “initial” solution with the t_{n+1} solution calculated prior. Repeat until final time reached.
I use Fenics to handle the spatial portion of the solve and use my own coded time functions plus Gaussian quadrature in time to handle the time portion.
I perform this method for both the primal(original) problem and the adjoint problem. However, I do increase the degree of interpolation in space and time by 1 for the adjoint problem to avoid orthogonality issues cropping up. For instance, if I use degree 1 in space and degree 2 in time for the primal problem, I will use at least degree 2 in space and degree 3 in time for the adjoint problem.
I have the CGq method working for the primal problem. I have the errors and error convergence rates for different q values to prove it. However, my effectivity ratios, the ratio of the calcuated error in the quantity of interest and the exact error in the quantity of interest, are diverging as my mesh size in space and time decreases. The expected behavior is that they converge to 1 as the mesh size decreases.
I’m not certain if it is my code for the adjoint problem, as I do not have a exact solution to check against, or my error representation code. I’ve been working on the code for several weeks now, but cannot seem to find what the issue is. I’m starting to think there is a quirk here from Fenics that I am not understanding or aware of. Any help in finding out what is wrong is greatly appreciated.
The following is a more in-depth PDF file of the derivation to get from the original heat equation to the error representation form.
https://www.dropbox.com/s/ylf6e9zes4dkocj/Error%20Estimates%20for%20Heat%20Equation%20in%201D.pdf?dl=0
The code that I am using is broken into two files (Requres Fenics 2019.1.0, Python3, and NumPy to be installed):
-
The file that you run in the command line. It is called HeatEquation1DCGq.py
-
The file that contains the functions that are called in the first file. This includes the primal and adjoint solvers as well as the error representation solver. It is called HeatEquation1DFunctionFile.py
The code is found here: https://www.dropbox.com/s/fqctx3vr17z9e9b/Code.zip?dl=0