Skip to content

Commit

Permalink
Added the plot of trapping region of Lorenze. Renamed some of the fun…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
MPeng5 committed May 9, 2023
1 parent 4327510 commit 46ac661
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 73 deletions.
17 changes: 14 additions & 3 deletions examples/8_trapping_sindy_examples/dysts_examples.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -26,6 +27,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -40,6 +42,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -131,6 +134,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -206,6 +210,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -421,7 +426,7 @@
" plt.grid(True)\n",
" plt.legend()\n",
" \n",
" check_stability_new(r, Xi, sindy_opt, 1.0)\n",
" check_local_stability(r, Xi, sindy_opt, 1.0)\n",
" Xi_true = (true_coefficients[i].T)[:Xi.shape[0], :]\n",
" if r == 3:\n",
" Xi_true = Xi_true[reorder1, :]\n",
Expand Down Expand Up @@ -449,6 +454,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -496,6 +502,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -660,7 +667,7 @@
" x_test_pred = model.simulate(x_test[0, :], t, integrator_kws=integrator_keywords)\n",
" \n",
" # Check stability and try simulated annealing with the IDENTIFIED model\n",
" check_stability_new(r, Xi, sindy_opt, 1.0)\n",
" check_local_stability(r, Xi, sindy_opt, 1.0)\n",
" PL_tensor = sindy_opt.PL_\n",
" PM_tensor = sindy_opt.PM_\n",
" L = np.tensordot(PL_tensor, Xi, axes=([3, 2], [0, 1]))\n",
Expand Down Expand Up @@ -688,6 +695,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -750,6 +758,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -824,7 +833,7 @@
")\n",
"model.fit(x_train, t=t_train, quiet=True)\n",
"Xi = model.coefficients().T\n",
"check_stability_new(r, Xi, sindy_opt, 1.0)\n",
"check_local_stability(r, Xi, sindy_opt, 1.0)\n",
"Q = np.tensordot(sindy_opt.PQ_, Xi, axes=([4, 3], [0, 1]))\n",
"print('nonlinearity preservation breaking = ', \n",
" np.max(np.abs((Q + np.transpose(Q, [1, 2, 0]) + np.transpose(Q, [2, 0, 1])))))\n",
Expand Down Expand Up @@ -856,6 +865,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -940,6 +950,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
268 changes: 199 additions & 69 deletions examples/8_trapping_sindy_examples/trapping_extended.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/8_trapping_sindy_examples/trapping_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_trapping_radius(max_eigval, eps_Q, r, d):
return rad_trap, rad_stab


def check_stability_new(r, Xi, sindy_opt, mean_val, mod_matrix=None):
def check_local_stability(r, Xi, sindy_opt, mean_val, mod_matrix=None):
if mod_matrix is None:
mod_matrix = np.eye(r)
opt_m = sindy_opt.m_history_[-1]
Expand Down

0 comments on commit 46ac661

Please sign in to comment.