1/* Copyright (c) 2012 Massachusetts Institute of Technology
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 */
21
22#include "model/optical/OpticalTestModel.h"
23#include "model/optical_graph/OpticalGraph.h"
24#include "model/optical_graph/OpticalWaveguide.h"
25#include "model/optical/RingModulator.h"
26#include "model/optical/RingFilter.h"
27#include "model/optical/RingDetector.h"
28#include "model/optical/LaserSource.h"
29
30namespace DSENT
31{
32    OpticalTestModel::OpticalTestModel(const String& instance_name_, const TechModel* tech_model_)
33        : OpticalModel(instance_name_, tech_model_)
34    {
35        initParameters();
36        initProperties();
37    }
38
39    OpticalTestModel::~OpticalTestModel()
40    {}
41
42    void OpticalTestModel::initParameters()
43    {
44        return;
45    }
46
47    void OpticalTestModel::initProperties()
48    {
49        return;
50    }
51
52    void OpticalTestModel::constructModel()
53    {
54        unsigned int wavelengths = 64;
55        unsigned int number_readers = 1;
56
57        createWaveguide("LaserToMod", makeWavelengthGroup(0, wavelengths-1));
58
59        // Create laser
60        LaserSource* laser = new LaserSource("Laser", getTechModel());
61        laser->setParameter("OutStart", 0);
62        laser->setParameter("OutEnd", wavelengths-1);
63        laser->construct();
64
65        // Create modulator
66        RingModulator* modulator = new RingModulator("Modulator", getTechModel());
67        modulator->setParameter("InStart", 0);
68        modulator->setParameter("InEnd", wavelengths-1);
69        modulator->setParameter("ModStart", 0);
70        modulator->setParameter("ModEnd", wavelengths-1);
71        modulator->construct();
72
73        for (unsigned int i = 0; i <= number_readers; ++i)
74        {
75            String n = (String) i;
76            createWaveguide("WaveguideDet-" + n, makeWavelengthGroup(0, wavelengths-1));
77        }
78
79        // Create a SWMR Configuration
80        for (unsigned int i = 0; i < number_readers; ++i)
81        {
82            String n = (String) i;
83
84            // Create resonant ring detector
85            RingDetector* detector = new RingDetector("Detector-" + n, getTechModel());
86            detector->setParameter("InStart", 0);
87            detector->setParameter("InEnd", wavelengths-1);
88            detector->setParameter("DetStart", 0);
89            detector->setParameter("DetEnd", wavelengths-1);
90            detector->setParameter("DropAll", "FALSE");
91            detector->setParameter("SenseAmp", "TRUE");
92            detector->construct();
93
94            opticalPortConnect(detector, "In", "WaveguideDet-" + n);
95            opticalPortConnect(detector, "Out", "WaveguideDet-" + (String) (i + 1));
96
97            addSubInstances(detector, 1.0);
98        }
99
100        opticalPortConnect(laser, "Out", "LaserToMod");
101        opticalPortConnect(modulator, "In", "LaserToMod");
102        opticalPortConnect(modulator, "Out", "WaveguideDet-0");
103
104        addSubInstances(laser, 1.0);
105        addSubInstances(modulator, 1.0);
106    }
107
108    void OpticalTestModel::updateModel()
109    {
110        double data_rate = 8e9;
111        double extinction_ratio = 5;
112        double insertion_loss = 3;
113
114        Model* laser = getSubInstance("Laser");
115        laser->update();
116
117        getWaveguide("LaserToMod")->setLoss(10);
118
119        Model* modulator = getSubInstance("Modulator");
120        modulator->setProperty("ExtinctionRatio", extinction_ratio);
121        modulator->setProperty("InsertionLoss", insertion_loss);
122        modulator->setProperty("DataRate", data_rate);
123        modulator->setProperty("P(In)", 0.5);
124        modulator->setProperty("Act(In)", 1.0);
125        modulator->update();
126
127        unsigned int number_readers = 1;
128        for (unsigned int i = 0; i < number_readers; ++i)
129        {
130            Model* detector = getSubInstance("Detector-" + (String) i);
131            detector->setProperty("ExtinctionRatio", extinction_ratio);
132            detector->setProperty("DataRate", data_rate);
133            detector->setProperty("P(In)", 0.5);
134            detector->setProperty("Act(In)", 1.0);
135            detector->update();
136        }
137
138
139    }
140
141} // namespace DSENT
142
143