Faster DP_fiber with GPU processing... Run test\gpu_cpu_comparison.m to see difference on your setup

This commit is contained in:
silas (home)
2026-02-01 13:53:20 +01:00
parent 67689bb70f
commit fba7cbdba2
15 changed files with 1281 additions and 217 deletions

View File

@@ -24,6 +24,8 @@ classdef DP_Fiber
SS_dzmax % [m] max dz (adaptive SSFM)
SS_dzmin % [m] min dz (adaptive SSFM)
n_waveplates % number of PMD waveplates
useGPU % GPU acceleration: true, false, or 'auto' (default)
useSingle % Use single precision on GPU (default: false)
% ---- Internal state (persistent between calls) ----
state % struct mirroring legacy 'state'
@@ -56,6 +58,8 @@ classdef DP_Fiber
options.SS_dzmax = 2e4 % m
options.SS_dzmin = 100 % m
options.n_waveplates = 100
options.useGPU = 'auto' % 'auto', true, or false
options.useSingle = false % single precision GPU
end
% Copy provided options into properties
@@ -208,7 +212,7 @@ classdef DP_Fiber
% Frequency-dependent PMD phase term (legacy form)
st.brf.db0 = (R.rand(st.wave_plates,1)*2*pi - pi) * brf_multiplier;
st.brf.db1 = sqrt(3*pi/8)*(st.dgd/obj.fa)/st.wave_plates .* st.omega;
st.brf.simdgd = 0;
st.brf.simdgd = 0;
% cumsum used in legacy only for debug; keep compatibility variable:
~cumsum(st.brf.db0); % no-op to mirror legacy path
@@ -228,7 +232,18 @@ classdef DP_Fiber
x_in = signal_in(:,1).';
y_in = signal_in(:,2).';
[x_out, y_out, obj.state] = CNLSE_plain(x_in, y_in, obj.state);
% Determine GPU usage
if ischar(obj.useGPU) || isstring(obj.useGPU)
if strcmpi(obj.useGPU, 'auto')
gpuFlag = []; % Let CNLSE_plain auto-detect
else
error('DP_Fiber:InvalidGPU', 'useGPU must be true, false, or ''auto''');
end
else
gpuFlag = logical(obj.useGPU);
end
[x_out, y_out, obj.state] = CNLSE_plain(x_in, y_in, obj.state, gpuFlag, obj.useSingle);
obj.state.propagated_length = obj.state.propagated_length + obj.state.L;

View File

@@ -42,7 +42,7 @@ classdef Optical_Demultiplex < handle
function signalclasses_out = process(obj, signalclass_in)
% ---- Infer wavelength: either given or from input total signal
% ---- Infer wavelength: either given or from input total signal
if isempty(obj.wavelengthplan)
obj.wavelengthplan = signalclass_in.lambda; %meter
else
@@ -81,7 +81,7 @@ classdef Optical_Demultiplex < handle
obj
signal_in
end
w = obj.fs_out ./ obj.fs_in ;
blocklen_in = length(signal_in);
blocklen_out = w*blocklen_in;
@@ -119,30 +119,31 @@ classdef Optical_Demultiplex < handle
N = size(lo,1);
C = size(lo,2);
x_envelopes = zeros(N, C, 'like', signal_in);
y_envelopes = zeros(N, C, 'like', signal_in);
% ---- VECTORIZED: Process all channels in parallel ----
% Batched FFT operates on each column simultaneously on GPU
s1 = signal_in(:,1);
s2 = signal_in(:,2);
% Extract polarization signals
s1 = signal_in(:,1); % X polarization [N×1]
s2 = signal_in(:,2); % Y polarization [N×1]
% Reusable work buffers (avoid reallocations)
wrk_time = zeros(N,1, 'like', signal_in);
wrk_freq = zeros(N,1, 'like', signal_in);
% Broadcast signal to all channels and multiply with LO
% s1, s2 are [N×1], lo is [N×C] result is [N×C]
x_mixed = att .* s1 .* lo; % [N×C]
y_mixed = att .* s2 .* lo; % [N×C]
% Batched FFT: each column computed in parallel
x_freq = fft(x_mixed); % [N×C]
y_freq = fft(y_mixed); % [N×C]
% Apply filter (H is [N×1], broadcasts across columns)
x_filtered = x_freq .* H; % [N×C]
y_filtered = y_freq .* H; % [N×C]
% Batched IFFT
x_envelopes = ifft(x_filtered); % [N×C]
y_envelopes = ifft(y_filtered); % [N×C]
for c = 1:C
% ---- X branch ----
wrk_time(:) = att .* s1 .* lo(:,c); % N×1
wrk_freq(:) = fft(wrk_time); % N×1
wrk_freq(:) = wrk_freq .* H; % N×1
x_envelopes(:,c) = ifft(wrk_freq); % N×1
% ---- Y branch ----
wrk_time(:) = att .* s2 .* lo(:,c);
wrk_freq(:) = fft(wrk_time);
wrk_freq(:) = wrk_freq .* H;
y_envelopes(:,c) = ifft(wrk_freq);
end
end
end
end

View File

@@ -1,10 +1,10 @@
classdef Optical_Multiplex < handle
% Takes a cell array of signals
% returns a total field signal
% WDM spacing is given in wavelength plan OR via delta_F
% returns a total field signal
% WDM spacing is given in wavelength plan OR via delta_F
% The grid is stored in the output signal -> the demux will ideally
% look this up and use this as the demux frequencies...
% look this up and use this as the demux frequencies...
% signal_cell = {Opt_sig_1, Opt_sig_2};
% Opt_sig_wdm = Optical_Multiplex("fs_in",Opt_sig.fs,"fs_out",4*Opt_sig.fs,...
@@ -117,7 +117,7 @@ classdef Optical_Multiplex < handle
% adapt frequency shifts to match the FFT grid! Find nearest grid point
[glitch(o),pos] = min(abs( freqaxis-obj.df_T(o) ));
obj.df_T(o) = freqaxis(pos);
polrots = [polrots, data_in{o}.polrot];
end
@@ -139,25 +139,36 @@ classdef Optical_Multiplex < handle
x_envelopes = NaN([blocklen_out N]);
y_envelopes = x_envelopes;
% ---- OPTIMIZED: Pre-compute all LO phases as [blocklen_out × N] matrix ----
time_idx = (0:blocklen_out-1).'; % [blocklen_out × 1]
lo_phases = mod(2*pi * time_idx * obj.df_T / obj.fs_out, 2*pi); % [blocklen_out × N]
lo_all = cos(lo_phases) + 1i*sin(lo_phases); % [blocklen_out × N]
% Collect all resampled signals first (still requires loop due to cell array)
x_signals = zeros(blocklen_out, N);
y_signals = zeros(blocklen_out, N);
for o = 1:N
pha = mod(2*pi*(0:blocklen_out-1)*obj.df_T(o)/obj.fs_out,2*pi).';
lo = cos(pha)+1i*sin(pha);
data_in_resampled = data_in{o}.resample("fs_out",obj.fs_out);
res_env = ifft(fft(data_in_resampled.signal(:,1)).*H);
x_envelopes(:,o) = att.*res_env.*lo;
res_env = ifft(fft(data_in_resampled.signal(:,2)).*H);
y_envelopes(:,o) = att.*res_env.*lo;
data_in_resampled = data_in{o}.resample("fs_out", obj.fs_out);
x_signals(:, o) = data_in_resampled.signal(:, 1);
y_signals(:, o) = data_in_resampled.signal(:, 2);
end
% ---- VECTORIZED: Batched FFT/IFFT for all channels ----
% Apply filter to all channels at once
x_filtered = ifft(fft(x_signals) .* H); % [blocklen_out × N]
y_filtered = ifft(fft(y_signals) .* H); % [blocklen_out × N]
% Apply attenuation and LO shift to all channels
x_envelopes = att .* x_filtered .* lo_all; % [blocklen_out × N]
y_envelopes = att .* y_filtered .* lo_all; % [blocklen_out × N]
data_out = data_in_resampled;
data_out.signal = [sum(x_envelopes,2), sum(y_envelopes,2)];
data_out.lambda = obj.lambda_T;
data_out.polrot = polrots;
end
end

View File

@@ -1,41 +1,72 @@
function [opt_out_x,opt_out_y,state] = CNLSE_plain(opt_in_x,opt_in_y,state)
function [opt_out_x,opt_out_y,state] = CNLSE_plain(opt_in_x,opt_in_y,state,useGPU,useSingle)
% 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);
end
%opt_out_struct.(curPol)=opt_in_struct.(curPol).envelope;
% 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
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);
%opt_out_struct.(curPol)=opt_in_struct.(curPol).envelope;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Split Step Method
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% [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,....
@@ -44,35 +75,33 @@ function [opt_out_x,opt_out_y,state] = CNLSE_plain(opt_in_x,opt_in_y,state)
% [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
% 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);
while state.z_prop < state.L
state.n_step = 0;
state.z_prop = 0;
state.test_dz = [];
state.powers = [];
% 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;
while state.z_prop < state.L
% append current step length to logbook (dzs)
state.dzs(state.n_step)=state.dz;
% 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
% half linear step
[opt_in_x,opt_in_y,state.z_prop,state.lin_z_test,...
% 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]...
@@ -82,12 +111,12 @@ function [opt_out_x,opt_out_y,state] = CNLSE_plain(opt_in_x,opt_in_y,state)
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]...
@@ -97,24 +126,34 @@ function [opt_out_x,opt_out_y,state] = CNLSE_plain(opt_in_x,opt_in_y,state)
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
toc
else
opt_out_x = opt_in_x;
opt_out_y = opt_in_y;
end
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

View File

@@ -0,0 +1,20 @@
function canUse = canUseGPU()
%CANUSEGPU Check if a compatible GPU is available for parallel computing
% Returns true if MATLAB Parallel Computing Toolbox is available and
% a CUDA-capable GPU is detected.
canUse = false;
% Check if Parallel Computing Toolbox is installed
if ~license('test', 'Distrib_Computing_Toolbox')
return;
end
% Check for GPU device
try
gpu = gpuDevice();
canUse = gpu.DeviceSupported;
catch
canUse = false;
end
end

View File

@@ -1,25 +1,25 @@
function [rDZ] = getNLstepsize(ux,uy,gamma,dzmin,dzmax,dphimax,alpha_lin)
maxPow = max(gamma.*max(real(ux).^2+imag(ux).^2+real(uy).^2+imag(uy).^2));
Leff = dphimax/maxPow;
alpha_lin = max([alpha_lin.X alpha_lin.Y]);
nl_att_len_ratio = alpha_lin*Leff;
if nl_att_len_ratio >= 1
rDZ = dzmax;
% gather() handles gpuArray inputs - ensures scalar is on CPU for comparisons
maxPow = gather(max(gamma.*max(real(ux).^2+imag(ux).^2+real(uy).^2+imag(uy).^2)));
Leff = dphimax/maxPow;
alpha_lin = max([alpha_lin.X alpha_lin.Y]);
nl_att_len_ratio = alpha_lin*Leff;
if nl_att_len_ratio >= 1
rDZ = dzmax;
else
if alpha_lin == 0
step = Leff;
else
if alpha_lin == 0
step = Leff;
else
%effective length?
step = -1/alpha_lin*log(1-nl_att_len_ratio);
end
rDZ = min([step dzmax]);
rDZ = max([rDZ dzmin]);
end
%effective length?
step = -1/alpha_lin*log(1-nl_att_len_ratio);
end
rDZ = min([step dzmax]);
rDZ = max([rDZ dzmin]);
end
end

View File

@@ -22,37 +22,37 @@ n_plates_left = n_plates - n_plates_done;
% compute last plate size ( if it fits, it should be 0)
if missing_dz > aStepSize
last_plate = aStepSize;
missing_dz = missing_dz-aStepSize;
plate_sizes = last_plate;
plate_numbers = n_plates;
else
last_plate = aStepSize - missing_dz - (n_plates_left-1)*corr_length;
if missing_dz == 0
missing_dz = [];
end
%build vector of plate lengths with missing plate part from prev.
%iterartion , then some normal plates and finally a fraction of a plate
%to fit into the step length
plate_sizes = [missing_dz corr_length*ones(1,n_plates_left-1) last_plate];
if n_plates_done == 0
plate_numbers =[(n_plates_done+1):(n_plates-1) n_plates];
else
plate_numbers = [n_plates_done (n_plates_done+1):(n_plates-1) n_plates]; % not wrking yet
end
%remember for next step
%remember for next step
missing_dz = corr_length - last_plate;
end
plate_steps = repmat(n_step,1,length(plate_sizes));
plate_steps = repmat(n_step,1,length(plate_sizes)); %#ok<NASGU>
%
%figure;stem(plate_sizes);
@@ -66,50 +66,39 @@ test_plate_numbers = [test_plate_numbers, plate_numbers];
opt_x=fft(opt_x);
opt_y=fft(opt_y);
% db1 = gpuArray(brf.db1);
% db0 = gpuArray(brf.db0);
% common_beta_x = gpuArray(common_beta_x);
% common_beta_y = gpuArray(common_beta_y);
db1 = (brf.db1);
db0 = (brf.db0);
common_beta_x = (common_beta_x);
common_beta_y = (common_beta_y);
% Note: db1, db0, common_beta_x, common_beta_y are already on GPU when
% useGPU=true (transferred in CNLSE_plain)
db1 = brf.db1;
db0 = brf.db0;
% process every waveplate with given sizes in plate_sizes
for n=1:length(plate_sizes)
dz = plate_sizes(n);
% figure(87);subplot(2,1,1);plot(real(x(900:1150)));subplot(2,1,2);plot(real(y(900:1150)));
% MOV1=[MOV1 getframe(87)];
% extract rotation matrix from pre calculated matrices
matR = brf.matR{plate_numbers(n)};
% transform to eigenvalue of of fiber segment
tOpt.X = conj(matR(1,1))*opt_x + conj(matR(2,1))*opt_y;
tOpt.Y = conj(matR(1,2))*opt_x + conj(matR(2,2))*opt_y;
% calculate statistical delta beta for pmd
delta_beta = 0.5*(db1+db0(n))/corr_length;
% build transfer function with delta beta
%common.beta = beta1+beta2*omega^2
%accumulate delta beta for log...
brf.simdgd = brf.simdgd + (db1(length(db1)/2+1)+db0(n))/corr_length;
h.X = exp(-1j*(common_beta_x-delta_beta)*dz);
h.Y = exp(-1j*(common_beta_y+delta_beta)*dz);
% delta_beta has to be added to the transfer function
% process with transfer function
tOpt.X = h.X.*tOpt.X ;
tOpt.Y = h.Y.*tOpt.Y ;
% rotate back
opt_x = matR(1,1)*tOpt.X + matR(1,2)*tOpt.Y;
opt_y = matR(2,1)*tOpt.X + matR(2,2)*tOpt.Y;
end
lin_z_test = lin_z_test + sum(plate_sizes,2);
@@ -117,9 +106,8 @@ lin_z_test = lin_z_test + sum(plate_sizes,2);
%update the number of processed plates so far
n_plates_done = n_plates_done + n_plates_left;
% attanuate the signal each linear state with alpha
% ( 0.2dB = 4.6052e-05 )
rOpt_x=ifft(exp(-alpha_lin_x*aStepSize/2).*opt_x); % /2 not sure why (have to find it in formulas)
rOpt_y=ifft(exp(-alpha_lin_y*aStepSize/2).*opt_y); % but not relevant for now
% attenuate the signal each linear step with alpha
rOpt_x=ifft(exp(-alpha_lin_x*aStepSize/2).*opt_x);
rOpt_y=ifft(exp(-alpha_lin_y*aStepSize/2).*opt_y);
end
end

View File

@@ -23,6 +23,12 @@ classdef DBHandler < handle
arguments
options.dataBase = ""; % Default value for pathToDB if not provided
options.type = "mysql";
options.server = "";
options.port = 3306;
options.user = "";
options.password = "";
end
% Assign values to class properties based on input arguments
@@ -46,12 +52,13 @@ classdef DBHandler < handle
obj.conn = database( ...
string(obj.dataBase), ... % Database name
"silas", ... % Username
"silas", ... % Password (or getSecret)
options.user, ... % Username
options.password, ... % Password (or getSecret)
"Vendor", "MySQL", ...
"Server", "134.245.243.254", ...
"Server", options.server, ...
"PortNumber", 3306, ...
"JDBCDriverLocation", "C:\Users\Silas\Documents\mysql-connector-j-9.3.0\mysql-connector-j-9.3.0.jar");
end
catch e