Skip to content

Commit 14ee77a

Browse files
authored
Add initial Sphinx documentation for FoLax (#30)
* first implementation of docs * documentation of loss functions completed * docstrings added/updated * mesh documentation is added * some doc updates * first page updated * quick start page added * add doc CI tests * add logo to docs * final updates * Update CI.yml
1 parent 1e9ca6d commit 14ee77a

51 files changed

Lines changed: 7522 additions & 1416 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/CI.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,27 @@ jobs:
4040
# flags: unittests
4141
# fail_ci_if_error: true
4242
# token: ${{ secrets.CODECOV_TOKEN }}
43+
44+
docs:
45+
name: Build documentation
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: checkout
49+
uses: actions/checkout@v4
50+
51+
- uses: actions/setup-python@v5
52+
with:
53+
python-version: '3.12'
54+
55+
- name: build docs (Sphinx)
56+
run: |
57+
sudo apt-get update
58+
sudo apt-get install libglu1-mesa
59+
python -m venv venv
60+
. venv/bin/activate
61+
pip install -e .[cpu,docs]
62+
# Run doctests inside documentation
63+
sphinx-build -M doctest docs docs/_build -T
64+
65+
# Build HTML docs (fail on warnings)
66+
sphinx-build -b html -W -T docs docs/_build/html

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
build/
88
*.egg-info/
99
dist/
10-
build/
10+
_build/
1111
play_ground/
1212
flax_state/
1313
*-py-env

docs/_static/css/folax_theme.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@import url("theme.css");
2+
3+
.wy-nav-content {
4+
max-width: 1290px;
5+
}
6+
7+
.rst-content table.docutils {
8+
width: 100%;
9+
}
10+
11+
.rst-content table.docutils td {
12+
vertical-align: top;
13+
padding: 0;
14+
}
15+
16+
.rst-content table.docutils td p {
17+
padding: 8px;
18+
}
19+
20+
.rst-content div[class^=highlight] {
21+
border: 0;
22+
margin: 0;
23+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
``fol.controls``
2+
================
3+
4+
Control strategies provided by FoLax.
5+
6+
.. automodule:: fol.controls
7+
.. currentmodule:: fol.controls
8+
9+
Identity control
10+
----------------
11+
12+
.. automodule:: fol.controls.identity_control
13+
.. currentmodule:: fol.controls.identity_control
14+
15+
.. autoclass:: IdentityControl
16+
:members:
17+
:show-inheritance:
18+
:exclude-members: Finalize
19+
20+
Dirichlet boundary control
21+
--------------------------
22+
23+
.. automodule:: fol.controls.dirichlet_control
24+
.. currentmodule:: fol.controls.dirichlet_control
25+
26+
.. autoclass:: DirichletControl
27+
:members:
28+
:show-inheritance:
29+
:exclude-members: Finalize
30+
31+
Fourier-based control
32+
---------------------
33+
34+
.. automodule:: fol.controls.fourier_control
35+
.. currentmodule:: fol.controls.fourier_control
36+
37+
.. autoclass:: FourierControl
38+
:members:
39+
:show-inheritance:
40+
41+
Voronoi-based control (2D)
42+
--------------------------
43+
44+
.. automodule:: fol.controls.voronoi_control2D
45+
.. currentmodule:: fol.controls.voronoi_control2D
46+
47+
.. autoclass:: VoronoiControl2D
48+
:members:
49+
:show-inheritance:
50+
51+
Voronoi-based control (3D)
52+
--------------------------
53+
54+
.. automodule:: fol.controls.voronoi_control3D
55+
.. currentmodule:: fol.controls.voronoi_control3D
56+
57+
.. autoclass:: VoronoiControl3D
58+
:members:
59+
:show-inheritance:
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
``fol.deep_neural_networks``
2+
============================
3+
4+
The ``fol.deep_neural_networks`` module provides a comprehensive collection of deep learning
5+
architectures and operator-learning frameworks designed for **learning mappings between
6+
function spaces**, with a strong focus on **physics-informed modeling**, **parametric systems**,
7+
and **scientific machine learning**.
8+
9+
This module implements state-of-the-art neural operators such as **DeepONets** and
10+
**Fourier Neural Operators (FNOs)**, together with **Conditional Neural Fields** and
11+
meta-learning strategies. The provided models enable the approximation of complex
12+
solution operators and continuous fields arising in **partial differential equations (PDEs)**,
13+
**multiphysics simulations**, and **high-dimensional parametric problems**, where classical
14+
surrogate models are often insufficient.
15+
16+
Key capabilities of this module include:
17+
18+
- Learning **nonlinear operators** mapping input functions, boundary conditions, or parameters
19+
to solution fields.
20+
- Supporting **data-driven**, **physics-informed**, and **hybrid** training paradigms.
21+
- Handling **explicit** and **implicit** parametric operator learning formulations.
22+
- Neural operators based on **DeepONets** and **Fourier Neural Operators** for learning
23+
mappings between infinite-dimensional spaces.
24+
- **Neural field representations** using coordinate-based MLPs, including **SIREN-style**
25+
sinusoidal networks for high-frequency signal and geometry representation.
26+
- **Conditional neural fields** that model families of functions conditioned on parameters,
27+
latent variables, or context embeddings.
28+
- **Autoencoding architectures** for learning compact latent representations of solution
29+
manifolds and parametric fields.
30+
- **Meta-learning and latent-variable methods** for fast adaptation across tasks, parameters,
31+
and operating regimes.
32+
- Efficient spectral representations and convolutions for scalable, high-dimensional problems.
33+
34+
The module is designed to be extensible and modular, enabling seamless integration
35+
into scientific computing pipelines while leveraging modern deep learning frameworks.
36+
37+
.. automodule:: fol.deep_neural_networks
38+
.. currentmodule:: fol.deep_neural_networks
39+
40+
Deep network base class
41+
-----------------------
42+
43+
.. automodule:: fol.deep_neural_networks.deep_network
44+
.. currentmodule:: fol.deep_neural_networks.deep_network
45+
46+
.. autoclass:: DeepNetwork
47+
:members:
48+
:show-inheritance:
49+
50+
Explicit parametric operator learning
51+
-------------------------------------
52+
53+
This submodule implements **explicit parametric operator learning** on discretized
54+
fields, where a fixed-dimensional parametric input space (for example control
55+
variables or Fourier coefficients) is mapped directly to a fixed-dimensional
56+
discretized field such as temperature or displacement.
57+
58+
The learning is **unsupervised or physics-informed**: no direct target fields are
59+
required. Instead, predicted fields are evaluated using physics-based loss
60+
functions (for example weighted residual- or energy-based formulations), with boundary
61+
conditions applied explicitly at the field level.
62+
63+
.. automodule:: fol.deep_neural_networks.explicit_parametric_operator_learning
64+
:members:
65+
:undoc-members:
66+
:show-inheritance:
67+
68+
.. currentmodule:: fol.deep_neural_networks.explicit_parametric_operator_learning
69+
70+
Implicit parametric operator learning
71+
-------------------------------------
72+
73+
This submodule implements **implicit parametric operator learning** using
74+
coordinate-based neural fields. A fixed-dimensional parametric input (for example
75+
control variables or parameterization features such as Fourier coefficients)
76+
conditions a neural field represented by a coordinate-based MLP (the synthesizer),
77+
with conditioning provided by a modulator network according to the coupling modes
78+
implemented by :class:`fol.deep_neural_networks.nns.HyperNetwork`.
79+
80+
The learning is **unsupervised or physics-informed**: predicted discretized fields
81+
are evaluated using physics-based loss functionals (for example residual- or
82+
energy-based formulations), and Dirichlet boundary conditions are enforced by
83+
explicitly inserting prescribed values across the batch.
84+
85+
Although training is typically performed on a fixed FE mesh, the coordinate-based
86+
synthesizer enables multi-resolution inference (and, in principle, multi-resolution
87+
training) by evaluating the conditioned neural field on alternative coordinate sets.
88+
89+
.. automodule:: fol.deep_neural_networks.implicit_parametric_operator_learning
90+
:members:
91+
:undoc-members:
92+
:show-inheritance:
93+
94+
.. currentmodule:: fol.deep_neural_networks.implicit_parametric_operator_learning
95+
96+
Meta-implicit parametric operator learning
97+
------------------------------------------
98+
99+
This submodule implements **meta-implicit parametric operator learning**, which
100+
extends implicit parametric operator learning by introducing **per-sample latent
101+
adaptation**. Instead of directly conditioning the neural field with parametric
102+
inputs, latent variables are optimized in an inner loop to minimize the
103+
physics-based loss, enabling fast adaptation without updating the main network
104+
weights.
105+
106+
The neural field is represented by a coordinate-based synthesizer MLP and is
107+
conditioned through a modulator network using the coupling modes implemented by
108+
:class:`fol.deep_neural_networks.nns.HyperNetwork`. Training remains
109+
**unsupervised or physics-informed**, with explicit boundary-condition
110+
enforcement and support for multi-resolution inference.
111+
112+
.. automodule:: fol.deep_neural_networks.meta_implicit_parametric_operator_learning
113+
:members:
114+
:undoc-members:
115+
:show-inheritance:
116+
117+
.. currentmodule:: fol.deep_neural_networks.meta_implicit_parametric_operator_learning
118+
119+
Meta-alpha-meta implicit parametric operator learning
120+
-----------------------------------------------------
121+
122+
This submodule implements **meta-alpha-meta implicit parametric operator learning**,
123+
which further extends meta-implicit parametric operator learning by introducing a
124+
**learnable latent-step size** in the inner-loop adaptation. As in the meta-implicit
125+
formulation, latent variables are optimized per sample to minimize the
126+
physics-based loss, but in this variant the magnitude of the latent update itself
127+
is learned jointly with the network parameters.
128+
129+
The neural field is represented by a coordinate-based synthesizer MLP and is
130+
conditioned through a modulator network using the coupling modes implemented by
131+
:class:`fol.deep_neural_networks.nns.HyperNetwork`. The latent codes are adapted
132+
using gradient-based updates, while a dedicated trainable step model controls the
133+
latent update size, enabling improved robustness and adaptability across problem
134+
instances.
135+
136+
Training remains **unsupervised or physics-informed**, with explicit enforcement
137+
of boundary conditions and preservation of the coordinate-based formulation, which
138+
allows multi-resolution inference by evaluating the conditioned neural field on
139+
alternative coordinate sets.
140+
141+
.. automodule:: fol.deep_neural_networks.meta_alpha_meta_implicit_parametric_operator_learning
142+
:members:
143+
:undoc-members:
144+
:show-inheritance:
145+
146+
.. currentmodule:: fol.deep_neural_networks.meta_alpha_meta_implicit_parametric_operator_learning
147+
148+
Fourier parametric operator learning
149+
------------------------------------
150+
151+
This submodule implements **Fourier parametric operator learning** using a
152+
**Fourier Neural Operator (FNO)** on discretized fields. A fixed-dimensional
153+
parametric input space (for example control variables or parameterization
154+
features) is mapped to grid-aligned input channels and processed by the FNO to
155+
produce discretized field outputs such as temperature or displacement.
156+
157+
The FNO is **not bound to a specific mesh resolution**. Once trained, the learned
158+
operator can be evaluated on different grid resolutions, as long as the mesh is
159+
structured and uniform (for example square grids in 2D or cubic grids in 3D).
160+
This enables resolution-invariant inference across compatible discretizations.
161+
162+
The learning can be **data-driven** or **physics-informed**, depending on the
163+
chosen loss function, with boundary conditions enforced explicitly through the
164+
loss.
165+
166+
.. automodule:: fol.deep_neural_networks.fourier_parametric_operator_learning
167+
:members:
168+
:undoc-members:
169+
:show-inheritance:
170+
171+
.. currentmodule:: fol.deep_neural_networks.fourier_parametric_operator_learning
172+
173+
DeepONet parametric operator learning
174+
-------------------------------------
175+
176+
This submodule implements **DeepONet-based parametric operator learning** on
177+
discretized fields. A fixed-dimensional parametric input space conditions a
178+
DeepONet that is evaluated on FE mesh node coordinates to produce discretized
179+
field outputs such as temperature or displacement.
180+
181+
The learning can be **data-driven** or **physics-informed**, depending on the
182+
chosen loss function, with boundary conditions enforced explicitly through the
183+
loss and inference utilities.
184+
185+
.. automodule:: fol.deep_neural_networks.deep_o_net_parametric_operator_learning
186+
:members:
187+
:undoc-members:
188+
:show-inheritance:
189+
190+
.. currentmodule:: fol.deep_neural_networks.deep_o_net_parametric_operator_learning
191+
192+
Neural fields and hypernetworks
193+
-------------------------------
194+
195+
This module provides building blocks for neural field models (e.g., SIREN-style
196+
MLPs and Fourier-feature MLPs) and DeepONets, and hypernetworks used to modulate or generate
197+
parameters for coordinate-based models. These components are commonly used in
198+
implicit neural representations, conditional neural fields, and meta-learning
199+
workflows.
200+
201+
.. automodule:: fol.deep_neural_networks.nns
202+
:members:
203+
:undoc-members:
204+
:show-inheritance:
205+
206+
.. currentmodule:: fol.deep_neural_networks.nns
207+

0 commit comments

Comments
 (0)