Local optimizers for the DQW example#
- Input files:
double_QW_AlGaAs.nnp
- Python scripts:
double_QW_local_optimization.py
This page describes the optimization of the double quantum well design using local optimization. For a description of the physical model and device parameters, as well as setup of the problem, see the optimization of a simple nano device page.
Optimization progress#
The code below shows how to use the local optimizers once the IO and the Metric objects are defined.
from nextnano_optimizers.optimizers import LocalOptimizer
variable_boundaries = [(4.0, 12.0), (4.0, 12.0), (0.0, 0.3), (0.0, 0.3)] # nm, nm, -, -
optimizer = LocalOptimizer(nextnanoio=nn_io, metric=metric)
optimizer.setup_plotting(objective_log_scale=True)
result = optimizer.run(
x0=np.array([8.0, 8.0, 0.1, 0.1]), method="Nelder-Mead", bounds=variable_boundaries, live_progress=True
)
With live_progress=True, the optimization progress is shown in the plot which is updated after each
algorithm iteration. In this specific setup, the objective is always non-negative, which allows to use logarithmic scale.
The progress plot is shown in the figure below:
Figure 8 Live progress of the Nelder-Mead optimization of the DQW design. The
left panel shows the objective of every evaluation together with the
best value found so far, on a logarithmic scale set by
objective_log_scale=True. The right panels show the four design
parameters over the same evaluations.#
The plots demonstrate that the optimization converges to a local minimum after about 100 evaluations.
Optimization results#
To print the optimization results, the following code can be used:
print(f"Optimal: Lx_QW1 = {result.x[0]:.3f} nm\n"
f" Lx_QW2 = {result.x[1]:.3f} nm\n"
f" Al_QW1 = {result.x[2]:.3f}\n"
f" Al_QW2 = {result.x[3]:.3f}")
print(f"Objective: {result.fun:.4g}")
The optimization results, namely the objective value and the optimized parameters are shown in the table below.
To demonstrate that the local optimization output is dependent on the starting point x0,
the optimization is repeated for two different starting points.
Design |
Objective |
|
|
|
|
|---|---|---|---|---|---|
Ideal design |
0 |
10.506 |
11.302 |
0.182 |
0.219 |
|
0.743 |
12.000 |
12.000 |
0.173 |
0.204 |
|
1.756 |
4.000 |
10.080 |
0.219 |
0.233 |
For two different points the algorithm converged to two different local minima, which are both far from the ideal design (i.e. global minimum). Nevertheless, the algorithm was able to find designs with objective values below 2, which is a significant improvement over the initial designs.