Storing time evolution for inverse problem (FEniCS-pymc3)

Hey! I have the following time dependent problem for a vibrating conductor: EULER + a viscous dampening term. I’ve managed to integrate the problem by reducing it to a system of equations, discretizing the time derivatives and taking it’s variational form. The next step is to make some inference on the parameters (mainly the stiffness EI and the viscous dampening coefficient c) by comparison with experimental data.
To perform this inference I will use pymc3 (its GitHub) wrapping the FEniCS system using the fenics-pymc3 lybrary (fenics-pymc3) which provides such a bridge between Theano and FEniCS.

For the code to work I have to provide a function that’s similar to this one:

def solve_fenics(kappa0, kappa1):
    # This function inside should be traceable by fenics_adjoint
    f = fa.Expression(
        "10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2
    )

    u = fa.Function(V)
    bcs = [fa.DirichletBC(V, fa.Constant(0.0), "on_boundary")]

    inner, grad, dx = ufl.inner, ufl.grad, ufl.dx
    v = fenics.TestFunction(V)
    F = inner(kappa0*grad(u), grad(v)) * dx - kappa1 * f * v * dx
    fa.solve(F == 0, u, bcs=bcs)
    return u

As I understand this function returns a FEniCS function that then gets evaluated in its domain to get the solution (which is then used by the sampling algorithm). Since my experimental data consists in a time series displacement values for a single point to solve my problem I need to do the following inside the solve_fenics function:

  • Integrate the whole problem up to a certain time
  • Store the time evolution of the point of interest
  • Build some function on a time domain that incorporates (via interpolation?) said time evolution
  • Return that function
    My question is: Can I build such a function as a FEniCS object? If so, how?