/*
 * pm_motor_2d_efficiency_map.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 14 2026, 11:33 by COMSOL 6.4.0.420. */
public class pm_motor_2d_efficiency_map {

  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.
//    Click Done.

    model.component().create("comp1", true);

    model.component("comp1").geom().create("geom1", 2);

    model.component("comp1").mesh().create("mesh1");

//    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 mm.

    model.component("comp1").geom("geom1").lengthUnit("mm");

//    In the Model Builder window, under Global Definitions, click Parameters 1.
//    In the Settings window for Parameters, locate the Parameters section.
//    Click Load from File.
//    Browse to the model's Application Library folder and double-click the file pm_motor_2d_efficiency_map_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("Np", "10", "Number of poles");
    model.param().set("Ns", "12", "Number of slots");
    model.param().set("L", "50[mm]", "Out-of-plane thickness of motor");
    model.param().set("init_ang", "198[deg]", "Initial current angle");
    model.param().set("w_rot", "12000[rpm]", "Shaft speed");
    model.param().set("f_el", "w_rot*(Np/2)", "Electrical frequency");
    model.param().set("Ipk", "30[A]", "Phase current peak value");
    model.param().set("Nturn", "10", "Number of turns per coil");
    model.param().set("ff_slot", "0.8", "Slot filling factor");
    model.param().set("lam_rho", "7500[kg/m^3]", "Laminated core density");
    model.param().set("Nframes", "10", "Number of time frames");
    model.param().set("Cu_rho0", "1.667e-8[ohm*m]", "Copper reference resistivity");
    model.param().set("Cu_alpha", "3.862e-3[1/K]", "Copper resistivity temperature coefficient");
    model.param().set("Cu_Tref", "293.15[K]", "Copper reference temperature");
    model.param().set("Nsec", "gcd(Np,Ns)", "Number of modeled sectors (1 = full circle)");
    model.param().set("PM_Br_ref", "1.31[T]", "Magnet reference remanence flux density");
    model.param().set("PM_alpha", "-0.12[%/K]", "Magnet remanence temperature coefficient");
    model.param().set("PM_Tref", "20[degC]", "Magnet reference temperature");

//    In the Home toolbar, click Windows and choose Part Libraries.
//    In the Part Libraries window, select AC/DC Module > Rotating Machinery 2D > Rotors > Internal > surface_mounted_magnet_internal_rotor_2d in the tree.
//    Click Add to Geometry.

    model.geom()
         .load(new String[]{"part1"}, "ACDC_Module\\Rotating_Machinery_2D\\Rotors\\Internal\\surface_mounted_magnet_internal_rotor_2d.mph", new String[]{"part1"});
    model.component("comp1").geom("geom1").create("pi1", "PartInstance");
    model.component("comp1").geom("geom1").feature("pi1").set("selkeepnoncontr", false);
    model.component("comp1").geom("geom1").feature("pi1").set("part", "part1");

//    In the Model Builder window, under Component 1 (comp1) > Geometry 1, click Internal Rotor – Surface Mounted Magnets 1 (pi1).
//    In the Settings window for Part Instance, locate the Input Parameters section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "number_of_poles", "Np");
    model.component("comp1").geom("geom1").feature("pi1")
         .setEntry("inputexpr", "number_of_modeled_poles", "Np/Nsec");

//    Click to expand the Domain Selections section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepdom", "pi1_shaft.dom", true);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepdom", "pi1_rotor_iron.dom", true);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepdom", "pi1_rotor_magnets", true);
    model.component("comp1").geom("geom1").feature("pi1")
         .setEntry("selkeepdom", "pi1_rotor_solid_domains.dom", true);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepdom", "pi1_rotor_air.dom", true);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepdom", "pi1_all.dom", true);

//    In the Home toolbar, click Part Libraries.
//    In the Part Libraries window, select AC/DC Module > Rotating Machinery 2D > Stators > External > slotted_external_stator_2d in the tree.
//    Click Add to Geometry.

    model.geom()
         .load(new String[]{"part2"}, "ACDC_Module\\Rotating_Machinery_2D\\Stators\\External\\slotted_external_stator_2d.mph", new String[]{"part1"});
    model.component("comp1").geom("geom1").run("pi1");
    model.component("comp1").geom("geom1").create("pi2", "PartInstance");
    model.component("comp1").geom("geom1").feature("pi2").set("selkeepnoncontr", false);
    model.component("comp1").geom("geom1").feature("pi2").set("part", "part2");

//    In the Model Builder window, under Component 1 (comp1) > Geometry 1, click External Stator – Slotted 1 (pi2).
//    In the Settings window for Part Instance, locate the Input Parameters section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("pi2").setEntry("inputexpr", "number_of_slots", "Ns");
    model.component("comp1").geom("geom1").feature("pi2")
         .setEntry("inputexpr", "number_of_modeled_slots", "Ns/Nsec");
    model.component("comp1").geom("geom1").feature("pi2").setEntry("inputexpr", "slot_winding_type", 2);
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selkeepdom", "pi2_stator_iron.dom", true);

//    Locate the Domain Selections section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("pi2").setEntry("selkeepdom", "pi2_stator_slots", true);

//    In the Model Builder window, under Component 1 (comp1) > Geometry 1, click Form Union (fin).
//    In the Settings window for Form Union/Assembly, locate the Form Union/Assembly section.
//    From the Action list, select Form an assembly.

    model.component("comp1").geom("geom1").feature("fin").set("action", "assembly");

//    In the Home toolbar, click Build All.

    model.component("comp1").geom("geom1").run("fin");

//    Click the Zoom Extents button in the Graphics toolbar.
//    Next, create a few selections and operators that will simplify the configuration of the physics.
//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel1", "Explicit");

//    In the Settings window for Explicit, type Stator Housing in the Label text field.

    model.component("comp1").selection("sel1").label("Stator Housing");

//    Select Domain 1.

    model.component("comp1").selection("sel1").set(1);

//    In the Definitions toolbar, click Union.

    model.component("comp1").selection().create("uni1", "Union");

//    In the Settings window for Union, type Solid Materials in the Label text field.

    model.component("comp1").selection("uni1").label("Solid Materials");

//    Locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select Stator Housing, Shaft (Internal Rotor – Surface Mounted Magnets 1), Rotor iron (Internal Rotor – Surface Mounted Magnets 1), Rotor Magnets (Internal Rotor – Surface Mounted Magnets 1), Stator iron (External Stator – Slotted 1), Stator slots (External Stator – Slotted 1) in the Selections to add list.
//    Click OK.

    model.component("comp1").selection("uni1")
         .set("input", new String[]{"sel1", "geom1_pi1_shaft_dom", "geom1_pi1_rotor_iron_dom", "geom1_pi1_rotor_magnets", "geom1_pi2_stator_iron_dom", "geom1_pi2_stator_slots"});

//    In the Definitions toolbar, click Adjacent.

    model.component("comp1").selection().create("adj1", "Adjacent");

//    In the Settings window for Adjacent, type Solid Materials - External Boundaries in the Label text field.

    model.component("comp1").selection("adj1").label("Solid Materials - External Boundaries");

//    Locate the Input Entities section.
//    Under Input selections, click Add.
//    In the Add dialog, select Solid Materials in the Input selections list.
//    Click OK.

    model.component("comp1").selection("adj1").set("input", new String[]{"uni1"});

//    In the Model Builder window, right-click Selections and choose Disk.

    model.component("comp1").selection().create("disk1", "Disk");

//    In the Settings window for Disk, type Airgap Heat Flux Boundaries in the Label text field.

    model.component("comp1").selection("disk1").label("Airgap Heat Flux Boundaries");

//    Locate the Geometric Entity Level section.
//    From the Level list, select Boundary.

    model.component("comp1").selection("disk1").set("entitydim", 1);

//    Locate the Input Entities section.
//    From the Entities list, select From selections.

    model.component("comp1").selection("disk1").set("inputent", "selections");

//    Under Selections, click Add.
//    In the Add dialog, select Solid Materials - External Boundaries in the Selections list.
//    Click OK.

    model.component("comp1").selection("disk1").set("input", new String[]{"adj1"});

//    In the Settings window for Disk, locate the Size and Shape section.
//    In the Outer radius text field, type 18.

    model.component("comp1").selection("disk1").set("r", 18);

//    In the Inner radius text field, type 11.

    model.component("comp1").selection("disk1").set("rin", 11);

//    Locate the Output Entities section.
//    From the Include entity if list, select Entity inside disk.

    model.component("comp1").selection("disk1").set("condition", "inside");

//    Right-click Selections and choose Disk.

    model.component("comp1").selection().create("disk2", "Disk");

//    In the Settings window for Disk, type Laminated Core - Housing Boundaries in the Label text field.

    model.component("comp1").selection("disk2").label("Laminated Core - Housing Boundaries");

//    Locate the Geometric Entity Level section.
//    From the Level list, select Boundary.

    model.component("comp1").selection("disk2").set("entitydim", 1);

//    Locate the Size and Shape section.
//    In the Outer radius text field, type 25.5.

    model.component("comp1").selection("disk2").set("r", 25.5);

//    In the Inner radius text field, type 24.5.

    model.component("comp1").selection("disk2").set("rin", 24.5);

//    Locate the Output Entities section.
//    From the Include entity if list, select Entity inside disk.

    model.component("comp1").selection("disk2").set("condition", "inside");

//    In the Definitions toolbar, click Adjacent.

    model.component("comp1").selection().create("adj2", "Adjacent");

//    In the Settings window for Adjacent, type Winding Insulation Boundaries in the Label text field.

    model.component("comp1").selection("adj2").label("Winding Insulation Boundaries");

//    Locate the Input Entities section.
//    Under Input selections, click Add.
//    In the Add dialog, select Stator slots (External Stator – Slotted 1) in the Input selections list.
//    Click OK.

    model.component("comp1").selection("adj2").set("input", new String[]{"geom1_pi2_stator_slots"});

//    Right-click Selections and choose Disk.

    model.component("comp1").selection().create("disk3", "Disk");

//    In the Settings window for Disk, type Water Jacket - External Boundaries in the Label text field.

    model.component("comp1").selection("disk3").label("Water Jacket - External Boundaries");

//    Locate the Geometric Entity Level section.
//    From the Level list, select Boundary.

    model.component("comp1").selection("disk3").set("entitydim", 1);

//    Locate the Size and Shape section.
//    In the Outer radius text field, type 28.8.

    model.component("comp1").selection("disk3").set("r", 28.8);

//    In the Inner radius text field, type 27.5.

    model.component("comp1").selection("disk3").set("rin", 27.5);

//    Locate the Output Entities section.
//    From the Include entity if list, select Entity inside disk.

    model.component("comp1").selection("disk3").set("condition", "inside");

//    In the Definitions toolbar, click Union.

    model.component("comp1").selection().create("uni2", "Union");

//    In the Settings window for Union, type Stator Solid Materials in the Label text field.

    model.component("comp1").selection("uni2").label("Stator Solid Materials");

//    Locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select Stator Housing, Stator iron (External Stator – Slotted 1), Stator slots (External Stator – Slotted 1) in the Selections to add list.
//    Click OK.

    model.component("comp1").selection("uni2")
         .set("input", new String[]{"sel1", "geom1_pi2_stator_iron_dom", "geom1_pi2_stator_slots"});

//    In the Definitions toolbar, click Nonlocal Couplings and choose Average.

    model.component("comp1").cpl().create("aveop1", "Average");
    model.component("comp1").cpl("aveop1").set("axisym", true);

//    In the Settings window for Average, type Average 1 - Winding in the Label text field.

    model.component("comp1").cpl("aveop1").label("Average 1 - Winding");

//    Locate the Source Selection section.
//    From the Selection list, select Stator slots (External Stator – Slotted 1).

    model.component("comp1").cpl("aveop1").selection().named("geom1_pi2_stator_slots");

//    In the Definitions toolbar, click Nonlocal Couplings and choose Average.

    model.component("comp1").cpl().create("aveop2", "Average");
    model.component("comp1").cpl("aveop2").set("axisym", true);

//    In the Settings window for Average, type Average 2 - Stator Solid Materials in the Label text field.

    model.component("comp1").cpl("aveop2").label("Average 2 - Stator Solid Materials");

//    Locate the Source Selection section.
//    From the Selection list, select Stator Solid Materials.

    model.component("comp1").cpl("aveop2").selection().named("uni2");

//    In the Home toolbar, click Add Physics to open the Add Physics window.
//    In the tree, select AC/DC > Electromagnetics and Mechanics > Magnetic Machinery, Rotating, Time Periodic (mmtp).
//    Click Add to Component 1 in the window toolbar.

    model.component("comp1").physics().create("mmtp", "MagneticMachineryTimePeriodic", "geom1");

//    In the tree, select Heat Transfer > Heat Transfer in Solids (ht).
//    Click Add to Component 1 in the window toolbar.

    model.component("comp1").physics().create("ht", "HeatTransfer", "geom1");

//    In the Home toolbar, click Add Physics to close the Add Physics window.
//    In the Model Builder window, collapse the Component 1 (comp1) > Definitions node.
//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Built-in > Air.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat1", "Common");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("eta", "Piecewise");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("rho", "Analytic");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("k", "Piecewise");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("cs", "Analytic");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("an1", "Analytic");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("an2", "Analytic");
    model.component("comp1").material("mat1").propertyGroup()
         .create("RefractiveIndex", "RefractiveIndex", "Refractive index");
    model.component("comp1").material("mat1").propertyGroup()
         .create("NonlinearModel", "NonlinearModel", "Nonlinear model");
    model.component("comp1").material("mat1").propertyGroup().create("idealGas", "idealGas", "Ideal gas");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat1").label("Air");
    model.component("comp1").material("mat1").set("family", "air");
    model.component("comp1").material("mat1").propertyGroup("def").func("eta").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("def").func("eta")
         .set("pieces", new String[][]{{"200.0", "1600.0", "-8.38278E-7+8.35717342E-8*T^1-7.69429583E-11*T^2+4.6437266E-14*T^3-1.06585607E-17*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("eta").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("def").func("eta").set("fununit", "Pa*s");
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp")
         .set("pieces", new String[][]{{"200.0", "1600.0", "1047.63657-0.372589265*T^1+9.45304214E-4*T^2-6.02409443E-7*T^3+1.2858961E-10*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("expr", "pA*0.02897/R_const[K*mol/J]/T");
    model.component("comp1").material("mat1").propertyGroup("def").func("rho").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho").set("fununit", "kg/m^3");
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "293.15"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("k").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("def").func("k")
         .set("pieces", new String[][]{{"200.0", "1600.0", "-0.00227583562+1.15480022E-4*T^1-7.90252856E-8*T^2+4.11702505E-11*T^3-7.43864331E-15*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("k").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("def").func("k").set("fununit", "W/(m*K)");
    model.component("comp1").material("mat1").propertyGroup("def").func("cs")
         .set("expr", "sqrt(1.4*R_const[K*mol/J]/0.02897*T)");
    model.component("comp1").material("mat1").propertyGroup("def").func("cs").set("args", new String[]{"T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("cs").set("fununit", "m/s");
    model.component("comp1").material("mat1").propertyGroup("def").func("cs").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("cs")
         .set("plotfixedvalue", new String[]{"273.15"});
    model.component("comp1").material("mat1").propertyGroup("def").func("cs")
         .set("plotargs", new String[][]{{"T", "273.15", "373.15"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1").set("funcname", "alpha_p");
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("expr", "-1/rho(pA,T)*d(rho(pA,T),T)");
    model.component("comp1").material("mat1").propertyGroup("def").func("an1").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1").set("fununit", "1/K");
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "373.15"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("funcname", "muB");
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("expr", "0.6*eta(T)");
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("args", new String[]{"T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("fununit", "Pa*s");
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2")
         .set("plotfixedvalue", new String[]{"200"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2")
         .set("plotargs", new String[][]{{"T", "200", "1600"}});
    model.component("comp1").material("mat1").propertyGroup("def").set("thermalexpansioncoefficient", "");
    model.component("comp1").material("mat1").propertyGroup("def").set("molarmass", "");
    model.component("comp1").material("mat1").propertyGroup("def").set("bulkviscosity", "");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"alpha_p(pA,T)", "0", "0", "0", "alpha_p(pA,T)", "0", "0", "0", "alpha_p(pA,T)"});
    model.component("comp1").material("mat1").propertyGroup("def").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat1").propertyGroup("def").set("bulkviscosity", "muB(T)");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat1").propertyGroup("def").set("dynamicviscosity", "eta(T)");
    model.component("comp1").material("mat1").propertyGroup("def").set("ratioofspecificheat", "1.4");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("electricconductivity", new String[]{"0[S/m]", "0", "0", "0", "0[S/m]", "0", "0", "0", "0[S/m]"});
    model.component("comp1").material("mat1").propertyGroup("def").set("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat1").propertyGroup("def").set("density", "rho(pA,T)");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalconductivity", new String[]{"k(T)", "0", "0", "0", "k(T)", "0", "0", "0", "k(T)"});
    model.component("comp1").material("mat1").propertyGroup("def").set("soundspeed", "cs(T)");
    model.component("comp1").material("mat1").propertyGroup("def").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("def").addInput("pressure");
    model.component("comp1").material("mat1").propertyGroup("RefractiveIndex")
         .set("n", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat1").propertyGroup("NonlinearModel").set("BA", "def.gamma-1");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").label("Piecewise 2");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp")
         .set("pieces", new String[][]{{"200.0", "1600.0", "1047.63657-0.372589265*T^1+9.45304214E-4*T^2-6.02409443E-7*T^3+1.2858961E-10*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("Rs", "R_const/Mn");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("ratioofspecificheat", "1.4");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat1").propertyGroup("idealGas").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("idealGas").addInput("pressure");
    model.component("comp1").material("mat1").materialType("nonSolid");

//    In the tree, select AC/DC > Soft Iron (Without Losses).
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat2", "Common");
    model.component("comp1").material("mat2").propertyGroup().create("BHCurve", "BHCurve", "B-H Curve");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func().create("BH", "Interpolation");
    model.component("comp1").material("mat2").propertyGroup()
         .create("EffectiveBHCurve", "EffectiveBHCurve", "Effective B-H Curve");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func()
         .create("BHeff", "Interpolation");
    model.component("comp1").material("mat2").label("Soft Iron (Without Losses)");
    model.component("comp1").material("mat2").set("family", "iron");
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("electricconductivity", new String[]{"0[S/m]", "0", "0", "0", "0[S/m]", "0", "0", "0", "0[S/m]"});
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat2").propertyGroup("BHCurve").label("B-H Curve");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").label("Interpolation 1");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH")
         .set("table", new String[][]{{"0", "0"}, 
         {"663.146", "1"}, 
         {"1067.5", "1.1"}, 
         {"1705.23", "1.2"}, 
         {"2463.11", "1.3"}, 
         {"3841.67", "1.4"}, 
         {"5425.74", "1.5"}, 
         {"7957.75", "1.6"}, 
         {"12298.3", "1.7"}, 
         {"20462.8", "1.8"}, 
         {"32169.6", "1.9"}, 
         {"61213.4", "2"}, 
         {"111408", "2.1"}, 
         {"188487.757", "2.2"}, 
         {"267930.364", "2.3"}, 
         {"347507.836", "2.4"}});
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("extrap", "linear");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("fununit", new String[]{"T"});
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH")
         .set("argunit", new String[]{"A/m"});
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("plotleftextrap", false);
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("defineinv", true);
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("defineprimfun", true);
    model.component("comp1").material("mat2").propertyGroup("BHCurve").set("normB", "BH(normHin)");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").set("normH", "BH_inv(normBin)");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").set("Wpm", "BH_prim(normHin)");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").descr("normHin", "Magnetic field norm");
    model.component("comp1").material("mat2").propertyGroup("BHCurve")
         .descr("normBin", "Magnetic flux density norm");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").addInput("magneticfield");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").addInput("magneticfluxdensity");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").label("Effective B-H Curve");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .label("Interpolation 1");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("table", new String[][]{{"0", "0"}, 
         {"663.146", "1.000000051691021"}, 
         {"1067.5", "1.4936495124126294"}, 
         {"1705.23", "1.9415328461315795"}, 
         {"2463.11", "2.257765669366018"}, 
         {"3841.67", "2.609980642431287"}, 
         {"5425.74", "2.8664452090837504"}, 
         {"7957.75", "3.1441438097176118"}, 
         {"12298.3", "3.448538051654125"}, 
         {"20462.8", "3.7816711973679054"}, 
         {"32169.6", "4.058345590113038"}, 
         {"61213.4", "4.420646552950275"}, 
         {"111408", "4.721274089545955"}, 
         {"188487.757", "4.972148140718701"}, 
         {"267930.364", "5.145510860855953"}, 
         {"347507.836", "5.245510861426532"}});
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("extrap", "linear");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("fununit", new String[]{"T"});
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("argunit", new String[]{"A/m"});
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("plotleftextrap", false);
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff").set("defineinv", true);
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("defineprimfun", true);
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").set("normBeff", "BHeff(normHeffin)");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve")
         .set("normHeff", "BHeff_inv(normBeffin)");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve")
         .set("Wpmeff", "BHeff_prim(normHeffin)");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve")
         .descr("normHeffin", "Effective magnetic field norm");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve")
         .descr("normBeffin", "Effective magnetic flux density norm");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").addInput("magneticfield");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").addInput("magneticfluxdensity");

//    In the tree, select AC/DC > Copper.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat3", "Common");
    model.component("comp1").material("mat3").propertyGroup()
         .create("Enu", "Enu", "Young's modulus and Poisson's ratio");
    model.component("comp1").material("mat3").propertyGroup().create("linzRes", "linzRes", "Linearized resistivity");
    model.component("comp1").material("mat3").label("Copper");
    model.component("comp1").material("mat3").set("family", "copper");
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("electricconductivity", new String[]{"5.998e7[S/m]", "0", "0", "0", "5.998e7[S/m]", "0", "0", "0", "5.998e7[S/m]"});
    model.component("comp1").material("mat3").propertyGroup("def").set("heatcapacity", "385[J/(kg*K)]");

    return model;
  }

  public static Model run2(Model model) {
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("def").set("emissivity", "0.5");
    model.component("comp1").material("mat3").propertyGroup("def").set("density", "8940[kg/m^3]");
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("thermalconductivity", new String[]{"400[W/(m*K)]", "0", "0", "0", "400[W/(m*K)]", "0", "0", "0", "400[W/(m*K)]"});
    model.component("comp1").material("mat3").propertyGroup("Enu").set("E", "126e9[Pa]");
    model.component("comp1").material("mat3").propertyGroup("Enu").set("nu", "0.34");
    model.component("comp1").material("mat3").propertyGroup("linzRes").set("rho0", "1.667e-8[ohm*m]");
    model.component("comp1").material("mat3").propertyGroup("linzRes").set("alpha", "3.862e-3[1/K]");
    model.component("comp1").material("mat3").propertyGroup("linzRes").set("Tref", "293.15[K]");
    model.component("comp1").material("mat3").propertyGroup("linzRes").addInput("temperature");

//    In the tree, select AC/DC > Hard Magnetic Materials > Sintered NdFeB Grades (Chinese Standard) > N54 (Sintered NdFeB).
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat4", "Common");
    model.component("comp1").material("mat4").propertyGroup()
         .create("RemanentFluxDensity", "RemanentFluxDensity", "Remanent flux density");
    model.component("comp1").material("mat4").label("N54 (Sintered NdFeB)");
    model.component("comp1").material("mat4").set("family", "chrome");
    model.component("comp1").material("mat4").propertyGroup("def")
         .set("electricconductivity", new String[]{"1/1.4[uohm*m]", "0", "0", "0", "1/1.4[uohm*m]", "0", "0", "0", "1/1.4[uohm*m]"});
    model.component("comp1").material("mat4").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat4").propertyGroup("RemanentFluxDensity")
         .set("murec", new String[]{"1.05", "0", "0", "0", "1.05", "0", "0", "0", "1.05"});
    model.component("comp1").material("mat4").propertyGroup("RemanentFluxDensity").set("normBr", "1.47[T]");

//    In the tree, select Built-in > High-strength alloy steel.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat5", "Common");
    model.component("comp1").material("mat5").propertyGroup()
         .create("Enu", "Enu", "Young's modulus and Poisson's ratio");
    model.component("comp1").material("mat5").propertyGroup().create("Murnaghan", "Murnaghan", "Murnaghan");
    model.component("comp1").material("mat5").label("High-strength alloy steel");
    model.component("comp1").material("mat5").set("family", "custom");
    model.component("comp1").material("mat5")
         .set("customspecular", new double[]{0.9803921568627451, 0.9803921568627451, 0.9803921568627451});
    model.component("comp1").material("mat5").set("diffuse", "custom");
    model.component("comp1").material("mat5")
         .set("customdiffuse", new double[]{0.9803921568627451, 0.9803921568627451, 0.9803921568627451});
    model.component("comp1").material("mat5").set("ambient", "custom");
    model.component("comp1").material("mat5")
         .set("customambient", new double[]{0.5882352941176471, 0.5882352941176471, 0.5882352941176471});
    model.component("comp1").material("mat5").set("noise", true);
    model.component("comp1").material("mat5").set("fresnel", 0.99);
    model.component("comp1").material("mat5").set("roughness", 0.12);
    model.component("comp1").material("mat5").set("diffusewrap", 0);
    model.component("comp1").material("mat5").set("reflectance", 0);
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat5").propertyGroup("def").set("heatcapacity", "475[J/(kg*K)]");
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("thermalconductivity", new String[]{"44.5[W/(m*K)]", "0", "0", "0", "44.5[W/(m*K)]", "0", "0", "0", "44.5[W/(m*K)]"});
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("electricconductivity", new String[]{"4.032e6[S/m]", "0", "0", "0", "4.032e6[S/m]", "0", "0", "0", "4.032e6[S/m]"});
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"12.3e-6[1/K]", "0", "0", "0", "12.3e-6[1/K]", "0", "0", "0", "12.3e-6[1/K]"});
    model.component("comp1").material("mat5").propertyGroup("def").set("density", "7850[kg/m^3]");
    model.component("comp1").material("mat5").propertyGroup("Enu").set("E", "200[GPa]");
    model.component("comp1").material("mat5").propertyGroup("Enu").set("nu", "0.30");
    model.component("comp1").material("mat5").propertyGroup("Murnaghan").set("l", "-300[GPa]");
    model.component("comp1").material("mat5").propertyGroup("Murnaghan").set("m", "-620[GPa]");
    model.component("comp1").material("mat5").propertyGroup("Murnaghan").set("n", "-720[GPa]");

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    Select Domains 2, 18.

    model.component("comp1").material("mat2").selection().set(2, 18);

//    In the Settings window for Material, locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat2").propertyGroup("def").set("thermalconductivity", new String[]{"20"});
    model.component("comp1").material("mat2").propertyGroup("def").set("density", new String[]{"1"});
    model.component("comp1").material("mat2").propertyGroup("def").set("heatcapacity", new String[]{"1"});

//    For the coil domains, specify a value for the thermal conductivity representing the in-plane bulk property of insulated copper strands.
//    In the Model Builder window, click Copper (mat3).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Stator slots (External Stator – Slotted 1).

    model.component("comp1").material("mat3").selection().named("geom1_pi2_stator_slots");

//    Locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat3").propertyGroup("def")
         .set("thermalconductivity", new String[]{"2[W/(m*K)]"});

//    In the Model Builder window, click N54 (Sintered NdFeB) (mat4).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Rotor Magnets (Internal Rotor – Surface Mounted Magnets 1).

    model.component("comp1").material("mat4").selection().named("geom1_pi1_rotor_magnets");

//    Locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat4").propertyGroup("def").set("thermalconductivity", new String[]{"9"});
    model.component("comp1").material("mat4").propertyGroup("def").set("density", new String[]{"1"});
    model.component("comp1").material("mat4").propertyGroup("def").set("heatcapacity", new String[]{"1"});

//    In the Model Builder window, click High-strength alloy steel (mat5).
//    Select Domains 1, 20.

    model.component("comp1").material("mat5").selection().set(1, 20);

//    In the Model Builder window, collapse the Component 1 (comp1) > Materials node.
//    In the Model Builder window, under Component 1 (comp1), click Materials.
//    In the Settings window for Materials, in the Graphics window toolbar, click ^ next to Colors, then choose Show Material Color and Texture.

    model.component("comp1").view("view1").set("showmaterial", true);

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Model Builder window, under Component 1 (comp1), click Magnetic Machinery, Rotating, Time Periodic (mmtp).
//    In the Settings window for Magnetic Machinery, Rotating, Time Periodic, locate the Domain Selection section.
//    In the list, select 1.
//    select 1 in the list.
//    Click Remove from Selection.

    model.component("comp1").physics("mmtp").selection()
         .set(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23);

//    Select Domains 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23.
//    In the list, select 20.
//    select 20 in the list.
//    Click Remove from Selection.

    model.component("comp1").physics("mmtp").selection()
         .set(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23);

//    Select Domains 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23.
//    Locate the Thickness section.
//    In the \[d\] text field, type L.

    model.component("comp1").physics("mmtp").prop("d").set("d", "L");

//    Locate the Time Periodic Settings section.
//    In the \[n_\mathrm{TP}\] text field, type Nframes.

    model.component("comp1").physics("mmtp").prop("TimePeriodicSettings").set("nTP", "Nframes");

//    In the \[f_\mathrm{TP}\] text field, type w_rot.

    model.component("comp1").physics("mmtp").prop("TimePeriodicSettings").set("freqTP", "w_rot");

//    Locate the Motion Settings section.
//    In the \[n_{\textrm{poles}}\] text field, type Np.

    model.component("comp1").physics("mmtp").prop("MotionSettings").set("NoPoles", "Np");

//    Click Add Rotational Boundary Features.

    model.component("comp1").physics("mmtp").feature().create("drcon1", "RotationalContinuityPair");
    model.component("comp1").physics("mmtp").feature("drcon1").set("pairs", "ap1");
    model.component("comp1").physics("mmtp").feature().create("drper1", "RotationalPeriodicity");
    model.component("comp1").physics("mmtp").feature("drper1").selection()
         .set(2, 3, 4, 8, 12, 32, 33, 37, 38, 39, 119, 121, 130, 134);

//    In the Physics toolbar, click Domains and choose Rotating Domain.

    model.component("comp1").physics("mmtp").create("tprot1", "TimePeriodicRotatingDomain", 2);

//    In the Settings window for Rotating Domain, locate the Rotating Domain section.
//    From the Time periodic rotation list, select Full mechanical revolution.

    model.component("comp1").physics("mmtp").feature("tprot1")
         .set("TimePeriodicRotationType", "FullMechanicalRevolution");

//    In the Physics toolbar, click Domains and choose Laminated Core.

    model.component("comp1").physics("mmtp").create("lc1", "LaminatedCore", 2);

//    Select Domains 2, 18.

    model.component("comp1").physics("mmtp").feature("lc1").selection().set(2, 18);

//    In the Physics toolbar, click Domains and choose Magnet.

    model.component("comp1").physics("mmtp").create("mag1", "Magnet", 2);

//    In the Settings window for Magnet, locate the Domain Selection section.
//    From the Selection list, select Rotor Magnets (Internal Rotor – Surface Mounted Magnets 1).

    model.component("comp1").physics("mmtp").feature("mag1").selection().named("geom1_pi1_rotor_magnets");

//    Locate the Magnet section.
//    From the Pattern type list, select Circular pattern.

    model.component("comp1").physics("mmtp").feature("mag1").set("PatternType", "CircularPattern");

//    From the Type of periodicity list, select Alternating.

    model.component("comp1").physics("mmtp").feature("mag1").set("PeriodicType", "Alternating");

//    Locate the Constitutive Relation B-H section.
//    From the \[\left\| \, {\mathbf{B} \,\! }_\textrm{r} \; \right\|\] list, select User defined.

    model.component("comp1").physics("mmtp").feature("mag1")
         .set("normBr_crel_BH_RemanentFluxDensity_mat", "userdef");

//    In the associated text field, type PM_Br_ref*(1+PM_alpha*(T-PM_Tref)).

    model.component("comp1").physics("mmtp").feature("mag1")
         .set("normBr_crel_BH_RemanentFluxDensity", "PM_Br_ref*(1+PM_alpha*(T-PM_Tref))");

//    In the Model Builder window, expand the Magnet 1 node, then click North 1.
//    Select Boundaries 161, 163, 164.

    model.component("comp1").physics("mmtp").feature("mag1").feature("north1").selection().set(161, 163, 164);

//    In the Model Builder window, click South 1.
//    Select Boundary 159.

    model.component("comp1").physics("mmtp").feature("mag1").feature("south1").selection().set(159);

//    In the Model Builder window, collapse the Component 1 (comp1) > Magnetic Machinery, Rotating, Time Periodic (mmtp) > Magnet 1 node.
//    In the Physics toolbar, click Domains and choose Multiphase Winding.

    model.component("comp1").physics("mmtp").create("wnd1", "MultiphaseWinding", 2);

//    In the Settings window for Multiphase Winding, locate the Domain Selection section.
//    From the Selection list, select Stator slots (External Stator – Slotted 1).

    model.component("comp1").physics("mmtp").feature("wnd1").selection().named("geom1_pi2_stator_slots");

//    Locate the Multiphase Winding section.
//    In the \[I_\mathrm{pk}\] text field, type Ipk.

    model.component("comp1").physics("mmtp").feature("wnd1").set("Ipk", "Ipk");

//    In the \[\alpha_\textrm{i}\] text field, type init_ang.

    model.component("comp1").physics("mmtp").feature("wnd1").set("alpha_i", "init_ang");

//    In the \[f_\textrm{t}\] text field, type f_el.

    model.component("comp1").physics("mmtp").feature("wnd1").set("freq_signal", "f_el");

//    From the Winding layout configuration list, select Automatic three phase.

    model.component("comp1").physics("mmtp").feature("wnd1").set("WindingLayout", "automatic");

//    In the \[n_{\textrm{slots}}\] text field, type Ns.

    model.component("comp1").physics("mmtp").feature("wnd1").set("NoSlots", "Ns");

//    Click Add Phases.

    model.component("comp1").physics("mmtp").feature("wnd1").runCommand("addPhases");

//    In the Model Builder window, collapse the Component 1 (comp1) > Magnetic Machinery, Rotating, Time Periodic (mmtp) > Multiphase Winding 1 node.
//    In the Model Builder window, click Multiphase Winding 1.
//    In the Settings window for Multiphase Winding, locate the Homogenized Conductor section.
//    In the \[N\] text field, type Nturn.

    model.component("comp1").physics("mmtp").feature("wnd1").set("N", "Nturn");

//    In the \[\sigma\] text field, type 1/(Cu_rho0*(1+Cu_alpha*(aveop1(T)-Cu_Tref))).

    model.component("comp1").physics("mmtp").feature("wnd1")
         .set("sigmaCoil", "1/(Cu_rho0*(1+Cu_alpha*(aveop1(T)-Cu_Tref)))");

//    In the \[f\] text field, type ff_slot.

    model.component("comp1").physics("mmtp").feature("wnd1").set("FillingFactor", "ff_slot");

//    In the Model Builder window, under Component 1 (comp1), click Heat Transfer in Solids (ht).
//    In the Settings window for Heat Transfer in Solids, locate the Domain Selection section.
//    From the Selection list, select Solid Materials.

    model.component("comp1").physics("ht").selection().named("uni1");

//    Locate the Physical Model section.
//    In the \[d_z\] text field, type L.

    model.component("comp1").physics("ht").prop("PhysicalModelProperty").set("dz", "L");

//    Click to expand the Discretization section.
//    From the Temperature list, select Linear.

    model.component("comp1").physics("ht").prop("ShapeProperty").set("order_temperature", 1);

//    In the Physics toolbar, click Boundaries and choose Thin Layer.

    model.component("comp1").physics("ht").create("sls1", "SolidLayeredShell", 1);

//    In the Settings window for Thin Layer, type Thin Layer 1 - Laminated Core <> Housing in the Label text field.

    model.component("comp1").physics("ht").feature("sls1").label("Thin Layer 1 - Laminated Core <> Housing");

//    Locate the Boundary Selection section.
//    From the Selection list, select Laminated Core - Housing Boundaries.

    model.component("comp1").physics("ht").feature("sls1").selection().named("disk2");

//    Locate the Shell Properties section.
//    From the Shell type list, select Nonlayered shell.

    model.component("comp1").physics("ht").feature("sls1").set("lth_mat", "userdef");

//    In the \[L_\textrm{th}\] text field, type 0.5e-4[m].

    model.component("comp1").physics("ht").feature("sls1").set("lth", "0.5e-4[m]");

//    Locate the Heat Conduction section.
//    From the \[k\] list, select User defined.

    model.component("comp1").physics("ht").feature("sls1").set("k_mat", "userdef");

//    In the associated text field, type 0.02.

    model.component("comp1").physics("ht").feature("sls1")
         .set("k", new double[]{0.02, 0, 0, 0, 0.02, 0, 0, 0, 0.02});

//    In the Physics toolbar, click Boundaries and choose Thin Layer.

    model.component("comp1").physics("ht").create("sls2", "SolidLayeredShell", 1);

//    In the Settings window for Thin Layer, type Thin Layer 2 - Winding Insulation in the Label text field.

    model.component("comp1").physics("ht").feature("sls2").label("Thin Layer 2 - Winding Insulation");

//    Locate the Boundary Selection section.
//    From the Selection list, select Winding Insulation Boundaries.

    model.component("comp1").physics("ht").feature("sls2").selection().named("adj2");

//    Locate the Shell Properties section.
//    From the Shell type list, select Nonlayered shell.

    model.component("comp1").physics("ht").feature("sls2").set("lth_mat", "userdef");

//    In the \[L_\textrm{th}\] text field, type 2e-4[m].

    model.component("comp1").physics("ht").feature("sls2").set("lth", "2e-4[m]");

//    Locate the Heat Conduction section.
//    From the \[k\] list, select User defined.

    model.component("comp1").physics("ht").feature("sls2").set("k_mat", "userdef");

//    In the associated text field, type 0.2.

    model.component("comp1").physics("ht").feature("sls2").set("k", new double[]{0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2});

//    In the Physics toolbar, click Boundaries and choose Heat Flux.

    model.component("comp1").physics("ht").create("hf1", "HeatFluxBoundary", 1);

//    In the Settings window for Heat Flux, type Heat Flux 1 - Water Jacket in the Label text field.

    model.component("comp1").physics("ht").feature("hf1").label("Heat Flux 1 - Water Jacket");

//    Locate the Boundary Selection section.
//    From the Selection list, select Water Jacket - External Boundaries.

    model.component("comp1").physics("ht").feature("hf1").selection().named("disk3");

//    Locate the Heat Flux section.
//    From the Flux type list, select Convective heat flux.

    model.component("comp1").physics("ht").feature("hf1").set("HeatFluxType", "ConvectiveHeatFlux");

//    In the \[h\] text field, type 500.

    model.component("comp1").physics("ht").feature("hf1").set("h", 500);

//    In the \[T_{\textrm{ext}}\] text field, type 25[degC].

    model.component("comp1").physics("ht").feature("hf1").set("Text", "25[degC]");

//    In the Physics toolbar, click Boundaries and choose Heat Flux.

    model.component("comp1").physics("ht").create("hf2", "HeatFluxBoundary", 1);

//    In the Settings window for Heat Flux, type Heat Flux 2 - Airgap in the Label text field.

    model.component("comp1").physics("ht").feature("hf2").label("Heat Flux 2 - Airgap");

//    Locate the Boundary Selection section.
//    From the Selection list, select Airgap Heat Flux Boundaries.

    model.component("comp1").physics("ht").feature("hf2").selection().named("disk1");

//    Locate the Heat Flux section.
//    From the Flux type list, select Convective heat flux.

    model.component("comp1").physics("ht").feature("hf2").set("HeatFluxType", "ConvectiveHeatFlux");

//    In the \[h\] text field, type 50.

    model.component("comp1").physics("ht").feature("hf2").set("h", 50);

//    In the \[T_{\textrm{ext}}\] text field, type aveop2(T).

    model.component("comp1").physics("ht").feature("hf2").set("Text", "aveop2(T)");

//    In the Physics toolbar, click Boundaries and choose Periodic Condition.

    model.component("comp1").physics("ht").create("pc1", "PeriodicHeat", 1);

//    Click the Select Box button in the Graphics toolbar.
//    Select Boundaries 1, 2, 3, 8, 33, 38, 39, 40, 121, 125, 127, 130.

    model.component("comp1").physics("ht").feature("pc1").selection()
         .set(1, 2, 3, 8, 33, 38, 39, 40, 121, 125, 127, 130);

//    In the Physics toolbar, click Multiphysics Couplings and choose Domain > Electromagnetic Heating.

    model.component("comp1").multiphysics().create("emh1", "ElectromagneticHeating", 2);

//    In the Model Builder window, right-click Component 1 (comp1) > Mesh 1 and choose Edit Physics-Induced Sequence.

    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 Curvature factor text field, type 0.6.

    model.component("comp1").mesh("mesh1").feature("size").set("hcurve", 0.6);

//    In the Resolution of narrow regions text field, type 0.5.

    model.component("comp1").mesh("mesh1").feature("size").set("hnarrow", 0.5);

//    In the Model Builder window, right-click Mesh 1 and choose Size.

    model.component("comp1").mesh("mesh1").create("size1", "Size");

//    Drag and drop Size 1 below Size.

    model.component("comp1").mesh("mesh1").feature().move("size1", 1);

//    In the Settings window for Size, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Domain.

    model.component("comp1").mesh("mesh1").feature("size1").selection().geom("geom1", 2);

//    From the Selection list, select Stator iron (External Stator – Slotted 1).

    model.component("comp1").mesh("mesh1").feature("size1").selection().named("geom1_pi2_stator_iron_dom");

//    Click to expand the Element Size Parameters section.
//    Locate the Element Size section.
//    Click the Custom button.

    model.component("comp1").mesh("mesh1").feature("size1").set("custom", true);

//    Locate the Element Size Parameters section.
//    Select the Maximum element size checkbox.

    model.component("comp1").mesh("mesh1").feature("size1").set("hmaxactive", true);

//    In the associated text field, type 1.

    model.component("comp1").mesh("mesh1").feature("size1").set("hmax", 1);

//    Click Build All.

    model.component("comp1").mesh("mesh1").run();

//    In the Model Builder window, collapse the Component 1 (comp1) > Mesh 1 node.
//    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("std1");
    model.study("std1").create("stat", "Stationary");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, type Study 1 - Convergence with Number of Time Frames in the Label text field.

    model.study("std1").label("Study 1 - Convergence with Number of Time Frames");

//    In the Study toolbar, click Parametric Sweep.

    model.study("std1").create("param", "Parametric");

//    In the Settings window for Parametric Sweep, locate the Study Settings section.
//    Click Add.

    model.study("std1").feature("param").setIndex("pname", "Np", 0);
    model.study("std1").feature("param").setIndex("plistarr", "", 0);
    model.study("std1").feature("param").setIndex("punit", "", 0);
    model.study("std1").feature("param").setIndex("pname", "Np", 0);
    model.study("std1").feature("param").setIndex("plistarr", "", 0);
    model.study("std1").feature("param").setIndex("punit", "", 0);

//    In the table, enter the following settings:

    model.study("std1").feature("param").setIndex("pname", "Nframes", 0);
    model.study("std1").feature("param").setIndex("plistarr", "10 30 60 120 180 240", 0);

//    In order to parameterize the number of time frames solved for it is necessary to disable the Parametric solver.
//    Click to expand the Advanced Settings section.
//    From the Use parametric solver list, select Off.

    model.study("std1").feature("param").set("paramselect", false);

//    Select the Reuse solution from previous step checkbox.

    model.study("std1").feature("param").set("reusesol", true);

//    While the Heat transfer is heavily influenced by the Magnetic Machinery in this case, the dependence on the coil resistivity and magnetic remanence flux density is only loosely coupled with temperature. For this problem, a Segregated solver is more efficient than the default Fully coupled.
//    In the Study toolbar, click Show Default Solver.

    model.study("std1").showAutoSequences("all");

//    In the Model Builder window, expand the Solution 1 (sol1) node.
//    Right-click Study 1 - Convergence with Number of Time Frames > Solver Configurations > Solution 1 (sol1) > Stationary Solver 1 and choose Segregated.

    model.sol("sol1").feature("s1").create("se1", "Segregated");

//    In the Model Builder window, expand the Study 1 - Convergence with Number of Time Frames > Solver Configurations > Solution 1 (sol1) > Stationary Solver 1 > Segregated 1 node, then click Segregated Step.
//    In the Settings window for Segregated Step, type Magnetic Field in the Label text field.

    model.sol("sol1").feature("s1").feature("se1").feature("ssDef").label("Magnetic Field");

//    Locate the General section.
//    In the Variables list, select External Temperature (comp1.ht.TextFace), Temperature (comp1.T).
//    Under Variables, click Delete.

    model.sol("sol1").feature("s1").feature("se1").feature("ssDef")
         .set("segvar", new String[]{"comp1_mmtp_AZ_tp0", "comp1_mmtp_drcon1_AZLM_tp0", "comp1_mmtp_mag1_V_d0_tp0"});

//    Click to expand the Method and Termination section.
//    From the Termination technique list, select Tolerance.

    model.sol("sol1").feature("s1").feature("se1").feature("ssDef").set("subtermconst", "tol");

//    In the Model Builder window, right-click Study 1 - Convergence with Number of Time Frames > Solver Configurations > Solution 1 (sol1) > Stationary Solver 1 > Segregated 1 and choose Segregated Step.

    model.sol("sol1").feature("s1").feature("se1").create("ss1", "SegregatedStep");

//    In the Settings window for Segregated Step, type Temperature Field in the Label text field.

    model.sol("sol1").feature("s1").feature("se1").feature("ss1").label("Temperature Field");

//    Locate the General section.
//    Under Variables, click Add.
//    In the Add dialog, select External Temperature (comp1.ht.TextFace), Temperature (comp1.T) in the Variables list.
//    Click OK.

    model.sol("sol1").feature("s1").feature("se1").feature("ss1")
         .set("segvar", new String[]{"comp1_ht_TextFace", "comp1_T"});

//    In the Model Builder window, collapse the Study 1 - Convergence with Number of Time Frames > Solver Configurations node.
//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.sol().create("sol2");
    model.sol("sol2").study("std1");
    model.sol("sol2").label("Parametric Solutions 1");

    model.batch("p1").feature("so1").set("psol", "sol2");
    model.batch("p1").run("compute");

    model.result().create("pg1", "PlotGroup2D");
    model.result("pg1").label("Magnetic Flux Density Norm (mmtp)");
    model.result("pg1").set("data", "dset2");
    model.result("pg1").setIndex("looplevel", 6, 0);
    model.result("pg1").set("titletype", "label");
    model.result("pg1").set("edges", "off");
    model.result("pg1").set("showlegendsmaxmin", true);
    model.result("pg1").set("smooth", "internal");
    model.result("pg1").feature().create("surf1", "Surface");
    model.result("pg1").feature("surf1").set("solutionparams", "parent");
    model.result("pg1").feature("surf1").set("expr", "mmtp.normB(phase)");
    model.result("pg1").feature("surf1").set("colortable", "Prism");
    model.result("pg1").feature("surf1").set("colortabletrans", "nonlinear");
    model.result("pg1").feature("surf1").set("colorcalibration", -0.8);
    model.result("pg1").feature("surf1").set("data", "parent");
    model.result("pg1").feature("surf1").feature().create("def1", "Deform");
    model.result("pg1").feature("surf1").feature("def1")
         .set("expr", new String[]{"mmtp.displX(phase)", "mmtp.displY(phase)"});
    model.result("pg1").feature("surf1").feature("def1").set("scaleactive", true);
    model.result("pg1").feature().create("str1", "Streamline");
    model.result("pg1").feature("str1").set("expr", new String[]{"mmtp.BX(phase)", "mmtp.BY(phase)"});
    model.result("pg1").feature("str1").set("posmethod", "uniform");
    model.result("pg1").feature("str1").set("udensity", 6.7);
    model.result("pg1").feature("str1").set("smooth", "internal");
    model.result("pg1").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("str1").set("data", "parent");
    model.result("pg1").feature("str1").selection().geom("geom1", 1);
    model.result("pg1").feature("str1").selection()
         .set(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 124, 126, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164);
    model.result("pg1").feature("str1").feature().create("col1", "Color");
    model.result("pg1").feature("str1").feature("col1").set("expr", "mmtp.normB(phase)");
    model.result("pg1").feature("str1").feature("col1").set("colortable", "PrismDark");
    model.result("pg1").feature("str1").feature("col1").set("colorlegend", false);
    model.result("pg1").feature("str1").feature("col1").set("colortabletrans", "nonlinear");
    model.result("pg1").feature("str1").feature("col1").set("colorcalibration", -0.8);
    model.result("pg1").feature("str1").feature().create("filt1", "Filter");
    model.result("pg1").feature("str1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result("pg1").feature("str1").feature().create("def1", "Deform");
    model.result("pg1").feature("str1").feature("def1")
         .set("expr", new String[]{"mmtp.displX(phase)", "mmtp.displY(phase)"});
    model.result("pg1").feature("str1").feature("def1").set("scaleactive", true);
    model.result("pg1").feature().create("con1", "Contour");

    return model;
  }

  public static Model run3(Model model) {
    model.result("pg1").feature("con1").set("solutionparams", "parent");
    model.result("pg1").feature("con1").set("expr", "mmtp.AZ(phase)");
    model.result("pg1").feature("con1").set("number", 10);
    model.result("pg1").feature("con1").set("levelrounding", false);
    model.result("pg1").feature("con1").set("coloring", "uniform");
    model.result("pg1").feature("con1").set("colorlegend", false);
    model.result("pg1").feature("con1").set("color", "custom");
    model.result("pg1").feature("con1")
         .set("customcolor", new double[]{0.4117647111415863, 0.4117647111415863, 0.4117647111415863});
    model.result("pg1").feature("con1").set("smooth", "internal");
    model.result("pg1").feature("con1").set("data", "parent");
    model.result("pg1").feature("con1").feature().create("filt1", "Filter");
    model.result("pg1").feature("con1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result("pg1").feature("con1").feature().create("def1", "Deform");
    model.result("pg1").feature("con1").feature("def1")
         .set("expr", new String[]{"mmtp.displX(phase)", "mmtp.displY(phase)"});
    model.result("pg1").feature("con1").feature("def1").set("scaleactive", true);
    model.result("pg1").feature().create("line1", "Line");
    model.result("pg1").feature("line1").set("expr", "1");
    model.result("pg1").feature("line1").set("coloring", "uniform");
    model.result("pg1").feature("line1").set("color", "fromtheme");
    model.result("pg1").feature("line1").set("smooth", "internal");
    model.result("pg1").feature("line1").set("data", "parent");
    model.result("pg1").feature("line1").feature().create("def1", "Deform");
    model.result("pg1").feature("line1").feature("def1")
         .set("expr", new String[]{"mmtp.displX(phase)", "mmtp.displY(phase)"});
    model.result("pg1").feature("line1").feature("def1").set("scaleactive", true);
    model.result().create("pg2", "PlotGroup2D");
    model.result("pg2").label("Temperature (ht)");
    model.result("pg2").set("data", "dset2");
    model.result("pg2").setIndex("looplevel", 6, 0);
    model.result("pg2").set("smooth", "internal");
    model.result("pg2").feature().create("surf1", "Surface");
    model.result("pg2").feature("surf1").set("solutionparams", "parent");
    model.result("pg2").feature("surf1").set("colortable", "HeatCameraLight");
    model.result("pg2").feature("surf1").set("data", "parent");
    model.result("pg1").run();

//    The following steps will create an Evaluation group and a plot to inspect the convergence with number of time frames.
//    In the Results toolbar, click Evaluation Group.

    model.result().evaluationGroup().create("eg1", "EvaluationGroup");

//    Right-click Evaluation Group 1 and choose Global Evaluation.

    model.result().evaluationGroup("eg1").create("gev1", "EvalGlobal");

//    In the Settings window for Global Evaluation, click Replace Expression in the upper-right corner of the Expressions section.
//    From the menu, choose Component 1 (comp1) > Magnetic Machinery, Rotating, Time Periodic > Mechanical > mmtp.drcon1.Tax_tpavg - Axial torque, time periodic average - N·m.

    model.result().evaluationGroup("eg1").feature("gev1").set("expr", new String[]{"mmtp.drcon1.Tax_tpavg"});
    model.result().evaluationGroup("eg1").feature("gev1")
         .set("descr", new String[]{"Axial torque, time periodic average"});
    model.result().evaluationGroup("eg1").feature("gev1").set("unit", new String[]{"N*m"});

//    Locate the Expressions section.
//    In the table, enter the following settings:

    model.result().evaluationGroup("eg1").feature("gev1").setIndex("descr", "Torque", 0);

//    In the Model Builder window, right-click Evaluation Group 1 and choose Integration > Surface Integration.

    model.result().evaluationGroup("eg1").create("int1", "IntSurface");
    model.result().evaluationGroup("eg1").feature("int1").set("intvolume", true);

//    In the Settings window for Surface Integration, locate the Selection section.
//    From the Selection list, select Stator slots (External Stator – Slotted 1).

    model.result().evaluationGroup("eg1").feature("int1").selection().named("geom1_pi2_stator_slots");

//    Locate the Expressions section.
//    In the table, enter the following settings:

    model.result().evaluationGroup("eg1").feature("int1").setIndex("expr", "mmtp.Qh*L*Nsec", 0);
    model.result().evaluationGroup("eg1").feature("int1").setIndex("descr", "Winding", 0);

//    Right-click Surface Integration 1 and choose Duplicate.

    model.result().evaluationGroup("eg1").feature().duplicate("int2", "int1");

//    In the Settings window for Surface Integration, locate the Selection section.
//    From the Selection list, select Stator iron (External Stator – Slotted 1).

    model.result().evaluationGroup("eg1").feature("int2").selection().named("geom1_pi2_stator_iron_dom");

//    Locate the Expressions section.
//    In the table, enter the following settings:

    model.result().evaluationGroup("eg1").feature("int2").setIndex("descr", "Stator core", 0);

//    Right-click Surface Integration 2 and choose Duplicate.

    model.result().evaluationGroup("eg1").feature().duplicate("int3", "int2");

//    In the Settings window for Surface Integration, locate the Selection section.
//    From the Selection list, select Rotor Magnets (Internal Rotor – Surface Mounted Magnets 1).

    model.result().evaluationGroup("eg1").feature("int3").selection().named("geom1_pi1_rotor_magnets");

//    Locate the Expressions section.
//    In the table, enter the following settings:

    model.result().evaluationGroup("eg1").feature("int3").setIndex("descr", "Magnets", 0);

//    Right-click Surface Integration 3 and choose Duplicate.

    model.result().evaluationGroup("eg1").feature().duplicate("int4", "int3");

//    In the Settings window for Surface Integration, locate the Selection section.
//    From the Selection list, select Rotor iron (Internal Rotor – Surface Mounted Magnets 1).

    model.result().evaluationGroup("eg1").feature("int4").selection().named("geom1_pi1_rotor_iron_dom");

//    Locate the Expressions section.
//    In the table, enter the following settings:

    model.result().evaluationGroup("eg1").feature("int4").setIndex("descr", "Rotor core", 0);

//    In the Model Builder window, click Evaluation Group 1.
//    In the Settings window for Evaluation Group, locate the Data section.
//    From the Dataset list, select Study 1 - Convergence with Number of Time Frames/Parametric Solutions 1 (sol2).

    model.result().evaluationGroup("eg1").set("data", "dset2");

//    In the Evaluation Group 1 toolbar, click Evaluate.

    model.result().evaluationGroup("eg1").run();

//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg3", "PlotGroup1D");
    model.result("pg3").run();

//    In the Settings window for 1D Plot Group, type Convergence with Number of Frames in the Label text field.

    model.result("pg3").label("Convergence with Number of Frames");

//    Locate the Plot Settings section.
//    Select the y-axis label checkbox.

    model.result("pg3").set("ylabelactive", true);

//    In the associated text field, type Electromagnetic loss [W].

    model.result("pg3").set("ylabel", "Electromagnetic loss [W]");

//    Select the Two y-axes checkbox.

    model.result("pg3").set("twoyaxes", true);

//    Locate the Legend section.
//    From the Position list, select Middle right.

    model.result("pg3").set("legendpos", "middleright");

//    Right-click Convergence with Number of Frames and choose Table Graph.

    model.result("pg3").create("tblp1", "Table");
    model.result("pg3").feature("tblp1").set("markerpos", "datapoints");
    model.result("pg3").feature("tblp1").set("linewidth", "preference");

//    In the Settings window for Table Graph, locate the Data section.
//    From the Source list, select Evaluation group.

    model.result("pg3").feature("tblp1").set("source", "evaluationgroup");

//    From the x-axis data list, select Nframes.

    model.result("pg3").feature("tblp1").set("xaxisdata", 1);

//    From the Plot columns list, select Manual.

    model.result("pg3").feature("tblp1").set("plotcolumninput", "manual");

//    In the Columns list, select Torque (N*m).

    model.result("pg3").feature("tblp1").set("plotcolumns", new int[]{2});

//    select Torque (N*m) in the Columns list.
//    Locate the y-Axis section.
//    Select the Plot on secondary y-axis checkbox.

    model.result("pg3").feature("tblp1").set("plotonsecyaxis", true);

//    Locate the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg3").feature("tblp1").set("linewidth", 2);

//    Click to expand the Legends section.
//    Select the Show legends checkbox.

    model.result("pg3").feature("tblp1").set("legend", true);

//    Right-click Table Graph 1 and choose Duplicate.

    model.result("pg3").feature().duplicate("tblp2", "tblp1");
    model.result("pg3").run();

//    In the Settings window for Table Graph, locate the Data section.
//    In the Columns list, select Winding (W), Stator core (W), Magnets (W), Rotor core (W).

    model.result("pg3").feature("tblp2").set("plotcolumns", new int[]{3, 4, 5, 6});

//    Locate the y-Axis section.
//    Clear the Plot on secondary y-axis checkbox.

    model.result("pg3").feature("tblp2").set("plotonsecyaxis", false);

//    In the Convergence with Number of Frames toolbar, click Plot.

    model.result("pg3").run();

//    In the Model Builder window, collapse the Results > Convergence with Number of Frames node.
//    Update the number of frames and create a new study sweeping over a range of speeds and current levels needed to generate the efficiency map.
//    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("Nframes", "120");

//    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 Study, type Study 2 - Efficiency Map in the Label text field.

    model.study("std2").label("Study 2 - Efficiency Map");

//    In the Study toolbar, click Parametric Sweep.

    model.study("std2").create("param", "Parametric");

//    In the Settings window for Parametric Sweep, locate the Study Settings section.
//    From the Sweep type list, select All combinations.

    model.study("std2").feature("param").set("sweeptype", "filled");

//    Click Add.

    model.study("std2").feature("param").setIndex("pname", "Np", 0);
    model.study("std2").feature("param").setIndex("plistarr", "", 0);
    model.study("std2").feature("param").setIndex("punit", "", 0);
    model.study("std2").feature("param").setIndex("pname", "Np", 0);
    model.study("std2").feature("param").setIndex("plistarr", "", 0);
    model.study("std2").feature("param").setIndex("punit", "", 0);

//    In the table, enter the following settings:

    model.study("std2").feature("param").setIndex("pname", "w_rot", 0);
    model.study("std2").feature("param").setIndex("plistarr", "range(1200,3600,12000)", 0);
    model.study("std2").feature("param").setIndex("punit", "rpm", 0);

//    Click Add.

    model.study("std2").feature("param").setIndex("pname", "Np", 1);
    model.study("std2").feature("param").setIndex("plistarr", "", 1);
    model.study("std2").feature("param").setIndex("punit", "", 1);
    model.study("std2").feature("param").setIndex("pname", "Np", 1);
    model.study("std2").feature("param").setIndex("plistarr", "", 1);
    model.study("std2").feature("param").setIndex("punit", "", 1);

//    In the table, enter the following settings:

    model.study("std2").feature("param").setIndex("pname", "Ipk", 1);
    model.study("std2").feature("param").setIndex("plistarr", "range(3,6.75,30)", 1);

//    Locate the Advanced Settings section.
//    Select the Reuse solution from previous step checkbox.

    model.study("std2").feature("param").set("reusesol", true);

//    In the Study toolbar, click Show Default Solver.

    model.study("std2").showAutoSequences("all");

//    In the Model Builder window, expand the Solution 9 (sol9) node.
//    In the Model Builder window, expand the Study 2 - Efficiency Map > Solver Configurations > Solution 9 (sol9) > Stationary Solver 1 node.
//    Right-click Study 2 - Efficiency Map > Solver Configurations > Solution 9 (sol9) > Stationary Solver 1 and choose Segregated.

    model.sol("sol9").feature("s1").create("se1", "Segregated");

//    In the Model Builder window, expand the Study 2 - Efficiency Map > Solver Configurations > Solution 9 (sol9) > Stationary Solver 1 > Segregated 1 node, then click Segregated Step.
//    In the Settings window for Segregated Step, type Magnetic Field in the Label text field.

    model.sol("sol9").feature("s1").feature("se1").feature("ssDef").label("Magnetic Field");

//    Locate the General section.
//    In the Variables list, select External Temperature (comp1.ht.TextFace), Temperature (comp1.T).
//    Under Variables, click Delete.

    model.sol("sol9").feature("s1").feature("se1").feature("ssDef")
         .set("segvar", new String[]{"comp1_mmtp_AZ_tp0", "comp1_mmtp_drcon1_AZLM_tp0", "comp1_mmtp_mag1_V_d0_tp0"});

//    Locate the Method and Termination section.
//    From the Termination technique list, select Tolerance.

    model.sol("sol9").feature("s1").feature("se1").feature("ssDef").set("subtermconst", "tol");

//    In the Model Builder window, right-click Study 2 - Efficiency Map > Solver Configurations > Solution 9 (sol9) > Stationary Solver 1 > Segregated 1 and choose Segregated Step.

    model.sol("sol9").feature("s1").feature("se1").create("ss1", "SegregatedStep");

//    In the Settings window for Segregated Step, type Temperature Field in the Label text field.

    model.sol("sol9").feature("s1").feature("se1").feature("ss1").label("Temperature Field");

//    Locate the General section.
//    Under Variables, click Add.
//    In the Add dialog, select External Temperature (comp1.ht.TextFace), Temperature (comp1.T) in the Variables list.
//    Click OK.

    model.sol("sol9").feature("s1").feature("se1").feature("ss1")
         .set("segvar", new String[]{"comp1_ht_TextFace", "comp1_T"});

//    In the Model Builder window, collapse the Study 2 - Efficiency Map > Solver Configurations node.
//    In the Study toolbar, click Compute.

    model.study("std2").createAutoSequences("all");

    model.sol("sol9").runAll();

    model.result().create("pg4", "PlotGroup2D");
    model.result("pg4").label("Magnetic Flux Density Norm (mmtp) 1");
    model.result("pg4").set("data", "dset3");
    model.result("pg4").setIndex("looplevel", 5, 0);
    model.result("pg4").setIndex("looplevel", 4, 1);
    model.result("pg4").set("titletype", "label");
    model.result("pg4").set("edges", "off");
    model.result("pg4").set("showlegendsmaxmin", true);
    model.result("pg4").set("smooth", "internal");
    model.result("pg4").feature().create("surf1", "Surface");
    model.result("pg4").feature("surf1").set("solutionparams", "parent");
    model.result("pg4").feature("surf1").set("expr", "mmtp.normB(phase)");
    model.result("pg4").feature("surf1").set("colortable", "Prism");
    model.result("pg4").feature("surf1").set("colortabletrans", "nonlinear");
    model.result("pg4").feature("surf1").set("colorcalibration", -0.8);
    model.result("pg4").feature("surf1").set("data", "parent");
    model.result("pg4").feature("surf1").feature().create("def1", "Deform");
    model.result("pg4").feature("surf1").feature("def1")
         .set("expr", new String[]{"mmtp.displX(phase)", "mmtp.displY(phase)"});
    model.result("pg4").feature("surf1").feature("def1").set("scaleactive", true);
    model.result("pg4").feature().create("str1", "Streamline");
    model.result("pg4").feature("str1").set("expr", new String[]{"mmtp.BX(phase)", "mmtp.BY(phase)"});
    model.result("pg4").feature("str1").set("posmethod", "uniform");
    model.result("pg4").feature("str1").set("udensity", 6.7);
    model.result("pg4").feature("str1").set("smooth", "internal");
    model.result("pg4").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("maxlen", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("str1").set("data", "parent");
    model.result("pg4").feature("str1").selection().geom("geom1", 1);
    model.result("pg4").feature("str1").selection()
         .set(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 124, 126, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164);
    model.result("pg4").feature("str1").feature().create("col1", "Color");
    model.result("pg4").feature("str1").feature("col1").set("expr", "mmtp.normB(phase)");
    model.result("pg4").feature("str1").feature("col1").set("colortable", "PrismDark");
    model.result("pg4").feature("str1").feature("col1").set("colorlegend", false);
    model.result("pg4").feature("str1").feature("col1").set("colortabletrans", "nonlinear");
    model.result("pg4").feature("str1").feature("col1").set("colorcalibration", -0.8);
    model.result("pg4").feature("str1").feature().create("filt1", "Filter");
    model.result("pg4").feature("str1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result("pg4").feature("str1").feature().create("def1", "Deform");
    model.result("pg4").feature("str1").feature("def1")
         .set("expr", new String[]{"mmtp.displX(phase)", "mmtp.displY(phase)"});
    model.result("pg4").feature("str1").feature("def1").set("scaleactive", true);
    model.result("pg4").feature().create("con1", "Contour");
    model.result("pg4").feature("con1").set("solutionparams", "parent");
    model.result("pg4").feature("con1").set("expr", "mmtp.AZ(phase)");
    model.result("pg4").feature("con1").set("number", 10);
    model.result("pg4").feature("con1").set("levelrounding", false);
    model.result("pg4").feature("con1").set("coloring", "uniform");
    model.result("pg4").feature("con1").set("colorlegend", false);
    model.result("pg4").feature("con1").set("color", "custom");
    model.result("pg4").feature("con1")
         .set("customcolor", new double[]{0.4117647111415863, 0.4117647111415863, 0.4117647111415863});
    model.result("pg4").feature("con1").set("smooth", "internal");
    model.result("pg4").feature("con1").set("data", "parent");
    model.result("pg4").feature("con1").feature().create("filt1", "Filter");
    model.result("pg4").feature("con1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result("pg4").feature("con1").feature().create("def1", "Deform");
    model.result("pg4").feature("con1").feature("def1")
         .set("expr", new String[]{"mmtp.displX(phase)", "mmtp.displY(phase)"});
    model.result("pg4").feature("con1").feature("def1").set("scaleactive", true);
    model.result("pg4").feature().create("line1", "Line");
    model.result("pg4").feature("line1").set("expr", "1");
    model.result("pg4").feature("line1").set("coloring", "uniform");
    model.result("pg4").feature("line1").set("color", "fromtheme");
    model.result("pg4").feature("line1").set("smooth", "internal");
    model.result("pg4").feature("line1").set("data", "parent");
    model.result("pg4").feature("line1").feature().create("def1", "Deform");
    model.result("pg4").feature("line1").feature("def1")
         .set("expr", new String[]{"mmtp.displX(phase)", "mmtp.displY(phase)"});
    model.result("pg4").feature("line1").feature("def1").set("scaleactive", true);
    model.result().create("pg5", "PlotGroup2D");
    model.result("pg5").label("Temperature (ht) 1");
    model.result("pg5").set("data", "dset3");
    model.result("pg5").setIndex("looplevel", 5, 0);
    model.result("pg5").setIndex("looplevel", 4, 1);
    model.result("pg5").set("smooth", "internal");
    model.result("pg5").feature().create("surf1", "Surface");
    model.result("pg5").feature("surf1").set("solutionparams", "parent");
    model.result("pg5").feature("surf1").set("colortable", "HeatCameraLight");
    model.result("pg5").feature("surf1").set("data", "parent");
    model.result("pg4").run();

//    The following steps duplicate and modify the already existing evaluation group and use it to generate the efficiency map.
//    In the Model Builder window, right-click Results > Evaluation Group 1 and choose Duplicate.

    model.result().evaluationGroup().duplicate("eg2", "eg1");

//    In the Settings window for Evaluation Group, locate the Data section.
//    From the Dataset list, select Study 2 - Efficiency Map/Solution 9 (sol9).

    model.result().evaluationGroup("eg2").set("data", "dset3");

//    In the Model Builder window, expand the Evaluation Group 2 node.
//    Right-click Results > Evaluation Group 2 > Global Evaluation 1 and choose Duplicate.

    model.result().evaluationGroup("eg2").feature().duplicate("gev2", "gev1");

//    In the Settings window for Global Evaluation, locate the Expressions section.
//    In the table, enter the following settings:

    model.result().evaluationGroup("eg2").feature("gev2").setIndex("expr", "mmtp.drcon1.Tax_tpavg*w_rot*2*pi", 0);
    model.result().evaluationGroup("eg2").feature("gev2").setIndex("unit", "W", 0);
    model.result().evaluationGroup("eg2").feature("gev2").setIndex("descr", "Shaft power", 0);

//    In the Model Builder window, click Evaluation Group 2.
//    In the Settings window for Evaluation Group, locate the Transformation section.
//    From the Transformation type list, select General.

    model.result().evaluationGroup("eg2").set("type", "general");

//    Select the Keep child nodes checkbox.

    model.result().evaluationGroup("eg2").set("keepchildnodes", true);

//    In the Expression text field, type gev2/(gev2+int1+int2+int3+int4).

    model.result().evaluationGroup("eg2").set("generalexpr", "gev2/(gev2+int1+int2+int3+int4)");

//    In the Column header text field, type Efficiency.

    model.result().evaluationGroup("eg2").set("generalheader", "Efficiency");

//    In the Evaluation Group 2 toolbar, click Evaluate.

    model.result().evaluationGroup("eg2").run();

//    Click Table Contour in the window toolbar.

    model.result().create("pg6", "PlotGroup2D");
    model.result("pg6").set("data", "none");
    model.result("pg6").create("tblc1", "TableContour");
    model.result("pg6").feature("tblc1").set("source", "evaluationgroup");
    model.result("pg6").feature("tblc1").set("evaluationgroup", "eg2");
    model.result("pg6").run();

//    In the Settings window for Table Contour, locate the Data section.
//    From the y-axis column list, select Torque (N*m).

    model.result("pg6").feature("tblc1").set("coly", 4);

//    Right-click Results > 2D Plot Group 6 > Table Contour 1 and choose Duplicate.

    model.result("pg6").feature().duplicate("tblc2", "tblc1");
    model.result("pg6").run();

//    In the Settings window for Table Contour, locate the Coloring and Style section.
//    From the Contour type list, select Line.

    model.result("pg6").feature("tblc2").set("contourtype", "lines");

//    Select the Level labels checkbox.

    model.result("pg6").feature("tblc2").set("contourlabels", true);

//    In the Precision text field, type 2.

    model.result("pg6").feature("tblc2").set("labelprec", 2);

//    From the Label color list, select Black.

    model.result("pg6").feature("tblc2").set("labelcolor", "black");

//    From the Color table list, select RainbowDark.

    model.result("pg6").feature("tblc2").set("colortable", "RainbowDark");

//    Clear the Color legend checkbox.

    model.result("pg6").feature("tblc2").set("colorlegend", false);

//    Click to expand the Title section.
//    From the Title type list, select None.

    model.result("pg6").feature("tblc2").set("titletype", "none");
    model.result("pg6").run();

//    In the Model Builder window, under Results, click 2D Plot Group 6.
//    In the Settings window for 2D Plot Group, type Motor Efficiency Map in the Label text field.

    model.result("pg6").label("Motor Efficiency Map");

//    Locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg6").set("xlabelactive", true);

//    In the associated text field, type Speed (rpm).

    model.result("pg6").set("xlabel", "Speed (rpm)");

//    In the Motor Efficiency Map toolbar, click Plot.

    model.result("pg6").run();

//    In the Model Builder window, collapse the Results > Evaluation Group 2 node.
//    In the Model Builder window, collapse the Results > Motor Efficiency Map node.

    model.result("pg5").run();

//    In the Model Builder window, expand the Results > Temperature (ht) 1 node, then click Surface 1.
//    In the Settings window for Surface, locate the Data section.
//    From the Dataset list, select Study 2 - Efficiency Map/Solution 9 (sol9).

    model.result("pg5").feature("surf1").set("data", "dset3");

//    From the Solution parameters list, select Manual.

    model.result("pg5").feature("surf1").set("solutionparams", "manual");

//    From the Parameter value (w_rot (rpm)) list, select 1200.

    model.result("pg5").feature("surf1").setIndex("looplevel", 1, 1);

//    From the Parameter value (Ipk (A)) list, select 3.

    model.result("pg5").feature("surf1").setIndex("looplevel", 1, 0);

//    Locate the Expression section.
//    In the Unit field, type degC.

    model.result("pg5").feature("surf1").set("unit", "degC");

//    Click to expand the Title section.
//    From the Title type list, select None.

    model.result("pg5").feature("surf1").set("titletype", "none");
    model.result("pg5").run();

//    In the Model Builder window, right-click Temperature (ht) 1 and choose Annotation.

    model.result("pg5").create("ann1", "Annotation");

//    In the Settings window for Annotation, locate the Data section.
//    From the Dataset list, select Study 2 - Efficiency Map/Solution 9 (sol9).

    model.result("pg5").feature("ann1").set("data", "dset3");

//    From the Parameter value (w_rot (rpm)) list, select 1200.

    model.result("pg5").feature("ann1").setIndex("looplevel", 1, 1);

//    From the Parameter value (Ipk (A)) list, select 3.

    model.result("pg5").feature("ann1").setIndex("looplevel", 1, 0);

//    Locate the Annotation section.
//    In the Text text field, type speed = eval(w_rot,rpm,5) Ipk = eval(Ipk,A,3).

    model.result("pg5").feature("ann1").set("text", "speed = eval(w_rot,rpm,5)  Ipk = eval(Ipk,A,3)");

//    Locate the Position section.
//    In the X text field, type -16.

    model.result("pg5").feature("ann1").set("posxexpr", -16);

//    In the Y text field, type 6.

    model.result("pg5").feature("ann1").set("posyexpr", 6);

//    Locate the Coloring and Style section.
//    Clear the Show point checkbox.

    model.result("pg5").feature("ann1").set("showpoint", false);

//    From the Background color list, select From theme.

    model.result("pg5").feature("ann1").set("backgroundcolor", "fromtheme");

//    Select the Show frame checkbox.

    model.result("pg5").feature("ann1").set("showframe", true);
    model.result("pg5").run();

//    In the Model Builder window, under Results > Temperature (ht) 1, Ctrl-click to select Surface 1, Annotation 1.
//    Right-click and choose Duplicate.

    model.result("pg5").feature().duplicate("surf2", "surf1");
    model.result("pg5").feature().duplicate("ann2", "ann1");
    model.result("pg5").run();

//    In the Settings window for Surface, locate the Data section.
//    From the Parameter value (Ipk (A)) list, select 30.

    model.result("pg5").feature("surf2").setIndex("looplevel", 5, 0);

//    Click to expand the Inherit Style section.
//    From the Plot list, select Surface 1.

    model.result("pg5").feature("surf2").set("inheritplot", "surf1");

//    Right-click Surface 2 and choose Transformation.

    model.result("pg5").feature("surf2").create("trn1", "Transformation");
    model.result("pg5").run();

//    In the Settings window for Transformation, locate the Transformation section.
//    In the Y text field, type 30.

    model.result("pg5").feature("surf2").feature("trn1").set("move", new int[]{0, 30});
    model.result("pg5").run();

//    In the Model Builder window, right-click Annotation 2 and choose Transformation.

    model.result("pg5").feature("ann2").create("trn1", "Transformation");
    model.result("pg5").run();

//    In the Settings window for Transformation, locate the Transformation section.
//    In the Y text field, type 30.

    model.result("pg5").feature("ann2").feature("trn1").set("move", new int[]{0, 30});
    model.result("pg5").run();

//    In the Model Builder window, click Annotation 2.
//    In the Settings window for Annotation, locate the Data section.
//    From the Parameter value (Ipk (A)) list, select 30.

    model.result("pg5").feature("ann2").setIndex("looplevel", 5, 0);
    model.result("pg5").run();

//    In the Model Builder window, under Results > Temperature (ht) 1, Ctrl-click to select Surface 2, Annotation 2.
//    Right-click and choose Duplicate.

    model.result("pg5").feature().duplicate("surf3", "surf2");
    model.result("pg5").feature().duplicate("ann3", "ann2");
    model.result("pg5").run();

//    In the Settings window for Surface, locate the Data section.
//    From the Parameter value (w_rot (rpm)) list, select 12000.

    model.result("pg5").feature("surf3").setIndex("looplevel", 4, 1);
    model.result("pg5").run();

//    In the Model Builder window, expand the Surface 3 node, then click Transformation 1.
//    In the Settings window for Transformation, locate the Transformation section.
//    In the X text field, type 60.

    model.result("pg5").feature("surf3").feature("trn1").set("move", new int[]{60, 30});
    model.result("pg5").run();

//    In the Model Builder window, under Results > Temperature (ht) 1, click Annotation 3.
//    In the Settings window for Annotation, locate the Data section.
//    From the Parameter value (w_rot (rpm)) list, select 12000.

    model.result("pg5").feature("ann3").setIndex("looplevel", 4, 1);
    model.result("pg5").run();

    return model;
  }

  public static Model run4(Model model) {

//    In the Model Builder window, expand the Annotation 3 node, then click Transformation 1.
//    In the Settings window for Transformation, locate the Transformation section.
//    In the X text field, type 60.

    model.result("pg5").feature("ann3").feature("trn1").set("move", new int[]{60, 30});
    model.result("pg5").run();

//    In the Model Builder window, under Results > Temperature (ht) 1, Ctrl-click to select Surface 3, Annotation 3.
//    Right-click and choose Duplicate.

    model.result("pg5").feature().duplicate("surf4", "surf3");
    model.result("pg5").feature().duplicate("ann4", "ann3");
    model.result("pg5").run();

//    In the Settings window for Surface, locate the Data section.
//    From the Parameter value (Ipk (A)) list, select 3.

    model.result("pg5").feature("surf4").setIndex("looplevel", 1, 0);
    model.result("pg5").run();

//    In the Model Builder window, expand the Surface 4 node, then click Transformation 1.
//    In the Settings window for Transformation, locate the Transformation section.
//    In the Y text field, type 0.

    model.result("pg5").feature("surf4").feature("trn1").set("move", new int[]{60, 0});
    model.result("pg5").run();

//    In the Model Builder window, under Results > Temperature (ht) 1, click Annotation 4.
//    In the Settings window for Annotation, locate the Data section.
//    From the Parameter value (Ipk (A)) list, select 3.

    model.result("pg5").feature("ann4").setIndex("looplevel", 1, 0);
    model.result("pg5").run();

//    In the Model Builder window, expand the Annotation 4 node, then click Transformation 1.
//    In the Settings window for Transformation, locate the Transformation section.
//    In the Y text field, type 0.

    model.result("pg5").feature("ann4").feature("trn1").set("move", new int[]{60, 0});

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Model Builder window, collapse the Results > Temperature (ht) 1 node.

    model.result("pg5").run();

//    In the Model Builder window, click Temperature (ht) 1.
//    In the Settings window for 2D Plot Group, click to expand the Title section.
//    From the Title type list, select Manual.

    model.result("pg5").set("titletype", "manual");

//    In the Title text area, type Temperature fields of four operating points.

    model.result("pg5").set("title", "Temperature fields of four operating points");

//    Clear the Parameter indicator text field.

    model.result("pg5").set("paramindicator", "");

//    Locate the Color Legend section.
//    Select the Show units checkbox.

    model.result("pg5").set("showlegendsunit", true);

//    In the Temperature (ht) 1 toolbar, click Plot.

    model.result("pg5").run();

//    Right-click Temperature (ht) 1 and choose Duplicate.

    model.result().duplicate("pg7", "pg5");
    model.result("pg7").run();

//    In the Settings window for 2D Plot Group, type Electromagnetic Loss in the Label text field.

    model.result("pg7").label("Electromagnetic Loss");

//    Locate the Title section.
//    In the Title text area, type Electromagnetic loss distribution of four operating points.

    model.result("pg7").set("title", "Electromagnetic loss distribution of four operating points");
    model.result("pg7").run();

//    In the Model Builder window, expand the Electromagnetic Loss node, then click Surface 1.
//    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) > Magnetic Machinery, Rotating, Time Periodic > Heating and losses > mmtp.Qh - Volumetric loss density, electromagnetic - W/m³.

    model.result("pg7").feature("surf1").set("expr", "mmtp.Qh");
    model.result("pg7").feature("surf1").set("descr", "Volumetric loss density, electromagnetic");

//    Locate the Coloring and Style section.
//    From the Color table list, select Rainbow.

    model.result("pg7").feature("surf1").set("colortable", "Rainbow");
    model.result("pg7").run();

//    In the Model Builder window, click Surface 2.
//    In the Settings window for Surface, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose mmtp.Qh - Volumetric loss density, electromagnetic - W/m³.

    model.result("pg7").feature("surf2").set("expr", "mmtp.Qh");
    model.result("pg7").feature("surf2").set("descr", "Volumetric loss density, electromagnetic");
    model.result("pg7").run();

//    In the Model Builder window, click Surface 3.
//    In the Settings window for Surface, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose mmtp.Qh - Volumetric loss density, electromagnetic - W/m³.

    model.result("pg7").feature("surf3").set("expr", "mmtp.Qh");
    model.result("pg7").feature("surf3").set("descr", "Volumetric loss density, electromagnetic");
    model.result("pg7").run();

//    In the Model Builder window, click Surface 4.
//    In the Settings window for Surface, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose mmtp.Qh - Volumetric loss density, electromagnetic - W/m³.

    model.result("pg7").feature("surf4").set("expr", "mmtp.Qh");
    model.result("pg7").feature("surf4").set("descr", "Volumetric loss density, electromagnetic");

//    In the Model Builder window, collapse the Results > Electromagnetic Loss node.

    model.result("pg7").run();
    model.result("pg6").run();

    model.title("Permanent Magnet Motor with Efficiency Map");

    model
         .description("A model demonstrating how to couple Magnetic Machinery Time Periodic with Heat Transfer (two-way) and generating an efficiency map of a sweep over current amplitude and rotor speed.");

    return model;
  }

  public static void main(String[] args) {
    Model model = run();
    model = run2(model);
    model = run3(model);
    run4(model);
  }

}
