Skip to content

19 add code verification module#22

Open
jrweinmeister wants to merge 5 commits intorelease-0.0.3from
19-add-code-verification-module
Open

19 add code verification module#22
jrweinmeister wants to merge 5 commits intorelease-0.0.3from
19-add-code-verification-module

Conversation

@jrweinmeister
Copy link
Copy Markdown
Collaborator

This pull request adds a code verification module to CFDverify. The major changes are:

  • Added code module
  • Added unit tests for module
  • Added documentation
  • Added code verification tutorial for new class

The code module at this time only includes the OrderOfAccuracy class which implements methods for computing order of accuracy studies, which are the preferred code verification method. The current class implements basic functionality plus a few utilities to export results and create plots.

Documentation is also added, including the addition of a theory guide in the documentation.

Changes should be consistent with the rules set out in the CFDverify development process: https://cfd-verify.readthedocs.io/en/latest/development.html

@jrweinmeister jrweinmeister added this to the Beta Release milestone Feb 10, 2026
@jrweinmeister jrweinmeister self-assigned this Feb 10, 2026
@jrweinmeister jrweinmeister added the enhancement New feature or request label Feb 10, 2026
@jrweinmeister jrweinmeister linked an issue Feb 10, 2026 that may be closed by this pull request
Comment thread src/cfdverify/code.py
xlabel: str | None=None,
ylabel: str | None=None,
title: str | None=None,
save_figure: str | os.PathLike | bool | None=None,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if supporting passing None or False to these plot helper methods is ideal. Currently, the logic would suggest no figure is saved w these inputs, so the func becomes a null op. The only exception would be if you returned the fig object, which could be further modified by the user (like matlab's "hold"). But since you are creating a new fig and ax pair when this function is called, I don't think that use case is what you had in mind. I suggest that you make this a required input str arg. This would remove one path to unexpected behavior / makes the API clearer imo.

Copy link
Copy Markdown
Collaborator

@dpsanjaya dpsanjaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code works well. I did notice that "Extrapolated Value" should be "Extrapolated value" to be consistent with "Fine mesh error" and "Fine mesh uncertainty".

Comment thread docs/source/theory.rst
Theory
******

This section includes a minimum theory to help users perform effective verification and validation. It is not a substitute for proper training on the topic. To start, several terms can be helpful to know. Verification activities evaluate the correctness of a model. Validation activities assess a model's representation of a real system. Together, these activities are used to assess the accuracy of a model and are often talked about together as verification and validation (V&V). V&V is often part of uncertainty quantification (UQ) activities, which may include uncertainty propagation and sensitivity analysis among many other types. These activities are often described together as VVUQ.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can improve the writing:
This section presents a brief theory to help users perform effective verification and validation. It is not a substitute for proper training, but it is helpful for first-time users. ... Altogether, these activities are often referred to as VVUQ.

Comment thread docs/source/theory.rst
Comment thread docs/source/theory.rst

Code verification activities determine if a code is implemented correctly. There are multiple methods with varying levels of rigor that can be used to ensure a code is correct. Books which cover code verification in detail include those by Roache [Roache1998]_ or Oberkampf & Roy [Oberkampf2010]_.

While code developers often conduct code verification to ensure their solver is bug-free, it is ultimately the responsibility of an analyst to verify their results. When available, analysts are encouraged to run verification suites on the same executable as their analysis. The test problems should also be reviewed to ensure they contain the same equations as the analysis problem, including boundary conditions, source terms, etc. when appropriate.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "When possible" instead of "When available"?

As standard practices, the test problems should also contain the same equations as the analysis problem, including boundary conditions, source terms, etc. Hence, please review the test problems and make sure that they reflect your needs.

Comment thread docs/source/theory.rst
Order of Accuracy
-----------------

Order of accuracy tests are the most rigorous code verification activity because they assess that the solver not only converges to the right value, but that it also converges at the formal order of accuracy. These tests often require solving the test problem on multiple meshes to ensure that the formal order is approached. It is common to not recover the *precise* formal order, but it is often sufficient to show that it is being asymptotically approached with refinement. This can require solving more than the minimum two discretization levels to conduct this test. Order of accuracy tests should be conducted with exact solutions for them best assurance; see the following two subsections for more details on the differences between exact and approximate solutions.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "the formal order is approached", maybe "... is realized" or "... is observed"?

In general, three or more discretization level are necessary to conduct this test.

"Their" best assurance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Code Verification Module

3 participants