Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
59d7714
Add Maxwell eigenmode solve via a KrylovKit extension
Nov 5, 2026
3eeaa7e
Merge maxwell/1-core into maxwell/2-eigen
Nov 5, 2026
1d30d09
Fix Maxwell eigenmodes without PEC and rank modes by frequency
Nov 5, 2026
20cab17
Raise the KrylovKit compat floor to 0.10
Nov 5, 2026
a17f68c
Rank Maxwell eigenmodes by complex angular frequency distance
Nov 5, 2026
56e5dc9
Handle degenerate sizes in Maxwell eigenmodes
Nov 5, 2026
5f5e6c2
Identify projected gradient modes by their eigenvectors
Nov 5, 2026
43b1711
Merge maxwell/1-core into maxwell/2-eigen
Nov 5, 2026
1694070
Merge maxwell/1-core into maxwell/2-eigen
Nov 5, 2026
28477f7
Merge maxwell/1-core into maxwell/2-eigen (PR workflow triggers)
Nov 6, 2026
e09706d
Merge forge/mwsync-1-core into maxwell/2-eigen
Nov 10, 2026
7b5b914
Make the eigenmode null-space cutoff independent of a high target and…
Nov 10, 2026
7570859
Merge forge/mwsync-1-core into 2-eigen
Nov 11, 2026
caff864
Eigenmodes: reject static modes for low targets; survive a target on …
Nov 11, 2026
991be1b
Merge forge/mwsync-1-core into 2-eigen
Nov 11, 2026
4445f19
Eigenmodes: warn about strongly contrasting materials
Nov 12, 2026
8618747
Eigenmodes: classify static modes by precision, not by the shift floor
Nov 12, 2026
f5be0d5
Merge forge/mwsync-1-core into 2-eigen
Nov 12, 2026
39c4c29
Tests: check the Lagrange facet node table through public shape values
Nov 12, 2026
7726ae0
Eigenmodes: describe the static-mode cutoff as a heuristic
Nov 12, 2026
28e5f3f
Eigenmodes: preserve the multiplicity of repeated eigenvalues
Nov 12, 2026
5c3d3f0
Eigenmodes: restarts widen their candidates like the first search
Nov 12, 2026
b54c319
Eigenmodes: restart deflation with an indefinite mass form
Nov 12, 2026
4c9806f
Eigenmodes: deflate restarts with a Gram-matrix projector
Nov 12, 2026
1ffb42d
Eigenmodes: keep the search helper's variables local and the shift si…
Nov 13, 2026
717958e
Eigenmodes: support ordinary passive materials only
Nov 13, 2026
24988ae
Tests: fix a stray end in the eigenmode rejection testset
Nov 13, 2026
62fe966
Eigenmodes: keep the shifted solve accurate near a resonance and chec…
Nov 13, 2026
26f468e
Eigenmodes: real modes of a repeated eigenvalue are built per cluster
Nov 13, 2026
ae83adc
Eigenmodes: extract the modes by Rayleigh-Ritz on the span of every v…
Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"

[weakdeps]
FerriteGmsh = "4f95f4f8-b27c-4ae5-9a39-ea55e634e36b"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"

[extensions]
FiniteElementMethodFerriteGmshExt = "FerriteGmsh"
FiniteElementMethodKrylovKitExt = "KrylovKit"
FiniteElementMethodMeshesExt = "Meshes"

[compat]
Expand All @@ -37,6 +39,7 @@ Ferrite = "1.7"
FerriteGmsh = "1.5"
ForwardDiff = "1.4"
Gmsh = "0.3"
KrylovKit = "0.10"
LinearAlgebra = "1.10"
ModelingToolkit = "11.34"
LinearSolve = "5"
Expand All @@ -61,6 +64,7 @@ julia = "1.10"
AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"
FerriteGmsh = "4f95f4f8-b27c-4ae5-9a39-ea55e634e36b"
Gmsh = "705231aa-382f-11e9-3f0c-b7cb4346fdeb"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
OrdinaryDiffEqBDF = "6ad6398a-0878-4a85-9266-38940aa047c8"
Expand All @@ -71,4 +75,4 @@ SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["AllocCheck", "FerriteGmsh", "Gmsh", "LinearSolve", "Meshes", "OrdinaryDiffEqBDF", "OrdinaryDiffEqNonlinearSolve", "Random", "SafeTestsets", "SciMLTesting", "Test"]
test = ["AllocCheck", "FerriteGmsh", "Gmsh", "KrylovKit", "LinearSolve", "Meshes", "OrdinaryDiffEqBDF", "OrdinaryDiffEqNonlinearSolve", "Random", "SafeTestsets", "SciMLTesting", "Test"]
18 changes: 18 additions & 0 deletions docs/src/maxwell.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ that is a function of `ω`, so a frequency sweep only recombines nonzero values
[`maxwell_operator!`](@ref), and further terms (boundary conditions, ports) are added as blocks with
`FiniteElementMethod.add_term!`.

## Resonant modes

[`maxwell_eigenmodes`](@ref) finds the modes nearest a target frequency by shift-invert Arnoldi, with the
PEC dofs eliminated and the `ω = 0` gradient null space of the edge elements projected out, so any target
works, including one below the lowest mode. It needs `using KrylovKit`. A lossy material gives complex
`ω`; the quality factor is `Q = Re(ω) / (2 Im(ω))`. Only ordinary passive materials are supported: `real(εr)` and `μr` must be positive (the gradient projection needs a definite mass form), otherwise an `ArgumentError` names the cell set. An air-filled 100 × 50 × 75 mm box has its TE101 mode
at 2.498 GHz:

```julia
using FiniteElementMethod, Ferrite, KrylovKit
grid = generate_grid(Tetrahedron, (12, 6, 9), Vec(0.0, 0.0, 0.0), Vec(100.0, 50.0, 75.0))
model = MaxwellModel(grid; pec = ["left", "right", "bottom", "top", "front", "back"], length_scale = 1.0e-3)
modes = maxwell_eigenmodes(model; nev = 4, target_frequency = 2.0e9)
modes.frequency, modes.Q # Hz; Q is Inf without loss
field_values(modes.modes[1], [Vec(50.0, 25.0, 37.5)]).E
```

```@docs
MaxwellModel
MaxwellMaterial
Expand All @@ -40,6 +57,7 @@ driven_problem
solve_driven
MaxwellSolution
field_values
maxwell_eigenmodes
FiniteElementMethod.maxwell_rhs
FiniteElementMethod.add_term!
FiniteElementMethod.EPS0
Expand Down
12 changes: 12 additions & 0 deletions ext/FiniteElementMethodKrylovKitExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module FiniteElementMethodKrylovKitExt

using FiniteElementMethod: FiniteElementMethod, KrylovKitEigensolver
using KrylovKit: eigsolve

function FiniteElementMethod._eigsolve(::KrylovKitEigensolver, op, x0, nev; krylovdim, tol, maxiter)
vals, vecs, info = eigsolve(op, x0, nev, :LM; ishermitian = false, krylovdim, tol, maxiter)
info.converged < nev && @warn "KrylovKit.eigsolve converged $(info.converged) of $nev eigenpairs"
return vals, vecs
end

end # module
7 changes: 4 additions & 3 deletions src/FiniteElementMethod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using DiffEqBase: BrownFullBasicInit
using DomainSets: DomainSets
using Ferrite: Ferrite, Lagrange, RefLine, RefTriangle, RefQuadrilateral, RefTetrahedron, RefHexahedron
using ForwardDiff: ForwardDiff
using LinearAlgebra: dot, mul!, norm
using LinearAlgebra: SingularException, Symmetric, dot, eigen, lu, mul!, norm, opnorm
using ModelingToolkit: ModelingToolkit, @parameters, @variables, Differential, MTKParameters,
ProblemTypeCtx, System, complete, getmetadata
using NonlinearSolveFirstOrder: NewtonRaphson
Expand All @@ -22,7 +22,7 @@ using PrecompileTools: PrecompileTools
using RuntimeGeneratedFunctions: RuntimeGeneratedFunctions
using SciMLBase: SciMLBase, DAEFunction, DAEProblem
using SciMLBase.SymbolicIndexingInterface: SymbolicIndexingInterface, getp, parameter_index, variable_index
using SparseArrays: SparseMatrixCSC, nnz, nonzeros, nzrange, rowvals
using SparseArrays: SparseMatrixCSC, nnz, nonzeros, nzrange, rowvals, sparse
using SymbolicUtils: SymbolicUtils
using Symbolics: Symbolics, Equation, Num, @register_array_symbolic, substitute, unwrap

Expand Down Expand Up @@ -55,8 +55,9 @@ export Weighted
# Frequency-domain Maxwell: a separate entry point assembled directly on Ferrite, not through the PDESystem front end.
include("maxwell/model.jl")
include("maxwell/driven.jl")
include("maxwell/eigen.jl")
export MaxwellMaterial, MaxwellModel, MaxwellTerm, maxwell_operator, maxwell_operator!
export MaxwellSolution, driven_problem, solve_driven, field_values
export MaxwellSolution, driven_problem, solve_driven, field_values, maxwell_eigenmodes

include("precompile.jl")

Expand Down
Loading
Loading