Skip to content

Commit 3f0cea7

Browse files
committed
added tutorials
1 parent 72b3432 commit 3f0cea7

File tree

5 files changed

+109
-10
lines changed

5 files changed

+109
-10
lines changed

tutorials/basic/methods_comparison/methods_comparison.ipynb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"- `from pyspod.spod_low_ram import SPOD_low_ram`\n",
3131
"- `from pyspod.spod_streaming import SPOD_streaming`\n",
3232
"\n",
33-
"that contain three different implementations of the SPOD algorithm, the first requiring low storage memory (intended for large RAM machines or small amount of data), the second requiring low RAM (intended for large dataset or small RAM machines), and the third being a streaming algorithm, that required little amount of memory (both storage and RAM) but runs typically slower than the other two.\n",
33+
"that contain three different implementations of the SPOD algorithm, the first requiring low storage memory (intended for large RAM machines or small amount of data), the second requiring low RAM (intended for large dataset or small RAM machines), and the third being a streaming algorithm, that required little amount of memory (both storage and RAM) but runs typically slower than the other two. \n"
3434
]
3535
},
3636
{
@@ -818,6 +818,29 @@
818818
" vars_idx=[0])"
819819
]
820820
},
821+
{
822+
"cell_type": "markdown",
823+
"metadata": {},
824+
"source": [
825+
"## Using modes for reduced order modeling\n",
826+
"\n",
827+
"It is possible to use the modes generated by SPOD to construct reduced order models. In particular, we can assume that the original data is composed by a temporal mean and a fluctuating component: \n",
828+
"\n",
829+
"$$\\mathbf{q}(t) = \\bar{\\mathbf{q}} + \\mathbf{q}'(t)$$\n",
830+
"\n",
831+
"We can use a reduced number of modes $\\boldsymbol{\\Phi}_r$, with $r < n$, where $n$ is the original dimension of the data $\\mathbf{q}(t)$ to approximate $\\mathbf{q}'(t)$, hence the dynamics of the system. Following [Chu and Schmidt, 2020](https://arxiv.org/pdf/2012.02902.pdf):\n",
832+
"\n",
833+
"- we construct a vector $\\tilde{\\mathbf{q}}$ that approximates the original data $\\mathbf{q}'$ as follows\n",
834+
"\n",
835+
"$$ \\tilde{\\mathbf{q}} = \\boldsymbol{\\Phi}_r(\\boldsymbol{\\Phi}_r^{*} \\mathbf{W}\\boldsymbol{\\Phi}_r)^{-1}\\boldsymbol{\\Phi}_r^{*}\\mathbf{W}\\mathbf{q}' = \\mathbf{P}\\mathbf{q}'$$\n",
836+
"\n",
837+
"- we couple the approximated vector $\\tilde{q}$ with the underlying dynamics (eventually approximated) of the problem being studied\n",
838+
"\n",
839+
"$$ \\frac{\\text{d}}{\\text{d}t}\\mathbf{q}' = f(\\bar{\\mathbf{q}}, \\mathbf{q}', t) \\longrightarrow \\frac{\\text{d}}{\\text{d}t}\\tilde{\\mathbf{q}} = \\mathbf{P}f(\\bar{\\mathbf{q}}, \\tilde{\\mathbf{q}}, t)$$\n",
840+
"\n",
841+
"Obviously, the second step depends on the knowledge we have of the system and how well our knowledge approximates the original dynamics."
842+
]
843+
},
821844
{
822845
"cell_type": "markdown",
823846
"metadata": {},

tutorials/basic/methods_comparison_file/methods_comparison_file.ipynb

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"- `from pyspod.spod_low_ram import SPOD_low_ram`\n",
3131
"- `from pyspod.spod_streaming import SPOD_streaming`\n",
3232
"\n",
33-
"that contain three different implementations of the SPOD algorithm, the first requiring low storage memory (intended for large RAM machines or small amount of data), the second requiring low RAM (intended for large dataset or small RAM machines), and the third being a streaming algorithm, that required little amount of memory (both storage and RAM) but runs typically slower than the other two.\n",
33+
"that contain three different implementations of the SPOD algorithm, the first requiring low storage memory (intended for large RAM machines or small amount of data), the second requiring low RAM (intended for large dataset or small RAM machines), and the third being a streaming algorithm, that required little amount of memory (both storage and RAM) but runs typically slower than the other two.\n"
3434
]
3535
},
3636
{
@@ -978,6 +978,29 @@
978978
" vars_idx=[0])"
979979
]
980980
},
981+
{
982+
"cell_type": "markdown",
983+
"metadata": {},
984+
"source": [
985+
"## Using modes for reduced order modeling\n",
986+
"\n",
987+
"It is possible to use the modes generated by SPOD to construct reduced order models. In particular, we can assume that the original data is composed by a temporal mean and a fluctuating component: \n",
988+
"\n",
989+
"$$\\mathbf{q}(t) = \\bar{\\mathbf{q}} + \\mathbf{q}'(t)$$\n",
990+
"\n",
991+
"We can use a reduced number of modes $\\boldsymbol{\\Phi}_r$, with $r < n$, where $n$ is the original dimension of the data $\\mathbf{q}(t)$ to approximate $\\mathbf{q}'(t)$, hence the dynamics of the system. Following [Chu and Schmidt, 2020](https://arxiv.org/pdf/2012.02902.pdf):\n",
992+
"\n",
993+
"- we construct a vector $\\tilde{\\mathbf{q}}$ that approximates the original data $\\mathbf{q}'$ as follows\n",
994+
"\n",
995+
"$$ \\tilde{\\mathbf{q}} = \\boldsymbol{\\Phi}_r(\\boldsymbol{\\Phi}_r^{*} \\mathbf{W}\\boldsymbol{\\Phi}_r)^{-1}\\boldsymbol{\\Phi}_r^{*}\\mathbf{W}\\mathbf{q}' = \\mathbf{P}\\mathbf{q}'$$\n",
996+
"\n",
997+
"- we couple the approximated vector $\\tilde{q}$ with the underlying dynamics (eventually approximated) of the problem being studied\n",
998+
"\n",
999+
"$$ \\frac{\\text{d}}{\\text{d}t}\\mathbf{q}' = f(\\bar{\\mathbf{q}}, \\mathbf{q}', t) \\longrightarrow \\frac{\\text{d}}{\\text{d}t}\\tilde{\\mathbf{q}} = \\mathbf{P}f(\\bar{\\mathbf{q}}, \\tilde{\\mathbf{q}}, t)$$\n",
1000+
"\n",
1001+
"Obviously, the second step depends on the knowledge we have of the system and how well our knowledge approximates the original dynamics."
1002+
]
1003+
},
9811004
{
9821005
"cell_type": "markdown",
9831006
"metadata": {},
@@ -995,9 +1018,9 @@
9951018
],
9961019
"metadata": {
9971020
"kernelspec": {
998-
"display_name": "pyspod_env",
1021+
"display_name": "Python 3",
9991022
"language": "python",
1000-
"name": "pyspod_env"
1023+
"name": "python3"
10011024
},
10021025
"language_info": {
10031026
"codemirror_mode": {
@@ -1009,7 +1032,7 @@
10091032
"name": "python",
10101033
"nbconvert_exporter": "python",
10111034
"pygments_lexer": "ipython3",
1012-
"version": "3.6.12"
1035+
"version": "3.8.6"
10131036
}
10141037
},
10151038
"nbformat": 4,

tutorials/climate/ERA20C_QBO_3D/ERA20C_QBO_3D.ipynb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,29 @@
751751
"spod.plot_data_tracers(coords_list=[(100,0,2),(200,10,10)])"
752752
]
753753
},
754+
{
755+
"cell_type": "markdown",
756+
"metadata": {},
757+
"source": [
758+
"## Using modes for reduced order modeling\n",
759+
"\n",
760+
"It is possible to use the modes generated by SPOD to construct reduced order models. In particular, we can assume that the original data is composed by a temporal mean and a fluctuating component: \n",
761+
"\n",
762+
"$$\\mathbf{q}(t) = \\bar{\\mathbf{q}} + \\mathbf{q}'(t)$$\n",
763+
"\n",
764+
"We can use a reduced number of modes $\\boldsymbol{\\Phi}_r$, with $r < n$, where $n$ is the original dimension of the data $\\mathbf{q}(t)$ to approximate $\\mathbf{q}'(t)$, hence the dynamics of the system. Following [Chu and Schmidt, 2020](https://arxiv.org/pdf/2012.02902.pdf):\n",
765+
"\n",
766+
"- we construct a vector $\\tilde{\\mathbf{q}}$ that approximates the original data $\\mathbf{q}'$ as follows\n",
767+
"\n",
768+
"$$ \\tilde{\\mathbf{q}} = \\boldsymbol{\\Phi}_r(\\boldsymbol{\\Phi}_r^{*} \\mathbf{W}\\boldsymbol{\\Phi}_r)^{-1}\\boldsymbol{\\Phi}_r^{*}\\mathbf{W}\\mathbf{q}' = \\mathbf{P}\\mathbf{q}'$$\n",
769+
"\n",
770+
"- we couple the approximated vector $\\tilde{q}$ with the underlying dynamics (eventually approximated) of the problem being studied\n",
771+
"\n",
772+
"$$ \\frac{\\text{d}}{\\text{d}t}\\mathbf{q}' = f(\\bar{\\mathbf{q}}, \\mathbf{q}', t) \\longrightarrow \\frac{\\text{d}}{\\text{d}t}\\tilde{\\mathbf{q}} = \\mathbf{P}f(\\bar{\\mathbf{q}}, \\tilde{\\mathbf{q}}, t)$$\n",
773+
"\n",
774+
"Obviously, the second step depends on the knowledge we have of the system and how well our knowledge approximates the original dynamics."
775+
]
776+
},
754777
{
755778
"cell_type": "markdown",
756779
"metadata": {},

tutorials/earthquakes/slip_potency_2D/slip_potency_2D.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"- `from pyspod.spod_low_ram import SPOD_low_ram`\n",
3131
"- `from pyspod.spod_streaming import SPOD_streaming`\n",
3232
"\n",
33-
"that contain three different implementations of the SPOD algorithm, the first requiring low storage memory (intended for large RAM machines or small amount of data), the second requiring low RAM (intended for large dataset or small RAM machines), and the third being a streaming algorithm, that required little amount of memory (both storage and RAM) but runs typically slower than the other two.\n",
33+
"that contain three different implementations of the SPOD algorithm, the first requiring low storage memory (intended for large RAM machines or small amount of data), the second requiring low RAM (intended for large dataset or small RAM machines), and the third being a streaming algorithm, that required little amount of memory (both storage and RAM) but runs typically slower than the other two.\n"
3434
]
3535
},
3636
{
@@ -55,7 +55,7 @@
5555
"# Import library specific modules\n",
5656
"from pyspod.spod_low_storage import SPOD_low_storage\n",
5757
"from pyspod.spod_low_ram import SPOD_low_ram\n",
58-
"from pyspod.spod_streaming import SPOD_streaming\n",
58+
"from pyspod.spod_streaming import SPOD_streaming\n"
5959
]
6060
},
6161
{
@@ -604,4 +604,4 @@
604604
},
605605
"nbformat": 4,
606606
"nbformat_minor": 4
607-
}
607+
}

tutorials/fluidmechanics/jet_2D/jet_2D.ipynb

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"- `from pyspod.spod_low_ram import SPOD_low_ram`\n",
3131
"- `from pyspod.spod_streaming import SPOD_streaming`\n",
3232
"\n",
33-
"that contain three different implementations of the SPOD algorithm, the first requiring low storage memory (intended for large RAM machines or small amount of data), the second requiring low RAM (intended for large dataset or small RAM machines), and the third being a streaming algorithm, that required little amount of memory (both storage and RAM) but runs typically slower than the other two.\n",
33+
"that contain three different implementations of the SPOD algorithm, the first requiring low storage memory (intended for large RAM machines or small amount of data), the second requiring low RAM (intended for large dataset or small RAM machines), and the third being a streaming algorithm, that required little amount of memory (both storage and RAM) but runs typically slower than the other two.\n"
3434
]
3535
},
3636
{
@@ -55,7 +55,7 @@
5555
"# Import library specific modules\n",
5656
"from pyspod.spod_low_storage import SPOD_low_storage\n",
5757
"from pyspod.spod_low_ram import SPOD_low_ram\n",
58-
"from pyspod.spod_streaming import SPOD_streaming\n",
58+
"from pyspod.spod_streaming import SPOD_streaming\n"
5959
]
6060
},
6161
{
@@ -585,6 +585,29 @@
585585
"spod.generate_2D_data_video(x1=x1, x2=x2, vars_idx=[0])"
586586
]
587587
},
588+
{
589+
"cell_type": "markdown",
590+
"metadata": {},
591+
"source": [
592+
"## Using modes for reduced order modeling\n",
593+
"\n",
594+
"It is possible to use the modes generated by SPOD to construct reduced order models. In particular, we can assume that the original data is composed by a temporal mean and a fluctuating component: \n",
595+
"\n",
596+
"$$\\mathbf{q}(t) = \\bar{\\mathbf{q}} + \\mathbf{q}'(t)$$\n",
597+
"\n",
598+
"We can use a reduced number of modes $\\boldsymbol{\\Phi}_r$, with $r < n$, where $n$ is the original dimension of the data $\\mathbf{q}(t)$ to approximate $\\mathbf{q}'(t)$, hence the dynamics of the system. Following [Chu and Schmidt, 2020](https://arxiv.org/pdf/2012.02902.pdf):\n",
599+
"\n",
600+
"- we construct a vector $\\tilde{\\mathbf{q}}$ that approximates the original data $\\mathbf{q}'$ as follows\n",
601+
"\n",
602+
"$$ \\tilde{\\mathbf{q}} = \\boldsymbol{\\Phi}_r(\\boldsymbol{\\Phi}_r^{*} \\mathbf{W}\\boldsymbol{\\Phi}_r)^{-1}\\boldsymbol{\\Phi}_r^{*}\\mathbf{W}\\mathbf{q}' = \\mathbf{P}\\mathbf{q}'$$\n",
603+
"\n",
604+
"- we couple the approximated vector $\\tilde{q}$ with the underlying dynamics (eventually approximated) of the problem being studied\n",
605+
"\n",
606+
"$$ \\frac{\\text{d}}{\\text{d}t}\\mathbf{q}' = f(\\bar{\\mathbf{q}}, \\mathbf{q}', t) \\longrightarrow \\frac{\\text{d}}{\\text{d}t}\\tilde{\\mathbf{q}} = \\mathbf{P}f(\\bar{\\mathbf{q}}, \\tilde{\\mathbf{q}}, t)$$\n",
607+
"\n",
608+
"Obviously, the second step depends on the knowledge we have of the system and how well our knowledge approximates the original dynamics."
609+
]
610+
},
588611
{
589612
"cell_type": "markdown",
590613
"metadata": {},
@@ -604,6 +627,13 @@
604627
"\n",
605628
"and compare the results."
606629
]
630+
},
631+
{
632+
"cell_type": "code",
633+
"execution_count": null,
634+
"metadata": {},
635+
"outputs": [],
636+
"source": []
607637
}
608638
],
609639
"metadata": {

0 commit comments

Comments
 (0)