Skip to content

Reorganize psydac examples#543

Merged
yguclu merged 70 commits intodevelfrom
new_examples
Dec 25, 2025
Merged

Reorganize psydac examples#543
yguclu merged 70 commits intodevelfrom
new_examples

Conversation

@FrederikSchnack
Copy link
Copy Markdown
Contributor

@FrederikSchnack FrederikSchnack commented Nov 21, 2025

Hi Team, this PR fixes #170 .

I think the PR is in a good state for a review, the machinery seems to work quite well and the generated documentation looks nice. We can add more notebooks and examples over time.

New Examples

As discussed in the meeting, we proposed the following examples presented as jupyter notebooks:

  • Define an equation symbolically, discretize it, compute some error norms, plot solution and error – Poisson 2D on a square with “Collela” mapping (Yaman)
  • FEEC API multipatch – Maxwell 2D time harmonic (Frederik)
  • FEM example: L2 projection (Martin)
  • [ ] FEM example: geometric projection (Martin)
  • Example with geometry file (Yaman)
  • 3D example with VTK and Paraview (Elena)
  • Get eigenvalues (FEEC) with SciPy (serial) (Frederik)
  • Get eigenvalues with PETSc + SLEPc (parallel) (Elena)
  • FEEC 3D vector potential (Julian): adapt new examples/vector_potential_3d.py to a notebook

Note: the geometric projections will be illustrated in a later PR, together with a discussion on the geometric nature of the (de Rham) conforming projections.

We can discuss these examples contents and allocation below.

Other todos:

  • create tests using the new examples (should not take too long)
  • expose notebooks to the documentation
  • move multipatch examples in psydac/feec/multipatch/examples to examples/feec and remove the psydac/feec/multipatch folder altogether
  • add feec example tests to CI testing
  • move old examples to examples/old_examples
  • move performance examples in performance to examples/performance
  • fix some minor things in documentation
  • move mpi test script.
  • remove old examples?
  • add tests to the other folders in examples/?

Getting the notebooks into the documentation

  • We need to install psydac in the documentation CI. (Should the documentation be deployed by one of the test CIs?)
  • All notebooks should have a cleared output, we could use nb-clean as a requirement similarly to in IGA-Python (and maybe also run it with the CI).
  • The CI copy-pastes the notebooks + images into the doc folder
  • nbsphinx (with ipykernel) can execute the notebooks and put them in the examples.rst toc.
  • Should we put the assests of notebooks (e.g. pregenerated plots) in the examples folders or somewhere in the documentation?

Testing the notebooks

The notebooks get run by the documentation CI, so any errors lead to a failing build of the documentation.
We can additionally employ ipytest to check for explicit asserts (e.g. convergence errors) for example. I implemented this in the Poisson_non_periodic.ipynb notebook.
This is what a failing test looks like:
failing_tests

If the tests are passing, they are also written in the documentation, which looks like this:
passing_tests

Adding examples

You can try to keep a similar structure to the current notebooks in examples/notebooks. Before commiting new notebooks, please run

nb-clean clean --remove-empty-cells --remove-all-notebook-metadata examples/notebooks/new_notebook.ipynb

To see the generated documentation download the artifact from the docs CI summary and open it in your browser locally.

@FrederikSchnack FrederikSchnack mentioned this pull request Nov 28, 2025
@campospinto
Copy link
Copy Markdown
Collaborator

campospinto commented Nov 28, 2025

I just added a temporary example to illustrate how to perform an L2 projection on a FEM space, with basic manipulations and visualizations in 2D.

At this stage this example is a work-in-progress, hopefully useful to decide which FEM functionalities should be exposed to the users (and possibly identify issues with the current api)

@campospinto
Copy link
Copy Markdown
Collaborator

I think the notebook on FEM + L2 projection is good now (for review), I also mentioned the (H1) conforming projection. I can try to add another one with geometric projections or with "conga-type" Poisson solve, but I'm not sure this is really needed for the 1st release

Comment thread examples/notebooks/Poisson_non_periodic.ipynb
Comment thread examples/notebooks/feec_curlcurl_eigenvalue.ipynb Outdated
Comment thread examples/notebooks/positive_Helmholtz_3D_VTK.ipynb Outdated
Comment thread examples/notebooks/positive_Helmholtz_3D_VTK.ipynb Outdated
Comment thread examples/notebooks/petsc_eigenvalues_positive_Helmholtz.ipynb Outdated
Comment thread .github/workflows/documentation.yml Outdated
Comment thread examples/notebooks/petsc_eigenvalues_regularized_curlcurl.ipynb
Copy link
Copy Markdown
Member

@yguclu yguclu left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@yguclu yguclu merged commit d2d673a into devel Dec 25, 2025
10 checks passed
@yguclu yguclu deleted the new_examples branch December 25, 2025 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Next Release Must be in next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reorganize the psydac/examples directory

5 participants