The tests
subpackage¶
All tests in this subpackage can be run using the command:
# BLDFM root directory
$ pytest -v tests
Unit tests¶
tests.test_pbl_model module¶
This module contains unit tests for the src.pbl_model.vertical_profiles()
function in the src.pbl_model
module. The tests validate the behavior of the function under different closure schemes, including:
CONSTANT Closure: Ensures the profiles for velocity and eddy diffusivity are constant and match expected values.
MOST (Monin-Obukhov Similarity Theory) Closure: Verifies that the profiles vary with height and are physically reasonable.
The tests use parameterized inputs to check the function’s output shapes, values, and physical consistency across various scenarios.
- tests.test_pbl_model.test_constant_closure(n, meas_height, wind, ustar, prsc)[source]¶
Test the CONSTANT closure for scalar inputs.
- Raises:
AssertionError – If the output shapes do not match the expected dimensions or if the profiles are not constant.
- tests.test_pbl_model.test_most_closure(n, meas_height, wind, ustar, mol)[source]¶
Test the MOST closure for scalar inputs.
- Raises:
AssertionError – If the output shapes do not match the expected dimensions or if the profiles are not physically reasonable.
tests.test_solver module¶
This module contains unit tests for the src.solver.steady_state_transport_solver()
function from the src.solver
module. It validates the numerical solver against the analytical solution for the steady-state advection-diffusion equation.
The tests ensure that the numerical solution matches the analytical solution within a specified tolerance and that the outputs have the correct shapes and types.
Functions:¶
test_steady_state_transport_solver: Tests the solver against an analytical solution.
- tests.test_solver.test_steady_state_transport_solver()[source]¶
Tests the
src.solver.steady_state_transport_solver()
function against an analytical solution for the steady-state advection-diffusion equation with a point source at the center of the domain.- The test validates:
The shape and type of the solver’s outputs.
The numerical accuracy of the solver by comparing its results to the analytical solution within a specified tolerance.
- Raises:
AssertionError – If any of the output shapes, types, or numerical accuracy checks fail.
Integration tests¶
tests.test_integration module¶
This module contains an integration test for the interaction between the pbl_model, utils, and solver components.
The test validates the combined behavior of these components by comparing the numerical and analytical solutions for the steady-state advection-diffusion equation. Currently, this test is similar to combining the pbl_model and solver tests, but it is designed to serve as a foundation for future extensions.
Functions:¶
test_integration: Tests the combined behavior of the pbl_model, utils, and solver components.
- tests.test_integration.test_integration()[source]¶
Tests the combined behavior of the pbl_model, utils, and solver components.
- The test validates:
The interaction between the components.
The numerical accuracy of the solver by comparing its results to the analytical solution within a specified tolerance.
- Raises:
AssertionError – If the numerical and analytical solutions differ beyond the specified tolerance.