/*
 * porous_absorber_time_domain.java
 */

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

/** Model exported on May 12 2026, 12:38 by COMSOL 6.4.0.418. */
public class porous_absorber_time_domain {

  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 2D.
//    Click Done.

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

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

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

//    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("L0", "1.5[m]");
    model.param().descr("L0", "Computational domain height");
    model.param().set("w0", "5[cm]");
    model.param().descr("w0", "Porous layer width");
    model.param().set("xs", "-1[m]");
    model.param().descr("xs", "Source location, x-coordinate");
    model.param().set("xr", "1[m]");
    model.param().descr("xr", "Receiver location, x-coordinate");
    model.param().set("ys", "0.5[m]");
    model.param().descr("ys", "Source and receiver location, y-coordinate");
    model.param().set("B", "0.045[m]");
    model.param().descr("B", "Pulse width");

//    Create an <l>Analytic</l> function for the initial pressure pulse that initiates the sound.
//    In the Home toolbar, click Functions and choose Global > Analytic.

    model.func().create("an1", "Analytic");

//    In the Settings window for Analytic, type p_init in the Function name text field.

    model.func("an1").set("funcname", "p_init");

//    Locate the Definition section.
//    In the Expression text field, type (1 - ((x - xs)^2 + (y - ys)^2)/B^2)*exp(-((x - xs)^2 + (y - ys)^2)/B^2/2).

    model.func("an1").set("expr", "(1 - ((x - xs)^2 + (y - ys)^2)/B^2)*exp(-((x - xs)^2 + (y - ys)^2)/B^2/2)");

//    In the Arguments text field, type x, y.

    model.func("an1").set("args", "x, y");

//    Then, create four <l>Partial Fraction Fit</l> functions for the partial fraction representation of the frequency-dependent data used in the model.
//    Make sure that the results fulfill the causality and reality conditions, that is, that the poles have negative real parts, as well as the passivity condition, that is, that the functions have non-negative real parts.
//    In the Home toolbar, click Functions and choose Global > Partial Fraction Fit.

    model.func().create("pff1", "PartialFraction");

//    In the Settings window for Partial Fraction Fit, type beta_porous in the Function name text field.

    model.func("pff1").set("funcname", "beta_porous");

//    Locate the Data section.
//    Click Browse.
//    Browse to the model's Application Library folder and double-click the file porous_absorber_time_domain_compressibility.txt.

    model.func("pff1").set("filename", "porous_absorber_time_domain_compressibility.txt");

//    Click Fit Parameters.

    model.func("pff1").run();

//    Click Plot.
//    In the Function Plot window, click x-Axis Log Scale in the window toolbar.
//    Right-click Partial Fraction Fit 1 (beta_porous) and choose Duplicate.

    model.func().duplicate("pff2", "pff1");

//    In the Settings window for Partial Fraction Fit, type rho_porous in the Function name text field.

    model.func("pff2").set("funcname", "rho_porous");

//    Locate the Data section.
//    Click Browse.
//    Browse to the model's Application Library folder and double-click the file porous_absorber_time_domain_density.txt.

    model.func("pff2").set("filename", "porous_absorber_time_domain_density.txt");

//    Click Fit Parameters.

    model.func("pff2").run();

//    Click Plot.
//    In the Function Plot window, click x-Axis Log Scale in the window toolbar.
//    Right-click Partial Fraction Fit 2 (rho_porous) and choose Duplicate.

    model.func().duplicate("pff3", "pff2");

//    In the Settings window for Partial Fraction Fit, type Y_5cm in the Function name text field.

    model.func("pff3").set("funcname", "Y_5cm");

//    Locate the Data section.
//    Click Browse.
//    Browse to the model's Application Library folder and double-click the file porous_absorber_time_domain_admittance.txt.

    model.func("pff3").set("filename", "porous_absorber_time_domain_admittance.txt");

//    Click Fit Parameters.

    model.func("pff3").run();

//    Click Plot.
//    In the Function Plot window, click x-Axis Log Scale in the window toolbar.
//    Right-click Partial Fraction Fit 3 (Y_5cm) and choose Duplicate.

    model.func().duplicate("pff4", "pff3");

//    In the Settings window for Partial Fraction Fit, type Y_15cm in the Function name text field.

    model.func("pff4").set("funcname", "Y_15cm");

//    Locate the Data Column Settings section.
//    In the table, enter the following settings:

    model.func("pff4").setEntry("columnType", "col4", "real");
    model.func("pff4").setEntry("columnType", "col5", "imag");

//    Click Fit Parameters.

    model.func("pff4").run();

//    Click Plot.
//    In the Function Plot window, click x-Axis Log Scale in the window toolbar.
//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").create("r1", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type 3*L0.

    model.component("comp1").geom("geom1").feature("r1").set("size", new String[]{"3*L0", "1"});

//    In the Height text field, type L0.

    model.component("comp1").geom("geom1").feature("r1").set("size", new String[]{"3*L0", "L0"});

//    Locate the Position section.
//    In the x text field, type -1.5*L0.

    model.component("comp1").geom("geom1").feature("r1").set("pos", new String[]{"-1.5*L0", "0"});

//    Click to expand the Layers section.
//    Select the Layers to the left checkbox.

    model.component("comp1").geom("geom1").feature("r1").set("layerleft", true);

//    Select the Layers to the right checkbox.

    model.component("comp1").geom("geom1").feature("r1").set("layerright", true);

//    Clear the Layers on bottom checkbox.

    model.component("comp1").geom("geom1").feature("r1").set("layerbottom", false);

//    Select the Layers on top checkbox.

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

//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("r1").setIndex("layer", "L0/5", 0);

//    Click Build Selected.

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

//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").create("r2", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type 3*L0.

    model.component("comp1").geom("geom1").feature("r2").set("size", new String[]{"3*L0", "1"});

//    In the Height text field, type w0.

    model.component("comp1").geom("geom1").feature("r2").set("size", new String[]{"3*L0", "w0"});

//    Locate the Position section.
//    In the x text field, type -1.5*L0.

    model.component("comp1").geom("geom1").feature("r2").set("pos", new String[]{"-1.5*L0", "0"});

//    In the y text field, type -w0.

    model.component("comp1").geom("geom1").feature("r2").set("pos", new String[]{"-1.5*L0", "-w0"});

//    Locate the Layers section.
//    Select the Layers to the right checkbox.

    model.component("comp1").geom("geom1").feature("r2").set("layerright", true);

//    Select the Layers to the left checkbox.

    model.component("comp1").geom("geom1").feature("r2").set("layerleft", true);

//    Clear the Layers on bottom checkbox.

    model.component("comp1").geom("geom1").feature("r2").set("layerbottom", false);

//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("r2").setIndex("layer", "L0/5", 0);

//    Click Build Selected.

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

//    In the Geometry toolbar, click Point.

    model.component("comp1").geom("geom1").create("pt1", "Point");

//    In the Settings window for Point, locate the Point section.
//    In the x text field, type xs.

    model.component("comp1").geom("geom1").feature("pt1").setIndex("p", "xs", 0);

//    In the y text field, type ys.

    model.component("comp1").geom("geom1").feature("pt1").setIndex("p", "ys", 1);

//    Click Build Selected.

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

//    Right-click Point 1 (pt1) and choose Duplicate.

    model.component("comp1").geom("geom1").feature().duplicate("pt2", "pt1");

//    In the Settings window for Point, locate the Point section.
//    In the x text field, type xr.

    model.component("comp1").geom("geom1").feature("pt2").setIndex("p", "xr", 0);

//    Click Build Selected.

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

//    Create selections to simplify the model setup.
//    In the Definitions toolbar, click Explicit.

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

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

//    Select Domains 2, 3, 5, 6, 8, 9.

    model.component("comp1").selection("sel1").set(2, 3, 5, 6, 8, 9);

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

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

//    In the Definitions toolbar, click Explicit.

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

//    Select Domains 1, 4, 7.

    model.component("comp1").selection("sel2").set(1, 4, 7);

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

    model.component("comp1").selection("sel2").label("Porous Layer");

//    In the Definitions toolbar, click Explicit.

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

//    Select Domains 1, 2, 3, 6, 7, 8, 9.

    model.component("comp1").selection("sel3").set(1, 2, 3, 6, 7, 8, 9);

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

    model.component("comp1").selection("sel3").label("Absorbing Layer");

//    In the Definitions toolbar, click Difference.

    model.component("comp1").selection().create("dif1", "Difference");

//    In the Settings window for Difference, locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select Air in the Selections to add list.
//    Click OK.

    model.component("comp1").selection("dif1").set("add", new String[]{"sel1"});

//    In the Settings window for Difference, locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select Porous Layer in the Selections to add list.
//    Click OK.

    model.component("comp1").selection("dif1").set("add", new String[]{"sel1", "sel2"});

//    In the Settings window for Difference, locate the Input Entities section.
//    Under Selections to subtract, click Add.
//    In the Add dialog, select Absorbing Layer in the Selections to subtract list.
//    Click OK.

    model.component("comp1").selection("dif1").set("subtract", new String[]{"sel3"});

//    In the Settings window for Difference, type Physical Domain in the Label text field.

    model.component("comp1").selection("dif1").label("Physical Domain");

//    In the Definitions toolbar, click Explicit.

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

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

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

//    Select Boundaries 4, 11, 18.

    model.component("comp1").selection("sel4").set(4, 11, 18);

//    In the Label text field, type Interface.

    model.component("comp1").selection("sel4").label("Interface");

//    In the Definitions toolbar, click Explicit.

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

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

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

//    Select Boundaries 1, 3, 5, 7, 14, 21, 22, 23, 24.

    model.component("comp1").selection("sel5").set(1, 3, 5, 7, 14, 21, 22, 23, 24);

//    In the Label text field, type Outer Boundary.

    model.component("comp1").selection("sel5").label("Outer Boundary");

//    Click the Zoom Extents button in the Graphics toolbar.
//    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 Home toolbar, click Add Physics to open the Add Physics window.
//    In the tree, select Acoustics > Pressure Acoustics > Pressure Acoustics, Time Explicit (pate).
//    Click Add to Component 1 in the window toolbar.

    model.component("comp1").physics().create("pate", "PressureAcousticsTimeExplicit", "geom1");

//    In the Home toolbar, click Add Physics to close the Add Physics window.
//    In the Settings window for Initial Values, locate the Initial Values section.
//    In the \[p\] text field, type p_init(x, y).

    model.component("comp1").physics("pate").feature("init1").set("p", "p_init(x, y)");

//    In the Physics toolbar, click Domains and choose Poroacoustics.

    model.component("comp1").physics("pate").create("pom1", "TransientPoroacousticsModel", 2);

//    In the Settings window for Poroacoustics, locate the Domain Selection section.
//    From the Selection list, select Porous Layer.

    model.component("comp1").physics("pate").feature("pom1").selection().named("sel2");

//    Locate the Poroacoustics Model section.
//    From the Poroacoustics model list, select User defined.

    model.component("comp1").physics("pate").feature("pom1").set("FluidModel", "UserDefined");

//    Click to expand the Isentropic Compressibility section.
//    From the Partial fraction fit list, select From function.

    model.component("comp1").physics("pate").feature("pom1").set("CompressibilityApproximantSource", "Function");

//    From the Reference list, select Partial Fraction Fit 1 (beta_porous).

    model.component("comp1").physics("pate").feature("pom1")
         .set("CompressibilityApproximantFunctionReference", "pff1");

//    Click Import.

    model.component("comp1").physics("pate").feature("pom1").set("beta_asymp", "7.163920377003123E-6");
    model.component("comp1").physics("pate").feature("pom1")
         .set("beta_R", new String[]{"0.003951422100388825", "6.869447667628804E-4", "0.0017583186110390597"});
    model.component("comp1").physics("pate").feature("pom1")
         .set("beta_xi", new String[]{"-13292.982617324331", "-3597.429942550003", "-830.0269343818281"});
    model.component("comp1").physics("pate").feature("pom1").set("beta_Q", new String[]{});
    model.component("comp1").physics("pate").feature("pom1").set("beta_zeta", new String[]{});

//    Click to collapse the Isentropic Compressibility section.
//    Click to expand the Density section.
//    From the Partial fraction fit list, select From function.

    model.component("comp1").physics("pate").feature("pom1").set("DensityApproximantSource", "Function");

//    From the Reference list, select Partial Fraction Fit 2 (rho_porous).

    model.component("comp1").physics("pate").feature("pom1").set("DensityApproximantFunctionReference", "pff2");

//    Click Import.

    model.component("comp1").physics("pate").feature("pom1").set("rho_asymp", "1.3422845046738547");
    model.component("comp1").physics("pate").feature("pom1")
         .set("rho_R", new String[]{"1326.911518068685", "246.51641311321762", "716.205637990928"});
    model.component("comp1").physics("pate").feature("pom1")
         .set("rho_xi", new String[]{"-5597.444876260024", "-1127.463168726241", "-3.9438943280005424E-4"});
    model.component("comp1").physics("pate").feature("pom1").set("rho_Q", new String[]{});
    model.component("comp1").physics("pate").feature("pom1").set("rho_zeta", new String[]{});

//    Note that the material discontinuity across the interface between the fluid and porous material domains is handled automatically by the <l>Continuity of Total Fields</l> feature.
//    In the Physics toolbar, click Boundaries and choose Impedance.

    model.component("comp1").physics("pate").create("imp1", "Impedance", 1);

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

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

//    In the Definitions toolbar, click Absorbing Layer.

    model.component("comp1").coordSystem().create("ab1", "AbsorbingLayer");

//    In the Settings window for Absorbing Layer, locate the Domain Selection section.
//    From the Selection list, select Absorbing Layer.

    model.component("comp1").coordSystem("ab1").selection().named("sel3");

//    In the Mesh toolbar, click Mapped.

    model.component("comp1").mesh("mesh1").create("map1", "Map");

//    In the Model Builder window, click Size.
//    In the Settings window for Size, click to expand the Element Size Parameters section.
//    In the Maximum element size text field, type 343[m/s]/4000[Hz]/1.5.

    model.component("comp1").mesh("mesh1").feature("size").set("hmax", "343[m/s]/4000[Hz]/1.5");

//    Click Build All.

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

//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Time Dependent.
//    Click Add Study in the window toolbar.

    model.study().create("std1");
    model.study("std1").create("time", "Transient");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, type Study 1 - Extended Reacting in the Label text field.

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

//    The plots will be generated manually.
//    Locate the Study Settings section.
//    Clear the Generate default plots checkbox.

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

//    In the Model Builder window, under Study 1 - Extended Reacting, click Step 1: Time Dependent.
//    In the Settings window for Time Dependent, locate the Study Settings section.
//    In the Output times text field, type range(0, 1[ms], 5[ms]) range(5.025[ms], 0.025[ms], 10[ms]).

    model.study("std1").feature("time").set("tlist", "range(0, 1[ms], 5[ms]) range(5.025[ms], 0.025[ms], 10[ms])");

//    It takes about 5 ms for the signal to reach the receiver. Therefore, use a coarser time resolution before that point in time. This will reduce the file size of the saved model.
//    In the Study toolbar, click Parametric Sweep.

    model.study("std1").create("param", "Parametric");

//    In the Settings window for Parametric Sweep, locate the Study Settings section.
//    Click Add.

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

//    In the table, enter the following settings:

    model.study("std1").feature("param").setIndex("pname", "w0", 0);
    model.study("std1").feature("param").setIndex("plistarr", "5[cm] 15[cm]", 0);

//    In the Study toolbar, click Compute.

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

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

    model.batch("p1").feature("so1").set("psol", "sol2");
    model.batch("p1").run("compute");

//    In the Home toolbar, click Add Physics to open the Add Physics window.
//    In the tree, select Recently Used > Pressure Acoustics, Time Explicit (pate).
//    Click Add to Selection in the window toolbar.

    model.component("comp1").physics().create("pate2", "PressureAcousticsTimeExplicit", "geom1");
    model.component("comp1").physics("pate2").selection().set();

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

//    In the Home toolbar, click Add Physics to close the Add Physics window.
//    In the Settings window for Initial Values, locate the Initial Values section.
//    In the \[p2\] text field, type p_init(x, y).

    model.component("comp1").physics("pate2").feature("init1").set("p2", "p_init(x, y)");

//    In the Model Builder window, click Pressure Acoustics, Time Explicit 2 (pate2).
//    In the Settings window for Pressure Acoustics, Time Explicit, locate the Domain Selection section.
//    From the Selection list, select Air.

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

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

    model.component("comp1").physics("pate2").create("imp1", "Impedance", 1);

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

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

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

    model.component("comp1").physics("pate2").create("imp2", "Impedance", 1);

//    In the Settings window for Impedance, type Impedance 2 - Local Reacting, 5 cm in the Label text field.

    model.component("comp1").physics("pate2").feature("imp2").label("Impedance 2 - Local Reacting, 5 cm");

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

    model.component("comp1").physics("pate2").feature("imp2").selection().named("sel4");

//    Locate the Impedance section.
//    From the Impedance model list, select General local reacting (rational approximation).

    model.component("comp1").physics("pate2").feature("imp2").set("ImpedanceModel", "RationalApproximation");

//    From the Partial fraction fit list, select From function.

    model.component("comp1").physics("pate2").feature("imp2").set("ApproximantSource", "Function");

    return model;
  }

  public static Model run2(Model model) {

//    From the Reference list, select Partial Fraction Fit 3 (Y_5cm).

    model.component("comp1").physics("pate2").feature("imp2").set("ApproximantFunctionReference", "pff3");

//    Click Import.

    model.component("comp1").physics("pate2").feature("imp2").set("Y_inf", "0.0016558010951927872");
    model.component("comp1").physics("pate2").feature("imp2").set("R", new String[]{"-0.34198675893865216"});
    model.component("comp1").physics("pate2").feature("imp2").set("xi", new String[]{"-899.2977787798211"});
    model.component("comp1").physics("pate2").feature("imp2")
         .set("Q", new String[]{"5.662751228224823+14.437407206647201*i", "4.495045659987196+0.6418934415255355*i", "4.14762489287589+1.127006859239739*i"});
    model.component("comp1").physics("pate2").feature("imp2")
         .set("zeta", new String[]{"-2809.0150089622994+7804.527075249731*i", "-692.6119600101805+4390.336723610788*i", "-401.61251353986813+1290.7825635384984*i"});

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

    model.component("comp1").physics("pate2").create("imp3", "Impedance", 1);

//    In the Settings window for Impedance, type Impedance 3 - Local Reacting, 15 cm in the Label text field.

    model.component("comp1").physics("pate2").feature("imp3").label("Impedance 3 - Local Reacting, 15 cm");

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

    model.component("comp1").physics("pate2").feature("imp3").selection().named("sel4");

//    Locate the Impedance section.
//    From the Impedance model list, select General local reacting (rational approximation).

    model.component("comp1").physics("pate2").feature("imp3").set("ImpedanceModel", "RationalApproximation");

//    From the Partial fraction fit list, select From function.

    model.component("comp1").physics("pate2").feature("imp3").set("ApproximantSource", "Function");

//    From the Reference list, select Partial Fraction Fit 4 (Y_15cm).

    model.component("comp1").physics("pate2").feature("imp3").set("ApproximantFunctionReference", "pff4");

//    Click Import.

    model.component("comp1").physics("pate2").feature("imp3").set("Y_inf", "0.002314667178200755");
    model.component("comp1").physics("pate2").feature("imp3").set("R", new String[]{"-5.044195763724572"});
    model.component("comp1").physics("pate2").feature("imp3").set("xi", new String[]{"-3033.9746369676163"});
    model.component("comp1").physics("pate2").feature("imp3")
         .set("Q", new String[]{"-0.3896649249999769+0.910844513652606*i", "0.8823743662088244+0.9388007936662003*i", "-0.3021800518951621-0.09739397818847474*i", "1.19220462294709+0.39498721246059343*i", "1.3372915333558657+0.33301422634362876*i", "1.1126469280911324+0.8869854989546475*i"});
    model.component("comp1").physics("pate2").feature("imp3")
         .set("zeta", new String[]{"-642.7643054665253+4063.3851318040834*i", "-600.0879153916148+3242.5082934800466*i", "-505.9555973079773+4827.358222721199*i", "-494.656489765256+2290.9766385627177*i", "-396.79593205946236+1292.9575526663477*i", "-229.93586833692143+323.6419824649901*i"});

//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Time Dependent.
//    Click Add Study in the window toolbar.

    model.study().create("std2");
    model.study("std2").create("time", "Transient");

//    In the Settings window for Study, type Study 2 - Local Reacting, 5 cm in the Label text field.

    model.study("std2").label("Study 2 - Local Reacting, 5 cm");

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

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

//    In the Model Builder window, under Study 2 - Local Reacting, 5 cm, click Step 1: Time Dependent.
//    In the Settings window for Time Dependent, locate the Study Settings section.
//    In the Output times text field, type range(0, 1[ms], 5[ms]) range(5.025[ms], 0.025[ms], 10[ms]).

    model.study("std2").feature("time").set("tlist", "range(0, 1[ms], 5[ms]) range(5.025[ms], 0.025[ms], 10[ms])");

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

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

//    In the tree, select Component 1 (comp1) > Pressure Acoustics, Time Explicit (pate).
//    Click Disable in Solvers.

    model.study("std2").feature("time").setSolveFor("/physics/pate", false);

//    In the tree, select Component 1 (comp1) > Pressure Acoustics, Time Explicit 2 (pate2) > Impedance 3 - Local Reacting, 15 cm.
//    Click Disable.

    model.study("std2").feature("time").set("disabledphysics", new String[]{"pate2/imp3"});

//    In the Study toolbar, click Compute.

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

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

//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Time Dependent.
//    Click Add Study in the window toolbar.

    model.study().create("std3");
    model.study("std3").create("time", "Transient");

//    In the Study toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, type Study 3 - Local Reacting, 15 cm in the Label text field.

    model.study("std3").label("Study 3 - Local Reacting, 15 cm");

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

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

//    In the Model Builder window, under Study 3 - Local Reacting, 15 cm, click Step 1: Time Dependent.
//    In the Settings window for Time Dependent, locate the Study Settings section.
//    In the Output times text field, type range(0, 1[ms], 5[ms]) range(5.025[ms], 0.025[ms], 10[ms]).

    model.study("std3").feature("time").set("tlist", "range(0, 1[ms], 5[ms]) range(5.025[ms], 0.025[ms], 10[ms])");
    model.study("std3").feature("time").setSolveFor("/physics/pate", false);

//    Locate the Physics and Variables Selection section.
//    In the Solve for column of the table, under Component 1 (comp1), clear the checkbox for Pressure Acoustics, Time Explicit (pate).
//    In the Study toolbar, click Compute.

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

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

    model.study("std1").feature("time").setSolveFor("/physics/pate2", false);

//    Before creating plots, process the datasets to only plot the results in the physical domains.
//    In the Model Builder window, expand the Results node.
//    In the Model Builder window, expand the Results > Datasets node, then click Study 1 - Extended Reacting/Parametric Solutions 1 (sol2).
//    In the Results toolbar, click Attributes and choose Selection.
//    In the Settings window for Selection, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Domain.

    model.result().dataset("dset2").selection().geom("geom1", 2);

//    From the Selection list, select Physical Domain.

    model.result().dataset("dset2").selection().named("dif1");

//    In the Model Builder window, under Results > Datasets, click Study 2 - Local Reacting, 5 cm/Solution 5 (sol5).
//    In the Results toolbar, click Attributes and choose Selection.
//    In the Settings window for Selection, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Domain.

    model.result().dataset("dset3").selection().geom("geom1", 2);

//    From the Selection list, select Physical Domain.

    model.result().dataset("dset3").selection().named("dif1");

//    In the Model Builder window, under Results > Datasets, click Study 3 - Local Reacting, 15 cm/Solution 6 (sol6).
//    In the Results toolbar, click Attributes and choose Selection.
//    In the Settings window for Selection, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Domain.

    model.result().dataset("dset4").selection().geom("geom1", 2);

//    From the Selection list, select Physical Domain.

    model.result().dataset("dset4").selection().named("dif1");

//    In the Model Builder window, collapse the Results > Datasets node.
//    In the Results toolbar, click 2D Plot Group.

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

//    In the Settings window for 2D Plot Group, type Acoustic Pressure, Extended Reacting (5 cm) in the Label text field.

    model.result("pg1").label("Acoustic Pressure, Extended Reacting (5 cm)");

//    Locate the Data section.
//    From the Dataset list, select Study 1 - Extended Reacting/Parametric Solutions 1 (sol2).

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

//    From the Parameter value (w0 (m)) list, select 0.05.

    model.result("pg1").setIndex("looplevel", 1, 1);

//    From the Time (s) list, select 0.0055.

    model.result("pg1").setIndex("looplevel", 26, 0);

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

    model.result("pg1").set("showlegendsunit", true);

//    Select the Show maximum and minimum values checkbox.

    model.result("pg1").set("showlegendsmaxmin", true);

//    Right-click Acoustic Pressure, Extended Reacting (5 cm) and choose Surface.

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

//    In the Settings window for Surface, locate the Coloring and Style section.
//    From the Color table list, select Wave.

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

//    From the Scale list, select Linear symmetric.

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

//    In the Acoustic Pressure, Extended Reacting (5 cm) toolbar, click Plot.

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

//    Click the Zoom Extents button in the Graphics toolbar.

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

//    In the Model Builder window, right-click Acoustic Pressure, Extended Reacting (5 cm) and choose Duplicate.

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

//    In the Settings window for 2D Plot Group, type Acoustic Pressure, Extended Reacting (15 cm) in the Label text field.

    model.result("pg2").label("Acoustic Pressure, Extended Reacting (15 cm)");

//    Locate the Data section.
//    From the Parameter value (w0 (m)) list, select 0.15.

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

//    In the Acoustic Pressure, Extended Reacting (15 cm) toolbar, click Plot.

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

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

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

//    In the Settings window for 2D Plot Group, type Acoustic Pressure, Local Reacting (5 cm) in the Label text field.

    model.result("pg3").label("Acoustic Pressure, Local Reacting (5 cm)");

//    Locate the Data section.
//    From the Dataset list, select Study 2 - Local Reacting, 5 cm/Solution 5 (sol5).

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

//    From the Time (s) list, select 0.0055.

    model.result("pg3").setIndex("looplevel", 26, 0);

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

    model.result("pg3").set("showlegendsunit", true);

//    Select the Show maximum and minimum values checkbox.

    model.result("pg3").set("showlegendsmaxmin", true);

//    Right-click Acoustic Pressure, Local Reacting (5 cm) and choose Surface.

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

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

    model.result("pg3").feature("surf1").set("expr", "pate2.p_t");

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

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

//    From the Scale list, select Linear symmetric.

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

//    In the Acoustic Pressure, Local Reacting (5 cm) toolbar, click Plot.

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

//    In the Model Builder window, right-click Acoustic Pressure, Local Reacting (5 cm) and choose Duplicate.

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

//    In the Settings window for 2D Plot Group, type Acoustic Pressure, Local Reacting (15 cm) in the Label text field.

    model.result("pg4").label("Acoustic Pressure, Local Reacting (15 cm)");

//    Locate the Data section.
//    From the Dataset list, select Study 3 - Local Reacting, 15 cm/Solution 6 (sol6).

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

//    In the Acoustic Pressure, Local Reacting (15 cm) toolbar, click Plot.

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

//    Plot the signal recorded by the receiver starting from 5 ms.
//    In the Results toolbar, click 1D Plot Group.

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

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

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

//    In the Label text field, type Signal at Receiver (5 cm).

    model.result("pg5").label("Signal at Receiver (5 cm)");

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

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

//    Right-click Signal at Receiver (5 cm) and choose Point Graph.

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

//    In the Settings window for Point Graph, locate the Data section.
//    From the Dataset list, select Study 1 - Extended Reacting/Parametric Solutions 1 (sol2).

    model.result("pg5").feature("ptgr1").set("data", "dset2");

//    From the Parameter selection (w0) list, select First.

    model.result("pg5").feature("ptgr1").setIndex("looplevelinput", "first", 1);

//    From the Time selection list, select Manual.

    model.result("pg5").feature("ptgr1").setIndex("looplevelinput", "manualindices", 0);

//    In the Time indices (1-206) text field, type range(6, 1, 206).

    model.result("pg5").feature("ptgr1").setIndex("looplevelindices", "range(6, 1, 206)", 0);

//    Select Point 10.

    model.result("pg5").feature("ptgr1").selection().set(10);

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

    model.result("pg5").feature("ptgr1").set("xdatasolnumtype", "level1");

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

    model.result("pg5").feature("ptgr1").set("legend", true);

//    From the Legends list, select Manual.

    model.result("pg5").feature("ptgr1").set("legendmethod", "manual");

//    In the table, enter the following settings:

    model.result("pg5").feature("ptgr1").setIndex("legends", "Extended Reacting", 0);
    model.result("pg5").run();

//    In the Model Builder window, right-click Signal at Receiver (5 cm) and choose Point Graph.

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

//    In the Settings window for Point Graph, locate the Data section.
//    From the Dataset list, select Study 2 - Local Reacting, 5 cm/Solution 5 (sol5).

    model.result("pg5").feature("ptgr2").set("data", "dset3");

//    From the Time selection list, select Manual.

    model.result("pg5").feature("ptgr2").setIndex("looplevelinput", "manualindices", 0);

//    In the Time indices (1-206) text field, type range(6, 1, 206).

    model.result("pg5").feature("ptgr2").setIndex("looplevelindices", "range(6, 1, 206)", 0);

//    Select Point 10.

    model.result("pg5").feature("ptgr2").selection().set(10);

//    Locate the y-Axis Data section.
//    In the Expression text field, type comp1.pate2.p_t.

    model.result("pg5").feature("ptgr2").set("expr", "comp1.pate2.p_t");

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

    model.result("pg5").feature("ptgr2").set("legend", true);

//    From the Legends list, select Manual.

    model.result("pg5").feature("ptgr2").set("legendmethod", "manual");

//    In the table, enter the following settings:

    model.result("pg5").feature("ptgr2").setIndex("legends", "Local Reacting", 0);

//    In the Signal at Receiver (5 cm) toolbar, click Plot.

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

//    Right-click Signal at Receiver (5 cm) and choose Duplicate.

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

//    In the Settings window for 1D Plot Group, type Signal at Receiver (15 cm) in the Label text field.

    model.result("pg6").label("Signal at Receiver (15 cm)");
    model.result("pg6").run();

//    In the Model Builder window, expand the Signal at Receiver (15 cm) node, then click Point Graph 1.
//    In the Settings window for Point Graph, locate the Data section.
//    From the Parameter selection (w0) list, select Last.

    model.result("pg6").feature("ptgr1").setIndex("looplevelinput", "last", 1);
    model.result("pg6").run();

//    In the Model Builder window, click Point Graph 2.
//    In the Settings window for Point Graph, locate the Data section.
//    From the Dataset list, select Study 3 - Local Reacting, 15 cm/Solution 6 (sol6).

    model.result("pg6").feature("ptgr2").set("data", "dset4");

//    In the Signal at Receiver (15 cm) toolbar, click Plot.

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

//    Poroacoustics Data for Fitting
//    In these final steps, set up a small model to generate the frequency domain poroacoustics data used for the fitting. Add a new component with a <l>Poroacoustics</l> domain feature in the frequency domain. Run the model with no sources and on a coarse mesh; then use the <l>Results Templates</l> to set up evaluation groups for the complex-valued compressibility and density.
//    In the Model Builder window, right-click the root node and choose Add Component > 2D.

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

    model.component("comp2").geom().create("geom2", 2);

    model.component("comp2").mesh().create("mesh2");

//    In the Geometry toolbar, click Rectangle.

    model.component("comp2").geom("geom2").create("r1", "Rectangle");

//    In the Home toolbar, click Windows and choose Add Physics.
//    In the tree, select Acoustics > Pressure Acoustics > Pressure Acoustics, Frequency Domain (acpr).
//    Click Add to Component 2 in the window toolbar.

    model.component("comp2").physics().create("acpr", "PressureAcoustics", "geom2");

    model.component("comp2").geom("geom2").run();

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

    model.component("comp2").physics("acpr").create("pom1", "PoroacousticsModel", 2);

//    Select Domain 1.

    model.component("comp2").physics("acpr").feature("pom1").selection().set(1);

//    In the Settings window for Poroacoustics, locate the Poroacoustics Model section.
//    From the Poroacoustics model list, select Johnson–Champoux–Allard (JCA).

    model.component("comp2").physics("acpr").feature("pom1").set("FluidModel", "JohnsonChampouxAllard");

//    In the Home toolbar, click Windows and choose Add Material from Library.
//    In the tree, select Built-in > Air.
//    Click Add to Component in the window toolbar.

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

//    In the Home toolbar, click Add Material to close the Add Material window.
//    In the Model Builder window, right-click Component 2 (comp2) > Materials and choose Blank Material.

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

//    In the Settings window for Material, type Generic Melamine Foam in the Label text field.

    model.component("comp2").material("mat3").label("Generic Melamine Foam");

//    In the Model Builder window, under Component 2 (comp2) > Pressure Acoustics, Frequency Domain (acpr), click Poroacoustics 1.
//    In the Settings window for Poroacoustics, locate the Porous Matrix Properties section.
//    From the Porous elastic material list, select Generic Melamine Foam (mat3).

    model.component("comp2").physics("acpr").feature("pom1").set("SolidMaterial", "mat3");

//    In the Model Builder window, under Component 2 (comp2) > Materials, click Generic Melamine Foam (mat3).
//    In the Settings window for Material, locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp2").material("mat3").propertyGroup("def").set("porosity", new String[]{"0.99"});
    model.component("comp2").material("mat3").propertyGroup()
         .create("PoroacousticsModel", "PoroacousticsModel", "Poroacoustics_model");
    model.component("comp2").material("mat3").propertyGroup("PoroacousticsModel").set("Lv", new String[]{"130[um]"});
    model.component("comp2").material("mat3").propertyGroup("PoroacousticsModel").set("Lth", new String[]{"160[um]"});
    model.component("comp2").material("mat3").propertyGroup("PoroacousticsModel").set("tau", new String[]{"1"});
    model.component("comp2").material("mat3").propertyGroup("PoroacousticsModel")
         .set("Rf", new String[]{"4500[N*s/m^4]"});

//    In the Mesh toolbar, click Free Triangular.

    model.component("comp2").mesh("mesh2").create("ftri1", "FreeTri");

//    In the Model Builder window, click Size.
//    In the Settings window for Size, locate the Element Size section.
//    From the Predefined list, select Extremely coarse.

    model.component("comp2").mesh("mesh2").feature("size").set("hauto", 9);

//    In the Home toolbar, click Windows and choose Add Study.
//    Find the Physics interfaces in study subsection.
//    In the table, enter the following settings:
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Frequency Domain.

    return model;
  }

  public static Model run3(Model model) {
//    Click Add Study in the window toolbar.

    model.study().create("std4");
    model.study("std4").create("freq", "Frequency");
    model.study("std4").feature("freq").setSolveFor("/physics/pate", false);
    model.study("std4").feature("freq").setSolveFor("/physics/pate2", false);

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, type Study 4 - Poroacoustics Data for Fitting in the Label text field.

    model.study("std4").label("Study 4 - Poroacoustics Data for Fitting");

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

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

//    In the Model Builder window, under Study 4 - Poroacoustics Data for Fitting, click Step 1: Frequency Domain.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    Click Range.
//    In the Range dialog, choose ISO preferred frequencies from the Entry method list.
//    In the Start frequency text field, type 50.
//    In the Stop frequency text field, type 5000.
//    From the Interval list, select 1/6 octave.
//    Click Replace.

    model.study("std4").feature("freq")
         .set("plist", "{50, 56, 63, 71, 80, 90, 100, 112, 125, 140, 160, 180, 200, 224, 250, 280, 315, 355, 400, 450, 500, 560, 630, 710, 800, 900, 1e3, 1.12e3, 1.25e3, 1.4e3, 1.6e3, 1.8e3, 2e3, 2.24e3, 2.5e3, 2.8e3, 3.15e3, 3.55e3, 4e3, 4.5e3, 5e3}");

//    In the Study toolbar, click Compute.

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

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

//    In the Home toolbar, click Windows and choose Result Templates.
//    In the Home toolbar, click Windows and choose Result Templates.
//    In the tree, select Study 4 - Poroacoustics Data for Fitting/Solution 7 (6) (sol7) > Pressure Acoustics, Frequency Domain > Poroacoustics Compressibility (acpr).
//    Click Add Result Template in the window toolbar.

    model.result().evaluationGroup().create("eg1", "EvaluationGroup");
    model.result().evaluationGroup("eg1").set("data", "dset6");
    model.result().evaluationGroup("eg1").label("Poroacoustics Compressibility (acpr)");
    model.result().evaluationGroup("eg1").create("av1", "AvSurface");
    model.result().evaluationGroup("eg1").feature("av1").set("intvolume", true);
    model.result().evaluationGroup("eg1").feature("av1").selection().set(1);
    model.result().evaluationGroup("eg1").feature("av1")
         .set("expr", new String[]{"real(1/acpr.K_eq)", "imag(1/acpr.K_eq)"});
    model.result().evaluationGroup("eg1").run();
    model.result().evaluationGroup("eg1").label("Poroacoustics Compressibility (acpr)");

//    In the tree, select Study 4 - Poroacoustics Data for Fitting/Solution 7 (6) (sol7) > Pressure Acoustics, Frequency Domain > Poroacoustics Density (acpr).
//    Click Add Result Template in the window toolbar.

    model.result().evaluationGroup().create("eg2", "EvaluationGroup");
    model.result().evaluationGroup("eg2").set("data", "dset6");
    model.result().evaluationGroup("eg2").label("Poroacoustics Density (acpr)");
    model.result().evaluationGroup("eg2").create("av1", "AvSurface");
    model.result().evaluationGroup("eg2").feature("av1").set("intvolume", true);
    model.result().evaluationGroup("eg2").feature("av1").selection().set(1);
    model.result().evaluationGroup("eg2").feature("av1")
         .set("expr", new String[]{"real(acpr.rho_c)", "imag(acpr.rho_c)"});
    model.result().evaluationGroup("eg2").run();
    model.result().evaluationGroup("eg2").label("Poroacoustics Density (acpr)");

//    In the Results toolbar, click Result Templates to close the Result Templates window.
//    Two evaluation groups have been generated with the necessary data to perform a <l>Partial Fraction Fit</l> for the computed frequency range. The data can be exported to a <c>.txt</c> file by selecting the <l>Export</l> action on the table. In this model, the data is imported to the <l>Partial Fraction Fit</l> from a file. It is also possible to directly point to the computed data by selecting the <l>Data source</l> to be a <l>Results table</l>.

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

    model.title("Porous Absorber with Local and Extended Reacting Approximations for Time-Domain Modeling");

    model
         .description("This tutorial studies the propagation of sound in the presence of a porous absorber in the time domain. It demonstrates how to model a porous absorber using the local and extended reacting approximations and compares the two approaches for absorbers of various thickness. The dissipative and resonant behavior of the absorber is frequency-dependent. The use of the Partial Fraction Fit functionality makes it possible to account for the frequency dependency in the time-domain simulations.");

    return model;
  }

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

}
