forked from kaliliofs/Optisystem-and-MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCallOptiSystem.m
74 lines (59 loc) · 3.14 KB
/
CallOptiSystem.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
clear all;
close all;
% create a COM server running OptiSystem
optsys = actxserver('optisystem.application');
% This pause is necessary to allow OptiSystem to be opened before
% call open the project
pause(15);
% Open the OptiSystem file defined by the path
optsys.Open(['C:\Users\mverreault\Desktop\OptiSystem 12 Samples\Software interworking\MATLAB co-simulation\MATLAB call OptiSystem\Matlab Call OptiSystem.osd']);
% Specify and define the parameters that will be varied
ParameterName1 = 'Power';
SignalPower = -20:5:-10; %dBm
ParameterName2 = 'Length';
FiberLength = 5:5:15; %meters
% Specify the results that will be transfered from OptiSystem
ResultName1 = 'Max. Gain (dB)';
ResultName2 = 'Min. Noise Figure (dB)';
ResultName3 = 'Output : Max. OSNR (dB)';
Document = optsys.GetActiveDocument;
LayoutMngr = Document.GetLayoutMgr;
CurrentLyt = LayoutMngr.GetCurrentLayout;
Canvas = CurrentLyt.GetCurrentCanvas;
% Specify the components that will have the parameters (results) transfered
Component1 = Canvas.GetComponentByName('CW Laser');
Component2 = Canvas.GetComponentByName('EDFA');
Visualizer1 = Canvas.GetComponentByName('Dual Port WDM Analyzer');
% vary the parameters, run OptiSystem project and get the results
for i = 1:length(SignalPower)
for k = 1:length(FiberLength)
%Set component parameters
Component1.SetParameterValue( ParameterName1, SignalPower(i) );
Component2.SetParameterValue( ParameterName2, FiberLength(k) );
%Calculate
Document.CalculateProject( true , true);
%Acces visualizer results
Result1 = Visualizer1.GetResult( ResultName1 );
Result2 = Visualizer1.GetResult( ResultName2 );
Result3 = Visualizer1.GetResult( ResultName3 );
Gain( (i-1)*length(FiberLength) + k ) = Result1.GetValue( 1 );
NF( (i-1)*length(FiberLength) + k ) = Result2.GetValue( 1 );
OSNR( (i-1)*length(FiberLength) + k ) = Result3.GetValue( 1 );
end
end
%plot graphs
figure
subplot(3,1,1); plot(FiberLength,Gain(1:length(FiberLength)),FiberLength,Gain(length(FiberLength)+1:2*length(FiberLength)),FiberLength,Gain(2*length(FiberLength)+1:3*length(FiberLength)) )
title('Signal Gain')
xlabel('Fiber length [m]')
ylabel('Gain [dB]')
subplot(3,1,2); plot(FiberLength,NF(1:length(FiberLength)),FiberLength,NF(length(FiberLength)+1:2*length(FiberLength)),FiberLength,NF(2*length(FiberLength)+1:3*length(FiberLength)) )
title('Noise Figure')
xlabel('Fiber length [m]')
ylabel('NF [dB]')
subplot(3,1,3); plot(FiberLength,OSNR(1:length(FiberLength)),FiberLength,OSNR(length(FiberLength)+1:2*length(FiberLength)),FiberLength,OSNR(2*length(FiberLength)+1:3*length(FiberLength)) )
title('OSNR')
xlabel('Fiber length [m]')
ylabel('OSNR [dB]')
% close OptiSystem
optsys.Quit;