FEniCS Compatable Observation Operators#

DolfinPointWise(configs)

An observation operator that interpolates Values (DOF) over a Fenics-based Mesh onto predefined observation (cartesian) coordinates

create_DolfinPointWise_observation_operator(model)

A wrapper around DolfinPointWise.

This module presents observation operators only tailored for Fenics/Dolfin-based simulation models The module is thus optional for the PyOED package, and is provided only as an example to enable interfacing third-party packages.

class DolfinPointWiseConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None, targets=None, Vh=None)[source]#

Bases: ObservationOperatorConfigs

Configuration class for DolfinPointWise observation operator

Parameters:
  • verbose (bool) – a boolean flag to control verbosity of the object.

  • debug (bool) – a boolean flag that enables adding extra functionlity in a debug mode

  • output_dir (str | Path) – the base directory where the output files will be saved.

  • model (SimulationModel | None) – the simulation model

  • targets (ndarray | None) – 2D array with shape (n, 2) elements describing coordinates of the n observation/sensor points.

  • Vh (FunctionSpace | None) – The finite element space of the model state.

model: SimulationModel | None#
targets: ndarray | None#
Vh: FunctionSpace | None#
__init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None, targets=None, Vh=None)#
class DolfinPointWise(configs)[source]#

Bases: ObservationOperator

An observation operator that interpolates Values (DOF) over a Fenics-based Mesh onto predefined observation (cartesian) coordinates

Parameters:

configs (DolfinPointWiseConfigs | dict) – an object holding the class configurations.

__init__(configs)[source]#
validate_configurations(configs, raise_for_invalid=True)[source]#

Check the passed configuratios and make sure they are conformable with each other, and with current configurations once combined. This guarantees that any key-value pair passed in configs can be properly used

Note

Here only the locally-defined configurations in DolfinPointWiseConfigs are validated. Finally, super classes validators are called.

Parameters:
  • configs – full or partial (subset) configurations to be validated

  • raise_for_invalid – if True raise an error for invalid configrations type/key. Default True

Returns:

flag indicating whether passed configurations dictionary is valid or not

Raises:
observation_vector(init_val=0.0, return_np=True)[source]#

Create an observation vector

is_observation_vector(observation, **kwargs)[source]#

Test whether the passed observation vector is valid or not

apply(state, return_np=True)[source]#

Apply the observation operator to a model state, and return an observation instance

Jacobian_T_matvec(observation, eval_at=None, return_np=True)[source]#

Evaluate and return the product of the Jacobian (tangent-linear (TLM) of the observation operator), evaluated at eval_at transposed multiplied by the passed observation.

get_observation_grid()[source]#

Return a copy of the observational grid

property shape#

A tuple holding the shape of the observation operator (observation size, model state size)

property extended_design#

Return a vector indicating active/inactive entries (with proper replication for multiple prognostic variables) of the observation vector/range

property design#

Get a copy of the design vector (bool representing active/inactive sensors)

property model#

The underlying simulation model

property Vh#

The finite element space of the model state

property targets#

The observation targets

create_DolfinPointWise_observation_operator(model, Vh=None, targets=None, num_obs_points=20, offset=0.1, exclude_boxes=[[(0.25, 0.15), (0.5, 0.4)], ((0.6, 0.625), (0.75, 0.85))], verbose=False)[source]#

A wrapper around DolfinPointWise. This function create a pointwise observation operator for Dolfin-based model.

Parameters:
  • model – the simulation model

  • Vh – The finite element space of the model state.

  • targets – 2D array with shape (n, 2) elements describing coordinates of the n observation/sensor points. If None, a set of targets will be created using the following arguments

  • num_obs_points (int) – (approximate) number of observation points (sensors). This number will mostly change especially if there are buildings to avoid

  • offset – margin/offset to leave between boundary and extreme observation points

  • exclude_boxes – either None, or a list of tuples; each tuple must be a pair of tuples (xl, yl), (xu, yu) to exclude points in the box with corners set to these coordintes. This simulates buildings in the domain.

  • verbose (bool) – screen verbosity

Returns:

an observation operator; an instance of DolfinPointWise

DolfinPointWiseObservations#

alias of DolfinPointWise

create_pointwise_observation_operator(model, Vh=None, targets=None, num_obs_points=20, offset=0.1, exclude_boxes=[[(0.25, 0.15), (0.5, 0.4)], ((0.6, 0.625), (0.75, 0.85))], verbose=False)#

A wrapper around DolfinPointWise. This function create a pointwise observation operator for Dolfin-based model.

Parameters:
  • model – the simulation model

  • Vh – The finite element space of the model state.

  • targets – 2D array with shape (n, 2) elements describing coordinates of the n observation/sensor points. If None, a set of targets will be created using the following arguments

  • num_obs_points (int) – (approximate) number of observation points (sensors). This number will mostly change especially if there are buildings to avoid

  • offset – margin/offset to leave between boundary and extreme observation points

  • exclude_boxes – either None, or a list of tuples; each tuple must be a pair of tuples (xl, yl), (xu, yu) to exclude points in the box with corners set to these coordintes. This simulates buildings in the domain.

  • verbose (bool) – screen verbosity

Returns:

an observation operator; an instance of DolfinPointWise