Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Evolve the ground state of the harmonic oscillator using GPELab
%% Setting the method and geometry
Computation = 'Dynamic';
Ncomponents = 1;
Type = 'Relaxation';
Deltat = 1e-4;
Stop_time = 2;
Method = Method_Var2d(Computation,Ncomponents, Type, Deltat, Stop_time);
xmin = -7.07;
xmax = 7.07;
ymin = -7.07;
ymax = 7.07;
Nx = 2^8+1;
Ny = 2^8+1;
Geometry2D = Geometry2D_Var2d(xmin,xmax, ymin,ymax, Nx, Ny);
%% Setting the Hamiltonian
Delta = 0.5;
Beta = 0;
Omega = 0;
Physics2D = Physics2D_Var2d(Method,Delta,Beta);
Physics2D = Dispersion_Var2d(Method, Physics2D, @(fftx,ffty) Delta*(fftx.^2+ffty.^2));
Physics2D = Potential_Var2d(Method, Physics2D, @(x,y) (1/2)*(x.^2+y.^2));
Physics2D = Nonlinearity_Var2d(Method, Physics2D, @(phi,x,y) abs(phi).^2 );
Physics2D = Gradientx_Var2d(Method, Physics2D,@(x,y) 1i*Omega*y);
Physics2D = Gradienty_Var2d(Method, Physics2D,@(x,y) -1i*Omega*x);
%% Setting the initial state
%w = 1;
%Normal = 0.5/pi;
%X = Geometry2D.X;
%Y = Geometry2D.Y;
%Phi_0 = sqrt(w * Normal) * exp(-(X^2 + Y^2) * 0.5 * w) * (1. + sqrt(2. * w) * X);
%% Setting gaussian initial state
InitialData_choice = 1;
Phi_0 = InitialData_Var2d(Method, Geometry2D, Physics2D,InitialData_choice,0,0,1,1);
%% Set output structure
Evo = 1000;
Outputs = OutputsINI_Var2d(Method,Evo);
Printing = 1;
Draw = 0;
Print = Print_Var2d(Printing,Evo,Draw);
%% Launch evolution
[Phi,Outputs]= GPELab2d(Phi_0,Method,Geometry2D,Physics2D,Outputs,[],Print);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment