General Description and Main Steps
Please note that mqwgain requires a separate license.
Also note that, like with any other script command, the graphical user interface (GUI) will not be responsive while running mqwgain command. This is not cause for alarm and the GUI will become responsive again after the command is executed, which can take from several minutes to several tens of minutes depending on the problem size.
The 2019B R2 release comes with a new script command mqwgain. It calculates stimulated and spontaneous emission coefficients in the multiplequantum well (MQW) structure. These results can be used as inputs to the travelling wave laser model (TWLM) to calculate LI curves and laser spectra. They can also be used to calculate the absorption due to the quantum confined Stark effect (QCSE) in electroabsorption modulators (EAM). A detailed description of the inputs and outputs for mqwgain can be found in our knowledge base for mqwgain. The related command to generate the material parameters that mqwgain requires is buildmqwmaterial.
The MQW gain calculation is based on the 4x4 k.p method as given in references [13]. The method is mainly suitable for IIIV materials with Zincblende crystal structure. Specifically, the list of materials supported by our default database is given in the KB documentation. In addition, other materials may be used by providing all required material properties.
The main steps necessary for using mqwgain command are:
 Create material parameters.
 Create inputs for mqwgain command (mqwgain).
 Run mqwgain.
Internally, the gain of the MQW structure is calculated using the following algorithm:
 Electronic band structure is calculated using the 4x4 k.p method. One eigenproblem in the valence band is solved for each transverse wave vector, while in the conduction band only one eigenproblem is solved in total at zero wave vector using the parabolic band assumption. The result of this step is the electronic wave functions and subbands in the conduction and valence bands of the quantum wells. These represent states confined in the quantum wells.
 Fermi level calculation. This energy level controls the occupation probability for each confined state through the FermiDirac distribution function. Its value depends on the band structure (calculated in step 1) and on the charge density (input parameter).
 Stimulated and spontaneous emission calculation. These emissions depend on the occupation of quantum well levels (step 2) and the overlap of wave functions between conduction and valence bands. The stimulated emission corresponds to gain, while the spontaneous emission mainly contributes to optical loss (it also seeds lasing when gain becomes larger than all loss mechanisms). Negative gain is equivalent to absorption that can be used in the simulations of EAMs based on the quantum confined Stark effect.
Obtaining Material Properties
The material properties have significant effects on the final results. While there are many published works listing important material properties for semiconductors of interest, it can be challenging to find accurate properties for certain ternary and quaternary materials. We allow several methods to define the material properties and customizing them:

By specifying materials and compositions directly at the input of mqwgain script command:
materials = cell(3);
#...
materials{2} = struct;
materials{2}.database_material = "AlGaAs";
materials{2}.x = 0.41;
The material properties will be defined based on our default material database. To customize, the users can provide their own database, which should be in the correct format of the default database:
config.materialdb = "/home/auser/myfolder/my_material_db.json";
For more details please check the documentation. 
By first calling buildmqwmaterial command, which returns the material properties as a struct that can be directly used as an input to mqwgain.
materials = cell(3);
#...
materials{2} = buildmqwmaterial("/home/auser/myfolder/my_material_db.json", 300, "InAlAs", 0.47);
To customize properties, this method provides direct access to all of the material properties from the script. For more details please check the mqwgain and buildmqwmaterial documentation. 
The users can also provide all material properties on their own. The properties should be provided as a struct with specific fields. For more details about the required fields please check the mqwgain or buildmqwmaterial documentation.
Adjusting Input Parameters and Configuration
 Relevant electron and hole states in the MQW structure are confined to the quantum wells. For physically meaningful results all other states should be filtered out. This is controlled at input by setting the boundary conditions. There are two types of boundary conditions: hard wall (wave function drops to zero at the boundary) and perfectly matched layer (PML). They are selected by the option pmlactive = true or false. For both types of boundary conditions it is best to extend the simulation region by a uniform potential to ensure that the wave function decays sufficiently towards the boundaries (~10nm is usually enough on each side). For hard wall boundaries and PML, the selection of confined states is governed by a threshold on the magnitude of the wave function derivative at the boundaries (option hwcutoff) or a threshold on the total probability density inside the PML, respectively. Sometimes it may be necessary to adjust these parameters from their default values to ensure that only confined states or enough confined states are selected. Whether a state is confined can be confirmed visually by inspecting the probability density near the boundaries (it should be vanishing).
 The electronic band structure (E,k) calculation is 1D, since the two inplane directions (transverse to the growth direction) are considered rotationally symmetric: wavevector k corresponds to the radial component. In order to accurately calculate the Fermi level for the given charge density it is necessary to include enough (E,k) states in the calculation. This is especially important if the simulation temperature is much higher than the room temperature, when larger k values contribute nonnegligibly to the density according to the FermiDirac distribution. It is usually enough to include 10% of the Brillouin zone (i.e. 2π/a*0.1, where a is the lattice constant) at room temperature and up to 20% at high temperatures. This is set by the option kt.
Input Charge Density and Output Emission Coefficients
One detail to note is the definition of charge density and emission coefficients (stimulated and spontaneous emission) used in the MQW gain solver. This may be important when comparing results from the solver with other results in the literature or with measurements.
In a MQW gain simulation, the carrier density input is a scalar that is averaged over the total simulation span. Typically, the carrier density in the quantum wells is larger than this. To convert to the quantum well density we can approximately assume that the charge is all confined in the quantum wells and then multiply the averaged density by the ratio of total thickness and quantum well thickness (taking all quantum wells into account).
The emission coefficients at the output are also calculated relative to the total simulation span. To convert to emission considering quantum wells only, we can again multiply by the ratio of total thickness to quantum well thickness. Note that the definition of thickness is consistent: for example, when using the gain and spontaneous emission from mqwgain in the travelling wave laser model, the mode confinement factor will also be calculated over the total thickness, so that the mode overlap with the active region will be larger than the overlap with the quantum wells only, but the emission coefficients are proportionally smaller by the same factor.
 D. Ahn et al., J. Appl. Phys. 64, 4056 (1988)
 S. L. Chuang, Physics of Optoelectronic Devices
 Chuang, Phys. Rev. B, 43, 9649 (1991)