18.2. NGSolve in JupyterLite#

The fastest way to share your ngsolve notebooks with others (who may or may not be in the ngsolve world) is through the new JupyterLite technology. It allows you to immediately deploy your notebooks in a live computing environment without even installing ngsolve.

Specifically, JupyterLite enables NGSolve to be run in your web browser on your computer without any install process and negligible startup time. This is made possible by compiling NGSolve into a WebAssembly code (supported by most major modern browsers). It is then offered to you using Pyodide and JupyterLite.

NGSolve with JupyterLite is recommended for

  • conference talks showing live code demos

  • hands-on tutorials (with no required installation)

  • introductory courses on finite elements.

18.2.1. A Ready-made NGSolve JupyterLite Template#

A small GitHub repository encapsulating all required elements for deploying NGSolve notebooks in JupyterLite can be found here:


The key statement in the set up there issues a jupyter lite build ... command using a --pyodide file provided by the NGSolve development team. Within the content subfolder, you will find a few notebooks, which can be immediately deployed.

To deploy your own ngsolve notebook collection, all you need to do is to fork this repo and replace the notebooks there with your own ones. Here are some examples where this is done.

18.2.2. Examples:#

Some caveats:

  • Note that external nonsymmetric sparse direct solvers (like umfpack and pardiso) are currently unavailable in NGSolve with JupyterLite. If you need to solve a nonsymmetric system, use iterative solvers, as in this example, or use ngs.directsolvers.SuperLU which interfaces to a scipy facility.

  • WebAssembly uses 32-bit memory addressing, not 64-bit.

  • Thread parallelism is yet to be perfected in jupyterlite.