Solving PDE with Euler implicit method

16 vues (au cours des 30 derniers jours)
Irit Amelchenko
Irit Amelchenko le 27 Déc 2018
I want to solve the Swift Hohenberg equation for homogenous solution, using the Euler method.
This is the function I have for the Euler method:
function [U] = Euler(f,y,dt,tmax)
% func - is a function handle
% dt - the steps
% tmax - the maximal time
% y - the first guess
% parameters:
q = 1;
b = 1.8;
r = 1;
f= @(u) r*u - u.^3 + b*u.^2 - q.^4*u; % Swift Hohenberg equation
y = -1:0.1:1; %initial guess
dt = 0.1;
tmax = 10;
t = 0:dt:tmax;
n = length(t);
U = zeros(length(y),n);
U(:,1) = y;
U_old = y(:);
for i=1:length(t)-1
U_new = U_old+dt.*f(t(i),U_old);
U(:,i+1)=U_new;
U_old=U_new;
end
end
I'm not sure about the initial guess I have.
I really don't know what to do from here. Any help would be appriciated.

Réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by