% time parameters nMC = 1e6; Fs = 1e6; dt = 1/Fs; t = 0:dt:((nMC-1)/Fs); % cavity round trip delay c = 3e8; % speed of light L = 3e3; % arm length T = 2*L/c; % propagation time iT = round(T/dt); % cavity reflectivities rb = 1; ta = sqrt(3e-2); ra = sqrt(1-ta^2); % input frequency noise and modulation modSine = sin(2*pi*35e3*t)'; ksiN = myLowpass(1e-1*randn(nMC,1), nMC/Fs, Fs, 1e2); %ksiN = linspace(-1e-2,1e-2,nMC)'; ksi = ksiN + 1e-3*modSine; % initialize field vector and compute steady state values E = zeros(nMC, 1); Ein = 1; Eres = Ein*ta/(1-ra*rb); % compute time domain simulation for i = 1:nMC if i<=iT E(i) = ta*Ein + ra*rb*exp(-2j*2*pi*ksi(i)).*Eres; else E(i) = ta*Ein + ra*rb*exp(-2j*2*pi*ksi(i)).*E(i-iT); end end % compute transmitted power and demodulate Ptrans = abs(E/Eres).^2; Pdemod = myLowpass(Ptrans.*modSine, nMC/Fs,Fs,2e3); PtransDC = myLowpass(Ptrans, nMC/Fs,Fs,2e3); PdemodNorm = Pdemod./(PtransDC + 2e-2); % plot transmitted raw power figure; plot(t, Ptrans); grid; xlabel('Time (s)') ylabel('Normalized transmitted power') % plot error signal and scaled input frequency noise figure;plot(t, Pdemod, t, PdemodNorm, t, -2e-2*ksiN);grid; legend('Demod signal','Demod signal normalized','frequency noise') xlabel('Time (s)') ylim([-2e-4 2e-4]) xlim(0.5 + [0 0.1]) % compute spectra, cut out initial transient maskTransient = t>0.1; nfft = Fs*0.1; [PSD_trans F] = pwelch(Ptrans(maskTransient), hanning(nfft), 0.5, nfft, Fs); [PSD_demod F] = pwelch(Pdemod(maskTransient), hanning(nfft), 0.5, nfft, Fs); [PSD_demodNorm F] = pwelch(PdemodNorm(maskTransient), hanning(nfft), 0.5, nfft, Fs); [PSD_ksiN F] = pwelch(2e-2*ksiN(maskTransient), hanning(nfft), 0.5, nfft, Fs); [coh_demod F] = mscohere(Pdemod(maskTransient), ksiN(maskTransient), hanning(nfft), 0.5, nfft, Fs); [coh_demodNorm F] = mscohere(PdemodNorm(maskTransient), ksiN(maskTransient), hanning(nfft), 0.5, nfft, Fs); % plot error signal and scale input frequency noise spectra figure;loglog(F, sqrt(PSD_demod), ... F, sqrt(PSD_demodNorm), ... F, sqrt(PSD_ksiN)); legend('Demod signal','Demod signal normalized','frequency noise') xlabel('Frequency (Hz)'); ylabel('ASD (au/rtHz)'); grid; xlim([10 1e5]) figure; semilogx(F, coh_demod, F, coh_demodNorm); legend('Demod signal','Demod signal normalized') grid; xlabel('Frequency (Hz)');