/*
 * microwave_oven.java
 */

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

/** Model exported on May 13 2026, 07:52 by COMSOL 6.4.0.419. */
public class microwave_oven {

  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 3D.
//    In the Select Physics tree, select Heat Transfer > Electromagnetic Heating > Microwave Heating.
//    Click Add.
//    In the Added physics interfaces tree, select Electromagnetic Waves, Frequency Domain (emw).
//    Click Study.
//    Add a <l>Frequency-Transient, One-Way Electromagnetic Heating</l> study sequence that add a <l>Frequency Domain</l> study type for the <l>Electromagnetic Waves, Frequency Domain</l> interface followed by a <l>Time Dependent</l> study type for the <l>Heat Transfer in Solids</l> interface.
//    In the Select Study tree, select Preset Studies for Selected Multiphysics > Frequency–Transient, One-Way Electromagnetic Heating.
//    Click Done.

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

    model.component("comp1").geom().create("geom1", 3);
    model.component("comp1").geom("geom1").geomRep("comsol");

    model.component("comp1").mesh().create("mesh1");
    model.component("comp1").mesh("mesh1").contribute("geom/detail", true);

    model.component("comp1").physics().create("emw", "ElectromagneticWaves", "geom1");
    model.component("comp1").physics().create("ht", "HeatTransfer", "geom1");

    model.component("comp1").multiphysics().create("emh1", "ElectromagneticHeating", 3);
    model.component("comp1").multiphysics("emh1").set("EMHeat_physics", "emw");
    model.component("comp1").multiphysics("emh1").set("Heat_physics", "ht");
    model.component("comp1").multiphysics("emh1").selection().all();

    model.study().create("std1");
    model.study("std1").create("freq", "Frequency");
    model.study("std1").feature("freq").set("punit", "Hz");
    model.study("std1").feature("freq").set("plist", "1[MHz]");
    model.study("std1").feature("freq").set("solnum", "auto");
    model.study("std1").feature("freq").set("notsolnum", "auto");
    model.study("std1").feature("freq").set("outputmap", new String[]{});
    model.study("std1").feature("freq").set("ngenAUX", "1");
    model.study("std1").feature("freq").set("goalngenAUX", "1");
    model.study("std1").feature("freq").set("ngenAUX", "1");
    model.study("std1").feature("freq").set("goalngenAUX", "1");
    model.study("std1").feature("freq").setSolveFor("/physics/ht", false);
    model.study("std1").feature("freq").setSolveFor("/multiphysics/emh1", false);
    model.study("std1").create("time", "Transient");
    model.study("std1").feature("time").set("initialtime", "0");
    model.study("std1").feature("time").set("solnum", "auto");
    model.study("std1").feature("time").set("notsolnum", "auto");
    model.study("std1").feature("time").set("outputmap", new String[]{});
    model.study("std1").feature("time").setSolveFor("/physics/emw", false);

//    Define the study frequency ahead of performing any frequency-dependent operation such as building mesh. The physics-controlled mesh uses the specified frequency value.
//    In the Model Builder window, under Study 1, click Step 1: Frequency Domain.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    In the Frequencies text field, type 2.45[GHz].

    model.study("std1").feature("freq").set("plist", "2.45[GHz]");

//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, locate the Study Settings section.
//    Select the Store solution for all intermediate study steps checkbox.

    model.study("std1").setStoreSolution(true);

//    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 microwave_oven_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("wo", "267[mm]", "Oven width");
    model.param().set("do", "270[mm]", "Oven depth");
    model.param().set("ho", "188[mm]", "Oven height");
    model.param().set("wg", "50[mm]", "Waveguide width");
    model.param().set("dg", "78[mm]", "Waveguide depth");
    model.param().set("hg", "18[mm]", "Waveguide height");
    model.param().set("rp", "113.5[mm]", "Glass plate radius");
    model.param().set("hp", "6[mm]", "Glass plate height");
    model.param().set("bp", "15[mm]", "Glass plate base");
    model.param().set("rpot", "31.5[mm]", "Potato radius");
    model.param().set("T0", "8[degC]", "Initial potato temperature");
    model.param().set("full_geometry", "1", "Symmetry flag");

//    In the Geometry toolbar, click Block.

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

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

    model.component("comp1").geom("geom1").feature("blk1").set("size", new String[]{"wo", "1", "1"});

//    In the Depth text field, type do.

    model.component("comp1").geom("geom1").feature("blk1").set("size", new String[]{"wo", "do", "1"});

//    In the Height text field, type ho.

    model.component("comp1").geom("geom1").feature("blk1").set("size", new String[]{"wo", "do", "ho"});

//    Locate the Position section.
//    In the y text field, type -do/2.

    model.component("comp1").geom("geom1").feature("blk1").set("pos", new String[]{"0", "-do/2", "0"});

//    In the Geometry toolbar, click Block.

    model.component("comp1").geom("geom1").run("blk1");
    model.component("comp1").geom("geom1").create("blk2", "Block");

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

    model.component("comp1").geom("geom1").feature("blk2").set("size", new String[]{"wg", "1", "1"});

//    In the Depth text field, type dg.

    model.component("comp1").geom("geom1").feature("blk2").set("size", new String[]{"wg", "dg", "1"});

//    In the Height text field, type hg.

    model.component("comp1").geom("geom1").feature("blk2").set("size", new String[]{"wg", "dg", "hg"});

//    Locate the Position section.
//    In the x text field, type -wg.

    model.component("comp1").geom("geom1").feature("blk2").set("pos", new String[]{"-wg", "0", "0"});

//    In the y text field, type -dg/2.

    model.component("comp1").geom("geom1").feature("blk2").set("pos", new String[]{"-wg", "-dg/2", "0"});

//    In the z text field, type ho-hg.

    model.component("comp1").geom("geom1").feature("blk2").set("pos", new String[]{"-wg", "-dg/2", "ho-hg"});

//    In the Geometry toolbar, click Cylinder.

    model.component("comp1").geom("geom1").run("blk2");
    model.component("comp1").geom("geom1").create("cyl1", "Cylinder");

//    In the Settings window for Cylinder, locate the Size and Shape section.
//    In the Radius text field, type rp.

    model.component("comp1").geom("geom1").feature("cyl1").set("r", "rp");

//    In the Height text field, type hp.

    model.component("comp1").geom("geom1").feature("cyl1").set("h", "hp");

//    Locate the Position section.
//    In the x text field, type wo/2.

    model.component("comp1").geom("geom1").feature("cyl1").set("pos", new String[]{"wo/2", "0", "0"});

//    In the z text field, type bp.

    model.component("comp1").geom("geom1").feature("cyl1").set("pos", new String[]{"wo/2", "0", "bp"});

//    In the Geometry toolbar, click Sphere.

    model.component("comp1").geom("geom1").run("cyl1");
    model.component("comp1").geom("geom1").create("sph1", "Sphere");

//    In the Settings window for Sphere, locate the Size section.
//    In the Radius text field, type rpot.

    model.component("comp1").geom("geom1").feature("sph1").set("r", "rpot");

//    Locate the Position section.
//    In the x text field, type wo/2.

    model.component("comp1").geom("geom1").feature("sph1").set("pos", new String[]{"wo/2", "0", "0"});

//    In the z text field, type rpot+bp+hp.

    model.component("comp1").geom("geom1").feature("sph1").set("pos", new String[]{"wo/2", "0", "rpot+bp+hp"});

//    Click Build All Objects.

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

//    Now, it is possible exploit the mirror symmetry of the model by chopping the geometry and only simulating one half of the model. For this purpose, form a union of all geometric and build an intersection with a block that includes only half of the model.
//    In the Geometry toolbar, click Booleans and Partitions and choose Union.

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

//    Click the Select All button in the Graphics toolbar.

    model.component("comp1").geom("geom1").feature("uni1").selection("input").set("blk1", "blk2", "cyl1", "sph1");

//    In the Geometry toolbar, click Block.

    model.component("comp1").geom("geom1").run("uni1");
    model.component("comp1").geom("geom1").create("blk3", "Block");

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

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

//    In the Depth text field, type 0.4.

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

//    In the Height text field, type 0.4.

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

//    Locate the Position section.
//    In the x text field, type -0.1.

    model.component("comp1").geom("geom1").feature("blk3").set("pos", new double[]{-0.1, 0, 0});

//    Click Build Selected.

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

//    In the Geometry toolbar, click Booleans and Partitions and choose Intersection.

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

//    Click the Select All button in the Graphics toolbar.

    model.component("comp1").geom("geom1").feature("int1").selection("input").set("blk3", "uni1");

//    In the Settings window for Intersection, click Build All Objects.

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

//    In the Geometry toolbar, click Programming and choose If + End If.

    model.component("comp1").geom("geom1").create("if1", "If");
    model.component("comp1").geom("geom1").feature().createAfter("endif1", "EndIf", "if1");

//    In the Settings window for If, type If Full Geometry in the Label text field.

    model.component("comp1").geom("geom1").feature("if1").label("If Full Geometry");

//    Locate the If section.
//    In the Condition text field, type full_geometry.

    model.component("comp1").geom("geom1").feature("if1").set("condition", "full_geometry");

//    In the Geometry toolbar, click Transforms and choose Mirror.

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

//    Select the object int1.

    model.component("comp1").geom("geom1").feature("mir1").selection("input").set("int1");

//    In the Settings window for Mirror, locate the Input section.
//    Select the Keep input objects checkbox.

    model.component("comp1").geom("geom1").feature("mir1").set("keep", true);

//    Locate the Normal Vector to Plane of Reflection section.
//    In the y text field, type 1.

    model.component("comp1").geom("geom1").feature("mir1").set("axis", new double[]{0, 1, 1});

//    In the z text field, type 0.

    model.component("comp1").geom("geom1").feature("mir1").set("axis", new double[]{0, 1, 0});

//    Click Build All Objects.

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

//    Click the Wireframe Rendering button in the Graphics toolbar.

    model.component("comp1").view("view1").set("renderwireframe", true);

//    Disable the analysis of the geometry as the remaining small geometric details can be kept.
//    In the Model Builder window, click Geometry 1.
//    In the Settings window for Geometry, locate the Cleanup section.
//    Clear the Automatic detection of small details checkbox.
//    Create the following selections definitions in order to make Domain and Boundary selections easier as you walk through these model instructions. Note that if you have problems finding certain numbers, you can always choose View &gt; Selection List.
//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel1", "Explicit");

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

//    In the Settings window for Explicit, type Potato in the Label text field.

    model.component("comp1").selection("sel1").label("Potato");

//    Select Domains 7, 8.

    model.component("comp1").selection("sel1").set(7, 8);

//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel2", "Explicit");

//    In the Settings window for Explicit, type Plate in the Label text field.

    model.component("comp1").selection("sel2").label("Plate");

//    Select Domains 5, 6.

    model.component("comp1").selection("sel2").set(5, 6);

//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel3", "Explicit");

//    In the Settings window for Explicit, type Air in the Label text field.

    model.component("comp1").selection("sel3").label("Air");

//    Select Domains 1, 2, 3, 4.

    model.component("comp1").selection("sel3").set(1, 2, 3, 4);

//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel4", "Explicit");

//    In the Settings window for Explicit, type Port Boundary in the Label text field.

    model.component("comp1").selection("sel4").label("Port Boundary");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").selection("sel4").geom(2);

//    Select Boundaries 1, 5.

    model.component("comp1").selection("sel4").set(1, 5);

//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel5", "Explicit");

//    In the Settings window for Explicit, type Metal Boundaries in the Label text field.

    model.component("comp1").selection("sel5").label("Metal Boundaries");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").selection("sel5").geom(2);

//    Select Boundaries 2, 3, 4, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 20, 39, 40.

    model.component("comp1").selection("sel5").set(2, 3, 4, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 20, 39, 40);

//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel6", "Explicit");

//    In the Settings window for Explicit, type Symmetry in the Label text field.

    model.component("comp1").selection("sel6").label("Symmetry");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").selection("sel6").geom(2);

//    Select Boundaries 6, 16, 23, 30.

    model.component("comp1").selection("sel6").set(6, 16, 23, 30);

//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel7", "Explicit");

//    In the Settings window for Explicit, type Half Model in the Label text field.

    model.component("comp1").selection("sel7").label("Half Model");

//    Select Domains 2, 4, 6, 8.

    model.component("comp1").selection("sel7").set(2, 4, 6, 8);

//    Next, define the materials. Air and Copper are already in the Material Library.
//    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 Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Air.

    model.component("comp1").material("mat1").selection().named("sel3");

//    In the Model Builder window, right-click Materials and choose Blank Material.

    model.component("comp1").material().create("mat2", "Common");

//    In the Settings window for Material, type Potato in the Label text field.

    model.component("comp1").material("mat2").label("Potato");

//    Locate the Geometric Entity Selection section.
//    From the Selection list, select Potato.

    model.component("comp1").material("mat2").selection().named("sel1");

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

    model.component("comp1").material("mat2").propertyGroup("def").set("relpermittivity", new String[]{"65-20*j"});
    model.component("comp1").material("mat2").propertyGroup("def").set("relpermeability", new String[]{"1"});
    model.component("comp1").material("mat2").propertyGroup("def").set("electricconductivity", new String[]{"0"});
    model.component("comp1").material("mat2").propertyGroup("def").set("thermalconductivity", new String[]{"0.55"});
    model.component("comp1").material("mat2").propertyGroup("def").set("density", new String[]{"1050"});
    model.component("comp1").material("mat2").propertyGroup("def").set("heatcapacity", new String[]{"3.64e3"});

//    Right-click Materials and choose Blank Material.

    model.component("comp1").material().create("mat3", "Common");

//    In the Settings window for Material, type Glass in the Label text field.

    model.component("comp1").material("mat3").label("Glass");

//    Locate the Geometric Entity Selection section.
//    From the Selection list, select Plate.

    model.component("comp1").material("mat3").selection().named("sel2");

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

    model.component("comp1").material("mat3").propertyGroup("def").set("relpermittivity", new String[]{"2.55"});
    model.component("comp1").material("mat3").propertyGroup("def").set("relpermeability", new String[]{"1"});
    model.component("comp1").material("mat3").propertyGroup("def").set("electricconductivity", new String[]{"0"});
    model.component("comp1").material("mat3").propertyGroup("def").set("thermalconductivity", new String[]{});
    model.component("comp1").material("mat3").propertyGroup("def").set("density", new String[]{});
    model.component("comp1").material("mat3").propertyGroup("def").set("heatcapacity", new String[]{});

//    You do not need to define the listed thermal properties, as the glass plate will not be in the thermal part of the model.
//    In the tree, select Built-in > Copper.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat4", "Common");
    model.component("comp1").material("mat4").propertyGroup()
         .create("Enu", "Enu", "Young's modulus and Poisson's ratio");
    model.component("comp1").material("mat4").propertyGroup().create("linzRes", "linzRes", "Linearized resistivity");
    model.component("comp1").material("mat4").label("Copper");
    model.component("comp1").material("mat4").set("family", "copper");
    model.component("comp1").material("mat4").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat4").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("mat4").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"17e-6[1/K]", "0", "0", "0", "17e-6[1/K]", "0", "0", "0", "17e-6[1/K]"});
    model.component("comp1").material("mat4").propertyGroup("def").set("heatcapacity", "385[J/(kg*K)]");
    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("def").set("density", "8960[kg/m^3]");
    model.component("comp1").material("mat4").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("mat4").propertyGroup("Enu").set("E", "110[GPa]");
    model.component("comp1").material("mat4").propertyGroup("Enu").set("nu", "0.35");
    model.component("comp1").material("mat4").propertyGroup("linzRes").set("rho0", "1.72e-8[ohm*m]");
    model.component("comp1").material("mat4").propertyGroup("linzRes").set("alpha", "0.0039[1/K]");
    model.component("comp1").material("mat4").propertyGroup("linzRes").set("Tref", "298[K]");
    model.component("comp1").material("mat4").propertyGroup("linzRes").addInput("temperature");

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").material("mat4").selection().geom("geom1", 2);

//    From the Selection list, select Metal Boundaries.

    model.component("comp1").material("mat4").selection().named("sel5");

//    For the electromagnetic part of the problem, begin by defining the input port. In the full model, you can exploit the predefined settings of the rectangular port.
//    In the Physics toolbar, click Boundaries and choose Port.

    model.component("comp1").physics("emw").create("port1", "Port", 2);

//    In the Settings window for Port, type Port 1, Full Model in the Label text field.

    model.component("comp1").physics("emw").feature("port1").label("Port 1, Full Model");

//    Locate the Boundary Selection section.
//    From the Selection list, select Port Boundary.

    model.component("comp1").physics("emw").feature("port1").selection().named("sel4");

//    Locate the Port Properties section.
//    From the Type of port list, select Rectangular.

    model.component("comp1").physics("emw").feature("port1").set("PortType", "Rectangular");

//    For the first port, wave excitation is <l>on</l> by default.
//    In the \[P_\textrm{in}\] text field, type 1[kW].

    model.component("comp1").physics("emw").feature("port1").set("Pin", "1[kW]");

//    Next, set up the remaining boundary conditions.

    return model;
  }

  public static Model run2(Model model) {
//    In the Physics toolbar, click Boundaries and choose Impedance Boundary Condition.

    model.component("comp1").physics("emw").create("imp1", "Impedance", 2);

//    In the Settings window for Impedance Boundary Condition, locate the Boundary Selection section.
//    From the Selection list, select Metal Boundaries.

    model.component("comp1").physics("emw").feature("imp1").selection().named("sel5");

//    In the Physics toolbar, click Select Physics Interface and choose Heat Transfer in Solids.
//    In the Model Builder window, under Component 1 (comp1), click Electromagnetic Waves, Frequency Domain (emw).
//    In the Settings window for Electromagnetic Waves, Frequency Domain, locate the Domain Selection section.
//    From the Selection list, select Half Model.

    model.component("comp1").physics("emw").selection().named("sel7");

//    In the Physics toolbar, click Boundaries and choose Port.

    model.component("comp1").physics("emw").create("port2", "Port", 2);

//    Keep in mind that the excited power is only half of Port 1.
//    In the Settings window for Port, type Port 2, Half Model in the Label text field.

    model.component("comp1").physics("emw").feature("port2").label("Port 2, Half Model");

//    Locate the Boundary Selection section.
//    From the Selection list, select Port Boundary.

    model.component("comp1").physics("emw").feature("port2").selection().named("sel4");

//    Locate the Port Properties section.
//    From the Type of port list, select Rectangular.

    model.component("comp1").physics("emw").feature("port2").set("PortType", "Rectangular");

//    From the Wave excitation at this port list, select On.

    model.component("comp1").physics("emw").feature("port2").set("PortExcitation", "on");

//    In the \[P_\textrm{in}\] text field, type 1[kW]/2.

    model.component("comp1").physics("emw").feature("port2").set("Pin", "1[kW]/2");

//    If you want to configure the port manually, the <l>Rectangular</l> type port can be replaced with <l>User defined</l> where the z-component of electric field is <c>cos(pi*y/dg)[V/m]</c> and the propagation constant is <c>2*pi/c_const*sqrt(freq^2-c_const^2/(4*dg^2))</c>.
//    Exploit the mirror symmetry of the model by adding a PMC type symmetry plane.
//    In the Physics toolbar, click Boundaries and choose Symmetry Plane.

    model.component("comp1").physics("emw").create("symp1", "SymmetryPlane", 2);

//    In the Settings window for Symmetry Plane, locate the Boundary Selection section.
//    From the Selection list, select Symmetry.

    model.component("comp1").physics("emw").feature("symp1").selection().named("sel6");

//    In the Model Builder window, click Electromagnetic Waves, Frequency Domain (emw).
//    In the Settings window for Electromagnetic Waves, Frequency Domain, locate the Domain Selection section.
//    From the Selection list, select All domains.

    model.component("comp1").physics("emw").selection().all();

//    This concludes the electromagnetic part of the physics.
//    The Heat Transfer physics will automatically use the electromagnetic heat source from the Electromagnetic Waves physics thanks to the Electromagnetic Heating coupling feature.
//    In order to solve for the temperature in the potato only, use the predefined potato selection.
//    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 Potato.

    model.component("comp1").physics("ht").selection().named("sel1");

//    Set the initial value for the temperature.
//    In the Model Builder window, under Component 1 (comp1) > Heat Transfer in Solids (ht), click Initial Values 1.
//    In the Settings window for Initial Values, locate the Initial Values section.
//    In the \[T\] text field, type T0.

    model.component("comp1").physics("ht").feature("init1").set("Tinit", "T0");

//    In the Home toolbar, click Build Mesh.

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

//    In the Model Builder window, under Study 1, click Step 1: Frequency Domain.
//    In the Settings window for Frequency Domain, locate the Physics and Variables Selection section.
//    Select the Modify model configuration for study step checkbox.

    model.study("std1").feature("freq").set("useadvanceddisable", true);

//    In the tree, select Component 1 (comp1) > Electromagnetic Waves, Frequency Domain (emw) > Port 2, Half Model.
//    Click Disable.

    model.study("std1").feature("freq").set("disabledphysics", new String[]{"emw/port2"});

//    In the tree, select Component 1 (comp1) > Electromagnetic Waves, Frequency Domain (emw) > Symmetry Plane 1.
//    Click Disable.

    model.study("std1").feature("freq").set("disabledphysics", new String[]{"emw/port2", "emw/symp1"});

//    In the Model Builder window, click Step 2: Time Dependent.
//    In the Settings window for Time Dependent, locate the Study Settings section.
//    In the Output times text field, type range(0,1,5).

    model.study("std1").feature("time").set("tlist", "range(0,1,5)");

//    This will give you output at every second from t = 0 s to t = 5 s.
//    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", "wo", 0);
    model.study("std1").feature("param").setIndex("plistarr", "", 0);
    model.study("std1").feature("param").setIndex("punit", "m", 0);
    model.study("std1").feature("param").setIndex("pname", "wo", 0);
    model.study("std1").feature("param").setIndex("plistarr", "", 0);
    model.study("std1").feature("param").setIndex("punit", "m", 0);

//    In the table, enter the following settings:

    model.study("std1").feature("param").setIndex("pname", "full_geometry", 0);
    model.study("std1").feature("param").setIndex("plistarr", 1, 0);

//    In the Study toolbar, click Compute.

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

    model.sol().create("sol3");
    model.sol("sol3").study("std1");
    model.sol("sol3").label("Parametric Solutions 1");

    model.batch("p1").feature("so1").set("psol", "sol3");

    model.sol().create("sol4");
    model.sol("sol4").study("std1");
    model.sol("sol4").label("Parametric Solutions 2");

    model.batch("p1").feature("so2").set("psol", "sol4");
    model.batch("p1").run("compute");

    model.result().create("pg1", "PlotGroup3D");
    model.result("pg1").set("data", "dset4");
    model.result("pg1").create("mslc1", "Multislice");
    model.result("pg1").feature("mslc1").set("expr", new String[]{"emw.normE"});
    model.result("pg1").set("showlegendsmaxmin", true);
    model.result("pg1").feature("mslc1").set("colortable", "RainbowLight");
    model.result("pg1").label("Electric Field (emw)");
    model.result().evaluationGroup().create("eg1", "EvaluationGroup");
    model.result().evaluationGroup("eg1").set("data", "dset4");
    model.result().evaluationGroup("eg1").label("S-Parameter (emw)");
    model.result().evaluationGroup("eg1").set("data", "dset2");
    model.result().evaluationGroup("eg1").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("eg1").feature("gev1").label("S-Parameter (emw)");
    model.result().evaluationGroup("eg1").feature("gev1").set("expr", new String[]{"emw.S11dB"});
    model.result().table().create("tbl1", "Table");
    model.result().evaluationGroup("eg1").feature("gev1").set("table", "tbl1");
    model.result().evaluationGroup("eg1").run();
    model.result().create("pg2", "PlotGroup3D");
    model.result("pg2").set("data", "dset4");
    model.result("pg2").label("Electric Field, Logarithmic (emw)");
    model.result("pg2").selection().geom("geom1", 3);
    model.result("pg2").selection().set(1, 2, 3, 4, 5, 6, 7, 8);
    model.result("pg2").set("applyselectiontodatasetedges", true);

    model.component("comp1").measure().selection().geom(2);
    model.component("comp1").measure().selection().set(2, 3, 4, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 20, 39, 40);
    model.component("comp1").measure().selection().geom(2);
    model.component("comp1").measure().selection()
         .set(1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 20, 39, 40);

    model.result("pg2").create("surf1", "Surface");
    model.result("pg2").feature("surf1").set("expr", "emw.normE");
    model.result("pg2").feature("surf1").create("sel1", "Selection");
    model.result("pg2").feature("surf1").feature("sel1").selection()
         .set(2, 3, 4, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 20, 39, 40);
    model.result("pg2").feature("surf1").set("colortable", "Dipole");
    model.result("pg2").feature("surf1").set("colorscalemode", "logarithmic");
    model.result("pg2").feature("surf1").create("tran1", "Transparency");
    model.result("pg2").feature("surf1").feature("tran1").set("transparency", 0.85);
    model.result("pg2").feature("surf1").create("mtrl1", "MaterialAppearance");
    model.result("pg2").feature("surf1").feature("mtrl1").set("appearance", "custom");
    model.result("pg2").feature("surf1").feature("mtrl1").set("family", "rosegold");
    model.result("pg2").feature("surf1").set("expr", "1");
    model.result("pg2").create("surf2", "Surface");
    model.result("pg2").feature("surf2").set("expr", "emw.normE");
    model.result("pg2").feature("surf2").create("sel1", "Selection");
    model.result("pg2").feature("surf2").feature("sel1").selection()
         .set(6, 14, 16, 18, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38);
    model.result("pg2").feature("surf2").set("colortable", "Dipole");
    model.result("pg2").feature("surf2").set("colorscalemode", "logarithmic");
    model.result("pg2").feature("surf2").create("tran1", "Transparency");
    model.result("pg2").feature("surf2").feature("tran1").set("transparency", 0.3);
    model.result("pg2").create("surf3", "Surface");
    model.result("pg2").feature("surf3").set("expr", "emw.normE");
    model.result("pg2").feature("surf3").create("sel1", "Selection");
    model.result("pg2").feature("surf3").feature("sel1").selection().set(1, 5);
    model.result("pg2").feature("surf3").set("colortable", "Dipole");
    model.result("pg2").feature("surf3").set("colorscalemode", "logarithmic");
    model.result("pg2").feature("surf3").create("tran1", "Transparency");
    model.result("pg2").feature("surf3").feature("tran1").set("transparency", 0.7);

    model.component("comp1").view().create("view2", "geom1");
    model.component("comp1").view("view2").camera().set("position", new double[]{-0.44, -0.66, 0.54});
    model.component("comp1").view("view2").set("environmentmap", "Indoor");
    model.component("comp1").view("view2").camera().set("zoomanglefull", 41.95);

    model.result("pg2").set("view", "view2");
    model.result().create("pg3", "PlotGroup3D");
    model.result("pg3").label("Temperature (ht)");
    model.result("pg3").set("data", "dset4");
    model.result("pg3").set("smooth", "internal");
    model.result("pg3").feature().create("vol1", "Volume");
    model.result("pg3").feature("vol1").set("solutionparams", "parent");
    model.result("pg3").feature("vol1").set("expr", "T");
    model.result("pg3").feature("vol1").set("colortable", "HeatCameraLight");
    model.result("pg3").feature("vol1").set("smooth", "internal");
    model.result("pg3").feature("vol1").set("data", "parent");
    model.result("pg1").run();
    model.result("pg1").run();

//    In the Model Builder window, expand the Electric Field (emw) node, then click Multislice 1.
//    In the Settings window for Multislice, locate the Multiplane Data section.
//    Find the X-planes subsection.
//    In the Planes text field, type 0.

    model.result("pg1").feature("mslc1").set("xnumber", "0");

//    Find the Z-planes subsection.
//    In the Planes text field, type 0.

    model.result("pg1").feature("mslc1").set("znumber", "0");

//    In the Electric Field (emw) toolbar, click Plot.

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

//    The results show the E-field norm distribution inside the microwave oven.

    model.result("pg2").set("applyselectiontodatasetedges", true);
    model.result("pg2").run();

//    In the Model Builder window, under Results, click Electric Field, Logarithmic (emw).

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

//    In the Model Builder window, expand the Results > Temperature (ht) node, then click Volume 1.
//    In the Settings window for Volume, locate the Expression section.
//    In the Unit field, type degC.

    model.result("pg3").feature("vol1").set("unit", "degC");

//    Right-click Volume 1 and choose Delete.

    model.result("pg3").feature().remove("vol1");
    model.result("pg3").set("applyselectiontodatasetedges", false);
    model.result("pg3").run();

//    In the Settings window for 3D Plot Group, locate the Data section.
//    From the Dataset list, select Study 1/Parametric Solutions 1 (sol3).

    model.result("pg3").set("data", "dset3");

//    In the Temperature (ht) toolbar, click Slice.

    model.result("pg3").create("slc1", "Slice");
    model.result("pg3").feature("slc1").set("evaluationsettings", "parent");

//    In the Settings window for Slice, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Heat Transfer in Solids > Temperature > T - Temperature - K.

    model.result("pg3").feature("slc1").set("expr", "T");
    model.result("pg3").feature("slc1").set("descr", "Temperature");

//    Locate the Expression section.
//    In the Unit field, type degC.

    model.result("pg3").feature("slc1").set("unit", "degC");

//    Locate the Plane Data section.
//    From the Plane list, select ZX-planes.

    model.result("pg3").feature("slc1").set("quickplane", "zx");

//    In the Planes text field, type 1.

    model.result("pg3").feature("slc1").set("quickynumber", 1);

//    Locate the Coloring and Style section.
//    From the Color table list, select HeatCameraLight.

    model.result("pg3").feature("slc1").set("colortable", "HeatCameraLight");

//    Next, add a nice visualization of the electromagnetic fields to the temperature plot.

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

//    In the Model Builder window, click Temperature (ht).
//    In the Temperature (ht) toolbar, click Slice.

    model.result("pg3").create("slc2", "Slice");
    model.result("pg3").feature("slc2").set("evaluationsettings", "parent");

//    In the Settings window for Slice, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Electromagnetic Waves, Frequency Domain > Electric > Electric field - V/m > emw.Ez - Electric field, z-component.

    model.result("pg3").feature("slc2").set("expr", "emw.Ez");
    model.result("pg3").feature("slc2").set("descr", "Electric field, z-component");

//    Locate the Plane Data section.
//    From the Plane list, select XY-planes.

    model.result("pg3").feature("slc2").set("quickplane", "xy");

//    From the Entry method list, select Coordinates.

    model.result("pg3").feature("slc2").set("quickzmethod", "coord");

//    In the Z-coordinates text field, type 0.1.

    model.result("pg3").feature("slc2").set("quickz", 0.1);

//    Right-click Slice 2 and choose Deformation.

    model.result("pg3").feature("slc2").create("def1", "Deform");
    model.result("pg3").run();

//    In the Settings window for Deformation, locate the Expression section.
//    In the X-component text field, type 0.

    model.result("pg3").feature("slc2").feature("def1").set("expr", new String[]{"0", "", ""});

//    In the Y-component text field, type 0.

    model.result("pg3").feature("slc2").feature("def1").set("expr", new String[]{"0", "0", ""});

//    In the Z-component text field, type patcheval(emw.Ez,2).

    model.result("pg3").feature("slc2").feature("def1").set("expr", new String[]{"0", "0", "patcheval(emw.Ez,2)"});

//    . The <c>patcheval</c> operator ensures a smoother color distribution on the deformed plotting plane.
//    In the Temperature (ht) toolbar, click Plot.

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

//    Add a filter to your plot to prevent the electric field plot from covering the potato.

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

//    In the Model Builder window, right-click Slice 2 and choose Filter.

    model.result("pg3").feature("slc2").create("filt1", "Filter");
    model.result("pg3").run();

//    In the Settings window for Filter, locate the Element Selection section.
//    In the Logical expression for inclusion text field, type y>0.

    model.result("pg3").feature("slc2").feature("filt1").set("expr", "y>0");

//    In the Temperature (ht) toolbar, click Plot.

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

//    In the Model Builder window, under Results, click Temperature (ht).
//    In the Settings window for 3D Plot Group, type Temperature (ht) and Ez in the Label text field.

    model.result("pg3").label("Temperature (ht) and Ez");

//    Create a plot showing the resistive heating on the symmetry plane.
//    In the Results toolbar, click 3D Plot Group.

    model.result().create("pg4", "PlotGroup3D");
    model.result("pg4").run();

//    In the Settings window for 3D Plot Group, type Resistive Heating in the Label text field.

    model.result("pg4").label("Resistive Heating");

//    Locate the Data section.
//    From the Dataset list, select Study 1/Solution Store 1 (sol2).

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

//    Right-click Resistive Heating and choose Slice.

    model.result("pg4").create("slc1", "Slice");
    model.result("pg4").feature("slc1").set("evaluationsettings", "parent");

//    In the Settings window for Slice, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Electromagnetic Waves, Frequency Domain > Heating and losses > emw.Qrh - Resistive losses - W/m³.

    model.result("pg4").feature("slc1").set("expr", "emw.Qrh");
    model.result("pg4").feature("slc1").set("descr", "Resistive losses");

//    Locate the Plane Data section.
//    From the Plane list, select ZX-planes.

    model.result("pg4").feature("slc1").set("quickplane", "zx");

//    From the Entry method list, select Coordinates.

    model.result("pg4").feature("slc1").set("quickymethod", "coord");

//    In the Resistive Heating toolbar, click Plot.

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

//    In the Results toolbar, click More Derived Values and choose Integration > Volume Integration.

    model.result().numerical().create("int1", "IntVolume");

//    Make a volume integral of the microwave heating to find out how much of the energy is absorbed in the potato.
//    In the Settings window for Volume Integration, locate the Data section.
//    From the Dataset list, select Study 1/Parametric Solutions 1 (sol3).

    model.result().numerical("int1").set("data", "dset3");

//    Click Replace Expression in the upper-right corner of the Expressions section.
//    From the menu, choose Component 1 (comp1) > Heat Transfer in Solids > Heat sources > ht.Qtot - Total heat source - W/m³.

    model.result().numerical("int1").set("expr", new String[]{"ht.Qtot"});
    model.result().numerical("int1").set("descr", new String[]{"Total heat source"});
    model.result().numerical("int1").set("unit", new String[]{"W"});

//    Select one point in time for the output. Since the material parameters of the potato are independent of the temperature, it does not matter which time you choose.
//    Locate the Data section.
//    From the Time selection list, select First.

    model.result().numerical("int1").setIndex("looplevelinput", "first", 0);

//    Locate the Selection section.
//    From the Selection list, select Potato.

    model.result().numerical("int1").selection().named("sel1");

//    Click Evaluate.

    model.result().table().create("tbl2", "Table");
    model.result().table("tbl2").comments("Volume Integration 1");
    model.result().numerical("int1").set("table", "tbl2");
    model.result().numerical("int1").setResult();

//    In the Results toolbar, click Cut Point 3D.

    model.result().dataset().create("cpt1", "CutPoint3D");

//    In the Settings window for Cut Point 3D, locate the Point Data section.
//    In the X text field, type wo/2.

    model.result().dataset("cpt1").set("pointx", "wo/2");

//    In the Y text field, type 0.

    model.result().dataset("cpt1").set("pointy", 0);

//    In the Z text field, type rpot+bp+hp.

    model.result().dataset("cpt1").set("pointz", "rpot+bp+hp");

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

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

//    In the Settings window for 1D Plot Group, locate the Data section.
//    From the Dataset list, select Cut Point 3D 1.

    model.result("pg5").set("data", "cpt1");

//    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 in potato.

    model.result("pg5").set("title", "Temperature in potato");

//    Locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg5").set("xlabelactive", true);

//    In the associated text field, type Time (s).

    model.result("pg5").set("xlabel", "Time (s)");

//    Right-click 1D Plot Group 5 and choose Point Graph.

    model.result("pg5").create("ptgr1", "PointGraph");
    model.result("pg5").feature("ptgr1").set("markerpos", "datapoints");
    model.result("pg5").feature("ptgr1").set("linewidth", "preference");

//    In the Settings window for Point Graph, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose T - Temperature - K.

    model.result("pg5").feature("ptgr1").set("expr", "T");
    model.result("pg5").feature("ptgr1").set("descr", "Temperature");

//    Locate the y-Axis Data section.
//    In the Unit field, type degC.

    model.result("pg5").feature("ptgr1").set("unit", "degC");

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

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

//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select Preset Studies for Selected Multiphysics > Frequency–Transient, One-Way Electromagnetic Heating.
//    Click Add Study in the window toolbar.

    model.study().create("std2");
    model.study("std2").create("freq", "Frequency");
    model.study("std2").feature("freq").set("punit", "Hz");
    model.study("std2").feature("freq").set("plist", "1[MHz]");
    model.study("std2").feature("freq").set("solnum", "auto");
    model.study("std2").feature("freq").set("notsolnum", "auto");
    model.study("std2").feature("freq").set("outputmap", new String[]{});
    model.study("std2").feature("freq").set("ngenAUX", "1");
    model.study("std2").feature("freq").set("goalngenAUX", "1");
    model.study("std2").feature("freq").set("ngenAUX", "1");
    model.study("std2").feature("freq").set("goalngenAUX", "1");
    model.study("std2").feature("freq").setSolveFor("/physics/ht", false);
    model.study("std2").feature("freq").setSolveFor("/multiphysics/emh1", false);
    model.study("std2").create("time", "Transient");
    model.study("std2").feature("time").set("initialtime", "0");
    model.study("std2").feature("time").set("solnum", "auto");
    model.study("std2").feature("time").set("notsolnum", "auto");
    model.study("std2").feature("time").set("outputmap", new String[]{});
    model.study("std2").feature("time").setSolveFor("/physics/emw", false);

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, locate the Study Settings section.
//    Select the Store solution for all intermediate study steps checkbox.

    model.study("std2").setStoreSolution(true);

//    In the Model Builder window, under Study 2, click Step 1: Frequency Domain.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    In the Frequencies text field, type 2.45[GHz].

    model.study("std2").feature("freq").set("plist", "2.45[GHz]");

//    Locate the Physics and Variables Selection section.
//    Select the Modify model configuration for study step checkbox.

    model.study("std2").feature("freq").set("useadvanceddisable", true);

//    In the tree, select Component 1 (comp1) > Electromagnetic Waves, Frequency Domain (emw) > Port 1, Full Model.
//    Click Disable.

    model.study("std2").feature("freq").set("disabledphysics", new String[]{"emw/port1"});

//    In the Model Builder window, click Step 2: Time Dependent.
//    In the Settings window for Time Dependent, locate the Study Settings section.
//    In the Output times text field, type range(0,1,5).

    model.study("std2").feature("time").set("tlist", "range(0,1,5)");

//    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.
//    Click Add.

    model.study("std2").feature("param").setIndex("pname", "wo", 0);
    model.study("std2").feature("param").setIndex("plistarr", "", 0);
    model.study("std2").feature("param").setIndex("punit", "m", 0);
    model.study("std2").feature("param").setIndex("pname", "wo", 0);
    model.study("std2").feature("param").setIndex("plistarr", "", 0);
    model.study("std2").feature("param").setIndex("punit", "m", 0);

//    In the table, enter the following settings:

    model.study("std2").feature("param").setIndex("pname", "full_geometry", 0);
    model.study("std2").feature("param").setIndex("plistarr", 0, 0);

//    In the Study toolbar, click Compute.

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

    model.sol().create("sol9");
    model.sol("sol9").study("std2");
    model.sol("sol9").label("Parametric Solutions 3");

    model.batch("p2").feature("so1").set("psol", "sol9");

    model.sol().create("sol10");
    model.sol("sol10").study("std2");
    model.sol("sol10").label("Parametric Solutions 4");

    model.batch("p2").feature("so2").set("psol", "sol10");
    model.batch("p2").run("compute");

    model.result().create("pg6", "PlotGroup3D");
    model.result("pg6").set("data", "dset8");
    model.result("pg6").create("mslc1", "Multislice");
    model.result("pg6").feature("mslc1").set("expr", new String[]{"emw.normE"});
    model.result("pg6").set("showlegendsmaxmin", true);
    model.result("pg6").feature("mslc1").set("colortable", "RainbowLight");
    model.result("pg6").feature("mslc1").set("ynumber", "0");
    model.result("pg6").create("surf1", "Surface");
    model.result("pg6").feature("surf1").set("expr", new String[]{"emw.normE"});
    model.result("pg6").feature("surf1").set("evaluationsettings", "parent");
    model.result("pg6").feature("surf1").create("sel1", "Selection");
    model.result("pg6").feature("surf1").feature("sel1").selection().set(2, 7, 13, 16);
    model.result("pg6").feature("surf1").set("inheritplot", "mslc1");
    model.result("pg6").label("Electric Field (emw) 1");
    model.result().evaluationGroup().create("eg2", "EvaluationGroup");
    model.result().evaluationGroup("eg2").set("data", "dset8");
    model.result().evaluationGroup("eg2").label("S-Parameter (emw) 1");
    model.result().evaluationGroup("eg2").set("data", "dset6");
    model.result().evaluationGroup("eg2").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("eg2").feature("gev1").label("S-Parameter (emw)");
    model.result().evaluationGroup("eg2").feature("gev1").set("expr", new String[]{"emw.S22dB"});
    model.result().table().create("tbl3", "Table");
    model.result().evaluationGroup("eg2").feature("gev1").set("table", "tbl3");
    model.result().evaluationGroup("eg2").run();
    model.result().create("pg7", "PlotGroup3D");
    model.result("pg7").set("data", "dset8");
    model.result("pg7").label("Electric Field, Logarithmic (emw) 1");
    model.result("pg7").selection().geom("geom1", 3);
    model.result("pg7").selection().set(1, 2, 3, 4);
    model.result("pg7").set("applyselectiontodatasetedges", true);

    model.component("comp1").measure().selection().geom(2);
    model.component("comp1").measure().selection().set(3, 4, 5, 6, 8, 10, 11, 22);
    model.component("comp1").measure().selection().geom(2);
    model.component("comp1").measure().selection().set(1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 13, 16, 22);

    model.result("pg7").create("surf1", "Surface");
    model.result("pg7").feature("surf1").set("expr", "emw.normE");
    model.result("pg7").feature("surf1").create("sel1", "Selection");
    model.result("pg7").feature("surf1").feature("sel1").selection().set(3, 4, 5, 6, 8, 10, 11, 22);
    model.result("pg7").feature("surf1").set("colortable", "Dipole");
    model.result("pg7").feature("surf1").set("colorscalemode", "logarithmic");
    model.result("pg7").feature("surf1").create("tran1", "Transparency");
    model.result("pg7").feature("surf1").feature("tran1").set("transparency", 0.77);
    model.result("pg7").feature("surf1").create("mtrl1", "MaterialAppearance");
    model.result("pg7").feature("surf1").feature("mtrl1").set("appearance", "custom");
    model.result("pg7").feature("surf1").feature("mtrl1").set("family", "rosegold");
    model.result("pg7").feature("surf1").set("expr", "1");
    model.result("pg7").create("surf2", "Surface");
    model.result("pg7").feature("surf2").set("expr", "emw.normE");
    model.result("pg7").feature("surf2").create("sel1", "Selection");
    model.result("pg7").feature("surf2").feature("sel1").selection().set(2, 7, 13, 16);
    model.result("pg7").feature("surf2").set("colortable", "Prism");
    model.result("pg7").feature("surf2").set("colorscalemode", "logarithmic");
    model.result("pg7").feature("surf2").create("tran1", "Transparency");
    model.result("pg7").feature("surf2").feature("tran1").set("transparency", 0.7);
    model.result("pg7").create("surf3", "Surface");
    model.result("pg7").feature("surf3").set("expr", "emw.normE");
    model.result("pg7").feature("surf3").create("sel1", "Selection");
    model.result("pg7").feature("surf3").feature("sel1").selection().set(9, 12, 14, 15, 17, 18, 19, 20, 21);
    model.result("pg7").feature("surf3").set("colortable", "Dipole");
    model.result("pg7").feature("surf3").set("colorscalemode", "logarithmic");
    model.result("pg7").feature("surf3").create("tran1", "Transparency");
    model.result("pg7").feature("surf3").feature("tran1").set("transparency", 0.3);
    model.result("pg7").create("surf4", "Surface");
    model.result("pg7").feature("surf4").set("expr", "emw.normE");
    model.result("pg7").feature("surf4").create("sel1", "Selection");
    model.result("pg7").feature("surf4").feature("sel1").selection().set(1);
    model.result("pg7").feature("surf4").set("colortable", "Dipole");
    model.result("pg7").feature("surf4").set("colorscalemode", "logarithmic");
    model.result("pg7").feature("surf4").create("tran1", "Transparency");
    model.result("pg7").feature("surf4").feature("tran1").set("transparency", 0.7);

    model.component("comp1").view().create("view3", "geom1");
    model.component("comp1").view("view3").camera().set("position", new double[]{-0.44, -0.66, 0.54});
    model.component("comp1").view("view3").set("environmentmap", "Indoor");
    model.component("comp1").view("view3").camera().set("zoomanglefull", 41.95);

    model.result("pg7").set("view", "view3");
    model.result().create("pg8", "PlotGroup3D");
    model.result("pg8").label("Temperature (ht)");
    model.result("pg8").set("data", "dset8");
    model.result("pg8").set("smooth", "internal");
    model.result("pg8").feature().create("vol1", "Volume");
    model.result("pg8").feature("vol1").set("solutionparams", "parent");

    return model;
  }

  public static Model run3(Model model) {
    model.result("pg8").feature("vol1").set("expr", "T");
    model.result("pg8").feature("vol1").set("colortable", "HeatCameraLight");
    model.result("pg8").feature("vol1").set("smooth", "internal");
    model.result("pg8").feature("vol1").set("data", "parent");
    model.result("pg6").run();

//    In the Settings window for 3D Plot Group, type Electric Field (emw), Half Model in the Label text field.

    model.result("pg6").label("Electric Field (emw), Half Model");
    model.result("pg6").run();

//    In the Model Builder window, expand the Electric Field (emw), Half Model node, then click Multislice 1.
//    In the Settings window for Multislice, locate the Multiplane Data section.
//    Find the X-planes subsection.
//    In the Planes text field, type 0.

    model.result("pg6").feature("mslc1").set("xnumber", "0");

//    Find the Z-planes subsection.
//    In the Planes text field, type 0.

    model.result("pg6").feature("mslc1").set("znumber", "0");

//    Find the Y-planes subsection.
//    From the Entry method list, select Coordinates.

    model.result("pg6").feature("mslc1").set("multiplaneymethod", "coord");

//    In the Coordinates text field, type 0.

    model.result("pg6").feature("mslc1").set("ycoord", 0);
    model.result("pg6").run();
    model.result("pg7").set("applyselectiontodatasetedges", true);
    model.result("pg7").run();

//    In the Model Builder window, under Results, click Electric Field, Logarithmic (emw) 1.
//    Review the default plots of the half size model and modify them to compare your results with those of the full size model.

    model.result("pg8").set("applyselectiontodatasetedges", false);
    model.result("pg8").run();

//    In the Model Builder window, click Temperature (ht).
//    In the Settings window for 3D Plot Group, locate the Data section.
//    From the Dataset list, select Study 2/Parametric Solutions 3 (sol9).

    model.result("pg8").set("data", "dset7");
    model.result("pg8").run();

//    In the Model Builder window, expand the Temperature (ht) node, then click Volume 1.
//    In the Settings window for Volume, locate the Expression section.
//    In the Unit field, type degC.

    model.result("pg8").feature("vol1").set("unit", "degC");
    model.result("pg8").run();

//    In the Model Builder window, right-click Temperature (ht) and choose Slice.

    model.result("pg8").create("slc1", "Slice");
    model.result("pg8").feature("slc1").set("evaluationsettings", "parent");

//    In the Settings window for Slice, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Electromagnetic Waves, Frequency Domain > Electric > Electric field - V/m > emw.Ez - Electric field, z-component.

    model.result("pg8").feature("slc1").set("expr", "emw.Ez");
    model.result("pg8").feature("slc1").set("descr", "Electric field, z-component");

//    Locate the Plane Data section.
//    From the Plane list, select XY-planes.

    model.result("pg8").feature("slc1").set("quickplane", "xy");

//    From the Entry method list, select Coordinates.

    model.result("pg8").feature("slc1").set("quickzmethod", "coord");

//    In the Z-coordinates text field, type 0.1.

    model.result("pg8").feature("slc1").set("quickz", 0.1);

//    Click the Go to Default View button in the Graphics toolbar.
//    Right-click Slice 1 and choose Deformation.

    model.result("pg8").feature("slc1").create("def1", "Deform");
    model.result("pg8").run();

//    In the Settings window for Deformation, locate the Expression section.
//    In the X-component text field, type 0.

    model.result("pg8").feature("slc1").feature("def1").set("expr", new String[]{"0", "", ""});

//    In the Y-component text field, type 0.

    model.result("pg8").feature("slc1").feature("def1").set("expr", new String[]{"0", "0", ""});

//    In the Z-component text field, type patcheval(emw.Ez,2).

    model.result("pg8").feature("slc1").feature("def1").set("expr", new String[]{"0", "0", "patcheval(emw.Ez,2)"});

//    In the Temperature (ht) toolbar, click Plot.

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

//    In the Model Builder window, under Results, click Temperature (ht).
//    In the Settings window for 3D Plot Group, type Temperature (ht) and Ez, Half Model in the Label text field.

    model.result("pg8").label("Temperature (ht) and Ez, Half Model");

//    In the Results toolbar, click 3D Plot Group.

    model.result().create("pg9", "PlotGroup3D");
    model.result("pg9").run();

//    In the Settings window for 3D Plot Group, type Resistive Heating, Half Model in the Label text field.

    model.result("pg9").label("Resistive Heating, Half Model");

//    Locate the Data section.
//    From the Dataset list, select Study 2/Solution Store 2 (sol8).

    model.result("pg9").set("data", "dset6");

//    Right-click Resistive Heating, Half Model and choose Slice.

    model.result("pg9").create("slc1", "Slice");
    model.result("pg9").feature("slc1").set("evaluationsettings", "parent");

//    In the Settings window for Slice, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Electromagnetic Waves, Frequency Domain > Heating and losses > emw.Qrh - Resistive losses - W/m³.

    model.result("pg9").feature("slc1").set("expr", "emw.Qrh");
    model.result("pg9").feature("slc1").set("descr", "Resistive losses");

//    Locate the Plane Data section.
//    From the Plane list, select ZX-planes.

    model.result("pg9").feature("slc1").set("quickplane", "zx");

//    From the Entry method list, select Coordinates.

    model.result("pg9").feature("slc1").set("quickymethod", "coord");

//    In the Resistive Heating, Half Model toolbar, click Plot.

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

//    Click the Go to Default View button in the Graphics toolbar.
//    In the Results toolbar, click More Derived Values and choose Integration > Volume Integration.

    model.result().numerical().create("int2", "IntVolume");

//    In the Settings window for Volume Integration, locate the Data section.
//    From the Dataset list, select Study 2/Parametric Solutions 3 (sol9).

    model.result().numerical("int2").set("data", "dset7");

//    From the Time selection list, select First.

    model.result().numerical("int2").setIndex("looplevelinput", "first", 0);

//    Select Domain 3.

    model.result().numerical("int2").selection().set(3);

//    Locate the Selection section.
//    From the Selection list, select Potato.

    model.result().numerical("int2").selection().named("sel1");

//    Click Replace Expression in the upper-right corner of the Expressions section.
//    From the menu, choose Component 1 (comp1) > Heat Transfer in Solids > Heat sources > ht.Qtot - Total heat source - W/m³.

    model.result().numerical("int2").set("expr", new String[]{"ht.Qtot"});
    model.result().numerical("int2").set("descr", new String[]{"Total heat source"});
    model.result().numerical("int2").set("unit", new String[]{"W"});

//    Click Evaluate.

    model.result().table().create("tbl4", "Table");
    model.result().table("tbl4").comments("Volume Integration 2");
    model.result().numerical("int2").set("table", "tbl4");
    model.result().numerical("int2").setResult();

//    The result is 314 W. This is roughly half the power as for the full model.
//    In the Results toolbar, click Cut Point 3D.

    model.result().dataset().create("cpt2", "CutPoint3D");

//    In the Settings window for Cut Point 3D, locate the Data section.
//    From the Dataset list, select Study 2/Solution 7 (sol7).

    model.result().dataset("cpt2").set("data", "dset5");

//    Locate the Point Data section.
//    In the X text field, type wo/2.

    model.result().dataset("cpt2").set("pointx", "wo/2");

//    In the Y text field, type 0.

    model.result().dataset("cpt2").set("pointy", 0);

//    In the Z text field, type rpot+bp+hp.

    model.result().dataset("cpt2").set("pointz", "rpot+bp+hp");

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

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

//    In the Settings window for 1D Plot Group, locate the Data section.
//    From the Dataset list, select Cut Point 3D 2.

    model.result("pg10").set("data", "cpt2");

//    Locate the Title section.
//    From the Title type list, select Manual.

    model.result("pg10").set("titletype", "manual");

//    In the Title text area, type Temperature in potato.

    model.result("pg10").set("title", "Temperature in potato");

//    Locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg10").set("xlabelactive", true);

//    In the associated text field, type Time (s).

    model.result("pg10").set("xlabel", "Time (s)");

//    Right-click 1D Plot Group 10 and choose Point Graph.

    model.result("pg10").create("ptgr1", "PointGraph");
    model.result("pg10").feature("ptgr1").set("markerpos", "datapoints");
    model.result("pg10").feature("ptgr1").set("linewidth", "preference");

//    In the Settings window for Point Graph, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose T - Temperature - K.

    model.result("pg10").feature("ptgr1").set("expr", "T");
    model.result("pg10").feature("ptgr1").set("descr", "Temperature");

//    Locate the y-Axis Data section.
//    In the Unit field, type degC.

    model.result("pg10").feature("ptgr1").set("unit", "degC");

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

    model.result("pg10").run();
    model.result("pg8").run();

    model.title("Microwave Oven");

    model
         .description("A potato inserted in a microwave oven is exposed to microwave radiation at 2.45\u00a0GHz. The heating of the potato for the first 5\u00a0seconds is solved for and analyzed. After that time the temperature in the potato approaches 100\u00b0C.");

    return model;
  }

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

}
