Info

This question is closed. Reopen it to edit or answer.

solving non linear schordinger equation on matlab

1 view (last 30 days)
Hi! im trying to solve non linear schordinger equation on matlab
this is my code:
epsilon=1;g=1;
m = 0;
x = linspace(0,1,20);
t = linspace(0,2,5);
sol = pdepe(m,@pde,@ic,@bc,x,t);
% --------------------------------------------------------------------------
function [c,f,s] = pde(x,t,u,DuDx,epsilon)
g=1;
alpha=0.05;
c =i;
f = -0.5*DuDx;
s = (-g*abs(u)^2+epsilon*exp(-x.^2/alpha^2)/(sqrt(pi)*alpha))*u;
% --------------------------------------------------------------------------
function u0 = ic(x)
a=3;
b=0.01;
c=-1.2;
mu=2.997
u0 =exp(-i*mu*t)*( a*cos(pi*x)+b*sin(pi*x)+c*cos(3*pi*x));
% --------------------------------------------------------------------------
function [pl,ql,pr,qr] = bc(xl,ul,xr,ur,t)
pl = ul;
ql = 0;
pr = ur;
qr = 0;
I have couple of problems:
1. the function pde: matlab doesn't allow c=i because i is imaginary. what should I do? the same issue for the function ic.
2. I want sol to get epsilon in its arguments. I mean that in pdepe , @pde should have epsilon in its arguments.i.e @pde(x,t,u,DuDx,epsilon). . I know I should do it with matlab handles but didnt succeed.
I would appriciate any help. thanks a lot !

Answers (0)

Community Treasure Hunt

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

Start Hunting!