%%% Test on Gauss-Lobatto Points %%%
clear; close all; clc;
addpath('funcs');
addpath('models');
%% Slow Manifold
n = 200;
T = 20;
N = [3,5,7,9,11];
x0 = [1,1];
r = [0.1, 0.1];
frac = 0.2;
op = 1;
p = struct();
p.alpha = -0.05;
p.beta = -1;
fmodel = @(t, x, p) SlowManifold(t, x, p);
fdynamics = @(X, Y, p) SlowManifoldDynamics(X, Y, p);
% test
running_time = zeros(1, length(N));
error_terminal = zeros(2, length(N));
xtT = [exp(p.alpha*T); (-2*p.alpha / (p.beta - 2*p.alpha)) * exp(p.beta*T) + (p.beta / (p.beta - 2*p.alpha)) * exp(2*p.alpha*T)];
for i = 1:length(N)
tic;
[xnT, n_decomp] = ASK_2D(fdynamics, p, n, T, N(i), x0, r, frac, op);
running_time(i) = toc;
error_terminal(:, i) = abs(xtT - xnT);
end
% display & store
model_name = 'SM';
format1 = '.mat';
format2 = '.png';
format3 = '.eps';
name1 = strcat('results\GaussLobatto\time_', model_name, '_N_', num2str(T));
name2 = strcat('results\GaussLobatto\error_', model_name, '_N_', num2str(T));
save(strcat(name1, format1), 'running_time');
save(strcat(name2, format1), 'error_terminal');
figure;
plot(N, running_time, 'o-', 'linewidth', 2, 'markersize', 10);
xlim([2, 12]);
xlabel('N', 'interpreter', 'latex', 'fontsize', 18);
ylabel('Running Time (s)', 'interpreter', 'latex', 'fontsize', 18);
set(gca, 'linewidth', 2);
set(gca, 'fontsize', 16);
saveas(gcf, strcat(name1, format2));
saveas(gcf, strcat(name1, format3));
NameArray = {'Marker'};
ValueArray = {'o'; 's'};
figure;
p = semilogy(N-1, error_terminal', '-', 'linewidth', 2, 'markersize', 10);
set(p, NameArray, ValueArray);
xlim([1, 11]);
xlabel('N', 'interpreter', 'latex', 'fontsize', 18);
ylim([1e-16, 1e-9]);
ylabel('Error', 'interpreter', 'latex', 'fontsize', 18);
set(gca, 'linewidth', 2);
set(gca, 'fontsize', 16);
saveas(gcf, strcat(name2, format2));
saveas(gcf, strcat(name2, format3));
disp('Slow manifold completed!');
%% Lotka-Volterra
n = 200;
T = 20;
N = [3,5,7,9,11];
x0 = [10,5];
r = [1.5, 1.5];
frac = 0.5;
op = 1;
p = struct();
p.alpha = 1.1;
p.beta = 0.4;
p.gamma = 0.4;
p.delta = 0.1;
fmodel = @(t, x, p) LotkaVolterraModel(t, x, p);
fdynamics = @(X, Y, p) LotkaVolterraDynamics(X, Y, p);
% test
running_time = zeros(1, length(N));
error_terminal = zeros(2, length(N));
t2 = linspace(0, T, 20000+1);
xt = RungeKutta9(fmodel, x0, t2, p);
for i = 1:length(N)
tic;
[xnT, n_decomp] = ASK_2D(fdynamics, p, n, T, N(i), x0, r, frac, op);
running_time(i) = toc;
error_terminal(:, i) = abs(xt(:, end) - xnT);
end
% display & store
model_name = 'LV';
format1 = '.mat';
format2 = '.png';
format3 = '.eps';
name1 = strcat('results\GaussLobatto\time_', model_name, '_N_', num2str(T));
name2 = strcat('results\GaussLobatto\error_', model_name, '_N_', num2str(T));
save(strcat(name1, format1), 'running_time');
save(strcat(name2, format1), 'error_terminal');
figure;
plot(N, running_time, 'o-', 'linewidth', 2, 'markersize', 10);
xlim([2, 12]);
xlabel('N', 'interpreter', 'latex', 'fontsize', 18);
ylabel('Running Time (s)', 'interpreter', 'latex', 'fontsize', 18);
set(gca, 'linewidth', 2);
set(gca, 'fontsize', 16);
saveas(gcf, strcat(name1, format2));
saveas(gcf, strcat(name1, format3));
NameArray = {'Marker'};
ValueArray = {'o'; 's'};
figure;
p = semilogy(N-1, error_terminal', '-', 'linewidth', 2, 'markersize', 10);
set(p, NameArray, ValueArray);
xlim([1, 11]);
xlabel('N', 'interpreter', 'latex', 'fontsize', 18);
yticks([10.^(-10:2:1)]);
ylim([1e-11, 1e0]);
ylabel('Error', 'interpreter', 'latex', 'fontsize', 18);
set(gca, 'linewidth', 2);
set(gca, 'fontsize', 16);
saveas(gcf, strcat(name2, format2));
saveas(gcf, strcat(name2, format3));
disp('Lotka-Volterrra model completed!');
%% Simple pendulum
clear;
n = 200;
T = 20;
N = [3,5,7,9,11];
x0 = [- pi/4, pi/6];
r = [pi/8, pi/12];
%r = [pi/8, pi/8];
frac = 0.2;
op = 1;
p = struct();
p.g = 9.8;
p.L = 9.8;
fmodel = @(t, x, p) SimplePendulum(t, x, p);
fdynamics = @(X, Y, p) SimplePendulumDynamics(X, Y, p);
% test
running_time = zeros(1, length(N));
error_terminal = zeros(2, length(N));
t2 = linspace(0, T, 20000+1);
xt = RungeKutta9(fmodel, x0, t2, p);
for i = 1:length(N)
tic;
[xnT, n_decomp] = ASK_2D(fdynamics, p, n, T, N(i), x0, r, frac, op);
running_time(i) = toc;
error_terminal(:, i) = abs(xt(:, end) - xnT);
end
% display & store
model_name = 'SP';
format1 = '.mat';
format2 = '.png';
format3 = '.eps';
name1 = strcat('results\GaussLobatto\time_', model_name, '_N_', num2str(T));
name2 = strcat('results\GaussLobatto\error_', model_name, '_N_', num2str(T));
save(strcat(name1, format1), 'running_time');
save(strcat(name2, format1), 'error_terminal');
figure;
plot(N, running_time, 'o-', 'linewidth', 2, 'markersize', 10);
xlim([2, 12]);
xlabel('N', 'interpreter', 'latex', 'fontsize', 18);
ylabel('Running Time (s)', 'interpreter', 'latex', 'fontsize', 18);
set(gca, 'linewidth', 2);
set(gca, 'fontsize', 16);
saveas(gcf, strcat(name1, format2));
saveas(gcf, strcat(name1, format3));
NameArray = {'Marker'};
ValueArray = {'o'; 's'};
figure;
p = semilogy(N-1, error_terminal', '-', 'linewidth', 2, 'markersize', 10);
set(p, NameArray, ValueArray);
xlim([1, 11]);
xlabel('N', 'interpreter', 'latex', 'fontsize', 18);
yticks([10.^(-14:2:1)]);
ylim([1e-15, 1e0]);
ylabel('Error', 'interpreter', 'latex', 'fontsize', 18);
set(gca, 'linewidth', 2);
set(gca, 'fontsize', 16);
saveas(gcf, strcat(name2, format2));
saveas(gcf, strcat(name2, format3));
disp('Simple pendulum model completed!');
%% Limit Cycle
clear;
n = 200;
T = 20;
N = [3,5,7,9,11];
x0 = [sqrt(2)/2, -sqrt(2)/2];
r = [sqrt(2)/6, sqrt(2)/6];
frac = 0.2;
op = 1;
p = struct();
p.k = 1;
fmodel = @(t, x, p) LimitCycle(t, x, p);
fdynamics = @(X, Y, p) LimitCycleDynamics(X, Y, p);
% test
running_time = zeros(1, length(N));
error_terminal = zeros(2, length(N));
xtT = solve_limit_cycle(T, x0, p)'; %closed-form
for i = 1:length(N)
tic;
[xnT, n_decomp] = ASK_2D(fdynamics, p, n, T, N(i), x0, r, frac, op);
running_time(i) = toc;
error_terminal(:, i) = abs(xtT - xnT);
end
% display & store
model_name = 'LC';
format1 = '.mat';
format2 = '.png';
format3 = '.eps';
name1 = strcat('results\GaussLobatto\time_', model_name, '_N_', num2str(T));
name2 = strcat('results\GaussLobatto\error_', model_name, '_N_', num2str(T));
save(strcat(name1, format1), 'running_time');
save(strcat(name2, format1), 'error_terminal');
figure;
plot(N, running_time, 'o-', 'linewidth', 2, 'markersize', 10);
xlim([2, 12]);
xlabel('N', 'interpreter', 'latex', 'fontsize', 18);
ylabel('Running Time (s)', 'interpreter', 'latex', 'fontsize', 18);
set(gca, 'linewidth', 2);
set(gca, 'fontsize', 16);
saveas(gcf, strcat(name1, format2));
saveas(gcf, strcat(name1, format3));
NameArray = {'Marker'};
ValueArray = {'o'; 's'};
figure;
p = semilogy(N-1, error_terminal', '-', 'linewidth', 2, 'markersize', 10);
set(p, NameArray, ValueArray);
xlim([1, 11]);
xlabel('N', 'interpreter', 'latex', 'fontsize', 18);
yticks([10.^(-10:2:-2)]);
ylim([1e-10, 1e-2]);
ylabel('Error', 'interpreter', 'latex', 'fontsize', 18);
set(gca, 'linewidth', 2);
set(gca, 'fontsize', 16);
saveas(gcf, strcat(name2, format2));
saveas(gcf, strcat(name2, format3));
disp('Limit cycle model completed!');
没有合适的资源?快使用搜索试试~ 我知道了~
自适应谱Koopman matlab代码.zip
共160个文件
m:160个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 13 浏览量
2024-03-24
21:39:05
上传
评论
收藏 145KB ZIP 举报
温馨提示
1.版本:matlab2014/2019a/2021a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 5.作者介绍:某大厂资深算法工程师,从事Matlab算法仿真工作10年;擅长智能优化算法、神经网络预测、信号处理、元胞自动机等多种领域的算法仿真实验,更多仿真源码、数据集定制私信+。
资源推荐
资源详情
资源评论
收起资源包目录
自适应谱Koopman matlab代码.zip (160个子文件)
test_GaussLobatto.m 7KB
test_CheckPoints.m 7KB
test_Radius.m 7KB
sol_KO.m 7KB
sol_Lorenz.m 7KB
sol_SimplePendulum.m 5KB
sol_LimitCycle.m 5KB
test_GaussLobatto.m 5KB
test_Radius.m 5KB
test_CheckPoints.m 5KB
sol_Lorenz.m 5KB
ASK_Full_3D.m 5KB
ASK_Full_3D.m 5KB
ASK_Full_2D.m 4KB
ASK_Full_2D.m 4KB
test_GaussLobatto.m 4KB
test_Radius.m 4KB
test_CheckPoints.m 4KB
sol_LimitCycle.m 4KB
test_Efficiency_time_KO.m 3KB
test_Efficiency_time_SP.m 3KB
test_Efficiency_KO.m 3KB
ASK_3D.m 3KB
ASK_3D.m 3KB
test_Efficiency_SP_updated.m 3KB
ASK_2D.m 3KB
ASK_2D.m 3KB
test_Efficiency_time.m 3KB
ASK_1D.m 3KB
test_Efficiency_updated.m 3KB
RungeKutta9.m 3KB
RungeKutta9.m 3KB
RungeKutta9.m 3KB
RungeKutta9.m 3KB
RungeKutta9.m 3KB
test_Efficiency_SM.m 2KB
test_Efficiency_SP.m 2KB
test_Efficiency_LC.m 2KB
trial.m 2KB
test_Efficiency.m 2KB
AdamsBashforth5.m 2KB
AdamsMoulton4.m 2KB
AdamsMoulton4.m 2KB
AdamsMoulton4.m 2KB
AdamsMoulton4.m 2KB
RungeKutta8.m 2KB
RungeKutta8.m 2KB
RungeKutta8.m 2KB
RungeKutta8.m 2KB
RungeKutta8.m 2KB
AdamsBashforth5.m 1KB
AdamsBashforth5.m 1KB
AdamsBashforth5.m 1KB
AdamsMoulton4.m 1KB
legendreDiff.m 1KB
legendreDiff.m 1KB
legendreDiff.m 1KB
legendreDiff.m 1KB
legendreDiff.m 1KB
approximate_Koopman_3D.m 1KB
approximate_Koopman_3D.m 1KB
approximate_Koopman_3D.m 1KB
AdamsBashforth5.m 1KB
numerical_solve_3D.m 999B
numerical_solve_3D.m 999B
numerical_solve_3D.m 999B
compute_diffMat_3D.m 998B
compute_diffMat_3D.m 998B
compute_diffMat_3D.m 998B
approximate_Koopman_2D.m 925B
approximate_Koopman_2D.m 925B
approximate_Koopman_2D.m 925B
rescale_diffMat_3D.m 918B
rescale_diffMat_3D.m 918B
rescale_diffMat_3D.m 918B
compute_diffMat_2D.m 880B
compute_diffMat_2D.m 880B
compute_diffMat_2D.m 880B
numerical_solve_2D.m 879B
numerical_solve_2D.m 879B
numerical_solve_2D.m 878B
rescale_diffMat_2D.m 779B
rescale_diffMat_2D.m 779B
rescale_diffMat_2D.m 779B
numerical_solve_1D.m 723B
compute_coef_3D.m 686B
compute_coef_3D.m 686B
compute_coef_3D.m 686B
chebyshevDiff.m 671B
chebyshevDiff.m 671B
chebyshevDiff.m 671B
chebyshevDiff.m 671B
chebyshevDiff.m 671B
compute_diffMat_1D.m 662B
RungeKutta4.m 619B
RungeKutta4.m 619B
RungeKutta4.m 619B
RungeKutta4.m 619B
RungeKutta4.m 619B
approximate_Koopman_1D.m 616B
共 160 条
- 1
- 2
资源评论
Matlab科研辅导帮
- 粉丝: 2w+
- 资源: 7553
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功