Skip to content

Adding 5 pymole examples for coverage - #525

Open
brehmd wants to merge 6 commits into
csrc-sdsu:mainfrom
brehmd:feature/pymole-examples
Open

brehmd wants to merge 6 commits into
csrc-sdsu:mainfrom
brehmd:feature/pymole-examples

Conversation

@brehmd

@brehmd brehmd commented Nov 19, 2026 •

Copy link
Copy Markdown

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Example
  • Documentation

Description

Adds five self-contained examples to python/examples/. Together they use every PyMole module (grid, gradient, divergence, laplacian, curl, boundary_condition, robin_boundary_condition, mimetic_operator). File names match the existing Octave/C++ examples.

  • elliptic1DHomogeneousDirichlet.py: -u'' = 1 with u(0) = u(1) = 0. Uses Grid,
    Laplacian, RobinBoundaryCondition. Ported from the Octave/C++ example of the same name.
  • elliptic1DLeftNeumannRightDirichlet.py: -u'' = 1 with u'(0) = 0, u(1) = 0.
    Defines a LeftRightBoundaryCondition(BoundaryCondition) subclass that combines two
    RobinBoundaryCondition objects, because RobinBoundaryCondition applies the same
    coefficients at both ends. Ported from the Octave/C++ example of the same name.
  • hyperbolic1D.py: periodic advection with leapfrog time stepping. Defines an
    Interpol(MimeticOperator) subclass that ports interpol.m. Ported from the
    Octave/C++ example of the same name.
  • curl2D.py: curl of F = (-y, x), which is 2 everywhere. Adapted from Octave
    test_curl.m (renamed so pytest does not collect it).
  • gradient1D.py: convergence of the 1D mimetic gradient for k = 2, 4, 6.
    New example, based on Octave test_grad2DCurv.m.
    Also adds run commands to python/README.md and Python links to the Sphinx pages for
    Elliptic1D-Homogeneous-Dirichlet, Elliptic1D-Left-Neumann-Right-Dirichlet, and Hyperbolic1D.

Related Issues & Documents

QA Instructions, Screenshots, Recordings

python -m pip install --user ./python
python python/examples/elliptic1DHomogeneousDirichlet.py
python python/examples/elliptic1DLeftNeumannRightDirichlet.py
python python/examples/hyperbolic1D.py
python python/examples/curl2D.py
python python/examples/gradient1D.py
python -m pytest python/tests

Tested on Windows 11 (Used WSL for C++)
image

elliptic1DHomogeneous_1 elliptic1DLeftNeumannRighDirichlet_1 hyperbolic1D_1 curl2d_1 gradient1D

Keep-open request

  • I am requesting maintainer review for keep-open.

Reason:

Added/updated tests?

_We encourage you to test all code included with MOLE, including examples.

  • Yes
  • No, and this is why: this PR adds only examples and documentation. No library code changed, so the existing tests still cover the operators. Each example checks itself: it compares its result with the analytical solution and prints the error. I also checked them by hand against the C++ versions.
  • I need help with writing tests

Read Contributing Guide and Code of Conduct

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

brehmd and others added 6 commits November 18, 2026 19:04
…n_boundary_condition modules. Example adapted from Octave and C++ of the same name
…tion, and robin_boundary_condition modules. Example adapted from Octave and C++ of the same name
…les. Example adapted from Octave and C++ of the same name
…on the test_grad2DCurv octave test. Also update Pymole README with all examples

@cpaolini cpaolini left a comment

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.

All five new Python examples run successfully, produce correct numerical results, and pass all existing Python tests. I approve the PR.

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create examples for pymole

2 participants