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/LaserSource.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 LaserSource::LaserSource(const String
& instance_name_
, const TechModel
* tech_model_
)
32 : OpticalModel(instance_name_
, tech_model_
)
38 LaserSource::~LaserSource()
41 void LaserSource::initParameters()
43 addParameterName("OutStart");
44 addParameterName("OutEnd");
45 addParameterName("MaxDetectors");
49 void LaserSource::initProperties()
51 addPropertyName("OptUtil", 1.0);
55 void LaserSource::constructModel()
58 Result
* area_result
= new AtomicResult("Photonic");
59 addAreaResult(area_result
);
60 // Create NDD power result
61 Result
* power_result
= new AtomicResult("Laser");
62 addNddPowerResult(power_result
);
65 WavelengthGroup laser_wavelengths
= makeWavelengthGroup(getParameter("OutStart"), getParameter("OutEnd"));
67 // Create optical ports
68 createOpticalOutputPort( "Out", laser_wavelengths
);
70 createLaser( "Laser", laser_wavelengths
);
71 OpticalLaser
* laser
= getLaser("Laser");
72 // Connect the laser to the output
73 laser
->addDownstreamNode(getWaveguide("Out"));
76 void LaserSource::updateModel()
79 double laser_efficiency
= getTechModel()->get("Laser->CW->Efficiency").toDouble();
80 double laser_area
= getTechModel()->get("Laser->CW->Area").toDouble();
81 double laser_diode_loss
= getTechModel()->get("Laser->CW->LaserDiodeLoss");
84 WavelengthGroup laser_wavelengths
= makeWavelengthGroup(getParameter("OutStart"), getParameter("OutEnd"));
85 unsigned int number_wavelengths
= laser_wavelengths
.second
- laser_wavelengths
.first
+ 1;
87 OpticalLaser
* laser
= getLaser("Laser");
88 laser
->setLoss(laser_diode_loss
);
89 laser
->setEfficiency(laser_efficiency
);
91 getAreaResult("Photonic")->setValue(laser_area
* number_wavelengths
);
94 void LaserSource::evaluateModel()
97 unsigned int max_detectors
= getParameter("MaxDetectors").toUInt();
98 WavelengthGroup laser_wavelengths
= makeWavelengthGroup(getParameter("OutStart"), getParameter("OutEnd"));
101 double opt_util
= getProperty("OptUtil");
103 // Create optical graph object
104 OpticalGraph
* optical_graph
= new OpticalGraph("LaserTrace", this);
105 // Ask optical graph object to perform power optimization
106 bool success
= optical_graph
->performPowerOpt(getLaser("Laser"), laser_wavelengths
, max_detectors
, opt_util
);
109 Log::printLine(std::cerr
, "[Warning] " + getInstanceName() +
110 " -> Wavelengths contains data paths with no possible modulator configurations!");
112 // Trace the wavelengths the laser is outputting to find the output
113 // power needed by the laser
114 OpticalWavelength
* wavelength
= optical_graph
->traceWavelength(laser_wavelengths
, getLaser("Laser"));
115 // Calculate the power needed by the wavelength
116 double laser_power
= wavelength
->getLaserPower(max_detectors
);
118 // Calculate NDD power
119 getNddPowerResult("Laser")->setValue(laser_power
);
122 delete optical_graph
;