/*
 * rf_heating.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 15 2026, 12:32 by COMSOL 6.4.0.421. */
public class rf_heating {

  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.
//    Click Study.
//    In the Select Study tree, select Preset Studies for Selected Multiphysics > Frequency–Transient.
//    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("ftrans", "FrequencyTransient");
    model.study("std1").feature("ftrans").set("initialtime", "0");
    model.study("std1").feature("ftrans").set("freq", "1000000");
    model.study("std1").feature("ftrans").set("solnum", "auto");
    model.study("std1").feature("ftrans").set("notsolnum", "auto");
    model.study("std1").feature("ftrans").set("outputmap", new String[]{});

//    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("f0", "10[GHz]");
    model.param().descr("f0", "Current frequency");
    model.param().set("lda0", "c_const/f0");
    model.param().descr("lda0", "Wavelength, air");
    model.param().set("h_max", "0.2*lda0");
    model.param().descr("h_max", "Maximum mesh element size, air");

//    Here, <c>c_const</c> is a predefined COMSOL constant for the speed of light in vacuum.
//    First, import the geometry of the waveguide including a dielectric block inside the waveguide.
//    In the Geometry toolbar, click Import.

    model.component("comp1").geom("geom1").create("imp1", "Import");

//    In the Settings window for Import, locate the Source section.
//    Click Browse.
//    Browse to the model's Application Library folder and double-click the file rf_heating.mphbin.

    model.component("comp1").geom("geom1").feature("imp1").set("filename", "rf_heating.mphbin");

//    Click Import.

    model.component("comp1").geom("geom1").feature("imp1").importData();

//    Use the wireframe rendering to see the inner parts of the waveguide.
//    Click the Wireframe Rendering button in the Graphics toolbar.

    model.component("comp1").view("view1").set("renderwireframe", true);

//    Create a set of selections for use before setting up the physics. First, create a selection for the dielectric block.
//    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 Dielectric in the Label text field.

    model.component("comp1").selection("sel1").label("Dielectric");

//    Select Domain 3.

    model.component("comp1").selection("sel1").set(3);

//    Add a selection for the air-filled region inside the waveguide.
//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel2", "Explicit");

//    In the Settings window for Explicit, type Air in the Label text field.

    model.component("comp1").selection("sel2").label("Air");

//    Select Domain 2.

    model.component("comp1").selection("sel2").set(2);

//    Add a selection for the waveguide structure.
//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel3", "Explicit");

//    In the Settings window for Explicit, type Waveguide in the Label text field.

    model.component("comp1").selection("sel3").label("Waveguide");

//    Select Domain 1.

    model.component("comp1").selection("sel3").set(1);

//    Add a selection for the inner surface of the waveguide.
//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel4", "Explicit");

//    In the Settings window for Explicit, type Waveguide inside surfaces in the Label text field.

    model.component("comp1").selection("sel4").label("Waveguide inside surfaces");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").selection("sel4").geom(2);

//    Select Boundaries 16, 17, 18, 35, 53, 54, 72, 74, 75, 78, 96, 97.

    model.component("comp1").selection("sel4").set(16, 17, 18, 35, 53, 54, 72, 74, 75, 78, 96, 97);

//    Add a selection for the outer surface of the waveguide.
//    In the Definitions toolbar, click Explicit.

    model.component("comp1").selection().create("sel5", "Explicit");

//    In the Settings window for Explicit, type Waveguide outside surfaces in the Label text field.

    model.component("comp1").selection("sel5").label("Waveguide outside surfaces");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").selection("sel5").geom(2);

//    Select Boundaries 48, 49, 50, 51, 52, 55, 69, 98.

    model.component("comp1").selection("sel5").set(48, 49, 50, 51, 52, 55, 69, 98);

//    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.
//    In the list, select 1.
//    select 1 in the list.
//    Click Remove from Selection.

    model.component("comp1").physics("emw").selection().set(2, 3);

//    Select Domains 2, 3.
//    In the Model Builder window, under Component 1 (comp1) > Electromagnetic Waves, Frequency Domain (emw), click Wave Equation, Electric 1.
//    In the Settings window for Wave Equation, Electric, locate the Electric Displacement Field section.
//    From the Electric displacement field model list, select Loss tangent, loss angle.

    model.component("comp1").physics("emw").feature("wee1").set("DisplacementFieldModel", "LossTangent");

//    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.
//    In the list, select 2.
//    select 2 in the list.
//    Click Remove from Selection.

    model.component("comp1").physics("ht").selection().set(1, 3);

//    Select Domains 1, 3.
//    In the Physics toolbar, click Boundaries and choose Heat Flux.

    model.component("comp1").physics("ht").create("hf1", "HeatFluxBoundary", 2);

//    In the Settings window for Heat Flux, locate the Boundary Selection section.
//    From the Selection list, select Waveguide outside surfaces.

    model.component("comp1").physics("ht").feature("hf1").selection().named("sel5");

//    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 5.

    model.component("comp1").physics("ht").feature("hf1").set("h", 5);

//    In the Model Builder window, under Component 1 (comp1), click Electromagnetic Waves, Frequency Domain (emw).
//    In the Physics toolbar, click Domains and choose Wave Equation, Electric.

    model.component("comp1").physics("emw").create("wee2", "WaveEquationElectric", 3);

//    In the Settings window for Wave Equation, Electric, locate the Domain Selection section.
//    From the Selection list, select Air.

    model.component("comp1").physics("emw").feature("wee2").selection().named("sel2");

//    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 Waveguide inside surfaces.

    model.component("comp1").physics("emw").feature("imp1").selection().named("sel4");

//    In the Physics toolbar, click Boundaries and choose Port.

    model.component("comp1").physics("emw").create("port1", "Port", 2);

//    Select Boundary 15.

    model.component("comp1").physics("emw").feature("port1").selection().set(15);

//    In the Settings window for Port, 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 100.

    model.component("comp1").physics("emw").feature("port1").set("Pin", 100);

//    In the Physics toolbar, click Boundaries and choose Port.

    model.component("comp1").physics("emw").create("port2", "Port", 2);

//    Select Boundary 79.

    model.component("comp1").physics("emw").feature("port2").selection().set(79);

//    In the Settings window for Port, locate the Port Properties section.
//    From the Type of port list, select Rectangular.

    model.component("comp1").physics("emw").feature("port2").set("PortType", "Rectangular");

//    Next, assign material properties on the model. Begin by specifying Aluminum for the waveguide structure.
//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Built-in > Aluminum.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat1", "Common");
    model.component("comp1").material("mat1").propertyGroup()
         .create("Enu", "Enu", "Young's modulus and Poisson's ratio");
    model.component("comp1").material("mat1").propertyGroup().create("Murnaghan", "Murnaghan", "Murnaghan");
    model.component("comp1").material("mat1").label("Aluminum");
    model.component("comp1").material("mat1").set("family", "aluminum");
    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("heatcapacity", "900[J/(kg*K)]");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalconductivity", new String[]{"238[W/(m*K)]", "0", "0", "0", "238[W/(m*K)]", "0", "0", "0", "238[W/(m*K)]"});
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("electricconductivity", new String[]{"3.774e7[S/m]", "0", "0", "0", "3.774e7[S/m]", "0", "0", "0", "3.774e7[S/m]"});
    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("thermalexpansioncoefficient", new String[]{"23e-6[1/K]", "0", "0", "0", "23e-6[1/K]", "0", "0", "0", "23e-6[1/K]"});
    model.component("comp1").material("mat1").propertyGroup("def").set("density", "2700[kg/m^3]");
    model.component("comp1").material("mat1").propertyGroup("Enu").set("E", "70[GPa]");
    model.component("comp1").material("mat1").propertyGroup("Enu").set("nu", "0.33");
    model.component("comp1").material("mat1").propertyGroup("Murnaghan").set("l", "-250[GPa]");
    model.component("comp1").material("mat1").propertyGroup("Murnaghan").set("m", "-330[GPa]");
    model.component("comp1").material("mat1").propertyGroup("Murnaghan").set("n", "-350[GPa]");

//    In the tree, select Built-in > Air.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat2", "Common");
    model.component("comp1").material("mat2").propertyGroup("def").func().create("eta", "Piecewise");
    model.component("comp1").material("mat2").propertyGroup("def").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat2").propertyGroup("def").func().create("rho", "Analytic");
    model.component("comp1").material("mat2").propertyGroup("def").func().create("k", "Piecewise");
    model.component("comp1").material("mat2").propertyGroup("def").func().create("cs", "Analytic");
    model.component("comp1").material("mat2").propertyGroup("def").func().create("an1", "Analytic");
    model.component("comp1").material("mat2").propertyGroup("def").func().create("an2", "Analytic");
    model.component("comp1").material("mat2").propertyGroup()
         .create("RefractiveIndex", "RefractiveIndex", "Refractive index");
    model.component("comp1").material("mat2").propertyGroup()
         .create("NonlinearModel", "NonlinearModel", "Nonlinear model");
    model.component("comp1").material("mat2").propertyGroup().create("idealGas", "idealGas", "Ideal gas");
    model.component("comp1").material("mat2").propertyGroup("idealGas").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat2").label("Air");
    model.component("comp1").material("mat2").set("family", "air");
    model.component("comp1").material("mat2").propertyGroup("def").func("eta").set("arg", "T");
    model.component("comp1").material("mat2").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("mat2").propertyGroup("def").func("eta").set("argunit", "K");
    model.component("comp1").material("mat2").propertyGroup("def").func("eta").set("fununit", "Pa*s");
    model.component("comp1").material("mat2").propertyGroup("def").func("Cp").set("arg", "T");
    model.component("comp1").material("mat2").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("mat2").propertyGroup("def").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat2").propertyGroup("def").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat2").propertyGroup("def").func("rho")
         .set("expr", "pA*0.02897/R_const[K*mol/J]/T");
    model.component("comp1").material("mat2").propertyGroup("def").func("rho").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat2").propertyGroup("def").func("rho").set("fununit", "kg/m^3");
    model.component("comp1").material("mat2").propertyGroup("def").func("rho")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat2").propertyGroup("def").func("rho")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat2").propertyGroup("def").func("rho")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat2").propertyGroup("def").func("rho")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "293.15"}});
    model.component("comp1").material("mat2").propertyGroup("def").func("k").set("arg", "T");
    model.component("comp1").material("mat2").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("mat2").propertyGroup("def").func("k").set("argunit", "K");
    model.component("comp1").material("mat2").propertyGroup("def").func("k").set("fununit", "W/(m*K)");
    model.component("comp1").material("mat2").propertyGroup("def").func("cs")
         .set("expr", "sqrt(1.4*R_const[K*mol/J]/0.02897*T)");
    model.component("comp1").material("mat2").propertyGroup("def").func("cs").set("args", new String[]{"T"});
    model.component("comp1").material("mat2").propertyGroup("def").func("cs").set("fununit", "m/s");
    model.component("comp1").material("mat2").propertyGroup("def").func("cs").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat2").propertyGroup("def").func("cs")
         .set("plotfixedvalue", new String[]{"273.15"});
    model.component("comp1").material("mat2").propertyGroup("def").func("cs")
         .set("plotargs", new String[][]{{"T", "273.15", "373.15"}});
    model.component("comp1").material("mat2").propertyGroup("def").func("an1").set("funcname", "alpha_p");
    model.component("comp1").material("mat2").propertyGroup("def").func("an1")
         .set("expr", "-1/rho(pA,T)*d(rho(pA,T),T)");
    model.component("comp1").material("mat2").propertyGroup("def").func("an1").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat2").propertyGroup("def").func("an1").set("fununit", "1/K");
    model.component("comp1").material("mat2").propertyGroup("def").func("an1")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat2").propertyGroup("def").func("an1")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat2").propertyGroup("def").func("an1")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat2").propertyGroup("def").func("an1")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "373.15"}});
    model.component("comp1").material("mat2").propertyGroup("def").func("an2").set("funcname", "muB");
    model.component("comp1").material("mat2").propertyGroup("def").func("an2").set("expr", "0.6*eta(T)");
    model.component("comp1").material("mat2").propertyGroup("def").func("an2").set("args", new String[]{"T"});
    model.component("comp1").material("mat2").propertyGroup("def").func("an2").set("fununit", "Pa*s");
    model.component("comp1").material("mat2").propertyGroup("def").func("an2").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat2").propertyGroup("def").func("an2")
         .set("plotfixedvalue", new String[]{"200"});
    model.component("comp1").material("mat2").propertyGroup("def").func("an2")
         .set("plotargs", new String[][]{{"T", "200", "1600"}});
    model.component("comp1").material("mat2").propertyGroup("def").set("thermalexpansioncoefficient", "");
    model.component("comp1").material("mat2").propertyGroup("def").set("molarmass", "");
    model.component("comp1").material("mat2").propertyGroup("def").set("bulkviscosity", "");
    model.component("comp1").material("mat2").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("mat2").propertyGroup("def").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat2").propertyGroup("def").set("bulkviscosity", "muB(T)");
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    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("def").set("dynamicviscosity", "eta(T)");
    model.component("comp1").material("mat2").propertyGroup("def").set("ratioofspecificheat", "1.4");
    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("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat2").propertyGroup("def").set("density", "rho(pA,T)");
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("thermalconductivity", new String[]{"k(T)", "0", "0", "0", "k(T)", "0", "0", "0", "k(T)"});
    model.component("comp1").material("mat2").propertyGroup("def").set("soundspeed", "cs(T)");
    model.component("comp1").material("mat2").propertyGroup("def").addInput("temperature");
    model.component("comp1").material("mat2").propertyGroup("def").addInput("pressure");
    model.component("comp1").material("mat2").propertyGroup("RefractiveIndex")
         .set("n", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat2").propertyGroup("NonlinearModel").set("BA", "def.gamma-1");
    model.component("comp1").material("mat2").propertyGroup("idealGas").func("Cp").label("Piecewise 2");
    model.component("comp1").material("mat2").propertyGroup("idealGas").func("Cp").set("arg", "T");
    model.component("comp1").material("mat2").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("mat2").propertyGroup("idealGas").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat2").propertyGroup("idealGas").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat2").propertyGroup("idealGas").set("Rs", "R_const/Mn");
    model.component("comp1").material("mat2").propertyGroup("idealGas").set("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat2").propertyGroup("idealGas").set("ratioofspecificheat", "1.4");
    model.component("comp1").material("mat2").propertyGroup("idealGas").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat2").propertyGroup("idealGas").addInput("temperature");
    model.component("comp1").material("mat2").propertyGroup("idealGas").addInput("pressure");
    model.component("comp1").material("mat2").materialType("nonSolid");

//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Waveguide.

    model.component("comp1").material("mat1").selection().named("sel3");

//    In the Model Builder window, click Air (mat2).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Air.

    model.component("comp1").material("mat2").selection().named("sel2");

//    In the Model Builder window, right-click Materials and choose Blank Material.

    model.component("comp1").material().create("mat3", "Common");

//    In the Settings window for Material, type Dielectric in the Label text field.

    model.component("comp1").material("mat3").label("Dielectric");

//    Select Domain 3.

    model.component("comp1").material("mat3").selection().set(3);

//    Locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat3").propertyGroup()
         .create("LossTangent", "LossTangent", "Loss_tangent_loss_angle");
    model.component("comp1").material("mat3").propertyGroup("LossTangent").set("epsilonPrim", new String[]{"2.1"});
    model.component("comp1").material("mat3").propertyGroup("LossTangent")
         .set("delta", new String[]{"0.001*(T/300[K])"});
    model.component("comp1").material("mat3").propertyGroup("def").set("relpermeability", new String[]{"1"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("thermalconductivity", new String[]{"0.3[W/m/K]*(T/300[K])"});
    model.component("comp1").material("mat3").propertyGroup("def").set("density", new String[]{"2200"});
    model.component("comp1").material("mat3").propertyGroup("def").set("heatcapacity", new String[]{"1050"});

//    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 Waveguide inside surfaces.

    model.component("comp1").material("mat4").selection().named("sel4");

//    Choose the maximum mesh size in the air domain smaller than 0.2 wavelengths using the parameter h_max that you defined earlier. For the dielectric materials, scale the mesh size by the inverse of the square root of the relative dielectric constant.
//    In the Model Builder window, right-click Component 1 (comp1) > Mesh 1 and choose Size.

    model.component("comp1").mesh("mesh1").create("size1", "Size");

//    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", 3);

//    From the Selection list, select Air.

    model.component("comp1").mesh("mesh1").feature("size1").selection().named("sel2");

//    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 h_max.

    model.component("comp1").mesh("mesh1").feature("size1").set("hmax", "h_max");

//    In the Model Builder window, right-click Mesh 1 and choose Size.

    model.component("comp1").mesh("mesh1").create("size2", "Size");

//    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("size2").selection().geom("geom1", 3);

//    From the Selection list, select Dielectric.

    model.component("comp1").mesh("mesh1").feature("size2").selection().named("sel1");

//    Locate the Element Size section.
//    Click the Custom button.

    model.component("comp1").mesh("mesh1").feature("size2").set("custom", true);

//    Locate the Element Size Parameters section.
//    Select the Maximum element size checkbox.

    model.component("comp1").mesh("mesh1").feature("size2").set("hmaxactive", true);

//    In the associated text field, type h_max/sqrt(2.1).

    model.component("comp1").mesh("mesh1").feature("size2").set("hmax", "h_max/sqrt(2.1)");

//    In the Mesh toolbar, click Free Tetrahedral.

    model.component("comp1").mesh("mesh1").create("ftet1", "FreeTet");

//    In the Settings window for Free Tetrahedral, click Build All.

    model.component("comp1").mesh("mesh1").run();

//    In the Model Builder window, under Study 1, click Step 1: Frequency–Transient.
//    In the Settings window for Frequency–Transient, locate the Study Settings section.
//    In the Output times text field, type range(0,15,300).

    model.study("std1").feature("ftrans").set("tlist", "range(0,15,300)");

//    From the Tolerance list, select User controlled.

    model.study("std1").feature("ftrans").set("usertol", true);

//    In the Relative tolerance text field, type 0.001.

    model.study("std1").feature("ftrans").set("rtol", 0.001);

//    In the Frequency text field, type f0.

    model.study("std1").feature("ftrans").set("freq", "f0");

//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std1").setGenPlots(false);

//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.component("comp1").probe("emw_port1_probe").genResult("none");

    model.sol("sol1").runAll();

//    Plot the transient response of the peak temperature.
//    In the Model Builder window, expand the Results node.
//    Right-click Results > Datasets and choose More Datasets > Maximum.

    model.result().dataset().create("max1", "Maximum");

//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg2", "PlotGroup1D");
    model.result("pg2").run();

//    In the Settings window for 1D Plot Group, locate the Data section.
//    From the Dataset list, select Maximum 1.

    model.result("pg2").set("data", "max1");

//    Right-click 1D Plot Group 2 and choose Point Graph.

    model.result("pg2").create("ptgr1", "PointGraph");
    model.result("pg2").feature("ptgr1").set("markerpos", "datapoints");
    model.result("pg2").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 Component 1 (comp1) > Heat Transfer in Solids > Temperature > T - Temperature - K.

    model.result("pg2").feature("ptgr1").set("expr", "T");
    model.result("pg2").feature("ptgr1").set("descr", "Temperature");

//    Locate the y-Axis Data section.
//    In the Unit field, type degC.

    model.result("pg2").feature("ptgr1").set("unit", "degC");

//    In the 1D Plot Group 2 toolbar, click Plot.

    model.result("pg2").run();

//    Next, add a Frequency-Stationary study to evaluate the peak temperature which can be observed with the <l>Frequency-Transient</l> study after applying a time sufficiently long that the peak temperature is saturated.
//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.

    return model;
  }

  public static Model run2(Model model) {
//    In the Select Study tree, select Empty Study.
//    Click Add Study in the window toolbar.

    model.study().create("std2");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Study toolbar, click More Study Steps and choose Stationary > Frequency–Stationary.

    model.study("std2").create("fstat", "FrequencyStationary");

//    In the Settings window for Frequency–Stationary, locate the Study Settings section.
//    In the Frequency text field, type f0.

    model.study("std2").feature("fstat").set("freq", "f0");

//    In the Study toolbar, click Compute.

    model.study("std2").createAutoSequences("all");

    model.component("comp1").probe("emw_port1_probe").genResult("none");

    model.sol("sol2").runAll();

    model.result().create("pg3", "PlotGroup3D");
    model.result("pg3").set("data", "dset3");
    model.result("pg3").create("mslc1", "Multislice");
    model.result("pg3").feature("mslc1").set("expr", new String[]{"emw.normE"});
    model.result("pg3").set("showlegendsmaxmin", true);
    model.result("pg3").feature("mslc1").set("colortable", "RainbowLight");
    model.result("pg3").label("Electric Field (emw)");
    model.result().create("pg4", "PlotGroup3D");
    model.result("pg4").label("Temperature (ht)");
    model.result("pg4").set("data", "dset3");
    model.result("pg4").set("smooth", "internal");
    model.result("pg4").feature().create("vol1", "Volume");
    model.result("pg4").feature("vol1").set("solutionparams", "parent");
    model.result("pg4").feature("vol1").set("expr", "T");
    model.result("pg4").feature("vol1").set("colortable", "HeatCameraLight");
    model.result("pg4").feature("vol1").set("smooth", "internal");
    model.result("pg4").feature("vol1").set("data", "parent");
    model.result("pg3").run();
    model.result("pg4").run();

//    The default plots show the distribution of the electric field norm and the temperature. For the temperature plot, first change the unit to the degree Celsius.

    model.result("pg4").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("pg4").feature("vol1").set("unit", "degC");

//    Right-click Volume 1 and choose Filter.

    model.result("pg4").feature("vol1").create("filt1", "Filter");
    model.result("pg4").run();

//    In the Settings window for Filter, locate the Element Selection section.
//    In the Logical expression for inclusion text field, type z<0.01.

    model.result("pg4").feature("vol1").feature("filt1").set("expr", "z<0.01");

//    In the Temperature (ht) toolbar, click Plot.

    model.result("pg4").run();

//    Then, add arrow plots of the electric fields, magnetic fields, and power flow.
//    In the Results toolbar, click 3D Plot Group.

    model.result().create("pg5", "PlotGroup3D");
    model.result("pg5").run();

//    In the Settings window for 3D Plot Group, type Electric Field, Magnetic Field, and Power Flow in the Label text field.

    model.result("pg5").label("Electric Field, Magnetic Field, and Power Flow");

//    Locate the Data section.
//    From the Dataset list, select Probe Solution 2 (sol2).

    model.result("pg5").set("data", "dset2");

//    Right-click Electric Field, Magnetic Field, and Power Flow and choose Arrow Volume.

    model.result("pg5").create("arwv1", "ArrowVolume");
    model.result("pg5").feature("arwv1").set("evaluationsettings", "parent");

//    In the Settings window for Arrow Volume, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Electromagnetic Waves, Frequency Domain > Electric > emw.Ex,emw.Ey,emw.Ez - Electric field.

    model.result("pg5").feature("arwv1").set("expr", new String[]{"emw.Ex", "emw.Ey", "emw.Ez"});
    model.result("pg5").feature("arwv1").set("descr", "Electric field");

//    Locate the Arrow Positioning section.
//    Find the X grid points subsection.
//    In the Points text field, type 40.

    model.result("pg5").feature("arwv1").set("xnumber", 40);

//    Find the Y grid points subsection.
//    In the Points text field, type 40.

    model.result("pg5").feature("arwv1").set("ynumber", 40);

//    Find the Z grid points subsection.
//    In the Points text field, type 1.

    model.result("pg5").feature("arwv1").set("znumber", 1);

//    In the Electric Field, Magnetic Field, and Power Flow toolbar, click Plot.

    model.result("pg5").run();

//    Right-click Arrow Volume 1 and choose Duplicate.

    model.result("pg5").feature().duplicate("arwv2", "arwv1");
    model.result("pg5").run();

//    In the Settings window for Arrow Volume, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Electromagnetic Waves, Frequency Domain > Magnetic > emw.Hx,emw.Hy,emw.Hz - Magnetic field.

    model.result("pg5").feature("arwv2").set("expr", new String[]{"emw.Hx", "emw.Hy", "emw.Hz"});
    model.result("pg5").feature("arwv2").set("descr", "Magnetic field");

//    Locate the Coloring and Style section.
//    From the Color list, select Green.

    model.result("pg5").feature("arwv2").set("color", "green");

//    Right-click Arrow Volume 2 and choose Duplicate.

    model.result("pg5").feature().duplicate("arwv3", "arwv2");
    model.result("pg5").run();

//    In the Settings window for Arrow Volume, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Electromagnetic Waves, Frequency Domain > Energy and power > emw.Poavx,...,emw.Poavz - Power flow, time average.

    model.result("pg5").feature("arwv3").set("expr", new String[]{"emw.Poavx", "emw.Poavy", "emw.Poavz"});
    model.result("pg5").feature("arwv3").set("descr", "Power flow, time average");

//    Locate the Coloring and Style section.
//    From the Color list, select Blue.

    model.result("pg5").feature("arwv3").set("color", "blue");
    model.result("pg5").run();

//    In the Model Builder window, right-click Electric Field, Magnetic Field, and Power Flow and choose Volume.

    model.result("pg5").create("vol1", "Volume");
    model.result("pg5").feature("vol1").set("evaluationsettings", "parent");

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg5").feature("vol1").set("expr", "1");

//    Right-click Volume 1 and choose Material Appearance.

    model.result("pg5").feature("vol1").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg5").feature("vol1").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Chrome.

    model.result("pg5").feature("vol1").feature("mtrl1").set("family", "chrome");
    model.result("pg5").run();

//    In the Model Builder window, right-click Volume 1 and choose Selection.

    model.result("pg5").feature("vol1").create("sel1", "Selection");

//    Select Domain 1.

    model.result("pg5").feature("vol1").feature("sel1").selection().set(1);
    model.result("pg5").run();

//    Right-click Volume 1 and choose Filter.

    model.result("pg5").feature("vol1").create("filt1", "Filter");
    model.result("pg5").run();

//    In the Settings window for Filter, locate the Element Selection section.
//    In the Logical expression for inclusion text field, type z<0.01.

    model.result("pg5").feature("vol1").feature("filt1").set("expr", "z<0.01");

//    In the Electric Field, Magnetic Field, and Power Flow toolbar, click Plot.

    model.result("pg5").run();
    model.result("pg5").run();

//    In the Model Builder window, right-click Electric Field, Magnetic Field, and Power Flow and choose Surface.

    model.result("pg5").create("surf1", "Surface");
    model.result("pg5").feature("surf1").set("evaluationsettings", "parent");

//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg5").feature("surf1").set("expr", "1");

//    Right-click Surface 1 and choose Selection.

    model.result("pg5").feature("surf1").create("sel1", "Selection");

//    Select Boundaries 16, 17, 35, 53, 54, 72, 74, 75, 78, 96, 97.

    model.result("pg5").feature("surf1").feature("sel1").selection().set(16, 17, 35, 53, 54, 72, 74, 75, 78, 96, 97);
    model.result("pg5").run();

//    In the Model Builder window, right-click Surface 1 and choose Material Appearance.

    model.result("pg5").feature("surf1").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg5").feature("surf1").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Copper.

    model.result("pg5").feature("surf1").feature("mtrl1").set("family", "copper");

//    In the Electric Field, Magnetic Field, and Power Flow toolbar, click Plot.

    model.result("pg5").run();
    model.result("pg5").run();

//    In the Model Builder window, right-click Electric Field, Magnetic Field, and Power Flow and choose Surface.

    model.result("pg5").create("surf2", "Surface");
    model.result("pg5").feature("surf2").set("evaluationsettings", "parent");

//    In the Settings window for Surface, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Electromagnetic Waves, Frequency Domain > Material properties > emw.delta - Loss tangent, loss angle - rad.

    model.result("pg5").feature("surf2").set("expr", "emw.delta");
    model.result("pg5").feature("surf2").set("descr", "Loss tangent, loss angle");

//    Locate the Coloring and Style section.
//    From the Color table list, select Ctenophora.

    model.result("pg5").feature("surf2").set("colortable", "Ctenophora");

//    In the Electric Field, Magnetic Field, and Power Flow toolbar, click Plot.

    model.result("pg5").run();

//    Click the <l>Zoom Box</l> button in the <l>Graphics</l> toolbar and then use the mouse to zoom in.

    model.title("RF Heating");

    model
         .description("This is a model of an RF waveguide bend with a dielectric block inside. Electromagnetic losses in the block as well as on the waveguide walls cause the assembly to heat up over time. The material properties of the block are functions of temperature. The model computes the transient thermal behavior as well as the steady-state solution.");

    return model;
  }

  public static void main(String[] args) {
    Model model = run();
    run2(model);
  }

}
