Revert "Merge branch 'main' of https://cau-git.rz.uni-kiel.de/nt/mitarbeiter/silas/imdd_simulation"
This reverts commit 798a0ca3b3
This commit is contained in:
@@ -1,72 +1,41 @@
|
||||
|
||||
function [opt_out_x,opt_out_y,state] = CNLSE_plain(opt_in_x,opt_in_y,state,useGPU,useSingle)
|
||||
function [opt_out_x,opt_out_y,state] = CNLSE_plain(opt_in_x,opt_in_y,state)
|
||||
|
||||
|
||||
% GPU auto-detection if not specified
|
||||
if nargin < 4 || isempty(useGPU)
|
||||
useGPU = canUseGPU();
|
||||
end
|
||||
if nargin < 5 || isempty(useSingle)
|
||||
useSingle = false;
|
||||
end
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% pre calculations
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% pre calculations
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
state.common_beta=struct('X',0,'Y',0);
|
||||
state.common_beta=struct('X',0,'Y',0);
|
||||
|
||||
for n=1:2
|
||||
% get current polarization name and contrary one
|
||||
curPol = state.polNames{n};
|
||||
for n=1:2
|
||||
% get current polarization name and contrary one
|
||||
curPol = state.polNames{n};
|
||||
|
||||
% extend linear transfer function depending on beta values for the current polarization
|
||||
% Was ist der Sinn dieser komischen beta notation? zB. state.beta.X = [0.3142 0 -9.1105e-28 5.1068e-41]
|
||||
for n_beta = 1:length(state.beta.(curPol))
|
||||
state.common_beta.(curPol) = state.common_beta.(curPol) + state.beta.(curPol)(n_beta) * (state.omega).^(n_beta-1) / factorial(n_beta-1);
|
||||
% extend linear transfer function depending on beta values for the current polarization
|
||||
% Was ist der Sinn dieser komischen beta notation? zB. state.beta.X = [0.3142 0 -9.1105e-28 5.1068e-41]
|
||||
for n_beta = 1:length(state.beta.(curPol))
|
||||
state.common_beta.(curPol) = state.common_beta.(curPol) + state.beta.(curPol)(n_beta) * (state.omega).^(n_beta-1) / factorial(n_beta-1);
|
||||
end
|
||||
|
||||
%opt_out_struct.(curPol)=opt_in_struct.(curPol).envelope;
|
||||
end
|
||||
|
||||
%opt_out_struct.(curPol)=opt_in_struct.(curPol).envelope;
|
||||
end
|
||||
beta_const = state.beta.('X')(1);
|
||||
beta_1 = state.beta.('X')(2);
|
||||
beta_2 = state.beta.('X')(3);
|
||||
beta_3 = state.beta.('X')(4);
|
||||
deltaomega = state.omega;
|
||||
beta_x = beta_const + beta_1 * deltaomega + 1/2 * beta_2 * deltaomega.^2 + 1/6 *beta_3 * deltaomega.^3;
|
||||
|
||||
% opt_in_x = gpuArray(opt_in_x);
|
||||
% opt_in_y = gpuArray(opt_in_y);
|
||||
|
||||
beta_const = state.beta.('X')(1);
|
||||
beta_1 = state.beta.('X')(2);
|
||||
beta_2 = state.beta.('X')(3);
|
||||
beta_3 = state.beta.('X')(4);
|
||||
deltaomega = state.omega;
|
||||
beta_x = beta_const + beta_1 * deltaomega + 1/2 * beta_2 * deltaomega.^2 + 1/6 *beta_3 * deltaomega.^3;
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% GPU Transfer (if enabled)
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
if useGPU
|
||||
% Convert to single precision if requested (faster on most GPUs)
|
||||
if useSingle
|
||||
opt_in_x = gpuArray(single(opt_in_x));
|
||||
opt_in_y = gpuArray(single(opt_in_y));
|
||||
state.common_beta.X = gpuArray(single(state.common_beta.X));
|
||||
state.common_beta.Y = gpuArray(single(state.common_beta.Y));
|
||||
state.brf.db1 = gpuArray(single(state.brf.db1));
|
||||
state.brf.db0 = gpuArray(single(state.brf.db0));
|
||||
for k = 1:numel(state.brf.matR)
|
||||
state.brf.matR{k} = gpuArray(single(state.brf.matR{k}));
|
||||
end
|
||||
else
|
||||
opt_in_x = gpuArray(opt_in_x);
|
||||
opt_in_y = gpuArray(opt_in_y);
|
||||
state.common_beta.X = gpuArray(state.common_beta.X);
|
||||
state.common_beta.Y = gpuArray(state.common_beta.Y);
|
||||
state.brf.db1 = gpuArray(state.brf.db1);
|
||||
state.brf.db0 = gpuArray(state.brf.db0);
|
||||
for k = 1:numel(state.brf.matR)
|
||||
state.brf.matR{k} = gpuArray(state.brf.matR{k});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Split Step Method
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Split Step Method
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% [opt_out_x,opt_out_y] = split_step_loop(state.L,opt_in_x,opt_in_y,state.gamma,state.SS_dzmin,state.SS_dzmax,state.SS_dphimax,state.alpha_lin,...
|
||||
% state.lin_z_test,state.corr_length,state.n_plates_done,state.missing_dz,state.brf,state.common_beta,....
|
||||
@@ -75,33 +44,35 @@ end
|
||||
% [opt_out_x,opt_out_y] = split_step_loop_mex(state.L,opt_in_x,opt_in_y,state.gamma,state.SS_dzmin,state.SS_dzmax,state.SS_dphimax,state.alpha_lin,...
|
||||
% state.lin_z_test,state.corr_length,state.n_plates_done,state.missing_dz,state.brf,state.common_beta,....
|
||||
% state.chi,state.manakov,state.beat_len);
|
||||
|
||||
% get nonlinear step size
|
||||
[state.dz] = getNLstepsize(opt_in_x,opt_in_y,state.gamma,state.SS_dzmin,state.SS_dzmax,state.SS_dphimax,state.alpha_lin);
|
||||
%[state.dz] = getNLstepsize_original(state,opt_out_struct);
|
||||
|
||||
state.n_step = 0;
|
||||
state.z_prop = 0;
|
||||
state.test_dz = [];
|
||||
state.powers = [];
|
||||
|
||||
% get nonlinear step size
|
||||
[state.dz] = getNLstepsize(opt_in_x,opt_in_y,state.gamma,state.SS_dzmin,state.SS_dzmax,state.SS_dphimax,state.alpha_lin);
|
||||
%[state.dz] = getNLstepsize_original(state,opt_out_struct);
|
||||
tic
|
||||
|
||||
state.n_step = 0;
|
||||
state.z_prop = 0;
|
||||
state.test_dz = [];
|
||||
state.powers = [];
|
||||
while state.z_prop < state.L
|
||||
|
||||
while state.z_prop < state.L
|
||||
% reduce step length (dz) if we are to overshoot the fiber length
|
||||
% (L) in the next step
|
||||
if state.z_prop + state.dz > state.L
|
||||
state.dz = state.L - state.z_prop;
|
||||
end
|
||||
|
||||
% update step number (n)
|
||||
state.n_step=state.n_step+1;
|
||||
|
||||
% reduce step length (dz) if we are to overshoot the fiber length
|
||||
% (L) in the next step
|
||||
if state.z_prop + state.dz > state.L
|
||||
state.dz = state.L - state.z_prop;
|
||||
end
|
||||
% append current step length to logbook (dzs)
|
||||
state.dzs(state.n_step)=state.dz;
|
||||
|
||||
% update step number (n)
|
||||
state.n_step=state.n_step+1;
|
||||
|
||||
% append current step length to logbook (dzs)
|
||||
state.dzs(state.n_step)=state.dz;
|
||||
|
||||
|
||||
% half linear step
|
||||
[opt_in_x,opt_in_y,state.z_prop,state.lin_z_test,...
|
||||
|
||||
% half linear step
|
||||
[opt_in_x,opt_in_y,state.z_prop,state.lin_z_test,...
|
||||
state.corr_length,state.n_plates_done,state.missing_dz,state.n_step,...
|
||||
state.test_plates,state.test_plate_numbers,state.brf,state.common_beta.X,...
|
||||
state.common_beta.Y,state.alpha_lin.X,state.alpha_lin.X]...
|
||||
@@ -111,12 +82,12 @@ while state.z_prop < state.L
|
||||
state.test_plates,state.test_plate_numbers,state.brf,state.common_beta.X,...
|
||||
state.common_beta.Y,state.alpha_lin.X,state.alpha_lin.X);
|
||||
|
||||
% complete nonlinear step
|
||||
|
||||
[opt_in_x,opt_in_y] = nl_step(opt_in_x,opt_in_y, state.dz, state.gamma, state.chi, state.manakov, state.beat_len ,state.alpha_lin.X, state.alpha_lin.Y);
|
||||
|
||||
% half linear step
|
||||
[opt_in_x,opt_in_y,state.z_prop,state.lin_z_test,...
|
||||
% complete nonlinear step
|
||||
|
||||
[opt_in_x,opt_in_y] = nl_step(opt_in_x,opt_in_y, state.dz, state.gamma, state.chi, state.manakov, state.beat_len ,state.alpha_lin.X, state.alpha_lin.Y);
|
||||
|
||||
% half linear step
|
||||
[opt_in_x,opt_in_y,state.z_prop,state.lin_z_test,...
|
||||
state.corr_length,state.n_plates_done,state.missing_dz,state.n_step,...
|
||||
state.test_plates,state.test_plate_numbers,state.brf,state.common_beta.X,...
|
||||
state.common_beta.Y,state.alpha_lin.X,state.alpha_lin.X]...
|
||||
@@ -126,34 +97,24 @@ while state.z_prop < state.L
|
||||
state.test_plates,state.test_plate_numbers,state.brf,state.common_beta.X,...
|
||||
state.common_beta.Y,state.alpha_lin.X,state.alpha_lin.X);
|
||||
|
||||
% get nonlinear step size
|
||||
[state.dz] = getNLstepsize(opt_in_x,opt_in_y,state.gamma,state.SS_dzmin,state.SS_dzmax,state.SS_dphimax,state.alpha_lin);
|
||||
%[state.dz] = getNLstepsize_original(state,opt_out_struct);
|
||||
% get nonlinear step size
|
||||
[state.dz] = getNLstepsize(opt_in_x,opt_in_y,state.gamma,state.SS_dzmin,state.SS_dzmax,state.SS_dphimax,state.alpha_lin);
|
||||
%[state.dz] = getNLstepsize_original(state,opt_out_struct);
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% GPU Gather (if enabled)
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
if useGPU
|
||||
opt_out_x = gather(opt_in_x);
|
||||
opt_out_y = gather(opt_in_y);
|
||||
|
||||
% Gather state arrays back to CPU
|
||||
state.common_beta.X = gather(state.common_beta.X);
|
||||
state.common_beta.Y = gather(state.common_beta.Y);
|
||||
state.brf.db1 = gather(state.brf.db1);
|
||||
state.brf.db0 = gather(state.brf.db0);
|
||||
for k = 1:numel(state.brf.matR)
|
||||
state.brf.matR{k} = gather(state.brf.matR{k});
|
||||
|
||||
end
|
||||
else
|
||||
opt_out_x = opt_in_x;
|
||||
opt_out_y = opt_in_y;
|
||||
end
|
||||
|
||||
toc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
opt_out_x = (opt_in_x);
|
||||
opt_out_y = (opt_in_y);
|
||||
|
||||
% opt_out_x = gather(opt_in_x);
|
||||
% opt_out_y = gather(opt_in_y);
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user