Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions docs/src/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
```

```@docs
POD
reduce!
SVD
TSVD
RSVD
deim
```
11 changes: 11 additions & 0 deletions src/DataReduction/POD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ end

_rsvd(data, n::Int, p::Int) = rsvd(data, n, p)

"""
POD(snapshots; min_renergy = 1.0, min_nmodes = 1, max_nmodes = length(snapshots[1]))
POD(snapshots, nmodes)

Proper orthogonal decomposition reduction problem built from state snapshots.
"""
mutable struct POD{S, T <: AbstractFloat} <: AbstractDRProblem
# specified
snapshots::S
Expand Down Expand Up @@ -81,6 +87,11 @@ function determine_truncation(
return nmodes, energy
end

"""
reduce!(pod, alg)

Compute the reduced basis and spectrum for `pod` using the SVD backend `alg`.
"""
function reduce!(pod::POD{S, T}, alg::SVD)::Nothing where {S, T}
u, s, v = _svd(pod.snapshots; alg.kwargs...)
pod.nmodes,
Expand Down
15 changes: 15 additions & 0 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ abstract type AbstractDRProblem <: AbstractReductionProblem end

abstract type AbstractSVD end

"""
SVD(; kwargs...)

Dense singular value decomposition backend for projection basis construction.
"""
struct SVD{K <: NamedTuple} <: AbstractSVD
kwargs::K
function SVD(; kwargs...)
Expand All @@ -12,6 +17,11 @@ struct SVD{K <: NamedTuple} <: AbstractSVD
end
end

"""
TSVD(; kwargs...)

Truncated singular value decomposition backend for projection basis construction.
"""
struct TSVD{K <: NamedTuple} <: AbstractSVD
kwargs::K
function TSVD(; kwargs...)
Expand All @@ -20,6 +30,11 @@ struct TSVD{K <: NamedTuple} <: AbstractSVD
end
end

"""
RSVD([p])

Randomized singular value decomposition backend with oversampling parameter `p`.
"""
struct RSVD <: AbstractSVD
p::Int
function RSVD(p::Int = 0)
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ MethodOfLines = "0.11"
ModelingToolkit = "11"
OrdinaryDiffEq = "7"
SafeTestsets = "0.1"
SciMLTesting = "1"
SciMLTesting = "2.1"
5 changes: 1 addition & 4 deletions test/qa/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@ Aqua = "0.8"
JET = "0.9, 0.10, 0.11"
LinearAlgebra = "1"
SafeTestsets = "0.0.1, 0.1"
SciMLTesting = "1.7"
SciMLTesting = "2.1"
Test = "1"

[sources]
ModelOrderReduction = {path = "../.."}
1 change: 1 addition & 0 deletions test/qa/qa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using SciMLTesting, ModelOrderReduction, Test
run_qa(
ModelOrderReduction;
explicit_imports = true,
api_docs_kwargs = (; rendered = true),
# Whole-package JET (`report_package`/`test_package`) hits a toplevel
# `invalid redefinition of constant ModelOrderReduction.TSVD` error: the package
# exports a `TSVD` struct whose name collides with the `TSVD` dependency package
Expand Down
Loading