# L2_error.py¶

Compute the -error between an infinite dimensional variable and its finite dimensional (discrete) projection in the mimetic polynomial space.

⭕ To access the source code, click on the [source] button at the right side or click on [L2_error.py]. Dependence may exist. In case of error, check import and install required packages or download required scripts. © mathischeap.com

A wrapper of all functions for computing -error.

Parameters:
• bf (MimeticBasisPolynomials) – The basis functions in .

• ct (CoordinateTransformation) –

The coordinate transformation representing the mapping ,

• quad_degree (list, tuple) – (default: None) The degree used for the numerical integral. It should be a list or tuple of three positive integers. If it is None, a suitable degree will be obtained from bf.

Example:

>>> import numpy as np
>>> from numpy import sin, cos, pi
>>> from coordinate_transformation import CoordinateTransformation
>>> from coordinate_transformation import Phi, d_Phi
>>> from mimetic_basis_polynomials import MimeticBasisPolynomials
>>> from projection import Reduction
>>> ct = CoordinateTransformation(Phi, d_Phi)
>>> bf = MimeticBasisPolynomials('Lobatto-5','Lobatto-5','Lobatto-5')
>>> def pressure(x,y,z):
...     return sin(np.pi*x) * sin(pi*y) * sin(pi*z)
>>> def velocity_x(x,y,z):
...     return pi * cos(pi*x) * sin(pi*y) * sin(pi*z)
>>> def velocity_y(x,y,z):
...     return pi * sin(pi*x) * cos(pi*y) * sin(pi*z)
>>> def velocity_z(x,y,z):
...     return pi * sin(pi*x) * sin(pi*y) * cos(pi*z)
>>> def source(x,y,z):
...     return -3 * pi**2 * sin(np.pi*x) * sin(pi*y) * sin(pi*z)
>>> rd = Reduction(bf, ct)
>>> loc_dofs_N = rd.NP(pressure)
>>> loc_dofs_E = rd.EP((velocity_x, velocity_y, velocity_z))
>>> loc_dofs_F = rd.FP((velocity_x, velocity_y, velocity_z))
>>> loc_dofs_V = rd.VP(source)
>>> L2e = L2Error(bf, ct)
>>> L2e.NP(loc_dofs_N, pressure)
0.0228947...
>>> L2e.EP(loc_dofs_E, (velocity_x, velocity_y, velocity_z))
0.3612213...
>>> L2e.FP(loc_dofs_F, (velocity_x, velocity_y, velocity_z))
0.4178056...
>>> L2e.VP(loc_dofs_V, source)
2.8203143...

EP(loc_dofs, exact_solution)[source]

Let and , we compute .

Parameters:
• loc_dofs – The local dofs of .

• exact_solution – A tuple of three functions representing the three components of the vector .

Returns:

A float representing the -error.

FP(loc_dofs, exact_solution)[source]

Let and , we compute .

Parameters:
• loc_dofs – The local dofs of .

• exact_solution – A tuple of three functions representing the three components of the vector .

Returns:

A float representing the -error.

NP(loc_dofs, exact_solution)[source]

Let and , we compute .

Parameters:
• loc_dofs – The local dofs of .

• exact_solution – The scalar/function .

Returns:

A float representing the -error.

VP(loc_dofs, exact_solution, n=2)[source]

Let and , we compute .

Parameters:
• loc_dofs – The local dofs of .

• exact_solution – The scalar/function .

• n – (default: ) We compute -error.

Returns:

A float representing the -error.

↩️ Back to Ph.D. thesis complements (ptc).