Automated optimization of Mid-IR Quantum Cascade Laser#
- Input files:
MidIR_QCL_InGaAs_InAlAs_Bai_NaturePhot2010_optimization.negf
- Python scripts:
MidIR_QCL_local_optimization.pyMidIR_QCL_bayesian.pyMidIR_QCL_evolution.py
General setup of the example#
This tutorial shows how to optimize a 1D Mid-IR Quantum Cascade Laser (QCL) using nextnano optimizers. QCL is modelled as a biased sequence of InGaAs wells separated by AlInAs barriers. The figure below shows an example of its conduction band edge at an applied bias of 330 mV
Figure 12 Conduction Band Edges of InGaAs/AlInAs-based QCL. Only one active region of the QCL is shown. The widths of first three quantum wells are used as optimization parameters. Other widths are fixed and not changed during the optimization#
Only one active region of the QCL is shown in this Figure. The widths of first
three quantum wells, LW1, LW2, and LW3 (variables $thickness_well_1, $thickness_well_2,
$thickness_well_1 in the input file) are used as optimization parameters. The
widths of all barriers (variables $thickness_barrier_1, $thickness_barrier_2,
$thickness_barrier_3, $thickness_barrier_4 in the input file) and the width
of the 4th well (variable $thickness_well_4 in the input file) are fixed and
not changed during the optimization.
The goal is to find (almost) optimal set of above defined optimization variables which maximize the gain of the QCL. The QCL gain describes how strongly the optical field is amplified as light propagates through the laser’s active region. Amplification is based on stimulated emission from intersubband electronic transitions. Optical gain is usually defined through the spatial evolution of the optical intensity:
Here \(I(x)\) is the optical intensity at position \(x\), [\({\rm W/cm}^2\)], \(x\) is the propagation distance along the active region, \(g\) is the optical gain coefficient, [\(1/{\rm cm}\)]. For a constant \(g\), the solution reads as follows
Positive (negative) \(g\) corresponds to optical amplification (absorption). The gain is calculated using the nextnano.NEGF, see the optical gain model.
Common optimization configuration#
The problem described above can be solved with the help of any method from nextnano optimizers package.
Regardless of the method chosen, the IO and Metric class are defined in the same way.
IO configuration#
In the IO class, the following has to be defined:
the path to the nextnano.NEGF input file used for the simulations:
MidIR_QCL_InGaAs_InAlAs_Bai_NaturePhot2010_optimization.negf;the variables to be optimized:
thickness_well_1,thickness_well_2, andthickness_well_3;full path to the nextnano.NEGF output file used to calculate the objective:
330mV/Gain/Gain_FermiGoldenRule_vs_Energy_[0,0,1].datfor the Fermi golden rule gain spectrum
The code below shows how to define the IO class for this example.
import os
from nextnano_optimizers.io import IO
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
input_file_path = os.path.join(
THIS_DIR, "MidIR_QCL_InGaAs_InAlAs_Bai_NaturePhot2010_optimization.negf"
)
variable_names = ["thickness_well_1", "thickness_well_2", "thickness_well_3"]
nn_io = IO(
input_file_path,
variable_names=variable_names,
output_files=["330mV/Gain/Gain_FermiGoldenRule_vs_Energy_[0,0,1].dat"],
)
Metric configuration#
Metric defines the objective function to be minimized.
In this example, the objective is to maximize the gain at 270 meV by varying the thicknesses of wells 1-3.
import numpy as np
from nextnano_optimizers.metric import Metric
TARGET_ENERGY = 270 # meV
def negative_gain_at_target(datafiles):
energy = datafiles[0].coords["Photon energy"].value
gain = datafiles[0].variables["Gain"].value
mask = np.isclose(energy, TARGET_ENERGY, atol=0.001)
# interpolate if the energy grid does not hit the target exactly
gain_at_target = gain[mask][0] if mask.any() else np.interp(TARGET_ENERGY, energy, gain)
# optimizers minimize, so maximize the gain by minimizing its negative
return np.array([-gain_at_target])
metric = Metric(input_shape=(1,), num_obj=1, extraction_function=negative_gain_at_target)
The following global variable is used to define the extraction function:
TARGET_ENERGY- target photon energy at which the gain is evaluated, in meV.
The extraction function negative_gain_at_target takes as input an array of nextnanopy datafiles and calculates the objective function value.
Datafiles are provided in the same order as they are defined in the IO class:
datafiles[0]isGain_FermiGoldenRule_vs_Energy_[0,0,1].dat, which contains the gain spectrum
The function reads the gain at the target photon energy and returns its negative, so that maximizing the gain becomes a minimization problem.
The defined negative_gain_at_target function is then passed to the Metric class as an extraction function, together with the 2 additional parameters:
input_shape- number of input datafiles, which is 1 in this example;num_obj- number of objective values, which is 1 in this example.
Application of various optimization methods#
The above described optimization problem can be tackled with the help of any method from nextnano optimizers package. You can use the following links to learn more about applications of Local Optimizers, Bayesian Optimization, Evolutionary Algorithms and Reinforcement Learning (coming soon) to this problem. Since different algorithms are used to solve one and the same problem, one can easily compare their performance, find pro and contra of each method, and choose the appropriate method for realistic optimizations.
Summary#
The table below summarizes the best designs found by each optimization method applied to this problem.
Method |
Gain at photon energy of 270 meV (\(\mathrm{cm}^{-1}\)) |
|
|
|
|---|---|---|---|---|
Local optimizer (Nelder-Mead) |
341.2 |
1.261 |
5.143 |
4.118 |
Bayesian optimization |
307.2 |
1.266 |
5.157 |
4.132 |
Evolutionary algorithm |
342.2 |
1.261 |
5.141 |
4.114 |
In this problem, Local optimizer worked exceptionally good when good starting point is known. For most of the starting points in this problem the result is much worse, see the local optimizers page for details. If there is no previous good starting point established, evolutionary algorithm provides the best result, and Bayesian optimization has good result relative to the evaluations spent.