1 /* Copyright (c) 2012 Massachusetts Institute of Technology
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:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
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
22 #include "model/optical/GatedLaserSource.h"
24 #include "model/optical_graph/OpticalWaveguide.h"
25 #include "model/optical_graph/OpticalWavelength.h"
26 #include "model/optical_graph/OpticalLaser.h"
27 #include "model/optical_graph/OpticalGraph.h"
31 GatedLaserSource::GatedLaserSource(const String
& instance_name_
, const TechModel
* tech_model_
)
32 : OpticalModel(instance_name_
, tech_model_
)
38 GatedLaserSource::~GatedLaserSource()
41 void GatedLaserSource::initParameters()
43 addParameterName("OutStart");
44 addParameterName("OutEnd");
45 addParameterName("MaxDetectors");
49 void GatedLaserSource::initProperties()
51 addPropertyName("OptUtil", 1.0);
52 addPropertyName("LaserEventTime");
56 void GatedLaserSource::constructModel()
59 Result
* area_result
= new AtomicResult("Photonic");
60 addAreaResult(area_result
);
61 // Create NDD power result
62 Result
* energy_result
= new AtomicResult("Laser");
63 addEventResult(energy_result
);
66 WavelengthGroup laser_wavelengths
= makeWavelengthGroup(getParameter("OutStart"), getParameter("OutEnd"));
68 // Create optical ports
69 createOpticalOutputPort( "Out", laser_wavelengths
);
71 createLaser( "Laser", laser_wavelengths
);
72 OpticalLaser
* laser
= getLaser("Laser");
73 // Connect the laser to the output
74 laser
->addDownstreamNode(getWaveguide("Out"));
77 void GatedLaserSource::updateModel()
80 double laser_efficiency
= getTechModel()->get("Laser->CW->Efficiency");
81 double laser_area
= getTechModel()->get("Laser->CW->Area");
82 double laser_diode_loss
= getTechModel()->get("Laser->CW->LaserDiodeLoss");
85 WavelengthGroup laser_wavelengths
= makeWavelengthGroup(getParameter("OutStart"), getParameter("OutEnd"));
86 unsigned int number_wavelengths
= laser_wavelengths
.second
- laser_wavelengths
.first
+ 1;
88 OpticalLaser
* laser
= getLaser("Laser");
89 laser
->setLoss(laser_diode_loss
);
90 laser
->setEfficiency(laser_efficiency
);
92 getAreaResult("Photonic")->setValue(laser_area
* number_wavelengths
);
95 void GatedLaserSource::evaluateModel()
98 unsigned int max_detectors
= getParameter("MaxDetectors");
99 double laser_event_time
= getProperty("LaserEventTime");
100 WavelengthGroup laser_wavelengths
= makeWavelengthGroup(getParameter("OutStart"), getParameter("OutEnd"));
103 double opt_util
= getProperty("OptUtil");
105 // Create optical graph object
106 OpticalGraph
* optical_graph
= new OpticalGraph("LaserTrace", this);
107 // Ask optical graph object to perform power optimization
108 bool success
= optical_graph
->performPowerOpt(getLaser("Laser"), laser_wavelengths
, max_detectors
, opt_util
);
111 Log::printLine(std::cerr
, "[Warning] " + getInstanceName() +
112 " -> Wavelengths contains data paths with no possible modulator configurations!");
114 // Trace the wavelengths the laser is outputting to find the output
115 // power needed by the laser
116 OpticalWavelength
* wavelength
= optical_graph
->traceWavelength(laser_wavelengths
, getLaser("Laser"));
117 // Calculate the power needed by the wavelength
118 double laser_power
= wavelength
->getLaserPower(max_detectors
);
119 // Calculate NDD power
120 getEventResult("Laser")->setValue(laser_power
* laser_event_time
);
123 delete optical_graph
;