Optimization of a 2DEG structure


The nextnanoevo package is under development. Its release is planned for 2024.


This tutorial demonstrates the use of nextnanoevo for optimization of a 2DEG design from the tutorial — FREE — Schrödinger-Poisson - A comparison to the tutorial file of Greg Snider’s code.


The first state (subband) confined in the GaAs quantum well is forming 2-dimensional electron gas (2DEG) formed at one of interfaces due to electric field originated from the Schottky layer. Multiple parameters of the structure are impacting formation of the 2DEG, and one of them is the width of the quantum well containing the 2DEG. Therefore, one can aim at choosing the best width of the quantum well for a given design, to obtain 2DEG with the highest possible occupation of the first state (subband). In this tutorial we show, how to perform such optimization. We show how to maximize occupation of the first electron state by varying the thickness of the GaAs quantum-well layer in the range from 1 nm to 20 nm.

Variables under optimization:



Initial value






Target output:



Initial value


Occupation of the fisrt subband





In this example scipy.optimize.minimize algorithm is used. The algorithm searches for the minimum value in the provided variable space. In this tutorial only 1 variable is optimized, but the algorithm supports n-dimensional variable space.


Every maximization problem can be formulated as minimization by changing the sign of the target value.

Optimization script

At first, specify input file, variables, and relevant output files in the IO instance:

from nextnanoevo.IO import IO
nn_io = IO(input_file_path,
       [('bias_00000', 'Quantum', 'occupation_quantum_region_Gamma.dat')])

Next, define the metric function to extract the occupation of the first subband in the 2DEG region.

def max_first_state_occupation(df_list):
    gamma_first_state_occupation = df_list[0].variables[0].value[0]

    # negative sign to use "minimize" method
    return -gamma_first_state_occupation
metric = Metric(input_length=1, output_length=1, extraction_function=max_first_state_occupation)

Create the Optimizer, and set the initial value and bounds for the quantum well thickness.

from nextnanoevo.OptimizerClass import Optimizer
optimizer = Optimizer(nextnanoio=nn_io, metric=metric, optimization_method='minimize')

# Setting the scipy.optimize.minimize arguments
optimizer.set_optimization_parameters(x0=15, bounds=[(1, 20), ], method='Nelder-Mead')

Run the optimization. The details are recorded in the Simulation*.log file, which tracks each input file execution.

result = optimizer.run_optimization()
print(f"The optimal quantum well thickness is {result.x} nm")


The optimal quantum well thickness is [8.34375] nm