-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLFPSqm.m
50 lines (44 loc) · 1.71 KB
/
LFPSqm.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [val] = LFPSqm(p,q,W0,W1,deltat,m,hquer,gradV,grad3V,a,b,H,T)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function LFPSqm.m solves the Wigner function equation with a quartic
% symmetric double-well potential with a leap-frog pseudospectral scheme,
% writes data in a txt file, new data appended, at time steps dt*Nstep
% and displays normalization and energy expectation value at console
%
% p,q coordinates (vector)
% W0, W1 initial structures at t=-deltat, t=0 (array)
% deltat time step-size (constant)
% m mass (constant)
% hquer reduced plank constant (constant)
% gradV first derivative of potential (vector)
% grad3V third derivative of potential (vector)
% a length of interval in q direction (constant)
% b length of interval in p direction (constant)
% H hamiltonian function (array)
% T final point of time (constant)
% val structure at time T
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
PM = diag(-p/m);
GRADV= diag(gradV);
GRAD3V = diag(-grad3V/24);
tol = 10^-8;
val_m1 = W0;
val_0 = W1;
disp(' time normalization energy')
Nend = T/deltat; %number of iterations in time
Nstep=(Nend-1)/10;
for s = 1:Nstep:Nend
t = s*deltat; %time
%% LFPS scheme
val = val_m1 + ...
2*deltat*DNq(val_0,a)*PM + ... % -(p/m) d_q W
2*deltat*GRADV*DNp(val_0,b) + ... % +d_q H * d_p W
2*deltat*hquer^2*GRAD3V*DN3p(val_0,b); % - d_q^3 H * d_p^3 W / 24
val_m1 = val_0;
val_0 = val;
%% calculation of normalization, energy, saving data, new data appended
dlmwrite('structure2.txt',val, '-append');
fprintf(' %d %e %e \n',t,trapz(p,trapz(q,val)), trapz(p,trapz(q,val.*H)));
end
end