diff --git a/Ring_Resonator/DelayInterfExp.m b/Ring_Resonator/DelayInterfExp.m new file mode 100644 index 0000000..a758c19 --- /dev/null +++ b/Ring_Resonator/DelayInterfExp.m @@ -0,0 +1,138 @@ +function [ Eout1,Eout2 ] = DelayInterfExp( f,TimDel,PhaDel,E1,E0,CoupConst,... + ExpCoef,MutCoef ) +%% Delay Interferometer +%c function[Eout1,Eout2] = DelayInterf( t,TimDel,PhaDel,E1,E0,CoupConst,... +%c ExpCoef,MutCoef ) +%c This function is responsible for implementing an Delay Interferometer +%c (DI). There many ways that this device can be implemented such as MZM, +%c passive components and couples with diffe light paths. This script will +%c inplement a DI ussing 3dB couples with 2-input and 2-outputs. The delay +%c given will be implement by light paths with different lengths and the +%c phase delay will be achieve with a phase controler. This will be the +%c principal and only device used to implement an All Optica FFT. Aiming to +%c separate subcarriers from an OFDM signal and convert from serial to +%c paralel. +%c +%c +%c Created by P.Marciano LG +%c 02/11/2017 +%c pablorafael.mcx@gmail.com +%c +%c Refences: +%c@article{hillerkuss2010simple, +%c title={Simple all-optical FFT scheme enabling Tbit/s real-time signal processing}, +%c author={Hillerkuss, D and Winter, M and Teschke, M and Marculescu, A and Li, J and Sigurdsson, G and Worms, K and Ezra, S Ben and Narkiss, N and Freude, W and others}, +%c journal={Optics express}, +%c volume={18}, +%c number={9}, +%c pages={9324--9340}, +%c year={2010}, +%c publisher={Optical Society of America} +%c} +%c +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c DelayInterf +%c +%c Input: +%c t : Time vector of the whole simulation [s] +%c TimDel : Time delay to be implemented by the DI +%c PhaDel : Phase delay to be implemented by the DI +%c E1 : Principal input signal to be implemented +%c E0 : Secundary input signal (usualy it is zero) +%c CoupConst : Couples Constant of the DI +%c ExpCoef : Exponential component from Ramaswami equation +%c MutCoef : Coeficient to control polarity +%c +%c Output: +%c Eout1 : Output1 from the DI interfometric response +%c Eout2 : Output2 from the DI interfometric response +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%% +% At the very first part of this iscript, it is necessary to be sure that +% all variable that will be used are needed to be correctly initialized. +%% Delay Interferometers +% it was fundamental to use a teoretical model for the couple. Because just +% adding signals together or subtracting them those will not result as an +% optical coupler. The model used at this script was taken from Optical +% Networks by Ramaswami. + +%Verifing the variables used on the optical coupler were correctly +%initialized. +if nargin<5 +% DelayInterfInputData; + CoupConst = 3*pi/4; %Couples Constant of the DI + ExpCoef = exp(-1j*1);%Exponential component from Ramaswami equation + MutCoef = 1; %Coeficient to control polarity + E0 = 0; +elseif nargin<6 + CoupConst = 3*pi/4; %Couples Constant of the DI + ExpCoef = exp(-1j*1);%Exponential component from Ramaswami equation + MutCoef = 1; %Coeficient to control polarity +else + error(['Input Arguments are not enougth. Please check this function'... + ' Call!']); +end + +%% * Stage: 1 spliting the principal input signal +% Fristly it is needed to divide the signal in two given that by the length +% difference of the optical pahts and the phase delay btween them the +% signals will interfere with one another. + % split + % An 3dB coupler with 2 inputs and 2 outputs is used to slplit the input + % signal. + %The couples will output two signals that are a combination of E1 and E0. + %As E0 = 0 the out put will be just the E1 signal slpit in two. The name + %notation E11 means the E1 signal at the arm 1 (uper arm) hence the + %notation name E12 means the E1 signal at the arm 2 (Lower arm). +E11 = ExpCoef.*(cos(CoupConst).*E1 + MutCoef*1j*sin(CoupConst).*E0); +E12 = ExpCoef.*(cos(CoupConst).*E0 + MutCoef*1j*sin(CoupConst).*E1); + +%% * Stage: 2 Changing the signal at the lower arm + %Dellay and change phase + %Firstly it is taken in acont what means for the input signal a time + %delay by measuring the input time vector +% aux1 = E12(t<=TimDel); +% aux1 = E12(1:TimDel); +% f=time2freq(t); + %Secondly the signal will be delayed by rotation its possition. That + %means a circular rith-shift will be performed. The number of possition + %to be deslocated will be given by the number of point that represent the + %delay based on the input time vector given as input. The time delay + %time accuracy depends on the time vector accuracy. +% E12d = [E12(end-(length(aux1)-1):end) E12(1:end-(length(aux1)))]; +E12d = ifft(fft(E12).*exp(-1j*2*pi*TimDel.*f)); + + %In practice the phase delay will be perfomed by an phase controler. In + %the simulation it will be done by multiplying the input signal by a + %complex neperian exponential where the argument was received as an input + %parameters. + %The nema notation means that the E12 was Delayed thus E12d +E12d = E12d.*exp(-1j*PhaDel); + +%% * Stage: 3 Recombining both signals + %Combining singnals + %Similarly to te input step. An 3dB coupler with 2 inputs and 2 outputs is + %used to combine the input signals from the arm1 and arm2. The couples + %will output two signals that are a combination of E12 and E12d. + %Thus the Eout1 is the combination of E11 and E12d wich will be out put + %at the port 1 of the couples. Hence, Eout2 is the combination of E11 and + %E12d wich will be out put at the port 2. +Eout1 = ExpCoef.*(cos(CoupConst).*E11 + MutCoef*1j*sin(CoupConst).*E12d); +Eout2 = ExpCoef.*(cos(CoupConst).*E12d + MutCoef*1j*sin(CoupConst).*E11); + +end + diff --git a/Ring_Resonator/Import_Data_MZM.m b/Ring_Resonator/Import_Data_MZM.m new file mode 100644 index 0000000..4783803 --- /dev/null +++ b/Ring_Resonator/Import_Data_MZM.m @@ -0,0 +1,107 @@ +function [L,U0,U_pi1,U_pi2,eta1,eta2,nopt,nel,alfa_ins,phi_0,C,alfa0] = ... + Import_Data_MZM (FileIndex,Local) +%% Import data from text file. +%cfunction [L,U0,U_pi1,U_pi2,eta1,eta2,nopt,nel,alfa_ins,phi_0,C,alfa0]=... +%c Import_Data_MZM (FileIndex,Local) +%c Script for importing data from the following text file: +%c +%c [pwd '\input_files\AA_MZ_Input_Data_t' num2str(FileIndex) '.m']; +%c +%c To extend the code to different selected data or a different text file, +%c generate a function instead of a script. +%c +%c Auto-generated by MATLAB on 2017/10/04 11:05:03 +%c +%c +%c +%c Updated by P.Marciano LG +%c 18/10/2017 +%c pablorafael.mcx@gmail.com +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Import_Data_MZM +%c +%c Input: +%c FileIndex : Indentifier of the file to be load into the workspace [-] +%c Local : Current path for the location of the files [-] +%c +%c Output: +%c L : Comprimento do dispositivo [cm] +%c U0 : Tensao de polarizacao [V] +%c U_pi1 : Tensao de chaveamento para 1 eletrodo [V] +%c U_pi2 : Tensao de chaveamento para 2 eletrodos [V] +%c eta1 : Sensibilidade no caminho 1 [1/V.m] +%c eta2 : Sensibilidade no caminho 2 [1/V.m] +%c nopt : Indice de refracao optico [-] +%c nel : Indice de refracao eletrico [-] +%c alfa_ins : Perda por insercao [dB] +%c phi_0 : Constante de fase entre os dois caminhos [-] +%c C : Parametro de chirp [?] +%c alfa0 : Perda condutiva [dB/cm.GHz^0.5] +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%% +%% Initialize variables. +if nargin<2 %Check if there is a specific laction to look for the files + filename = [pwd '\input_files\AA_MZ_Input_Data_t' num2str(FileIndex)...%If not assume that there is a input_files folder + '.m']; +else + filename = [Local 'AA_MZ_Input_Data_t' num2str(FileIndex) '.m']; %If yes, open the files on the given path +end +delimiter = ' '; + +%% Format string for each line of text: +% column1: double (%f) +% For more information, see the TEXTSCAN documentation. +formatSpec = '%f%[^\n\r]'; + +%% Open the text file. +fileID = fopen(filename,'r'); + +%% Read columns of data according to format string. +% This call is based on the structure of the file used to generate this +% code. If an error occurs for a different file, try regenerating the code +% from the Import Tool. +dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, ... + 'MultipleDelimsAsOne', true, 'ReturnOnError', false); + +%% Close the text file. +fclose(fileID); + +%% Post processing for unimportable data. +% No unimportable data rules were applied during the import, so no post +% processing code is included. To generate code which works for +% unimportable data, select unimportable cells in a file and regenerate the +% script. + +%% Allocate imported array to column variable names +VarName1 = dataArray{:, 1}; + +L = VarName1(1); +U0 = VarName1(2); +U_pi1 = VarName1(3); +U_pi2 = VarName1(4); +eta1 = VarName1(5); +eta2 = VarName1(6); +nopt = VarName1(7); +nel = VarName1(8); +alfa_ins = VarName1(9); +phi_0 = VarName1(10); +alfa0 = VarName1(11); + +C = (eta1+eta2)/(eta1-eta2); % Parametro de chirp +alfa0 = 10^(alfa0/20); % [1/cm.GHz^0.5] + + +%% Clear temporary variables +clearvars filename delimiter formatSpec fileID dataArray ans; \ No newline at end of file diff --git a/Ring_Resonator/MZ_Input_Data.m b/Ring_Resonator/MZ_Input_Data.m new file mode 100644 index 0000000..d57695e --- /dev/null +++ b/Ring_Resonator/MZ_Input_Data.m @@ -0,0 +1,72 @@ +%c +%c ..'Ž`'..'Ž`..'Ž`.. +%c +%c Arquivo de entrada usado pela funcao Mach_Zehnder_Modulator. Contem +%c informacoes sobre as caracteristicas fisicas do modulador Mach-Zehnder. +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c L : Comprimento do dispositivo [cm] +%c U0 : Tensao de polarizacao [V] +%c eletrodes : Numero de eletrodos (1,2). Definido pelo +%c numero de variaveis de entrada na funcao +%c Mach_Zehnder_Modulator +%c U_pi1 : Tensao de chaveamento para 1 eletrodo [V] +%c U_pi2 : Tensao de chaveamento para 2 eletrodos [V] +%c eta1 : Sensibilidade no caminho 1 [1/V.m] +%c eta2 : Sensibilidade no caminho 2 [1/V.m] +%c nopt : Indice de refracao optico +%c nel : Indice de refracao eletrico +%c alfa_ins : Perda por insercao [dB] +%c phi_0 : Constante de fase entre os dois caminhos +%c alfa0 : Perda condutiva [dB/cm.GHz^0.5] +%c +%c by M.Segatto, S. Cani, B. Jesus e A. Togneri +%c 04/09/2002 +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +% + +L = 10; +U0 = 6; +U_pi1 = 6; +U_pi2 = 6; +eta1 = 89;% 89; +eta2 =-12.7;%-12.7; +% +nopt = 2.17; +nel = 2.60; +alfa_ins = 5.1; +phi_0 = 0.0; +alfa0 = 0.55; + +C = (eta1+eta2)/(eta1-eta2); % Parametro de chirp +alfa0 = 10^(alfa0/20); % [1/cm.GHz^0.5] + + +% +% L = 10; +% U0 = 0; +% U_pi1 = 0; +% U_pi2 = 0; +% eta1 = 89; +% eta2 = -12.7; +% % +% nopt = 1; +% nel = 2; +% alfa_ins = 5.1; +% phi_0 = 0.0; +% alfa0 = 0.55; +% % +% C = (eta1+eta2)/(eta1-eta2); % Parametro de chirp +% alfa0 = 10^(alfa0/20); % [1/cm.GHz^0.5] diff --git a/Ring_Resonator/Mach_Zehnder_Modulator_simplificado.m b/Ring_Resonator/Mach_Zehnder_Modulator_simplificado.m new file mode 100644 index 0000000..8e1e167 --- /dev/null +++ b/Ring_Resonator/Mach_Zehnder_Modulator_simplificado.m @@ -0,0 +1,96 @@ +function [Eout,H] = Mach_Zehnder_Modulator_simplificado(t,Ein,U,MZ_Input_File) +%c +%c function [Eout,H] = Mach_Zehnder_Modulator(t,Ein,U1t,U2t,MZ_Input_File); +%c +%c This script is responsible to reproduce the output field of a MZM +%c modulator of one or two arms depending on the inputs. +%c +%c +%c Updated by P.Marciano LG +%c 18/09/2017 +%c pablorafael.mcx@gmail.com +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Modulador Mach-Zehnder +%c +%c Entrada: +%c t : Vetor de tempo [s] +%c Ein : Campo Eletrico de Entrada [V/m] +%c (dominio do tempo) +%c U1t : Tensao de entrada no braco 1 do modulador [V] +%c (dominio do tempo) +%c U2t : Tensao de entrada no braco 2 do modulador [V] +%c (dominio do tempo) +%c MZ_Input_File :Arquivo de entrada contendo parametros do modulador +%c +%c Saida +%c Eout : Campo Eletrico optico modulado no tempo [V/m] +%c H : Funcao de tranferencia eletrica do modulador +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Usa: time2freq_lamb +%% +if (nargin <= 3), + MZ_Input_File ='MZ_Input_Data'; + run([MZ_Input_File '.m']); +else + [L,U0,U_pi1,U_pi2,~,~,nopt,nel,~,~,C,alfa0] = Import_Data_MZM (... + MZ_Input_File);%Import the data from files +end +if isstruct(U), + electrodes = 2; % Two arms modulator + U1t = U.U1t; + U2t = U.U2t; + U_pi = U_pi2; +else + electrodes = 1; % One arm modulator + U1t = U; + U_pi = U_pi1; +end +% +tps = t/1E-12; +ccmns = 30; % Velocidade da luz [cm/ns] +freqTHz = time2freq_lamb(tps); +freqGHz = freqTHz*1e-3; % Frequencia em GHz +freqGHz = -fftshift(freqGHz); +freqGHz(1) = freqGHz(2); +n = length(U1t); % Tamanho de U1t +% + +%%%%%%% FUNCAO DE TRANSFEWRENCIA ELETRICA DO MODULADOR %%%%%%%%%%% +% +alfaf = 0.5*alfa0*(abs(freqGHz).^0.5); +gamaf = 2*pi*abs(freqGHz).*(nel - nopt)/ccmns; +atn = alfaf + 1j*gamaf; +H = (1./(atn*L)).*(1 - exp(-atn*L)); +% +if (electrodes == 1), + U1f = fft(U1t); + U1t = real(ifft(U1f.*H)); + exp1 = exp(1j*C*(pi/2).*(U1t/U_pi)); + if C~=0 + Eout = Ein.*cos((pi/2).*(U1t - U0)/U_pi).*exp1; + else + Eout = Ein.*cos((pi/2).*(U1t - U0)/U_pi); + end +else + U1f = fft(U1t); + U1t = ifft(U1f.*H); + U2f = fft(U2t); + U2t = ifft(U2f.*H); + %The final part of the following equation is the Chirp parameter and it + %should not be removed, because it will be the key parameter to create + %the optical carriers at the same level. + Eout = Ein.*cos((pi/2).*(U1t - U2t - U0)/U_pi).*exp(-1j*(pi/2).*((U1t + U2t)/U_pi)); +end diff --git a/Ring_Resonator/Make_MZ_Input_Files_Simp.m b/Ring_Resonator/Make_MZ_Input_Files_Simp.m new file mode 100644 index 0000000..06d1e27 --- /dev/null +++ b/Ring_Resonator/Make_MZ_Input_Files_Simp.m @@ -0,0 +1,45 @@ +%c +%c ..'Ž`'..'Ž`..'Ž`.. +%c File: Make_MZ_Input_Files_Simp +%c(Creating the input file necessary for the MZM) +%c +%c This main code is resposible to call and load the right parameters +%c to be saved in a file for latter be used by the MZM +%c +%c +%c by P.Marciano LG +%c 18/08/2017 +%c Last UpDate +%c 23/12/2017 +%c pablorafael.mcx@gmail.com +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c Here it will be added the functions that this code will call +%c +%c +%c Set_MZ_Input_Data. - Function that will create and load the files with +%c the given in data. +%c +%c +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Start of the Program % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +S=1; %Variabel that give the name for the input file +for Inc2=1:Vbias_steps%Secundary loop for the possible combinations + U0 = Vbias(Inc2);%Variation of the Vbias + [MZ_Input_Sdata] = Set_MZ_Input_Data_Simp(S,L,U0,U_pi1,U_pi2,eta1,... %Functionresponsible to create the input files + eta2,nopt,nel,alfa_ins,phi_0,alfa0,Local); + S = S+1; +end +% clear L U0 U_pi1 U_pi2 eta1 eta2 nopt nel alfa_ins phi_0 alfa0 C alfa0 \ No newline at end of file diff --git a/Ring_Resonator/MeasPower.m b/Ring_Resonator/MeasPower.m new file mode 100644 index 0000000..5106135 --- /dev/null +++ b/Ring_Resonator/MeasPower.m @@ -0,0 +1,18 @@ +function [ThisPower,ThisPowerdBm] = MeasPower(Ein,t,InfLim,UpeLim) +%% + if nargin<2 + t = linspace(0,length(Ein),length(Ein)); + InfLim = t(1); + UpeLim = t(end); + elseif nargin<3 + InfLim = t(1); + UpeLim = t(end); + end + + ThisPower = sum(abs(Ein(find(t==InfLim):find(t==UpeLim))).^2)/(... + length(Ein(find(t==InfLim):find(t==UpeLim)))); + if nargout == 2 + ThisPowerdBm = 30 + 10*log10(ThisPower); + end + +end \ No newline at end of file diff --git a/Ring_Resonator/OpticalFFTN.m b/Ring_Resonator/OpticalFFTN.m new file mode 100644 index 0000000..fa25806 --- /dev/null +++ b/Ring_Resonator/OpticalFFTN.m @@ -0,0 +1,227 @@ +function [Eout,Count,MapVet]=OpticalFFTN(f,SymPer,StopPoint,E1,AngVec,... + ActStag,Count,E0,MapVet) +%% All Optical Fast Furier Transform for N carriers +%c function [Eout,Count,MapVet]=OpticalFFTN(t,SymPer,StopPoint,E1,... +%c AngVec,ActStag,Count,E0,MapVet) +%c This function is responsible for implementing an all-optical FFT. It +%c is possíble to create an FFT of any size. Albeit, one must understand +%c it’s limitations such as the granularity problem. This process takes on +%c account angel from 0 to 180 degrees and this interval is divided by 2 to +%c the power of N where N is the order of the FFT. For instance, if the +%c user need to filter 32 carriers it will have an FFT process of order 5 +%c hence the interval will be 5.6250, therefore in practice to implement +%c the MZI it needs to accurately create phase delays spaced of 5.6250. +%c Another problem is, the carriers are shuffled by this FFT, and for a +%c perfect FFT implementation, the exact phase delay must be added to the +%c right signal at the right time. This function also returns a vector map +%c that indicates where each carrier is, thus the user can use this vector +%c to correctly extract the right carrier. The following illustration +%c better demonstrates the output mapping vector for an FFT of order 5. +%c +%c Ein : Is the input fild +%c MZI : Is the Mach-Zehnder Interferometre +%c Nº : The number are each carrier from 1 to 32 within Ein +%c +%c /1 +%c (MZI) +%c / 1 \17 +%c (MZI) +%c / \ 9 /9 +%c / 1 (MZI) +%c (MZI) \25 +%c / \ 5 /5 +%c / \ (MZI) +%c / \ / 5 \21 +%c / (MZI) +%c / \ 13 /13 +%c / 1 (MZI) +%c (MZI) \29 +%c / \ 3 /3 +%c / \ (MZI) +%c / \ / 3 \19 +%c / \ (MZI) +%c / \ / \ 11 /11 +%c / \ / 3 (MZI) +%c / (MZI) \27 +%c / \ 7 /7 +%c / \ (MZI) +%c / \ / 7 \23 +%c / (MZI) +%c / \ 15 /15 +%c / (MZI) +%c / 1 \31 +%cEin---(MZI) +%c \ 2 /2 +%c \ (MZI) +%c \ / 2 \18 +%c \ (MZI) +%c \ / \ 10 /10 +%c \ / 2 (MZI) +%c \ (MZI) \26 +%c \ / \ /6 +%c \ / \ 6 (MZI) +%c \ / \ / 6 \22 +%c \ / (MZI) +%c \ / \ 14 /14 +%c \ / 2 (MZI) +%c (MZI) \30 +%c \ 4 /4 +%c \ (MZI) +%c \ / 4 \20 +%c \ (MZI) +%c \ / \ 12 /12 +%c \ / 4 (MZI) +%c (MZI) \28 +%c \ 8 /8 +%c \ (MZI) +%c \ / 8 \24 +%c (MZI) +%c \ 16 /16 +%c (MZI) +%c \32 +%c Each MZI vertically aligned correspond to one Stage of the OFFT. +%c +%c +%c +%c +%c +%c Created by P.Marciano LG +%c 11/01/2018 +%c Last UpDate +%c 12/01/2018 +%c pablorafael.mcx@gmail.com +%c +%c Refences: +%c@article{hillerkuss2010simple, +%c title={Simple all-optical FFT scheme enabling Tbit/s real-time signal processing}, +%c author={Hillerkuss, D and Winter, M and Teschke, M and Marculescu, A and Li, J and Sigurdsson, G and Worms, K and Ezra, S Ben and Narkiss, N and Freude, W and others}, +%c journal={Optics express}, +%c volume={18}, +%c number={9}, +%c pages={9324--9340}, +%c year={2010}, +%c publisher={Optical Society of America} +%c} +%c +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%cEout,Count,MapVet]=OpticalFFTN(t,SymPer,StopPoint,E1,AngVec,... + % ActStag,Count,E0,MapVet) +%c OpticalFFT +%c +%c Input: +%c t : Time vector of the whole simulation [s] +%c SymPer : Symble Period [s] +%c StopPoint : Maximum number of stages need [u] +%c E1 : Actual input field for the FFT [-] +%c AngVec : Brings the phase shifft for the current stage [rad] +%c ActStag : Current interaction stage [u] +%c Count : variable to control the expansion of the phase delay [u] +%c E0 : Signal is equal to zero if not otherwise given [-] +%c MapVet : Map vector to locate the actual carriers at the output [u] +%c +%c Output: +%c Eout : Final and partial output signal [-] +%c Count : variable to control the expansion of the phase delay [u] +%c MapVet : Map vector to locate the actual carriers at the output [u] +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%% +% At the very first part of this iscript, it is necessary to be sure that +% all variable that will be used are needed to be correctly initialized. +% In addition, this function is called recursivaly. Thus, it is important +% to think in all possible steps . + + if nargin<4 || nargin==5 || nargin==6 + %If the input argument is underspecified an error will be displayed + error(['Input Arguments are not enougth. Please check this ' + 'function Call!']); + + elseif nargin == 4%The minimum input arguments required. + AngVec = 0; %The first angle is zero + ActStag = 1; %For the FFT at it's first order + Count = ones(1,StopPoint); %Control variable initialized + E0 = zeros(1,length(E1)); %Variable for the second input of the MZI + MapVet = 1; %At the stage 1 the first carrier is 1 + elseif nargin<8 + E0 = zeros(1,length(E1)); %Variable for the second input of the MZI + MapVet = 1; %At the stage 1 the first carrier is 1 + elseif nargin<9 + MapVet = 1; %At the stage 1 the first carrier is 1 + end + + %% Delay Interferometer +% There is where the magic of this sistme happens. Basically saying, +% by given the time signal a time delay and a phase delay. Those two +% parameters will not affect the data. But when the input signal is +% divided half of it passes through a light path and it is not changed. +% The second half will pass through another light path and through the +% application of a voltage it is possible to delay the signal by +% changing material characteristics. As a result, the second signal will +% have time and phase differences from the other signal. When those two +% components combine again at the end to DI there will be constructive +% and destructive results in both signals. At the end, the DI outputs +% two signals where one carrier the even components of the sub-carries +% and the other carriers the odd components of the input signal. Thus, +% it was implemented the first step of the Optical FFT. + + TimDel = SymPer/(2^ActStag); %Create the time delay + PhaDel = AngVec(Count(ActStag)); %Acquiring the time delay + [Eout1,Eout2] = DelayInterfExp(f,TimDel,PhaDel,E1,E0); %Sends the input signal to the DI + + Count(ActStag) = Count(ActStag) + 1; %Takin in account the current interaction + ActStag = ActStag + 1; %Marking the occurence of the current stage + + %% Checking for recursivity +% At this point it is needed to evaluate in which interaction the program +% is and if it gets to an end. As stop criteria, the variable ActStag, +% indicates in wich stage the script is hence when the value of Actstag is +% equal to the StopPoint, which means that the number of stages for the +% program It has got to an end. + if ActStag>StopPoint + MapVet = [MapVet MapVet+2^(ActStag-2)]; + Eout = [Eout1;Eout2]; + else%Otherwise move to the next stage + n = ActStag-1; %Auxiliar variable to calculate the step + MyStep = pi/(2^n); %Step for the phase delay + AngVec = [AngVec AngVec+MyStep]; %Calculating the phase delay for this current interaction + Vetaux = MapVet+2^(ActStag-2); %Calculating the carrier of thie current interaction + + [EoutAux1,Count,MyVetAux1] = OpticalFFTN(f,SymPer,StopPoint,... + Eout2,AngVec,ActStag,Count,E0,Vetaux);%Calculating the next interaction of the FFT + [EoutAux2,Count,MyVetAux2] = OpticalFFTN(f,SymPer,StopPoint,... + Eout1,AngVec,ActStag,Count,E0,MapVet);%Calculating the next interaction of the FFT + + MapVet = [MyVetAux2 MyVetAux1]; %Storing the received mapping vector. + Eout = [EoutAux2;EoutAux1]; %Storing the received Output from the FFT. + end +end + +% while Stage<=StopPoint +% +% % else +% n = Stage-1; +% m = length(AngVec); +% MyStep = pi/(2^n); +% MyVec = zeros(1,2^n); +% MyVec(1:m) = AngVec; +% for kk=1:m +% MyVec(m+kk) = AngVec(kk) + MyStep; +% MyVec.*(180/pi) +% a=2; +% end +% AngVec = MyVec; +% Stage = Stage + 1; +% % Eout = expfunc(Stage,AngVec,StopPoint); +% end \ No newline at end of file diff --git a/Ring_Resonator/README.asv b/Ring_Resonator/README.asv new file mode 100644 index 0000000..51556d0 --- /dev/null +++ b/Ring_Resonator/README.asv @@ -0,0 +1,4 @@ +# integrate-optics +This repository will be used for developing coding in different software for creating and testing optical devices that will be used integrated with electronic circuits. + +This is a first draft, later on this file will be modified to better explaing the projects here under development. diff --git a/Ring_Resonator/README.md b/Ring_Resonator/README.md new file mode 100644 index 0000000..435fa1f --- /dev/null +++ b/Ring_Resonator/README.md @@ -0,0 +1,6 @@ +# integrate-optics +This repository will be used for developing coding in different software for creating and testing optical devices that will be used integrated with electronic circuits. + +This is a first draft, later on this file will be modified to better explaing the projects here under development. + +It is important to add the "matlab_tools" folder to the path directory of your matlabt for the codes here to proper work. diff --git a/Ring_Resonator/Ring_Resonator_Singlebus.m b/Ring_Resonator/Ring_Resonator_Singlebus.m new file mode 100644 index 0000000..e269118 --- /dev/null +++ b/Ring_Resonator/Ring_Resonator_Singlebus.m @@ -0,0 +1,62 @@ +function [Eout,Edrop,Tout]=Ring_Resonator(lambda,Ein,V0) + +neff = 2.61; +Rlength = 10e-6*2*pi; +alpha = -log(10^(-7/10)); +a = exp(-alpha*Rlength/2); +k = 0.274; +r = sqrt(1-k^2); +gap = 10e-6; + +neff = 4.18 - (900000.*lambda); + +%mode=0, Ring Resonator +%mode=1, Ring Resonator Modulator +mode=1; +if (mode==0) + + Beta=(2*pi*neff)./(lambda); + teta=(Beta.*Rlength); + +elseif (mode==1) + + Beta=(2*pi*neff)./(lambda); + Vpi=7; + teta = (Beta.*Rlength)+((pi*V0*0.88)/Vpi); + +end + + +%type=0, Ring Resonator all-pass +%type=1, Ring Resonator add-drop +type=0; +if (type==0) + +% Eout = Ein.*((r-a*exp(j*teta)))./(1-conj(r)*a*exp(j*teta)); + +% Eout = Ein.*(exp(1j*(pi+teta)).*((a-r*exp(-1j*teta))./(1-r*a*exp(1j*teta)))); + + Eout = Ein.*((-sqrt(a)+r*exp(-1j*teta)) ./ (-sqrt(a)*conj(r)+exp(-1j*teta))); + +% Tout = Ein.*(((a^2)+(r^2)-(2*a*r*cos(teta)))./(1+((r*a)^2)-(2*a*r*cos(teta)))); + + Tout = 0; + + Edrop = 0; + +elseif (type==1) + + Eout=(r-conj(r)*sqrt(a)*exp(1j*teta)) ./ (1-sqrt(a)*(conj(r)^2).*exp(1j*teta)); + + Edrop=(conj(k)*conj(k)*sqrt(a*exp(1j*teta))) ./ (1-sqrt(a)*conj(r)^2*exp(1j*teta)); + + Tout=0; + +end + + + + + + + diff --git a/Ring_Resonator/Set_MZ_Input_Data_Simp.m b/Ring_Resonator/Set_MZ_Input_Data_Simp.m new file mode 100644 index 0000000..5bc4cb6 --- /dev/null +++ b/Ring_Resonator/Set_MZ_Input_Data_Simp.m @@ -0,0 +1,76 @@ +function [ FileName ] = Set_MZ_Input_Data( FileIdex,L,U0,U_pi1,U_pi2,... + eta1,eta2,nopt,nel,alfa_ins,phi_0,alfa0,Local) +%% %c Generate Input Files for MZM +%c +%c function [ FileName ] = Set_MZ_Input_Data( FileIdex,L,U0,U_pi1,U_pi2,... +%c eta1,eta2,nopt,nel,alfa_ins,phi_0,alfa0,Local) +%c +%c by P.Marciano LG +%c 5/10/2017 +%c pablorafael.mcx@gmail.com +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Generator of Input File for the Modulador Mach-Zehnder +%c +%c Input: +%c FileIdex : Number of the file in the sequence given by variable S +%c L : Comprimento do dispositivo [cm] +%c U0 : Tensao de polarizacao [V] +%c eletrodes : Numero de eletrodos (1,2). Definido pelo numero de +%c variaveis de entrada na funcao Mach_Zehnder_Modulator +%c U_pi1 : Tensao de chaveamento para 1 eletrodo [V] +%c U_pi2 : Tensao de chaveamento para 2 eletrodos [V] +%c eta1 : Sensibilidade no caminho 1 [1/V.m] +%c eta2 : Sensibilidade no caminho 2 [1/V.m] +%c nopt : Indice de refracao optico +%c nel : Indice de refracao eletrico +%c alfa_ins : Perda por insercao [dB] +%c phi_0 : Constante de fase entre os dois caminhos +%c alfa0 : Perda condutiva [dB/cm.GHz^0.5] +%c Local : Variavél onde os arquivos serão salvos +%c +%c Output: +%c FileName : Nome do arquivo gerado +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%% +if nargin==12 %Verify if the storage folder was passed to this function + Local = [pwd '\'];%if not the files will be saved on the current folder +elseif nargin<12%Verify if there is all parameters needed +error('Not enough input arguments for Set_MZ_Input_Data'); +end + +%Location and name of the input file to be created +Name = [Local 'AA_MZ_Input_Data_t' num2str(FileIdex) '.m']; +fid = fopen( Name, 'wt' ); +ContTimeOut = toc; +while(fid<3) + if ((toc-ContTimeOut)/60)>5 + break; + end + fid = fopen( Name, 'wt' ); +end +%opening the file or creating it +%writing in the file the parameters passed to this function +fprintf( fid, '%6.2f\n',L); +fprintf( fid, '%6.3f\n',U0); +fprintf( fid, '%6.2f\n',U_pi1); +fprintf( fid, '%6.2f\n',U_pi2); +fprintf( fid, '%6.2f\n',eta1); +fprintf( fid, '%6.2f\n',eta2); +fprintf( fid, '%6.2f\n',nopt); +fprintf( fid, '%6.2f\n',nel); +fprintf( fid, '%6.2f\n',alfa_ins); +fprintf( fid, '%6.2f\n',phi_0); +fprintf( fid, '%6.2f\n',alfa0); + +fclose(fid);%closing the file + +FileName = ['MZ_Input_Data_t' num2str(FileIdex)];%Passing out the file +end \ No newline at end of file diff --git a/Ring_Resonator/main.m b/Ring_Resonator/main.m new file mode 100644 index 0000000..b8d811a --- /dev/null +++ b/Ring_Resonator/main.m @@ -0,0 +1,62 @@ +clear all; +clc; + +Local = [pwd '\input_files\']; +MZ_Input_File ='MZ_Input_Data'; +MZ_Input_Data; + +nNyx = 2^10; +fc = 12.5e9; +T = 1/fc; +nT = 10; +tf = T*nT +t = linspace(0,tf,nNyx*nT); +f = time2freq(t); + +lambda = linspace(1500*1e-9,1600*1e-9,nNyx*nT) + +% lambda = 1500*1e-9; + +Ein = ones(1,length(t)); + +% Sinal = randint(1,nT,2); +Sinal = [0 0 0 0 1 1 0 0 0 0]; +% Sinal(Sinal==0)= -1; +Sinalret = rectpulse(Sinal,nNyx); +Sinal_steps = length(Sinalret); + +for i=-2:0.5:0 + + V0 = i + (0*sin(2*pi*fc*t)); + [Eout,Edrop,Tout] = Ring_Resonator_Singlebus(lambda,Ein,V0); + plot(lambda,Eout); + hold on + axis([1500e-9 1600e-9 -1.5 1.5]); + xlabel('wavelength') + ylabel('Eout') + +end + + + +% [Eout,Edrop,Tout] = Ring_Resonator_Singlebus(lambda,Ein,V0); +% load C:/Users/Thiago/Desktop/testestets.mat; +% ax1 = axes; +% lum.x0 = lum.x0*10^-9; +% lum.y0 = (lum.y0-min(lum.y0))/(max(lum.y0)-min(lum.y0)); +% Eout = (Eout-min(Eout))/(max(Eout)-min(Eout)); +% plot(lum.x0,lum.y0) +% % plot(lambda,Eout,lum.x0,lum.y0); +% axis([1500e-9 1600e-9 -0.5 1.5]); +% % legend('MatLab','Lumerical'); +% xlabel('Wavelength') +% ylabel('Eout normalizado') + + + +% plot(f,Tout); +% axis([-8e7 8e7 -2 2]); + + + + diff --git a/Ring_Resonator/main_inputdata.asv b/Ring_Resonator/main_inputdata.asv new file mode 100644 index 0000000..1d4b3cc --- /dev/null +++ b/Ring_Resonator/main_inputdata.asv @@ -0,0 +1,100 @@ +%c +%c ..'Ž`'..'Ž`..'Ž`.. +%c File: main_inputdata +%c +%c This code is used to set up the input parameters that will be used +%c in the whole simualation. +%c +%c +%c +%c +%c +%c by P.Marciano LT +%c 04/11/2019 +%c pablorafael.mcx@gmail.com +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c +%c +%c t :This is the time vector for your simulation, it +%c will run just as much periods of your signal you +%c need and/or want to simulate. [s] +%c f :This is the frequency vector for your simulation, it +%c will run just as much periods of your signal you need +%c and/or want to simulate. [Hz] +%c Po :The power of the signal [w] +%c Eo_CW :This is the Amplitude of the signal [V] +%c nsamp :numpre of up sampling [-] +%c M :Order of Gausian filter [-] +%c m :Modulation number [-] +%c k :Number of bits per simble [-] +%c p :Auxiliar variable to store the current directory [-] +%c Local :It stores where the files for the MZM will be stored [-] +%c L :Comprimento do dispositivo [cm] +%c U0 :Tensao de polarizacao [V] +%c eletrodes :Numero de eletrodos (1,2). Definido pelo +%c numero de variaveis de entrada na funcao +%c Mach_Zehnder_Modulator [-] +%c U_pi1 :Tensao de chaveamento para 1 eletrodo [V] +%c U_pi2 :Tensao de chaveamento para 2 eletrodos [V] +%c eta1 :Sensibilidade no caminho 1 [1/V.m] +%c eta2 :Sensibilidade no caminho 2 [1/V.m] +%c nopt :Indice de refracao optico [-] +%c nel :Indice de refracao eletrico [-] +%c alfa_ins :Perda por insercao [dB] +%c phi_0 :Constante de fase entre os dois caminhos [-] +%c alfa0 :Perda condutiva [dB/cm.GHz^0.5] +%c C :Parametro de chirp [-] +%c +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c Here it will be added the functions that this code will call +%c +%c +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Start of the Program % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +close all; clc; clear; +%% +% Variable of the program + +fc = 1e9; % Center frequency of the optical carrier +Nyq = 2^4; % Nyquest number +F = 1e6; % Center frequency of the electrical signal +T = 1/F; % Electrical signal Period +NuT = 2^4; % Number of periods of the electrical signal on this simulation +tf = NuT*T; % Final time of this simulation +Fa = Nyq*fc; % Sampling Ratio of the electrical signal +Ta = 1/Fa; % Sampring period of the electrical signal +NumPon = tf/Ta;% Total number of points for this simulation +t = linspace(0,tf,NumPon+1); % Time vector for this simulation +f = time2freq(t); % Frequency vector for this simulation +Cw = ones(1,length(t)); +Amp1 = 1; % Amplitudo of the electrical signal +Amp2 = 1; % Amplitudo of the electrical signal + +pha1 = 90*pi/180; +pha2 = 180*pi/180; + +ElecSing.U1t = Amp1.*sin(2*pi*F*t + pha1); +ElecSing.U2t = Amp2.*sin(2*pi*F*t + pha2); + +figure; +plot(t,seno); + +figure +plot((f),20*log10(abs(fftshift(fft(seno)./length(seno)))),(f),20*log10(abs(fftshift(fft(Cw)./length(Cw))))) + + +a=1; \ No newline at end of file diff --git a/Ring_Resonator/main_inputdata.m b/Ring_Resonator/main_inputdata.m new file mode 100644 index 0000000..765f0bb --- /dev/null +++ b/Ring_Resonator/main_inputdata.m @@ -0,0 +1,122 @@ +%c +%c ..'Ž`'..'Ž`..'Ž`.. +%c File: main_inputdata +%c +%c This code is used to set up the input parameters that will be used +%c in the whole simualation. +%c +%c +%c +%c +%c +%c by P.Marciano LT +%c 04/11/2019 +%c pablorafael.mcx@gmail.com +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c +%c +%c t :This is the time vector for your simulation, it +%c will run just as much periods of your signal you +%c need and/or want to simulate. [s] +%c f :This is the frequency vector for your simulation, it +%c will run just as much periods of your signal you need +%c and/or want to simulate. [Hz] +%c Po :The power of the signal [w] +%c Eo_CW :This is the Amplitude of the signal [V] +%c nsamp :numpre of up sampling [-] +%c M :Order of Gausian filter [-] +%c m :Modulation number [-] +%c k :Number of bits per simble [-] +%c p :Auxiliar variable to store the current directory [-] +%c Local :It stores where the files for the MZM will be stored [-] +%c L :Comprimento do dispositivo [cm] +%c U0 :Tensao de polarizacao [V] +%c eletrodes :Numero de eletrodos (1,2). Definido pelo +%c numero de variaveis de entrada na funcao +%c Mach_Zehnder_Modulator [-] +%c U_pi1 :Tensao de chaveamento para 1 eletrodo [V] +%c U_pi2 :Tensao de chaveamento para 2 eletrodos [V] +%c eta1 :Sensibilidade no caminho 1 [1/V.m] +%c eta2 :Sensibilidade no caminho 2 [1/V.m] +%c nopt :Indice de refracao optico [-] +%c nel :Indice de refracao eletrico [-] +%c alfa_ins :Perda por insercao [dB] +%c phi_0 :Constante de fase entre os dois caminhos [-] +%c alfa0 :Perda condutiva [dB/cm.GHz^0.5] +%c C :Parametro de chirp [-] +%c +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c Here it will be added the functions that this code will call +%c +%c +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Start of the Program % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +close all; clc; clear; +%% Files parameters +p = pwd; %Geting the current path of the main program +Local = [p '\input_files\'];%variable that shows where the input files for + %the mzm will be saved + +%% MZM Parameters +MZ_Input_Data; %Loading the basic data to be saved +L = 10.00; +% U0 = 2.390; +U_pi1 = 3.80; +U_pi2 = 3.80; +eta1 = 89.00;%1;% +eta2 = -12.70;%-1;% +nopt = 2.17; +nel = 2.60; +alfa_ins = 5.10; +phi_0 = 0.00; +alfa0 = 1.07; +% C = (eta1+eta2)/(eta1-eta2); +% alfa0 = 10^(alfa0/20); + +%% Variable of the program +fc = 1e9; % Center frequency of the optical carrier +Nyq = 2^4; % Nyquest number +F = 1e6; % Center frequency of the electrical signal +T = 1/F; % Electrical signal Period +NuT = 2^4; % Number of periods of the electrical signal on this simulation +tf = NuT*T; % Final time of this simulation +Fa = Nyq*fc; % Sampling Ratio of the electrical signal +Ta = 1/Fa; % Sampring period of the electrical signal +NumPon = tf/Ta;% Total number of points for this simulation +t = linspace(0,tf,NumPon+1); % Time vector for this simulation +f = time2freq(t); % Frequency vector for this simulation +Cw = ones(1,length(t)); +Amp1 = 1; % Amplitudo of the electrical signal +Amp2 = 1; % Amplitudo of the electrical signal + +pha1 = 90*pi/180; % Phase of the electrical signal +pha2 = 180*pi/180; % Phase of the electrical signal + +ElecSing.U1t = Amp1.*sin(2*pi*F*t + pha1); % One modulating electrical signal +ElecSing.U2t = Amp2.*sin(2*pi*F*t + pha2); % Other modulating electrical signal + +Vbias = -8:0.1:8; % Polarizatin voltage +Vbias_steps = length(Vbias); % The total number of different polarizations + +figure; +plot(t,ElecSing.U1t,t,ElecSing.U2t); + +figure +plot((f),20*log10(abs(fftshift(fft(ElecSing.U1t)./length(ElecSing.U1t)))),(f),20*log10(abs(fftshift(fft(ElecSing.U2t)./length(ElecSing.U2t)))),(f),20*log10(abs(fftshift(fft(Cw)./length(Cw))))) + + +a=1; \ No newline at end of file diff --git a/Ring_Resonator/matlab_tools/Import_Data_MZM.m b/Ring_Resonator/matlab_tools/Import_Data_MZM.m new file mode 100644 index 0000000..73064e9 --- /dev/null +++ b/Ring_Resonator/matlab_tools/Import_Data_MZM.m @@ -0,0 +1,107 @@ +function [L,U0,U_pi1,U_pi2,eta1,eta2,nopt,nel,alfa_ins,phi_0,C,alfa0] = ... + Import_Data_MZM (FileIndex,Local) +%% Import data from text file. +%cfunction [L,U0,U_pi1,U_pi2,eta1,eta2,nopt,nel,alfa_ins,phi_0,C,alfa0]=... +%c Import_Data_MZM (FileIndex,Local) +%c Script for importing data from the following text file: +%c +%c [pwd '\input_files\AA_MZ_Input_Data_t' num2str(FileIndex) '.m']; +%c +%c To extend the code to different selected data or a different text file, +%c generate a function instead of a script. +%c +%c Auto-generated by MATLAB on 2017/10/04 11:05:03 +%c +%c +%c +%c Updated by P.Marciano LG +%c 18/10/2017 +%c pablorafael.mcx@gmail.com +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Import_Data_MZM +%c +%c Input: +%c FileIndex : Indentifier of the file to be load into the workspace [-] +%c Local : Current path for the location of the files [-] +%c +%c Output: +%c L : Comprimento do dispositivo [cm] +%c U0 : Tensao de polarizacao [V] +%c U_pi1 : Tensao de chaveamento para 1 eletrodo [V] +%c U_pi2 : Tensao de chaveamento para 2 eletrodos [V] +%c eta1 : Sensibilidade no caminho 1 [1/V.m] +%c eta2 : Sensibilidade no caminho 2 [1/V.m] +%c nopt : Indice de refracao optico [-] +%c nel : Indice de refracao eletrico [-] +%c alfa_ins : Perda por insercao [dB] +%c phi_0 : Constante de fase entre os dois caminhos [-] +%c C : Parametro de chirp [?] +%c alfa0 : Perda condutiva [dB/cm.GHz^0.5] +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%% +%% Initialize variables. +if nargin<2 %Check if there is a specific laction to look for the files + filename = [pwd '\input_files\AA_MZ_Input_Data_t' num2str(FileIndex)...%If not assume that there is a input_files folder + '.m']; +else + filename = [Local 'AA_MZ_Input_Data_t' num2str(FileIndex) '.m']; %If yes, open the files on the given path +end +delimiter = ' '; + +%% Format string for each line of text: +% column1: double (%f) +% For more information, see the TEXTSCAN documentation. +formatSpec = '%f%[^\n\r]'; + +%% Open the text file. +fileID = fopen(filename,'r'); + +%% Read columns of data according to format string. +% This call is based on the structure of the file used to generate this +% code. If an error occurs for a different file, try regenerating the code +% from the Import Tool. +dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, ... + 'MultipleDelimsAsOne', true, 'ReturnOnError', false); + +%% Close the text file. +fclose(fileID); + +%% Post processing for unimportable data. +% No unimportable data rules were applied during the import, so no post +% processing code is included. To generate code which works for +% unimportable data, select unimportable cells in a file and regenerate the +% script. + +%% Allocate imported array to column variable names +VarName1 = dataArray{:, 1}; + +L = VarName1(1); +U0 = VarName1(2); +U_pi1 = VarName1(3); +U_pi2 = VarName1(4); +eta1 = VarName1(5); +eta2 = VarName1(6); +nopt = VarName1(7); +nel = VarName1(8); +alfa_ins = VarName1(9); +phi_0 = VarName1(10); +alfa0 = VarName1(11); + +C = (eta1+eta2)/(eta1-eta2); % Parametro de chirp +alfa0 = 10^(alfa0/20); % [1/cm.GHz^0.5] + + +%% Clear temporary variables +clearvars filename delimiter formatSpec fileID dataArray ans; \ No newline at end of file diff --git a/Ring_Resonator/matlab_tools/MZ_Input_Data.m b/Ring_Resonator/matlab_tools/MZ_Input_Data.m new file mode 100644 index 0000000..2f31df0 --- /dev/null +++ b/Ring_Resonator/matlab_tools/MZ_Input_Data.m @@ -0,0 +1,72 @@ +%c +%c ..'Ž`'..'Ž`..'Ž`.. +%c +%c Arquivo de entrada usado pela funcao Mach_Zehnder_Modulator. Contem +%c informacoes sobre as caracteristicas fisicas do modulador Mach-Zehnder. +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c L : Comprimento do dispositivo [cm] +%c U0 : Tensao de polarizacao [V] +%c eletrodes : Numero de eletrodos (1,2). Definido pelo +%c numero de variaveis de entrada na funcao +%c Mach_Zehnder_Modulator +%c U_pi1 : Tensao de chaveamento para 1 eletrodo [V] +%c U_pi2 : Tensao de chaveamento para 2 eletrodos [V] +%c eta1 : Sensibilidade no caminho 1 [1/V.m] +%c eta2 : Sensibilidade no caminho 2 [1/V.m] +%c nopt : Indice de refracao optico +%c nel : Indice de refracao eletrico +%c alfa_ins : Perda por insercao [dB] +%c phi_0 : Constante de fase entre os dois caminhos +%c alfa0 : Perda condutiva [dB/cm.GHz^0.5] +%c +%c by M.Segatto, S. Cani, B. Jesus e A. Togneri +%c 04/09/2002 +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +% + +L = 10; +U0 = 1.900; +U_pi1 = 3.8; +U_pi2 = 3.8; +eta1 = 89;% 89; +eta2 =-12.7;%-12.7; +% +nopt = 2.17; +nel = 2.60; +alfa_ins = 5.1; +phi_0 = 0.0; +alfa0 = 0.55; + +C = (eta1+eta2)/(eta1-eta2); % Parametro de chirp +alfa0 = 10^(alfa0/20); % [1/cm.GHz^0.5] + + +% +% L = 10; +% U0 = 0; +% U_pi1 = 0; +% U_pi2 = 0; +% eta1 = 89; +% eta2 = -12.7; +% % +% nopt = 1; +% nel = 2; +% alfa_ins = 5.1; +% phi_0 = 0.0; +% alfa0 = 0.55; +% % +% C = (eta1+eta2)/(eta1-eta2); % Parametro de chirp +% alfa0 = 10^(alfa0/20); % [1/cm.GHz^0.5] diff --git a/Ring_Resonator/matlab_tools/Mach_Zehnder_Modulator_simplificado.m b/Ring_Resonator/matlab_tools/Mach_Zehnder_Modulator_simplificado.m new file mode 100644 index 0000000..3b33e48 --- /dev/null +++ b/Ring_Resonator/matlab_tools/Mach_Zehnder_Modulator_simplificado.m @@ -0,0 +1,96 @@ +function [Eout,H] = Mach_Zehnder_Modulator_simplificado(t,Ein,U,MZ_Input_File) +%c +%c function [Eout,H] = Mach_Zehnder_Modulator(t,Ein,U1t,U2t,MZ_Input_File); +%c +%c This script is responsible to reproduce the output field of a MZM +%c modulator of one or two arms depending on the inputs. +%c +%c +%c Updated by P.Marciano LG +%c 18/09/2017 +%c pablorafael.mcx@gmail.com +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Modulador Mach-Zehnder +%c +%c Entrada: +%c t : Vetor de tempo [s] +%c Ein : Campo Eletrico de Entrada [V/m] +%c (dominio do tempo) +%c U1t : Tensao de entrada no braco 1 do modulador [V] +%c (dominio do tempo) +%c U2t : Tensao de entrada no braco 2 do modulador [V] +%c (dominio do tempo) +%c MZ_Input_File :Arquivo de entrada contendo parametros do modulador +%c +%c Saida +%c Eout : Campo Eletrico optico modulado no tempo [V/m] +%c H : Funcao de tranferencia eletrica do modulador +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Usa: time2freq_lamb +%% +if (nargin <= 3), + MZ_Input_File ='MZ_Input_Data'; + load([MZ_Input_File '.m']); +else + [L,U0,U_pi1,U_pi2,~,~,nopt,nel,~,~,C,alfa0] = Import_Data_MZM (... + MZ_Input_File);%Import the data from files +end +if isstruct(U), + electrodes = 2; % Two arms modulator + U1t = U.U1t; + U2t = U.U2t; + U_pi = U_pi2; +else + electrodes = 1; % One arm modulator + U1t = U; + U_pi = U_pi1; +end +% +tps = t/1E-12; +ccmns = 30; % Velocidade da luz [cm/ns] +freqTHz = time2freq_lamb(tps); +freqGHz = freqTHz*1e-3; % Frequencia em GHz +freqGHz = -fftshift(freqGHz); +freqGHz(1) = freqGHz(2); +n = length(U1t); % Tamanho de U1t +% + +%%%%%%% FUNCAO DE TRANSFEWRENCIA ELETRICA DO MODULADOR %%%%%%%%%%% +% +alfaf = 0.5*alfa0*(abs(freqGHz).^0.5); +gamaf = 2*pi*abs(freqGHz).*(nel - nopt)/ccmns; +atn = alfaf + 1j*gamaf; +H = (1./(atn*L)).*(1 - exp(-atn*L)); +% +if (electrodes == 1), + U1f = fft(U1t); + U1t = real(ifft(U1f.*H)); + exp1 = exp(1j*C*(pi/2).*(U1t/U_pi)); + if C~=0 + Eout = Ein.*cos((pi/2).*(U1t - U0)/U_pi).*exp1; + else + Eout = Ein.*cos((pi/2).*(U1t - U0)/U_pi); + end +else + U1f = fft(U1t); + U1t = ifft(U1f.*H); + U2f = fft(U2t); + U2t = ifft(U2f.*H); + %The final part of the following equation is the Chirp parameter and it + %should not be removed, because it will be the key parameter to create + %the optical carriers at the same level. + Eout = Ein.*cos((pi/2).*(U1t - U2t - U0)/U_pi).*exp(-1j*(pi/2).*((U1t + U2t)/U_pi)); +end diff --git a/Ring_Resonator/matlab_tools/Make_MZ_Input_Files_Simp.m b/Ring_Resonator/matlab_tools/Make_MZ_Input_Files_Simp.m new file mode 100644 index 0000000..f5b43b1 --- /dev/null +++ b/Ring_Resonator/matlab_tools/Make_MZ_Input_Files_Simp.m @@ -0,0 +1,45 @@ +%c +%c ..'Ž`'..'Ž`..'Ž`.. +%c File: Make_MZ_Input_Files_Simp +%c(Creating the input file necessary for the MZM) +%c +%c This main code is resposible to call and load the right parameters +%c to be saved in a file for latter be used by the MZM +%c +%c +%c by P.Marciano LG +%c 18/08/2017 +%c Last UpDate +%c 23/12/2017 +%c pablorafael.mcx@gmail.com +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c Here it will be added the functions that this code will call +%c +%c +%c Set_MZ_Input_Data. - Function that will create and load the files with +%c the given in data. +%c +%c +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Start of the Program % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +S=1; %Variabel that give the name for the input file +for Inc2=1:Vbias_steps%Secundary loop for the possible combinations + U0 = Vbias(Inc2);%Variation of the Vbias + [MZ_Input_Sdata] = Set_MZ_Input_Data_Simp(S,L,U0,U_pi1,U_pi2,eta1,... %Functionresponsible to create the input files + eta2,nopt,nel,alfa_ins,phi_0,alfa0,Local); + S = S+1; +end +% clear L U0 U_pi1 U_pi2 eta1 eta2 nopt nel alfa_ins phi_0 alfa0 C alfa0 \ No newline at end of file diff --git a/Ring_Resonator/matlab_tools/MeasPower.m b/Ring_Resonator/matlab_tools/MeasPower.m new file mode 100644 index 0000000..bff9e1c --- /dev/null +++ b/Ring_Resonator/matlab_tools/MeasPower.m @@ -0,0 +1,18 @@ +function [ThisPower,ThisPowerdBm] = MeasPower(Ein,t,InfLim,UpeLim) +%% + if nargin<2 + t = linspace(0,length(Ein),length(Ein)); + InfLim = t(1); + UpeLim = t(end); + elseif nargin<3 + InfLim = t(1); + UpeLim = t(end); + end + + ThisPower = sum(abs(Ein(find(t==InfLim):find(t==UpeLim))).^2)/(... + length(Ein(find(t==InfLim):find(t==UpeLim)))); + if nargout == 2 + ThisPowerdBm = 30 + 10*log10(ThisPower); + end + +end \ No newline at end of file diff --git a/Ring_Resonator/matlab_tools/Set_MZ_Input_Data_Simp.m b/Ring_Resonator/matlab_tools/Set_MZ_Input_Data_Simp.m new file mode 100644 index 0000000..ac4c2ae --- /dev/null +++ b/Ring_Resonator/matlab_tools/Set_MZ_Input_Data_Simp.m @@ -0,0 +1,76 @@ +function [ FileName ] = Set_MZ_Input_Data( FileIdex,L,U0,U_pi1,U_pi2,... + eta1,eta2,nopt,nel,alfa_ins,phi_0,alfa0,Local) +%% %c Generate Input Files for MZM +%c +%c function [ FileName ] = Set_MZ_Input_Data( FileIdex,L,U0,U_pi1,U_pi2,... +%c eta1,eta2,nopt,nel,alfa_ins,phi_0,alfa0,Local) +%c +%c by P.Marciano LG +%c 5/10/2017 +%c pablorafael.mcx@gmail.com +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Generator of Input File for the Modulador Mach-Zehnder +%c +%c Input: +%c FileIdex : Number of the file in the sequence given by variable S +%c L : Comprimento do dispositivo [cm] +%c U0 : Tensao de polarizacao [V] +%c eletrodes : Numero de eletrodos (1,2). Definido pelo numero de +%c variaveis de entrada na funcao Mach_Zehnder_Modulator +%c U_pi1 : Tensao de chaveamento para 1 eletrodo [V] +%c U_pi2 : Tensao de chaveamento para 2 eletrodos [V] +%c eta1 : Sensibilidade no caminho 1 [1/V.m] +%c eta2 : Sensibilidade no caminho 2 [1/V.m] +%c nopt : Indice de refracao optico +%c nel : Indice de refracao eletrico +%c alfa_ins : Perda por insercao [dB] +%c phi_0 : Constante de fase entre os dois caminhos +%c alfa0 : Perda condutiva [dB/cm.GHz^0.5] +%c Local : Variavél onde os arquivos serão salvos +%c +%c Output: +%c FileName : Nome do arquivo gerado +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%% +if nargin==12 %Verify if the storage folder was passed to this function + Local = [pwd '\'];%if not the files will be saved on the current folder +elseif nargin<12%Verify if there is all parameters needed + error('Not enough input arguments for Set_MZ_Input_Data'); +end + +%Location and name of the input file to be created +Name = [Local 'AA_MZ_Input_Data_t' num2str(FileIdex) '.m']; +fid = fopen( Name, 'wt' ); +ContTimeOut = toc; +while(fid<3) + if ((toc-ContTimeOut)/60)>5 + break; + end + fid = fopen( Name, 'wt' ); +end +%opening the file or creating it +%writing in the file the parameters passed to this function +fprintf( fid, '%6.2f\n',L); +fprintf( fid, '%6.3f\n',U0); +fprintf( fid, '%6.2f\n',U_pi1); +fprintf( fid, '%6.2f\n',U_pi2); +fprintf( fid, '%6.2f\n',eta1); +fprintf( fid, '%6.2f\n',eta2); +fprintf( fid, '%6.2f\n',nopt); +fprintf( fid, '%6.2f\n',nel); +fprintf( fid, '%6.2f\n',alfa_ins); +fprintf( fid, '%6.2f\n',phi_0); +fprintf( fid, '%6.2f\n',alfa0); + +fclose(fid);%closing the file + +FileName = ['MZ_Input_Data_t' num2str(FileIdex)];%Passing out the file +end \ No newline at end of file diff --git a/Ring_Resonator/matlab_tools/time2freq.m b/Ring_Resonator/matlab_tools/time2freq.m new file mode 100644 index 0000000..6912a70 --- /dev/null +++ b/Ring_Resonator/matlab_tools/time2freq.m @@ -0,0 +1,18 @@ +function freq = time2freq(T) +% +% function freq = time2freq(T); +% +% Gera o vetor de freqüência para um dado vetor tempo para ser usado junto com a FFT. +% +% ENTRADA: +% T : Vetor tempo +% +% SAÍDA: +% freq : Vetor freqüência + +dT = mean(diff(T)); +nT = length(T); +nT2 = nT/2; +df = inv(dT*nT); +% +freq = df*(-nT2:nT2 - 1); \ No newline at end of file diff --git a/Ring_Resonator/matlab_tools/time2freq_lamb.m b/Ring_Resonator/matlab_tools/time2freq_lamb.m new file mode 100644 index 0000000..3e9119c --- /dev/null +++ b/Ring_Resonator/matlab_tools/time2freq_lamb.m @@ -0,0 +1,51 @@ +function [freq,lamb] = time2freq_lamb(T,lc) +%c +%c function [freq,lamb] = time2freq_lamb(T,lc); +%c +%c Gera os vetores de frequencia e comprimento de onda para um dado vetor +%c tempo. +%c +%c by : M.Segatto +%c Date : 2004 +%c email: segatto@ele.ufes.br +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Entrada: +%c T : Vetor tempo [ps] +%c lc : Comprimento de onda central [nm] +%c +%c Saida: +%c freq : Vetor frequencia [THz] +%c lamb : Vetor comprimento de onda [nm] +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +lamb = 0; +cnmps = 2.998E5; % Velocidade da luz [nm/ps] + +dT = mean(diff(T)); +nT = length(T); +df = inv(dT*nT); % [THz] +switch nargin + case 1 + fc = 0; + for n = 1:nT, + freq(n) = fc - (n - 1 - nT/2)*df; % [THz] vetor de freq + end + case 2 + fc = cnmps/lc; % [THz] + for n = 1:nT, + freq(n) = fc - (n - 1 - nT/2)*df; % [THz] vetor de freq + end + lamb = (cnmps./freq); % Gera vetor de lambdas [nm] +% + otherwise error('Numero de parametros de entrada nao confere...'); +end diff --git a/Ring_Resonator/ofc-mzi-generation b/Ring_Resonator/ofc-mzi-generation new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Ring_Resonator/ofc-mzi-generation @@ -0,0 +1 @@ + diff --git a/Ring_Resonator/time2freq.m b/Ring_Resonator/time2freq.m new file mode 100644 index 0000000..fbfbdb5 --- /dev/null +++ b/Ring_Resonator/time2freq.m @@ -0,0 +1,18 @@ +function freq = time2freq(T) +% +% function freq = time2freq(T); +% +% Gera o vetor de freqüência para um dado vetor tempo para ser usado junto com a FFT. +% +% ENTRADA: +% T : Vetor tempo +% +% SAÍDA: +% freq : Vetor freqüência + +dT = mean(diff(T)); +nT = length(T); +nT2 = nT/2; +df = inv(dT*nT); +% +freq = df*(-nT2:nT2 - 1); \ No newline at end of file diff --git a/Ring_Resonator/time2freq_lamb.m b/Ring_Resonator/time2freq_lamb.m new file mode 100644 index 0000000..e0d5ea3 --- /dev/null +++ b/Ring_Resonator/time2freq_lamb.m @@ -0,0 +1,51 @@ +function [freq,lamb] = time2freq_lamb(T,lc) +%c +%c function [freq,lamb] = time2freq_lamb(T,lc); +%c +%c Gera os vetores de frequencia e comprimento de onda para um dado vetor +%c tempo. +%c +%c by : M.Segatto +%c Date : 2004 +%c email: segatto@ele.ufes.br +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c G L O B A L V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c L I S T O F V A R I A B L E S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +%c Entrada: +%c T : Vetor tempo [ps] +%c lc : Comprimento de onda central [nm] +%c +%c Saida: +%c freq : Vetor frequencia [THz] +%c lamb : Vetor comprimento de onda [nm] +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c S T R U C T S % +%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%c +lamb = 0; +cnmps = 2.998E5; % Velocidade da luz [nm/ps] + +dT = mean(diff(T)); +nT = length(T); +df = inv(dT*nT); % [THz] +switch nargin + case 1 + fc = 0; + for n = 1:nT, + freq(n) = fc - (n - 1 - nT/2)*df; % [THz] vetor de freq + end + case 2 + fc = cnmps/lc; % [THz] + for n = 1:nT, + freq(n) = fc - (n - 1 - nT/2)*df; % [THz] vetor de freq + end + lamb = (cnmps./freq); % Gera vetor de lambdas [nm] +% + otherwise error('Numero de parametros de entrada nao confere...'); +end diff --git a/Ring_Resonator/untitled.jpg b/Ring_Resonator/untitled.jpg new file mode 100644 index 0000000..e8977de Binary files /dev/null and b/Ring_Resonator/untitled.jpg differ