Solving PDE with Euler implicit method

조회 수: 16 (최근 30일)
Irit Amelchenko
Irit Amelchenko 2018년 12월 27일
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.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by