50 lines
2.0 KiB
Matlab
50 lines
2.0 KiB
Matlab
classdef Photodiode_test < IMDDTestCase
|
|
methods (Test, TestTags = {'unit', 'fast', 'receive', 'photodiode'})
|
|
function processZeroNoiseBaselineMatchesAnalyticalExpectation(testCase)
|
|
pd = Photodiode("fsimu", 0, "responsivity", 2.5, "dark_current", 0.75, "nep", 0, "randomkey", 1);
|
|
xin = [1 + 1i, 2 - 1i; 0.5, 0.25i];
|
|
|
|
yout = pd.process_(xin);
|
|
expected = 2.5 * sum(abs(xin).^2, 2) + 0.75;
|
|
|
|
testCase.verifyEqual(yout, expected, "AbsTol", 1e-12);
|
|
end
|
|
|
|
function responsivityScalesDetectedPowerLinearly(testCase)
|
|
xin = [1 + 2i, 0.5 - 0.5i; 0.25, 1i];
|
|
|
|
pd1 = Photodiode("fsimu", 0, "responsivity", 1, "dark_current", 0, "nep", 0, "randomkey", 1);
|
|
pd2 = Photodiode("fsimu", 0, "responsivity", 3.5, "dark_current", 0, "nep", 0, "randomkey", 1);
|
|
|
|
y1 = pd1.process_(xin);
|
|
y2 = pd2.process_(xin);
|
|
|
|
testCase.verifyEqual(y2, 3.5 * y1, "AbsTol", 1e-12);
|
|
end
|
|
|
|
function darkCurrentAddsConstantOffset(testCase)
|
|
xin = [1; 0; 2];
|
|
|
|
pdNoDc = Photodiode("fsimu", 0, "responsivity", 1.2, "dark_current", 0, "nep", 0, "randomkey", 1);
|
|
pdWithDc = Photodiode("fsimu", 0, "responsivity", 1.2, "dark_current", 0.42, "nep", 0, "randomkey", 1);
|
|
|
|
yNoDc = pdNoDc.process_(xin);
|
|
yWithDc = pdWithDc.process_(xin);
|
|
|
|
testCase.verifyEqual(yWithDc - yNoDc, 0.42 * ones(size(xin, 1), 1), "AbsTol", 1e-12);
|
|
end
|
|
|
|
function identicalSeedsProduceIdenticalStochasticOutputs(testCase)
|
|
xin = [1 + 1i; 0.5; 2];
|
|
|
|
pd1 = Photodiode("fsimu", 1, "responsivity", 0, "dark_current", 0, "nep", 1e-12, "randomkey", 7);
|
|
pd2 = Photodiode("fsimu", 1, "responsivity", 0, "dark_current", 0, "nep", 1e-12, "randomkey", 7);
|
|
|
|
y1 = pd1.process_(xin);
|
|
y2 = pd2.process_(xin);
|
|
|
|
testCase.verifyEqual(y1, y2);
|
|
end
|
|
end
|
|
end
|