Skip to content

Commit 04f4097

Browse files
committed
updated header documentation for scaler
1 parent 176af0f commit 04f4097

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

romtools/trial_space_utils/scaler.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,19 @@
4444
#
4545

4646
'''
47-
The scaler class is used to performed scaled POD.
47+
---
48+
##**Notes**
49+
The scaler class is used to performed scaled POD. Scaling is applied to tensors of shape $\mathbb{R}^{ N_{\\mathrm{vars}} \\times N_{\\mathrm{x}} \\times N_s}$. These tensors are then reshaped into matrices when performing SVD.
50+
51+
___
52+
##**Theory**
4853
4954
*What is scaled POD, and why would I do it?*
5055
5156
Standard POD computes a basis that minimizes the projection error in a standard Euclidean $\\ell^2$ inner product,
52-
i.e., for a snapshot matrix $\\mathbf{S}$, POD computes the basis by solving the minimization problem
57+
i.e., for a snapshot matrix $\\mathbf{S} \\in \\mathbb{R}^{ N_{\\mathrm{vars}} N_{\\mathrm{x}} \\times N_s}$, POD computes the basis by solving the minimization problem
5358
(assuming no affine offset)
54-
$$ \\boldsymbol \\Phi = \\underset{ \\boldsymbol \\Phi_{\\*} \\in \\mathbb{R}^{N \\times K} | \\boldsymbol
59+
$$ \\boldsymbol \\Phi = \\underset{ \\boldsymbol \\Phi_{\\*} \\in \\mathbb{R}^{ N_{\\mathrm{vars}} N_{\\mathrm{x}} \\times K} | \\boldsymbol
5560
\\Phi_{\\*}^T \\boldsymbol \\Phi_{\\*} = \\mathbf{I}}{ \\mathrm{arg \\; min} } \\| \\Phi_{\\*} \\Phi_{\\*}^T
5661
\\mathbf{S} - \\mathbf{S} \\|_2.$$
5762
In this minimization problem, errors are measured in a standard $\\ell^2$ norm.
@@ -64,11 +69,14 @@
6469
Defining $\\mathbf{S}_{\\*} = \\mathbf{W}^{-1} \\mathbf{S}$, where $\\mathbf{W}$ is a weighting matrix
6570
(e.g., a diagonal matrix containing the max absolute value of each state variable),
6671
we compute the basis as the solution to the minimization problem
67-
$$ \\boldsymbol \\Phi = \\mathbf{W} \\underset{ \\boldsymbol \\Phi_{\\*} \\in \\mathbb{R}^{N \\times K} |\\boldsymbol
72+
$$ \\boldsymbol \\Phi = \\mathbf{W} \\underset{ \\boldsymbol \\Phi_{\\*} \\in \\mathbb{R}^{N_{\\mathrm{vars}} N_{\\mathrm{x}} \\times K} |\\boldsymbol
6873
\\Phi_{\\*}^T \\boldsymbol \\Phi_{\\*} = \\mathbf{I}}{ \\mathrm{arg \\; min} } \\| \\Phi_{\\*} \\Phi_{\\*}^T
6974
\\mathbf{S}_{\\*} - \\mathbf{S}_{\\*} \\|_2.$$
7075
71-
The Scaler encapsulates this information
76+
The Scaler encapsulates this information.
77+
78+
___
79+
##**API**
7280
'''
7381

7482
import abc
@@ -113,7 +121,7 @@ class VectorScaler(Scaler):
113121
'''
114122
Concrete implementation designed to scale snapshot matrices by a vector.
115123
For a snapshot tensor $\\mathbf{S} \\in \\mathbb{R}^{N_{\\mathrm{u}} \\times N \\times K}$, the VectorScaler
116-
accepts in a scaling vector $\\mathbf{v} \\in \\mathbb{R}^{N$, and scales by
124+
accepts in a scaling vector $\\mathbf{v} \\in \\mathbb{R}^{N}$, and scales by
117125
$$\\mathbf{S}^* = \\mathrm{diag}(\\mathbf{v})^{-1} \\mathbf{S}$$
118126
before performing POD (i.e., POD is performed on $\\mathbf{S}^*$). After POD is performed, the bases
119127
are post-scaled by $$\\boldsymbol \\Phi = \\mathrm{diag}(\\mathbf{v}) \\mathbf{U}$$

0 commit comments

Comments
 (0)