FEniCSPoisson2D#

class cuqipy_fenics.testproblem.FEniCSPoisson2D(dim=None, bc_types=None, bc_values=None, exactSolution=None, source_term=None, noise_level=None, field_type=None, field_params=None, mapping=None, prior=None)#

2D Diffusion PDE-based Bayesian inverse problem that uses FEniCS. The problem is set up on a unit square ([0,1]x[0,1]) mesh with either Dirichlet or Neumann boundary conditions on each boundary. The unknown parameter is the (possibly heterogeneous) diffusion coefficient (e.g. conductivity) field. The unknown parameter (e.g. conductivity) and the PDE solution (e.g. the potential) are approximated in the first order Lagrange FEM space.

Parameters:
  • dim (tuple, Default (32,32)) –

    Number of the 2D mesh vertices on the x and y directions, respectively.

  • bc_type (list of str, Default ['Dirichlet', 'Dirichlet', 'Dirichlet', 'Dirichlet']) –

    Boundary conditions on each boundary. The accepted values are:
    ’Dirichlet’: Dirichlet boundary condition.
    ’Neumann’: Neumann boundary condition.
    The list should be ordered as follows: [left, bottom, right, top]

  • bc_value (list of entries, each is a float or a callable , Default [0, 0, 0, 0]) –

    Boundary condition values on each boundary. The accepted values are:
    A float: a constant value.
    A callable : a callable that takes a point coordinate vector x in the physical domain as input and return the boundary condition value at that point, e.g., lambda x: np.sin(x[0])+np.cos(x[1]).
    The list should be ordered as follows: [left, bottom, right, top]

  • exactSolution (ndarray, CUQIarray, or callable , Default None) –

    Exact solution to the Bayesian inverse problem used to generate data, the diffusivity coefficient field in this case. When passed as a callable, it should take a point coordinate vector x in the physical domain as input and return the exact solution value at that point, e.g. lambda x: np.sin(x[0])+np.cos(x[1]). If None, a default exact solution is chosen. The default exact solution is a prior sample if the field_type is ‘KL’ and a smooth function if the field_type is None.

  • source_term (float, callable, or dolfin.Expression, Default 1) –

    Source term in the PDE. The accepted values are:
    A float: a constant value.
    A callable: a callable that takes a point coordinate vector x in the physical domain as input and returns the source term value at that point, e.g. lambda x: np.sin(x[0])+np.cos(x[1]).
    A dolfin.Expression: a dolfin.Expression object that defines the source term.

  • noise_level (float, default 0.01) – Noise level relative to the exact data (the ratio of the L2 norm of the noise to the L2 norm of the exact data). By default, the noise level is 1% (=0.01).

  • field_type (str, Default None) –

    Field type of the forward model domain. The accepted values are:
    ”KL”: a MaternKLExpansion geometry object will be created and set as a domain geometry.
    None: a FEniCSContinuous geometry object will be created and set as a domain geometry.

  • field_params (dict, Default None) –

    A dictionary of keyword arguments that the underlying geometry accepts. (Passed to the underlying geometry when field type is “KL” or None). For example, for “KL” field type, the dictionary can be {“length_scale”: 0.1, “num_terms”: 32}. If None is passed as field_type, this argument is ignored.

  • mapping (str or callable , Default None) –

    mapping to parametrize the Bayesian parameters. If None, no mapping is applied. If provided as callable, it should take a FEniCS function (of the unknown parameter) as input and return a FEniCS form, e.g. lambda m: ufl.exp(m).
    If provided as string, it can take one of the values:
    ’exponential’ : Parameterization in which the unknown parameter becomes the log of the diffusion coefficient.

  • prior (cuqi.distribution.Distribution, Default Gaussian) –

    Distribution of the prior. Needs to be i.i.d standard Gaussian if field_type is “KL”. The prior name property, i.e., prior.name is expected to be “x”.

__init__(dim=None, bc_types=None, bc_values=None, exactSolution=None, source_term=None, noise_level=None, field_type=None, field_params=None, mapping=None, prior=None)#

Methods

MAP([disp, x0])

Compute the Maximum A Posteriori (MAP) estimate of the posterior.

ML([disp, x0])

Compute the Maximum Likelihood (ML) estimate of the posterior.

UQ([Ns, Nb, percent, exact, experimental])

Run an Uncertainty Quantification (UQ) analysis on the Bayesian problem and provide a summary of the results.

__init__([dim, bc_types, bc_values, ...])

get_components()

Method that returns the model, the data and additional information to be used in formulating the Bayesian problem.

sample_posterior(Ns[, Nb, callback, ...])

Sample the posterior.

sample_prior(Ns[, callback])

Sample the prior distribution.

set_data(**kwargs)

Set the data of the problem.

Attributes

data

Extract the observed data from likelihood

likelihood

The likelihood function.

model

Extract the cuqi model from likelihood.

posterior

Create posterior distribution from likelihood and prior.

prior

The prior distribution