L2_error_dual.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
- class L2_error_dual.L2ErrorDual(bf, ct, quad_degree=None)[source]¶
A wrapper of all functions for computing -error. in the dual spaces , , and .
- 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 isNone
, a suitable degree will be obtained frombf
.
- 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_dual import ReductionDual >>> 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 = ReductionDual(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 = L2ErrorDual(bf, ct) >>> L2e.NP(loc_dofs_N, pressure) 0.0228947239... >>> L2e.EP(loc_dofs_E, (velocity_x, velocity_y, velocity_z)) 0.3612213119... >>> L2e.FP(loc_dofs_F, (velocity_x, velocity_y, velocity_z)) 0.4178056796... >>> L2e.VP(loc_dofs_V, source) 2.8203143473...
- 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.
↩️ Back to Ph.D. thesis complements (ptc).