Non-uniform grid

6 visualizaciones (últimos 30 días)
颯太 小濱
颯太 小濱 el 18 de En. de 2022
Comentada: John D'Errico el 9 de Mzo. de 2022
I have a question about unequal spacing.
In the code below, I would like to either increase the number of N to avoid running out of memory, or increase the number of grids only around i=2N to prevent the solution from diverging.
function brussode(N)
if nargin<1
N = 100;
end
tspan = [0; 10]; %時間変更可能
y0 = [repmat(0.9,1,N); repmat(321221,1,N)];
options = odeset('Vectorized','on');
[t,y] = ode15s(@f,tspan,y0,options);
u= y(:,1:2:end);
x = (1:N)/(N+1);
p=y(:,2:2:end);
assignin('base','s',u(end,:))
assignin('base','p',p(end,:))
function dydt = f(~,y)
a=0.0002/N;
b=3.15*10^-4;
c=2.4*10^-5;
d=300000;
e=1;
f=174284;
k=6.4*10^-14;
l=5;
dydt = zeros(2*N,size(y,2)); % preallocate dy/dt
i = 1;
dydt(i,:) = 1/2/a^2/b*((k*(y(i,:).^l+y(i+2,:).^l)).*((y(i+3,:)-y(i+1,:))+f*(1.417*(y(i+2,:)-y(i,:))-2.12*((1-y(i,:)).^2-(1-y(i+2,:)).^2)+1.263*((1-y(i,:)).^3-(1-y(i+2,:)).^3))).*y(i,:)-(k*(2* y(i,:).^l)).*((y(i+1,:)-d)+f*(1.417*(y(i,:)-e)-2.12*((1-e).^2-(1-y(i,:)).^2)+1.263*((1-e).^3-(1-y(i,:)).^3))).*y(i,:));
dydt(i+1,:) =1/2/a^2/c*((k*((1-y(i,:)).^l+(1-y(i+2,:)).^l).*(y(i+3,:)-y(i+1,:))).*y(i+3,:)-(2*k*((1-y(i,:)).^l).*(y(i+1,:)-d)).*y(i+1,:));
% Evaluate the 2 components of the function at all interior grid points.
i = 3:2:2*N-3;
dydt(i,:) = 1/2/a^2/b*((k*(y(i,:).^l+y(i+2,:).^l)).*((y(i+3,:)-y(i+1,:))+f*(1.417*(y(i+2,:)-y(i,:))-2.12*((1-y(i,:)).^2-(1-y(i+2,:)).^2)+1.263*((1-y(i,:)).^3-(1-y(i+2,:)).^3))).*y(i,:)-(k*(y(i-2,:).^l+y(i,:).^l)).*((y(i+1,:)-y(i-1,:))+f*(1.417*(y(i,:)-y(i-2,:))-2.12*((1-y(i-2,:)).^2-(1-y(i,:)).^2)+1.263*((1-y(i-2,:)).^3-(1-y(i,:)).^3))).*y(i-2,:));
dydt(i+1,:) =1/2/a^2/c*((k*((1-y(i,:)).^l+(1-y(i+2,:)).^l).*(y(i+3,:)-y(i+1,:))).*y(i+3,:)-(k*((1-y(i-2,:)).^l+(1-y(i,:)).^l).*(y(i+1,:)-y(i-1,:))).*y(i+1,:));
i = 2*N-1;
dydt(i,:) = 1/2/a^2/b*(-9.93*10^-6*a*b*2-(k*(y(i-2,:).^l+y(i,:).^l)).*((y(i+1,:)-y(i-1,:))+f*(1.417*(y(i,:)-y(i-2,:))-2.12*((1-y(i-2,:)).^2-(1-y(i,:)).^2)+1.263*((1-y(i-2,:)).^3-(1-y(i,:)).^3))).*y(i-2,:));
dydt(i+1,:) =1/2/a^2/c*(804./y(i,:) *a*c*2-(k*((1-y(i-2,:)).^l+(1-y(i,:)).^l)).*(y(i+1,:)-y(i-1,:)).*y(i+1,:));
end
end
Please let me know what I need to change to calculate under 300GB.
Thank you for your help.
  1 comentario
John D'Errico
John D'Errico el 9 de Mzo. de 2022
Why are you using a hack like assignin, instead of just returning the variables as arguments from the function?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by