Made changes to plotting functionality.

This commit is contained in:
Karthik 2024-06-18 17:30:55 +02:00
parent 4858e97a55
commit 89dde6f9c4
5 changed files with 142 additions and 84 deletions

View File

@ -1,31 +1,39 @@
set(0,'defaulttextInterpreter','latex') function makeMovie(run_index)
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex'); set(0,'defaulttextInterpreter','latex')
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');
RunIdx = 1; folder_path = './Data';
FileDir = dir(sprintf('./Data/Run_%03i/TimeEvolution/*.mat',RunIdx)); FileDir = dir(sprintf(horzcat(folder_path, '/Run_%03i/*.mat'),run_index));
NumFiles = numel(FileDir); NumFiles = numel(FileDir);
QuenchSettings = load(sprintf('./Data/Run_%03i/QuenchSettings',RunIdx),'Quench','Params','Transf','VDk','V');
Transf = QuenchSettings.Transf; Params = QuenchSettings.Params;
x = Transf.x; y = Transf.y; z = Transf.z;
dx = x(2)-x(1); dy = y(2)-y(1); dz = z(2)-z(1);
mkdir(sprintf('./Data/Run_%03i/Figures',RunIdx)) Data = load(sprintf(horzcat(folder_path, '/Run_%03i/psi_%i.mat'),run_index,1),'Params','Transf');
outputVideo = VideoWriter(fullfile('./Data/Movie.avi'));
outputVideo.FrameRate = 10;
open(outputVideo)
figure(1); Params = Data.Params;
x0 = 800; Transf = Data.Transf;
y0 = 200;
width = 800;
height = 600;
set(gcf,'position',[x0,y0,width,height])
EVecTemp = []; x = Transf.x; y = Transf.y; z = Transf.z;
dx = x(2)-x(1); dy = y(2)-y(1); dz = z(2)-z(1);
for ii = 2:(NumFiles-1) mkdir(sprintf(horzcat(folder_path, '/Run_%03i/Figures'),run_index))
load(sprintf('./Data/Run_%03i/TimeEvolution/psi_%i.mat',RunIdx,ii),'psi','muchem','T','Observ','t_idx'); outputVideo = VideoWriter(fullfile(horzcat(folder_path, '/Movie.avi')));
outputVideo.FrameRate = 10;
open(outputVideo)
figure(1);
x0 = 800;
y0 = 200;
width = 800;
height = 600;
set(gcf,'position',[x0,y0,width,height])
for ii = 1:(NumFiles-1)
Data = load(sprintf(horzcat(folder_path, '/Run_%03i/psi_%i.mat'),run_index,ii),'psi','muchem','T','Observ');
psi = Data.psi;
muchem = Data.muchem;
T = Data.T;
Observ = Data.Observ;
%Plotting %Plotting
subplot(2,3,1) subplot(2,3,1)
@ -65,13 +73,13 @@ for ii = 2:(NumFiles-1)
sgtitle(sprintf('$\\mu =%.3f \\hbar\\omega_0$, $T=%.1f$nK, $t=%.1f$ms',muchem,T,tVal)) sgtitle(sprintf('$\\mu =%.3f \\hbar\\omega_0$, $T=%.1f$nK, $t=%.1f$ms',muchem,T,tVal))
drawnow drawnow
saveas(gcf,sprintf('./Data/Run_%03i/Figures/Image_%i.jpg',RunIdx,ii)) saveas(gcf,sprintf(horzcat(folder_path, '/Run_%03i/Figures/Image_%i.jpg'),run_index,ii))
img = imread(sprintf('./Data/Run_%03i/Figures/Image_%i.jpg',RunIdx,ii)); img = imread(sprintf(horzcat(folder_path, '/Run_%03i/Figures/Image_%i.jpg'),run_index,ii));
writeVideo(outputVideo,img) writeVideo(outputVideo,img)
% hold off;
clf clf
end end
close(outputVideo) close(outputVideo)
close(figure(1)) close(figure(1))
delete(sprintf('./Data/Run_%03i/Figures/*.jpg',RunIdx)) % deleting images after movie is made delete(sprintf(horzcat(folder_path, '/Run_%03i/Figures/*.jpg'),run_index)) % deleting images after movie is made
end

View File

@ -1,4 +1,4 @@
function LPlot = LivePlot(psi,Params,Transf,Observ) function plotLive(psi,Params,Transf,Observ)
set(0,'defaulttextInterpreter','latex') set(0,'defaulttextInterpreter','latex')
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex'); set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');
@ -6,8 +6,6 @@ function LPlot = LivePlot(psi,Params,Transf,Observ)
x = Transf.x*Params.l0*1e6; x = Transf.x*Params.l0*1e6;
y = Transf.y*Params.l0*1e6; y = Transf.y*Params.l0*1e6;
z = Transf.z*Params.l0*1e6; z = Transf.z*Params.l0*1e6;
%percentcomplete = linspace(0,1,Params.cut_off/200);
dx = x(2)-x(1); dy = y(2)-y(1); dz = z(2)-z(1); dx = x(2)-x(1); dy = y(2)-y(1); dz = z(2)-z(1);
%Plotting %Plotting
@ -43,5 +41,4 @@ function LPlot = LivePlot(psi,Params,Transf,Observ)
subplot(2,3,6) subplot(2,3,6)
plot(Observ.mucVec,'-b') plot(Observ.mucVec,'-b')
ylabel('$\mu$'); xlabel('steps'); ylabel('$\mu$'); xlabel('steps');
% xlim([0,1]); ylim([0,8]); end
% xlim([0,1]); ylim([0,8]);

View File

@ -0,0 +1,53 @@
function visualizeGSWavefunction(run_index)
set(0,'defaulttextInterpreter','latex')
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');
folder_path = './Data';
Data = load(sprintf(horzcat(folder_path, '/Run_%03i/psi_gs.mat'),run_index),'psi','Params','Transf','Observ');
psi = Data.psi;
Params = Data.Params;
Transf = Data.Transf;
Observ = Data.Observ;
format long
x = Transf.x*Params.l0*1e6;
y = Transf.y*Params.l0*1e6;
z = Transf.z*Params.l0*1e6;
dx = x(2)-x(1); dy = y(2)-y(1); dz = z(2)-z(1);
%Plotting
subplot(2,3,1)
n = abs(psi).^2;
nxz = squeeze(trapz(n*dy,2));
nyz = squeeze(trapz(n*dx,1));
nxy = squeeze(trapz(n*dz,3));
plotxz = pcolor(x,z,nxz');
set(plotxz, 'EdgeColor', 'none');
xlabel('$x$ [$\mu$m]'); ylabel('$z$ [$\mu$m]');
subplot(2,3,2)
plotyz = pcolor(y,z,nyz');
set(plotyz, 'EdgeColor', 'none');
xlabel('$y$ [$\mu$m]'); ylabel('$z$ [$\mu$m]');
subplot(2,3,3)
plotxy = pcolor(x,y,nxy');
set(plotxy, 'EdgeColor', 'none');
xlabel('$x$ [$\mu$m]'); ylabel('$y$ [$\mu$m]');
subplot(2,3,4)
plot(-log10(Observ.residual),'-b')
ylabel('$-\mathrm{log}_{10}(r)$'); xlabel('steps');
subplot(2,3,5)
plot(Observ.EVec,'-b')
ylabel('$E$'); xlabel('steps');
subplot(2,3,6)
plot(Observ.mucVec,'-b')
ylabel('$\mu$'); xlabel('steps');
end

View File

@ -11,20 +11,20 @@ OptionsStruct.DipolarPolarAngle = pi/2;
OptionsStruct.DipolarAzimuthAngle = 0; OptionsStruct.DipolarAzimuthAngle = 0;
OptionsStruct.ScatteringLength = 86; OptionsStruct.ScatteringLength = 86;
OptionsStruct.TrapFrequencies = [125, 125, 250]; OptionsStruct.TrapFrequencies = [50, 10, 150];
OptionsStruct.TrapDepth = 5; OptionsStruct.TrapDepth = 5;
OptionsStruct.BoxSize = 15; OptionsStruct.BoxSize = 15;
OptionsStruct.TrapPotentialType = 'Harmonic'; OptionsStruct.TrapPotentialType = 'Harmonic';
OptionsStruct.NumberOfGridPoints = [64, 64, 48]; OptionsStruct.NumberOfGridPoints = [64, 32, 64];
OptionsStruct.Dimensions = [40, 40, 20]; OptionsStruct.Dimensions = [20, 40, 80];
OptionsStruct.CutoffType = 'Cylindrical'; OptionsStruct.CutoffType = 'Cylindrical';
OptionsStruct.SimulationMode = 'ImaginaryTimeEvolution'; % 'ImaginaryTimeEvolution' | 'RealTimeEvolution' OptionsStruct.SimulationMode = 'ImaginaryTimeEvolution'; % 'ImaginaryTimeEvolution' | 'RealTimeEvolution'
OptionsStruct.TimeStepSize = 50E-6; % in s OptionsStruct.TimeStepSize = 50E-6; % in s
OptionsStruct.NumberOfTimeSteps = 100; % in s OptionsStruct.NumberOfTimeSteps = 100; % in s
OptionsStruct.EnergyTolerance = 5E-10; OptionsStruct.EnergyTolerance = 5E-10;
OptionsStruct.JobNumber = 6; OptionsStruct.JobNumber = 1;
OptionsStruct.SaveData = true; OptionsStruct.SaveData = true;
OptionsStruct.SaveDirectory = './Data'; OptionsStruct.SaveDirectory = './Data';
options = Helper.convertstruct2cell(OptionsStruct); options = Helper.convertstruct2cell(OptionsStruct);

View File

@ -16,7 +16,7 @@ OptionsStruct.TrapDepth = 5;
OptionsStruct.BoxSize = 15; OptionsStruct.BoxSize = 15;
OptionsStruct.TrapPotentialType = 'Harmonic'; OptionsStruct.TrapPotentialType = 'Harmonic';
OptionsStruct.NumberOfGridPoints = [256, 512, 256]; OptionsStruct.NumberOfGridPoints = [128, 256, 128];
OptionsStruct.Dimensions = [50, 120, 150]; OptionsStruct.Dimensions = [50, 120, 150];
OptionsStruct.CutoffType = 'Cylindrical'; OptionsStruct.CutoffType = 'Cylindrical';
OptionsStruct.SimulationMode = 'ImaginaryTimeEvolution'; % 'ImaginaryTimeEvolution' | 'RealTimeEvolution' OptionsStruct.SimulationMode = 'ImaginaryTimeEvolution'; % 'ImaginaryTimeEvolution' | 'RealTimeEvolution'