%% Tilting of the dipoles
% Atom Number Density   = 1250 ppum
% System size           = [5 * l_rot, 5 * l_rot]

theta_values  = 0:1:7;

%% v_z = 500

as_values_500  = [76.408020791433103, 76.408020791433103, 76.538777583310534, 76.538777583310534, 76.538777583310534, 76.538777583310534, 76.669534375187951, 76.669534375187951];
num_iterations = length(theta_values);

for i = 1:num_iterations
    OptionsStruct = struct;

    OptionsStruct.NumberOfAtoms           = 101250;     
    OptionsStruct.DipolarPolarAngle       = deg2rad(theta_values(i));
    OptionsStruct.DipolarAzimuthAngle     = 0;
    OptionsStruct.ScatteringLength        = as_values_500(i);        

    OptionsStruct.TrapFrequencies         = [0, 0, 500];
    OptionsStruct.TrapPotentialType       = 'None';

    OptionsStruct.NumberOfGridPoints      = [128, 128];
    OptionsStruct.Dimensions              = [9, 9];      
    OptionsStruct.TimeStepSize            = 0.005;           % in s
    OptionsStruct.MinimumTimeStepSize     = 1E-5;            % in s
    OptionsStruct.TimeCutOff              = 2E6;             % in s
    OptionsStruct.EnergyTolerance         = 5E-10;
    OptionsStruct.ResidualTolerance       = 1E-05;
    OptionsStruct.NoiseScaleFactor        = 0.05;

    OptionsStruct.MaxIterations           = 10;      
    OptionsStruct.VariationalWidth        = 1.2;       
    OptionsStruct.WidthLowerBound         = 0.01;
    OptionsStruct.WidthUpperBound         = 12;
    OptionsStruct.WidthCutoff             = 5e-3;

    OptionsStruct.PlotLive                = false;
    OptionsStruct.JobNumber               = i-1; % Assign a unique JobNumber per iteration
    OptionsStruct.RunOnGPU                = true;
    OptionsStruct.SaveData                = true;
    OptionsStruct.SaveDirectory           = './Results/Data_TiltingOfDipoles/TransitionAngle/Hz500';

    options = Helper.convertstruct2cell(OptionsStruct);
    clear OptionsStruct

    solver = VariationalSolver2D.DipolarGas(options{:});
    pot = VariationalSolver2D.Potentials(options{:});
    solver.Potential = pot.trap();

    % Run Solver
    [Params, Transf, psi, V, VDk] = solver.run();
end

%% v_z = 750

as_values_750  = [70.523965156949174, 70.523965156949174, 70.523965156949174, 70.523965156949174, 70.523965156949174, 70.654721948826605, 70.654721948826605, 70.785478740704022];
num_iterations = length(theta_values);

for i = 1:num_iterations
    OptionsStruct = struct;

    OptionsStruct.NumberOfAtoms           = 61250;     
    OptionsStruct.DipolarPolarAngle       = deg2rad(theta_values(i));
    OptionsStruct.DipolarAzimuthAngle     = 0;
    OptionsStruct.ScatteringLength        = as_values_750(i);        

    OptionsStruct.TrapFrequencies         = [0, 0, 750];
    OptionsStruct.TrapPotentialType       = 'None';

    OptionsStruct.NumberOfGridPoints      = [128, 128];
    OptionsStruct.Dimensions              = [7, 7];      
    OptionsStruct.TimeStepSize            = 0.005;           % in s
    OptionsStruct.MinimumTimeStepSize     = 1E-5;            % in s
    OptionsStruct.TimeCutOff              = 2E6;             % in s
    OptionsStruct.EnergyTolerance         = 5E-10;
    OptionsStruct.ResidualTolerance       = 1E-05;
    OptionsStruct.NoiseScaleFactor        = 0.05;

    OptionsStruct.MaxIterations           = 10;      
    OptionsStruct.VariationalWidth        = 0.85;       
    OptionsStruct.WidthLowerBound         = 0.01;
    OptionsStruct.WidthUpperBound         = 12;
    OptionsStruct.WidthCutoff             = 5e-3;

    OptionsStruct.PlotLive                = false;
    OptionsStruct.JobNumber               = i-1; % Assign a unique JobNumber per iteration
    OptionsStruct.RunOnGPU                = true;
    OptionsStruct.SaveData                = true;
    OptionsStruct.SaveDirectory           = './Results/Data_TiltingOfDipoles/TransitionAngle/Hz750';

    options = Helper.convertstruct2cell(OptionsStruct);
    clear OptionsStruct

    solver = VariationalSolver2D.DipolarGas(options{:});
    pot = VariationalSolver2D.Potentials(options{:});
    solver.Potential = pot.trap();

    % Run Solver
    [Params, Transf, psi, V, VDk] = solver.run();
end

%% v_z = 1000

as_values_1000  = [65.947477441239442, 65.947477441239442, 65.947477441239442, 65.947477441239442, 66.078234233116873, 66.078234233116873, 66.078234233116873, 66.208991024994290];
num_iterations = length(theta_values);

for i = 1:num_iterations
    OptionsStruct = struct;

    OptionsStruct.NumberOfAtoms           = 45000;     
    OptionsStruct.DipolarPolarAngle       = deg2rad(theta_values(i));
    OptionsStruct.DipolarAzimuthAngle     = 0;
    OptionsStruct.ScatteringLength        = as_values_1000(i);        

    OptionsStruct.TrapFrequencies         = [0, 0, 1000];
    OptionsStruct.TrapPotentialType       = 'None';

    OptionsStruct.NumberOfGridPoints      = [128, 128];
    OptionsStruct.Dimensions              = [6, 6];      
    OptionsStruct.TimeStepSize            = 0.005;           % in s
    OptionsStruct.MinimumTimeStepSize     = 1E-5;            % in s
    OptionsStruct.TimeCutOff              = 2E6;             % in s
    OptionsStruct.EnergyTolerance         = 5E-10;
    OptionsStruct.ResidualTolerance       = 1E-05;
    OptionsStruct.NoiseScaleFactor        = 0.05;

    OptionsStruct.MaxIterations           = 10;      
    OptionsStruct.VariationalWidth        = 0.7;       
    OptionsStruct.WidthLowerBound         = 0.01;
    OptionsStruct.WidthUpperBound         = 12;
    OptionsStruct.WidthCutoff             = 5e-3;

    OptionsStruct.PlotLive                = false;
    OptionsStruct.JobNumber               = i-1; % Assign a unique JobNumber per iteration
    OptionsStruct.RunOnGPU                = true;
    OptionsStruct.SaveData                = true;
    OptionsStruct.SaveDirectory           = './Results/Data_TiltingOfDipoles/TransitionAngle/Hz1000';

    options = Helper.convertstruct2cell(OptionsStruct);
    clear OptionsStruct

    solver = VariationalSolver2D.DipolarGas(options{:});
    pot = VariationalSolver2D.Potentials(options{:});
    solver.Potential = pot.trap();

    % Run Solver
    [Params, Transf, psi, V, VDk] = solver.run();
end

%% v_z = 2000

as_values_2000  = [53.917852588516730, 53.917852588516730, 53.917852588516730, 54.048609380394161, 54.048609380394161, 54.048609380394161, 54.179366172271585, 54.310122964149002];
num_iterations = length(theta_values);

for i = 1:num_iterations
    OptionsStruct = struct;

    OptionsStruct.NumberOfAtoms           = 31250;     
    OptionsStruct.DipolarPolarAngle       = deg2rad(theta_values(i));
    OptionsStruct.DipolarAzimuthAngle     = 0;
    OptionsStruct.ScatteringLength        = as_values_2000(i);        

    OptionsStruct.TrapFrequencies         = [0, 0, 2000];
    OptionsStruct.TrapPotentialType       = 'None';

    OptionsStruct.NumberOfGridPoints      = [128, 128];
    OptionsStruct.Dimensions              = [5, 5];      
    OptionsStruct.TimeStepSize            = 0.005;           % in s
    OptionsStruct.MinimumTimeStepSize     = 1E-5;            % in s
    OptionsStruct.TimeCutOff              = 2E6;             % in s
    OptionsStruct.EnergyTolerance         = 5E-10;
    OptionsStruct.ResidualTolerance       = 1E-05;
    OptionsStruct.NoiseScaleFactor        = 0.05;

    OptionsStruct.MaxIterations           = 10;      
    OptionsStruct.VariationalWidth        = 0.5;       
    OptionsStruct.WidthLowerBound         = 0.01;
    OptionsStruct.WidthUpperBound         = 12;
    OptionsStruct.WidthCutoff             = 5e-3;

    OptionsStruct.PlotLive                = false;
    OptionsStruct.JobNumber               = i-1; % Assign a unique JobNumber per iteration
    OptionsStruct.RunOnGPU                = true;
    OptionsStruct.SaveData                = true;
    OptionsStruct.SaveDirectory           = './Results/Data_TiltingOfDipoles/TransitionAngle/Hz2000';

    options = Helper.convertstruct2cell(OptionsStruct);
    clear OptionsStruct

    solver = VariationalSolver2D.DipolarGas(options{:});
    pot = VariationalSolver2D.Potentials(options{:});
    solver.Potential = pot.trap();

    % Run Solver
    [Params, Transf, psi, V, VDk] = solver.run();
end

%% Tilting of the dipoles
% Atom Number      = 1250 ppum
% System size      = [5 * l_rot, 5 * l_rot]

theta_values  = 8:1:15;

%% v_z = 500

as_values_500  = [76.800291167065367,  76.800291167065367,  76.931047958942784,  77.061804750820215,  77.061804750820215,  77.192561542697632,  77.323318334575049,  77.454075126452480];
num_iterations = length(theta_values);

for i = 1:num_iterations
    OptionsStruct = struct;

    OptionsStruct.NumberOfAtoms           = 101250;     
    OptionsStruct.DipolarPolarAngle       = deg2rad(theta_values(i));
    OptionsStruct.DipolarAzimuthAngle     = 0;
    OptionsStruct.ScatteringLength        = as_values_500(i);        

    OptionsStruct.TrapFrequencies         = [0, 0, 500];
    OptionsStruct.TrapPotentialType       = 'None';

    OptionsStruct.NumberOfGridPoints      = [128, 128];
    OptionsStruct.Dimensions              = [9, 9];      
    OptionsStruct.TimeStepSize            = 0.005;           % in s
    OptionsStruct.MinimumTimeStepSize     = 1E-5;            % in s
    OptionsStruct.TimeCutOff              = 3E6;             % in s
    OptionsStruct.EnergyTolerance         = 5E-10;
    OptionsStruct.ResidualTolerance       = 1E-05;
    OptionsStruct.NoiseScaleFactor        = 0.05;

    OptionsStruct.MaxIterations           = 10;      
    OptionsStruct.VariationalWidth        = 1.2;       
    OptionsStruct.WidthLowerBound         = 0.01;
    OptionsStruct.WidthUpperBound         = 12;
    OptionsStruct.WidthCutoff             = 5e-3;

    OptionsStruct.PlotLive                = false;
    OptionsStruct.JobNumber               = i-1; % Assign a unique JobNumber per iteration
    OptionsStruct.RunOnGPU                = true;
    OptionsStruct.SaveData                = true;
    OptionsStruct.SaveDirectory           = './Results/Data_TiltingOfDipoles/TransitionAngle/Hz500';

    options = Helper.convertstruct2cell(OptionsStruct);
    clear OptionsStruct

    solver = VariationalSolver2D.DipolarGas(options{:});
    pot = VariationalSolver2D.Potentials(options{:});
    solver.Potential = pot.trap();

    % Run Solver
    [Params, Transf, psi, V, VDk] = solver.run();
end

%% v_z = 750

as_values_750  = [70.785478740704022,  70.916235532581439,  71.046992324458870,  71.046992324458870,  71.177749116336287, 71.308505908213704,  71.439262700091120,  71.700776283845968];
num_iterations = length(theta_values);

for i = 1:num_iterations
    OptionsStruct = struct;

    OptionsStruct.NumberOfAtoms           = 61250;     
    OptionsStruct.DipolarPolarAngle       = deg2rad(theta_values(i));
    OptionsStruct.DipolarAzimuthAngle     = 0;
    OptionsStruct.ScatteringLength        = as_values_750(i);        

    OptionsStruct.TrapFrequencies         = [0, 0, 750];
    OptionsStruct.TrapPotentialType       = 'None';

    OptionsStruct.NumberOfGridPoints      = [128, 128];
    OptionsStruct.Dimensions              = [7, 7];      
    OptionsStruct.TimeStepSize            = 0.005;           % in s
    OptionsStruct.MinimumTimeStepSize     = 1E-5;            % in s
    OptionsStruct.TimeCutOff              = 3E6;             % in s
    OptionsStruct.EnergyTolerance         = 5E-10;
    OptionsStruct.ResidualTolerance       = 1E-05;
    OptionsStruct.NoiseScaleFactor        = 0.05;

    OptionsStruct.MaxIterations           = 10;      
    OptionsStruct.VariationalWidth        = 0.85;       
    OptionsStruct.WidthLowerBound         = 0.01;
    OptionsStruct.WidthUpperBound         = 12;
    OptionsStruct.WidthCutoff             = 5e-3;

    OptionsStruct.PlotLive                = false;
    OptionsStruct.JobNumber               = i-1; % Assign a unique JobNumber per iteration
    OptionsStruct.RunOnGPU                = true;
    OptionsStruct.SaveData                = true;
    OptionsStruct.SaveDirectory           = './Results/Data_TiltingOfDipoles/TransitionAngle/Hz750';

    options = Helper.convertstruct2cell(OptionsStruct);
    clear OptionsStruct

    solver = VariationalSolver2D.DipolarGas(options{:});
    pot = VariationalSolver2D.Potentials(options{:});
    solver.Potential = pot.trap();

    % Run Solver
    [Params, Transf, psi, V, VDk] = solver.run();
end

%% v_z = 1000

as_values_1000  = [66.339747816871707,  66.339747816871707,  66.470504608749138,  66.601261400626555,  66.732018192503972,  66.862774984381389,  66.993531776258820,  67.255045360013654];
num_iterations = length(theta_values);

for i = 1:num_iterations
    OptionsStruct = struct;

    OptionsStruct.NumberOfAtoms           = 45000;     
    OptionsStruct.DipolarPolarAngle       = deg2rad(theta_values(i));
    OptionsStruct.DipolarAzimuthAngle     = 0;
    OptionsStruct.ScatteringLength        = as_values_1000(i);        

    OptionsStruct.TrapFrequencies         = [0, 0, 1000];
    OptionsStruct.TrapPotentialType       = 'None';

    OptionsStruct.NumberOfGridPoints      = [128, 128];
    OptionsStruct.Dimensions              = [6, 6];      
    OptionsStruct.TimeStepSize            = 0.005;           % in s
    OptionsStruct.MinimumTimeStepSize     = 1E-5;            % in s
    OptionsStruct.TimeCutOff              = 3E6;             % in s
    OptionsStruct.EnergyTolerance         = 5E-10;
    OptionsStruct.ResidualTolerance       = 1E-05;
    OptionsStruct.NoiseScaleFactor        = 0.05;

    OptionsStruct.MaxIterations           = 10;      
    OptionsStruct.VariationalWidth        = 0.7;       
    OptionsStruct.WidthLowerBound         = 0.01;
    OptionsStruct.WidthUpperBound         = 12;
    OptionsStruct.WidthCutoff             = 5e-3;

    OptionsStruct.PlotLive                = false;
    OptionsStruct.JobNumber               = i-1; % Assign a unique JobNumber per iteration
    OptionsStruct.RunOnGPU                = true;
    OptionsStruct.SaveData                = true;
    OptionsStruct.SaveDirectory           = './Results/Data_TiltingOfDipoles/TransitionAngle/Hz1000';

    options = Helper.convertstruct2cell(OptionsStruct);
    clear OptionsStruct

    solver = VariationalSolver2D.DipolarGas(options{:});
    pot = VariationalSolver2D.Potentials(options{:});
    solver.Potential = pot.trap();

    % Run Solver
    [Params, Transf, psi, V, VDk] = solver.run();
end

%% v_z = 2000

as_values_2000  = [54.310122964149002, 54.440879756026426,  54.571636547903843,  54.702393339781267,  54.963906923536108,  55.094663715413525,  55.225420507290949,  55.486934091045789];
num_iterations = length(theta_values);

for i = 1:num_iterations
    OptionsStruct = struct;

    OptionsStruct.NumberOfAtoms           = 31250;     
    OptionsStruct.DipolarPolarAngle       = deg2rad(theta_values(i));
    OptionsStruct.DipolarAzimuthAngle     = 0;
    OptionsStruct.ScatteringLength        = as_values_2000(i);        

    OptionsStruct.TrapFrequencies         = [0, 0, 2000];
    OptionsStruct.TrapPotentialType       = 'None';

    OptionsStruct.NumberOfGridPoints      = [128, 128];
    OptionsStruct.Dimensions              = [5, 5];      
    OptionsStruct.TimeStepSize            = 0.005;           % in s
    OptionsStruct.MinimumTimeStepSize     = 1E-5;            % in s
    OptionsStruct.TimeCutOff              = 3E6;             % in s
    OptionsStruct.EnergyTolerance         = 5E-10;
    OptionsStruct.ResidualTolerance       = 1E-05;
    OptionsStruct.NoiseScaleFactor        = 0.05;

    OptionsStruct.MaxIterations           = 10;      
    OptionsStruct.VariationalWidth        = 0.5;       
    OptionsStruct.WidthLowerBound         = 0.01;
    OptionsStruct.WidthUpperBound         = 12;
    OptionsStruct.WidthCutoff             = 5e-3;

    OptionsStruct.PlotLive                = false;
    OptionsStruct.JobNumber               = i-1; % Assign a unique JobNumber per iteration
    OptionsStruct.RunOnGPU                = true;
    OptionsStruct.SaveData                = true;
    OptionsStruct.SaveDirectory           = './Results/Data_TiltingOfDipoles/TransitionAngle/Hz2000';

    options = Helper.convertstruct2cell(OptionsStruct);
    clear OptionsStruct

    solver = VariationalSolver2D.DipolarGas(options{:});
    pot = VariationalSolver2D.Potentials(options{:});
    solver.Potential = pot.trap();

    % Run Solver
    [Params, Transf, psi, V, VDk] = solver.run();
end