/*
 * chip_cooling.java
 */

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

/** Model exported on May 14 2026, 10:05 by COMSOL 6.4.0.420. */
public class chip_cooling {

  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 > Heat Transfer in Solids and Fluids (ht).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Stationary.
//    Click Done.

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

    model.component("comp1").geom().create("geom1", 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("ht", "HeatTransferInSolidsAndFluids", "geom1");

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

//    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 chip_cooling.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("n_fins", "4", "Number of pins, x direction");
    model.param().set("L_chip", "40[mm]", "Chip size");
    model.param().set("H_chip", "4[mm]", "Chip height");
    model.param().set("P0", "10[W]", "Total power dissipated by the electronic chip");
    model.param().set("h0", "10[W/m^2/K]", "Heat Transfer coefficient");
    model.param().set("W_channel", "8[cm]", "Channel width");
    model.param().set("D_channel", "30[cm]", "Channel depth");
    model.param().set("H_channel", "6[cm]", "Channel height");
    model.param().set("U0", "0.1[m/s]", "Mean inlet velocity");

//    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 L_chip.

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

//    In the Depth text field, type L_chip.

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

//    In the Height text field, type H_chip.

    model.component("comp1").geom("geom1").feature("blk1").setIndex("size", "H_chip", 2);

//    Locate the Position section.
//    In the z text field, type -H_chip.

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

//    Click Build Selected.

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

//    In the Geometry toolbar, click Part Libraries.
//    In the Part Libraries window, select Heat Transfer Module > Heat Sinks > heat_sink_straight_fins in the tree.
//    Click Add to Geometry.

    model.geom()
         .load(new String[]{"part1"}, "Heat_Transfer_Module/Heat_Sinks/heat_sink_straight_fins.mph", new String[]{"part1"});
    model.component("comp1").geom("geom1").create("pi1", "PartInstance");
    model.component("comp1").geom("geom1").feature("pi1").set("selkeepnoncontr", false);
    model.component("comp1").geom("geom1").feature("pi1").set("part", "part1");

//    In the Model Builder window, under Component 1 (comp1) > Geometry 1, click Heat Sink - Straight Fins 1 (pi1).
//    In the Settings window for Part Instance, locate the Input Parameters section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "n_fins_x", "n_fins");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "X_fins_bottom", "3[mm]");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "X_fins_top", "2[mm]");

//    Locate the Position and Orientation of Output section.
//    Find the Coordinate system in part subsection.
//    From the Work plane in part list, select Work plane for heat sink base (wp11).

    model.component("comp1").geom("geom1").feature("pi1").set("workplanepart", "wp11");

//    Find the Displacement subsection.
//    In the xwi text field, type -5[mm].

    model.component("comp1").geom("geom1").feature("pi1").set("displ", new String[]{"-5[mm]", "0", "0"});

//    In the ywi text field, type -5[mm].

    model.component("comp1").geom("geom1").feature("pi1").set("displ", new String[]{"-5[mm]", "-5[mm]", "0"});

//    Click to expand the Domain Selections section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepdom", "pi1_csel1.dom", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetodom", "pi1_csel1.dom", "none");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepdom", "pi1_csel2.dom", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetodom", "pi1_csel2.dom", "none");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepdom", "pi1_csel3.dom", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetodom", "pi1_csel3.dom", "none");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepdom", "pi1_csel9.dom", true);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selshowdom", "pi1_csel9.dom", true);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetodom", "pi1_csel9.dom", "none");

//    Click to collapse the Domain Selections section.
//    Click to expand the Boundary Selections section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_boxsel1", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_boxsel1", "none");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_adjsel2", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_adjsel2", "none");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_difsel1", true);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selshowbnd", "pi1_difsel1", true);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_difsel1", "none");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_csel9.bnd", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_csel9.bnd", "none");

//    Click to collapse the Boundary Selections section.
//    In the Geometry toolbar, click Build All.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Model Builder window, click Geometry 1.
//    In the Home toolbar, click Add Material to open the Add Material window.
//    In the tree, select Built-in > Aluminum.
//    Right-click and choose Add to Component 1 (comp1).

    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 > Silica glass.
//    Right-click and choose Add to Component 1 (comp1).

    model.component("comp1").material().create("mat2", "Common");
    model.component("comp1").material("mat2").propertyGroup()
         .create("Enu", "Enu", "Young's modulus and Poisson's ratio");
    model.component("comp1").material("mat2").propertyGroup()
         .create("RefractiveIndex", "RefractiveIndex", "Refractive index");
    model.component("comp1").material("mat2").label("Silica glass");
    model.component("comp1").material("mat2").set("family", "custom");
    model.component("comp1").material("mat2").set("diffuse", "custom");
    model.component("comp1").material("mat2").set("ambient", "custom");
    model.component("comp1").material("mat2").set("noise", true);
    model.component("comp1").material("mat2").set("fresnel", 0.99);
    model.component("comp1").material("mat2").set("roughness", 0.02);
    model.component("comp1").material("mat2").set("diffusewrap", 0);
    model.component("comp1").material("mat2").set("reflectance", 0);
    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("electricconductivity", new String[]{"1e-14[S/m]", "0", "0", "0", "1e-14[S/m]", "0", "0", "0", "1e-14[S/m]"});
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"0.55e-6[1/K]", "0", "0", "0", "0.55e-6[1/K]", "0", "0", "0", "0.55e-6[1/K]"});
    model.component("comp1").material("mat2").propertyGroup("def").set("heatcapacity", "703[J/(kg*K)]");
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("relpermittivity", new String[]{"3.75", "0", "0", "0", "3.75", "0", "0", "0", "3.75"});
    model.component("comp1").material("mat2").propertyGroup("def").set("density", "2203[kg/m^3]");
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("thermalconductivity", new String[]{"1.38[W/(m*K)]", "0", "0", "0", "1.38[W/(m*K)]", "0", "0", "0", "1.38[W/(m*K)]"});
    model.component("comp1").material("mat2").propertyGroup("Enu").set("E", "73.1[GPa]");
    model.component("comp1").material("mat2").propertyGroup("Enu").set("nu", "0.17");
    model.component("comp1").material("mat2").propertyGroup("RefractiveIndex")
         .set("n", new String[]{"1.45", "0", "0", "0", "1.45", "0", "0", "0", "1.45"});

//    In the Home toolbar, click Add Material to close the Add Material window.
//    Click the Zoom Extents button in the Graphics toolbar.
//    Click the Wireframe Rendering button in the Graphics toolbar.

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

//    Select Domain 3.

    model.component("comp1").material("mat2").selection().set(3);

//    In order to easily reuse the selection of the domain corresponding to the chip, create a dedicated selection for it.
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    Click Create Selection.
//    In the Create Selection dialog, type Chip in the Selection name text field.
//    Click OK.

    model.component("comp1").selection().create("sel1", "Explicit");
    model.component("comp1").selection("sel1").geom(3);
    model.component("comp1").selection("sel1").label("Chip");
    model.component("comp1").selection("sel1").set(3);

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

//    In the Physics toolbar, click Shared Properties and choose Ambient Properties.

    model.component("comp1").common().create("ampr1", "AmbientProperties");

//    In the Physics toolbar, click Domains and choose Heat Source.

    model.component("comp1").physics("ht").create("hs1", "HeatSource", 3);

//    In the Settings window for Heat Source, locate the Domain Selection section.
//    From the Selection list, select Chip.

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

//    Locate the Heat Source section.
//    From the Heat source list, select Heat rate.

    model.component("comp1").physics("ht").feature("hs1").set("heatSourceType", "HeatRate");

//    In the \[P_0\] text field, type P0.

    model.component("comp1").physics("ht").feature("hs1").set("P0", "P0");

//    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 Exterior boundaries without heat sink base (Heat Sink - Straight Fins 1).

    model.component("comp1").physics("ht").feature("hf1").selection().named("geom1_pi1_difsel1");

//    Locate the Heat Flux section.
//    From the Flux type list, select Convective heat flux.

    model.component("comp1").physics("ht").feature("hf1").set("HeatFluxType", "ConvectiveHeatFlux");

//    First enter the heat transfer coefficient defined from a parameter.
//    In the \[h\] text field, type h0.

    model.component("comp1").physics("ht").feature("hf1").set("h", "h0");

//    Then the external temperature is set to the ambient temperature defined in the <l>Ambient Properties 1</l> node (the default value is 293.15 K).
//    From the \[T_{\textrm{ext}}\] list, select Ambient temperature (ampr1).

    model.component("comp1").physics("ht").feature("hf1").set("Text_src", "root.comp1.ampr1.T_amb");

//    In the Home toolbar, click Compute.

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

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

    model.result().create("pg1", "PlotGroup3D");
    model.result("pg1").label("Temperature (ht)");
    model.result("pg1").set("smooth", "internal");
    model.result("pg1").feature().create("vol1", "Volume");
    model.result("pg1").feature("vol1").set("solutionparams", "parent");
    model.result("pg1").feature("vol1").set("colortable", "HeatCameraLight");
    model.result("pg1").feature("vol1").set("smooth", "internal");
    model.result("pg1").feature("vol1").set("data", "parent");
    model.result("pg1").run();

//    The computation takes a few seconds and about 1 GB of memory.
//    Change the unit of the temperature results to degrees Celsius.
//    In the Results toolbar, click Configurations and choose Preferred Units.

    model.result().configuration().create("prfu1", "PreferredUnits");

//    In the Settings window for Preferred Units, locate the Units section.
//    Click Add Physical Quantity.
//    In the Physical Quantity dialog, select General > Temperature (K) in the tree.
//    Click OK.

    model.result().configuration("prfu1")
         .setIndex("quantityunits", new String[]{"temperature", "Temperature", "K", "K"}, 0);

//    In the Settings window for Preferred Units, locate the Units section.
//    In the table, enter the following settings:

    model.result().configuration("prfu1").setIndex("quantityunits", "\u00b0C", 0, 3);

//    Click Apply.

    model.result().configuration("prfu1").apply();
    model.result("pg1").run();

//    The automatically generated default plot shows the temperature in the domain. Modify this plot to display the temperature at the interface between the chip and the heat sink by applying the existing domain selections to the volume plot.

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

//    In the Model Builder window, expand the Temperature (ht) node.
//    Right-click Volume 1 and choose Selection.

    model.result("pg1").feature("vol1").create("sel1", "Selection");

//    In the Settings window for Selection, locate the Selection section.
//    From the Selection list, select Chip.

    model.result("pg1").feature("vol1").feature("sel1").selection().named("sel1");
    model.result("pg1").run();

//    Right-click Volume 1 and choose Duplicate.

    model.result("pg1").feature().duplicate("vol2", "vol1");
    model.result("pg1").run();
    model.result("pg1").run();

//    In the Model Builder window, expand the Volume 2 node, then click Selection 1.
//    In the Settings window for Selection, locate the Selection section.
//    From the Selection list, select All (Heat Sink - Straight Fins 1).

    model.result("pg1").feature("vol2").feature("sel1").selection().named("geom1_pi1_csel9_dom");
    model.result("pg1").run();

//    In the Model Builder window, click Volume 2.
//    In the Settings window for Volume, click to expand the Title section.
//    From the Title type list, select None.

    model.result("pg1").feature("vol2").set("titletype", "none");

//    Click to expand the Inherit Style section.
//    From the Plot list, select Volume 1.

    model.result("pg1").feature("vol2").set("inheritplot", "vol1");

//    Right-click Volume 2 and choose Filter.

    model.result("pg1").feature("vol2").create("filt1", "Filter");
    model.result("pg1").run();

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

    model.result("pg1").feature("vol2").feature("filt1").set("expr", "x>0.02");

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

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

//    Compare with the temperature plot shown above.
//    Click the Go to Default View button in the Graphics toolbar.
//    Click the Zoom Extents button in the Graphics toolbar.
//    Now update the model to evaluate the effect of the thermal contact between the chip and the heat sink. First assume a poor thermal contact due to a thin film of air between the chip and the heat sink.
//    In the Physics toolbar, click Boundaries and choose Thermal Contact.

    model.component("comp1").physics("ht").create("tc1", "ThermalContact", 2);

//    Select Boundary 15.

    model.component("comp1").physics("ht").feature("tc1").selection().set(15);

//    To facilitate the selection of this boundary in the following steps, create a dedicated selection for it.
//    In the Settings window for Thermal Contact, locate the Boundary Selection section.
//    Click Create Selection.
//    In the Create Selection dialog, type Chip/Heat Sink Interface in the Selection name text field.
//    Click OK.

    model.component("comp1").selection().create("sel2", "Explicit");
    model.component("comp1").selection("sel2").geom(2);
    model.component("comp1").selection("sel2").label("Chip/Heat Sink Interface");
    model.component("comp1").selection("sel2").set(15);

    model.component("comp1").physics("ht").feature("tc1").selection().named("sel2");

//    In the Settings window for Thermal Contact, locate the Thermal Contact section.
//    From the Contact model list, select Equivalent thin resistive layer.

    model.component("comp1").physics("ht").feature("tc1").set("ContactModel", "EquThinLayer");

//    From the Specify list, select Layer thermal conductivity and thickness.

    model.component("comp1").physics("ht").feature("tc1").set("Specify", "LayerConductivityandThickness");

//    In the \[d_\textrm{s}\] text field, type 50[um].

    model.component("comp1").physics("ht").feature("tc1").set("ds", "50[um]");

//    Define the material (air) present at the interface between the chip and the heat sink.
//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Built-in > Air.
//    Right-click and choose Add to Component 1 (comp1).

    model.component("comp1").material().create("mat3", "Common");
    model.component("comp1").material("mat3").propertyGroup("def").func().create("eta", "Piecewise");
    model.component("comp1").material("mat3").propertyGroup("def").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat3").propertyGroup("def").func().create("rho", "Analytic");
    model.component("comp1").material("mat3").propertyGroup("def").func().create("k", "Piecewise");
    model.component("comp1").material("mat3").propertyGroup("def").func().create("cs", "Analytic");
    model.component("comp1").material("mat3").propertyGroup("def").func().create("an1", "Analytic");
    model.component("comp1").material("mat3").propertyGroup("def").func().create("an2", "Analytic");
    model.component("comp1").material("mat3").propertyGroup()
         .create("RefractiveIndex", "RefractiveIndex", "Refractive index");
    model.component("comp1").material("mat3").propertyGroup()
         .create("NonlinearModel", "NonlinearModel", "Nonlinear model");
    model.component("comp1").material("mat3").propertyGroup().create("idealGas", "idealGas", "Ideal gas");
    model.component("comp1").material("mat3").propertyGroup("idealGas").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat3").label("Air");
    model.component("comp1").material("mat3").set("family", "air");
    model.component("comp1").material("mat3").propertyGroup("def").func("eta").set("arg", "T");
    model.component("comp1").material("mat3").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("mat3").propertyGroup("def").func("eta").set("argunit", "K");
    model.component("comp1").material("mat3").propertyGroup("def").func("eta").set("fununit", "Pa*s");
    model.component("comp1").material("mat3").propertyGroup("def").func("Cp").set("arg", "T");
    model.component("comp1").material("mat3").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("mat3").propertyGroup("def").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat3").propertyGroup("def").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat3").propertyGroup("def").func("rho")
         .set("expr", "pA*0.02897/R_const[K*mol/J]/T");
    model.component("comp1").material("mat3").propertyGroup("def").func("rho").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat3").propertyGroup("def").func("rho").set("fununit", "kg/m^3");
    model.component("comp1").material("mat3").propertyGroup("def").func("rho")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat3").propertyGroup("def").func("rho")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat3").propertyGroup("def").func("rho")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat3").propertyGroup("def").func("rho")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "293.15"}});
    model.component("comp1").material("mat3").propertyGroup("def").func("k").set("arg", "T");
    model.component("comp1").material("mat3").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("mat3").propertyGroup("def").func("k").set("argunit", "K");
    model.component("comp1").material("mat3").propertyGroup("def").func("k").set("fununit", "W/(m*K)");
    model.component("comp1").material("mat3").propertyGroup("def").func("cs")
         .set("expr", "sqrt(1.4*R_const[K*mol/J]/0.02897*T)");
    model.component("comp1").material("mat3").propertyGroup("def").func("cs").set("args", new String[]{"T"});
    model.component("comp1").material("mat3").propertyGroup("def").func("cs").set("fununit", "m/s");
    model.component("comp1").material("mat3").propertyGroup("def").func("cs").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat3").propertyGroup("def").func("cs")
         .set("plotfixedvalue", new String[]{"273.15"});
    model.component("comp1").material("mat3").propertyGroup("def").func("cs")
         .set("plotargs", new String[][]{{"T", "273.15", "373.15"}});
    model.component("comp1").material("mat3").propertyGroup("def").func("an1").set("funcname", "alpha_p");
    model.component("comp1").material("mat3").propertyGroup("def").func("an1")
         .set("expr", "-1/rho(pA,T)*d(rho(pA,T),T)");
    model.component("comp1").material("mat3").propertyGroup("def").func("an1").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat3").propertyGroup("def").func("an1").set("fununit", "1/K");
    model.component("comp1").material("mat3").propertyGroup("def").func("an1")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat3").propertyGroup("def").func("an1")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat3").propertyGroup("def").func("an1")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat3").propertyGroup("def").func("an1")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "373.15"}});
    model.component("comp1").material("mat3").propertyGroup("def").func("an2").set("funcname", "muB");
    model.component("comp1").material("mat3").propertyGroup("def").func("an2").set("expr", "0.6*eta(T)");
    model.component("comp1").material("mat3").propertyGroup("def").func("an2").set("args", new String[]{"T"});
    model.component("comp1").material("mat3").propertyGroup("def").func("an2").set("fununit", "Pa*s");
    model.component("comp1").material("mat3").propertyGroup("def").func("an2").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat3").propertyGroup("def").func("an2")
         .set("plotfixedvalue", new String[]{"200"});
    model.component("comp1").material("mat3").propertyGroup("def").func("an2")
         .set("plotargs", new String[][]{{"T", "200", "1600"}});
    model.component("comp1").material("mat3").propertyGroup("def").set("thermalexpansioncoefficient", "");
    model.component("comp1").material("mat3").propertyGroup("def").set("molarmass", "");
    model.component("comp1").material("mat3").propertyGroup("def").set("bulkviscosity", "");
    model.component("comp1").material("mat3").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("mat3").propertyGroup("def").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat3").propertyGroup("def").set("bulkviscosity", "muB(T)");
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("def").set("dynamicviscosity", "eta(T)");
    model.component("comp1").material("mat3").propertyGroup("def").set("ratioofspecificheat", "1.4");
    model.component("comp1").material("mat3").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("mat3").propertyGroup("def").set("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat3").propertyGroup("def").set("density", "rho(pA,T)");
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("thermalconductivity", new String[]{"k(T)", "0", "0", "0", "k(T)", "0", "0", "0", "k(T)"});
    model.component("comp1").material("mat3").propertyGroup("def").set("soundspeed", "cs(T)");
    model.component("comp1").material("mat3").propertyGroup("def").addInput("temperature");
    model.component("comp1").material("mat3").propertyGroup("def").addInput("pressure");
    model.component("comp1").material("mat3").propertyGroup("RefractiveIndex")
         .set("n", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("NonlinearModel").set("BA", "def.gamma-1");
    model.component("comp1").material("mat3").propertyGroup("idealGas").func("Cp").label("Piecewise 2");
    model.component("comp1").material("mat3").propertyGroup("idealGas").func("Cp").set("arg", "T");
    model.component("comp1").material("mat3").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("mat3").propertyGroup("idealGas").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat3").propertyGroup("idealGas").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat3").propertyGroup("idealGas").set("Rs", "R_const/Mn");
    model.component("comp1").material("mat3").propertyGroup("idealGas").set("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat3").propertyGroup("idealGas").set("ratioofspecificheat", "1.4");
    model.component("comp1").material("mat3").propertyGroup("idealGas").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat3").propertyGroup("idealGas").addInput("temperature");
    model.component("comp1").material("mat3").propertyGroup("idealGas").addInput("pressure");
    model.component("comp1").material("mat3").materialType("nonSolid");

//    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("mat3").selection().geom("geom1", 2);

//    From the Selection list, select Chip/Heat Sink Interface.

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

//    In the Home toolbar, click Compute.

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

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

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

//    The temperature plot is updated after the computation. Note that the presence of the thin layer of air between the chip and the heat sink induced approximately 10°C increase of the maximum temperature.
//    Now assume that thermal grease is used to avoid an air layer at the interface between the chip and the heat sink. Update the model in order to check how the cooling is improved by this change.
//    In the Home toolbar, click Add Material to open the Add Material window.
//    In the tree, select Built-in > Thermal grease.
//    Right-click and choose Add to Component 1 (comp1).

    model.component("comp1").material().create("mat4", "Common");
    model.component("comp1").material("mat4").label("Thermal grease");
    model.component("comp1").material("mat4").set("family", "concrete");
    model.component("comp1").material("mat4").propertyGroup("def").set("density", "2600[kg/m^3]");
    model.component("comp1").material("mat4").propertyGroup("def").set("heatcapacity", "1200[J/(kg*K)]");

    return model;
  }

  public static Model run2(Model model) {
    model.component("comp1").material("mat4").propertyGroup("def")
         .set("thermalconductivity", new String[]{"3[W/(m*K)]", "0", "0", "0", "3[W/(m*K)]", "0", "0", "0", "3[W/(m*K)]"});

//    In the Home 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 Chip/Heat Sink Interface.

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

//    The red triangle in the <l>Air</l> material icon indicates that it is overridden by the <l>Thermal grease</l> material.
//    In the Home toolbar, click Compute.

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

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

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

//    The temperature plot is updated and shows the temperature distribution when thermal grease is used.
//    At this point we can evaluate the effect of the quality of the thermal contact. In the first computation, the thermal contact was assumed to be ideal and the maximum temperature was around 86°C. When accounting for a 50-µm-wide air layer the maximum temperature was close to 96°C. Using thermal grease to enhance the thermal contact seems efficient here as the maximum temperature is only slightly higher than the initial case of ideal thermal contact.
//    In the first part, we have been using a convective cooling boundary condition to account for the airflow cooling. While there are a number of geometrical configurations for which the heat transfer coefficient is known with very good accuracy, that is not the case for this particular heat sink geometry.
//    Modify the model to include the air channel in the geometry and to compute the air velocity. Then, you can accurately model the flow cooling without relying on any approximation of the heat transfer coefficient.
//    In the Geometry toolbar, click Block.

    model.component("comp1").geom("geom1").run("pi1");
    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 W_channel.

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

//    In the Depth text field, type D_channel.

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

//    In the Height text field, type H_channel.

    model.component("comp1").geom("geom1").feature("blk2").setIndex("size", "H_channel", 2);

//    Locate the Position section.
//    In the x text field, type -(W_channel-40[mm])/2.

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

//    In the y text field, type -80[mm].

    model.component("comp1").geom("geom1").feature("blk2").setIndex("pos", "-80[mm]", 1);

//    In the Geometry toolbar, click Build All.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    Define the material properties in the newly created channel domain.
//    In the Model Builder window, right-click Component 1 (comp1) > Materials > Air (mat3) and choose Duplicate.

    model.component("comp1").material().duplicate("mat5", "mat3");

//    This creates a new instance of the Air material that will be applied to the domain selection corresponding to the channel.
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Domain.

    model.component("comp1").material("mat5").selection().geom("geom1", 3);

//    Select Domain 1.

    model.component("comp1").material("mat5").selection().set(1);

//    Click Create Selection.
//    In the Create Selection dialog, type Air in the Selection name text field.
//    Click OK.

    model.component("comp1").selection().create("sel3", "Explicit");
    model.component("comp1").selection("sel3").geom(3);
    model.component("comp1").selection("sel3").label("Air");
    model.component("comp1").selection("sel3").set(1);

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

//    In the Home toolbar, click Add Physics to open the Add Physics window.
//    In the tree, select Fluid Flow > Single-Phase Flow > Laminar Flow (spf).
//    Click Add to Component 1 in the window toolbar.

    model.component("comp1").physics().create("spf", "LaminarFlow", "geom1");

//    In the Home toolbar, click Add Physics to close the Add Physics window.
//    Specify that the flow interface is active only in the air channel.
//    In the Settings window for Laminar Flow, locate the Domain Selection section.
//    From the Selection list, select Air.

    model.component("comp1").physics("spf").selection().named("sel3");

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

    model.component("comp1").physics("spf").create("inl1", "InletBoundary", 2);

//    Select Boundary 2.

    model.component("comp1").physics("spf").feature("inl1").selection().set(2);

//    In the Settings window for Inlet, locate the Boundary Selection section.
//    Click Create Selection.
//    In the Create Selection dialog, type Inlet in the Selection name text field.
//    Click OK.

    model.component("comp1").selection().create("sel4", "Explicit");
    model.component("comp1").selection("sel4").geom(2);
    model.component("comp1").selection("sel4").label("Inlet");
    model.component("comp1").selection("sel4").set(2);

    model.component("comp1").physics("spf").feature("inl1").selection().named("sel4");

//    In the Settings window for Inlet, locate the Boundary Condition section.
//    From the list, select Fully developed flow.

    model.component("comp1").physics("spf").feature("inl1").set("BoundaryCondition", "FullyDevelopedFlow");

//    Locate the Fully Developed Flow section.
//    In the \[U_{\textrm{av}}\] text field, type U0.

    model.component("comp1").physics("spf").feature("inl1").set("Uavfdf", "U0");

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

    model.component("comp1").physics("spf").create("out1", "OutletBoundary", 2);

//    Select Boundary 5.

    model.component("comp1").physics("spf").feature("out1").selection().set(5);

//    In the Settings window for Outlet, locate the Boundary Selection section.
//    Click Create Selection.
//    In the Create Selection dialog, type Outlet in the Selection name text field.
//    Click OK.

    model.component("comp1").selection().create("sel5", "Explicit");
    model.component("comp1").selection("sel5").geom(2);
    model.component("comp1").selection("sel5").label("Outlet");
    model.component("comp1").selection("sel5").set(5);

    model.component("comp1").physics("spf").feature("out1").selection().named("sel5");

//    The boundaries where the heat flux condition was applied are no longer exterior boundaries, so the heat flux condition cannot be applied. Instead, a continuity condition is applied by default between the solid and the fluid domains.
//    In the Model Builder window, click Fluid 1.
//    In the Settings window for Fluid, locate the Domain Selection section.
//    From the Selection list, select Air.

    model.component("comp1").physics("ht").feature("fluid1").selection().named("sel3");

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

    model.component("comp1").physics("ht").create("ifl1", "Inflow", 2);

//    In the Settings window for Inflow, locate the Boundary Selection section.
//    From the Selection list, select Inlet.

    model.component("comp1").physics("ht").feature("ifl1").selection().named("sel4");

//    Locate the Upstream Properties section.
//    From the \[T_\textrm{ustr}\] list, select Ambient temperature (ampr1).

    model.component("comp1").physics("ht").feature("ifl1").set("Tustr_src", "root.comp1.ampr1.T_amb");

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

    model.component("comp1").physics("ht").create("ofl1", "ConvectiveOutflow", 2);

//    In the Settings window for Outflow, locate the Boundary Selection section.
//    From the Selection list, select Outlet.

    model.component("comp1").physics("ht").feature("ofl1").selection().named("sel5");

//    Now add the <l>Nonisothermal Flow</l> multiphysics feature to couple the <l>Heat Transfer in Solids and Fluids</l> and <l>Laminar Flow</l> interfaces. By doing this, you ensure in particular that the velocity field computed by the <l>Laminar Flow</l> interface is used by the <l>Fluid 1</l> feature in the <l>Heat Transfer in Solids and Fluids</l> interface. In addition, the temperature dependence of the material properties in the flow interface is then defined from the temperature field computed by the <l>Heat Transfer in Solids and Fluids</l> interface.
//    In the Home toolbar, click Add Multiphysics to open the Add Multiphysics window.
//    In the tree, select Heat Transfer > Conjugate Heat Transfer > Laminar Flow.
//    Click Add to Component in the window toolbar.

    model.component("comp1").multiphysics().create("nitf1", "NonIsothermalFlow", 3);

    model.study("std1").feature("stat").setSolveFor("/multiphysics/nitf1", true);

    model.component("comp1").multiphysics("nitf1").set("Fluid_physics", "spf");
    model.component("comp1").multiphysics("nitf1").set("Heat_physics", "ht");

    model.component("comp1").physics("ht").prop("ShapeProperty").set("order_temperature", "1");
    model.component("comp1").physics("spf").prop("AdvancedSettingProperty").set("UsePseudoTime", "1");
    model.component("comp1").physics("spf").prop("PhysicalModelProperty")
         .set("Compressibility", "WeaklyCompressible");

//    In the Home toolbar, click Add Multiphysics to close the Add Multiphysics window.
//    As this tutorial is intended to explore the heat transfer modeling capabilities, define a coarse mesh to speed up the computation. Note however that for accurate results, a finer mesh is needed.
//    In the Settings window for Mesh, locate the Physics-Controlled Mesh section.
//    From the Element size list, select Extremely coarse.

    model.component("comp1").mesh("mesh1").autoMeshSize(9);

//    In the table, enter the following settings:

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

//    In the Home toolbar, click Compute.

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

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

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

//    The computation for this model takes a couple of minutes and about 2 GB of memory. The longer computational time is due to the extra degrees on freedom corresponding to the velocity, pressure, and temperature in the air domain.
//    Add a plot from the <l>Result Templates</l> showing temperature and velocity field and hide some walls from the display to make visible the temperature on the heat sink and on the channel walls and the flow structure.
//    In the Results toolbar, click Result Templates to open the Result Templates window.
//    In the tree, select Study 1/Solution 1 (sol1) > Nonisothermal Flow 1 > Temperature and Fluid Flow (nitf1).
//    Click Add Result Template in the window toolbar.

    model.result().create("pg2", "PlotGroup3D");
    model.result("pg2").label("Temperature and Fluid Flow (nitf1)");
    model.result("pg2").set("showlegendsunit", true);
    model.result("pg2").set("smooth", "internal");
    model.result("pg2").feature().create("surf1", "Surface");
    model.result("pg2").feature("surf1").label("Wall Temperature");
    model.result("pg2").feature("surf1").set("solutionparams", "parent");
    model.result("pg2").feature("surf1").set("expr", "ht.Tvar");
    model.result("pg2").feature("surf1").set("colortable", "HeatCameraLight");
    model.result("pg2").feature("surf1").set("smooth", "internal");
    model.result("pg2").feature("surf1").set("data", "parent");
    model.result("pg2").feature("surf1").feature().create("sel1", "Selection");
    model.result("pg2").feature("surf1").feature("sel1").selection().geom("geom1", 2);
    model.result("pg2").feature("surf1").feature("sel1").selection()
         .set(1, 3, 4, 6, 7, 9, 11, 12, 13, 14, 15, 16, 22, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 37, 39, 40, 41, 42, 43, 44);
    model.result("pg2").feature().create("vol1", "Volume");
    model.result("pg2").feature("vol1").label("Solid Temperature");
    model.result("pg2").feature("vol1").set("solutionparams", "parent");
    model.result("pg2").feature("vol1").set("expr", "nitf1.T");
    model.result("pg2").feature("vol1").set("smooth", "internal");
    model.result("pg2").feature("vol1").set("data", "parent");
    model.result("pg2").feature("vol1").feature().create("sel1", "Selection");
    model.result("pg2").feature("vol1").feature("sel1").selection().geom("geom1", 3);
    model.result("pg2").feature("vol1").feature("sel1").selection().set(2, 3, 4, 5, 6, 7);
    model.result("pg2").feature("vol1").set("inheritplot", "surf1");
    model.result("pg2").feature().create("arwv1", "ArrowVolume");
    model.result("pg2").feature("arwv1").label("Fluid Flow");
    model.result("pg2").feature("arwv1").set("solutionparams", "parent");
    model.result("pg2").feature("arwv1").set("expr", new String[]{"nitf1.ux", "nitf1.uy", "nitf1.uz"});
    model.result("pg2").feature("arwv1").set("xnumber", 30);
    model.result("pg2").feature("arwv1").set("ynumber", 30);
    model.result("pg2").feature("arwv1").set("znumber", 30);
    model.result("pg2").feature("arwv1").set("arrowtype", "cone");
    model.result("pg2").feature("arwv1").set("arrowlength", "logarithmic");
    model.result("pg2").feature("arwv1").set("data", "parent");
    model.result("pg2").feature("arwv1").feature().create("col1", "Color");
    model.result("pg2").feature("arwv1").feature("col1").set("expr", "spf.U");
    model.result("pg2").feature("arwv1").feature().create("filt1", "Filter");
    model.result("pg2").feature("arwv1").feature("filt1").set("expr", "spf.U>nitf1.Uave");
    model.result("pg2").label("Temperature and Fluid Flow (nitf1)");
    model.result("pg2").run();

//    In the Results toolbar, click Result Templates to close the Result Templates window.
//    Click the Click and Hide button in the Graphics toolbar.
//    On the object fin, select Boundaries 1, 2, 4, 5.

    model.component("comp1").view("view1").hideObjects().create("hide1");
    model.component("comp1").view("view1").hideObjects("hide1").init(2);
    model.component("comp1").view("view1").hideObjects("hide1").add("fin", 1, 2, 4, 5);

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

//    In the Model Builder window, expand the Results > Temperature and Fluid Flow (nitf1) node.

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

//    In the Model Builder window, expand the Results > Temperature and Fluid Flow (nitf1) > Fluid Flow node, then click Filter 1.
//    In the Settings window for Filter, locate the Element Selection section.
//    In the Logical expression for inclusion text field, type spf.U>1.2*nitf1.Uave.

    model.result("pg2").feature("arwv1").feature("filt1").set("expr", "spf.U>1.2*nitf1.Uave");

//    In the Temperature and Fluid Flow (nitf1) toolbar, click Plot.

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

//    Duplicate this plot and keep only temperature subnodes to see better the temperature distribution.

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

//    In the Model Builder window, right-click Temperature and Fluid Flow (nitf1) and choose Duplicate.

    model.result().duplicate("pg3", "pg2");
    model.result("pg3").run();

//    In the Settings window for 3D Plot Group, type Temperature of the channel walls and heat sink in the Label text field.

    model.result("pg3").label("Temperature of the channel walls and heat sink");

//    Locate the Color Legend section.
//    Clear the Show units checkbox.

    model.result("pg3").set("showlegendsunit", false);
    model.result("pg3").run();

//    In the Model Builder window, expand the Temperature of the channel walls and heat sink node.
//    Right-click Fluid Flow and choose Delete.

    model.result("pg3").feature().remove("arwv1");
    model.result("pg3").run();
    model.result("pg3").run();

//    In the Model Builder window, under Results, click Temperature of the channel walls and heat sink.
//    In the Temperature of the channel walls and heat sink toolbar, click Plot.

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

//    Now modify the model to include surface-to-surface radiation effects. First, add the <l>Surface-to-Surface Radiation</l> interface to the model. Then, study the effects of surface-to-surface radiation between the heat sink and the channel walls.
//    In the Home toolbar, click Add Physics to open the Add Physics window.
//    In the tree, select Heat Transfer > Radiation > Surface-to-Surface Radiation (rad).
//    Click Add to Component 1 in the window toolbar.

    model.component("comp1").physics().create("rad", "SurfaceToSurfaceRadiation", "geom1");

//    In the Home toolbar, click Add Physics to close the Add Physics window.
//    In the Settings window for Surface-to-Surface Radiation, locate the Boundary Selection section.
//    From the Selection list, select Exterior boundaries without heat sink base (Heat Sink - Straight Fins 1).

    model.component("comp1").physics("rad").selection().named("geom1_pi1_difsel1");
    model.component("comp1").physics("rad").selection()
         .set(1, 3, 4, 6, 7, 9, 11, 12, 13, 14, 15, 16, 22, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 37, 39, 40, 41, 42, 43, 44);

//    To add the channel walls, click the <l>Paste Selection</l> button and type 1 3 4 44 (note that boundaries 1 and 4 have been hidden previously and are not visible in the graphics window).
//    The interface selection now contains boundaries 1, 3, 4, 6, 7, 9, 11–16, 22, 24–29, 31–35, 37, and 39–44.
//    By default the radiation direction is controlled by the opacity of the domains. The solid parts are automatically defined as opaque while the fluid parts are transparent. You can change this setting using the <l>Opacity</l> feature in the <l>Surface-to-Surface Radiation</l> interface.
//    When the <l>Diffuse Surface</l> boundary condition defines <l>Emitted radiation direction</l> as <l>Opacity controlled</l> (the default setting), the selected boundaries should be located between an opaque and a transparent domain. The exterior is defined as transparent by default. Change the default setting to make the exterior opaque and have the radiation direction automatically defined on the channel walls.
//    In the Physics toolbar, click Domains and choose Opacity.

    model.component("comp1").physics("rad").create("opac1", "Opacity", 3);

//    In the Settings window for Opacity, locate the Domain Selection section.
//    From the Selection list, select All voids.

    model.component("comp1").physics("rad").feature("opac1").selection().allVoids();

//    In the Model Builder window, click Diffuse Surface 1.
//    In the Settings window for Diffuse Surface, in the Graphics window toolbar, click ^ next to View Unhidden, then choose View All.

    model.component("comp1").view("view1").set("hidestatus", "ignore");

//    In the Physics toolbar, click Add Multiphysics to open the Add Multiphysics window.
//    In the tree, select No Predefined Multiphysics Available for the Selected Physics Interfaces.
//    Find the Select the physics interfaces you want to couple subsection.
//    In the table, enter the following settings:
//    In the tree, select Heat Transfer > Radiation > Heat Transfer with Surface-to-Surface Radiation.
//    Click Add to Component in the window toolbar.

    model.component("comp1").multiphysics().create("htrad1", "HeatTransferWithSurfaceToSurfaceRadiation", 2);

    model.study("std1").feature("stat").setSolveFor("/multiphysics/htrad1", true);

    model.component("comp1").multiphysics("htrad1").selection().all();
    model.component("comp1").multiphysics("htrad1").set("Heat_physics", "ht");
    model.component("comp1").multiphysics("htrad1").set("Rad_physics", "rad");

//    In the Physics toolbar, click Add Multiphysics to close the Add Multiphysics window.
//    In the Settings window for Heat Transfer with Surface-to-Surface Radiation, in the Graphics window toolbar, click ^ next to View Unhidden, then choose View Unhidden.

    model.component("comp1").view("view1").set("hidestatus", "hide");

//    In the Materials toolbar, click Blank Material.

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

//    In the Settings window for Material, type Heat sink walls in the Label text field.

    model.component("comp1").material("mat6").label("Heat sink walls");

//    Locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    From the Selection list, select Exterior boundaries without heat sink base (Heat Sink - Straight Fins 1).

    model.component("comp1").material("mat6").selection().named("geom1_pi1_difsel1");

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

    model.component("comp1").material("mat6").propertyGroup("def").set("emissivity", new String[]{"0.9"});

//    In the Materials toolbar, click Blank Material.

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

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

    model.component("comp1").material("mat7").label("Channel walls");

//    Locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    In the Graphics window toolbar, click ^ next to View Unhidden, then choose View All.

    model.component("comp1").view("view1").set("hidestatus", "ignore");

//    Select Boundaries 1, 3, 4, 44.

    model.component("comp1").material("mat7").selection().set(1, 3, 4, 44);

//    In the Graphics window toolbar, click ^ next to View Unhidden, then choose View Unhidden.

    model.component("comp1").view("view1").set("hidestatus", "hide");

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

    model.component("comp1").material("mat7").propertyGroup("def").set("emissivity", new String[]{"0.85"});

//    In order to keep the previous solution and to be able to compare it with this version of the model, add a second stationary study. And just before, edit the first study to exclude surface-to-surface to make sure the same solution will be computed in case it is solved again.
//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, type Study 1 Without Radiation in the Label text field.

    model.study("std1").label("Study 1 Without Radiation");
    model.study("std1").feature("stat").setSolveFor("/physics/rad", false);

//    In the Model Builder window, under Study 1 Without Radiation, click Step 1: Stationary.
//    In the Settings window for Stationary, locate the Physics and Variables Selection section.

    model.study("std1").feature("stat").setSolveFor("/multiphysics/htrad1", false);

//    In the Solve for column of the table, under Component 1 (comp1), clear the checkbox for Surface-to-Surface Radiation (rad).
//    In the Solve for column of the table, under Component 1 (comp1) > Multiphysics, clear the checkbox for Heat Transfer with Surface-to-Surface Radiation 1 (htrad1).
//    In the Study toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Stationary.
//    Right-click and choose Add Study.

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

//    In the Study toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, type Study 2 With Radiation in the Label text field.

    model.study("std2").label("Study 2 With Radiation");

//    In the Study toolbar, click Compute.

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

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

    model.result().create("pg4", "PlotGroup3D");
    model.result("pg4").label("Temperature (ht) 1");
    model.result("pg4").set("data", "dset2");
    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("colortable", "HeatCameraLight");
    model.result("pg4").feature("vol1").set("smooth", "internal");
    model.result("pg4").feature("vol1").set("data", "parent");
    model.result().dataset("dset2").set("geom", "geom1");
    model.result().create("pg5", "PlotGroup3D");
    model.result("pg5").label("Velocity (spf)");
    model.result("pg5").set("data", "dset2");
    model.result("pg5").set("frametype", "spatial");
    model.result("pg5").set("smooth", "internal");
    model.result("pg5").feature().create("mslc1", "Multislice");
    model.result("pg5").feature("mslc1").set("expr", "spf.U");
    model.result("pg5").feature("mslc1").set("smooth", "internal");
    model.result("pg5").feature("mslc1").set("data", "parent");
    model.result().create("pg6", "PlotGroup3D");
    model.result("pg6").label("Pressure (spf)");
    model.result("pg6").set("data", "dset2");
    model.result("pg6").set("frametype", "spatial");
    model.result("pg6").set("smooth", "internal");
    model.result("pg6").feature().create("surf1", "Surface");
    model.result("pg6").feature("surf1").label("Surface");
    model.result("pg6").feature("surf1").set("expr", "p");
    model.result("pg6").feature("surf1").set("colortable", "Tectocoris");
    model.result("pg6").feature("surf1").set("colortabletype", "discrete");
    model.result("pg6").feature("surf1").set("bandcount", 25);
    model.result("pg6").feature("surf1").set("smooth", "internal");
    model.result("pg6").feature("surf1").set("data", "parent");
    model.result("pg6").feature("surf1").feature().create("sel1", "Selection");
    model.result("pg6").feature("surf1").feature("sel1").selection().geom("geom1", 2);
    model.result("pg6").feature("surf1").feature("sel1").selection()
         .set(1, 3, 4, 6, 7, 9, 11, 12, 13, 14, 15, 16, 22, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 37, 39, 40, 41, 42, 43, 44);
    model.result().create("pg7", "PlotGroup3D");
    model.result("pg7").label("Surface Radiosity (rad)");
    model.result("pg7").set("data", "dset2");
    model.result("pg7").set("smooth", "internal");
    model.result("pg7").feature().create("slit1", "SurfaceSlit");
    model.result("pg7").feature("slit1").set("upexpr", "rad.Ju");
    model.result("pg7").feature("slit1").set("downexpr", "rad.Jd");
    model.result("pg7").feature("slit1").set("smooth", "internal");
    model.result("pg7").feature("slit1").set("data", "parent");
    model.result().create("pg8", "PlotGroup3D");
    model.result("pg8").label("Temperature and Fluid Flow (nitf1) 1");
    model.result("pg8").set("data", "dset2");
    model.result("pg8").set("showlegendsunit", true);
    model.result("pg8").set("smooth", "internal");
    model.result("pg8").feature().create("surf1", "Surface");
    model.result("pg8").feature("surf1").label("Wall Temperature");
    model.result("pg8").feature("surf1").set("solutionparams", "parent");
    model.result("pg8").feature("surf1").set("expr", "ht.Tvar");
    model.result("pg8").feature("surf1").set("colortable", "HeatCameraLight");
    model.result("pg8").feature("surf1").set("smooth", "internal");
    model.result("pg8").feature("surf1").set("data", "parent");
    model.result("pg8").feature("surf1").feature().create("sel1", "Selection");
    model.result("pg8").feature("surf1").feature("sel1").selection().geom("geom1", 2);
    model.result("pg8").feature("surf1").feature("sel1").selection()
         .set(1, 3, 4, 6, 7, 9, 11, 12, 13, 14, 15, 16, 22, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 37, 39, 40, 41, 42, 43, 44);
    model.result("pg8").feature().create("vol1", "Volume");
    model.result("pg8").feature("vol1").label("Solid Temperature");
    model.result("pg8").feature("vol1").set("solutionparams", "parent");
    model.result("pg8").feature("vol1").set("expr", "nitf1.T");
    model.result("pg8").feature("vol1").set("smooth", "internal");
    model.result("pg8").feature("vol1").set("data", "parent");
    model.result("pg8").feature("vol1").feature().create("sel1", "Selection");
    model.result("pg8").feature("vol1").feature("sel1").selection().geom("geom1", 3);
    model.result("pg8").feature("vol1").feature("sel1").selection().set(2, 3, 4, 5, 6, 7);
    model.result("pg8").feature("vol1").set("inheritplot", "surf1");
    model.result("pg8").feature().create("arwv1", "ArrowVolume");
    model.result("pg8").feature("arwv1").label("Fluid Flow");
    model.result("pg8").feature("arwv1").set("solutionparams", "parent");
    model.result("pg8").feature("arwv1").set("expr", new String[]{"nitf1.ux", "nitf1.uy", "nitf1.uz"});
    model.result("pg8").feature("arwv1").set("xnumber", 30);
    model.result("pg8").feature("arwv1").set("ynumber", 30);
    model.result("pg8").feature("arwv1").set("znumber", 30);
    model.result("pg8").feature("arwv1").set("arrowtype", "cone");
    model.result("pg8").feature("arwv1").set("arrowlength", "logarithmic");
    model.result("pg8").feature("arwv1").set("data", "parent");
    model.result("pg8").feature("arwv1").feature().create("col1", "Color");
    model.result("pg8").feature("arwv1").feature("col1").set("expr", "spf.U");
    model.result("pg8").feature("arwv1").feature().create("filt1", "Filter");
    model.result("pg8").feature("arwv1").feature("filt1").set("expr", "spf.U>nitf1.Uave");
    model.result("pg4").run();
    model.result("pg4").run();

//    In the Model Builder window, expand the Temperature (ht) 1 node.
//    Right-click Volume 1 and choose Transparency.

    model.result("pg4").feature("vol1").create("tran1", "Transparency");
    model.result("pg4").run();
    model.result("pg8").run();

//    In the Model Builder window, expand the Results > Temperature and Fluid Flow (nitf1) 1 node.

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

//    In the Model Builder window, expand the Results > Temperature and Fluid Flow (nitf1) 1 > Fluid Flow node, then click Filter 1.
//    In the Settings window for Filter, locate the Element Selection section.
//    In the Logical expression for inclusion text field, type spf.U>1.2*nitf1.Uave.

    model.result("pg8").feature("arwv1").feature("filt1").set("expr", "spf.U>1.2*nitf1.Uave");

//    In the Temperature and Fluid Flow (nitf1) 1 toolbar, click Plot.

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

//    In the Model Builder window, right-click Temperature and Fluid Flow (nitf1) 1 and choose Duplicate.

    model.result().duplicate("pg9", "pg8");
    model.result("pg9").run();

//    In the Settings window for 3D Plot Group, type Temperature of the channel walls and heat sink, with radiation in the Label text field.

    model.result("pg9").label("Temperature of the channel walls and heat sink, with radiation");

//    Locate the Color Legend section.
//    Clear the Show units checkbox.

    model.result("pg9").set("showlegendsunit", false);
    model.result("pg9").run();

//    In the Model Builder window, expand the Temperature of the channel walls and heat sink, with radiation node.
//    Right-click Fluid Flow and choose Delete.

    model.result("pg9").feature().remove("arwv1");
    model.result("pg9").run();
    model.result("pg9").run();

//    In the Model Builder window, under Results, click Temperature of the channel walls and heat sink, with radiation.
//    In the Temperature of the channel walls and heat sink, with radiation toolbar, click Plot.

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

    return model;
  }

  public static Model run3(Model model) {

//    By comparing this plot with the previous temperature plot we observe that the heat transfer by radiation induces a significant cooling and that the maximum temperature is about 10°C lower when thermal radiation is accounted for.
//    In order to visualize the temperature on each side of the thermal contact, follow the next steps.
//    In the Results toolbar, click Result Templates to open the Result Templates window.
//    In the tree, select Study 2 With Radiation/Solution 2 (sol2) > Heat Transfer in Solids and Fluids > Contact Temperature (ht).
//    Click Add Result Template in the window toolbar.

    model.result().create("pg10", "PlotGroup3D");
    model.result("pg10").label("Contact Temperature (ht)");
    model.result("pg10").set("data", "dset2");
    model.result("pg10").set("smooth", "internal");
    model.result("pg10").feature().create("slit1", "SurfaceSlit");
    model.result("pg10").feature("slit1").set("solutionparams", "parent");
    model.result("pg10").feature("slit1").set("updescractive", true);
    model.result("pg10").feature("slit1").set("upexpr", "ht.Tu");
    model.result("pg10").feature("slit1").set("updescr", "Upside temperature");
    model.result("pg10").feature("slit1").set("downdescractive", true);
    model.result("pg10").feature("slit1").set("downexpr", "ht.Td");
    model.result("pg10").feature("slit1").set("downdescr", "Downside temperature");
    model.result("pg10").feature("slit1").set("colortable", "HeatCameraLight");
    model.result("pg10").feature("slit1").set("smooth", "internal");
    model.result("pg10").feature("slit1").set("data", "parent");
    model.result("pg10").feature("slit1").feature().create("sel1", "Selection");
    model.result("pg10").feature("slit1").feature("sel1").selection().geom("geom1", 2);
    model.result("pg10").feature("slit1").feature("sel1").selection().set(20);
    model.result("pg10").label("Contact Temperature (ht)");
    model.result("pg10").run();

//    In the Results toolbar, click Result Templates to close the Result Templates window.

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

//    In the Model Builder window, expand the Results > Contact Temperature (ht) node, then click Surface Slit 1.
//    In the Contact Temperature (ht) toolbar, click Plot.

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

    model.title("Electronic Chip Cooling");

    model
         .description("This tutorial model uses a heat sink geometry from the Part Library. The tutorial shows different approaches to heat transfer modeling when studying the cooling of an electronic chip.\n\nIn the first part, only the solid parts are modeled, while the convective airflow is modeled using Convective Heat Flux boundary conditions.\n\nIn the second part, the model is extended to include a fluid domain for the flow channel to compute the coupled temperature and velocity of the fluid, assuming nonisothermal behavior.\n\nIn the last part, surface-to-surface radiation is considered to see how significantly it contributes to the results.");

    return model;
  }

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

}
