Errors#
Errors#
Module for calculating errors.
This module provides functions to calculate error norms, including L2 error and H1 semi-norm, between fields defined over a given mesh. Additional error calculation functions can be added as needed.
- phasefieldx.errors_functions.compute_error_H1(field_a, field_b, msh, dx=Measure('cell', subdomain_id='everywhere'))[source]#
Compute the H1 norm error between two fields over a given mesh.
- Parameters:
- field_adolfinx.Function
The first field for the H1 norm error calculation.
- field_bdolfinx.Function
The second field for the H1 norm error calculation.
- mshdolfinx.Mesh
The mesh over which the H1 norm error is computed.
- Returns:
- error_H1float
The H1 norm error between field_a and field_b over the mesh.
Notes
The H1 norm error is computed using the formula: error_H1 = sqrt(∫|field_a - field_b|^2 dx + ∫|∇(field_a - field_b)|^2 dx)
where ‘∇’ represents the gradient operator, and ‘dx’ represents the integration over the entire mesh.
- phasefieldx.errors_functions.compute_error_semiH1(field_a, field_b, msh, dx=Measure('cell', subdomain_id='everywhere'))[source]#
Compute the H1 semi norm error between two fields over a given mesh.
- Parameters:
- field_adolfinx.Function
The first field for the H1 norm error calculation.
- field_bdolfinx.Function
The second field for the H1 norm error calculation.
- mshdolfinx.Mesh
The mesh over which the H1 norm error is computed.
- Returns:
- error_semiH1float
The H1 norm error between field_a and field_b over the mesh.
Notes
The H1 semi norm error is computed using the formula: error_H1 = sqrt( |∇(field_a - field_b)|^2 dx)
where ‘∇’ represents the gradient operator, and ‘dx’ represents the integration over the entire mesh.
- phasefieldx.errors_functions.error_L2_higher_order_space(uh, u_ex, degree_raise=3, dx=Measure('cell', subdomain_id='everywhere'))[source]#
error_L2_higher_order_space _summary_
_extended_summary_
- Parameters:
- uh_type_
_description_
- u_ex_type_
_description_
- degree_raiseint, optional
_description_, by default 3
- dx_type_, optional
_description_, by default ufl.dx
- Returns:
- _type_
_description_
- phasefieldx.errors_functions.eval_error_L2(field_a, field_b, msh, dx=Measure('cell', subdomain_id='everywhere'))[source]#
Compute the L2 error norm between two fields over a given mesh.
- Parameters:
- field_adolfinx.Function
The first field for the L2 error norm calculation.
- field_bdolfinx.Function
The second field for the L2 error norm calculation.
- mshdolfinx.Mesh
The mesh over which the L2 error norm is computed.
- Returns:
- error_L2float
The L2 error norm between field_a and field_b over the mesh.
Notes
The L2 error norm is computed using the formula: error_L2 = sqrt(∫|field_a - field_b|^2 dx)
where ‘dx’ represents the integration over the entire mesh.
- phasefieldx.errors_functions.eval_error_L2_normalized(field_a, field_b, msh, dx=Measure('cell', subdomain_id='everywhere'))[source]#
Compute the normalized L2 error norm between two fields over a given mesh.
- Parameters:
- field_adolfinx.Function
The first field for the normalized L2 error norm calculation.
- field_bdolfinx.Function
The second field for the normalized L2 error norm calculation.
- mshdolfinx.Mesh
The mesh over which the normalized L2 error norm is computed.
- Returns:
- normalized_error_L2float
The normalized L2 error norm between field_a and field_b over the mesh.
Notes
The normalized L2 error norm is computed using the formula: normalized_error_L2 = sqrt(∫|field_a - field_b|^2 dx) / sqrt(∫|field_a|^2 dx)
where ‘dx’ represents the integration over the entire mesh.
- phasefieldx.errors_functions.eval_error_LP(field_a, field_b, msh, p=2, dx=Measure('cell', subdomain_id='everywhere'))[source]#
Compute the Lp error norm between two fields over a given mesh.
- Parameters:
- field_adolfinx.Function
The first field for the Lp error norm calculation.
- field_bdolfinx.Function
The second field for the Lp error norm calculation.
- mshdolfinx.Mesh
The mesh over which the Lp error norm is computed.
- pfloat, optional
The exponent for the Lp norm calculation. Default is 2.
- Returns:
- error_Lpfloat
The Lp error norm between field_a and field_b over the mesh.
Notes
The Lp error norm is computed using the formula: error_Lp = ( ∫|field_a - field_b|^p dx )^(1/p)
where ‘dx’ represents the integration over the entire mesh.