%% Parameter to simulate and save params = struct; params.M = [4]; params.datarate = [224]; params.sir = [25]; %decibel = attenuation of interference path params.mpi_pathlen = [50]; params.laser_linewidth = [1e6]; params.pn_key = [15]; params.vbias_rel = [0.5]; params.rop = 0; params.clipfactor = [1.3]; params.rrcalpha = [0.1]; name = ['wh_',strrep(num2str(now),'.','')]; wh = DataStorage(params); wh.addStorage("ber"); wh.addStorage("rop"); wh.addStorage("txpapr"); wh.addStorage("er"); %% Init Params link_length = 10000; %meter endcnt = prod(wh.dim); cnt=0; disp(['Start Simulation of ',num2str(endcnt),' loops...']) tic for M = wh.parameter.M.values for datarate = wh.parameter.datarate.values for rrcalpha = wh.parameter.rrcalpha.values %% SETUP HERE: %% kover = 8; Awg = M8199A("kover",kover); fdac = Awg.fdac; fsym = round(datarate / log2(M))*1e9; Lp_awg = Filter('filtdegree',4,"f_cutoff",75e9,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true); Lp_mod = Filter('filtdegree',2,"f_cutoff",100e9,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true); Lp_opt = Filter('filtdegree',6,"f_cutoff",fsym.*0.7,"fs",fdac*kover,"filterType",filtertypes.gaussian,"active",true); Lp_phd = Filter('filtdegree',2,"f_cutoff",70e9,"fs",fdac*kover,"filterType",filtertypes.gaussian,"active",true); fadc = 256e9; Lp_scpe = Filter('filtdegree',4,"f_cutoff",63e9,"fs",fadc,"filterType",filtertypes.butterworth,"active",true); Scp = Scope("fsimu",fdac*kover,"fadc",fadc,... "delay",0,"fixed_delay",0,"filtertype",filtertypes.butterworth,... "samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,... "adcresolution",16,"quantbuffer",0.1,'block_dc',1,'lpf_active',1,'H_lpf',Lp_scpe); fadc = Scp.fadc; % figure(222) % Lp_awg.showHere; % Lp_mod.showHere; % Lp_opt.showHere; % Lp_phd.showHere; % Lp_scpe.showHere; % SETUP TX Model Pmap = PAMmapper(M,0); Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rrcalpha); % SETUP RX Model Phd = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20); % Eq = EQ_silas("Ne",[25,0,0],"Nb",[2,0,0],"trainlength",4096,... % "sps",2,... % "mu_dc_dd",0.1,... % "mu_dc_train",0.0,... % "mu_ffe_train",0.00,... % "mu_dfe_train",0.005,... % "mu_ffe_dd",[0.0004 0.0004 0.0004],... % "mu_dfe_dd",0.005,... % "ddloops",3,... % "trainloops",4,... % "eq_parallelization_blocklength",0, ... % "eq_updatelatency",0,... % "eq_avg_blocklength",1000); % Eq = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",1e-4,"mu_tr",0,"order",25,"sps",2,"decide",0); % Eq = FFE_DFE("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"ffe_mu_dd",1e-4,"dfe_mu_dd",5e-4,"ffe_mu_tr",0,"dfe_mu_tr",0,"ffe_order",25,"dfe_order",2,"sps",2,"decide",1); % Eq = EQ_silas_sliding_window_dc_removal("Ne",[25,0,0],"Nb",[2,0,0],"trainlength",4096,... % "sps",2,... % "mu_dc_dd",0.05,... % "mu_dc_train",0.05,... % "mu_ffe_train",0,... % "mu_dfe_train",0.005,... % "mu_ffe_dd",[0.0004 0.0004 0.0004],... % "mu_dfe_dd",0.0004,... % "ddloops",4,... % "trainloops",4,... % "eq_blocklength",0,... % "eq_updatelatency",0); % Eq = EQ("Ne",[25,3,3],"Nb",[0,0,0],"training_length",4096,"training_loops",4,"dd_loops",4,"K",2,"DCmu",0,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",1); Eq = VNLE("epochs_tr",7,"epochs_dd",7,"len_tr",4096,"mu_dd",[0.0004 0.0005 0.0006],"mu_tr",0,"order",[25,3,3],"sps",2,"decide",1); for clipfactor = wh.parameter.clipfactor.values % TX model [El,Bits,Ref] = tx_model(fsym,Pmap,Pform,Awg,"clipfactor",clipfactor); % Laser and Modulation El = Lp_mod.process(El); El = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",15).process(El); pwr_ = El.power; % in dbm into 50 ohm papr_ = papr(El.signal); vpk_ = max(abs(El.signal)); vswing_ = max(El.signal)-min(El.signal); awg_string = ['AWG: Pout: ',num2str(round(pwr_,2)),' dBm (50 Ohm); PAPR: ',num2str(round(papr_,2)),'; Vpk: ',num2str(round(vpk_,2)),' V; Vswing: ',num2str(round(vswing_,2)),' V']; disp(awg_string); for laser_linewidth = wh.parameter.laser_linewidth.values for pn_key = wh.parameter.pn_key.values for vbias_rel = wh.parameter.vbias_rel.values u_pi = 2.9; vbias = -vbias_rel*u_pi; extmodlaser = EML("mode",eml_mode.im_cosinus,"power",3,"fsimu",El.fs,"lambda",1290,"bias",vbias,"u_pi",u_pi,"linewidth",laser_linewidth,"randomkey",pn_key); % El = El.normalize("mode","oneone").*u_pi.*0.4; [modulated,extmodlaser] = extmodlaser.process(El); if 1 figure(10) hold on scatter(El.signal(1:100000)+vbias,(abs(modulated.signal(1:100000)).^2)*1e3,0.1,'.','DisplayName','Modulator TF') ylim([0 4]); xlim([-u_pi/2, u_pi/2]+vbias); xlabel('Input in V') ylabel('abs(Output) in mW') % Define properties boxPosition = [0.15 0.86 0.2 0.05]; % Position for the first box [x y width height] boxColor = [0.9 0.9 0.9]; % Light grey background color boxEdgeColor = 'k'; % Black edge color boxLineStyle = '--'; % Dashed line style boxFontWeight = 'bold'; % Bold font % Create first annotation box for Power annotation('textbox', boxPosition, ... 'String', ['V pi: ',num2str(u_pi),' V'], ... 'BackgroundColor', boxColor, ... 'EdgeColor', boxEdgeColor, ... 'LineStyle', boxLineStyle, ... 'FontWeight', boxFontWeight, ... 'HorizontalAlignment', 'center'); % Adjust position for the second box (slightly to the right) boxPosition = [0.37 0.86 0.2 0.05]; % Adjusted position % Create second annotation box for PAPR annotation('textbox', boxPosition, ... 'String', ['V bias: ',num2str(vbias),' V'], ... 'BackgroundColor', boxColor, ... 'EdgeColor', boxEdgeColor, ... 'LineStyle', boxLineStyle, ... 'FontWeight', boxFontWeight, ... 'HorizontalAlignment', 'center'); modulated.eye(fsym,M); modulated.spectrum("fignum",112,"displayname",'transmit spectrum'); modulated = Lp_opt.process(modulated); end er = modulated.extinctionratio(fsym,M); if 1 m_ = wh.parameter.mpi_pathlen.length; j_ = wh.parameter.sir.length; i_ = wh.parameter.rop.length; ber=zeros(m_,j_,i_); patten=zeros(m_,j_,i_); for m = 1:m_ mpi_path = wh.parameter.mpi_pathlen.values(m); for j = 1:j_ sir = wh.parameter.sir.values(j); % MPI Channel Opt = channel_model_mpi(modulated,link_length,mpi_path,sir); for i = 1:i_ rop=wh.parameter.rop.values(i); % Set ROP Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",rop).process(Opt); patten(m,j,i) = Rx_sig.power; % RX Model Rx_bits = rx_model(Rx_sig,Ref,Phd,Lp_phd,Scp,Eq,Pmap); % BER [~,errors_bm,ber(m,j,i),errors] = calc_ber(Rx_bits.signal,Bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1); cnt = cnt+1; disp(['BER: ',sprintf('%.1E',ber(m,j,i)),' - - ROP: ',num2str(Rx_sig.power),'dBm - - PAM-',num2str(M),' - - ',num2str(fsym*1e-9),' GBd']); end end end for m = 1:m_ mpi_path = wh.parameter.mpi_pathlen.values(m); for j = 1:j_ sir = wh.parameter.sir.values(j); for i = 1:i_ rop=wh.parameter.rop.values(i); wh.addValueToStorage(ber(m,j,i),'ber',M,datarate,sir,mpi_path,laser_linewidth,pn_key,vbias_rel,rop,clipfactor,rrcalpha); wh.addValueToStorage(patten(m,j,i),'rop',M,datarate,sir,mpi_path,laser_linewidth,pn_key,vbias_rel,rop,clipfactor,rrcalpha); wh.addValueToStorage(er,'er',M,datarate,sir,mpi_path,laser_linewidth,pn_key,vbias_rel,rop,clipfactor,rrcalpha); end end end end end toc disp(['Simulated: ',num2str(cnt/endcnt*100),' %']); save(['C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\MPI_Juni\',name,'.mat'],"wh"); end end end end end end