/*
 * mosfet.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 12 2026, 08:29 by COMSOL 6.4.0.418. */
public class mosfet {

  public static Model run() {
    Model model = ModelUtil.create("Model");

//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    In the Model Wizard window, click 2D.
//    In the Select Physics tree, select Semiconductor > Semiconductor (semi).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Stationary.
//    Click Done.

    model.component().create("comp1", true);

    model.component("comp1").geom().create("geom1", 2);

    model.component("comp1").mesh().create("mesh1");

    model.component("comp1").physics().create("semi", "Semiconductor", "geom1");

    model.study().create("std1");
    model.study("std1").create("stat", "Stationary");

//    Define parameters for the drain and gate voltages that you will later use when performing parametric sweeps.
//    In the Model Builder window, under Global Definitions, click Parameters 1.
//    In the Settings window for Parameters, locate the Parameters section.
//    In the table, enter the following settings:

    model.param().set("Vd", "10[mV]");
    model.param().descr("Vd", "Drain voltage");
    model.param().set("Vg", "2[V]");
    model.param().descr("Vg", "Gate voltage");

//    The geometry can be specified using COMSOL's built in tools. First choose to define geometry objects using micrometer units.
//    In the Model Builder window, under Component 1 (comp1), click Geometry 1.
//    In the Settings window for Geometry, locate the Units section.
//    From the Length unit list, select µm.

    model.component("comp1").geom("geom1").lengthUnit("\u00b5m");

//    Next create a rectangle to define the geometry extents.
//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").create("r1", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type 3.

    model.component("comp1").geom("geom1").feature("r1").set("size", new double[]{3, 1});

//    In the Height text field, type 0.7.

    model.component("comp1").geom("geom1").feature("r1").set("size", new double[]{3, 0.7});

//    Add a polygon which will include points to define the source, drain and gate contacts. It will also include a line to help create the mesh.
//    In the Geometry toolbar, click Polygon.

    model.component("comp1").geom("geom1").run("r1");
    model.component("comp1").geom("geom1").create("pol1", "Polygon");
    model.component("comp1").geom("geom1").feature("pol1").set("source", "table");

//    In the Settings window for Polygon, locate the Object Type section.
//    From the Type list, select Closed curve.

    model.component("comp1").geom("geom1").feature("pol1").set("type", "closed");

//    Locate the Coordinates section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0, 0, 0);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.67, 0, 1);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0, 1, 0);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.7, 1, 1);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.5, 2, 0);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.7, 2, 1);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.7, 3, 0);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.7, 3, 1);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 2.3, 4, 0);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.7, 4, 1);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 2.5, 5, 0);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.7, 5, 1);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 3, 6, 0);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.7, 6, 1);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 3, 7, 0);
    model.component("comp1").geom("geom1").feature("pol1").setIndex("table", 0.67, 7, 1);

//    In the Geometry toolbar, click Virtual Operations and choose Mesh Control Edges.

    model.component("comp1").geom("geom1").run("fin");
    model.component("comp1").geom("geom1").create("mce1", "MeshControlEdges");

//    On the object fin, select Boundary 4.

    model.component("comp1").geom("geom1").feature("mce1").selection("input").set("fin", 4);

//    It might be easier to select the correct boundary by using the <l>Selection List</l> window. To open this window, in the <l>Home</l> toolbar click <l>Windows</l> and choose <l>Selection List</l>. (If you are running the cross-platform desktop, you find <l>Windows</l> in the main menu.)
//    Right-click Mesh Control Edges 1 (mce1) and choose Build All Objects.

    model.component("comp1").geom("geom1").runPre("fin");

//    Use the Zoom Extents button to zoom to the full geometry if desired.
//    Click the Zoom Extents button in the Graphics toolbar.

    model.component("comp1").geom("geom1").run();

//    Next the material properties are added to the model.
//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Semiconductors > Si - Silicon.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat1", "Common");
    model.component("comp1").material("mat1").propertyGroup()
         .create("AroraMobilityModel", "AroraMobilityModel", "Arora mobility model");
    model.component("comp1").material("mat1").propertyGroup()
         .create("PowerLawMobilityModel", "PowerLawMobilityModel", "Power law mobility model");
    model.component("comp1").material("mat1").propertyGroup().create("Auger", "Auger", "Auger recombination");
    model.component("comp1").material("mat1").propertyGroup().create("Direct", "Direct", "Direct recombination");
    model.component("comp1").material("mat1").propertyGroup()
         .create("SRH", "SRH", "Shockley\u2013Read\u2013Hall recombination");
    model.component("comp1").material("mat1").propertyGroup()
         .create("FletcherMobilityModel", "FletcherMobilityModel", "Fletcher mobility model");
    model.component("comp1").material("mat1").propertyGroup()
         .create("CaugheyThomasMobilityModel", "CaugheyThomasMobilityModel", "Caughey\u2013Thomas mobility model");
    model.component("comp1").material("mat1").propertyGroup()
         .create("SemicondMaterial", "SemicondMaterial", "Semiconductor material");
    model.component("comp1").material("mat1").propertyGroup()
         .create("LombardiSurfaceMobilityModel", "LombardiSurfaceMobilityModel", "Lombardi surface mobility model");
    model.component("comp1").material("mat1").propertyGroup()
         .create("ImpactIonization", "ImpactIonization", "Impact ionization");
    model.component("comp1").material("mat1").propertyGroup()
         .create("SlotboomModel", "SlotboomModel", "Slotboom model");
    model.component("comp1").material("mat1").propertyGroup()
         .create("JainRoulstonModel", "JainRoulstonModel", "Jain\u2013Roulston model");
    model.component("comp1").material("mat1").propertyGroup()
         .create("KlaassenUnifiedMobilityModel", "KlaassenUnifiedMobilityModel", "Klaassen unified mobility model");
    model.component("comp1").material("mat1").label("Si - Silicon");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("relpermittivity", new String[]{"11.7", "0", "0", "0", "11.7", "0", "0", "0", "11.7"});
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalconductivity", new String[]{"131[W/(m*K)]", "0", "0", "0", "131[W/(m*K)]", "0", "0", "0", "131[W/(m*K)]"});
    model.component("comp1").material("mat1").propertyGroup("def").set("density", "2329[kg/m^3]");
    model.component("comp1").material("mat1").propertyGroup("def").set("heatcapacity", "700[J/(kg*K)]");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel")
         .set("mun0_ref_arora", "1252[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel")
         .set("mup0_ref_arora", "407[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel")
         .set("mun_min_ref_arora", "88[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel")
         .set("mup_min_ref_arora", "54.3[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel")
         .set("Nn0_ref_arora", "1.26e17[1/cm^3]");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel")
         .set("Np0_ref_arora", "2.35e17[1/cm^3]");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel").set("alpha0_arora", "0.88");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel").set("beta1_arora", "-0.57");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel").set("beta2_arora", "-2.33");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel").set("beta3_arora", "-2.33");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel").set("beta4_arora", "-0.146");
    model.component("comp1").material("mat1").propertyGroup("AroraMobilityModel").set("Tref_arora", "300[K]");
    model.component("comp1").material("mat1").propertyGroup("PowerLawMobilityModel")
         .set("mun0_pl", "1448[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("PowerLawMobilityModel")
         .set("mup0_pl", "473[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("PowerLawMobilityModel").set("alphan_pl", "2.33");
    model.component("comp1").material("mat1").propertyGroup("PowerLawMobilityModel").set("alphap_pl", "2.23");
    model.component("comp1").material("mat1").propertyGroup("PowerLawMobilityModel").set("Tref_pl", "300[K]");
    model.component("comp1").material("mat1").propertyGroup("Auger").set("Cn", "2.8e-31[cm^6/s]");
    model.component("comp1").material("mat1").propertyGroup("Auger").set("Cp", "9.9e-32[cm^6/s]");
    model.component("comp1").material("mat1").propertyGroup("Direct").set("C", "0[cm^3/s]");
    model.component("comp1").material("mat1").propertyGroup("SRH").set("taun", "10[us]");
    model.component("comp1").material("mat1").propertyGroup("SRH").set("taup", "10[us]");
    model.component("comp1").material("mat1").propertyGroup("FletcherMobilityModel")
         .set("F1_fl", "1.04e21[1/(cm^1*V*s)]");
    model.component("comp1").material("mat1").propertyGroup("FletcherMobilityModel").set("F2_fl", "7.45e13[1/cm^2]");
    model.component("comp1").material("mat1").propertyGroup("FletcherMobilityModel").set("Tref_fl", "300[K]");
    model.component("comp1").material("mat1").propertyGroup("CaugheyThomasMobilityModel").set("alphan0_ct", "1.11");
    model.component("comp1").material("mat1").propertyGroup("CaugheyThomasMobilityModel").set("alphap0_ct", "1.21");
    model.component("comp1").material("mat1").propertyGroup("CaugheyThomasMobilityModel").set("vn0_ct", "1e7[cm/s]");
    model.component("comp1").material("mat1").propertyGroup("CaugheyThomasMobilityModel")
         .set("vp0_ct", "8.37e6[cm/s]");
    model.component("comp1").material("mat1").propertyGroup("CaugheyThomasMobilityModel").set("betan1_ct", "0.66");
    model.component("comp1").material("mat1").propertyGroup("CaugheyThomasMobilityModel").set("betap1_ct", "0.17");
    model.component("comp1").material("mat1").propertyGroup("CaugheyThomasMobilityModel").set("betan2_ct", "-0.87");
    model.component("comp1").material("mat1").propertyGroup("CaugheyThomasMobilityModel").set("betap2_ct", "-0.52");
    model.component("comp1").material("mat1").propertyGroup("CaugheyThomasMobilityModel").set("Tref_ct", "300[K]");
    model.component("comp1").material("mat1").propertyGroup("SemicondMaterial").set("Eg0", "1.12[V]");
    model.component("comp1").material("mat1").propertyGroup("SemicondMaterial").set("chi0", "4.05[V]");
    model.component("comp1").material("mat1").propertyGroup("SemicondMaterial")
         .set("Nv", "(T/300[K])^(3/2)*1.04e19[1/cm^3]");
    model.component("comp1").material("mat1").propertyGroup("SemicondMaterial")
         .set("Nc", "(T/300[K])^(3/2)*2.8e19[1/cm^3]");
    model.component("comp1").material("mat1").propertyGroup("SemicondMaterial").set("mun", "1450[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("SemicondMaterial").set("mup", "500[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("SemicondMaterial").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel")
         .set("deltan_ls", "5.82e14[V/s]");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel")
         .set("deltap_ls", "2.05e14[V/s]");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel")
         .set("mun1_ls", "4.75e7[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel")
         .set("mup1_ls", "9.93e7[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel")
         .set("mun2_ls", "1.74e5[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel")
         .set("mup2_ls", "8.84e5[cm^2/(V*s)]");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel").set("alphan_ls", "0.125");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel")
         .set("alphap_ls", "0.0317");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel").set("Tref_ls", "1[K]");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel").set("Eref_ls", "1[V/cm]");
    model.component("comp1").material("mat1").propertyGroup("LombardiSurfaceMobilityModel")
         .set("Nref_ls", "1[1/cm^3]");
    model.component("comp1").material("mat1").propertyGroup("ImpactIonization").set("an", "0.426[1/V]");
    model.component("comp1").material("mat1").propertyGroup("ImpactIonization").set("ap", "0.243[1/V]");
    model.component("comp1").material("mat1").propertyGroup("ImpactIonization").set("bn", "4.81E5[V/cm]");
    model.component("comp1").material("mat1").propertyGroup("ImpactIonization").set("bp", "6.53E5[V/cm]");
    model.component("comp1").material("mat1").propertyGroup("ImpactIonization").set("cnii", "3.05E-4[1/K]");
    model.component("comp1").material("mat1").propertyGroup("ImpactIonization").set("cpii", "5.35E-4[1/K]");
    model.component("comp1").material("mat1").propertyGroup("ImpactIonization").set("dn", "6.86E-4[1/K]");
    model.component("comp1").material("mat1").propertyGroup("ImpactIonization").set("dp", "5.67E-4[1/K]");
    model.component("comp1").material("mat1").propertyGroup("SlotboomModel").set("Eref_sb", "0.00692[V]");
    model.component("comp1").material("mat1").propertyGroup("SlotboomModel").set("Nref_sb", "1.3e17[1/cm^3]");
    model.component("comp1").material("mat1").propertyGroup("SlotboomModel").set("alpha_sb", "0.5");
    model.component("comp1").material("mat1").propertyGroup("JainRoulstonModel").set("An_jr", "3.5e-8[V]");
    model.component("comp1").material("mat1").propertyGroup("JainRoulstonModel").set("Bn_jr", "0[V]");
    model.component("comp1").material("mat1").propertyGroup("JainRoulstonModel").set("Cn_jr", "0[V]");
    model.component("comp1").material("mat1").propertyGroup("JainRoulstonModel").set("Ap_jr", "3.5e-8[V]");
    model.component("comp1").material("mat1").propertyGroup("JainRoulstonModel").set("Bp_jr", "0[V]");
    model.component("comp1").material("mat1").propertyGroup("JainRoulstonModel").set("Cp_jr", "0[V]");
    model.component("comp1").material("mat1").propertyGroup("JainRoulstonModel").set("Nref_jr", "1[1/cm^3]");
    model.component("comp1").material("mat1").propertyGroup("JainRoulstonModel").set("alpha_jr", "0.5");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("T_ref_kl", "300[K]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("mu_e_max_kl", "1414.0[cm^2/V/s]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("mu_h_max_kl", "470.5[cm^2/V/s]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("mu_e_min_kl", "68.5[cm^2/V/s]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("mu_h_min_kl", "44.9[cm^2/V/s]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("theta_e_kl", "2.285");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("theta_h_kl", "2.247");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("alpha_e_1_kl", "0.711");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("alpha_h_1_kl", "0.719");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("N_ref_e_1_kl", "9.20e16[cm^-3]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("N_ref_h_1_kl", "2.23e17[cm^-3]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("c_D_kl", "0.21");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("c_A_kl", "0.50");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("N_ref_D_kl", "4.0e20[cm^-3]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("N_ref_A_kl", "7.2e20[cm^-3]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("f_BH_kl", "3.828");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("f_CW_kl", "2.459");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("N_BH_kl", "1.36e20[cm^-3]");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("P_CW_kl", "3.97e13");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("s_1_kl", "0.89233");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("s_2_kl", "0.41372");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("s_3_kl", "0.19778");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("s_4_kl", "0.28227");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("s_5_kl", "0.005978");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("s_6_kl", "1.80618");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("s_7_kl", "0.72169");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("r_1_kl", "0.7643");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("r_2_kl", "2.2999");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("r_3_kl", "6.5502");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("r_4_kl", "2.3670");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("r_5_kl", "-0.01552");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("r_6_kl", "0.6478");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel").set("m_e_kl", "me_const");
    model.component("comp1").material("mat1").propertyGroup("KlaassenUnifiedMobilityModel")
         .set("m_h_kl", "1.258*me_const");

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    Next the physics settings must be defined. Start by defining the doping.
//    In the Settings window for Semiconductor, locate the Model Properties section.
//    From the Carrier statistics list, select Fermi–Dirac.

    model.component("comp1").physics("semi").prop("ModelProperties").set("CarrierStatistics", "FermiDirac");

//    In the Physics toolbar, click Domains and choose Analytic Doping Model.

    model.component("comp1").physics("semi").create("adm1", "AnalyticDopingModel", 2);

//    First a constant background acceptor concentration is defined.
//    In the Settings window for Analytic Doping Model, locate the Impurity section.
//    In the \[N_{A0}\] text field, type 1e17[1/cm^3].

    model.component("comp1").physics("semi").feature("adm1").set("NAc", "1e17[1/cm^3]");

//    Locate the Domain Selection section.
//    From the Selection list, select All domains.

    model.component("comp1").physics("semi").feature("adm1").selection().all();

//    Add a second doping feature to define the implanted doping profile for the source.
//    In the Physics toolbar, click Domains and choose Analytic Doping Model.

    model.component("comp1").physics("semi").create("adm2", "AnalyticDopingModel", 2);

//    In the Settings window for Analytic Doping Model, locate the Domain Selection section.
//    From the Selection list, select All domains.

    model.component("comp1").physics("semi").feature("adm2").selection().all();

//    Locate the Distribution section.
//    From the list, select Box.

    model.component("comp1").physics("semi").feature("adm2").set("impurityDistribution", "box");

//    When defining a Gaussian doping distribution a rectangular region of constant doping is defined. The Gaussian drop off occurs away from the edges of this rectangular region.
//    First define the location of the lower left corner of the uniformly doped region.
//    Locate the Uniform Region section.
//    Specify the \[r_0\] vector as

    model.component("comp1").physics("semi").feature("adm2").set("rb", new String[]{"0[um]", "0.6[um]", "0"});

//    Then define the width and height of the uniformly doped region.
//    In the \[W\] text field, type 0.6[um].

    model.component("comp1").physics("semi").feature("adm2").set("jwidth", "0.6[um]");

//    In the \[D\] text field, type 0.1[um].

    model.component("comp1").physics("semi").feature("adm2").set("jdepth", "0.1[um]");

//    Choose the dopant type and the doping level in the uniformly doped region.
//    Locate the Impurity section.
//    From the Impurity type list, select Donor doping (n-type).

    model.component("comp1").physics("semi").feature("adm2").set("impurityType", "donor");

//    In the \[N_{D0}\] text field, type 1e20[1/cm^3].

    model.component("comp1").physics("semi").feature("adm2").set("NDc", "1e20[1/cm^3]");

//    Next specify the length scale over which the Gaussian drop off occurs. If doping into a background dopant distribution of opposite type (as in this case), this setting specifies the junction depth. In this model different length scales are used in the <eqv>x</eqv> and <eqv>y</eqv> directions.
//    Locate the Profile section.
//    Select the Specify different length scales for each direction checkbox.

    model.component("comp1").physics("semi").feature("adm2").set("AsymmetricJunctionDepth", true);

//    Specify the \[d_{j}\] vector as

    model.component("comp1").physics("semi").feature("adm2").set("jda", new String[]{"0.2[um]", "0.25[um]", "0"});

//    Finally specify the constant background doping level.
//    From the \[N_b\] list, select Acceptor concentration (semi/adm1).

    model.component("comp1").physics("semi").feature("adm2").set("Nb_src", "root.comp1.semi.adm1.NAc");

//    Here you can plot the preview of the doping profile for the selected feature.
//    Click Plot Doping Profile for Selected in the window toolbar.
//    Add a similar Gaussian doping profile for the drain.
//    Right-click Analytic Doping Model 2 and choose Duplicate.

    model.component("comp1").physics("semi").feature().duplicate("adm3", "adm2");

//    In the Settings window for Analytic Doping Model, locate the Uniform Region section.
//    Specify the \[r_0\] vector as

    model.component("comp1").physics("semi").feature("adm3").set("rb", new String[]{"2.4[um]", "0.6[um]", "0"});

//    Here you can plot the preview of the doping profile for all the features.
//    Click Plot Net Doping Profile for All in the window toolbar.
//    Next set up boundary conditions for the contacts and gate.
//    First add a contact for the source.
//    In the Physics toolbar, click Boundaries and choose Metal Contact.

    model.component("comp1").physics("semi").create("mc1", "MetalContact", 1);

//    The Metal Contact feature is used to define Metal-Semiconductor interfaces of various types. In this instance, use the default Ideal ohmic contact to define the source.
//    Select Boundary 3.

    model.component("comp1").physics("semi").feature("mc1").selection().set(3);

//    Note that the Metal Contact feature in COMSOL Multiphysics is a so-called Terminal boundary condition. By default a fixed potential of 0 V is applied, which is appropriate in this instance, since the source is grounded. The terminal can also be set up to specify an input current, input power, or to connect to a voltage or current source from an external circuit.
//    Add a second Metal Contact feature to define the drain.
//    In the Physics toolbar, click Boundaries and choose Metal Contact.

    model.component("comp1").physics("semi").create("mc2", "MetalContact", 1);

//    Select Boundary 7.

    model.component("comp1").physics("semi").feature("mc2").selection().set(7);

//    Set the drain voltage to be determined by the previously defined parameter.
//    In the Settings window for Metal Contact, locate the Terminal section.
//    In the \[V_0\] text field, type Vd.

    model.component("comp1").physics("semi").feature("mc2").set("V0", "Vd");

//    Add a third Metal Contact to set the body voltage to 0 V.
//    In the Physics toolbar, click Boundaries and choose Metal Contact.

    model.component("comp1").physics("semi").create("mc3", "MetalContact", 1);

//    Select Boundary 2.

    model.component("comp1").physics("semi").feature("mc3").selection().set(2);

//    Set up the gate. The gate dielectric is not explicitly represented in the model, instead the Thin Insulator Gate boundary condition represents both the gate contact and the thin layer of oxide.
//    In the Physics toolbar, click Boundaries and choose Thin Insulator Gate.

    model.component("comp1").physics("semi").create("gc1", "GateContact", 1);

//    The Thin Insulator Gate feature is also a terminal, but in this instance it is possible to fix the voltage or charge on the terminal, as well as to connect it to a circuit. Note that the charge setting determines the charge on the conductor and does not relate to trapped charge at the oxide-semiconductor interface.
//    The voltage applied to the gate is determined by the parameter previously added.
//    In the Settings window for Thin Insulator Gate, locate the Terminal section.
//    In the \[V_0\] text field, type Vg.

    model.component("comp1").physics("semi").feature("gc1").set("V0", "Vg");

//    Locate the Gate Contact section.
//    In the \[\epsilon_{ins}\] text field, type 4.5.

    model.component("comp1").physics("semi").feature("gc1").set("epsilon_ins", 4.5);

//    In the \[d_{ins}\] text field, type 30[nm].

    model.component("comp1").physics("semi").feature("gc1").set("d_ins", "30[nm]");

//    Select Boundary 5.

    model.component("comp1").physics("semi").feature("gc1").selection().set(5);

//    A range of recombination–generation mechanisms are available to be added to the model. In this case, simply add trap-assisted recombination, using the default Shockley–Read–Hall model.
//    In the Physics toolbar, click Domains and choose Trap-Assisted Recombination.

    model.component("comp1").physics("semi").create("tar1", "TrapAssistedRecombination", 2);

//    In the Settings window for Trap-Assisted Recombination, locate the Domain Selection section.
//    From the Selection list, select All domains.

    model.component("comp1").physics("semi").feature("tar1").selection().all();

//    In the Model Builder window, click Semiconductor Material Model 1.
//    In the Settings window for Semiconductor Material Model, click to expand the Band Gap Narrowing section.
//    From the Band gap narrowing list, select Jain–Roulston model.

    model.component("comp1").physics("semi").feature("smm1").set("BandGapNarrowing", "jain");

//    We will use a user-defined mesh for this model.
//    In the Model Builder window, under Component 1 (comp1), click Mesh 1.
//    In the Settings window for Mesh, locate the Sequence Type section.
//    From the list, select User-controlled mesh.

    model.component("comp1").mesh("mesh1").automatic(false);

//    In the Model Builder window, under Component 1 (comp1) > Mesh 1, click Size.
//    In the Settings window for Size, locate the Element Size section.
//    Click the Custom button.

    model.component("comp1").mesh("mesh1").feature("size").set("custom", true);

//    Locate the Element Size Parameters section.
//    In the Maximum element growth rate text field, type 1.05.

    model.component("comp1").mesh("mesh1").feature("size").set("hgrad", 1.05);

//    In the Model Builder window, right-click Size 1 and choose Delete.

    model.component("comp1").mesh("mesh1").feature().remove("size1");

//    Right-click Size 2 and choose Delete.

    model.component("comp1").mesh("mesh1").feature().remove("size2");

//    Right-click Free Triangular 1 and choose Delete.

    model.component("comp1").mesh("mesh1").feature().remove("ftri1");

//    In the Mesh toolbar, click More Generators and choose Edge.

    model.component("comp1").mesh("mesh1").create("edg1", "Edge");

//    Select Boundaries 3, 4, 5, 6, 7.

    model.component("comp1").mesh("mesh1").feature("edg1").selection().set(3, 4, 5, 6, 7);

//    In the Settings window for Edge, click to expand the Control Entities section.
//    From the Smooth across removed control entities list, select Off.

    model.component("comp1").mesh("mesh1").feature("edg1").set("smoothcontrol", false);

//    Right-click Edge 1 and choose Size.

    model.component("comp1").mesh("mesh1").feature("edg1").create("size1", "Size");

//    In the Settings window for Size, locate the Element Size section.
//    From the Calibrate for list, select Semiconductor.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("size1").set("table", "semi");

//    Click the Custom button.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("size1").set("custom", true);

//    Locate the Element Size Parameters section.
//    Select the Maximum element size checkbox.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("size1").set("hmaxactive", true);

//    In the associated text field, type 0.03.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("size1").set("hmax", 0.03);

//    In the Mesh toolbar, click Mapped.

    model.component("comp1").mesh("mesh1").create("map1", "Map");

//    In the Settings window for Mapped, locate the Domain Selection section.
//    From the Geometric entity level list, select Domain.

    model.component("comp1").mesh("mesh1").feature("map1").selection().geom("geom1", 2);

//    Select Domain 2.

    model.component("comp1").mesh("mesh1").feature("map1").selection().set(2);

//    Click to expand the Control Entities section.
//    From the Smooth across removed control entities list, select Off.

    model.component("comp1").mesh("mesh1").feature("map1").set("smoothcontrol", false);

//    Click to expand the Reduce Element Skewness section.

    return model;
  }

  public static Model run2(Model model) {
//    Select the Adjust edge mesh checkbox.

    model.component("comp1").mesh("mesh1").feature("map1").set("adjustedgdistr", true);

//    Right-click Mapped 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("map1").create("dis1", "Distribution");

//    Select Boundary 9.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").selection().set(9);

//    In the Settings window for Distribution, locate the Distribution section.
//    From the Distribution type list, select Predefined.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("type", "predefined");

//    In the Number of elements text field, type 8.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("elemcount", 8);

//    In the Element ratio text field, type 9.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("elemratio", 9);

//    From the Growth rate list, select Exponential.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("growthrate", "exponential");

//    Select the Reverse direction checkbox.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("reverse", true);

//    In the Mesh toolbar, click Free Triangular.

    model.component("comp1").mesh("mesh1").create("ftri1", "FreeTri");

//    In the Settings window for Free Triangular, click to expand the Control Entities section.
//    From the Smooth across removed control entities list, select Off.

    model.component("comp1").mesh("mesh1").feature("ftri1").set("smoothcontrol", false);

//    Click Build All.

    model.component("comp1").mesh("mesh1").run();

//    Click the Zoom Extents button in the Graphics toolbar.
//    The user-defined mesh is shown in the image below. The mapped mesh with the specific distribution helps create layers of thin elements underneath the gate, where the large gradient of the carrier concentration needs to be resolved by the mesh.
//    Before setting up the study, check that the doping was set up correctly. To do this, first get the initial value for the study.
//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std1").setGenPlots(false);

//    Disable the default plots since these are not required.
//    In the Study toolbar, click Get Initial Value.

    model.study("std1").createAutoSequences("sol");
    model.study("std1").createAutoSequences("jobs");

    model.sol("sol1").runFromTo("st1", "v1");

//    Add a 2D plot group to check the dopant distribution in the model.
//    In the Results toolbar, click 2D Plot Group.

    model.result().create("pg1", "PlotGroup2D");
    model.result("pg1").run();

//    Right-click 2D Plot Group 1 and choose Surface.

    model.result("pg1").create("surf1", "Surface");
    model.result("pg1").feature("surf1").set("evaluationsettings", "parent");

//    Plot the signed dopant concentration (Nd-Na). This quantity is positive for net donor doping and negative for net acceptor doping.
//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type semi.Nd-semi.Na.

    model.result("pg1").feature("surf1").set("expr", "semi.Nd-semi.Na");

//    In the Unit field, type 1/cm^3.

    model.result("pg1").feature("surf1").set("unit", "1/cm^3");

//    In the 2D Plot Group 1 toolbar, click Plot.

    model.result("pg1").run();

//    Click the Zoom Extents button in the Graphics toolbar.
//    The doping distribution is shown below.

    model.result("pg1").run();

//    In the Model Builder window, right-click 2D Plot Group 1 and choose Rename.
//    In the Rename 2D Plot Group dialog, type Signed Dopant Concentration in the New label text field.
//    Click OK.

    model.result("pg1").label("Signed Dopant Concentration");

//    Now set up a Stationary study to determine the turn-on voltage for the transistor. In this study, set Vd to 10 mV and sweep over Vg.
//    In the Model Builder window, under Study 1, click Step 1: Stationary.
//    In the Settings window for Stationary, click to expand the Study Extensions section.
//    The study extensions panel can be used to set up a parametric sweep.
//    Select the Auxiliary sweep checkbox.

    model.study("std1").feature("stat").set("useparam", true);

//    From the Sweep type list, select All combinations.

    model.study("std1").feature("stat").set("sweeptype", "filled");

//    Choose all combinations for the sweep to sweep over every combination of the specified parameters.
//    Click Add.

    model.study("std1").feature("stat").setIndex("pname", "Vd", 0);
    model.study("std1").feature("stat").setIndex("plistarr", "", 0);
    model.study("std1").feature("stat").setIndex("punit", "V", 0);
    model.study("std1").feature("stat").setIndex("pname", "Vd", 0);
    model.study("std1").feature("stat").setIndex("plistarr", "", 0);
    model.study("std1").feature("stat").setIndex("punit", "V", 0);

//    In the table, enter the following settings:

    model.study("std1").feature("stat").setIndex("plistarr", 0.01, 0);

//    The drain voltage is fixed at a constant value.
//    Click Add.

    model.study("std1").feature("stat").setIndex("pname", "Vg", 1);
    model.study("std1").feature("stat").setIndex("plistarr", "", 1);
    model.study("std1").feature("stat").setIndex("punit", "V", 1);
    model.study("std1").feature("stat").setIndex("pname", "Vg", 1);
    model.study("std1").feature("stat").setIndex("plistarr", "", 1);
    model.study("std1").feature("stat").setIndex("punit", "V", 1);

//    In the table, enter the following settings:

    model.study("std1").feature("stat").setIndex("plistarr", "range(0,0.2,1.4) 2 3 4", 1);

//    The gate voltage is swept between 0 and 4 V with uneven step sizes to reduce computation time and file size.
//    Running continuation for the Vg parameter configures the solver to use the solution for the previous continuation parameter step as the initial guess for the solution. It also allows the solver to take intermediate steps at values of Vg not specified in the list if necessary.
//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.sol("sol1").runAll();

    model.result("pg1").run();

//    Add a 1D plot group to plot the source current versus the gate voltage.
//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg2", "PlotGroup1D");
    model.result("pg2").run();

//    In the Settings window for 1D Plot Group, locate the Legend section.
//    From the Position list, select Upper left.

    model.result("pg2").set("legendpos", "upperleft");

//    Right-click 1D Plot Group 2 and choose Global.

    model.result("pg2").create("glob1", "Global");
    model.result("pg2").feature("glob1").set("markerpos", "datapoints");
    model.result("pg2").feature("glob1").set("linewidth", "preference");

//    The postprocessing menus contain a wide range of quantities available for plotting. Choose the current flowing into terminal 2.
//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Semiconductor > Terminals > semi.I0_2 - Terminal current - A.

    model.result("pg2").feature("glob1").set("expr", new String[]{"semi.I0_2"});
    model.result("pg2").feature("glob1").set("descr", new String[]{"Terminal current"});
    model.result("pg2").feature("glob1").set("unit", new String[]{"A"});

//    Locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg2").feature("glob1").setIndex("unit", "uA", 0);
    model.result("pg2").feature("glob1").setIndex("descr", "Terminal current", 0);

//    In the 1D Plot Group 2 toolbar, click Plot.

    model.result("pg2").run();

//    From the plot it is clear that the turn on voltage of the transistor is approximately 1.2 V.
//    Click the Zoom Extents button in the Graphics toolbar.

    model.result("pg2").run();

//    In the Model Builder window, right-click 1D Plot Group 2 and choose Rename.
//    In the Rename 1D Plot Group dialog, type Id vs. Vg (Vd=10mV) in the New label text field.
//    Click OK.

    model.result("pg2").label("Id vs. Vg (Vd=10mV)");

//    Now add an additional study to plot the source current as a function of drain voltage at a range of different gate voltages.
//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Stationary.
//    Click Add Study in the window toolbar.

    model.study().create("std2");
    model.study("std2").create("stat", "Stationary");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Stationary, click to expand the Values of Dependent Variables section.
//    Find the Initial values of variables solved for subsection.
//    From the Settings list, select User controlled.

    model.study("std2").feature("stat").set("useinitsol", true);

//    From the Method list, select Solution.

    model.study("std2").feature("stat").set("initmethod", "sol");

//    From the Study list, select Study 1, Stationary.

    model.study("std2").feature("stat").set("initstudy", "std1");

//    From the Parameter value (Vg (V),Vd (V)) list, select 9: Vg=2 V, Vd=0.01 V.

    model.study("std2").feature("stat").set("solnum", 9);

//    Locate the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

    model.study("std2").feature("stat").set("useparam", true);

//    From the Sweep type list, select All combinations.

    model.study("std2").feature("stat").set("sweeptype", "filled");

//    Click Add.

    model.study("std2").feature("stat").setIndex("pname", "Vd", 0);
    model.study("std2").feature("stat").setIndex("plistarr", "", 0);
    model.study("std2").feature("stat").setIndex("punit", "V", 0);
    model.study("std2").feature("stat").setIndex("pname", "Vd", 0);
    model.study("std2").feature("stat").setIndex("plistarr", "", 0);
    model.study("std2").feature("stat").setIndex("punit", "V", 0);
    model.study("std2").feature("stat").setIndex("pname", "Vg", 0);
    model.study("std2").feature("stat").setIndex("plistarr", "", 0);
    model.study("std2").feature("stat").setIndex("punit", "V", 0);

//    In the table, select Vg as the Auxiliary Parameter.
//    Now set up the study to sweep over Vg.
//    Click Range.
//    In the Range dialog, type 2 in the Start text field.
//    In the Step text field, type 1.
//    In the Stop text field, type 4.
//    Click Replace.

    model.study("std2").feature("stat").setIndex("plistarr", "range(2,1,4)", 0);

//    In the Settings window for Stationary, locate the Study Extensions section.
//    Click Add.

    model.study("std2").feature("stat").setIndex("pname", "Vd", 1);
    model.study("std2").feature("stat").setIndex("plistarr", "", 1);
    model.study("std2").feature("stat").setIndex("punit", "V", 1);
    model.study("std2").feature("stat").setIndex("pname", "Vd", 1);
    model.study("std2").feature("stat").setIndex("plistarr", "", 1);
    model.study("std2").feature("stat").setIndex("punit", "V", 1);

//    In this case the default Auxiliary Parameter, Vd, is the desired parameter for the sweep.
//    In the table, enter the following settings:

    model.study("std2").feature("stat").setIndex("plistarr", "range(0,0.25,1.5) 2 3 4 5", 1);
    model.study("std2").feature("stat").setIndex("punit", "V", 1);

//    The inner sweep over <c>Vd</c>, the last parameter, should be used for the continuation solver since the solution will only change slightly between close values of Vd. Configure the solver to reuse the solution from the last step of the continuation parameter sweep as the initial value for the next step for the outer sweep parameter <c>Vg</c>.
//    From the Reuse solution from previous step list, select Auto.

    model.study("std2").feature("stat").set("preusesol", "auto");

//    In the Study toolbar, click Compute.

    model.study("std2").createAutoSequences("all");

    model.sol("sol2").runAll();

    model.result().create("pg3", "PlotGroup2D");
    model.result("pg3").label("Electron Concentration (semi)");
    model.result("pg3").set("data", "dset2");
    model.result("pg3").setIndex("looplevel", 11, 0);
    model.result("pg3").setIndex("looplevel", 3, 1);
    model.result("pg3").set("showlegendsmaxmin", true);
    model.result("pg3").feature().create("surf1", "Surface");
    model.result("pg3").feature("surf1").set("expr", "semi.N");
    model.result("pg3").feature("surf1").set("unit", "1/cm^3");
    model.result("pg3").feature("surf1").set("colortable", "Prism");
    model.result("pg3").feature("surf1").set("colorscalemode", "logarithmic");
    model.result("pg3").feature("surf1").set("resolution", "norefine");
    model.result("pg3").feature("surf1").set("smooth", "internal");
    model.result("pg3").feature("surf1").set("data", "parent");
    model.result().create("pg4", "PlotGroup2D");
    model.result("pg4").label("Hole Concentration (semi)");
    model.result("pg4").set("data", "dset2");
    model.result("pg4").setIndex("looplevel", 11, 0);
    model.result("pg4").setIndex("looplevel", 3, 1);
    model.result("pg4").set("showlegendsmaxmin", true);
    model.result("pg4").feature().create("surf1", "Surface");
    model.result("pg4").feature("surf1").set("expr", "semi.P");
    model.result("pg4").feature("surf1").set("unit", "1/cm^3");
    model.result("pg4").feature("surf1").set("colortable", "Prism");
    model.result("pg4").feature("surf1").set("colorscalemode", "logarithmic");
    model.result("pg4").feature("surf1").set("resolution", "norefine");
    model.result("pg4").feature("surf1").set("smooth", "internal");
    model.result("pg4").feature("surf1").set("data", "parent");
    model.result().create("pg5", "PlotGroup2D");
    model.result("pg5").label("Electric Potential (semi)");
    model.result("pg5").set("data", "dset2");
    model.result("pg5").setIndex("looplevel", 11, 0);
    model.result("pg5").setIndex("looplevel", 3, 1);
    model.result("pg5").feature().create("surf1", "Surface");
    model.result("pg5").feature("surf1").set("expr", "V");
    model.result("pg5").feature("surf1").set("resolution", "norefine");
    model.result("pg5").feature("surf1").set("smooth", "internal");
    model.result("pg5").feature("surf1").set("data", "parent");
    model.result().create("pg6", "PlotGroup2D");
    model.result("pg6").set("data", "dset2");
    model.result("pg6").create("surf2", "Surface");
    model.result("pg6").create("surf1", "Surface");
    model.result("pg6").feature("surf2").set("expr", "semi.Nnetdop");
    model.result("pg6").feature("surf2").set("unit", "1/cm^3");
    model.result("pg6").feature("surf2").set("coloring", "gradient");
    model.result("pg6").feature("surf2").set("colorscalemode", "logarithmic");
    model.result("pg6").feature("surf2").set("topcolor", "red");
    model.result("pg6").feature("surf2").set("bottomcolor", "custom");
    model.result("pg6").feature("surf2").set("custombottomcolor", new double[]{1, 0.8, 0.8});
    model.result("pg6").feature("surf2").set("smooth", "internal");
    model.result("pg6").feature("surf2").set("data", "parent");
    model.result("pg6").feature("surf2").set("titletype", "none");
    model.result("pg6").feature("surf2").feature().create("filt1", "Filter");
    model.result("pg6").feature("surf2").feature("filt1").set("expr", "semi.Na-semi.Nd > 1[1/cm^3]");
    model.result("pg6").feature("surf2").feature("filt1").set("useder", true);
    model.result("pg6").feature("surf1").set("expr", "semi.Nnetdop");
    model.result("pg6").feature("surf1").set("unit", "1/cm^3");
    model.result("pg6").feature("surf1").set("coloring", "gradient");
    model.result("pg6").feature("surf1").set("colorscalemode", "logarithmic");
    model.result("pg6").feature("surf1").set("topcolor", "blue");
    model.result("pg6").feature("surf1").set("bottomcolor", "custom");
    model.result("pg6").feature("surf1").set("custombottomcolor", new double[]{0.8, 0.8, 1});
    model.result("pg6").feature("surf1").set("smooth", "internal");
    model.result("pg6").feature("surf1").set("data", "parent");
    model.result("pg6").feature("surf1").set("titletype", "none");
    model.result("pg6").feature("surf1").feature().create("filt1", "Filter");
    model.result("pg6").feature("surf1").feature("filt1").set("expr", "semi.Nd-semi.Na > 1[1/cm^3]");
    model.result("pg6").feature("surf1").feature("filt1").set("useder", true);
    model.result("pg6").set("titletype", "manual");
    model.result("pg6")
         .set("title", "Net Dopant Concentration \\vert N<sub>d</sub> - N<sub>a</sub>\\vert: P-type (Red), N-type (Blue)");
    model.result("pg6").set("showlegendsmaxmin", true);
    model.result("pg6").set("showlegendsunit", true);
    model.result("pg6").set("legendpos", "alternating");
    model.result("pg6").feature("surf2").label("P-Type");
    model.result("pg6").feature("surf1").label("N-Type");
    model.result("pg6").label("Net Dopant Concentration (semi)");
    model.result("pg3").run();

//    By looking at the electron concentration at <c>Vd</c> values of 0, 1, and 5 V the pinch-off of the channel can be clearly seen.
//    Click the Zoom Extents button in the Graphics toolbar.
//    By default the plot shows the results for the case <c>Vd</c>=5 V and <c>Vg</c>=4 V.
//    In the <l>Settings</l> window for <l>2D Plot Group</l>, locate the <l>Data</l> section. Change the <c>Vd</c> parameter value to 1 V and then to 0 V, each time clicking the <l>Plot</l> button to see how the results change.
//    In the <l>Model Builder</l> window, under <l>Results</l> click <l>Electric Potential (semi)</l>.
//    Once again look at the plot for <c>Vd</c> values of 5 V, 1 V, and 0 V.

    model.result("pg3").setIndex("looplevel", 1, 0);
    model.result("pg3").run();
    model.result("pg3").setIndex("looplevel", 5, 0);
    model.result("pg3").run();
    model.result("pg5").run();
    model.result("pg5").setIndex("looplevel", 1, 0);
    model.result("pg5").run();
    model.result("pg5").setIndex("looplevel", 5, 0);
    model.result("pg5").run();

//    Add another 1D plot group to plot the drain current versus the drain voltage.
//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg7", "PlotGroup1D");
    model.result("pg7").run();

//    In the Settings window for 1D Plot Group, locate the Data section.
//    From the Dataset list, select Study 2/Solution 2 (sol2).

    model.result("pg7").set("data", "dset2");

//    Locate the Legend section.
//    From the Position list, select Center.

    model.result("pg7").set("legendpos", "center");

//    Right-click 1D Plot Group 7 and choose Global.

    model.result("pg7").create("glob1", "Global");
    model.result("pg7").feature("glob1").set("markerpos", "datapoints");
    model.result("pg7").feature("glob1").set("linewidth", "preference");

//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Semiconductor > Terminals > semi.I0_2 - Terminal current - A.

    model.result("pg7").feature("glob1").set("expr", new String[]{"semi.I0_2"});
    model.result("pg7").feature("glob1").set("descr", new String[]{"Terminal current"});
    model.result("pg7").feature("glob1").set("unit", new String[]{"A"});

//    Locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg7").feature("glob1").setIndex("unit", "uA", 0);
    model.result("pg7").feature("glob1").setIndex("descr", "Terminal current", 0);

//    In the 1D Plot Group 7 toolbar, click Plot.

    model.result("pg7").run();

//    The drain current versus drain voltage diagram takes the usual form. Short channel effects can be seen at the larger gate voltages.
//    Click the Zoom Extents button in the Graphics toolbar.

    model.result("pg7").run();

//    In the Model Builder window, right-click 1D Plot Group 7 and choose Rename.
//    In the Rename 1D Plot Group dialog, type Id vs. Vd in the New label text field.
//    Click OK.

    model.result("pg7").label("Id vs. Vd");

    model.title("DC Characteristics of a MOS Transistor (MOSFET)");

    model
         .description("This example calculates the DC characteristics of a simple MOSFET. The drain current versus gate voltage characteristics are first computed in order to determine the threshold voltage for the device. Then the drain current vs. drain voltage characteristics are computed for several gate voltages. The linear and saturation regions for the device can be identified from these plots.");

    return model;
  }

  public static void main(String[] args) {
    Model model = run();
    run2(model);
  }

}
