gfem 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. gfem-0.1.0/LICENSE +21 -0
  2. gfem-0.1.0/PKG-INFO +133 -0
  3. gfem-0.1.0/README.md +90 -0
  4. gfem-0.1.0/pyproject.toml +202 -0
  5. gfem-0.1.0/pyproject.toml.orig +207 -0
  6. gfem-0.1.0/src/gfem/__init__.py +242 -0
  7. gfem-0.1.0/src/gfem/__main__.py +107 -0
  8. gfem-0.1.0/src/gfem/_adjoint/__init__.py +5 -0
  9. gfem-0.1.0/src/gfem/_adjoint/measure.py +187 -0
  10. gfem-0.1.0/src/gfem/_adjoint/solve_vjp.py +536 -0
  11. gfem-0.1.0/src/gfem/_boundaries.py +849 -0
  12. gfem-0.1.0/src/gfem/_checks.py +82 -0
  13. gfem-0.1.0/src/gfem/_codec.py +345 -0
  14. gfem-0.1.0/src/gfem/_cuda.py +164 -0
  15. gfem-0.1.0/src/gfem/_domain.py +157 -0
  16. gfem-0.1.0/src/gfem/_eigen/__init__.py +1 -0
  17. gfem-0.1.0/src/gfem/_eigen/adjoint.py +307 -0
  18. gfem-0.1.0/src/gfem/_eigen/arpack.py +81 -0
  19. gfem-0.1.0/src/gfem/_eigen/kept.py +64 -0
  20. gfem-0.1.0/src/gfem/_eigen/operator.py +556 -0
  21. gfem-0.1.0/src/gfem/_eigen/ratios.py +481 -0
  22. gfem-0.1.0/src/gfem/_eigen/refine.py +128 -0
  23. gfem-0.1.0/src/gfem/_eigen/rule.py +2468 -0
  24. gfem-0.1.0/src/gfem/_eigen/seed.py +157 -0
  25. gfem-0.1.0/src/gfem/_eigen/slepc.py +390 -0
  26. gfem-0.1.0/src/gfem/_engine/__init__.py +5 -0
  27. gfem-0.1.0/src/gfem/_engine/anisotropy.py +250 -0
  28. gfem-0.1.0/src/gfem/_engine/cache.py +1071 -0
  29. gfem-0.1.0/src/gfem/_engine/coefficients.py +431 -0
  30. gfem-0.1.0/src/gfem/_engine/dc_conduction.py +697 -0
  31. gfem-0.1.0/src/gfem/_engine/dispersion.py +961 -0
  32. gfem-0.1.0/src/gfem/_engine/domain.py +234 -0
  33. gfem-0.1.0/src/gfem/_engine/driven.py +3170 -0
  34. gfem-0.1.0/src/gfem/_engine/eigen.py +689 -0
  35. gfem-0.1.0/src/gfem/_engine/electrostatic.py +912 -0
  36. gfem-0.1.0/src/gfem/_engine/energy.py +72 -0
  37. gfem-0.1.0/src/gfem/_engine/estimate.py +2141 -0
  38. gfem-0.1.0/src/gfem/_engine/field_duals.py +162 -0
  39. gfem-0.1.0/src/gfem/_engine/fields.py +836 -0
  40. gfem-0.1.0/src/gfem/_engine/floquet_ports.py +352 -0
  41. gfem-0.1.0/src/gfem/_engine/gauge.py +801 -0
  42. gfem-0.1.0/src/gfem/_engine/mesh.py +557 -0
  43. gfem-0.1.0/src/gfem/_engine/port_mode.py +573 -0
  44. gfem-0.1.0/src/gfem/_engine/port_network.py +497 -0
  45. gfem-0.1.0/src/gfem/_engine/power_flow.py +368 -0
  46. gfem-0.1.0/src/gfem/_engine/probe.py +495 -0
  47. gfem-0.1.0/src/gfem/_engine/quadrature.py +48 -0
  48. gfem-0.1.0/src/gfem/_engine/runtime.py +82 -0
  49. gfem-0.1.0/src/gfem/_engine/seam_check.py +204 -0
  50. gfem-0.1.0/src/gfem/_engine/sensitivity.py +1317 -0
  51. gfem-0.1.0/src/gfem/_engine/sweep_outputs.py +364 -0
  52. gfem-0.1.0/src/gfem/_engine/system_operator.py +963 -0
  53. gfem-0.1.0/src/gfem/_engine/terms.py +1597 -0
  54. gfem-0.1.0/src/gfem/_engine/thermal.py +1613 -0
  55. gfem-0.1.0/src/gfem/_engine/thermo_optic.py +128 -0
  56. gfem-0.1.0/src/gfem/_engine/wave_ports.py +593 -0
  57. gfem-0.1.0/src/gfem/_engine/workers.py +134 -0
  58. gfem-0.1.0/src/gfem/_field.py +491 -0
  59. gfem-0.1.0/src/gfem/_floquet.py +1185 -0
  60. gfem-0.1.0/src/gfem/_linalg/__init__.py +744 -0
  61. gfem-0.1.0/src/gfem/_linalg/base.py +596 -0
  62. gfem-0.1.0/src/gfem/_linalg/bddc.py +695 -0
  63. gfem-0.1.0/src/gfem/_linalg/blas.py +106 -0
  64. gfem-0.1.0/src/gfem/_linalg/cg.py +98 -0
  65. gfem-0.1.0/src/gfem/_linalg/coarse.py +284 -0
  66. gfem-0.1.0/src/gfem/_linalg/cudss.py +315 -0
  67. gfem-0.1.0/src/gfem/_linalg/direct.py +532 -0
  68. gfem-0.1.0/src/gfem/_linalg/factor_reuse.py +287 -0
  69. gfem-0.1.0/src/gfem/_linalg/gauge.py +358 -0
  70. gfem-0.1.0/src/gfem/_linalg/gmres.py +635 -0
  71. gfem-0.1.0/src/gfem/_linalg/layout.py +221 -0
  72. gfem-0.1.0/src/gfem/_linalg/lowrank.py +253 -0
  73. gfem-0.1.0/src/gfem/_linalg/pardiso.py +498 -0
  74. gfem-0.1.0/src/gfem/_linalg/petsc.py +928 -0
  75. gfem-0.1.0/src/gfem/_linalg/pieces.py +586 -0
  76. gfem-0.1.0/src/gfem/_linalg/report.py +244 -0
  77. gfem-0.1.0/src/gfem/_linalg/superlu.py +86 -0
  78. gfem-0.1.0/src/gfem/_materials.py +1656 -0
  79. gfem-0.1.0/src/gfem/_morph.py +164 -0
  80. gfem-0.1.0/src/gfem/_mpi.py +939 -0
  81. gfem-0.1.0/src/gfem/_objective.py +1207 -0
  82. gfem-0.1.0/src/gfem/_periodic.py +496 -0
  83. gfem-0.1.0/src/gfem/_petsc.py +366 -0
  84. gfem-0.1.0/src/gfem/_port_section.py +772 -0
  85. gfem-0.1.0/src/gfem/_power_flow.py +229 -0
  86. gfem-0.1.0/src/gfem/_probe.py +174 -0
  87. gfem-0.1.0/src/gfem/_pytree.py +47 -0
  88. gfem-0.1.0/src/gfem/_refine.py +357 -0
  89. gfem-0.1.0/src/gfem/_sheet.py +159 -0
  90. gfem-0.1.0/src/gfem/_sign.py +54 -0
  91. gfem-0.1.0/src/gfem/_solve_cache.py +969 -0
  92. gfem-0.1.0/src/gfem/_sparse.py +58 -0
  93. gfem-0.1.0/src/gfem/_sweep/__init__.py +1 -0
  94. gfem-0.1.0/src/gfem/_sweep/adaptive.py +436 -0
  95. gfem-0.1.0/src/gfem/_sweep/port_mode.py +1213 -0
  96. gfem-0.1.0/src/gfem/_text.py +30 -0
  97. gfem-0.1.0/src/gfem/_timing.py +162 -0
  98. gfem-0.1.0/src/gfem/conventions.py +406 -0
  99. gfem-0.1.0/src/gfem/design.py +629 -0
  100. gfem-0.1.0/src/gfem/errors.py +551 -0
  101. gfem-0.1.0/src/gfem/job.py +959 -0
  102. gfem-0.1.0/src/gfem/measurements.py +1292 -0
  103. gfem-0.1.0/src/gfem/mesh.py +983 -0
  104. gfem-0.1.0/src/gfem/model.py +1063 -0
  105. gfem-0.1.0/src/gfem/options.py +572 -0
  106. gfem-0.1.0/src/gfem/problems.py +1107 -0
  107. gfem-0.1.0/src/gfem/py.typed +0 -0
  108. gfem-0.1.0/src/gfem/quantum.py +590 -0
  109. gfem-0.1.0/src/gfem/refinement.py +3173 -0
  110. gfem-0.1.0/src/gfem/results.py +1809 -0
  111. gfem-0.1.0/src/gfem/shape.py +642 -0
  112. gfem-0.1.0/src/gfem/solve.py +423 -0
  113. gfem-0.1.0/src/gfem/thermal.py +681 -0
  114. gfem-0.1.0/src/gfem/thermo_optic.py +1019 -0
gfem-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Benjamin Vial
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
gfem-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.4
2
+ Name: gfem
3
+ Version: 0.1.0
4
+ Summary: Differentiable finite-element electromagnetics for RF, microwave, mm-wave and superconducting quantum devices.
5
+ Author: Benjamin Vial
6
+ Author-email: Benjamin Vial <contact@bvial.info>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Operating System :: MacOS
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Scientific/Engineering :: Physics
19
+ Classifier: Typing :: Typed
20
+ Requires-Dist: jax>=0.12
21
+ Requires-Dist: meshio>=5.3.5
22
+ Requires-Dist: ngsolve>=6.2.2608,<6.3
23
+ Requires-Dist: numpy>=2.0
24
+ Requires-Dist: scipy>=1.15
25
+ Requires-Dist: nvmath-python[cu12]>=1.0,<1.1 ; (platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'cuda12') or (sys_platform == 'win32' and extra == 'cuda12')
26
+ Requires-Dist: nvmath-python[cu13]>=1.0,<1.1 ; (platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'cuda13') or (sys_platform == 'win32' and extra == 'cuda13')
27
+ Requires-Dist: mkl>=2026.2 ; (platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'mkl') or (platform_machine == 'AMD64' and sys_platform == 'win32' and extra == 'mkl')
28
+ Requires-Dist: mpi4py>=4.1.2,<5 ; platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'mpi'
29
+ Requires-Dist: pyvista ; extra == 'viz'
30
+ Requires-Dist: xarray>=2024.10 ; extra == 'xarray'
31
+ Requires-Python: >=3.12
32
+ Project-URL: Homepage, https://bvial.info/gfem/
33
+ Project-URL: Documentation, https://bvial.info/gfem/
34
+ Project-URL: Source, https://github.com/benvial/gfem
35
+ Project-URL: Issues, https://github.com/benvial/gfem/issues
36
+ Provides-Extra: cuda12
37
+ Provides-Extra: cuda13
38
+ Provides-Extra: mkl
39
+ Provides-Extra: mpi
40
+ Provides-Extra: viz
41
+ Provides-Extra: xarray
42
+ Description-Content-Type: text/markdown
43
+
44
+ <h1>
45
+ <picture>
46
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/benvial/gfem/main/docs/_static/logo/gfem-lockup-dark.svg">
47
+ <img alt="gfem" src="https://raw.githubusercontent.com/benvial/gfem/main/docs/_static/logo/gfem-lockup-light.svg" height="64">
48
+ </picture>
49
+ </h1>
50
+
51
+ Differentiable finite-element electromagnetics for RF, microwave, mm-wave and superconducting quantum devices.
52
+ gfem runs on [NGSolve](https://ngsolve.org) for discretization and [JAX](https://jax.readthedocs.io) for
53
+ everything differentiable.
54
+
55
+ gfem 0.1.0 is the first release. The API may still change before 1.0.
56
+
57
+ ## Install
58
+
59
+ ```bash
60
+ pip install gfem
61
+ ```
62
+
63
+ Each optional extra goes in brackets after `gfem`:
64
+
65
+ ```bash
66
+ pip install "gfem[mkl]" # a faster CPU direct solver, MKL PARDISO (Linux x86_64, Windows); read the licence first
67
+ pip install "gfem[cuda12]" # the direct solver on an NVIDIA GPU, cuDSS (Linux x86_64, Windows); cuda13 for CUDA 13
68
+ pip install "gfem[xarray]" # results as xarray datasets (.to_xarray())
69
+ pip install "gfem[viz]" # fields as PyVista grids (.to_pyvista())
70
+ pip install "gfem[mpi]" # one solve across MPI ranks (Linux x86_64; Open MPI from your machine)
71
+ ```
72
+
73
+ Supported platforms: Linux x86_64 (glibc >= 2.28), macOS arm64 and Windows x86_64, Python >= 3.12.
74
+
75
+ Importing gfem turns on JAX double precision (`jax_enable_x64`), which every gfem solve requires.
76
+
77
+ ## A first solve
78
+
79
+ A parallel-plate line 40 mm long, 6 mm wide and 1 mm high joins two lumped ports matched to it. Its middle 20 mm
80
+ is filled with a ceramic of relative permittivity 10. How much of the incident power reaches port 2 at 2, 5 and
81
+ 8 GHz?
82
+
83
+ ```python
84
+ import urllib.request
85
+
86
+ import gfem
87
+
88
+ url = "https://raw.githubusercontent.com/benvial/gfem/main/docs/tutorials/data/line.msh"
89
+ urllib.request.urlretrieve(url, "line.msh")
90
+ mesh = gfem.Mesh.from_gmsh("line.msh", length_unit="mm")
91
+
92
+ z_line = 376.73 / 6 # ohm: the 6 mm wide, 1 mm high parallel-plate line in air
93
+ model = gfem.Model(
94
+ mesh,
95
+ materials={"feed": gfem.Material(), "design": gfem.Material(eps_r=10.0)},
96
+ boundaries=[gfem.PEC("bottom"), gfem.PEC("top")],
97
+ ports=[
98
+ gfem.LumpedPort("p1", "port1", "+z", impedance=z_line),
99
+ gfem.LumpedPort("p2", "port2", "+z", impedance=z_line),
100
+ ],
101
+ )
102
+ result = gfem.solve(model, gfem.Driven(frequency=(2e9, 5e9, 8e9), excite="p1"))
103
+ print(abs(result.s["p2", "p1"])) # |S21| at 2, 5 and 8 GHz
104
+ ```
105
+
106
+ ```text
107
+ [0.83062238 0.90133217 0.60517471]
108
+ ```
109
+
110
+ [Get started](https://bvial.info/gfem/get-started.html) explains each line, checks the numbers by hand and differentiates the
111
+ result.
112
+
113
+ ## Documentation
114
+
115
+ The documentation is at <https://bvial.info/gfem/>. Good places to start:
116
+
117
+ - [Get started](https://bvial.info/gfem/get-started.html): install, a first solve and its gradient.
118
+ - [Tutorials](https://bvial.info/gfem/tutorials/topology.html): a band-stop filter, a coplanar line matched to 50 Ω, photonic
119
+ waveguide bends and a metagrating, each designed with gradients.
120
+ - [Heaters and thermo-optic phase](https://bvial.info/gfem/recipes/heater-temperature.html): steady and transient
121
+ heat conduction, Joule heating from a DC current, and the phase a heater puts on a waveguide, in 2D and 3D.
122
+ - [PETSc and SLEPc](https://bvial.info/gfem/recipes/petsc-slepc.html): the PETSc and SLEPc solvers, which need a source build.
123
+ - [Distributed solve](https://bvial.info/gfem/recipes/distributed-solve.html): one driven, electrostatic or eigenmode solve across the ranks of an MPI job.
124
+
125
+ ## Licence
126
+
127
+ MIT. gfem depends on NGSolve (LGPL-2.1), whose PyPI wheels also contain GPL-2.0+ SuiteSparse code (UMFPACK, CHOLMOD
128
+ Supernodal); keep that in mind when redistributing a whole gfem environment. The `mkl` and `cuda12`/`cuda13`
129
+ extras pull proprietary vendor libraries: see [Licence](https://bvial.info/gfem/project/licence.html).
130
+
131
+ ## Contributing
132
+
133
+ To build gfem, run its tests or rebuild the docs, see [Contributing](https://bvial.info/gfem/project/development.html).
gfem-0.1.0/README.md ADDED
@@ -0,0 +1,90 @@
1
+ <h1>
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/benvial/gfem/main/docs/_static/logo/gfem-lockup-dark.svg">
4
+ <img alt="gfem" src="https://raw.githubusercontent.com/benvial/gfem/main/docs/_static/logo/gfem-lockup-light.svg" height="64">
5
+ </picture>
6
+ </h1>
7
+
8
+ Differentiable finite-element electromagnetics for RF, microwave, mm-wave and superconducting quantum devices.
9
+ gfem runs on [NGSolve](https://ngsolve.org) for discretization and [JAX](https://jax.readthedocs.io) for
10
+ everything differentiable.
11
+
12
+ gfem 0.1.0 is the first release. The API may still change before 1.0.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pip install gfem
18
+ ```
19
+
20
+ Each optional extra goes in brackets after `gfem`:
21
+
22
+ ```bash
23
+ pip install "gfem[mkl]" # a faster CPU direct solver, MKL PARDISO (Linux x86_64, Windows); read the licence first
24
+ pip install "gfem[cuda12]" # the direct solver on an NVIDIA GPU, cuDSS (Linux x86_64, Windows); cuda13 for CUDA 13
25
+ pip install "gfem[xarray]" # results as xarray datasets (.to_xarray())
26
+ pip install "gfem[viz]" # fields as PyVista grids (.to_pyvista())
27
+ pip install "gfem[mpi]" # one solve across MPI ranks (Linux x86_64; Open MPI from your machine)
28
+ ```
29
+
30
+ Supported platforms: Linux x86_64 (glibc >= 2.28), macOS arm64 and Windows x86_64, Python >= 3.12.
31
+
32
+ Importing gfem turns on JAX double precision (`jax_enable_x64`), which every gfem solve requires.
33
+
34
+ ## A first solve
35
+
36
+ A parallel-plate line 40 mm long, 6 mm wide and 1 mm high joins two lumped ports matched to it. Its middle 20 mm
37
+ is filled with a ceramic of relative permittivity 10. How much of the incident power reaches port 2 at 2, 5 and
38
+ 8 GHz?
39
+
40
+ ```python
41
+ import urllib.request
42
+
43
+ import gfem
44
+
45
+ url = "https://raw.githubusercontent.com/benvial/gfem/main/docs/tutorials/data/line.msh"
46
+ urllib.request.urlretrieve(url, "line.msh")
47
+ mesh = gfem.Mesh.from_gmsh("line.msh", length_unit="mm")
48
+
49
+ z_line = 376.73 / 6 # ohm: the 6 mm wide, 1 mm high parallel-plate line in air
50
+ model = gfem.Model(
51
+ mesh,
52
+ materials={"feed": gfem.Material(), "design": gfem.Material(eps_r=10.0)},
53
+ boundaries=[gfem.PEC("bottom"), gfem.PEC("top")],
54
+ ports=[
55
+ gfem.LumpedPort("p1", "port1", "+z", impedance=z_line),
56
+ gfem.LumpedPort("p2", "port2", "+z", impedance=z_line),
57
+ ],
58
+ )
59
+ result = gfem.solve(model, gfem.Driven(frequency=(2e9, 5e9, 8e9), excite="p1"))
60
+ print(abs(result.s["p2", "p1"])) # |S21| at 2, 5 and 8 GHz
61
+ ```
62
+
63
+ ```text
64
+ [0.83062238 0.90133217 0.60517471]
65
+ ```
66
+
67
+ [Get started](https://bvial.info/gfem/get-started.html) explains each line, checks the numbers by hand and differentiates the
68
+ result.
69
+
70
+ ## Documentation
71
+
72
+ The documentation is at <https://bvial.info/gfem/>. Good places to start:
73
+
74
+ - [Get started](https://bvial.info/gfem/get-started.html): install, a first solve and its gradient.
75
+ - [Tutorials](https://bvial.info/gfem/tutorials/topology.html): a band-stop filter, a coplanar line matched to 50 Ω, photonic
76
+ waveguide bends and a metagrating, each designed with gradients.
77
+ - [Heaters and thermo-optic phase](https://bvial.info/gfem/recipes/heater-temperature.html): steady and transient
78
+ heat conduction, Joule heating from a DC current, and the phase a heater puts on a waveguide, in 2D and 3D.
79
+ - [PETSc and SLEPc](https://bvial.info/gfem/recipes/petsc-slepc.html): the PETSc and SLEPc solvers, which need a source build.
80
+ - [Distributed solve](https://bvial.info/gfem/recipes/distributed-solve.html): one driven, electrostatic or eigenmode solve across the ranks of an MPI job.
81
+
82
+ ## Licence
83
+
84
+ MIT. gfem depends on NGSolve (LGPL-2.1), whose PyPI wheels also contain GPL-2.0+ SuiteSparse code (UMFPACK, CHOLMOD
85
+ Supernodal); keep that in mind when redistributing a whole gfem environment. The `mkl` and `cuda12`/`cuda13`
86
+ extras pull proprietary vendor libraries: see [Licence](https://bvial.info/gfem/project/licence.html).
87
+
88
+ ## Contributing
89
+
90
+ To build gfem, run its tests or rebuild the docs, see [Contributing](https://bvial.info/gfem/project/development.html).
@@ -0,0 +1,202 @@
1
+ [project]
2
+ name = "gfem"
3
+ version = "0.1.0"
4
+ description = "Differentiable finite-element electromagnetics for RF, microwave, mm-wave and superconducting quantum devices."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Intended Audience :: Science/Research",
12
+ "Operating System :: MacOS",
13
+ "Operating System :: Microsoft :: Windows",
14
+ "Operating System :: POSIX :: Linux",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Programming Language :: Python :: 3.14",
19
+ "Topic :: Scientific/Engineering :: Physics",
20
+ "Typing :: Typed",
21
+ ]
22
+ dependencies = [
23
+ "jax>=0.12",
24
+ "meshio>=5.3.5",
25
+ "ngsolve>=6.2.2608,<6.3",
26
+ "numpy>=2.0",
27
+ "scipy>=1.15",
28
+ ]
29
+
30
+ [[project.authors]]
31
+ name = "Benjamin Vial"
32
+ email = "contact@bvial.info"
33
+
34
+ [project.urls]
35
+ Homepage = "https://bvial.info/gfem/"
36
+ Documentation = "https://bvial.info/gfem/"
37
+ Source = "https://github.com/benvial/gfem"
38
+ Issues = "https://github.com/benvial/gfem/issues"
39
+
40
+ [project.scripts]
41
+ gfem = "gfem.__main__:main"
42
+
43
+ [project.optional-dependencies]
44
+ cuda12 = ["nvmath-python[cu12]>=1.0,<1.1; (sys_platform == 'linux' and platform_machine == 'x86_64') or sys_platform == 'win32'"]
45
+ cuda13 = ["nvmath-python[cu13]>=1.0,<1.1; (sys_platform == 'linux' and platform_machine == 'x86_64') or sys_platform == 'win32'"]
46
+ mkl = ["mkl>=2026.2; (sys_platform == 'linux' and platform_machine == 'x86_64') or (sys_platform == 'win32' and platform_machine == 'AMD64')"]
47
+ mpi = ["mpi4py>=4.1.2,<5; sys_platform == 'linux' and platform_machine == 'x86_64'"]
48
+ viz = ["pyvista"]
49
+ xarray = ["xarray>=2024.10"]
50
+
51
+ [dependency-groups]
52
+ docs = [
53
+ "ipykernel>=6.29",
54
+ "matplotlib>=3.9",
55
+ "nbconvert>=7.16",
56
+ "optax>=0.2.4",
57
+ "pyvista>=0.44",
58
+ ]
59
+ lint = [
60
+ "ruff>=0.14",
61
+ "ty==0.0.85",
62
+ ]
63
+ site = [
64
+ "myst-nb~=1.4",
65
+ "myst-parser~=5.1",
66
+ "pagefind[bin]==1.5.2",
67
+ "shibuya==2026.7.12",
68
+ "sphinx~=9.2.0",
69
+ "sphinx-autoapi~=3.8",
70
+ "sphinx-copybutton==0.5.2",
71
+ "sphinxext-opengraph",
72
+ "trame-pyvista",
73
+ "trame-vtk",
74
+ ]
75
+ test = [
76
+ "pytest>=8.3",
77
+ "pytest-cov>=6.0",
78
+ "xarray>=2024.10",
79
+ ]
80
+
81
+ [[dependency-groups.dev]]
82
+ include-group = "lint"
83
+
84
+ [[dependency-groups.dev]]
85
+ include-group = "test"
86
+
87
+ [build-system]
88
+ requires = ["uv_build>=0.13,<0.14"]
89
+ build-backend = "uv_build"
90
+
91
+ [tool.pytest.ini_options]
92
+ addopts = "--tb=short --strict-markers --import-mode=importlib -m 'not reference and not benchmark and not cuda and not mpi'"
93
+ markers = [
94
+ "unit: fast tests run on every PR on all platforms (tests/unit)",
95
+ "verification: convergence, manufactured-solution and Taylor tests (tests/verification)",
96
+ "reference: reference problems against frozen baselines, needs GFEM_REFERENCE_DIR (tests/reference, deselected by default)",
97
+ "benchmark: wall-time and memory regression runs (tests/benchmark, deselected by default)",
98
+ "cuda: needs an NVIDIA GPU and the cuda12 or cuda13 extra (tests/cuda, deselected by default)",
99
+ "mpi: launched under ranks from a one-process pytest, needs mpi4py and Open MPI; skipped without them (tests/mpi, deselected by default)",
100
+ "petsc: needs complex petsc4py built as the PETSc and SLEPc recipe describes; skipped without it (run alone with -m petsc)",
101
+ "slepc: needs slepc4py on that PETSc; skipped without it",
102
+ "bitwise: needs repeatable direct solves (last bits, tight convergence); one solve thread without PARDISO",
103
+ ]
104
+ pythonpath = [
105
+ "tools",
106
+ "tests",
107
+ ".",
108
+ ]
109
+ testpaths = ["tests"]
110
+
111
+ [tool.ruff]
112
+ fix = true
113
+ target-version = "py312"
114
+
115
+ [tool.ruff.format]
116
+ docstring-code-format = true
117
+
118
+ [tool.ruff.lint]
119
+ ignore = [
120
+ "ANN",
121
+ "C408",
122
+ "C901",
123
+ "COM812",
124
+ "CPY001",
125
+ "D105",
126
+ "D417",
127
+ "E741",
128
+ "EM101",
129
+ "EM102",
130
+ "FBT",
131
+ "FIX002",
132
+ "N803",
133
+ "N806",
134
+ "PLC0415",
135
+ "PLR0913",
136
+ "PLR2004",
137
+ "RET504",
138
+ "TC001",
139
+ "TC002",
140
+ "TC003",
141
+ "TD002",
142
+ "TD003",
143
+ "TRY003",
144
+ ]
145
+ select = ["ALL"]
146
+
147
+ [tool.ruff.lint.per-file-ignores]
148
+ "docs/**/*.ipynb" = [
149
+ "D",
150
+ "T201",
151
+ ]
152
+ "tests/**/*.py" = [
153
+ "D",
154
+ "INP001",
155
+ "PT011",
156
+ "S101",
157
+ "S603",
158
+ "SLF001",
159
+ ]
160
+ "docs/**/*.py" = ["INP001"]
161
+ "tools/{*,stacks/*}.py" = [
162
+ "INP001",
163
+ "S603",
164
+ "T201",
165
+ ]
166
+ "benchmarks/**/*.py" = [
167
+ "S603",
168
+ "S607",
169
+ "T201",
170
+ ]
171
+
172
+ [tool.ruff.lint.pydocstyle]
173
+ convention = "google"
174
+
175
+ [tool.ty.src]
176
+ include = [
177
+ "src",
178
+ "benchmarks",
179
+ ]
180
+
181
+ [tool.ty.analysis]
182
+ allowed-unresolved-imports = [
183
+ "nvmath.**",
184
+ "cuda.**",
185
+ "petsc4py.**",
186
+ "slepc4py.**",
187
+ "mpi4py.**",
188
+ ]
189
+
190
+ [tool.uv]
191
+ environments = [
192
+ "sys_platform == 'linux' and platform_machine == 'x86_64'",
193
+ "sys_platform == 'darwin' and platform_machine == 'arm64'",
194
+ "sys_platform == 'win32' and platform_machine == 'AMD64'",
195
+ ]
196
+ conflicts = [[
197
+ { extra = "cuda12" },
198
+ { extra = "cuda13" },
199
+ ]]
200
+
201
+ [tool.uv.dependency-groups.site]
202
+ requires-python = ">=3.13"
@@ -0,0 +1,207 @@
1
+ [project]
2
+ name = "gfem"
3
+ version = "0.1.0"
4
+ description = "Differentiable finite-element electromagnetics for RF, microwave, mm-wave and superconducting quantum devices."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "Benjamin Vial", email = "contact@bvial.info" }]
10
+ classifiers = [
11
+ "Development Status :: 3 - Alpha",
12
+ "Intended Audience :: Science/Research",
13
+ "Operating System :: MacOS",
14
+ "Operating System :: Microsoft :: Windows",
15
+ "Operating System :: POSIX :: Linux",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Topic :: Scientific/Engineering :: Physics",
21
+ "Typing :: Typed",
22
+ ]
23
+ # Upper bound only where gfem touches internals (NGSolve). JAX gets a floor
24
+ # only: a cap would collide with optax / equinox in users' environments.
25
+ dependencies = [
26
+ "jax>=0.12",
27
+ "meshio>=5.3.5",
28
+ "ngsolve>=6.2.2608,<6.3",
29
+ "numpy>=2.0",
30
+ "scipy>=1.15",
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://bvial.info/gfem/"
35
+ Documentation = "https://bvial.info/gfem/"
36
+ Source = "https://github.com/benvial/gfem"
37
+ Issues = "https://github.com/benvial/gfem/issues"
38
+
39
+ [project.scripts]
40
+ gfem = "gfem.__main__:main"
41
+
42
+ [project.optional-dependencies]
43
+ # cuDSS through nvmath-python. A no-op on macOS, so a shared requirements file
44
+ # still installs there. The two CUDA extras exclude each other.
45
+ cuda12 = [
46
+ "nvmath-python[cu12]>=1.0,<1.1; (sys_platform == 'linux' and platform_machine == 'x86_64') or sys_platform == 'win32'",
47
+ ]
48
+ cuda13 = [
49
+ "nvmath-python[cu13]>=1.0,<1.1; (sys_platform == 'linux' and platform_machine == 'x86_64') or sys_platform == 'win32'",
50
+ ]
51
+ # MKL PARDISO with METIS ordering for the CPU direct solver. Proprietary: `mkl`
52
+ # is under the Intel Simplified Software License, and the `intel-openmp` and
53
+ # `intel-cmplr-lib-ur` it pulls in under the Intel End User License Agreement
54
+ # for Developer Tools (no SaaS or service-bureau use; see
55
+ # docs/project/licence.md). Wheels exist for x86_64 Linux and Windows only;
56
+ # elsewhere the extra installs nothing and `direct` stays sparse Cholesky.
57
+ mkl = [
58
+ "mkl>=2026.2; (sys_platform == 'linux' and platform_machine == 'x86_64') or (sys_platform == 'win32' and platform_machine == 'AMD64')",
59
+ ]
60
+ # mpi4py for distributed solves. Brings no MPI library: load Open MPI's module or
61
+ # package, the only MPI that gives right numbers with NGSolve's wheel. Linux x86_64
62
+ # only, like the MPI PETSc stack. Capped: NGSolve's wrapper reaches into mpi4py.
63
+ mpi = [
64
+ "mpi4py>=4.1.2,<5; sys_platform == 'linux' and platform_machine == 'x86_64'",
65
+ ]
66
+ viz = ["pyvista"]
67
+ xarray = ["xarray>=2024.10"]
68
+
69
+ [dependency-groups]
70
+ dev = [{ include-group = "lint" }, { include-group = "test" }]
71
+ # Running the tutorial notebooks (docs/tutorials): an external optimizer, plots,
72
+ # 3D views and a headless notebook runner.
73
+ docs = [
74
+ "ipykernel>=6.29",
75
+ "matplotlib>=3.9",
76
+ "nbconvert>=7.16",
77
+ "optax>=0.2.4",
78
+ "pyvista>=0.44",
79
+ ]
80
+ lint = ["ruff>=0.14", "ty==0.0.85"]
81
+ # Building the docs site (docs/conf.py), on top of `docs`. Python >= 3.13 only
82
+ # ([tool.uv.dependency-groups] below): Sphinx 9.2 does not support 3.12.
83
+ site = [
84
+ "myst-nb~=1.4",
85
+ "myst-parser~=5.1",
86
+ "pagefind[bin]==1.5.2",
87
+ "shibuya==2026.7.12",
88
+ "sphinx~=9.2.0",
89
+ "sphinx-autoapi~=3.8",
90
+ "sphinx-copybutton==0.5.2",
91
+ "sphinxext-opengraph",
92
+ # The tutorials' 3D scenes: exported by `just notebooks` (trame-pyvista),
93
+ # opened on the site by trame-vtk's offline vtk.js viewer.
94
+ "trame-pyvista",
95
+ "trame-vtk",
96
+ ]
97
+ test = ["pytest>=8.3", "pytest-cov>=6.0", "xarray>=2024.10"]
98
+
99
+ [build-system]
100
+ requires = ["uv_build>=0.13,<0.14"]
101
+ build-backend = "uv_build"
102
+
103
+ [tool.pytest.ini_options]
104
+ # Test tiers are markers. tests/conftest.py marks every test by its directory
105
+ # (tests/unit -> unit, tests/verification -> verification, ...). The heavy and
106
+ # GPU tiers are opt-in, e.g. `pytest -m reference`. importlib mode lets
107
+ # tiers share test file names (tests/unit/test_x.py, tests/verification/test_x.py).
108
+ addopts = "--tb=short --strict-markers --import-mode=importlib -m 'not reference and not benchmark and not cuda and not mpi'"
109
+ markers = [
110
+ "unit: fast tests run on every PR on all platforms (tests/unit)",
111
+ "verification: convergence, manufactured-solution and Taylor tests (tests/verification)",
112
+ "reference: reference problems against frozen baselines, needs GFEM_REFERENCE_DIR (tests/reference, deselected by default)",
113
+ "benchmark: wall-time and memory regression runs (tests/benchmark, deselected by default)",
114
+ "cuda: needs an NVIDIA GPU and the cuda12 or cuda13 extra (tests/cuda, deselected by default)",
115
+ "mpi: launched under ranks from a one-process pytest, needs mpi4py and Open MPI; skipped without them (tests/mpi, deselected by default)",
116
+ "petsc: needs complex petsc4py built as the PETSc and SLEPc recipe describes; skipped without it (run alone with -m petsc)",
117
+ "slepc: needs slepc4py on that PETSc; skipped without it",
118
+ "bitwise: needs repeatable direct solves (last bits, tight convergence); one solve thread without PARDISO",
119
+ ]
120
+ pythonpath = ["tools", "tests", "."] # "." imports the benchmarks package
121
+ testpaths = ["tests"]
122
+
123
+ [tool.ruff]
124
+ fix = true
125
+ target-version = "py312"
126
+
127
+ [tool.ruff.format]
128
+ docstring-code-format = true
129
+
130
+ [tool.ruff.lint] # see https://docs.astral.sh/ruff/rules; the ignore list starts from gsim's
131
+ ignore = [
132
+ "ANN", # flake8-annotations (too noisy for evolving API)
133
+ "C408", # unnecessary-collection-call
134
+ "C901", # complex-structure
135
+ "COM812", # missing-trailing-comma (conflicts with the formatter)
136
+ "CPY001", # missing-copyright-notice (LICENSE covers the repository)
137
+ "D105", # undocumented-magic-method
138
+ "D417", # undocumented-param (google convention is strict here)
139
+ "E741", # ambiguous-variable-name
140
+ "EM101", # exception-must-not-use-string-literal
141
+ "EM102", # exception-must-not-use-f-string-literal
142
+ "FBT", # boolean-trap
143
+ "FIX002", # line-contains-todo
144
+ "N803", # invalid-argument-name (physics names: E, H, Z0, ...)
145
+ "N806", # non-lowercase-variable-in-function (physics names)
146
+ "PLC0415", # import-outside-top-level (lazy imports of heavy dependencies)
147
+ "PLR0913", # too-many-arguments
148
+ "PLR2004", # magic-value-comparison
149
+ "RET504", # unnecessary-assign
150
+ "TC001", # typing-only-first-party-import
151
+ "TC002", # typing-only-third-party-import
152
+ "TC003", # typing-only-standard-library-import
153
+ "TD002", # missing-todo-author
154
+ "TD003", # missing-todo-link
155
+ "TRY003", # raise-vanilla-args
156
+ ]
157
+ select = ["ALL"]
158
+
159
+ [tool.ruff.lint.per-file-ignores]
160
+ "docs/**/*.ipynb" = [
161
+ "D", # pydocstyle (tutorial helpers are explained in the prose)
162
+ "T201", # print (notebooks report results)
163
+ ]
164
+ "tests/**/*.py" = [
165
+ "D", # pydocstyle
166
+ "INP001", # implicit-namespace-package
167
+ "PT011", # pytest-raises-too-broad
168
+ "S101", # assert
169
+ "S603", # subprocess-without-shell-equals-true
170
+ "SLF001", # private-member-access
171
+ ]
172
+ "docs/**/*.py" = [
173
+ "INP001", # implicit-namespace-package (Sphinx configuration, not a package)
174
+ ]
175
+ "tools/{*,stacks/*}.py" = [
176
+ "INP001", # implicit-namespace-package (scripts, not a package)
177
+ "S603", # subprocess-without-shell-equals-true
178
+ "T201", # print
179
+ ]
180
+ "benchmarks/**/*.py" = [
181
+ "S603", # subprocess-without-shell-equals-true (launches sbatch, srun, workers)
182
+ "S607", # start-process-with-partial-path (sbatch, srun, rsync, git from PATH)
183
+ "T201", # print (a command line)
184
+ ]
185
+
186
+ [tool.ruff.lint.pydocstyle]
187
+ convention = "google"
188
+
189
+ [tool.ty.src]
190
+ include = ["src", "benchmarks"]
191
+
192
+ [tool.ty.analysis]
193
+ # The cuda12 / cuda13 extras: absent from the default environment.
194
+ allowed-unresolved-imports = ["nvmath.**", "cuda.**", "petsc4py.**", "slepc4py.**", "mpi4py.**"]
195
+
196
+ [tool.uv]
197
+ # The supported platforms: jaxlib has no Intel macOS wheel and
198
+ # ngsolve has no Linux aarch64 wheel.
199
+ environments = [
200
+ "sys_platform == 'linux' and platform_machine == 'x86_64'",
201
+ "sys_platform == 'darwin' and platform_machine == 'arm64'",
202
+ "sys_platform == 'win32' and platform_machine == 'AMD64'",
203
+ ]
204
+ conflicts = [[{ extra = "cuda12" }, { extra = "cuda13" }]]
205
+
206
+ [tool.uv.dependency-groups]
207
+ site = { requires-python = ">=3.13" }