/*
 * caughey_thomas_mobility.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 15 2026, 09:43 by COMSOL 6.4.0.421. */
public class caughey_thomas_mobility {

  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");

//    Enter model parameters.
//    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("Wfin", "10[nm]");
    model.param().descr("Wfin", "Height");
    model.param().set("Lg", "100[nm]");
    model.param().descr("Lg", "Width");
    model.param().set("tox", "1[nm]");
    model.param().descr("tox", "Gate oxide thickness");
    model.param().set("Vds", "0[V]");
    model.param().descr("Vds", "Drain source voltage");
    model.param().set("Vgs", "0[V]");
    model.param().descr("Vgs", "Gate source voltage");
    model.param().set("ds", "0");
    model.param().descr("ds", "Continuation parameter");

//    Create model geometry representing a simplified channel region of a field effect transistor.
//    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 nm.

    model.component("comp1").geom("geom1").lengthUnit("nm");

//    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 Lg.

    model.component("comp1").geom("geom1").feature("r1").set("size", new String[]{"Lg", "1"});

//    In the Height text field, type Wfin/2.

    model.component("comp1").geom("geom1").feature("r1").set("size", new String[]{"Lg", "Wfin/2"});

//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").run("r1");
    model.component("comp1").geom("geom1").create("r2", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Height text field, type Wfin/2.

    model.component("comp1").geom("geom1").feature("r2").set("size", new String[]{"1", "Wfin/2"});

//    Locate the Position section.
//    In the x text field, type -1.

    model.component("comp1").geom("geom1").feature("r2").set("pos", new double[]{-1, 0});

//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").run("r2");
    model.component("comp1").geom("geom1").create("r3", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Height text field, type Wfin/2.

    model.component("comp1").geom("geom1").feature("r3").set("size", new String[]{"1", "Wfin/2"});

//    Locate the Position section.
//    In the x text field, type Lg.

    model.component("comp1").geom("geom1").feature("r3").set("pos", new String[]{"Lg", "0"});

//    Click Build All Objects.

    model.component("comp1").geom("geom1").runPre("fin");

//    Add the built-in silicon material properties.

    model.component("comp1").geom("geom1").run();

//    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.
//    Enter physics settings.
//    In the Settings window for Semiconductor, click to expand the Continuation Settings section.
//    In the \[C_p\] text field, type ds.

    model.component("comp1").physics("semi").prop("Continuation").set("cp", "ds");

//    In the Physics toolbar, click Domains and choose Analytic Doping Model.

    model.component("comp1").physics("semi").create("adm1", "AnalyticDopingModel", 2);

//    Select Domains 1, 3.

    model.component("comp1").physics("semi").feature("adm1").selection().set(1, 3);

//    In the Settings window for Analytic Doping Model, locate the Impurity section.
//    From the Impurity type list, select Donor doping (n-type).

    model.component("comp1").physics("semi").feature("adm1").set("impurityType", "donor");

//    In the \[N_{D0}\] text field, type 1e19[1/cm^3].

    model.component("comp1").physics("semi").feature("adm1").set("NDc", "1e19[1/cm^3]");

//    In the Physics toolbar, click Domains and choose Analytic Doping Model.

    model.component("comp1").physics("semi").create("adm2", "AnalyticDopingModel", 2);

//    Select Domain 2.

    model.component("comp1").physics("semi").feature("adm2").selection().set(2);

//    In the Settings window for Analytic Doping Model, locate the Impurity section.
//    In the \[N_{A0}\] text field, type 1e15[1/cm^3].

    model.component("comp1").physics("semi").feature("adm2").set("NAc", "1e15[1/cm^3]");

//    In the Physics toolbar, click Boundaries and choose Metal Contact.

    model.component("comp1").physics("semi").create("mc1", "MetalContact", 1);

//    Select Boundary 1.

    model.component("comp1").physics("semi").feature("mc1").selection().set(1);

//    In the Settings window for Metal Contact, locate the Terminal section.
//    In the \[V_0\] text field, type Vds.

    model.component("comp1").physics("semi").feature("mc1").set("V0", "Vds");

//    In the Physics toolbar, click Boundaries and choose Metal Contact.

    model.component("comp1").physics("semi").create("mc2", "MetalContact", 1);

//    Select Boundary 10.

    model.component("comp1").physics("semi").feature("mc2").selection().set(10);

//    In the Physics toolbar, click Boundaries and choose Thin Insulator Gate.

    model.component("comp1").physics("semi").create("gc1", "GateContact", 1);

//    Select Boundary 6.

    model.component("comp1").physics("semi").feature("gc1").selection().set(6);

//    In the Settings window for Thin Insulator Gate, locate the Terminal section.
//    In the \[V_0\] text field, type Vgs.

    model.component("comp1").physics("semi").feature("gc1").set("V0", "Vgs");

//    Locate the Gate Contact section.
//    In the \[\epsilon_{ins}\] text field, type 3.9.

    model.component("comp1").physics("semi").feature("gc1").set("epsilon_ins", 3.9);

//    In the \[d_{ins}\] text field, type tox.

    model.component("comp1").physics("semi").feature("gc1").set("d_ins", "tox");

//    In the Model Builder window, click Semiconductor Material Model 1.
//    In the Physics toolbar, click Attributes and choose Caughey–Thomas Mobility Model (E).

    model.component("comp1").physics("semi").feature("smm1").create("mmct1", "CaugheyThomasMobilityModel", 2);

//    In the Settings window for Caughey–Thomas Mobility Model (E), click to expand the Continuation Settings section.
//    From the Continuation type list, select Use interface continuation parameter.

    model.component("comp1").physics("semi").feature("smm1").feature("mmct1").set("ContinuationType", "Interface");

//    Do not forget to select the mobility model in the Semiconductor Material Model node, otherwise the mobility model subnode has no effect.
//    In the Model Builder window, click Semiconductor Material Model 1.
//    In the Settings window for Semiconductor Material Model, locate the Mobility Model section.
//    From the \[\mu_{n}\] list, select Electron mobility, Caughey–Thomas (semi/smm1/mmct1).

    model.component("comp1").physics("semi").feature("smm1").set("mun_mat", "root.comp1.semi.mun_ct");

//    From the \[\mu_{p}\] list, select Hole mobility, Caughey–Thomas (semi/smm1/mmct1).

    model.component("comp1").physics("semi").feature("smm1").set("mup_mat", "root.comp1.semi.mup_ct");

//    Optionally use the finite element log formulation to compute this model.
//    In the Model Builder window, click Semiconductor (semi).
//    In the Settings window for Semiconductor, click to expand the Discretization section.
//    From the Formulation list, select Finite element, log formulation (linear shape function).

    model.component("comp1").physics("semi").prop("ShapeProperty").set("Formulation", "FEM1log");

//    Set up a user-defined mesh.
//    In the Mesh toolbar, click Mapped.

    model.component("comp1").mesh("mesh1").create("map1", "Map");

//    In the Settings window for Mapped, click to expand the Reduce Element Skewness section.
//    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 Boundaries 1, 4, 10.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").selection().set(1, 4, 10);

//    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 20.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("elemcount", 20);

//    In the Element ratio text field, type 5.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("elemratio", 5);

//    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 Model Builder window, right-click Mapped 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("map1").create("dis2", "Distribution");

//    Select Boundaries 3, 9.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis2").selection().set(3, 9);

//    Right-click Mapped 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("map1").create("dis3", "Distribution");

//    Select Boundary 6.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis3").selection().set(6);

//    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("dis3").set("type", "predefined");

//    In the Number of elements text field, type 50.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis3").set("elemcount", 50);

//    In the Element ratio text field, type 25.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis3").set("elemratio", 25);

//    From the Growth rate list, select Exponential.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis3").set("growthrate", "exponential");

//    Select the Symmetric distribution checkbox.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis3").set("symmetric", true);

//    Set up an auxiliary sweep for the <c>ds</c> parameter, with the value 0 for constant mobility and 1 for mobility model.
//    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.
//    Select the Auxiliary sweep checkbox.

    model.study("std1").feature("stat").set("useparam", true);

//    Click Add.

    model.study("std1").feature("stat").setIndex("pname", "Wfin", 0);
    model.study("std1").feature("stat").setIndex("plistarr", "", 0);
    model.study("std1").feature("stat").setIndex("punit", "m", 0);
    model.study("std1").feature("stat").setIndex("pname", "Wfin", 0);
    model.study("std1").feature("stat").setIndex("plistarr", "", 0);
    model.study("std1").feature("stat").setIndex("punit", "m", 0);

//    In the table, enter the following settings:

    model.study("std1").feature("stat").setIndex("pname", "Vds", 0);

//    Click Add.

    model.study("std1").feature("stat").setIndex("pname", "Wfin", 1);
    model.study("std1").feature("stat").setIndex("plistarr", "", 1);
    model.study("std1").feature("stat").setIndex("punit", "m", 1);
    model.study("std1").feature("stat").setIndex("pname", "Wfin", 1);
    model.study("std1").feature("stat").setIndex("plistarr", "", 1);
    model.study("std1").feature("stat").setIndex("punit", "m", 1);

//    In the table, enter the following settings:

    model.study("std1").feature("stat").setIndex("plistarr", "range(0,0.1,1)", 0);
    model.study("std1").feature("stat").setIndex("pname", "ds", 1);
    model.study("std1").feature("stat").setIndex("plistarr", "0 1", 1);

//    From the Sweep type list, select All combinations.

    model.study("std1").feature("stat").set("sweeptype", "filled");

//    From the Reuse solution from previous step list, select Auto.

    model.study("std1").feature("stat").set("preusesol", "auto");

//    The field-dependent mobility models are very nonlinear and difficult to solve in a fully coupled manner. The Semiconductor interface automatically creates a suggested solver sequence when the built-in field-dependent mobility models are used. This suggested solver sequence alternately solves the main dependent variables with the electric field variables fixed and then updates the electric field variables afterward, using the Segregated solver. By default 3 iterations are used, however depending on the model, more iterations may be needed. For this model we will use 4 iterations for better accuracy.
//    In the Study toolbar, click Show Default Solver.

    model.study("std1").showAutoSequences("all");

//    In the Model Builder window, expand the Solution 1 (sol1) node.
//    In the Model Builder window, expand the Study 1 > Solver Configurations > Solution 1 (sol1) > Stationary Solver 1 node, then click Segregated 1.
//    In the Settings window for Segregated, locate the General section.
//    In the Number of iterations text field, type 4.

    model.sol("sol1").feature("s1").feature("se1").set("segiter", 4);

//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.sol("sol1").runAll();

    model.result().create("pg1", "PlotGroup2D");
    model.result("pg1").label("Electron Concentration (semi)");
    model.result("pg1").set("showlegendsmaxmin", true);
    model.result("pg1").feature().create("surf1", "Surface");
    model.result("pg1").feature("surf1").set("expr", "semi.N");
    model.result("pg1").feature("surf1").set("unit", "1/cm^3");
    model.result("pg1").feature("surf1").set("colortable", "Prism");
    model.result("pg1").feature("surf1").set("colorscalemode", "logarithmic");
    model.result("pg1").feature("surf1").set("resolution", "norefine");
    model.result("pg1").feature("surf1").set("smooth", "internal");
    model.result("pg1").feature("surf1").set("data", "parent");
    model.result().create("pg2", "PlotGroup2D");
    model.result("pg2").label("Hole Concentration (semi)");
    model.result("pg2").set("showlegendsmaxmin", true);
    model.result("pg2").feature().create("surf1", "Surface");
    model.result("pg2").feature("surf1").set("expr", "semi.P");
    model.result("pg2").feature("surf1").set("unit", "1/cm^3");
    model.result("pg2").feature("surf1").set("colortable", "Prism");
    model.result("pg2").feature("surf1").set("colorscalemode", "logarithmic");
    model.result("pg2").feature("surf1").set("resolution", "norefine");
    model.result("pg2").feature("surf1").set("smooth", "internal");
    model.result("pg2").feature("surf1").set("data", "parent");
    model.result().create("pg3", "PlotGroup2D");
    model.result("pg3").label("Electric Potential (semi)");
    model.result("pg3").feature().create("surf1", "Surface");
    model.result("pg3").feature("surf1").set("expr", "V");
    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").set("data", "dset1");
    model.result("pg4").create("surf2", "Surface");
    model.result("pg4").create("surf1", "Surface");
    model.result("pg4").feature("surf2").set("expr", "semi.Nnetdop");
    model.result("pg4").feature("surf2").set("unit", "1/cm^3");
    model.result("pg4").feature("surf2").set("coloring", "gradient");
    model.result("pg4").feature("surf2").set("colorscalemode", "logarithmic");
    model.result("pg4").feature("surf2").set("topcolor", "red");

    return model;
  }

  public static Model run2(Model model) {
    model.result("pg4").feature("surf2").set("bottomcolor", "custom");
    model.result("pg4").feature("surf2").set("custombottomcolor", new double[]{1, 0.8, 0.8});
    model.result("pg4").feature("surf2").set("smooth", "internal");
    model.result("pg4").feature("surf2").set("data", "parent");
    model.result("pg4").feature("surf2").set("titletype", "none");
    model.result("pg4").feature("surf2").feature().create("filt1", "Filter");
    model.result("pg4").feature("surf2").feature("filt1").set("expr", "semi.Na-semi.Nd > 1[1/cm^3]");
    model.result("pg4").feature("surf2").feature("filt1").set("useder", true);
    model.result("pg4").feature("surf1").set("expr", "semi.Nnetdop");
    model.result("pg4").feature("surf1").set("unit", "1/cm^3");
    model.result("pg4").feature("surf1").set("coloring", "gradient");
    model.result("pg4").feature("surf1").set("colorscalemode", "logarithmic");
    model.result("pg4").feature("surf1").set("topcolor", "blue");
    model.result("pg4").feature("surf1").set("bottomcolor", "custom");
    model.result("pg4").feature("surf1").set("custombottomcolor", new double[]{0.8, 0.8, 1});
    model.result("pg4").feature("surf1").set("smooth", "internal");
    model.result("pg4").feature("surf1").set("data", "parent");
    model.result("pg4").feature("surf1").set("titletype", "none");
    model.result("pg4").feature("surf1").feature().create("filt1", "Filter");
    model.result("pg4").feature("surf1").feature("filt1").set("expr", "semi.Nd-semi.Na > 1[1/cm^3]");
    model.result("pg4").feature("surf1").feature("filt1").set("useder", true);
    model.result("pg4").set("titletype", "manual");
    model.result("pg4")
         .set("title", "Net Dopant Concentration \\vert N<sub>d</sub> - N<sub>a</sub>\\vert: P-type (Red), N-type (Blue)");
    model.result("pg4").set("showlegendsmaxmin", true);
    model.result("pg4").set("showlegendsunit", true);
    model.result("pg4").set("legendpos", "alternating");
    model.result("pg4").feature("surf2").label("P-Type");
    model.result("pg4").feature("surf1").label("N-Type");
    model.result("pg4").label("Net Dopant Concentration (semi)");
    model.result("pg1").run();

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg5", "PlotGroup1D");
    model.result("pg5").run();

//    In the Settings window for 1D Plot Group, type Terminal current_constant vs. Caughey–Thomas mobility in the Label text field.

    model.result("pg5").label("Terminal current_constant vs. Caughey\u2013Thomas mobility");

//    Right-click Terminal current_constant vs. Caughey–Thomas mobility and choose Global.

    model.result("pg5").create("glob1", "Global");
    model.result("pg5").feature("glob1").set("markerpos", "datapoints");
    model.result("pg5").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_1 - Terminal current - A.

    model.result("pg5").feature("glob1").set("expr", new String[]{"semi.I0_1"});
    model.result("pg5").feature("glob1").set("descr", new String[]{"Terminal current"});
    model.result("pg5").feature("glob1").set("unit", new String[]{"A"});

//    Locate the x-Axis Data section.
//    From the Axis source data list, select Vds.

    model.result("pg5").feature("glob1").set("xdatasolnumtype", "level2");

//    In the Terminal current_constant vs. Caughey–Thomas mobility toolbar, click Plot.

    model.result("pg5").run();

//    Click to expand the Legends section.
//    From the Legends list, select Manual.

    model.result("pg5").feature("glob1").set("legendmethod", "manual");

//    In the table, enter the following settings:

    model.result("pg5").feature("glob1").setIndex("legends", "Constant mobility", 0);
    model.result("pg5").feature("glob1").setIndex("legends", "Caughey-Thomas mobility", 1);

//    In the Terminal current_constant vs. Caughey–Thomas mobility toolbar, click Plot.

    model.result("pg5").run();

//    Click the Zoom Extents button in the Graphics toolbar.

    model.result("pg5").run();

//    In the Model Builder window, click Terminal current_constant vs. Caughey–Thomas mobility.
//    In the Settings window for 1D Plot Group, locate the Legend section.
//    From the Position list, select Lower right.

    model.result("pg5").set("legendpos", "lowerright");

//    In the Results toolbar, click 2D Plot Group.

    model.result().create("pg6", "PlotGroup2D");
    model.result("pg6").run();

//    In the Settings window for 2D Plot Group, type Electron mobility in the Label text field.

    model.result("pg6").label("Electron mobility");

//    Right-click Electron mobility and choose Surface.

    model.result("pg6").create("surf1", "Surface");
    model.result("pg6").feature("surf1").set("evaluationsettings", "parent");

//    In the Settings window for Surface, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Semiconductor > Mobility > semi.mun_ct - Electron mobility, Caughey–Thomas - m²/(V·s).

    model.result("pg6").feature("surf1").set("expr", "semi.mun_ct");
    model.result("pg6").feature("surf1").set("descr", "Electron mobility, Caughey\u2013Thomas");

//    In the Electron mobility toolbar, click Plot.

    model.result("pg6").run();

//    Click the Zoom Extents button in the Graphics toolbar.

    model.result("pg6").run();

//    In the Model Builder window, right-click Electron mobility and choose Duplicate.

    model.result().duplicate("pg7", "pg6");
    model.result("pg7").run();

//    In the Settings window for 2D Plot Group, type Electron drift velocity in the Label text field.

    model.result("pg7").label("Electron drift velocity");
    model.result("pg7").run();

//    In the Model Builder window, expand the Electron drift velocity node, then click Surface 1.
//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type semi.mun_ct*semi.smm1.mmct1.Fn.

    model.result("pg7").feature("surf1").set("expr", "semi.mun_ct*semi.smm1.mmct1.Fn");

//    Select the Description checkbox.

    model.result("pg7").feature("surf1").set("descractive", true);

//    In the associated text field, type Electron drift velocity.

    model.result("pg7").feature("surf1").set("descr", "Electron drift velocity");

//    In the Electron drift velocity toolbar, click Plot.

    model.result("pg7").run();

//    Click the Zoom Extents button in the Graphics toolbar.

    model.result("pg7").run();

//    In the Model Builder window, click Electron drift velocity.
//    In the Settings window for 2D Plot Group, locate the Data section.
//    From the Parameter value (ds) list, select 0.

    model.result("pg7").setIndex("looplevel", 1, 0);

//    In the Electron drift velocity toolbar, click Plot.

    model.result("pg7").run();

//    Click the Zoom Extents button in the Graphics toolbar.

    model.title("Caughey\u2013Thomas Mobility");

    model
         .description("This example demonstrates how to use the Caughey\u2013Thomas high-field saturation model for the electron and hole mobility. Field-dependent mobility makes a problem which is already highly nonlinear even more nonlinear. The Semiconductor physics interface automatically creates a suggested solver sequence for better convergence when a built-in field-dependent mobility model is used.");

    return model;
  }

  public static void main(String[] args) {
    Model model = run();
    run2(model);
  }

}
