/*
 * thermal_bridge_3d_two_floors.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 15 2026, 08:45 by COMSOL 6.4.0.421. */
public class thermal_bridge_3d_two_floors {

  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 (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", "HeatTransfer", "geom1");

    model.study().create("std1");
    model.study("std1").create("stat", "Stationary");

//    Define the geometrical parameters.
//    In the Model Builder window, under Global Definitions, click Parameters 1.
//    In the Settings window for Parameters, locate the Parameters section.
//    In the table, enter the following settings:

    model.param().set("wall_t1", "5[cm]");
    model.param().descr("wall_t1", "Insulation layer thickness");
    model.param().set("wall_t2", "30[cm]");
    model.param().descr("wall_t2", "Wall thickness");
    model.param().set("rect1", "1.2[m]");
    model.param().descr("rect1", "Wall first rectangle basis");
    model.param().set("rect2", "1.3[m]");
    model.param().descr("rect2", "Wall second rectangle basis");
    model.param().set("rect_shift", "-10[cm]");
    model.param().descr("rect_shift", "Shift for the rectangles");
    model.param().set("wall_h", "2.15[m]");
    model.param().descr("wall_h", "Wall height");
    model.param().set("blk_w", "1.15[m]");
    model.param().descr("blk_w", "Rectangle horizontal block width");
    model.param().set("blk_d", "1.9[m]");
    model.param().descr("blk_d", "Rectangle horizontal block depth");
    model.param().set("blk_h", "0.15[m]");
    model.param().descr("blk_h", "Rectangle horizontal block height");
    model.param().set("blk_shiftx", "5[cm]");
    model.param().descr("blk_shiftx", "Rectangle horizontal block x-shift");
    model.param().set("blk_shifty", "-0.7[m]");
    model.param().descr("blk_shifty", "Rectangle horizontal block y-shift");
    model.param().set("blk_shiftz", "1[m]");
    model.param().descr("blk_shiftz", "Rectangle horizontal block z-shift");
    model.param().set("sq_l", "1[m]");
    model.param().descr("sq_l", "Square horizontal block side length");
    model.param().set("sq_h", "5[cm]");
    model.param().descr("sq_h", "Square horizontal block height");
    model.param().set("sq_shift", "0.2[m]");
    model.param().descr("sq_shift", "Square horizontal block shift");

//    In the Home toolbar, click Parameters and choose Add > Parameters.

    model.param().create("par2");

//    In the Settings window for Parameters, type Parameters - Physics in the Label text field.

    model.param("par2").label("Parameters - Physics");

//    Locate the Parameters section.
//    Click Load from File.
//    Browse to the model's Application Library folder and double-click the file thermal_bridge_3d_two_floors_parameters.txt.
//    To import content from file, use:
//    model.param("par2").loadFile("FILENAME");
    model.param("par2").set("T_gamma", "0[degC]", "Gamma temperature");
    model.param("par2").set("T_beta", "15[degC]", "Beta temperature");
    model.param("par2").set("T_alpha", "20[degC]", "Alpha temperature");
    model.param("par2").set("R_gamma", "0.05[m^2*K/W]", "Gamma R-value");
    model.param("par2").set("R_beta", "0.2[m^2*K/W]", "Beta R-value");
    model.param("par2").set("R_alpha", "0.2[m^2*K/W]", "Alpha R-value");
    model.param("par2").set("h_gamma", "1/R_gamma", "Gamma heat transfer coefficient");
    model.param("par2").set("h_beta", "1/R_beta", "Beta heat transfer coefficient");
    model.param("par2").set("h_alpha", "1/R_alpha", "Alpha heat transfer coefficient");

//    To build the walls separating the external and internal surfaces, create the cross section geometry and extrude it.
//    In the Geometry toolbar, click Work Plane.

    model.component("comp1").geom("geom1").create("wp1", "WorkPlane");
    model.component("comp1").geom("geom1").feature("wp1").set("unite", true);

//    In the Settings window for Work Plane, click Go to Plane Geometry.
//    In the Model Builder window, click Plane Geometry.
//    The first two rectangles below correspond to the insulation layer of the wall.
//    In the Work Plane toolbar, click Rectangle.

    model.component("comp1").geom("geom1").feature("wp1").geom().create("r1", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type rect1.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r1")
         .set("size", new String[]{"rect1", "1"});

//    In the Height text field, type wall_t1.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r1")
         .set("size", new String[]{"rect1", "wall_t1"});

//    Click Build Selected.

    model.component("comp1").geom("geom1").feature("wp1").geom().run("r1");

//    In the Work Plane toolbar, click Rectangle.

    model.component("comp1").geom("geom1").feature("wp1").geom().create("r2", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type wall_t1.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r2")
         .set("size", new String[]{"wall_t1", "1"});

//    In the Height text field, type rect1.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r2")
         .set("size", new String[]{"wall_t1", "rect1"});

//    Click Build Selected.

    model.component("comp1").geom("geom1").feature("wp1").geom().run("r2");

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Work Plane toolbar, click Booleans and Partitions and choose Union.

    model.component("comp1").geom("geom1").feature("wp1").geom().create("uni1", "Union");

//    Click in the Graphics window and then press Ctrl+A to select both objects.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("uni1").selection("input").set("r1", "r2");

//    In the Settings window for Union, locate the Union section.
//    Clear the Keep interior boundaries checkbox.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("uni1").set("intbnd", false);

//    Click Build Selected.

    model.component("comp1").geom("geom1").feature("wp1").geom().run("uni1");

//    Build the remaining layers of the walls in a similar manner.
//    In the Work Plane toolbar, click Rectangle.

    model.component("comp1").geom("geom1").feature("wp1").geom().create("r3", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type rect2.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r3")
         .set("size", new String[]{"rect2", "1"});

//    In the Height text field, type wall_t2.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r3")
         .set("size", new String[]{"rect2", "wall_t2"});

//    Locate the Position section.
//    In the xw text field, type rect_shift.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r3")
         .set("pos", new String[]{"rect_shift", "0"});

//    In the yw text field, type rect_shift.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r3")
         .set("pos", new String[]{"rect_shift", "rect_shift"});

//    Click Build Selected.

    model.component("comp1").geom("geom1").feature("wp1").geom().run("r3");

//    In the Work Plane toolbar, click Rectangle.

    model.component("comp1").geom("geom1").feature("wp1").geom().create("r4", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type wall_t2.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r4")
         .set("size", new String[]{"wall_t2", "1"});

//    In the Height text field, type rect2.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r4")
         .set("size", new String[]{"wall_t2", "rect2"});

//    Locate the Position section.
//    In the xw text field, type rect_shift.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r4")
         .set("pos", new String[]{"rect_shift", "0"});

//    In the yw text field, type rect_shift.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r4")
         .set("pos", new String[]{"rect_shift", "rect_shift"});

//    Click Build Selected.

    model.component("comp1").geom("geom1").feature("wp1").geom().run("r4");

//    In the Work Plane toolbar, click Booleans and Partitions and choose Union.

    model.component("comp1").geom("geom1").feature("wp1").geom().create("uni2", "Union");

//    Select the objects r3, r4.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("uni2").selection("input").set("r3", "r4");

//    In the Settings window for Union, locate the Union section.
//    Clear the Keep interior boundaries checkbox.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("uni2").set("intbnd", false);

//    Click Build Selected.

    model.component("comp1").geom("geom1").feature("wp1").geom().run("uni2");

//    In the Model Builder window, right-click Geometry 1 and choose Extrude.

    model.component("comp1").geom("geom1").run("wp1");
    model.component("comp1").geom("geom1").feature().create("ext1", "Extrude");

//    In the Settings window for Extrude, locate the Distances section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("ext1").setIndex("distance", "wall_h", 0);

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("ext1");

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Geometry toolbar, click Block.

    model.component("comp1").geom("geom1").create("blk1", "Block");

//    This block separates the two floors of the structure.
//    In the Settings window for Block, locate the Size and Shape section.
//    In the Width text field, type blk_w.

    model.component("comp1").geom("geom1").feature("blk1").set("size", new String[]{"blk_w", "1", "1"});

//    In the Depth text field, type blk_d.

    model.component("comp1").geom("geom1").feature("blk1").set("size", new String[]{"blk_w", "blk_d", "1"});

//    In the Height text field, type blk_h.

    model.component("comp1").geom("geom1").feature("blk1").set("size", new String[]{"blk_w", "blk_d", "blk_h"});

//    Locate the Position section.
//    In the x text field, type blk_shiftx.

    model.component("comp1").geom("geom1").feature("blk1").set("pos", new String[]{"blk_shiftx", "0", "0"});

//    In the y text field, type blk_shifty.

    model.component("comp1").geom("geom1").feature("blk1").setIndex("pos", "blk_shifty", 1);

//    In the z text field, type blk_shiftz.

    model.component("comp1").geom("geom1").feature("blk1").setIndex("pos", "blk_shiftz", 2);

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("blk1");

//    To avoid unnecessary edges, remove the intersection of the block with the walls. To do so, use the boolean operation <l>Difference</l> to subtract a copy of the block from the walls. Begin by creating the copy.
//    Right-click Block 1 (blk1) and choose Duplicate.

    model.component("comp1").geom("geom1").feature().duplicate("blk2", "blk1");

//    In the Geometry toolbar, click Booleans and Partitions and choose Difference.

    model.component("comp1").geom("geom1").run("blk2");
    model.component("comp1").geom("geom1").create("dif1", "Difference");

//    Select the object ext1.

    model.component("comp1").geom("geom1").feature("dif1").selection("input").set("ext1");

//    The object labeled <c>ext1</c> is made up of the walls previously obtained by extrusion.
//    In the Settings window for Difference, locate the Difference section.
//    Select the Activate Selection toggle button for Objects to subtract.
//    Select the object blk1.

    model.component("comp1").geom("geom1").feature("dif1").selection("input2").set("blk1");

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("dif1");

//    In the Geometry toolbar, click Block.

    model.component("comp1").geom("geom1").create("blk3", "Block");

//    This block corresponds to the floor of the inside upper level.
//    In the Settings window for Block, locate the Size and Shape section.
//    In the Width text field, type sq_l.

    model.component("comp1").geom("geom1").feature("blk3").set("size", new String[]{"sq_l", "1", "1"});

//    In the Depth text field, type sq_l.

    model.component("comp1").geom("geom1").feature("blk3").set("size", new String[]{"sq_l", "sq_l", "1"});

//    In the Height text field, type sq_h.

    model.component("comp1").geom("geom1").feature("blk3").set("size", new String[]{"sq_l", "sq_l", "sq_h"});

//    Locate the Position section.
//    In the x text field, type sq_shift.

    model.component("comp1").geom("geom1").feature("blk3").set("pos", new String[]{"sq_shift", "0", "0"});

//    In the y text field, type sq_shift.

    model.component("comp1").geom("geom1").feature("blk3").set("pos", new String[]{"sq_shift", "sq_shift", "0"});

//    In the z text field, type blk_shiftz+blk_h.

    model.component("comp1").geom("geom1").feature("blk3").setIndex("pos", "blk_shiftz+blk_h", 2);

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("blk3");

//    In the Geometry toolbar, click Virtual Operations and choose Ignore Edges.

    model.component("comp1").geom("geom1").run("fin");
    model.component("comp1").geom("geom1").create("ige1", "IgnoreEdges");

//    In the first steps of the geometry sequence, six unused vertical edges were created on the walls. They are responsible for unnecessary constraints on the mesh and they generate extra boundaries by splitting some faces. For these reasons, follow the instructions below to remove them.
//    On the object fin, select Edges 6, 17, 33, 38, 60, 63.

    model.component("comp1").geom("geom1").feature("ige1").selection("input").set("fin", 6, 17, 33, 38, 60, 63);

//    To reach the edges, click the <l>Wireframe Rendering</l> button in the <l>Graphics</l> toolbar. Note that you can make the selection by clicking the <l>Paste Selection</l> button and typing the indices in the dialog that opens.
//    In the Settings window for Ignore Edges, click Build Selected.

    model.component("comp1").geom("geom1").run("ige1");

//    In the Geometry toolbar, click Selections and choose Explicit Selection.

    model.component("comp1").geom("geom1").create("sel1", "ExplicitSelection");

//    On the object ige1, select Domains 4, 5.

    model.component("comp1").geom("geom1").feature("sel1").selection("selection").set("ige1", 4, 5);

//    In the Settings window for Explicit Selection, type Interior wall in the Label text field.

    model.component("comp1").geom("geom1").feature("sel1").label("Interior wall");

//    In the Geometry toolbar, click Selections and choose Explicit Selection.

    model.component("comp1").geom("geom1").run("sel1");
    model.component("comp1").geom("geom1").create("sel2", "ExplicitSelection");

//    On the object ige1, select Domain 2.

    model.component("comp1").geom("geom1").feature("sel2").selection("selection").set("ige1", 2);

//    In the Settings window for Explicit Selection, type Isolation in the Label text field.

    model.component("comp1").geom("geom1").feature("sel2").label("Isolation");

//    In the Geometry toolbar, click Selections and choose Explicit Selection.

    model.component("comp1").geom("geom1").run("sel2");
    model.component("comp1").geom("geom1").create("sel3", "ExplicitSelection");

//    In the Settings window for Explicit Selection, type Exterior wall in the Label text field.

    model.component("comp1").geom("geom1").feature("sel3").label("Exterior wall");

//    On the object ige1, select Domain 1.

    model.component("comp1").geom("geom1").feature("sel3").selection("selection").set("ige1", 1);

//    In the Geometry toolbar, click Selections and choose Explicit Selection.

    model.component("comp1").geom("geom1").run("sel3");
    model.component("comp1").geom("geom1").create("sel4", "ExplicitSelection");

//    In the Settings window for Explicit Selection, type Horizontal Structure in the Label text field.

    model.component("comp1").geom("geom1").feature("sel4").label("Horizontal Structure");

//    On the object ige1, select Domain 3.

    model.component("comp1").geom("geom1").feature("sel4").selection("selection").set("ige1", 3);

//    In the Geometry toolbar, click Selections and choose Explicit Selection.

    model.component("comp1").geom("geom1").run("sel4");
    model.component("comp1").geom("geom1").create("sel5", "ExplicitSelection");

//    In the Settings window for Explicit Selection, type Floor in the Label text field.

    model.component("comp1").geom("geom1").feature("sel5").label("Floor");

//    On the object ige1, select Domain 6.

    model.component("comp1").geom("geom1").feature("sel5").selection("selection").set("ige1", 6);

//    In the Geometry toolbar, click Selections and choose Explicit Selection.

    model.component("comp1").geom("geom1").run("sel5");
    model.component("comp1").geom("geom1").create("sel6", "ExplicitSelection");

//    In the Settings window for Explicit Selection, type Alpha in the Label text field.

    model.component("comp1").geom("geom1").feature("sel6").label("Alpha");

//    Locate the Entities to Select section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").geom("geom1").feature("sel6").selection("selection").init(2);

//    On the object ige1, select Boundaries 33, 34, 35.

    model.component("comp1").geom("geom1").feature("sel6").selection("selection").set("ige1", 33, 34, 35);

//    In the Geometry toolbar, click Selections and choose Explicit Selection.

    model.component("comp1").geom("geom1").run("sel6");
    model.component("comp1").geom("geom1").create("sel7", "ExplicitSelection");

//    In the Settings window for Explicit Selection, type Beta in the Label text field.

    model.component("comp1").geom("geom1").feature("sel7").label("Beta");

//    Locate the Entities to Select section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").geom("geom1").feature("sel7").selection("selection").init(2);

//    On the object ige1, select Boundaries 39, 40, 41.

    model.component("comp1").geom("geom1").feature("sel7").selection("selection").set("ige1", 39, 40, 41);

//    In the Geometry toolbar, click Selections and choose Explicit Selection.

    model.component("comp1").geom("geom1").run("sel7");
    model.component("comp1").geom("geom1").create("sel8", "ExplicitSelection");

//    In the Settings window for Explicit Selection, type Gamma in the Label text field.

    model.component("comp1").geom("geom1").feature("sel8").label("Gamma");

//    Locate the Entities to Select section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").geom("geom1").feature("sel8").selection("selection").init(2);

//    On the object ige1, select Boundaries 1, 2, 11, 12, 13, 14.

    model.component("comp1").geom("geom1").feature("sel8").selection("selection").set("ige1", 1, 2, 11, 12, 13, 14);
    model.component("comp1").geom("geom1").run();

//    In the Materials toolbar, click Blank Material.

    model.component("comp1").material().create("mat1", "Common");

//    In the Settings window for Material, type Interior Wall in the Label text field.

    model.component("comp1").material("mat1").label("Interior Wall");

//    Locate the Geometric Entity Selection section.
//    From the Selection list, select Interior wall.

    model.component("comp1").material("mat1").selection().named("geom1_sel1");

//    Locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalconductivity", new String[]{"0.7[W/(m*K)]"});
    model.component("comp1").material("mat1").propertyGroup("def").set("density", new String[]{"1700[kg/m^3]"});
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("heatcapacity", new String[]{"800[J/(kg*K)]"});

//    In the Materials toolbar, click Blank Material.

    model.component("comp1").material().create("mat2", "Common");

//    In the Settings window for Material, type Isolation in the Label text field.

    model.component("comp1").material("mat2").label("Isolation");

//    Locate the Geometric Entity Selection section.
//    From the Selection list, select Isolation.

    model.component("comp1").material("mat2").selection().named("geom1_sel2");

//    Locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat2").propertyGroup("def")
         .set("thermalconductivity", new String[]{"0.04[W/(m*K)]"});
    model.component("comp1").material("mat2").propertyGroup("def").set("density", new String[]{"200[kg/m^3]"});
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("heatcapacity", new String[]{"1000[J/(kg*K)]"});

//    In the Materials toolbar, click Blank Material.

    model.component("comp1").material().create("mat3", "Common");

//    In the Settings window for Material, type Exterior Wall in the Label text field.

    model.component("comp1").material("mat3").label("Exterior Wall");

//    Locate the Geometric Entity Selection section.
//    From the Selection list, select Exterior wall.

    model.component("comp1").material("mat3").selection().named("geom1_sel3");

//    Locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat3").propertyGroup("def")
         .set("thermalconductivity", new String[]{"1[W/(m*K)]"});
    model.component("comp1").material("mat3").propertyGroup("def").set("density", new String[]{"2000[kg/m^3]"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("heatcapacity", new String[]{"1000[J/(kg*K)]"});

//    In the Materials toolbar, click Blank Material.

    model.component("comp1").material().create("mat4", "Common");

//    In the Settings window for Material, type Horizontal Structure in the Label text field.

    model.component("comp1").material("mat4").label("Horizontal Structure");

//    Locate the Geometric Entity Selection section.
//    From the Selection list, select Horizontal Structure.

    model.component("comp1").material("mat4").selection().named("geom1_sel4");

//    Locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat4").propertyGroup("def")
         .set("thermalconductivity", new String[]{"2.5[W/(m*K)]"});
    model.component("comp1").material("mat4").propertyGroup("def").set("density", new String[]{"5000[kg/m^3]"});
    model.component("comp1").material("mat4").propertyGroup("def")
         .set("heatcapacity", new String[]{"600[J/(kg*K)]"});

//    In the Materials toolbar, click Blank Material.

    model.component("comp1").material().create("mat5", "Common");

//    In the Settings window for Material, type Floor in the Label text field.

    model.component("comp1").material("mat5").label("Floor");

//    Locate the Geometric Entity Selection section.
//    From the Selection list, select Floor.

    model.component("comp1").material("mat5").selection().named("geom1_sel5");

//    Locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat5").propertyGroup("def")
         .set("thermalconductivity", new String[]{"1[W/(m*K)]"});
    model.component("comp1").material("mat5").propertyGroup("def").set("density", new String[]{"1000[kg/m^3]"});
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("heatcapacity", new String[]{"800[J/(kg*K)]"});

//    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, type Heat Flux - Alpha in the Label text field.

    model.component("comp1").physics("ht").feature("hf1").label("Heat Flux - Alpha");

//    Locate the Boundary Selection section.
//    From the Selection list, select Alpha.

    model.component("comp1").physics("ht").feature("hf1").selection().named("geom1_sel6");

//    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 h_alpha.

    model.component("comp1").physics("ht").feature("hf1").set("h", "h_alpha");

//    In the \[T_{\textrm{ext}}\] text field, type T_alpha.

    model.component("comp1").physics("ht").feature("hf1").set("Text", "T_alpha");

//    In the Physics toolbar, click Boundaries and choose Heat Flux.

    model.component("comp1").physics("ht").create("hf2", "HeatFluxBoundary", 2);

//    In the Settings window for Heat Flux, type Heat Flux - Beta in the Label text field.

    model.component("comp1").physics("ht").feature("hf2").label("Heat Flux - Beta");

//    Locate the Boundary Selection section.
//    From the Selection list, select Beta.

    model.component("comp1").physics("ht").feature("hf2").selection().named("geom1_sel7");

//    Locate the Heat Flux section.
//    From the Flux type list, select Convective heat flux.

    model.component("comp1").physics("ht").feature("hf2").set("HeatFluxType", "ConvectiveHeatFlux");

//    In the \[h\] text field, type h_beta.

    model.component("comp1").physics("ht").feature("hf2").set("h", "h_beta");

//    In the \[T_{\textrm{ext}}\] text field, type T_beta.

    model.component("comp1").physics("ht").feature("hf2").set("Text", "T_beta");

//    In the Physics toolbar, click Boundaries and choose Heat Flux.

    model.component("comp1").physics("ht").create("hf3", "HeatFluxBoundary", 2);

//    Select Boundaries 1, 2, 11, 12, 13, 14.

    model.component("comp1").physics("ht").feature("hf3").selection().set(1, 2, 11, 12, 13, 14);

//    In the Settings window for Heat Flux, type Heat Flux - Gamma in the Label text field.

    model.component("comp1").physics("ht").feature("hf3").label("Heat Flux - Gamma");

//    Locate the Boundary Selection section.
//    From the Selection list, select Gamma.

    model.component("comp1").physics("ht").feature("hf3").selection().named("geom1_sel8");

//    Locate the Heat Flux section.
//    From the Flux type list, select Convective heat flux.

    model.component("comp1").physics("ht").feature("hf3").set("HeatFluxType", "ConvectiveHeatFlux");

//    In the \[h\] text field, type h_gamma.

    model.component("comp1").physics("ht").feature("hf3").set("h", "h_gamma");

//    In the \[T_{\textrm{ext}}\] text field, type T_gamma.

    model.component("comp1").physics("ht").feature("hf3").set("Text", "T_gamma");

//    In the Model Builder window, under Component 1 (comp1), click Mesh 1.
//    In the Settings window for Mesh, locate the Physics-Controlled Mesh section.
//    In the table, enter the following settings:

    model.component("comp1").mesh("mesh1").contribute("geom/detail", false);

//    Click Build All.

    model.component("comp1").mesh("mesh1").run();

//    In the Study 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();

//    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();
    model.result("pg1").run();

//    In the Model Builder window, expand the Temperature (ht) node, then click Volume 1.
//    In the Temperature (ht) toolbar, click Plot.

    model.result("pg1").run();

//    Follow the steps below to find the minimum temperatures on <symbol>a</symbol> and <symbol>b</symbol> as well as the heat fluxes through <symbol>a</symbol>, <symbol>b</symbol>, and <symbol>g</symbol>.
//    In the Results toolbar, click More Derived Values and choose Minimum > Surface Minimum.

    model.result().numerical().create("min1", "MinSurface");

//    In the Settings window for Surface Minimum, locate the Selection section.
//    From the Selection list, select Alpha.

    model.result().numerical("min1").selection().named("geom1_sel6");

//    Click Evaluate.

    model.result().table().create("tbl1", "Table");
    model.result().table("tbl1").comments("Surface Minimum 1");
    model.result().numerical("min1").set("table", "tbl1");
    model.result().numerical("min1").setResult();

//    The displayed value should be close to 11.3°C.
//    In the Results toolbar, click More Derived Values and choose Minimum > Surface Minimum.

    model.result().numerical().create("min2", "MinSurface");

//    In the Settings window for Surface Minimum, locate the Selection section.
//    From the Selection list, select Beta.

    model.result().numerical("min2").selection().named("geom1_sel7");

//    Click Evaluate.

    model.result().table().create("tbl2", "Table");
    model.result().table("tbl2").comments("Surface Minimum 2");
    model.result().numerical("min2").set("table", "tbl2");
    model.result().numerical("min2").setResult();

//    The displayed value should be close to 11.1°C.
//    In the Results toolbar, click More Derived Values and choose Integration > Surface Integration.

    model.result().numerical().create("int1", "IntSurface");
    model.result().numerical("int1").set("intvolume", true);

//    In the Settings window for Surface Integration, locate the Selection section.
//    From the Selection list, select Alpha.

    model.result().numerical("int1").selection().named("geom1_sel6");

//    Click Replace Expression in the upper-right corner of the Expressions section.
//    From the menu, choose Component 1 (comp1) > Heat Transfer in Solids > Boundary fluxes > ht.q0 - Inward heat flux - W/m².

    model.result().numerical("int1").set("expr", new String[]{"ht.q0"});
    model.result().numerical("int1").set("descr", new String[]{"Inward heat flux"});

    return model;
  }

  public static Model run2(Model model) {
    model.result().numerical("int1").set("unit", new String[]{"W"});

//    Click Evaluate.

    model.result().table().create("tbl3", "Table");
    model.result().table("tbl3").comments("Surface Integration 1");
    model.result().numerical("int1").set("table", "tbl3");
    model.result().numerical("int1").setResult();

//    The displayed value should be close to 46.2 W.
//    In the Results toolbar, click More Derived Values and choose Integration > Surface Integration.

    model.result().numerical().create("int2", "IntSurface");
    model.result().numerical("int2").set("intvolume", true);

//    In the Settings window for Surface Integration, locate the Selection section.
//    From the Selection list, select Beta.

    model.result().numerical("int2").selection().named("geom1_sel7");

//    Click Replace Expression in the upper-right corner of the Expressions section.
//    From the menu, choose Component 1 (comp1) > Heat Transfer in Solids > Boundary fluxes > ht.q0 - Inward heat flux - W/m².

    model.result().numerical("int2").set("expr", new String[]{"ht.q0"});
    model.result().numerical("int2").set("descr", new String[]{"Inward heat flux"});
    model.result().numerical("int2").set("unit", new String[]{"W"});

//    Click Evaluate.

    model.result().table().create("tbl4", "Table");
    model.result().table("tbl4").comments("Surface Integration 2");
    model.result().numerical("int2").set("table", "tbl4");
    model.result().numerical("int2").setResult();

//    The displayed value should be close to 13.9 W.
//    In the Results toolbar, click More Derived Values and choose Integration > Surface Integration.

    model.result().numerical().create("int3", "IntSurface");
    model.result().numerical("int3").set("intvolume", true);

//    In the Settings window for Surface Integration, locate the Selection section.
//    From the Selection list, select Gamma.

    model.result().numerical("int3").selection().named("geom1_sel8");

//    Click Replace Expression in the upper-right corner of the Expressions section.
//    From the menu, choose Component 1 (comp1) > Heat Transfer in Solids > Boundary fluxes > ht.q0 - Inward heat flux - W/m².

    model.result().numerical("int3").set("expr", new String[]{"ht.q0"});
    model.result().numerical("int3").set("descr", new String[]{"Inward heat flux"});
    model.result().numerical("int3").set("unit", new String[]{"W"});

//    Click Evaluate.

    model.result().table().create("tbl5", "Table");
    model.result().table("tbl5").comments("Surface Integration 3");
    model.result().numerical("int3").set("table", "tbl5");
    model.result().numerical("int3").setResult();

//    The displayed value should be close to 60.1 W.

    model.result("pg1").run();

//    To plot the location of the minimum temperature on <symbol>a</symbol>, follow the instructions below.
//    The resulting dataset is restricted to the surfaces <symbol>a</symbol>.
//    In the Model Builder window, expand the Results > Datasets node.
//    Right-click Results and choose 3D Plot Group.

    model.result().create("pg2", "PlotGroup3D");
    model.result("pg2").run();

//    In the Settings window for 3D Plot Group, type Minimum Temperature on Alpha in the Label text field.

    model.result("pg2").label("Minimum Temperature on Alpha");

//    Locate the Plot Settings section.
//    From the View list, select New view.

    model.result("pg2").set("view", "new");

//    In the Minimum Temperature on Alpha toolbar, click Plot.

    model.result("pg2").run();

//    This generates a dedicated view for the plot.
//    In the Minimum Temperature on Alpha toolbar, click Surface.

    model.result("pg2").create("surf1", "Surface");
    model.result("pg2").feature("surf1").set("evaluationsettings", "parent");

//    In the Settings window for Surface, locate the Coloring and Style section.
//    From the Color table list, select HeatCameraLight.

    model.result("pg2").feature("surf1").set("colortable", "HeatCameraLight");

//    In the Minimum Temperature on Alpha toolbar, click Selection.

    model.result("pg2").feature("surf1").create("sel1", "Selection");

//    In the Settings window for Selection, locate the Selection section.
//    From the Selection list, select Alpha.

    model.result("pg2").feature("surf1").feature("sel1").selection().named("geom1_sel6");
    model.result("pg2").run();

//    In the Model Builder window, under Results, click Minimum Temperature on Alpha.
//    In the Minimum Temperature on Alpha toolbar, click More Plots and choose Max/Min Surface.

    model.result("pg2").create("mms1", "MaxMinSurface");

//    In the Minimum Temperature on Alpha toolbar, click Selection.

    model.result("pg2").feature("mms1").create("sel1", "Selection");

//    In the Settings window for Selection, locate the Selection section.
//    From the Selection list, select Alpha.

    model.result("pg2").feature("mms1").feature("sel1").selection().named("geom1_sel6");

//    In the Minimum Temperature on Alpha toolbar, click Plot.

    model.result("pg2").run();

//    Click Plot.

    model.result("pg2").run();

//    Now plot the location of the minimum temperature on <symbol>b</symbol>.

    model.result("pg2").run();

//    Right-click Minimum Temperature on Alpha and choose Duplicate.

    model.result().duplicate("pg3", "pg2");
    model.result("pg3").run();

//    In the Settings window for 3D Plot Group, type Minimum Temperature on Beta in the Label text field.

    model.result("pg3").label("Minimum Temperature on Beta");

//    Locate the Plot Settings section.
//    From the View list, select New view.

    model.result("pg3").set("view", "new");

//    In the Minimum Temperature on Beta toolbar, click Plot.

    model.result("pg3").run();

//    In the Model Builder window, expand the Minimum Temperature on Beta node.

    model.result("pg3").run();

//    In the Model Builder window, expand the Results > Minimum Temperature on Beta > Surface 1 node, then click Selection 1.
//    In the Settings window for Selection, locate the Selection section.
//    From the Selection list, select Beta.

    model.result("pg3").feature("surf1").feature("sel1").selection().named("geom1_sel7");
    model.result("pg3").run();

//    In the Model Builder window, expand the Results > Minimum Temperature on Beta > Max/Min Surface 1 node, then click Selection 1.
//    In the Settings window for Selection, locate the Selection section.
//    From the Selection list, select Beta.

    model.result("pg3").feature("mms1").feature("sel1").selection().named("geom1_sel7");

//    In the Minimum Temperature on Beta toolbar, click Plot.

    model.result("pg3").run();

//    Click the Zoom Extents button in the Graphics toolbar.

    model.result("pg3").run();

    model.title("Thermal Bridges in Building Construction \u2014 3D Structure Between Two Floors");

    model
         .description("This example studies the heat conduction in a building structure separating two floors from the external environment. The structure is made of four materials with different thermal conductivities. The temperature distribution and the heat flux through the structure are compared with published data. This example corresponds to Case\u00a03 in the European standard EN ISO 10211:2017 for thermal bridges in building constructions.");

    return model;
  }

  public static void main(String[] args) {
    Model model = run();
    run2(model);
  }

}
