function [opt_out_x,opt_out_y,state] = CNLSE_plain(opt_in_x,opt_in_y,state) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % pre calculations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% state.common_beta=struct('X',0,'Y',0); 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); 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); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 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,.... % state.chi,state.manakov,state.beat_len); % [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 = []; tic 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; % 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,... 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]... = lin_step(... opt_in_x,opt_in_y,state.z_prop,state.lin_z_test,... state.dz/2,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); % 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]... = lin_step... (opt_in_x,opt_in_y,state.z_prop,state.lin_z_test,... state.dz/2,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); % 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 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