/*
 * helmholtz_resonator_with_flow.java
 */

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

/** Model exported on May 15 2026, 09:01 by COMSOL 6.4.0.421. */
public class helmholtz_resonator_with_flow {

  public static Model run() {
    Model model = ModelUtil.create("Model");

//    The following model consists of several steps. First the background mean flow is solved using the CFD Module, then the CFD solution is mapped to the acoustics mesh using the multiphysics coupling and the mapping study, then the acoustics is solved with the mapped flow as input, finally the results are postprocessed.
//    The first step is to set up the CFD model and solve the flow for two Mach numbers. Running this part of the model can take about 5 h.
//    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 Fluid Flow > Single-Phase Flow > Turbulent Flow > Turbulent Flow, SST (spf).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select Preset Studies for Selected Physics Interfaces > Stationary with Initialization.
//    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("spf", "TurbulentFlowSST", "geom1");

    model.study().create("std1");
    model.study("std1").create("wdi", "WallDistanceInitialization");
    model.study("std1").feature("wdi").set("solnum", "auto");
    model.study("std1").feature("wdi").set("notsolnum", "auto");
    model.study("std1").feature("wdi").set("outputmap", new String[]{});
    model.study("std1").feature("wdi").set("ngenAUX", "1");
    model.study("std1").feature("wdi").set("goalngenAUX", "1");
    model.study("std1").feature("wdi").set("ngenAUX", "1");
    model.study("std1").feature("wdi").set("goalngenAUX", "1");
    model.study("std1").create("stat", "Stationary");
    model.study("std1").feature("stat").set("solnum", "auto");
    model.study("std1").feature("stat").set("notsolnum", "auto");
    model.study("std1").feature("stat").set("outputmap", new String[]{});
    model.study("std1").feature("stat").set("ngenAUX", "1");
    model.study("std1").feature("stat").set("goalngenAUX", "1");
    model.study("std1").feature("stat").set("ngenAUX", "1");
    model.study("std1").feature("stat").set("goalngenAUX", "1");

//    In the Model Builder window, collapse the Global Definitions node.
//    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 helmholtz_resonator_with_flow_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("Ma", "0.0", "Flow Mach number");
    model.param().set("c0", "343[m/s]", "Speed of sound");
    model.param().set("Uin", "Ma*c0", "Inflow velocity");
    model.param().set("Lin", "60[cm]", "Inlet duct length");
    model.param().set("Lout", "50[cm]", "Outlet duct length");
    model.param().set("Lpml", "10[cm]", "PML domain length");
    model.param().set("Dmain", "4.859[cm]", "Main duct diameter");
    model.param().set("Dneck", "4.044[cm]", "Neck diameter");
    model.param().set("Lneck", "32.47[cm]-24.42[cm]", "Neck length");
    model.param().set("Dreson", "15.32[cm]", "Resonator volume diameter");
    model.param().set("Lreson", "24.42[cm]", "Resonator volume length");
    model.param().set("Lsource", "5[cm]", "Source domain length");
    model.param().set("f0", "200[Hz]", "Maximal frequency");
    model.param().set("dvisc", "0.22[mm]*sqrt(100[Hz]/f0)", "Viscous boundary layer thickness at f0");

//    The first step is to build the geometry of the Helmholtz resonator system. To save time you can <l>Insert Sequence</l> from file by referring to the <c>helmholtz_renoator_with_flow.mph</c> file in the applications folder of the COMSOL installation.
//    In the Geometry toolbar, click Cylinder.

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

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

    model.component("comp1").geom("geom1").feature("cyl1").set("r", "Dmain/2");

//    In the Height text field, type Lin+Lout+2*Lpml.

    model.component("comp1").geom("geom1").feature("cyl1").set("h", "Lin+Lout+2*Lpml");

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

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

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

    model.component("comp1").geom("geom1").feature("cyl1").setIndex("layername", "Layer 1", 0);
    model.component("comp1").geom("geom1").feature("cyl1").setIndex("layer", "Lpml", 0);

//    Clear the Layers on side checkbox.

    model.component("comp1").geom("geom1").feature("cyl1").set("layerside", false);

//    Select the Layers on bottom checkbox.

    model.component("comp1").geom("geom1").feature("cyl1").set("layerbottom", true);

//    Select the Layers on top checkbox.

    model.component("comp1").geom("geom1").feature("cyl1").set("layertop", true);

//    In the Geometry toolbar, click Cylinder.

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

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

    model.component("comp1").geom("geom1").feature("cyl2").set("r", "Dneck/2");

//    In the Height text field, type 1.2*Lneck.

    model.component("comp1").geom("geom1").feature("cyl2").set("h", "1.2*Lneck");

//    Locate the Position section.
//    In the x text field, type Dmain/2-0.2*Lneck.

    model.component("comp1").geom("geom1").feature("cyl2").set("pos", new String[]{"Dmain/2-0.2*Lneck", "0", "0"});

//    Locate the Axis section.
//    From the Axis type list, select x-axis.

    model.component("comp1").geom("geom1").feature("cyl2").set("axistype", "x");

//    In the Geometry toolbar, click Cylinder.

    model.component("comp1").geom("geom1").run("cyl2");
    model.component("comp1").geom("geom1").create("cyl3", "Cylinder");

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

    model.component("comp1").geom("geom1").feature("cyl3").set("r", "Dreson/2");

//    In the Height text field, type Lreson.

    model.component("comp1").geom("geom1").feature("cyl3").set("h", "Lreson");

//    Locate the Position section.
//    In the x text field, type Dmain/2+Lneck.

    model.component("comp1").geom("geom1").feature("cyl3").set("pos", new String[]{"Dmain/2+Lneck", "0", "0"});

//    Locate the Axis section.
//    From the Axis type list, select x-axis.

    model.component("comp1").geom("geom1").feature("cyl3").set("axistype", "x");

//    In the Geometry toolbar, click Cylinder.

    model.component("comp1").geom("geom1").run("cyl3");
    model.component("comp1").geom("geom1").create("cyl4", "Cylinder");

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

    model.component("comp1").geom("geom1").feature("cyl4").set("r", "Dmain/2");

//    In the Height text field, type Lsource.

    model.component("comp1").geom("geom1").feature("cyl4").set("h", "Lsource");

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

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

//    In the Geometry toolbar, click Cylinder.

    model.component("comp1").geom("geom1").run("cyl4");
    model.component("comp1").geom("geom1").create("cyl5", "Cylinder");

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

    model.component("comp1").geom("geom1").feature("cyl5").set("r", "Dmain/2");

//    In the Height text field, type 0.2.

    model.component("comp1").geom("geom1").feature("cyl5").set("h", 0.2);

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

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

//    Click Build Selected.

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

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

    model.component("comp1").geom("geom1").create("pard1", "PartitionDomains");

//    On the object cyl2, select Domain 1.

    model.component("comp1").geom("geom1").feature("pard1").selection("domain").set("cyl2", 1);

//    In the Settings window for Partition Domains, locate the Partition Domains section.
//    From the Partition with list, select Extended faces.

    model.component("comp1").geom("geom1").feature("pard1").set("partitionwith", "extendedfaces");

//    On the object cyl1, select Boundaries 12, 15.

    model.component("comp1").geom("geom1").feature("pard1").selection("extendedface").set("cyl1", 12, 15);

//    It might be easier to select the boundaries by using the <l>Selection List</l> window. To open this window, in the <l>Home</l> toolbar click <l>Windows</l> and choose <l>Selection List</l>. (If you are running the cross-platform desktop, you find <l>Windows</l> in the main menu.)
//    From the Repair tolerance list, select Relative.

    model.component("comp1").geom("geom1").feature("pard1").set("repairtoltype", "relative");

//    Click Build All Objects.

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

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

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

//    In the Model Builder window, right-click Geometry 1 and choose Delete Entities.

    model.component("comp1").geom("geom1").create("del1", "Delete");

//    In the Settings window for Delete Entities, locate the Entities or Objects to Delete section.
//    From the Geometric entity level list, select Domain.

    model.component("comp1").geom("geom1").feature("del1").selection("input").init(3);

//    On the object pard1, select Domain 1.

    model.component("comp1").geom("geom1").feature("del1").selection("input").set("pard1", 1);

//    Click Build Selected.

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

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

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

//    Click in the Graphics window and then press Ctrl+A to select all objects.

    model.component("comp1").geom("geom1").feature("uni1").selection("input")
         .set("cyl1", "cyl3", "cyl4", "cyl5", "del1");

//    In the Geometry toolbar, click Work Plane.

    model.component("comp1").geom("geom1").run("uni1");
    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, locate the Plane Definition section.
//    From the Plane list, select zx-plane.

    model.component("comp1").geom("geom1").feature("wp1").set("quickplane", "zx");

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

    model.component("comp1").geom("geom1").run("wp1");
    model.component("comp1").geom("geom1").create("par1", "Partition");

//    Select the object uni1.

    model.component("comp1").geom("geom1").feature("par1").selection("input").set("uni1");

//    In the Settings window for Partition Objects, locate the Partition Objects section.
//    From the Partition with list, select Work plane.

    model.component("comp1").geom("geom1").feature("par1").set("partitionwith", "workplane");

//    Click Build Selected.

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

//    Right-click Geometry 1 and choose Delete Entities.

    model.component("comp1").geom("geom1").create("del2", "Delete");

//    In the Settings window for Delete Entities, locate the Entities or Objects to Delete section.
//    From the Geometric entity level list, select Domain.

    model.component("comp1").geom("geom1").feature("del2").selection("input").init(3);

//    On the object par1, select Domains 2, 4, 6, 8, 10, 12, 14, 16.

    model.component("comp1").geom("geom1").feature("del2").selection("input").set("par1", 2, 4, 6, 8, 10, 12, 14, 16);

//    Click Build All Objects.

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

//    Rotate the geometry in the <l>Graphics</l> window. The geometry should look like the figure above.
//    In the Definitions toolbar, click Explicit.

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

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

//    In the Settings window for Explicit, locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundaries 2, 5, 8, 11, 14, 17, 29, 34.

    model.component("comp1").selection("sel1").set(2, 5, 8, 11, 14, 17, 29, 34);

//    In the Label text field, type Symmetry.

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

//    In the Definitions toolbar, click Explicit.

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

//    In the Settings window for Explicit, locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundaries 1, 4, 7, 10, 13, 16, 20, 21, 22, 23, 24, 25, 27, 28, 30, 31, 32, 35.

    model.component("comp1").selection("sel2")
         .set(1, 4, 7, 10, 13, 16, 20, 21, 22, 23, 24, 25, 27, 28, 30, 31, 32, 35);

//    In the Label text field, type Walls.

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

//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Built-in > Air.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat1", "Common");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("eta", "Piecewise");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("rho", "Analytic");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("k", "Piecewise");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("cs", "Analytic");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("an1", "Analytic");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("an2", "Analytic");
    model.component("comp1").material("mat1").propertyGroup()
         .create("RefractiveIndex", "RefractiveIndex", "Refractive index");
    model.component("comp1").material("mat1").propertyGroup()
         .create("NonlinearModel", "NonlinearModel", "Nonlinear model");
    model.component("comp1").material("mat1").propertyGroup().create("idealGas", "idealGas", "Ideal gas");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat1").label("Air");
    model.component("comp1").material("mat1").set("family", "air");
    model.component("comp1").material("mat1").propertyGroup("def").func("eta").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("def").func("eta")
         .set("pieces", new String[][]{{"200.0", "1600.0", "-8.38278E-7+8.35717342E-8*T^1-7.69429583E-11*T^2+4.6437266E-14*T^3-1.06585607E-17*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("eta").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("def").func("eta").set("fununit", "Pa*s");
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp")
         .set("pieces", new String[][]{{"200.0", "1600.0", "1047.63657-0.372589265*T^1+9.45304214E-4*T^2-6.02409443E-7*T^3+1.2858961E-10*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("expr", "pA*0.02897/R_const[K*mol/J]/T");
    model.component("comp1").material("mat1").propertyGroup("def").func("rho").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho").set("fununit", "kg/m^3");
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "293.15"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("k").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("def").func("k")
         .set("pieces", new String[][]{{"200.0", "1600.0", "-0.00227583562+1.15480022E-4*T^1-7.90252856E-8*T^2+4.11702505E-11*T^3-7.43864331E-15*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("k").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("def").func("k").set("fununit", "W/(m*K)");
    model.component("comp1").material("mat1").propertyGroup("def").func("cs")
         .set("expr", "sqrt(1.4*R_const[K*mol/J]/0.02897*T)");
    model.component("comp1").material("mat1").propertyGroup("def").func("cs").set("args", new String[]{"T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("cs").set("fununit", "m/s");
    model.component("comp1").material("mat1").propertyGroup("def").func("cs").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("cs")
         .set("plotfixedvalue", new String[]{"273.15"});
    model.component("comp1").material("mat1").propertyGroup("def").func("cs")
         .set("plotargs", new String[][]{{"T", "273.15", "373.15"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1").set("funcname", "alpha_p");
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("expr", "-1/rho(pA,T)*d(rho(pA,T),T)");
    model.component("comp1").material("mat1").propertyGroup("def").func("an1").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1").set("fununit", "1/K");
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "373.15"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("funcname", "muB");
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("expr", "0.6*eta(T)");
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("args", new String[]{"T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("fununit", "Pa*s");
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2")
         .set("plotfixedvalue", new String[]{"200"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2")
         .set("plotargs", new String[][]{{"T", "200", "1600"}});
    model.component("comp1").material("mat1").propertyGroup("def").set("thermalexpansioncoefficient", "");
    model.component("comp1").material("mat1").propertyGroup("def").set("molarmass", "");
    model.component("comp1").material("mat1").propertyGroup("def").set("bulkviscosity", "");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"alpha_p(pA,T)", "0", "0", "0", "alpha_p(pA,T)", "0", "0", "0", "alpha_p(pA,T)"});
    model.component("comp1").material("mat1").propertyGroup("def").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat1").propertyGroup("def").set("bulkviscosity", "muB(T)");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat1").propertyGroup("def").set("dynamicviscosity", "eta(T)");
    model.component("comp1").material("mat1").propertyGroup("def").set("ratioofspecificheat", "1.4");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("electricconductivity", new String[]{"0[S/m]", "0", "0", "0", "0[S/m]", "0", "0", "0", "0[S/m]"});
    model.component("comp1").material("mat1").propertyGroup("def").set("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat1").propertyGroup("def").set("density", "rho(pA,T)");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalconductivity", new String[]{"k(T)", "0", "0", "0", "k(T)", "0", "0", "0", "k(T)"});
    model.component("comp1").material("mat1").propertyGroup("def").set("soundspeed", "cs(T)");
    model.component("comp1").material("mat1").propertyGroup("def").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("def").addInput("pressure");
    model.component("comp1").material("mat1").propertyGroup("RefractiveIndex")
         .set("n", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat1").propertyGroup("NonlinearModel").set("BA", "def.gamma-1");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").label("Piecewise 2");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp")
         .set("pieces", new String[][]{{"200.0", "1600.0", "1047.63657-0.372589265*T^1+9.45304214E-4*T^2-6.02409443E-7*T^3+1.2858961E-10*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("Rs", "R_const/Mn");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("ratioofspecificheat", "1.4");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat1").propertyGroup("idealGas").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("idealGas").addInput("pressure");
    model.component("comp1").material("mat1").materialType("nonSolid");

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    In the Settings window for Turbulent Flow, SST, locate the Physical Model section.
//    From the Compressibility list, select Compressible flow (Ma<0.3).

    model.component("comp1").physics("spf").prop("PhysicalModelProperty")
         .set("Compressibility", "CompressibleMALT03");

//    The background flow is now set to be fully compressible. This results in the density to vary spatially. The effects of a nonconstant background density are included in the linearized Navier–Stokes equations. The importance of including this depends on the specific application.
//    In the Physics toolbar, click Boundaries and choose Symmetry.

    model.component("comp1").physics("spf").create("sym1", "Symmetry", 2);

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

    model.component("comp1").physics("spf").feature("sym1").selection().named("sel1");

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

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

//    Select Boundary 19.

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

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

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

//    Select Boundary 3.

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

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

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

//    This boundary condition ensures a fully developed turbulent flow profile at the inlet.
//    Generate the mesh used for the CFD simulation. In this model, set up a user-defined mesh consisting of hexahedral elements in the main part of the duct. Such a mesh will give the smallest amount of numerical diffusion. The turbulent viscosity will yield a good estimate of the eddy viscosity used in the acoustics model.
//    In the Model Builder window, under Component 1 (comp1), click Mesh 1.
//    In the Settings window for Mesh, type Mesh - CFD in the Label text field.

    model.component("comp1").mesh("mesh1").label("Mesh - CFD");

//    In the Mesh toolbar, click More Generators and choose Free Quad.

    model.component("comp1").mesh("mesh1").create("fq1", "FreeQuad");

//    Select Boundaries 3, 19.

    model.component("comp1").mesh("mesh1").feature("fq1").selection().set(3, 19);

//    Right-click Free Quad 1 and choose Size.

    model.component("comp1").mesh("mesh1").feature("fq1").create("size1", "Size");

//    In the Settings window for Size, locate the Element Size section.
//    From the Calibrate for list, select Fluid dynamics.

    model.component("comp1").mesh("mesh1").feature("fq1").feature("size1").set("table", "cfd");

//    From the Predefined list, select Extremely fine.

    model.component("comp1").mesh("mesh1").feature("fq1").feature("size1").set("hauto", 1);

//    In the Model Builder window, under Component 1 (comp1) > Mesh - CFD, click Size.
//    In the Settings window for Size, locate the Element Size section.
//    From the Calibrate for list, select Fluid dynamics.

    model.component("comp1").mesh("mesh1").feature("size").set("table", "cfd");

//    Click the Custom button.

    model.component("comp1").mesh("mesh1").feature("size").set("custom", true);

//    Locate the Element Size Parameters section.
//    In the Maximum element size text field, type 0.005.

    model.component("comp1").mesh("mesh1").feature("size").set("hmax", 0.005);

//    In the Minimum element size text field, type 0.001.

    model.component("comp1").mesh("mesh1").feature("size").set("hmin", 0.001);

//    In the Maximum element growth rate text field, type 1.1.

    model.component("comp1").mesh("mesh1").feature("size").set("hgrad", 1.1);

//    In the Curvature factor text field, type 0.4.

    model.component("comp1").mesh("mesh1").feature("size").set("hcurve", 0.4);

//    In the Resolution of narrow regions text field, type 1.

    model.component("comp1").mesh("mesh1").feature("size").set("hnarrow", 1);

//    In the Mesh toolbar, click Swept.

    model.component("comp1").mesh("mesh1").create("swe1", "Sweep");

//    In the Settings window for Swept, locate the Domain Selection section.
//    From the Geometric entity level list, select Domain.

    model.component("comp1").mesh("mesh1").feature("swe1").selection().geom("geom1", 3);

//    Select Domains 1, 2.

    model.component("comp1").mesh("mesh1").feature("swe1").selection().set(1, 2);

//    Right-click Swept 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("swe1").create("dis1", "Distribution");

//    Select Domain 1.

    model.component("comp1").mesh("mesh1").feature("swe1").feature("dis1").selection().set(1);

//    In the Settings window for Distribution, locate the Distribution section.
//    In the Number of elements text field, type 8.

    model.component("comp1").mesh("mesh1").feature("swe1").feature("dis1").set("numelem", 8);

//    In the Model Builder window, right-click Swept 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("swe1").create("dis2", "Distribution");

//    Select Domain 2.

    model.component("comp1").mesh("mesh1").feature("swe1").feature("dis2").selection().set(2);

//    In the Mesh toolbar, click Swept.

    model.component("comp1").mesh("mesh1").create("swe2", "Sweep");

//    In the Settings window for Swept, locate the Domain Selection section.
//    From the Geometric entity level list, select Domain.

    model.component("comp1").mesh("mesh1").feature("swe2").selection().geom("geom1", 3);

//    Select Domain 3.

    model.component("comp1").mesh("mesh1").feature("swe2").selection().set(3);

//    Right-click Swept 2 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("swe2").create("dis1", "Distribution");

//    In the Settings window for Distribution, locate the Distribution section.
//    From the Distribution type list, select Predefined.

    model.component("comp1").mesh("mesh1").feature("swe2").feature("dis1").set("type", "predefined");

//    In the Number of elements text field, type 50.

    model.component("comp1").mesh("mesh1").feature("swe2").feature("dis1").set("elemcount", 50);

//    In the Element ratio text field, type 4.

    model.component("comp1").mesh("mesh1").feature("swe2").feature("dis1").set("elemratio", 4);

//    Select the Reverse direction checkbox.

    model.component("comp1").mesh("mesh1").feature("swe2").feature("dis1").set("reverse", true);

//    In the Mesh toolbar, click Swept.

    model.component("comp1").mesh("mesh1").create("swe3", "Sweep");

//    In the Settings window for Swept, locate the Domain Selection section.
//    From the Geometric entity level list, select Domain.

    model.component("comp1").mesh("mesh1").feature("swe3").selection().geom("geom1", 3);

//    Select Domain 6.

    model.component("comp1").mesh("mesh1").feature("swe3").selection().set(6);

//    Right-click Swept 3 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("swe3").create("dis1", "Distribution");

//    In the Settings window for Distribution, locate the Distribution section.
//    In the Number of elements text field, type 8.

    model.component("comp1").mesh("mesh1").feature("swe3").feature("dis1").set("numelem", 8);

//    In the Mesh toolbar, click Swept.

    model.component("comp1").mesh("mesh1").create("swe4", "Sweep");

//    In the Settings window for Swept, locate the Domain Selection section.
//    From the Geometric entity level list, select Domain.

    return model;
  }

  public static Model run2(Model model) {

    model.component("comp1").mesh("mesh1").feature("swe4").selection().geom("geom1", 3);

//    Select Domain 5.

    model.component("comp1").mesh("mesh1").feature("swe4").selection().set(5);

//    Right-click Swept 4 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("swe4").create("dis1", "Distribution");

//    In the Settings window for Distribution, locate the Distribution section.
//    From the Distribution type list, select Predefined.

    model.component("comp1").mesh("mesh1").feature("swe4").feature("dis1").set("type", "predefined");

//    In the Number of elements text field, type 50.

    model.component("comp1").mesh("mesh1").feature("swe4").feature("dis1").set("elemcount", 50);

//    In the Element ratio text field, type 4.

    model.component("comp1").mesh("mesh1").feature("swe4").feature("dis1").set("elemratio", 4);

//    Select the Reverse direction checkbox.

    model.component("comp1").mesh("mesh1").feature("swe4").feature("dis1").set("reverse", true);

//    In the Mesh toolbar, click More Attributes and choose Corner Refinement.

    model.component("comp1").mesh("mesh1").create("cr1", "CornerRefinement");

//    In the Settings window for Corner Refinement, locate the Boundary Selection section.
//    From the Selection list, select Walls.

    model.component("comp1").mesh("mesh1").feature("cr1").selection("boundary").named("sel2");

//    In the Mesh toolbar, click Free Tetrahedral.

    model.component("comp1").mesh("mesh1").create("ftet1", "FreeTet");

//    Right-click Free Tetrahedral 1 and choose Size.

    model.component("comp1").mesh("mesh1").feature("ftet1").create("size1", "Size");

//    In the Settings window for Size, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").mesh("mesh1").feature("ftet1").feature("size1").selection().geom("geom1", 2);

//    Select Boundary 26.

    model.component("comp1").mesh("mesh1").feature("ftet1").feature("size1").selection().set(26);

//    Locate the Element Size section.
//    Click the Custom button.

    model.component("comp1").mesh("mesh1").feature("ftet1").feature("size1").set("custom", true);

//    Locate the Element Size Parameters section.
//    Select the Maximum element size checkbox.

    model.component("comp1").mesh("mesh1").feature("ftet1").feature("size1").set("hmaxactive", true);

//    In the associated text field, type 0.0015.

    model.component("comp1").mesh("mesh1").feature("ftet1").feature("size1").set("hmax", 0.0015);

//    In the Mesh toolbar, click Boundary Layers.

    model.component("comp1").mesh("mesh1").create("bl1", "BndLayer");
    model.component("comp1").mesh("mesh1").feature("bl1").create("blp", "BndLayerProp");

//    In the Model Builder window, click Boundary Layer Properties.
//    In the Settings window for Boundary Layer Properties, locate the Geometric Entity Selection section.
//    From the Selection list, select Walls.

    model.component("comp1").mesh("mesh1").feature("bl1").feature("blp").selection().named("sel2");

//    Locate the Layers section.
//    In the Thickness adjustment factor text field, type 1.4.

    model.component("comp1").mesh("mesh1").feature("bl1").feature("blp").set("blhminfact", 1.4);

//    Click Build All.

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

//    The CFD mesh should look like the figure above.
//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, type Study 1 - CFD in the Label text field.

    model.study("std1").label("Study 1 - CFD");

//    Locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std1").setGenPlots(false);

//    In the Model Builder window, under Study 1 - CFD, click Step 2: Stationary.
//    In the Settings window for Stationary, click to expand the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

    model.study("std1").feature("stat").set("useparam", true);

//    Click Add.

    model.study("std1").feature("stat").setIndex("pname", "Ma", 0);
    model.study("std1").feature("stat").setIndex("plistarr", "", 0);
    model.study("std1").feature("stat").setIndex("punit", "", 0);
    model.study("std1").feature("stat").setIndex("pname", "Ma", 0);
    model.study("std1").feature("stat").setIndex("plistarr", "", 0);
    model.study("std1").feature("stat").setIndex("punit", "", 0);

//    In the table, enter the following settings:

    model.study("std1").feature("stat").setIndex("plistarr", "0.05 0.1", 0);
    model.study("std1").feature("stat").setIndex("punit", "", 0);

//    Enabling this option ensures that the solution obtained at Ma = 0.05 is used as the initial solution for Ma = 0.1, which results in a better convergence of the nonlinear solver.
//    In the Study toolbar, click Show Default Solver.

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

//    After generating the solver sequence you can inspect the setup and make changes to the defaults if necessary.
//    Note that solving the model can take 5 h per value of the Mach number parameter (depending on your hardware).
//    Click Compute.

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

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

//    In the Model Builder window, expand the Results node.
//    Right-click Results > Datasets and choose Cut Line 3D.

    model.result().dataset().create("cln1", "CutLine3D");

//    In the Settings window for Cut Line 3D, locate the Line Data section.
//    In row Point 1, set y to -0.0001.

    model.result().dataset("cln1").setIndex("genpoints", "-0.0001", 0, 1);

//    In row Point 1, set z to -1.

    model.result().dataset("cln1").setIndex("genpoints", -1, 0, 2);

//    In row Point 2, set x to 0.

    model.result().dataset("cln1").setIndex("genpoints", 0, 1, 0);

//    In row Point 2, set y to -0.0001.

    model.result().dataset("cln1").setIndex("genpoints", "-0.0001", 1, 1);

//    In row Point 2, set z to 1.

    model.result().dataset("cln1").setIndex("genpoints", 1, 1, 2);

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

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

//    In the Settings window for 3D Plot Group, type CFD: Velocity in the Label text field.

    model.result("pg1").label("CFD: Velocity");

//    Right-click CFD: Velocity and choose Volume.

    model.result("pg1").create("vol1", "Volume");
    model.result("pg1").feature("vol1").set("evaluationsettings", "parent");

//    In the Model Builder window, right-click Volume 1 and choose Transparency.

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

//    In the Model Builder window, right-click CFD: Velocity and choose Streamline.

    model.result("pg1").create("str1", "Streamline");
    model.result("pg1").feature("str1").set("evaluationsettings", "parent");

//    In the Settings window for Streamline, locate the Streamline Positioning section.
//    In the Number text field, type 50.

    model.result("pg1").feature("str1").set("selnumber", 50);

//    Select Boundaries 12, 26.

    model.result("pg1").feature("str1").selection().set(12, 26);

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

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

//    Right-click Streamline 1 and choose Color Expression.

    model.result("pg1").feature("str1").create("col1", "Color");
    model.result("pg1").run();

//    In the CFD: Velocity toolbar, click Plot.

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

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

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

//    In the Settings window for 3D Plot Group, type CFD: Turbulent Viscosity in the Label text field.

    model.result("pg2").label("CFD: Turbulent Viscosity");

//    Right-click CFD: Turbulent Viscosity and choose Surface.

    model.result("pg2").create("surf1", "Surface");
    model.result("pg2").feature("surf1").set("evaluationsettings", "parent");

//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type spf.muT.

    model.result("pg2").feature("surf1").set("expr", "spf.muT");

//    In the CFD: Turbulent Viscosity toolbar, click Plot.

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

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

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

//    In the Settings window for 1D Plot Group, type CFD: Turbulent Viscosity Axial in the Label text field.

    model.result("pg3").label("CFD: Turbulent Viscosity Axial");

//    Locate the Data section.
//    From the Dataset list, select Cut Line 3D 1.

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

//    Click to expand the Title section.
//    From the Title type list, select Label.

    model.result("pg3").set("titletype", "label");

//    Right-click CFD: Turbulent Viscosity Axial and choose Line Graph.

    model.result("pg3").create("lngr1", "LineGraph");
    model.result("pg3").feature("lngr1").set("markerpos", "datapoints");
    model.result("pg3").feature("lngr1").set("linewidth", "preference");
    model.result("pg3").feature("lngr1").set("evaluationsettings", "parent");

//    In the Settings window for Line Graph, type CFD: Turbulent Viscosity Axial in the Label text field.

    model.result("pg3").feature("lngr1").label("CFD: Turbulent Viscosity Axial");

//    Locate the y-Axis Data section.
//    In the Expression text field, type spf.muT.

    model.result("pg3").feature("lngr1").set("expr", "spf.muT");

//    Locate the x-Axis Data section.
//    From the Parameter list, select Expression.

    model.result("pg3").feature("lngr1").set("xdata", "expr");

//    In the Expression text field, type z.

    model.result("pg3").feature("lngr1").set("xdataexpr", "z");

//    Click to expand the Legends section.
//    Select the Show legends checkbox.

    model.result("pg3").feature("lngr1").set("legend", true);

//    From the Legends list, select Evaluated.

    model.result("pg3").feature("lngr1").set("legendmethod", "evaluated");

//    In the Legend text field, type Ma = eval(Ma).

    model.result("pg3").feature("lngr1").set("legendpattern", "Ma = eval(Ma)");

//    In the CFD: Turbulent Viscosity Axial toolbar, click Plot.

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

//    The plot shows the turbulent viscosity along the central axis of the model.
//    Mapping, Multiphysics, and Acoustics
//    An important part of solving aeroacoustic problems is to correctly map the CFD solution onto the acoustics domain. This is done using the built-in <l>Background Fluid Flow Coupling</l> multiphysics feature and the dedicated <l>Mapping</l> study.
//    First, add the linearized Navier–Stokes interface, then the multiphysics coupling, create a mesh for the acoustics problem, and then compute the mapping study.
//    In the Home toolbar, click Add Physics to open the Add Physics window.
//    In the tree, select Acoustics > Aeroacoustics > Linearized Navier–Stokes, Frequency Domain (lnsf).
//    Find the Physics interfaces in study subsection.
//    In the table, enter the following settings:
//    Click Add to Component 1 in the window toolbar.

    model.component("comp1").physics().create("lnsf", "LinearizedNavierStokesFrequency", "geom1");

    model.study("std1").feature("wdi").setSolveFor("/physics/lnsf", false);
    model.study("std1").feature("stat").setSolveFor("/physics/lnsf", false);

//    In the Home toolbar, click Add Physics to close the Add Physics window.
//    In the Physics toolbar, click Multiphysics Couplings and choose Domain > Background Fluid Flow Coupling.

    model.component("comp1").multiphysics().create("bffc1", "BackgroundFluidFlowCoupling", 3);

//    In the Settings window for Background Fluid Flow Coupling, locate the Domain Selection section.
//    From the Selection list, select All domains.

    model.component("comp1").multiphysics("bffc1").selection().all();

//    Locate the Variables to Map section.
//    Select the Map the turbulent viscosity checkbox.

    model.component("comp1").multiphysics("bffc1").set("mapTurbulentViscosity", true);

//    Create the acoustics mesh that the CFD solution is mapped onto. The mesh can be relatively coarse. Note that the finer the mesh the less damping is introduced by the stabilization, this is present to stabilize submesh physical phenomena like vorticity waves. The acoustic boundary layer is not resolved at the walls since slip (and adiabatic) conditions are used there. One or two boundary layer mesh elements is enough to resolve the background flow profile near the wall.
//    In the Mesh toolbar, click Add Mesh and choose Add Mesh.

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

//    In the Settings window for Mesh, type Mesh - Acoustics in the Label text field.

    model.component("comp1").mesh("mesh2").label("Mesh - Acoustics");

//    In the Mesh toolbar, click Free Tetrahedral.

    model.component("comp1").mesh("mesh2").create("ftet1", "FreeTet");

//    In the Model Builder window, click Size.
//    In the Settings window for Size, locate the Element Size section.
//    Click the Custom button.

    model.component("comp1").mesh("mesh2").feature("size").set("custom", true);

//    Locate the Element Size Parameters section.
//    In the Maximum element size text field, type Dmain/8.

    model.component("comp1").mesh("mesh2").feature("size").set("hmax", "Dmain/8");

//    In the Minimum element size text field, type Dmain/15.

    model.component("comp1").mesh("mesh2").feature("size").set("hmin", "Dmain/15");

//    In the Model Builder window, click Free Tetrahedral 1.
//    In the Settings window for Free Tetrahedral, locate the Domain Selection section.
//    From the Geometric entity level list, select Domain.

    model.component("comp1").mesh("mesh2").feature("ftet1").selection().geom("geom1", 3);

//    Select Domains 2, 3, 4, 5, 7, 8.

    model.component("comp1").mesh("mesh2").feature("ftet1").selection().set(2, 3, 4, 5, 7, 8);

//    Add a <l>Size</l> feature to the opening of the resonator, as the flow is likely to have large gradients there.
//    Right-click Free Tetrahedral 1 and choose Size.

    model.component("comp1").mesh("mesh2").feature("ftet1").create("size1", "Size");

//    In the Settings window for Size, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").mesh("mesh2").feature("ftet1").feature("size1").selection().geom("geom1", 2);

//    Select Boundary 26.

    model.component("comp1").mesh("mesh2").feature("ftet1").feature("size1").selection().set(26);

//    Locate the Element Size section.
//    Click the Custom button.

    model.component("comp1").mesh("mesh2").feature("ftet1").feature("size1").set("custom", true);

//    Locate the Element Size Parameters section.
//    Select the Maximum element size checkbox.

    model.component("comp1").mesh("mesh2").feature("ftet1").feature("size1").set("hmaxactive", true);

//    In the associated text field, type Dmain/15.

    model.component("comp1").mesh("mesh2").feature("ftet1").feature("size1").set("hmax", "Dmain/15");

//    Click Build Selected.

    model.component("comp1").mesh("mesh2").run("ftet1");

//    In the Mesh toolbar, click Swept.

    model.component("comp1").mesh("mesh2").create("swe1", "Sweep");

//    Right-click Swept 1 and choose Distribution.

    model.component("comp1").mesh("mesh2").feature("swe1").create("dis1", "Distribution");

//    In the Settings window for Distribution, locate the Distribution section.
//    In the Number of elements text field, type 16.

    model.component("comp1").mesh("mesh2").feature("swe1").feature("dis1").set("numelem", 16);

//    Click Build Selected.

    model.component("comp1").mesh("mesh2").run("swe1");

//    In the Mesh toolbar, click Boundary Layers.

    model.component("comp1").mesh("mesh2").create("bl1", "BndLayer");
    model.component("comp1").mesh("mesh2").feature("bl1").create("blp", "BndLayerProp");
    model.component("comp1").mesh("mesh2").feature("bl1").selection().geom(3);
    model.component("comp1").mesh("mesh2").feature("bl1").selection().set();
    model.component("comp1").mesh("mesh2").feature("bl1").selection().allGeom();

//    In the Settings window for Boundary Layers, click to expand the Transition section.
//    Clear the Smooth transition to interior mesh checkbox.

    model.component("comp1").mesh("mesh2").feature("bl1").set("smoothtransition", false);

//    In the Model Builder window, click Boundary Layer Properties.
//    In the Settings window for Boundary Layer Properties, locate the Geometric Entity Selection section.
//    From the Selection list, select Walls.

    model.component("comp1").mesh("mesh2").feature("bl1").feature("blp").selection().named("sel2");

//    Locate the Layers section.
//    In the Number of layers text field, type 2.

    model.component("comp1").mesh("mesh2").feature("bl1").feature("blp").set("blnlayers", 2);

//    From the Thickness specification list, select First layer.

    model.component("comp1").mesh("mesh2").feature("bl1").feature("blp").set("inittype", "blhmin");

//    In the Thickness text field, type Dmain/40.

    model.component("comp1").mesh("mesh2").feature("bl1").feature("blp").set("blhmin", "Dmain/40");

//    Click Build All.

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

//    The acoustics mesh should look like the figure above.
//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Physics interfaces in study subsection.
//    In the table, enter the following settings:
//    Find the Studies subsection.
//    In the Select Study tree, select Preset Studies for Selected Multiphysics > Mapping.
//    Click Add Study in the window toolbar.

    model.study().create("std2");
    model.study("std2").create("mapp", "Mapping");
    model.study("std2").feature("mapp").set("solnum", "auto");
    model.study("std2").feature("mapp").set("notsolnum", "auto");
    model.study("std2").feature("mapp").set("outputmap", new String[]{});
    model.study("std2").feature("mapp").setSolveFor("/physics/spf", false);
    model.study("std2").feature("mapp").setSolveFor("/physics/lnsf", false);
    model.study("std2").feature("mapp").setSolveFor("/physics/lnsf", false);

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Mapping, locate the Data to Map section.
//    From the Source list, select Study 1 - CFD, Stationary.

    model.study("std2").feature("mapp").set("notstudy", "std1");

//    From the Solution list, select Solution 1 (sol1).

    model.study("std2").feature("mapp").set("notsol", "sol1");

//    From the Parameter value (Ma) list, select Automatic (all solutions).

    model.study("std2").feature("mapp").set("notsolnum", "all");

//    Expand the <l>Mesh Selection</l> section to verify that the destination mesh is selected.
//    In the Model Builder window, click Study 2.
//    In the Settings window for Study, type Study 2 - Mapping in the Label text field.

    model.study("std2").label("Study 2 - Mapping");

//    In the Study toolbar, click Compute.

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

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

//    Create two plots that compare the original CFD solution (evaluated on the CFD mesh) with the mapped solution (evaluated on the acoustics mesh).
//    In the Results toolbar, click 1D Plot Group.

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

//    In the Settings window for 1D Plot Group, type Mapping Comparison: z velocity in the Label text field.

    model.result("pg4").label("Mapping Comparison: z velocity");

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

    model.result("pg4").set("titletype", "label");

//    Right-click Mapping Comparison: z velocity and choose Line Graph.

    model.result("pg4").create("lngr1", "LineGraph");
    model.result("pg4").feature("lngr1").set("markerpos", "datapoints");
    model.result("pg4").feature("lngr1").set("linewidth", "preference");
    model.result("pg4").feature("lngr1").set("evaluationsettings", "parent");

//    In the Settings window for Line Graph, locate the Selection section.
//    Select the Activate Selection toggle button.
//    Select Edge 12.

    model.result("pg4").feature("lngr1").selection().set(12);

//    Locate the y-Axis Data section.
//    In the Expression text field, type w.

    model.result("pg4").feature("lngr1").set("expr", "w");

//    Locate the x-Axis Data section.
//    From the Parameter list, select Expression.

    model.result("pg4").feature("lngr1").set("xdata", "expr");

//    In the Expression text field, type x.

    model.result("pg4").feature("lngr1").set("xdataexpr", "x");

//    Locate the Legends section.
//    Select the Show legends checkbox.

    model.result("pg4").feature("lngr1").set("legend", true);

//    From the Legends list, select Evaluated.

    model.result("pg4").feature("lngr1").set("legendmethod", "evaluated");

//    In the Legend text field, type Ma = eval(Ma).

    model.result("pg4").feature("lngr1").set("legendpattern", "Ma = eval(Ma)");
    model.result("pg4").run();

//    In the Model Builder window, right-click Mapping Comparison: z velocity and choose Line Graph.

    model.result("pg4").create("lngr2", "LineGraph");
    model.result("pg4").feature("lngr2").set("markerpos", "datapoints");
    model.result("pg4").feature("lngr2").set("linewidth", "preference");
    model.result("pg4").feature("lngr2").set("evaluationsettings", "parent");

//    In the Settings window for Line Graph, locate the Data section.
//    From the Dataset list, select Study 2 - Mapping/Solution 3 (sol3).

    model.result("pg4").feature("lngr2").set("data", "dset3");

//    Select Edge 12.

    model.result("pg4").feature("lngr2").selection().set(12);

//    Click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Background Fluid Flow Coupling 1 > Mapped velocity - m/s > bffc1.u_mapz - Mapped velocity, z-component.

    model.result("pg4").feature("lngr2").set("expr", "bffc1.u_mapz");
    model.result("pg4").feature("lngr2").set("descr", "Mapped velocity, z-component");

//    Locate the x-Axis Data section.
//    From the Parameter list, select Expression.

    model.result("pg4").feature("lngr2").set("xdata", "expr");

//    In the Expression text field, type x.

    model.result("pg4").feature("lngr2").set("xdataexpr", "x");

//    Click to expand the Coloring and Style section.
//    Find the Line style subsection.
//    From the Line list, select Dashed.

    model.result("pg4").feature("lngr2").set("linestyle", "dashed");

//    Locate the Legends section.
//    Select the Show legends checkbox.

    model.result("pg4").feature("lngr2").set("legend", true);

//    From the Legends list, select Evaluated.

    model.result("pg4").feature("lngr2").set("legendmethod", "evaluated");

//    In the Legend text field, type Ma = eval(Ma).

    model.result("pg4").feature("lngr2").set("legendpattern", "Ma = eval(Ma)");

//    In the Mapping Comparison: z velocity toolbar, click Plot.

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

//    Right-click Mapping Comparison: z velocity and choose Duplicate.

    model.result().duplicate("pg5", "pg4");
    model.result("pg5").run();

//    In the Model Builder window, click Mapping Comparison: z velocity 1.
//    In the Settings window for 1D Plot Group, type Mapping Comparison: Dynamic Viscosity in the Label text field.

    model.result("pg5").label("Mapping Comparison: Dynamic Viscosity");
    model.result("pg5").run();

//    In the Model Builder window, click Line Graph 1.
//    In the Settings window for Line Graph, locate the y-Axis Data section.
//    In the Expression text field, type spf.mu_eff.

    model.result("pg5").feature("lngr1").set("expr", "spf.mu_eff");
    model.result("pg5").run();

//    In the Model Builder window, click Line Graph 2.
//    In the Settings window for Line Graph, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Background Fluid Flow Coupling 1 > bffc1.mu_eff_map - Mapped turbulent viscosity - Pa·s.

    model.result("pg5").feature("lngr2").set("expr", "bffc1.mu_eff_map");
    model.result("pg5").feature("lngr2").set("descr", "Mapped turbulent viscosity");

//    In the Mapping Comparison: Dynamic Viscosity toolbar, click Plot.

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

//    Now set up the acoustics model solving the Linearized Navier–Stokes equations for the background mean flow configuration with Ma = 0.05 and Ma = 0.1. The no-flow case (Ma = 0) is solved using Pressure Acoustics afterward. First, create variables and set up the PMLs.
//    In the Model Builder window, right-click Component 1 (comp1) > Definitions and choose Variables.

    model.component("comp1").variable().create("var1");

//    In the Settings window for Variables, type Variables: Plane Wave in the Label text field.

    model.component("comp1").variable("var1").label("Variables: Plane Wave");

//    Locate the Variables section.
//    Click Load from File.
//    Browse to the model's Application Library folder and double-click the file helmholtz_resonator_with_flow_variables.txt.
//    To import content from file, use:
//    model.component("comp1").variable("var1").loadFile("FILENAME");
    model.component("comp1").variable("var1").set("k0", "lnsf.omega/(lnsf.c0+Uin)", "Convected wave number");
    model.component("comp1").variable("var1").set("pb", "1[Pa]*exp(-i*k0*z)", "Background acoustic pressure");
    model.component("comp1").variable("var1").set("ub", "0", "Background acoustic x-velocity");
    model.component("comp1").variable("var1").set("vb", "0", "Background acoustic y-velocity");
    model.component("comp1").variable("var1")
         .set("wb", "-1/(lnsf.iomega*lnsf.rho0)*d(pb,z)", "Background acoustic z-velocity");
    model.component("comp1").variable("var1")
         .set("Tb", "lnsf.alpha_p*lnsf.T0/(lnsf.rho0*lnsf.Cp)*pb", "Background acoustic temperature");

//    These variables define a plane wave moving in the positive <eqv>z</eqv> direction including the effect of a uniform flow. This wave is used as the source of the model.
//    In the Definitions toolbar, click Nonlocal Couplings and choose Integration.

    model.component("comp1").cpl().create("intop1", "Integration");
    model.component("comp1").cpl("intop1").set("axisym", true);

//    In the Settings window for Integration, locate the Source Selection section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").cpl("intop1").selection().geom("geom1", 2);

//    Select Boundary 6.

    model.component("comp1").cpl("intop1").selection().set(6);

//    In the Operator name text field, type intop_in.

    model.component("comp1").cpl("intop1").set("opname", "intop_in");

//    In the Definitions toolbar, click Nonlocal Couplings and choose Integration.

    model.component("comp1").cpl().create("intop2", "Integration");
    model.component("comp1").cpl("intop2").set("axisym", true);

//    In the Settings window for Integration, locate the Source Selection section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").cpl("intop2").selection().geom("geom1", 2);

//    Select Boundary 18.

    model.component("comp1").cpl("intop2").selection().set(18);

//    In the Operator name text field, type intop_out.

    model.component("comp1").cpl("intop2").set("opname", "intop_out");

//    In the Definitions toolbar, click Perfectly Matched Layer.

    model.component("comp1").coordSystem().create("pml1", "PML");

//    Select Domains 1, 6.

    model.component("comp1").coordSystem("pml1").selection().set(1, 6);

//    Inspect, the <l>Model Input</l> and <l>Fluid Properties</l> sections. Notice that the background mean flow properties are automatically picked up.
//    In the Model Builder window, click Wall 1.
//    In the Settings window for Wall, locate the Mechanical section.
//    From the Mechanical condition list, select Slip (perfect).

    model.component("comp1").physics("lnsf").feature("wall1").set("MechanicalCondition", "Slip");

//    Locate the Thermal section.
//    From the Thermal condition list, select Adiabatic.

    model.component("comp1").physics("lnsf").feature("wall1").set("ThermalCondition", "Adiabatic");

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

    model.component("comp1").physics("lnsf").create("sym1", "Symmetry", 2);

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

    model.component("comp1").physics("lnsf").feature("sym1").selection().named("sel1");

//    In the Physics toolbar, click Domains and choose Background Acoustic Fields.

    model.component("comp1").physics("lnsf").create("baf1", "BackgroundAcousticFields", 3);

//    Select Domain 2.

    model.component("comp1").physics("lnsf").feature("baf1").selection().set(2);

//    In the Settings window for Background Acoustic Fields, locate the Background Acoustic Fields section.
//    In the \[p_\textrm{b}\] text field, type pb.

    model.component("comp1").physics("lnsf").feature("baf1").set("p", "pb");

//    Specify the \[\mathbf{u}_\textrm{b}\] vector as

    model.component("comp1").physics("lnsf").feature("baf1").set("u", new String[]{"ub", "vb", "wb"});

//    In the \[T_\textrm{b}\] text field, type Tb.

    model.component("comp1").physics("lnsf").feature("baf1").set("T", "Tb");

//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Physics interfaces in study subsection.
//    In the table, enter the following settings:
//    Find the Multiphysics couplings in study subsection.
//    In the table, enter the following settings:
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Frequency Domain.
//    Click Add Study in the window toolbar.

    model.study().create("std3");
    model.study("std3").create("freq", "Frequency");
    model.study("std3").feature("freq").setSolveFor("/physics/spf", false);
    model.study("std3").feature("freq").setSolveFor("/multiphysics/bffc1", false);

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    In the Frequencies text field, type range(50,10,200).

    model.study("std3").feature("freq").set("plist", "range(50,10,200)");

//    Click to expand the Values of Dependent Variables section.
//    Find the Values of variables not solved for subsection.
//    From the Settings list, select User controlled.

    model.study("std3").feature("freq").set("usesol", true);

//    From the Method list, select Solution.

    model.study("std3").feature("freq").set("notsolmethod", "sol");

//    From the Study list, select Study 2 - Mapping, Mapping.

    model.study("std3").feature("freq").set("notstudy", "std2");

//    From the Parameter value (Ma) list, select Automatic (all solutions).

    model.study("std3").feature("freq").set("notsolnum", "all");

//    Under the <l>Mesh Selection</l> section check that the acoustics mesh is used.
//    Click to expand the Mesh Selection section.
//    Add an auxiliary sweep to solve for the two Mach numbers.
//    Click to expand the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

    model.study("std3").feature("freq").set("useparam", true);

//    Click Add.

    model.study("std3").feature("freq").setIndex("pname_aux", "Ma", 0);
    model.study("std3").feature("freq").setIndex("plistarr_aux", "", 0);
    model.study("std3").feature("freq").setIndex("punit_aux", "", 0);

    return model;
  }

  public static Model run3(Model model) {
    model.study("std3").feature("freq").setIndex("pname_aux", "Ma", 0);
    model.study("std3").feature("freq").setIndex("plistarr_aux", "", 0);
    model.study("std3").feature("freq").setIndex("punit_aux", "", 0);

//    In the table, enter the following settings:

    model.study("std3").feature("freq").setIndex("plistarr_aux", "0.05 0.1", 0);
    model.study("std3").feature("freq").setIndex("punit_aux", "", 0);

//    From the Run continuation for list, select Manual.

    model.study("std3").feature("freq").set("pcontinuationmode", "manual");

//    From the Continuation parameter list, select freq.

    model.study("std3").feature("freq").set("pcontinuation", "freq");

//    In the Model Builder window, click Study 3.
//    In the Settings window for Study, locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std3").setGenPlots(false);

//    In the Label text field, type Study 3 - Acoustics, Ma = 0.05 and Ma = 0.1.

    model.study("std3").label("Study 3 - Acoustics, Ma = 0.05 and Ma = 0.1");

//    In the Study toolbar, click Show Default Solver.

    model.study("std3").showAutoSequences("all");

//    In the Model Builder window, expand the Solution 4 (sol4) node.
//    In the Model Builder window, expand the Study 3 - Acoustics, Ma = 0.05 and Ma = 0.1 > Solver Configurations > Solution 4 (sol4) > Stationary Solver 1 node.
//    Right-click Study 3 - Acoustics, Ma = 0.05 and Ma = 0.1 > Solver Configurations > Solution 4 (sol4) > Stationary Solver 1 > Suggested Iterative Solver (GMRES with Direct Precond.) (lnsf) and choose Enable.

    model.sol("sol4").feature("s1").feature("i1").active(true);

//    In the Study toolbar, click Compute.

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

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

//    Now, add Pressure Acoustics to model the no-flow case (Ma = 0). A background pressure field is also used here to excite the model to simplify postprocessing and get a similar setup as for the linearized Navier–Stokes model. A port condition would normally have been preferred for this waveguide setup.
//    In the Home toolbar, click Add Physics to open the Add Physics window.
//    Find the Physics interfaces in study subsection.
//    In the table, enter the following settings:
//    In the tree, select Acoustics > Pressure Acoustics > Pressure Acoustics, Frequency Domain (acpr).
//    Click Add to Component 1 in the window toolbar.

    model.component("comp1").physics().create("acpr", "PressureAcoustics", "geom1");

    model.study("std1").feature("wdi").setSolveFor("/physics/acpr", false);
    model.study("std1").feature("stat").setSolveFor("/physics/acpr", false);
    model.study("std2").feature("mapp").setSolveFor("/physics/acpr", false);
    model.study("std3").feature("freq").setSolveFor("/physics/acpr", false);

//    In the Home toolbar, click Add Physics to close the Add Physics window.
//    In the Physics toolbar, click Domains and choose Narrow Region Acoustics.

    model.component("comp1").physics("acpr").create("nra1", "NarrowRegionAcousticsModel", 3);

//    Select Domain 7.

    model.component("comp1").physics("acpr").feature("nra1").selection().set(7);

//    In the Settings window for Narrow Region Acoustics, locate the Duct Properties section.
//    From the Duct type list, select Circular duct.

    model.component("comp1").physics("acpr").feature("nra1").set("DuctType", "CircularDuct");

//    In the \[a\] text field, type Dneck/2.

    model.component("comp1").physics("acpr").feature("nra1").set("a", "Dneck/2");

//    In the Physics toolbar, click Domains and choose Background Pressure Field.

    model.component("comp1").physics("acpr").create("bpf1", "BackgroundPressureField", 3);

//    Select Domain 2.

    model.component("comp1").physics("acpr").feature("bpf1").selection().set(2);

//    In the Settings window for Background Pressure Field, locate the Background Pressure Field section.
//    In the \[p_0\] text field, type 1.

    model.component("comp1").physics("acpr").feature("bpf1").set("pamp", 1);

//    From the \[c\] list, select From material.

    model.component("comp1").physics("acpr").feature("bpf1").set("c_mat", "from_mat");

//    Specify the \[\mathbf{e}_k\] vector as

    model.component("comp1").physics("acpr").feature("bpf1").set("dir", new int[]{0, 0, 1});

//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Physics interfaces in study subsection.
//    In the table, enter the following settings:
//    Find the Multiphysics couplings in study subsection.
//    In the table, enter the following settings:
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Frequency Domain.
//    Click Add Study in the window toolbar.

    model.study().create("std4");
    model.study("std4").create("freq", "Frequency");
    model.study("std4").feature("freq").setSolveFor("/physics/spf", false);
    model.study("std4").feature("freq").setSolveFor("/physics/lnsf", false);
    model.study("std4").feature("freq").setSolveFor("/multiphysics/bffc1", false);

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    In the Frequencies text field, type range(50,10,200).

    model.study("std4").feature("freq").set("plist", "range(50,10,200)");

//    In the Model Builder window, click Study 4.
//    In the Settings window for Study, locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std4").setGenPlots(false);

//    In the Label text field, type Study 4 - Acoustics, Ma = 0.

    model.study("std4").label("Study 4 - Acoustics, Ma = 0");

//    In the Study toolbar, click Compute.

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

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

//    Results
//    Finally, analyze the acoustic results and compute the transmission loss TL of the model.
//    In the Results toolbar, click 3D Plot Group.

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

//    In the Settings window for 3D Plot Group, type Acoustics: Pressure, Ma = 0 in the Label text field.

    model.result("pg6").label("Acoustics: Pressure, Ma = 0");

//    Locate the Data section.
//    From the Dataset list, select Study 4 - Acoustics, Ma = 0/Solution 5 (sol5).

    model.result("pg6").set("data", "dset5");

//    From the Parameter value (freq (Hz)) list, select 150.

    model.result("pg6").setIndex("looplevel", 11, 0);

//    Click to expand the Selection section.
//    From the Geometric entity level list, select Domain.

    model.result("pg6").selection().geom("geom1", 3);

//    Select Domains 3, 4, 5, 7, 8.

    model.result("pg6").selection().geom("geom1", 3);
    model.result("pg6").selection().set(3, 4, 5, 7, 8);

//    Select the Apply to dataset edges checkbox.

    model.result("pg6").set("applyselectiontodatasetedges", true);

//    Right-click Acoustics: Pressure, Ma = 0 and choose Surface.

    model.result("pg6").create("surf1", "Surface");
    model.result("pg6").feature("surf1").set("evaluationsettings", "parent");

//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type acpr.p_t.

    model.result("pg6").feature("surf1").set("expr", "acpr.p_t");

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

    model.result("pg6").feature("surf1").set("colortable", "Wave");

//    From the Scale list, select Linear symmetric.

    model.result("pg6").feature("surf1").set("colorscalemode", "linearsymmetric");

//    In the Acoustics: Pressure, Ma = 0 toolbar, click Plot.

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

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

    model.result().create("pg7", "PlotGroup3D");
    model.result("pg7").set("applyselectiontodatasetedges", false);
    model.result("pg7").run();

//    In the Settings window for 3D Plot Group, type Acoustics: Pressure, Ma = 0.1 in the Label text field.

    model.result("pg7").label("Acoustics: Pressure, Ma = 0.1");

//    Locate the Data section.
//    From the Dataset list, select Study 3 - Acoustics, Ma = 0.05 and Ma = 0.1/Solution 4 (sol4).

    model.result("pg7").set("data", "dset4");

//    From the Parameter value (freq (Hz)) list, select 150.

    model.result("pg7").setIndex("looplevel", 11, 0);

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

    model.result("pg7").selection().geom("geom1", 3);

//    Select Domains 3, 4, 5, 7, 8.

    model.result("pg7").selection().geom("geom1", 3);
    model.result("pg7").selection().set(3, 4, 5, 7, 8);

//    Select the Apply to dataset edges checkbox.

    model.result("pg7").set("applyselectiontodatasetedges", true);

//    Right-click Acoustics: Pressure, Ma = 0.1 and choose Surface.

    model.result("pg7").create("surf1", "Surface");
    model.result("pg7").feature("surf1").set("evaluationsettings", "parent");

//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type lnsf.p_t.

    model.result("pg7").feature("surf1").set("expr", "lnsf.p_t");

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

    model.result("pg7").feature("surf1").set("colortable", "Wave");

//    From the Scale list, select Linear symmetric.

    model.result("pg7").feature("surf1").set("colorscalemode", "linearsymmetric");

//    In the Acoustics: Pressure, Ma = 0.1 toolbar, click Plot.

    model.result("pg7").run();
    model.result("pg7").run();
    model.result("pg7").setIndex("looplevel", 1, 1);
    model.result("pg7").run();
    model.result("pg7").setIndex("looplevel", 2, 1);

//    Right-click Surface 1 and choose Duplicate.

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

//    In the Model Builder window, click Acoustics: Pressure, Ma = 0.1.1.
//    In the Settings window for 3D Plot Group, type Acoustics: Sound Pressure Level, Ma = 0.05 in the Label text field.

    model.result("pg8").label("Acoustics: Sound Pressure Level, Ma = 0.05");

//    Locate the Data section.
//    From the Parameter value (Ma) list, select 0.05.

    model.result("pg8").setIndex("looplevel", 1, 1);
    model.result("pg8").run();

//    In the Model Builder window, click Surface 1.
//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type lnsf.Lp.

    model.result("pg8").feature("surf1").set("expr", "lnsf.Lp");

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

    model.result("pg8").feature("surf1").set("colortable", "Rainbow");

//    From the Scale list, select Linear.

    model.result("pg8").feature("surf1").set("colorscalemode", "linear");

//    Click to expand the Quality section.
//    From the Evaluation settings list, select Manual.

    model.result("pg8").feature("surf1").set("evaluationsettings", "manual");

//    From the Resolution list, select Finer.

    model.result("pg8").feature("surf1").set("resolution", "finer");

//    In the Acoustics: Sound Pressure Level, Ma = 0.05 toolbar, click Plot.

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

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

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

//    In the Settings window for 1D Plot Group, type Transmission Loss in the Label text field.

    model.result("pg9").label("Transmission Loss");

//    Locate the Data section.
//    From the Dataset list, select None.

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

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

    model.result("pg9").set("titletype", "label");

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

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

//    In the associated text field, type f (Hz).

    model.result("pg9").set("xlabel", "f (Hz)");

//    Select the y-axis label checkbox.

    model.result("pg9").set("ylabelactive", true);

//    In the associated text field, type TL (dB).

    model.result("pg9").set("ylabel", "TL (dB)");

//    Locate the Axis section.
//    Select the Manual axis limits checkbox.

    model.result("pg9").set("axislimits", true);

//    In the y minimum text field, type 0.

    model.result("pg9").set("ymin", 0);

//    In the y maximum text field, type 40.

    model.result("pg9").set("ymax", 40);

//    In the x minimum text field, type 50.

    model.result("pg9").set("xmin", 50);

//    In the x maximum text field, type 200.

    model.result("pg9").set("xmax", 200);

//    Right-click Transmission Loss and choose Global.

    model.result("pg9").create("glob1", "Global");
    model.result("pg9").feature("glob1").set("markerpos", "datapoints");
    model.result("pg9").feature("glob1").set("linewidth", "preference");

//    In the Settings window for Global, locate the Data section.
//    From the Dataset list, select Study 4 - Acoustics, Ma = 0/Solution 5 (sol5).

    model.result("pg9").feature("glob1").set("data", "dset5");

//    Locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg9").feature("glob1").setIndex("expr", "20*log10(abs(intop_in(1[Pa])/intop_out(acpr.p_t)))", 0);
    model.result("pg9").feature("glob1").setIndex("unit", "", 0);
    model.result("pg9").feature("glob1").setIndex("descr", "Ma = 0", 0);

//    Click to expand the Coloring and Style section.
//    Find the Line markers subsection.
//    From the Marker list, select Point.

    model.result("pg9").feature("glob1").set("linemarker", "point");
    model.result("pg9").run();

//    In the Model Builder window, right-click Transmission Loss and choose Global.

    model.result("pg9").create("glob2", "Global");
    model.result("pg9").feature("glob2").set("markerpos", "datapoints");
    model.result("pg9").feature("glob2").set("linewidth", "preference");

//    In the Settings window for Global, locate the Data section.
//    From the Dataset list, select Study 3 - Acoustics, Ma = 0.05 and Ma = 0.1/Solution 4 (sol4).

    model.result("pg9").feature("glob2").set("data", "dset4");

//    Locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg9").feature("glob2").setIndex("expr", "20*log10(abs(intop_in(pb)/intop_out(lnsf.p_t)))", 0);
    model.result("pg9").feature("glob2").setIndex("unit", "", 0);
    model.result("pg9").feature("glob2").setIndex("descr", "", 0);

//    Locate the x-Axis Data section.
//    From the Axis source data list, select freq.

    model.result("pg9").feature("glob2").set("xdatasolnumtype", "level1");

//    Locate the Coloring and Style section.
//    Find the Line markers subsection.
//    From the Marker list, select Point.

    model.result("pg9").feature("glob2").set("linemarker", "point");

//    The last thing to do is to disable the PMLs in the CFD study. This is to make sure that, if the study is solved again then the results will be correct. The CFD interface is not supported inside domains with PMLs.
//    In the Model Builder window, under Study 1 - CFD, click Step 1: Wall Distance Initialization.
//    In the Settings window for Wall Distance Initialization, locate the Physics and Variables Selection section.
//    Select the Modify model configuration for study step checkbox.

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

//    In the tree, select Component 1 (comp1) > Definitions > Artificial Domains > Perfectly Matched Layer 1 (pml1).
//    Right-click and choose Disable.

    model.study("std1").feature("wdi").set("disabledcoordinatesystems", new String[]{"pml1"});

//    In the Model Builder window, click Step 2: Stationary.
//    In the Settings window for Stationary, locate the Physics and Variables Selection section.
//    Select the Modify model configuration for study step checkbox.

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

//    In the tree, select Component 1 (comp1) > Definitions > Artificial Domains > Perfectly Matched Layer 1 (pml1).
//    Right-click and choose Disable.

    model.study("std1").feature("stat").set("disabledcoordinatesystems", new String[]{"pml1"});

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

    model.title("Helmholtz Resonator with Flow: Interaction of Flow and Acoustics");

    model
         .description("Helmholtz resonators are used in exhaust systems, as they can attenuate a specific narrow frequency band. The presence of a flow in the system alters the acoustic properties of the resonator and the transmission loss of the subsystem. In this tutorial model, a Helmholtz resonator is located as a side branch to a main duct. The transmission loss through the main duct is investigated when a flow is introduced.\n\nThe mean flow is calculated with the SST turbulence model for Ma = 0.05 and Ma = 0.1. The acoustics problem is then solved using the Linearized Navier\u2013Stokes, Frequency Domain (LNS) interface. The mean flow velocity, pressure, and turbulent viscosity are coupled to the LNS model. Results are compared to measurements found in a journal paper and the amplitudes and resonance locations show good agreement with the measurement data (as seen in the 1D plot). The balance between attenuation and flow effects needs to be modeled rigorously in order for the resonance location to be correct.");

    return model;
  }

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

}
