Hi verybody, I wish I have plot a figure using a part of data avaible.

1 view (last 30 days)
I am solving a nonlinear equation with a MATLAB code using the split-step fourier method. I wish I plot a 3D figure where the spatial extent of the grid is [-150 150], but the solution is computed on the spatial extent [-256000 255000] but I am unable. Here is my code: clear all; close all; clc;
g1D=0.; chi=1; epsi=0.2; omega=0.001; alp = 3/1280; epsiz=1;
V10=1; sigma = 1.47; L1 = 10*sigma; % external trapping potential parameters
beta2 = 1; gamma = 1; epsi = 0.50000e-012; P0 = 1;
L= 41; % Longueur de la fibre (dns NLSE duree max de propagation Lstep = 0.05e3; % pas arbitraire
fmax=0.001; % frequence maxi observable dx = 1/fmax; % pas temporelle n = 1; T0 = 0; while T0 < 500*dx % d?nition de la fenetre temporelle n = n+1; nt= 2^n; % nombre de points sur l'axe des temps
T0 = dx*(2^n);
end
df = 1/T0; % pas en fr?ence dw = 2*pi*df; % pas en pulsation n1 = nt/2; % definition de l'axe des temps n2 = n1-1; N1 = n1 + n2 + 1; x = (-n1:n2)*1*dx; % axe des espaces dans NLSE, pts espacés de dx de -n1*dx à (n1-1)*dx
% dénition de l'axe des temps
w = (-n1:n2)*dw; %definition de l'axe des pulsations, dns NLSE, w= nbre d'onde f = w/(2*pi); %definition de l'axe des pulsations w2 = w.*w;
%%%% CHAMP INITIAL dénition de l'onde continue initiale: solution stationnaire mu = 2.8; c0 = 0; K = 1/12; delta = g1D^2-4*chi*(V10-mu); u0 = sqrt((-g1D+sqrt(delta))/(2*chi)); Vg = u0*sqrt(g1D+2*chi*u0^2);
b1 = 3/4+chi*u0^4/Vg^2; b2 = 1/(8*Vg); c11 = -6*b2*K/b1; d11 = 0; beta1 = -4*b2*K^3; X = x-Vg*0; eta1 = c0+c11*tanh(K*X-beta1*0); eta1X = c11*(1-tanh(K*X-beta1*0).^2)*K; U0 = u0*(1+eta1X/(2*Vg)).*exp(1i*(-mu*0+eta1))+10^-5*(rand(1,N1)-0.5);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% External field
Pot=V10*(exp(-(x+L1/2).^2/sigma^2)+exp(-(x-L1/2).^2/sigma^2)); % est donné pour tous les xi car x est 1 vect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
V0 = fftshift(ifft(U0)); % Transformee de Fourier la transformee inverse est utilise coe transf directe est 1 vect qui fourier trans en tous les xi % V0p = fftshift(ifft(U0p)); % V est un vect de dim dim(x) % V0pp = fftshift(ifft(U0pp));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t = 0; % a t =0 on va initialiser U, t est le temps dns NLSE U = U0; % initialisation de U
V = V0; % initialisation de V %%%% PAS D'INTEGRATION SUIVANT Z (dns NLSE Z est plutot t)
L_NL = 1/(gamma*P0); % longueur nonlin?re % in O.F L_D = T0^2/abs(beta2); % longueur dispersion % in O.F Lmin = min([L_NL L_D Lstep]); dt = Lmin/500; %(pas temporel dns NLSEà % pas suivant z in F.O1
npt = round(L/dt); G = []; % gain numerically GdB = []; % gain numerically ZZ = []; PP0 = [];
DISP =exp(-1i*0.5*dt*w.^2); %terme dans l'espace spectral (integrale de la part dispersive)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TabU = []; TabUmax = []; %initialisation des grandeurs à représenter
TabV = [];
TabG = []; %NUMerical checking of gain
Tabt = []; Tabx = [];
nplot=50; npt1=npt/nplot; %nplot est le nbre de courbes npt1 est l'espace entre les courbes
for k = 1:nplot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for I = 1:npt1
P = (abs(U)).^2; %P module de psi au carré
SPM=Pot+P*g1D+chi*P.^2; % /lamda terme de nonlinéarité + potentiel(espace reel des x)
U = U.*exp(-1i*dt*SPM); %soltion de la part nonlin, produit solution initial+terme de
V = fftshift(ifft(U)); % ifft(U) est la FFT (passage dns l'esp spectrale de la solution
V = V.*DISP; % produit des solutions des part nonlin et lin dns l'esp spectral
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
U = fft(fftshift(V)); % fft est la IFFT (solution num dns l'esp reel)
Umax=max(U);
t=t+dt;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TabU = [TabU; (abs(U)).^2]; % dans TabU on met valeur absolue de U solution espace reel
TabV = [TabV; abs(V)]; % solution espace spectral
TabUmax = [TabUmax; abs(Umax)];
Tabt = [Tabt; ones(1,nt)*t]; % sauvergarde du temps
Tabx=[Tabx; x.*ones(1,nt)]; % alp = half_spatial_extension/(nt*dx)
end
figure(1) mesh(Tabx,Tabt,TabU) grid off colorbar view(0,90) xlabel('x', 'fontsize', 30) % , 'fontsize', 30 ylabel('t') zlabel('|\Psi(x,t)|^2', 'fontsize', 30)
figure(2) plot(Tabx,TabU(10,:), 'red', 'LineStyle', ':', 'LineWidth',6); xlabel('x', 'fontsize', 30) ylabel('|\Psi(x,t=10)|^2', 'fontsize', 30)
One should notice that the code gives a figure (the one of figure(1)) on the spatial extent [-256000 255000], but the solution width is too tiny because its width is 12. That's why I need to represent on the spatial extent [-150 150] in order to have a correct view of the solution. Thank you for your help.
  1 Comment
Image Analyst
Image Analyst on 11 Mar 2015
Either read this : formatting code
or else just attach your m-file with the paper clip icon. The post is unreadable as is.

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!