/*
 * vented_loudspeaker_enclosure.java
 */

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

/** Model exported on May 13 2026, 13:30 by COMSOL 6.4.0.419. */
public class vented_loudspeaker_enclosure {

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

//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    In the Model Wizard window, click 3D.
//    In the Select Physics tree, select Acoustics > Pressure Acoustics > Pressure Acoustics, Frequency Domain (acpr).
//    Click Add.
//    In the Select Physics tree, select Acoustics > Pressure Acoustics > Pressure Acoustics, Boundary Elements (pabe).
//    Click Add.
//    In the Select Physics tree, select Structural Mechanics > Solid Mechanics (solid).
//    Click Add.
//    In the Select Physics tree, select Structural Mechanics > Shell (shell).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Frequency Domain.
//    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("acpr", "PressureAcoustics", "geom1");
    model.component("comp1").physics().create("pabe", "PressureAcousticsBoundaryElements", "geom1");
    model.component("comp1").physics().create("solid", "SolidMechanics", "geom1");
    model.component("comp1").physics().create("shell", "Shell", "geom1");

    model.study().create("std1");
    model.study("std1").create("freq", "Frequency");

//    In the Model Builder window, under Component 1 (comp1), click Geometry 1.
//    In the Settings window for Geometry, locate the Units section.
//    From the Length unit list, select mm.

    model.component("comp1").geom("geom1").lengthUnit("mm");

//    In the Geometry toolbar, click Import.

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

//    In the Settings window for Import, locate the Source section.
//    Click Browse.
//    Browse to the model's Application Library folder and double-click the file vented_loudspeaker_enclosure.mphbin.

    model.component("comp1").geom("geom1").feature("imp1").set("filename", "vented_loudspeaker_enclosure.mphbin");

//    Click Import.

    model.component("comp1").geom("geom1").feature("imp1").importData();

//    In the Geometry toolbar, click Transforms and choose Rotate.

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

//    Select the object imp1.

    model.component("comp1").geom("geom1").feature("rot1").selection("input").set("imp1");

//    In the Settings window for Rotate, locate the Rotation section.
//    In the Angle text field, type 180.

    model.component("comp1").geom("geom1").feature("rot1").set("rot", 180);

//    In the Geometry toolbar, click Build All.

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

//    To make it easier to select some important sets of domains and boundaries in a complicated geometry such as the one you are looking at, it is good modeling practice to begin by defining selections. When working on your own model, these selections are most conveniently defined by clicking and selecting directly in the geometry. The instructions however refer to them by numbers. Whenever a selection is made, it is therefore recommended that you use the Paste Selection button. Enter the number or list of numbers in the text field that appears. Input such as 5, 5-8, 13, or 4, 7, and 9 is accepted.
//    In the Model Builder window, expand the Component 1 (comp1) > Definitions node.
//    Right-click Definitions and choose View.

    model.component("comp1").view().create("view2", "geom1");

//    In the Settings window for View, locate the View section.
//    Select the Lock camera checkbox.

    model.component("comp1").view("view2").set("locked", true);

//    Select the Lock rotation center checkbox.

    model.component("comp1").view("view2").set("rotcenlocked", true);

//    In the Model Builder window, expand the View 2 node, then click Camera.
//    In the Settings window for Camera, locate the Position section.
//    In the x text field, type 1505.2598876953125.

    model.component("comp1").view("view2").camera().setIndex("position", 1505.2598876953125, 0);

//    In the y text field, type 2077.179931640625.

    model.component("comp1").view("view2").camera().setIndex("position", 2077.179931640625, 1);

//    Locate the Target section.
//    In the x text field, type -116.375.

    model.component("comp1").view("view2").camera().set("target", new double[]{-116.375, 85, -100});

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

    model.component("comp1").view("view2").camera().setIndex("target", -85, 1);

//    Locate the Up Vector section.
//    In the x text field, type -0.3086974024772644.

    model.component("comp1").view("view2").camera().setIndex("up", -0.3086974024772644, 0);

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

    model.component("comp1").view("view2").camera().setIndex("up", -0.4115965962409973, 1);

//    Click Update.
//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel1").label("All Domains");

//    Locate the Input Entities section.
//    Select the All domains checkbox.

    model.component("comp1").selection("sel1").all();

//    In the Definitions toolbar, click Explicit.

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

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

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

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

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

//    With wireframe rendering, you can see through boundaries and get a better view of which ones you are selecting.
//    Select Domain 26.

    model.component("comp1").selection("sel2").set(26);

//    In the Definitions toolbar, click Explicit.

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

//    In the Settings window for Explicit, type Narrow Region Inner in the Label text field.

    model.component("comp1").selection("sel3").label("Narrow Region Inner");

//    Select Domain 29.

    model.component("comp1").selection("sel3").set(29);

//    In the Definitions toolbar, click Explicit.

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

//    In the Settings window for Explicit, type Narrow Region Outer in the Label text field.

    model.component("comp1").selection("sel4").label("Narrow Region Outer");

//    Select Domain 28.

    model.component("comp1").selection("sel4").set(28);

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel5").label("Soft Iron");

//    Select Domains 23, 27.

    model.component("comp1").selection("sel5").set(23, 27);

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel6").label("Ferrite");

//    Select Domain 24.

    model.component("comp1").selection("sel6").set(24);

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel7").label("Enclosure");

//    Select Domains 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42.

    model.component("comp1").selection("sel7")
         .set(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42);

//    In the Definitions toolbar, click Difference.

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

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

    model.component("comp1").selection("dif1").label("Air Domains");

//    Locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select All Domains 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 subtract, click Add.
//    In the Add dialog, select Coil, Soft Iron, Ferrite, Enclosure in the Selections to subtract list.
//    Click OK.

    model.component("comp1").selection("dif1").set("subtract", new String[]{"sel2", "sel5", "sel6", "sel7"});

//    In the Definitions toolbar, click Union.

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

//    In the Settings window for Union, type Structural Domains in the Label text field.

    model.component("comp1").selection("uni1").label("Structural Domains");

//    Locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select Coil, Soft Iron, Ferrite, Enclosure in the Selections to add list.
//    Click OK.

    model.component("comp1").selection("uni1").set("input", new String[]{"sel2", "sel5", "sel6", "sel7"});

//    In the Definitions toolbar, click Union.

    model.component("comp1").selection().create("uni2", "Union");

//    In the Settings window for Union, type Swept Domains in the Label text field.

    model.component("comp1").selection("uni2").label("Swept Domains");

//    Locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select Coil, Narrow Region Inner, Narrow Region Outer, Enclosure in the Selections to add list.
//    Click OK.

    model.component("comp1").selection("uni2").set("input", new String[]{"sel2", "sel3", "sel4", "sel7"});

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel8").label("All Boundaries");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select the All boundaries checkbox.

    model.component("comp1").selection("sel8").all();

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel9").label("Composite");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundaries 199, 200, 201, 202.

    model.component("comp1").selection("sel9").set(199, 200, 201, 202);

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel10").label("Cloth");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundaries 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 187, 188, 191, 192, 193, 194.

    model.component("comp1").selection("sel10")
         .set(173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 187, 188, 191, 192, 193, 194);

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel11").label("Foam");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundaries 271, 272, 273, 274.

    model.component("comp1").selection("sel11").set(271, 272, 273, 274);

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel12").label("Glass Fiber");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundaries 115, 116, 121, 122, 141, 142, 163, 164, 171, 172, 195, 196.

    model.component("comp1").selection("sel12").set(115, 116, 121, 122, 141, 142, 163, 164, 171, 172, 195, 196);

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel13").label("Basket");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundaries 129, 130, 155, 156, 189, 190, 239, 240, 269, 270.

    model.component("comp1").selection("sel13").set(129, 130, 155, 156, 189, 190, 239, 240, 269, 270);

//    In the Definitions toolbar, click Explicit.

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

//    In the Settings window for Explicit, type Other Mapped Boundaries in the Label text field.

    model.component("comp1").selection("sel14").label("Other Mapped Boundaries");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundaries 124, 150, 151, 239, 240, 259, 260, 261, 262, 263, 264, 266, 268, 269, 270, 275, 276.

    model.component("comp1").selection("sel14")
         .set(124, 150, 151, 239, 240, 259, 260, 261, 262, 263, 264, 266, 268, 269, 270, 275, 276);

//    In the Definitions toolbar, click Explicit.

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

//    In the Settings window for Explicit, type Not Mapped Boundaries in the Label text field.

    model.component("comp1").selection("sel15").label("Not Mapped Boundaries");

//    Locate the Input Entities section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundaries 195, 196.

    model.component("comp1").selection("sel15").set(195, 196);

//    In the Definitions toolbar, click Union.

    model.component("comp1").selection().create("uni3", "Union");

//    In the Settings window for Union, type Shell Domains in the Label text field.

    model.component("comp1").selection("uni3").label("Shell Domains");

//    Locate the Geometric Entity Level section.
//    From the Level list, select Boundary.

    model.component("comp1").selection("uni3").set("entitydim", 2);

//    Locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select Composite, Cloth, Foam, Glass Fiber, Basket in the Selections to add list.
//    Click OK.

    model.component("comp1").selection("uni3").set("input", new String[]{"sel9", "sel10", "sel11", "sel12", "sel13"});

//    In the Definitions toolbar, click Box.

    model.component("comp1").selection().create("box1", "Box");

//    In the Settings window for Box, type Symmetry Boundaries in the Label text field.

    model.component("comp1").selection("box1").label("Symmetry Boundaries");

//    Locate the Geometric Entity Level section.
//    From the Level list, select Boundary.

    model.component("comp1").selection("box1").set("entitydim", 2);

//    Locate the Box Limits section.
//    In the y minimum text field, type 0.

    model.component("comp1").selection("box1").set("ymin", 0);

//    Locate the Output Entities section.
//    From the Include entity if list, select Entity inside box.

    model.component("comp1").selection("box1").set("condition", "inside");

//    In the Definitions toolbar, click Difference.

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

//    In the Settings window for Difference, type Boundaries out of Symmetry Plane in the Label text field.

    model.component("comp1").selection("dif2").label("Boundaries out of Symmetry Plane");

//    Locate the Geometric Entity Level section.
//    From the Level list, select Boundary.

    model.component("comp1").selection("dif2").set("entitydim", 2);

//    Locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select All Boundaries in the Selections to add list.
//    Click OK.

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

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

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

//    In the Definitions toolbar, click Difference.

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

//    In the Settings window for Difference, type Mapped Boundaries in the Label text field.

    model.component("comp1").selection("dif3").label("Mapped Boundaries");

//    Locate the Geometric Entity Level section.
//    From the Level list, select Boundary.

    model.component("comp1").selection("dif3").set("entitydim", 2);

//    Locate the Input Entities section.
//    Under Selections to add, click Add.
//    In the Add dialog, select Cloth, Foam, Glass Fiber, Other Mapped Boundaries in the Selections to add list.
//    Click OK.

    model.component("comp1").selection("dif3").set("add", new String[]{"sel10", "sel11", "sel12", "sel14"});

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

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

//    In the Definitions toolbar, click Box.

    model.component("comp1").selection().create("box2", "Box");

//    In the Settings window for Box, type Symmetry Edges in the Label text field.

    model.component("comp1").selection("box2").label("Symmetry Edges");

//    Locate the Geometric Entity Level section.
//    From the Level list, select Edge.

    model.component("comp1").selection("box2").set("entitydim", 1);

//    Locate the Box Limits section.
//    In the y minimum text field, type 0.

    model.component("comp1").selection("box2").set("ymin", 0);

//    Locate the Output Entities section.
//    From the Include entity if list, select Entity inside box.

    model.component("comp1").selection("box2").set("condition", "inside");

//    Next, define interpolation functions to bring in the blocked resistance and inductance from the model of the driver.
//    In the Definitions toolbar, click Interpolation.

    model.component("comp1").func().create("int1", "Interpolation");

//    In the Settings window for Interpolation, locate the Definition section.
//    From the Data source list, select File.

    model.component("comp1").func("int1").set("source", "file");

//    Click Browse.
//    Browse to the model's Application Library folder and double-click the file vented_loudspeaker_enclosure_Rb.txt.

    model.component("comp1").func("int1").set("filename", "vented_loudspeaker_enclosure_Rb.txt");

//    Click Import.

    model.component("comp1").func("int1").importData();

//    In the Function name text field, type Rb.

    model.component("comp1").func("int1").set("funcname", "Rb");

//    Locate the Units section.
//    In the Argument table, enter the following settings:

    model.component("comp1").func("int1").setIndex("argunit", "Hz", 0);
    model.component("comp1").func("int1").setIndex("fununit", "ohm", 0);

//    In the Function table, enter the following settings:
//    In the Definitions toolbar, click Interpolation.

    model.component("comp1").func().create("int2", "Interpolation");

//    In the Settings window for Interpolation, locate the Definition section.
//    From the Data source list, select File.

    model.component("comp1").func("int2").set("source", "file");

//    Click Browse.
//    Browse to the model's Application Library folder and double-click the file vented_loudspeaker_enclosure_Lb.txt.

    model.component("comp1").func("int2").set("filename", "vented_loudspeaker_enclosure_Lb.txt");

//    Click Import.

    model.component("comp1").func("int2").importData();

//    In the Function name text field, type Lb.

    model.component("comp1").func("int2").set("funcname", "Lb");

//    Locate the Units section.
//    In the Argument table, enter the following settings:

    model.component("comp1").func("int2").setIndex("argunit", "Hz", 0);
    model.component("comp1").func("int2").setIndex("fununit", "H", 0);

//    In the Function table, enter the following settings:
//    To enable extraction of the velocity, define an average operator acting on the voice coil.
//    In the Definitions toolbar, click Nonlocal Couplings and choose Average.

    model.component("comp1").cpl().create("aveop1", "Average");
    model.component("comp1").cpl("aveop1").set("axisym", true);

//    In the Settings window for Average, type av_coil in the Operator name text field.

    model.component("comp1").cpl("aveop1").set("opname", "av_coil");

//    Locate the Source Selection section.
//    From the Selection list, select Coil.

    model.component("comp1").cpl("aveop1").selection().named("sel2");

//    Define parameters for the driving voltage, the BL factor from the loudspeaker driver model, the frequency at which the material losses are specified, and the wavelength at 3550 Hz (used to set the mesh size).
//    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("V0", "3.55[V]");
    model.param().descr("V0", "Driving Voltage");
    model.param().set("BL", "10.48[N/A]");
    model.param().descr("BL", "Force factor from loudspeaker driver model");
    model.param().set("f_loss", "40[Hz]");
    model.param().descr("f_loss", "Frequency at which loss factor is given");
    model.param().set("omega_loss", "2*pi*f_loss");
    model.param().descr("omega_loss", "Angular frequency at which loss factor is given");
    model.param().set("fmax", "3.55[kHz]");
    model.param().descr("fmax", "Maximal study frequency");
    model.param().set("c0", "343[m/s]");
    model.param().descr("c0", "Speed of sound in air");
    model.param().set("lam0", "c0/fmax");
    model.param().descr("lam0", "Minimum wave length");

//    Next, create the expressions used in defining the electric driving force. The Description field is optional, but helps you keep track of what you are doing.
//    In the Definitions toolbar, click Local Variables.

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

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

    model.component("comp1").variable("var1").set("v0", "av_coil(solid.u_tX)");
    model.component("comp1").variable("var1").descr("v0", "Coil velocity");
    model.component("comp1").variable("var1").set("Zb", "Rb(freq)+acpr.iomega*Lb(freq)");
    model.component("comp1").variable("var1").descr("Zb", "Blocked coil impedance");
    model.component("comp1").variable("var1").set("Fe", "BL*V0/Zb-v0*BL^2/Zb");
    model.component("comp1").variable("var1").descr("Fe", "Electric driving force");

//    While the material properties used in this model are partly made up, they resemble those used in a real driver. The coil former has properties representative of glass fiber materials. The spider, acting as a spring, is made of a phenolic cloth with a much lower stiffness. The material used in the coil is taken to be lighter than copper, as the wire is insulated and does not completely fill the coil domain. The surround, finally, is a light resistive foam.
//    Except for air and soft iron, the materials you will use all come from a material library created especially for this model (to be loaded from the file <c>loudspeaker_driver_materials.mph</c>). You may notice that some of the materials will report missing properties. For example, the composite does not include any electromagnetic properties. This is fine, as you will not model the magnetic fields in the domains where the composite is used.
//    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", "");

    return model;
  }

  public static Model run2(Model model) {
    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 tree, select Built-in > Structural steel.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat2", "Common");
    model.component("comp1").material("mat2").propertyGroup()
         .create("Enu", "Enu", "Young's modulus and Poisson's ratio");
    model.component("comp1").material("mat2").propertyGroup("Enu").func().create("int1", "Interpolation");
    model.component("comp1").material("mat2").propertyGroup("Enu").func().create("int2", "Interpolation");
    model.component("comp1").material("mat2").propertyGroup().create("Murnaghan", "Murnaghan", "Murnaghan");
    model.component("comp1").material("mat2").propertyGroup()
         .create("ElastoplasticModel", "ElastoplasticModel", "Elastoplastic material model");
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").func()
         .create("int1", "Interpolation");
    model.component("comp1").material("mat2").propertyGroup().create("Ludwik", "Ludwik", "Ludwik");
    model.component("comp1").material("mat2").propertyGroup("Ludwik").func().create("int1", "Interpolation");
    model.component("comp1").material("mat2").propertyGroup().create("JohnsonCook", "JohnsonCook", "Johnson-Cook");
    model.component("comp1").material("mat2").propertyGroup().create("Swift", "Swift", "Swift");
    model.component("comp1").material("mat2").propertyGroup().create("Voce", "Voce", "Voce");
    model.component("comp1").material("mat2").propertyGroup("Voce").func().create("int1", "Interpolation");
    model.component("comp1").material("mat2").propertyGroup()
         .create("HockettSherby", "HockettSherby", "Hockett-Sherby");
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").func().create("int1", "Interpolation");
    model.component("comp1").material("mat2").propertyGroup()
         .create("ArmstrongFrederick", "ArmstrongFrederick", "Armstrong-Frederick");
    model.component("comp1").material("mat2").propertyGroup("ArmstrongFrederick").func()
         .create("int1", "Interpolation");
    model.component("comp1").material("mat2").propertyGroup().create("Norton", "Norton", "Norton");
    model.component("comp1").material("mat2").propertyGroup()
         .create("Garofalo", "Garofalo", "Garofalo (hyperbolic sine)");
    model.component("comp1").material("mat2").propertyGroup()
         .create("ChabocheViscoplasticity", "ChabocheViscoplasticity", "Chaboche viscoplasticity");
    model.component("comp1").material("mat2").label("Structural steel");
    model.component("comp1").material("mat2").set("family", "custom");
    model.component("comp1").material("mat2")
         .set("customspecular", new double[]{0.7843137254901961, 0.7843137254901961, 0.7843137254901961});
    model.component("comp1").material("mat2").set("diffuse", "custom");
    model.component("comp1").material("mat2")
         .set("customdiffuse", new double[]{0.6666666666666666, 0.6666666666666666, 0.6666666666666666});
    model.component("comp1").material("mat2").set("ambient", "custom");
    model.component("comp1").material("mat2")
         .set("customambient", new double[]{0.6666666666666666, 0.6666666666666666, 0.6666666666666666});
    model.component("comp1").material("mat2").set("noise", true);
    model.component("comp1").material("mat2").set("fresnel", 0.9);
    model.component("comp1").material("mat2").set("roughness", 0.3);
    model.component("comp1").material("mat2").set("diffusewrap", 0);
    model.component("comp1").material("mat2").set("reflectance", 0);
    model.component("comp1").material("mat2").propertyGroup("def").set("lossfactor", "0.02");
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat2").propertyGroup("def").set("heatcapacity", "475[J/(kg*K)]");
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("thermalconductivity", new String[]{"44.5[W/(m*K)]", "0", "0", "0", "44.5[W/(m*K)]", "0", "0", "0", "44.5[W/(m*K)]"});
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("electricconductivity", new String[]{"4.032e6[S/m]", "0", "0", "0", "4.032e6[S/m]", "0", "0", "0", "4.032e6[S/m]"});
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"12.3e-6[1/K]", "0", "0", "0", "12.3e-6[1/K]", "0", "0", "0", "12.3e-6[1/K]"});
    model.component("comp1").material("mat2").propertyGroup("def").set("density", "7850[kg/m^3]");
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int1").set("funcname", "E");
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int1")
         .set("table", new String[][]{{"293.15", "200e9"}, {"793.15", "166.6e9"}});
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int1").set("extrap", "linear");
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int1").set("fununit", new String[]{"Pa"});
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int1").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int2").set("funcname", "nu");
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int2")
         .set("table", new String[][]{{"293.15", "0.30"}, {"793.15", "0.315"}});
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int2").set("extrap", "linear");
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int2").set("fununit", new String[]{"1"});
    model.component("comp1").material("mat2").propertyGroup("Enu").func("int2").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat2").propertyGroup("Enu").set("E", "E(T)");
    model.component("comp1").material("mat2").propertyGroup("Enu").set("nu", "nu(T)");
    model.component("comp1").material("mat2").propertyGroup("Enu").addInput("temperature");
    model.component("comp1").material("mat2").propertyGroup("Murnaghan").set("l", "-3.0e11[Pa]");
    model.component("comp1").material("mat2").propertyGroup("Murnaghan").set("m", "-6.2e11[Pa]");
    model.component("comp1").material("mat2").propertyGroup("Murnaghan").set("n", "-7.2e11[Pa]");
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").func("int1").set("funcname", "a");
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").func("int1")
         .set("fununit", new String[]{"1"});
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").func("int1")
         .set("argunit", new String[]{"K"});
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").set("sigmags", "350[MPa]*a(T)");
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").set("Et", "1.045[GPa]*a(T)");
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").set("Ek", "1.045[GPa]*a(T)");
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel")
         .set("sigmagh", "1.050[GPa]*epe*a(T)");
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel")
         .set("Hillcoefficients", new String[]{"0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]"});
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel")
         .set("ys", new String[]{"0[N/m^2]", "0[N/m^2]", "0[N/m^2]", "0[N/m^2]", "0[N/m^2]", "0[N/m^2]"});
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").addInput("temperature");
    model.component("comp1").material("mat2").propertyGroup("ElastoplasticModel").addInput("effectiveplasticstrain");
    model.component("comp1").material("mat2").propertyGroup("Ludwik").func("int1").set("funcname", "a");
    model.component("comp1").material("mat2").propertyGroup("Ludwik").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat2").propertyGroup("Ludwik").func("int1").set("fununit", new String[]{"1"});
    model.component("comp1").material("mat2").propertyGroup("Ludwik").func("int1").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat2").propertyGroup("Ludwik").set("k_lud", "560[MPa]*a(T)");
    model.component("comp1").material("mat2").propertyGroup("Ludwik").set("n_lud", "0.61");
    model.component("comp1").material("mat2").propertyGroup("Ludwik").addInput("temperature");
    model.component("comp1").material("mat2").propertyGroup("JohnsonCook").label("Johnson-Cook");
    model.component("comp1").material("mat2").propertyGroup("JohnsonCook").set("k_jcook", "560[MPa]");
    model.component("comp1").material("mat2").propertyGroup("JohnsonCook").set("n_jcook", "0.61");
    model.component("comp1").material("mat2").propertyGroup("JohnsonCook").set("C_jcook", "0.12");
    model.component("comp1").material("mat2").propertyGroup("JohnsonCook").set("epet0_jcook", "1[1/s]");
    model.component("comp1").material("mat2").propertyGroup("JohnsonCook").set("m_jcook", "0.6");
    model.component("comp1").material("mat2").propertyGroup("Swift").set("e0_swi", "0.021");
    model.component("comp1").material("mat2").propertyGroup("Swift").set("n_swi", "0.2");
    model.component("comp1").material("mat2").propertyGroup("Voce").func("int1").set("funcname", "a");
    model.component("comp1").material("mat2").propertyGroup("Voce").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat2").propertyGroup("Voce").func("int1").set("fununit", new String[]{"1"});
    model.component("comp1").material("mat2").propertyGroup("Voce").func("int1").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat2").propertyGroup("Voce").set("sigma_voc", "249[MPa]*a(T)");
    model.component("comp1").material("mat2").propertyGroup("Voce").set("beta_voc", "9.3");
    model.component("comp1").material("mat2").propertyGroup("Voce").addInput("temperature");
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").label("Hockett-Sherby");
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").func("int1").set("funcname", "a");
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").func("int1")
         .set("fununit", new String[]{"1"});
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").func("int1")
         .set("argunit", new String[]{"K"});
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").set("sigma_hoc", "684[MPa]*a(T)");
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").set("m_hoc", "3.9");
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").set("n_hoc", "0.85");
    model.component("comp1").material("mat2").propertyGroup("HockettSherby").addInput("temperature");
    model.component("comp1").material("mat2").propertyGroup("ArmstrongFrederick").label("Armstrong-Frederick");
    model.component("comp1").material("mat2").propertyGroup("ArmstrongFrederick").func("int1").set("funcname", "a");
    model.component("comp1").material("mat2").propertyGroup("ArmstrongFrederick").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat2").propertyGroup("ArmstrongFrederick").func("int1")
         .set("fununit", new String[]{"1"});
    model.component("comp1").material("mat2").propertyGroup("ArmstrongFrederick").func("int1")
         .set("argunit", new String[]{"K"});
    model.component("comp1").material("mat2").propertyGroup("ArmstrongFrederick").set("Ck", "2.070[GPa]*a(T)");
    model.component("comp1").material("mat2").propertyGroup("ArmstrongFrederick").set("gammak", "8.0");
    model.component("comp1").material("mat2").propertyGroup("ArmstrongFrederick").addInput("temperature");
    model.component("comp1").material("mat2").propertyGroup("Norton").set("A_nor", "1.2e-15[1/s]");
    model.component("comp1").material("mat2").propertyGroup("Norton").set("sigRef_nor", "1[MPa]");
    model.component("comp1").material("mat2").propertyGroup("Norton").set("n_nor", "4.5");
    model.component("comp1").material("mat2").propertyGroup("Garofalo").set("A_gar", "1e-6[1/s]");
    model.component("comp1").material("mat2").propertyGroup("Garofalo").set("sigRef_gar", "100[MPa]");
    model.component("comp1").material("mat2").propertyGroup("Garofalo").set("n_gar", "4.6");
    model.component("comp1").material("mat2").propertyGroup("ChabocheViscoplasticity").set("A_cha", "1[1/s]");
    model.component("comp1").material("mat2").propertyGroup("ChabocheViscoplasticity").set("sigRef_cha", "490[MPa]");
    model.component("comp1").material("mat2").propertyGroup("ChabocheViscoplasticity").set("n_cha", "9");

//    Add this material twice as it will be used in both the Solid and Shell physics interfaces.
//    In the tree, select Built-in > Structural steel.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat3", "Common");
    model.component("comp1").material("mat3").propertyGroup()
         .create("Enu", "Enu", "Young's modulus and Poisson's ratio");
    model.component("comp1").material("mat3").propertyGroup("Enu").func().create("int1", "Interpolation");
    model.component("comp1").material("mat3").propertyGroup("Enu").func().create("int2", "Interpolation");
    model.component("comp1").material("mat3").propertyGroup().create("Murnaghan", "Murnaghan", "Murnaghan");
    model.component("comp1").material("mat3").propertyGroup()
         .create("ElastoplasticModel", "ElastoplasticModel", "Elastoplastic material model");
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").func()
         .create("int1", "Interpolation");
    model.component("comp1").material("mat3").propertyGroup().create("Ludwik", "Ludwik", "Ludwik");
    model.component("comp1").material("mat3").propertyGroup("Ludwik").func().create("int1", "Interpolation");
    model.component("comp1").material("mat3").propertyGroup().create("JohnsonCook", "JohnsonCook", "Johnson-Cook");
    model.component("comp1").material("mat3").propertyGroup().create("Swift", "Swift", "Swift");
    model.component("comp1").material("mat3").propertyGroup().create("Voce", "Voce", "Voce");
    model.component("comp1").material("mat3").propertyGroup("Voce").func().create("int1", "Interpolation");
    model.component("comp1").material("mat3").propertyGroup()
         .create("HockettSherby", "HockettSherby", "Hockett-Sherby");
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").func().create("int1", "Interpolation");
    model.component("comp1").material("mat3").propertyGroup()
         .create("ArmstrongFrederick", "ArmstrongFrederick", "Armstrong-Frederick");
    model.component("comp1").material("mat3").propertyGroup("ArmstrongFrederick").func()
         .create("int1", "Interpolation");
    model.component("comp1").material("mat3").propertyGroup().create("Norton", "Norton", "Norton");
    model.component("comp1").material("mat3").propertyGroup()
         .create("Garofalo", "Garofalo", "Garofalo (hyperbolic sine)");
    model.component("comp1").material("mat3").propertyGroup()
         .create("ChabocheViscoplasticity", "ChabocheViscoplasticity", "Chaboche viscoplasticity");
    model.component("comp1").material("mat3").label("Structural steel 1");
    model.component("comp1").material("mat3").set("family", "custom");
    model.component("comp1").material("mat3")
         .set("customspecular", new double[]{0.7843137254901961, 0.7843137254901961, 0.7843137254901961});
    model.component("comp1").material("mat3").set("diffuse", "custom");
    model.component("comp1").material("mat3")
         .set("customdiffuse", new double[]{0.6666666666666666, 0.6666666666666666, 0.6666666666666666});
    model.component("comp1").material("mat3").set("ambient", "custom");
    model.component("comp1").material("mat3")
         .set("customambient", new double[]{0.6666666666666666, 0.6666666666666666, 0.6666666666666666});
    model.component("comp1").material("mat3").set("noise", true);
    model.component("comp1").material("mat3").set("fresnel", 0.9);
    model.component("comp1").material("mat3").set("roughness", 0.3);
    model.component("comp1").material("mat3").set("diffusewrap", 0);
    model.component("comp1").material("mat3").set("reflectance", 0);
    model.component("comp1").material("mat3").propertyGroup("def").set("lossfactor", "0.02");
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("def").set("heatcapacity", "475[J/(kg*K)]");
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("thermalconductivity", new String[]{"44.5[W/(m*K)]", "0", "0", "0", "44.5[W/(m*K)]", "0", "0", "0", "44.5[W/(m*K)]"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("electricconductivity", new String[]{"4.032e6[S/m]", "0", "0", "0", "4.032e6[S/m]", "0", "0", "0", "4.032e6[S/m]"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"12.3e-6[1/K]", "0", "0", "0", "12.3e-6[1/K]", "0", "0", "0", "12.3e-6[1/K]"});
    model.component("comp1").material("mat3").propertyGroup("def").set("density", "7850[kg/m^3]");
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int1").set("funcname", "E");
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int1")
         .set("table", new String[][]{{"293.15", "200e9"}, {"793.15", "166.6e9"}});
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int1").set("extrap", "linear");
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int1").set("fununit", new String[]{"Pa"});
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int1").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int2").set("funcname", "nu");
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int2")
         .set("table", new String[][]{{"293.15", "0.30"}, {"793.15", "0.315"}});
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int2").set("extrap", "linear");
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int2").set("fununit", new String[]{"1"});
    model.component("comp1").material("mat3").propertyGroup("Enu").func("int2").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat3").propertyGroup("Enu").set("E", "E(T)");
    model.component("comp1").material("mat3").propertyGroup("Enu").set("nu", "nu(T)");
    model.component("comp1").material("mat3").propertyGroup("Enu").addInput("temperature");
    model.component("comp1").material("mat3").propertyGroup("Murnaghan").set("l", "-3.0e11[Pa]");
    model.component("comp1").material("mat3").propertyGroup("Murnaghan").set("m", "-6.2e11[Pa]");
    model.component("comp1").material("mat3").propertyGroup("Murnaghan").set("n", "-7.2e11[Pa]");
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").func("int1").set("funcname", "a");
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").func("int1")
         .set("fununit", new String[]{"1"});
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").func("int1")
         .set("argunit", new String[]{"K"});
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").set("sigmags", "350[MPa]*a(T)");
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").set("Et", "1.045[GPa]*a(T)");
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").set("Ek", "1.045[GPa]*a(T)");
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel")
         .set("sigmagh", "1.050[GPa]*epe*a(T)");
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel")
         .set("Hillcoefficients", new String[]{"0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]"});
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel")
         .set("ys", new String[]{"0[N/m^2]", "0[N/m^2]", "0[N/m^2]", "0[N/m^2]", "0[N/m^2]", "0[N/m^2]"});
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").addInput("temperature");
    model.component("comp1").material("mat3").propertyGroup("ElastoplasticModel").addInput("effectiveplasticstrain");
    model.component("comp1").material("mat3").propertyGroup("Ludwik").func("int1").set("funcname", "a");
    model.component("comp1").material("mat3").propertyGroup("Ludwik").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat3").propertyGroup("Ludwik").func("int1").set("fununit", new String[]{"1"});
    model.component("comp1").material("mat3").propertyGroup("Ludwik").func("int1").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat3").propertyGroup("Ludwik").set("k_lud", "560[MPa]*a(T)");
    model.component("comp1").material("mat3").propertyGroup("Ludwik").set("n_lud", "0.61");
    model.component("comp1").material("mat3").propertyGroup("Ludwik").addInput("temperature");
    model.component("comp1").material("mat3").propertyGroup("JohnsonCook").label("Johnson-Cook");
    model.component("comp1").material("mat3").propertyGroup("JohnsonCook").set("k_jcook", "560[MPa]");
    model.component("comp1").material("mat3").propertyGroup("JohnsonCook").set("n_jcook", "0.61");
    model.component("comp1").material("mat3").propertyGroup("JohnsonCook").set("C_jcook", "0.12");
    model.component("comp1").material("mat3").propertyGroup("JohnsonCook").set("epet0_jcook", "1[1/s]");
    model.component("comp1").material("mat3").propertyGroup("JohnsonCook").set("m_jcook", "0.6");
    model.component("comp1").material("mat3").propertyGroup("Swift").set("e0_swi", "0.021");
    model.component("comp1").material("mat3").propertyGroup("Swift").set("n_swi", "0.2");
    model.component("comp1").material("mat3").propertyGroup("Voce").func("int1").set("funcname", "a");
    model.component("comp1").material("mat3").propertyGroup("Voce").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat3").propertyGroup("Voce").func("int1").set("fununit", new String[]{"1"});
    model.component("comp1").material("mat3").propertyGroup("Voce").func("int1").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat3").propertyGroup("Voce").set("sigma_voc", "249[MPa]*a(T)");
    model.component("comp1").material("mat3").propertyGroup("Voce").set("beta_voc", "9.3");
    model.component("comp1").material("mat3").propertyGroup("Voce").addInput("temperature");
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").label("Hockett-Sherby");
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").func("int1").set("funcname", "a");
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").func("int1")
         .set("fununit", new String[]{"1"});
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").func("int1")
         .set("argunit", new String[]{"K"});
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").set("sigma_hoc", "684[MPa]*a(T)");
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").set("m_hoc", "3.9");
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").set("n_hoc", "0.85");
    model.component("comp1").material("mat3").propertyGroup("HockettSherby").addInput("temperature");
    model.component("comp1").material("mat3").propertyGroup("ArmstrongFrederick").label("Armstrong-Frederick");
    model.component("comp1").material("mat3").propertyGroup("ArmstrongFrederick").func("int1").set("funcname", "a");
    model.component("comp1").material("mat3").propertyGroup("ArmstrongFrederick").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat3").propertyGroup("ArmstrongFrederick").func("int1")
         .set("fununit", new String[]{"1"});
    model.component("comp1").material("mat3").propertyGroup("ArmstrongFrederick").func("int1")
         .set("argunit", new String[]{"K"});
    model.component("comp1").material("mat3").propertyGroup("ArmstrongFrederick").set("Ck", "2.070[GPa]*a(T)");
    model.component("comp1").material("mat3").propertyGroup("ArmstrongFrederick").set("gammak", "8.0");
    model.component("comp1").material("mat3").propertyGroup("ArmstrongFrederick").addInput("temperature");
    model.component("comp1").material("mat3").propertyGroup("Norton").set("A_nor", "1.2e-15[1/s]");
    model.component("comp1").material("mat3").propertyGroup("Norton").set("sigRef_nor", "1[MPa]");
    model.component("comp1").material("mat3").propertyGroup("Norton").set("n_nor", "4.5");
    model.component("comp1").material("mat3").propertyGroup("Garofalo").set("A_gar", "1e-6[1/s]");
    model.component("comp1").material("mat3").propertyGroup("Garofalo").set("sigRef_gar", "100[MPa]");
    model.component("comp1").material("mat3").propertyGroup("Garofalo").set("n_gar", "4.6");
    model.component("comp1").material("mat3").propertyGroup("ChabocheViscoplasticity").set("A_cha", "1[1/s]");
    model.component("comp1").material("mat3").propertyGroup("ChabocheViscoplasticity").set("sigRef_cha", "490[MPa]");
    model.component("comp1").material("mat3").propertyGroup("ChabocheViscoplasticity").set("n_cha", "9");

//    In the Model Builder window, right-click Component 1 (comp1) > Materials > Structural steel 1 (mat3) and choose Browse Materials.
//    In the ribbon make sure to select the <l>Materials</l> tab and then click the <l>Browse Materials</l> icon.
//    The <l>Import Material Library</l> functionality is activated by clicking the small icon at the lower-right, below the <l>Material Browser</l> tree.
//    In the Material Browser window, click Import Material Library.
//    Browse to the model's Application Library folder and double-click the file loudspeaker_driver_materials.mph.
//    Click Done.
//    In the tree, select loudspeaker driver materials > Composite.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat4", "Common");
    model.component("comp1").material("mat4").label("Composite");
    model.component("comp1").material("mat4").propertyGroup("def").set("youngsmodulus", "2[GPa]");
    model.component("comp1").material("mat4").propertyGroup("def").set("poissonsratio", "0.42");
    model.component("comp1").material("mat4").propertyGroup("def").set("density", "1200[kg/m^3]");
    model.component("comp1").material("mat4").propertyGroup("def").set("lossfactor", "0.04");

//    In the tree, select loudspeaker driver materials > Cloth.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat5", "Common");
    model.component("comp1").material("mat5").label("Cloth");
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("electricconductivity", new String[]{"0", "0", "0", "0", "0", "0", "0", "0", "0"});
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});

    return model;
  }

  public static Model run3(Model model) {
    model.component("comp1").material("mat5").propertyGroup("def").set("youngsmodulus", "0.58[GPa]");
    model.component("comp1").material("mat5").propertyGroup("def").set("poissonsratio", "0.3");
    model.component("comp1").material("mat5").propertyGroup("def").set("density", "650[kg/m^3]");

//    In the tree, select loudspeaker driver materials > Foam.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat6", "Common");
    model.component("comp1").material("mat6").label("Foam");
    model.component("comp1").material("mat6").propertyGroup("def").set("youngsmodulus", "5[MPa]");
    model.component("comp1").material("mat6").propertyGroup("def").set("poissonsratio", "0.4");
    model.component("comp1").material("mat6").propertyGroup("def").set("density", "67[kg/m^3]");

//    In the tree, select loudspeaker driver materials > Coil.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat7", "Common");
    model.component("comp1").material("mat7").label("Coil");
    model.component("comp1").material("mat7").propertyGroup("def").set("lossfactor", "0.05");
    model.component("comp1").material("mat7").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat7").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat7").propertyGroup("def").set("youngsmodulus", "110[GPa]");
    model.component("comp1").material("mat7").propertyGroup("def").set("poissonsratio", "0.35");
    model.component("comp1").material("mat7").propertyGroup("def").set("density", "4500[kg/m^3]");

//    In the tree, select loudspeaker driver materials > Glass Fiber.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat8", "Common");
    model.component("comp1").material("mat8").label("Glass Fiber");
    model.component("comp1").material("mat8").propertyGroup("def")
         .set("electricconductivity", new String[]{"0", "0", "0", "0", "0", "0", "0", "0", "0"});
    model.component("comp1").material("mat8").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat8").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat8").propertyGroup("def").set("youngsmodulus", "70[GPa]");
    model.component("comp1").material("mat8").propertyGroup("def").set("poissonsratio", "0.33");
    model.component("comp1").material("mat8").propertyGroup("def").set("density", "2000[kg/m^3]");
    model.component("comp1").material("mat8").propertyGroup("def").set("lossfactor", "0.04");

//    In the tree, select loudspeaker driver materials > Generic Ferrite.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat9", "Common");
    model.component("comp1").material("mat9").propertyGroup()
         .create("RemanentFluxDensity", "RemanentFluxDensity", "Remanent flux density");
    model.component("comp1").material("mat9").label("Generic Ferrite");
    model.component("comp1").material("mat9").propertyGroup("def").set("lossfactor", "0.01");
    model.component("comp1").material("mat9").propertyGroup("def")
         .set("electricconductivity", new String[]{"0", "0", "0", "0", "0", "0", "0", "0", "0"});
    model.component("comp1").material("mat9").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat9").propertyGroup("def").set("poissonsratio", "0.3");
    model.component("comp1").material("mat9").propertyGroup("def").set("youngsmodulus", "200[GPa]");
    model.component("comp1").material("mat9").propertyGroup("def").set("density", "5000[kg/m^3]");
    model.component("comp1").material("mat9").propertyGroup("RemanentFluxDensity")
         .set("murec", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat9").propertyGroup("RemanentFluxDensity").set("normBr", "0.4[T]");

//    In the tree, select loudspeaker driver materials > Fiberboard.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat10", "Common");
    model.component("comp1").material("mat10").label("Fiberboard");
    model.component("comp1").material("mat10").propertyGroup("def").set("density", "");
    model.component("comp1").material("mat10").propertyGroup("def").set("poissonsratio", "");
    model.component("comp1").material("mat10").propertyGroup("def").set("youngsmodulus", "");
    model.component("comp1").material("mat10").propertyGroup("def").set("lossfactor", "");
    model.component("comp1").material("mat10").propertyGroup("def").set("density", "900[kg/m^3]");
    model.component("comp1").material("mat10").propertyGroup("def").set("poissonsratio", "0.3");
    model.component("comp1").material("mat10").propertyGroup("def").set("youngsmodulus", "4[GPa]");
    model.component("comp1").material("mat10").propertyGroup("def").set("lossfactor", "0.07");

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select All domains and voids.

    model.component("comp1").material("mat1").selection().all();
    model.component("comp1").material("mat1").selection().allVoids();

//    In the Model Builder window, click Structural steel (mat2).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Soft Iron.

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

//    In the Model Builder window, click Structural steel 1 (mat3).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    From the Selection list, select Basket.

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

//    In the Model Builder window, click Composite (mat4).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    From the Selection list, select Composite.

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

//    In the Model Builder window, click Cloth (mat5).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    From the Selection list, select Cloth.

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

//    In the Model Builder window, click Foam (mat6).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    From the Selection list, select Foam.

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

//    In the Model Builder window, click Coil (mat7).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Coil.

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

//    In the Model Builder window, click Glass Fiber (mat8).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    From the Selection list, select Glass Fiber.

    model.component("comp1").material("mat8").selection().named("sel12");

//    In the Model Builder window, click Generic Ferrite (mat9).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Ferrite.

    model.component("comp1").material("mat9").selection().named("sel6");

//    In the Model Builder window, click Fiberboard (mat10).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Enclosure.

    model.component("comp1").material("mat10").selection().named("sel7");

//    With the materials defined, it is now time to set up the remaining physics of the model. Begin by specifying the symmetry condition in the acoustics domain.
//    In the Model Builder window, under Component 1 (comp1), click Pressure Acoustics, Frequency Domain (acpr).
//    In the Settings window for Pressure Acoustics, Frequency Domain, locate the Domain Selection section.
//    From the Selection list, select Air Domains.

    model.component("comp1").physics("acpr").selection().named("dif1");

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

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

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

    model.component("comp1").physics("acpr").feature("sym1").selection().named("box1");

//    Next add the <l>Narrow Region Acoustics</l> features to account for the losses in the domains surrounding the voice coil. The values of the slit heights are taken from the 2D Axisymmetric model and differ from the measurements of the geometry, as the thickness of the coil former is not specifically captured in the geometry.
//    In the Physics toolbar, click Domains and choose Narrow Region Acoustics.

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

//    In the Settings window for Narrow Region Acoustics, locate the Domain Selection section.
//    From the Selection list, select Narrow Region Inner.

    model.component("comp1").physics("acpr").feature("nra1").selection().named("sel3");

//    Locate the Duct Properties section.
//    From the Duct type list, select Slit.

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

//    In the \[h\] text field, type 0.4[mm].

    model.component("comp1").physics("acpr").feature("nra1").set("h", "0.4[mm]");

//    In the Physics toolbar, click Domains and choose Narrow Region Acoustics.

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

//    In the Settings window for Narrow Region Acoustics, locate the Domain Selection section.
//    From the Selection list, select Narrow Region Outer.

    model.component("comp1").physics("acpr").feature("nra2").selection().named("sel4");

//    Locate the Duct Properties section.
//    From the Duct type list, select Slit.

    model.component("comp1").physics("acpr").feature("nra2").set("DuctType", "Slit");

//    In the \[h\] text field, type 0.2[mm].

    model.component("comp1").physics("acpr").feature("nra2").set("h", "0.2[mm]");

//    The <l>Pressure Acoustics, Boundary Elements</l> interface lets you compute the pressure field (including phase) at any finite distance from the loudspeaker. Specify the symmetry condition of the <eqv>xz</eqv>-plane.
//    In the Model Builder window, under Component 1 (comp1), click Pressure Acoustics, Boundary Elements (pabe).
//    In the Settings window for Pressure Acoustics, Boundary Elements, locate the Domain Selection section.
//    From the Selection list, select All voids.

    model.component("comp1").physics("pabe").selection().set();
    model.component("comp1").physics("pabe").selection().allVoids();

//    Click to expand the Symmetry/Infinite Boundary Condition section.
//    From the Condition for the y = y₀ plane list, select Symmetric/Infinite sound hard boundary.

    model.component("comp1").physics("pabe").prop("Symmetry").setIndex("sym2", "even", 0);

//    In the Model Builder window, under Component 1 (comp1), click Solid Mechanics (solid).
//    In the Settings window for Solid Mechanics, locate the Domain Selection section.
//    From the Selection list, select Structural Domains.

    model.component("comp1").physics("solid").selection().named("uni1");

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

    model.component("comp1").physics("solid").create("sym1", "SymmetrySolid", 2);

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

    model.component("comp1").physics("solid").feature("sym1").selection().named("box1");

//    In the Model Builder window, click Linear Elastic Material 1.
//    In the Physics toolbar, click Attributes and choose Damping.

    model.component("comp1").physics("solid").feature("lemm1").create("dmp1", "Damping", 3);

//    In the Settings window for Damping, locate the Damping Settings section.
//    From the Damping type list, select Isotropic loss factor.

    model.component("comp1").physics("solid").feature("lemm1").feature("dmp1")
         .set("DampingType", "IsotropicLossFactor");

//    Next, apply the opposing electromagnetic forces acting onto the coil and the soft iron. The reaction force on the magnetic circuit only has a minor influence on the response as the magnet system is much heavier than the speaker cone. Also, due to the use of symmetry in the model, remember to multiply the force with 0.5 as you apply a total force.
//    In the Physics toolbar, click Domains and choose Body Load.

    model.component("comp1").physics("solid").create("bl1", "BodyLoad", 3);

//    In the Settings window for Body Load, locate the Domain Selection section.
//    From the Selection list, select Soft Iron.

    model.component("comp1").physics("solid").feature("bl1").selection().named("sel5");

//    Locate the Force section.
//    From the Load type list, select Total force.

    model.component("comp1").physics("solid").feature("bl1").set("forceType", "TotalForce");

//    Specify the \[\mathbf{F}_{\mathrm{tot}}\] vector as

    model.component("comp1").physics("solid").feature("bl1").set("force", new String[]{"-0.5*Fe", "0", "0"});

//    In the Physics toolbar, click Domains and choose Body Load.

    model.component("comp1").physics("solid").create("bl2", "BodyLoad", 3);

//    In the Settings window for Body Load, locate the Domain Selection section.
//    From the Selection list, select Coil.

    model.component("comp1").physics("solid").feature("bl2").selection().named("sel2");

//    Locate the Force section.
//    From the Load type list, select Total force.

    model.component("comp1").physics("solid").feature("bl2").set("forceType", "TotalForce");

//    Specify the \[\mathbf{F}_{\mathrm{tot}}\] vector as

    model.component("comp1").physics("solid").feature("bl2").set("force", new String[]{"0.5*Fe", "0", "0"});

//    Now set up the shell physics. Begin by specifying the individual thicknesses and damping properties of the moving parts of the driver.
//    In the Model Builder window, under Component 1 (comp1), click Shell (shell).
//    In the Settings window for Shell, locate the Boundary Selection section.
//    From the Selection list, select Shell Domains.

    model.component("comp1").physics("shell").selection().named("uni3");

//    In the Model Builder window, under Component 1 (comp1) > Shell (shell), click Linear Elastic Material 1.
//    In the Physics toolbar, click Attributes and choose Damping.

    model.component("comp1").physics("shell").feature("emm1").create("dmp1", "Damping", 2);

//    In the Settings window for Damping, locate the Boundary Selection section.
//    From the Selection list, select Shell Domains.

    model.component("comp1").physics("shell").feature("emm1").feature("dmp1").selection().named("uni3");

//    Locate the Damping Settings section.
//    From the Damping type list, select Isotropic loss factor.

    model.component("comp1").physics("shell").feature("emm1").feature("dmp1")
         .set("DampingType", "IsotropicLossFactor");

//    In the Model Builder window, click Linear Elastic Material 1.
//    In the Physics toolbar, click Attributes and choose Damping.

    model.component("comp1").physics("shell").feature("emm1").create("dmp2", "Damping", 2);

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

    model.component("comp1").physics("shell").feature("emm1").feature("dmp2").selection().named("sel10");

//    Locate the Damping Settings section.
//    In the \[\beta_{\textrm{d}K}\] text field, type 0.14/omega_loss.

    model.component("comp1").physics("shell").feature("emm1").feature("dmp2").set("beta_dK", "0.14/omega_loss");

//    In the Model Builder window, click Linear Elastic Material 1.
//    In the Physics toolbar, click Attributes and choose Damping.

    model.component("comp1").physics("shell").feature("emm1").create("dmp3", "Damping", 2);

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

    model.component("comp1").physics("shell").feature("emm1").feature("dmp3").selection().named("sel11");

//    Locate the Damping Settings section.
//    In the \[\beta_{\textrm{d}K}\] text field, type 0.46/omega_loss.

    model.component("comp1").physics("shell").feature("emm1").feature("dmp3").set("beta_dK", "0.46/omega_loss");

//    Change the thickness in the default node to <c>1[mm]</c>, this will be applied to the Cone of the speaker. Set the thickness of the other speaker parts.
//    In the Model Builder window, under Component 1 (comp1) > Shell (shell), click Thickness and Offset 1.
//    In the Settings window for Thickness and Offset, locate the Thickness and Offset section.
//    In the \[d_0\] text field, type 1[mm].

    model.component("comp1").physics("shell").feature("to1").set("d", "1[mm]");

//    In the Physics toolbar, click Boundaries and choose Thickness and Offset.

    model.component("comp1").physics("shell").create("to2", "ThicknessOffset", 2);

//    In the Settings window for Thickness and Offset, locate the Boundary Selection section.
//    From the Selection list, select Cloth.

    model.component("comp1").physics("shell").feature("to2").selection().named("sel10");

//    Locate the Thickness and Offset section.
//    In the \[d_0\] text field, type 0.4[mm].

    model.component("comp1").physics("shell").feature("to2").set("d", "0.4[mm]");

//    In the Physics toolbar, click Boundaries and choose Thickness and Offset.

    model.component("comp1").physics("shell").create("to3", "ThicknessOffset", 2);

//    In the Settings window for Thickness and Offset, locate the Boundary Selection section.
//    From the Selection list, select Foam.

    model.component("comp1").physics("shell").feature("to3").selection().named("sel11");

//    Locate the Thickness and Offset section.
//    In the \[d_0\] text field, type 1.5[mm].

    model.component("comp1").physics("shell").feature("to3").set("d", "1.5[mm]");

//    In the Physics toolbar, click Boundaries and choose Thickness and Offset.

    model.component("comp1").physics("shell").create("to4", "ThicknessOffset", 2);

//    In the Settings window for Thickness and Offset, locate the Boundary Selection section.
//    From the Selection list, select Glass Fiber.

    model.component("comp1").physics("shell").feature("to4").selection().named("sel12");

//    Locate the Thickness and Offset section.
//    In the \[d_0\] text field, type 0.2[mm].

    model.component("comp1").physics("shell").feature("to4").set("d", "0.2[mm]");

//    In the Physics toolbar, click Boundaries and choose Thickness and Offset.

    model.component("comp1").physics("shell").create("to5", "ThicknessOffset", 2);

//    In the Settings window for Thickness and Offset, locate the Boundary Selection section.
//    From the Selection list, select Basket.

    model.component("comp1").physics("shell").feature("to5").selection().named("sel13");

//    Locate the Thickness and Offset section.
//    In the \[d_0\] text field, type 0.8[mm].

    model.component("comp1").physics("shell").feature("to5").set("d", "0.8[mm]");

//    Next, add a symmetry condition for the edges in the <eqv>xz</eqv>-plane.
//    In the Physics toolbar, click Edges and choose Symmetry.

    model.component("comp1").physics("shell").create("sym1", "SymmetrySolid1", 1);

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

    model.component("comp1").physics("shell").feature("sym1").selection().named("box2");

//    Update the <l>Structural Steel</l> material to add the isotropic structural loss factor of 0.01.
//    In the Model Builder window, under Component 1 (comp1) > Materials, click Structural steel (mat2).
//    In the Settings window for Material, locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat2").propertyGroup("def").set("lossfactor", new String[]{"0.01"});

//    In the Model Builder window, click Structural steel 1 (mat3).
//    In the Settings window for Material, locate the Material Contents section.
//    In the table, enter the following settings:

    model.component("comp1").material("mat3").propertyGroup("def").set("lossfactor", new String[]{"0.01"});

//    In the following steps, add the multiphysics couplings between the different physics.
//    In the Physics toolbar, click Multiphysics Couplings and choose Boundary > Acoustic–Structure Boundary.

    model.component("comp1").multiphysics().create("asb1", "AcousticStructureBoundary", 2);

//    In the Settings window for Acoustic–Structure Boundary, locate the Boundary Selection section.
//    From the Selection list, select All boundaries.

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

//    In the Physics toolbar, click Multiphysics Couplings and choose Boundary > Acoustic–Structure Boundary.

    model.component("comp1").multiphysics().create("asb2", "AcousticStructureBoundary", 2);

//    In the Settings window for Acoustic–Structure Boundary, locate the Boundary Selection section.
//    From the Selection list, select All boundaries.

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

//    Locate the Coupled Interfaces section.
//    From the Structure list, select Shell (shell).

    model.component("comp1").multiphysics("asb2").set("Structure_physics", "shell");

//    In the Physics toolbar, click Multiphysics Couplings and choose Boundary > Acoustic–Structure Boundary.

    model.component("comp1").multiphysics().create("asb3", "AcousticStructureBoundary", 2);

//    In the Settings window for Acoustic–Structure Boundary, locate the Boundary Selection section.
//    From the Selection list, select Boundaries out of Symmetry Plane.

    model.component("comp1").multiphysics("asb3").selection().named("dif2");

//    Locate the Coupled Interfaces section.
//    From the Acoustics list, select Pressure Acoustics, Boundary Elements (pabe).

    model.component("comp1").multiphysics("asb3").set("Acoustics_physics", "pabe");

//    In the Physics toolbar, click Multiphysics Couplings and choose Boundary > Acoustic–Structure Boundary.

    model.component("comp1").multiphysics().create("asb4", "AcousticStructureBoundary", 2);

//    In the Settings window for Acoustic–Structure Boundary, locate the Boundary Selection section.
//    From the Selection list, select Boundaries out of Symmetry Plane.

    model.component("comp1").multiphysics("asb4").selection().named("dif2");

//    Locate the Coupled Interfaces section.
//    From the Acoustics list, select Pressure Acoustics, Boundary Elements (pabe).

    model.component("comp1").multiphysics("asb4").set("Acoustics_physics", "pabe");

//    From the Structure list, select Shell (shell).

    model.component("comp1").multiphysics("asb4").set("Structure_physics", "shell");

//    In the Physics toolbar, click Multiphysics Couplings and choose Boundary > Acoustic BEM–FEM Boundary.

    model.component("comp1").multiphysics().create("abfb1", "AcousticBEMFEMBoundary", 2);

//    Select Boundary 277.

    model.component("comp1").multiphysics("abfb1").selection().set(277);

//    In the Physics toolbar, click Multiphysics Couplings and choose Global > Solid–Thin Structure Connection.

    model.component("comp1").multiphysics().create("sshc1", "SolidShellConnection", -1);

//    In the Settings window for Solid–Thin Structure Connection, locate the Connection Settings section.
//    From the Connection type list, select Shared boundaries.

    model.component("comp1").multiphysics("sshc1").set("connectionSettings", "sharedBnd");

//    In this model, the mesh is set up manually. Proceed by directly adding the first desired mesh component. The mesh needs to resolve the fine details of the geometry as well as the waves at all frequencies. It is always recommended to have at least two elements through the thickness of thin structures to accurately capture the bending stiffness.
//    In the Mesh toolbar, click More Generators and choose Mapped.

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

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

    model.component("comp1").mesh("mesh1").feature("map1").selection().named("dif3");

//    Right-click Mapped 1 and choose Distribution.

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

//    Select Edges 165, 270, 309, 310, 311, 312, 314, 340, 346, 348, 462, 479, 481, 485, 489, 510.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").selection()
         .set(165, 270, 309, 310, 311, 312, 314, 340, 346, 348, 462, 479, 481, 485, 489, 510);

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

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("numelem", 2);

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

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

//    Select Edges 328, 329, 498, 499.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis2").selection().set(328, 329, 498, 499);

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

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis2").set("numelem", 10);

//    Right-click Mapped 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("map1").create("dis3", "Distribution");

//    Select Edges 219, 220, 222, 224, 270, 504, 505.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis3").selection()
         .set(219, 220, 222, 224, 270, 504, 505);

//    Right-click Mapped 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("map1").create("dis4", "Distribution");

//    Select Edges 517, 519.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis4").selection().set(517, 519);

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

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis4").set("numelem", 3);

//    In the Model Builder window, under Component 1 (comp1) > Mesh 1, click Size.
//    In the Settings window for Size, locate the Element Size section.
//    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 lam0/4.

    model.component("comp1").mesh("mesh1").feature("size").set("hmax", "lam0/4");

//    In the Minimum element size text field, type 2[mm].

    model.component("comp1").mesh("mesh1").feature("size").set("hmin", "2[mm]");

//    This gives you a minimum of four elements per wavelength at the highest frequency, 3550 Hz. In practice, remember that a mesh convergence analysis is always recommended.
//    The shortest edges of the geometry have length 1 mm, which you will resolve with this setting. You can increase the <l>Minimum element size</l> setting to get a coarser mesh in the narrow region. This can trigger a warning as COMSOL checks if the minimum size is larger than a geometric entity. The model will solve when a warning is present. It is up to the user to decide if the warning is relevant for the quality of the simulation results.
//    Use a swept mesh for some of the domains to reduce the running time of the model.
//    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);

//    From the Selection list, select Swept Domains.

    model.component("comp1").mesh("mesh1").feature("swe1").selection().named("uni2");

//    Right-click Swept 1 and choose Distribution.

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

//    Select Domains 1, 2, 3, 4, 5, 6, 8, 10, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42.

    model.component("comp1").mesh("mesh1").feature("swe1").feature("dis1").selection()
         .set(1, 2, 3, 4, 5, 6, 8, 10, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42);

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

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

//    In the Mesh toolbar, click Free Tetrahedral.

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

//    In the Settings window for Free Tetrahedral, click to expand the Element Quality Optimization section.
//    From the Optimization level list, select High.

    model.component("comp1").mesh("mesh1").feature("ftet1").set("optlevel", "high");

//    This option increases the level of optimization of the meshing operation, which will increase the quality of the mesh while slightly increasing the time required for the meshing operation.
//    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);

//    From the Selection list, select Composite.

    model.component("comp1").mesh("mesh1").feature("ftet1").feature("size1").selection().named("sel9");

//    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 8[mm].

    model.component("comp1").mesh("mesh1").feature("ftet1").feature("size1").set("hmax", "8[mm]");

//    Click Build All.

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

//    The mesh plot should look like this.
//    In the Model Builder window, click Mesh 1.

    return model;
  }

  public static Model run4(Model model) {
//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, type Study 1 - Complete Study in the Label text field.

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

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

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

//    In the Model Builder window, under Study 1 - Complete Study, 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 20.
//    In the Stop frequency text field, type 3550.
//    From the Interval list, select 1/6 octave.
//    Click Replace.

    model.study("std1").feature("freq")
         .set("plist", "{20, 22.4, 25, 28, 31.5, 35.5, 40, 45, 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}");

//    This gives you frequencies with a 1/6 octave resolution from 20 to 3550 Hz with values specified by the ISO standard. The model takes about 30 GB of RAM to solve and will solve in around 90 min (depending on your hardware). If you are short on time you can, for example, select 1/3 octave or simply octave spacing.
//    Right-click Study 1 - Complete Study > Step 1: Frequency Domain and choose Get Initial Value for Step.

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

    model.sol("sol1").runFromTo("st1", "v1");

//    Getting the initial values of the step creates also the solver suggestions based on the existing physics. Use the direct solver suggestion in this model. In the current setup of the model using a direct solver is faster than the default iterative. Here the BEM problem is small compared to the FEM part.
//    In the Model Builder window, expand the Study 1 - Complete Study > Solver Configurations node.
//    In the Model Builder window, expand the Study 1 - Complete Study > Solver Configurations > Solution 1 (sol1) node.
//    In the Model Builder window, expand the Study 1 - Complete Study > Solver Configurations > Solution 1 (sol1) > Stationary Solver 1 node.
//    Right-click Suggested Direct Solver (abfb1_asb4_asb1_sshc1_asb3_asb2) and choose Enable.

    model.sol("sol1").feature("s1").feature("d1").active(true);

//    In the Study toolbar, click Compute.

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

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

//    Now that the model has been solved, proceed to generate the plots.
//    In the Model Builder window, expand the Results node.
//    In the Model Builder window, expand the Results > Datasets node.
//    Right-click Results > Datasets and choose More 3D Datasets > Grid 3D.

    model.result().dataset().create("grid1", "Grid3D");
    model.result().dataset("grid1").set("source", "data");

//    This dataset allows for the evaluation of the boundary elements solution at any spatial location in the model.
//    In the Settings window for Grid 3D, locate the Parameter Bounds section.
//    Find the First parameter subsection.
//    In the Minimum text field, type -500[mm].

    model.result().dataset("grid1").set("parmin1", "-500[mm]");

//    In the Maximum text field, type 500[mm].

    model.result().dataset("grid1").set("parmax1", "500[mm]");

//    Find the Second parameter subsection.
//    In the Minimum text field, type -500[mm].

    model.result().dataset("grid1").set("parmin2", "-500[mm]");

//    In the Maximum text field, type -0.1[mm].

    model.result().dataset("grid1").set("parmax2", "-0.1[mm]");

//    Find the Third parameter subsection.
//    In the Minimum text field, type -400[mm].

    model.result().dataset("grid1").set("parmin3", "-400[mm]");

//    In the Maximum text field, type 300[mm].

    model.result().dataset("grid1").set("parmax3", "300[mm]");

//    These coordinates define a box surrounding the speaker where you will plot the variables.
//    Click to expand the Grid section.
//    In the x resolution text field, type 100.

    model.result().dataset("grid1").set("res1", 100);

//    In the y resolution text field, type 100.

    model.result().dataset("grid1").set("res2", 100);

//    In the z resolution text field, type 100.

    model.result().dataset("grid1").set("res3", 100);

//    Increase the resolution from the default values. This produces smoother plots but may increase the time required for evaluating the solution in a plot.
//    Click Plot.
//    In the Graphics window toolbar, click ^ next to Go to Default View, then choose Go to View 2.
//    Click the Zoom Extents button in the Graphics toolbar.
//    The plot should look like this.
//    In the Results toolbar, click Result Templates to open the Result Templates window.
//    In the tree, select Study 1 - Complete Study/Solution 1 (sol1) > Pressure Acoustics, Frequency Domain > Acoustic Pressure (acpr).
//    Click Add Result Template in the window toolbar.

    model.result().create("pg1", "PlotGroup3D");
    model.result("pg1").set("data", "dset1");
    model.result("pg1").setIndex("looplevel", 46, 0);
    model.result("pg1").create("surf1", "Surface");
    model.result("pg1").feature("surf1").set("expr", new String[]{"acpr.p_t"});
    model.result("pg1").feature("surf1").set("colortable", "Wave");
    model.result("pg1").feature("surf1").set("colorscalemode", "linearsymmetric");
    model.result("pg1").set("showlegendsunit", true);
    model.result("pg1").label("Acoustic Pressure (acpr)");
    model.result("pg1").label("Acoustic Pressure (acpr)");
    model.result("pg1").run();

//    In the Results toolbar, click Result Templates to close the Result Templates window.
//    In the Settings window for 3D Plot Group, type Acoustic Pressure in the Label text field.

    model.result("pg1").label("Acoustic Pressure");

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

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

//    Locate the Plot Settings section.
//    Clear the Plot dataset edges checkbox.

    model.result("pg1").set("edges", false);
    model.result("pg1").run();

//    In the Model Builder window, expand the Acoustic Pressure node, then click Surface 1.
//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type if(isnan(acpr.p_t),pabe.p_t_bnd,acpr.p_t).

    model.result("pg1").feature("surf1").set("expr", "if(isnan(acpr.p_t),pabe.p_t_bnd,acpr.p_t)");

//    This will plot the total acoustic pressure for both Pressure Acoustics interfaces defined in the model.
//    Right-click Surface 1 and choose Deformation.

    model.result("pg1").feature("surf1").create("def1", "Deform");
    model.result("pg1").run();

//    In the Settings window for Deformation, locate the Expression section.
//    In the X-component text field, type if(isnan(shell.disp),u,u2).

    model.result("pg1").feature("surf1").feature("def1")
         .set("expr", new String[]{"if(isnan(shell.disp),u,u2)", "v", "w"});

//    In the Y-component text field, type if(isnan(shell.disp),v,v2).

    model.result("pg1").feature("surf1").feature("def1").setIndex("expr", "if(isnan(shell.disp),v,v2)", 1);

//    In the Z-component text field, type if(isnan(shell.disp),w,w2).

    model.result("pg1").feature("surf1").feature("def1").setIndex("expr", "if(isnan(shell.disp),w,w2)", 2);

//    This is the displacement of the structure obtained from the Shell or the Solid Mechanics interface.

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

//    In the Model Builder window, right-click Acoustic Pressure and choose Line.

    model.result("pg1").create("line1", "Line");
    model.result("pg1").feature("line1").set("evaluationsettings", "parent");

//    In the Settings window for Line, locate the Expression section.
//    In the Expression text field, type 0.

    model.result("pg1").feature("line1").set("expr", "0");

//    Locate the Coloring and Style section.
//    From the Coloring list, select Uniform.

    model.result("pg1").feature("line1").set("coloring", "uniform");

//    From the Color list, select Black.

    model.result("pg1").feature("line1").set("color", "black");

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

    model.result("pg1").feature("line1").set("inheritplot", "surf1");

//    Clear the Color checkbox.

    model.result("pg1").feature("line1").set("inheritcolor", false);

//    Clear the Color and data range checkbox.

    model.result("pg1").feature("line1").set("inheritrange", false);

//    Clear the Tube radius scale factor checkbox.

    model.result("pg1").feature("line1").set("inherittubescale", false);
    model.result("pg1").run();

//    In the Model Builder window, right-click Results > Acoustic Pressure > Surface 1 > Deformation 1 and choose Copy.

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

//    In the Model Builder window, right-click Line 1 and choose Paste Deformation.

    model.result("pg1").feature("line1").feature().copy("def1", "pg1/surf1/def1");
    model.result("pg1").run();
    model.result("pg1").run();

//    In the Acoustic Pressure toolbar, click More Plots and choose Multislice.

    model.result("pg1").create("mslc1", "Multislice");
    model.result("pg1").feature("mslc1").set("evaluationsettings", "parent");

//    In the Settings window for Multislice, locate the Data section.
//    From the Dataset list, select Grid 3D 1.

    model.result("pg1").feature("mslc1").set("data", "grid1");

//    Locate the Expression section.
//    In the Expression text field, type pabe.p_t.

    model.result("pg1").feature("mslc1").set("expr", "pabe.p_t");

//    Locate the Multiplane Data section.
//    Find the x-planes subsection.
//    From the Entry method list, select Coordinates.

    model.result("pg1").feature("mslc1").set("multiplanexmethod", "coord");

//    In the Coordinates text field, type -125[mm].

    model.result("pg1").feature("mslc1").set("xcoord", "-125[mm]");

//    Find the z-planes subsection.
//    From the Entry method list, select Coordinates.

    model.result("pg1").feature("mslc1").set("multiplanezmethod", "coord");

//    In the Coordinates text field, type 0.

    model.result("pg1").feature("mslc1").set("zcoord", 0);

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

    model.result("pg1").feature("mslc1").set("inheritplot", "surf1");

//    Click the Show Grid button in the Graphics toolbar.

    model.component("comp1").view("view2").set("showgrid", false);

//    In the Acoustic Pressure 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 and choose Duplicate.

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

//    In the Model Builder window, click Acoustic Pressure 1.
//    In the Settings window for 3D Plot Group, type Sound Pressure Level in the Label text field.

    model.result("pg2").label("Sound Pressure Level");
    model.result("pg2").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 if(isnan(acpr.Lp),pabe.Lp_bnd,acpr.Lp).

    model.result("pg2").feature("surf1").set("expr", "if(isnan(acpr.Lp),pabe.Lp_bnd,acpr.Lp)");

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

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

//    From the Scale list, select Linear.

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

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

    model.result("pg2").feature("surf1").set("resolution", "extrafine");
    model.result("pg2").run();

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

    model.result("pg2").feature("mslc1").set("expr", "pabe.Lp");

//    In the Sound Pressure Level toolbar, click Plot.

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

//    In the Model Builder window, right-click Sound Pressure Level and choose Duplicate.

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

//    In the Model Builder window, click Sound Pressure Level 1.
//    In the Settings window for 3D Plot Group, type Displacement in the Label text field.

    model.result("pg3").label("Displacement");
    model.result("pg3").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 if(isnan(shell.disp),solid.disp,shell.disp).

    model.result("pg3").feature("surf1").set("expr", "if(isnan(shell.disp),solid.disp,shell.disp)");
    model.result("pg3").run();

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

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

//    In the Model Builder window, under Results, click Displacement.
//    In the Displacement toolbar, click Plot.

    model.result("pg3").run();
    model.result("pg3").setIndex("looplevel", 9, 0);
    model.result("pg3").run();
    model.result("pg3").setIndex("looplevel", 38, 0);
    model.result("pg3").run();
    model.result("pg3").setIndex("looplevel", 39, 0);
    model.result("pg3").run();
    model.result("pg3").setIndex("looplevel", 40, 0);
    model.result("pg3").run();
    model.result("pg3").setIndex("looplevel", 46, 0);
    model.result("pg3").run();

//    Right-click Displacement and choose Duplicate.

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

//    In the Model Builder window, click Displacement 1.
//    In the Settings window for 3D Plot Group, type Stress in the Label text field.

    model.result("pg4").label("Stress");

//    Locate the Data section.
//    From the Parameter value (freq (Hz)) list, select 140.

    model.result("pg4").setIndex("looplevel", 18, 0);

//    In the next steps, a selection is created to show only the stress results at the basket. This selection can be modified or removed completely to analyze other areas of the model.
//    Click to expand the Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    From the Selection list, select Basket.

    model.result("pg4").selection().named("sel13");

//    Select the Apply to dataset edges checkbox.

    model.result("pg4").set("applyselectiontodatasetedges", true);
    model.result("pg4").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 if(isnan(shell.mises),solid.mises,shell.mises).

    model.result("pg4").feature("surf1").set("expr", "if(isnan(shell.mises),solid.mises,shell.mises)");

//    From the Unit list, select MPa.

    model.result("pg4").feature("surf1").set("unit", "MPa");

//    In the Stress toolbar, click Plot.

    model.result("pg4").run();
    model.result("pg4").run();
    model.result("pg4").feature("surf1").feature("def1").set("scaleactive", true);
    model.result("pg4").feature("surf1").feature("def1").set("scale", 350);
    model.result("pg4").run();
    model.result("pg4").feature("surf1").feature("def1").set("scaleactive", false);
    model.result("pg2").set("applyselectiontodatasetedges", false);
    model.result("pg2").run();

//    In the Model Builder window, right-click Sound Pressure Level and choose Duplicate.

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

//    In the Model Builder window, click Sound Pressure Level 1.
//    In the Settings window for 3D Plot Group, type Radiation Pattern in the Label text field.

    model.result("pg5").label("Radiation Pattern");
    model.result("pg5").run();

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

    model.result("pg5").feature().remove("mslc1");
    model.result("pg5").run();
    model.result("pg5").run();

//    In the Model Builder window, under Results, click Radiation Pattern.
//    In the Radiation Pattern toolbar, click More Plots and choose Radiation Pattern.

    model.result("pg5").create("rp1", "RadiationPattern");

//    In the Settings window for Radiation Pattern, locate the Expression section.
//    In the Expression text field, type 1000[mm].

    model.result("pg5").feature("rp1").set("expr", "1000[mm]");

//    Clear the Use as color expression checkbox.

    model.result("pg5").feature("rp1").set("useradiusascolor", false);

//    Locate the Color section.
//    In the Expression text field, type pabe.Lp.

    model.result("pg5").feature("rp1").set("colorexpr", "pabe.Lp");

//    Locate the Evaluation section.
//    Find the Angles subsection.
//    In the Number of elevation angles text field, type 160.

    model.result("pg5").feature("rp1").set("thetadisc", 160);

//    In the Number of azimuth angles text field, type 320.

    model.result("pg5").feature("rp1").set("phidisc", 320);

//    From the Restriction list, select Manual.

    model.result("pg5").feature("rp1").set("anglerestr", "manual");

//    In the φ range text field, type -180.

    model.result("pg5").feature("rp1").set("phirange", -180);

//    Find the Sphere subsection.
//    From the Sphere list, select Manual.

    model.result("pg5").feature("rp1").set("sphere", "manual");

//    In the Radius text field, type 1000[mm].

    model.result("pg5").feature("rp1").set("radius", "1000[mm]");

//    Locate the Coloring and Style section.
//    From the Grid list, select Fine.

    model.result("pg5").feature("rp1").set("grid", "fine");

//    In the Radiation Pattern toolbar, click Plot.

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

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

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

//    In the Model Builder window, click Surface 1.
//    In the Settings window for Surface, locate the Coloring and Style section.
//    Clear the Color legend checkbox.

    model.result("pg5").feature("surf1").set("colorlegend", false);

//    In the Radiation Pattern toolbar, click Plot.

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

//    In the Model Builder window, click Radiation Pattern.
//    In the Settings window for 3D Plot Group, locate the Data section.
//    From the Parameter value (freq (Hz)) list, select 20.

    model.result("pg5").setIndex("looplevel", 1, 0);

//    In the Radiation Pattern toolbar, click Plot.

    model.result("pg5").run();
    model.result("pg5").setIndex("looplevel", 17, 0);
    model.result("pg5").run();
    model.result("pg5").setIndex("looplevel", 18, 0);
    model.result("pg5").run();
    model.result("pg5").setIndex("looplevel", 46, 0);
    model.result("pg5").run();

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

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

//    In the Settings window for 1D Plot Group, type Sensitivity at 1 m. in the Label text field.

    model.result("pg6").label("Sensitivity at 1 m.");

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

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

//    In the Sensitivity at 1 m. toolbar, click More Plots and choose Octave Band.

    model.result("pg6").create("oct1", "OctaveBand");
    model.result("pg6").feature("oct1").set("quantity", "bandpower");
    model.result("pg6").feature("oct1").set("markerpos", "datapoints");
    model.result("pg6").feature("oct1").set("linewidth", "preference");

//    In the Settings window for Octave Band, locate the Selection section.
//    From the Geometric entity level list, select Global.

    model.result("pg6").feature("oct1").selection().geom("geom1");

//    Locate the y-Axis Data section.
//    In the Expression text field, type at3_spatial(1[m],0,0,pabe.p_t,'minc').

    model.result("pg6").feature("oct1").set("expr", "at3_spatial(1[m],0,0,pabe.p_t,'minc')");

//    Locate the Plot section.
//    From the Quantity list, select Continuous power spectral density.

    model.result("pg6").feature("oct1").set("quantity", "continuous");

//    In the Sensitivity at 1 m. toolbar, click Plot.

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

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

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

//    In the Settings window for 1D Plot Group, type Directivity xy-plane in the Label text field.

    model.result("pg7").label("Directivity xy-plane");

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

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

//    In the Directivity xy-plane toolbar, click More Plots and choose Directivity.

    model.result("pg7").create("dir1", "Directivity");
    model.result("pg7").feature("dir1").set("linewidth", "preference");

//    In the Settings window for Directivity, locate the Expression section.
//    In the Expression text field, type pabe.Lp_t.

    model.result("pg7").feature("dir1").set("expr", "pabe.Lp_t");

//    Locate the Evaluation section.
//    Find the Angles subsection.
//    In the Number of angles text field, type 180.

    model.result("pg7").feature("dir1").set("phidisc", 180);

//    From the Restriction list, select Manual.

    model.result("pg7").feature("dir1").set("anglerestr", "manual");

//    In the φ start text field, type -180.

    model.result("pg7").feature("dir1").set("phimin", -180);

//    Find the Evaluation distance subsection.
//    In the Radius text field, type 1000[mm].

    model.result("pg7").feature("dir1").set("radius", "1000[mm]");

//    Locate the Levels section.
//    From the Entry method list, select Levels.

    model.result("pg7").feature("dir1").set("levelmethod", "levels");

//    In the Levels text field, type 9 6 3 1.5 -1.5 -3 -6 -9 -12 -18 -24.

    model.result("pg7").feature("dir1").set("levels", "9 6 3 1.5 -1.5 -3 -6 -9 -12 -18 -24");

//    In the Directivity xy-plane toolbar, click Plot.

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

//    Click the x-Axis Log Scale button in the Graphics toolbar.

    model.result("pg7").set("xlog", true);
    model.result("pg7").run();

//    In the Model Builder window, right-click Directivity xy-plane and choose Duplicate.

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

//    In the Model Builder window, click Directivity xy-plane 1.
//    In the Settings window for 1D Plot Group, type Directivity xz-plane in the Label text field.

    model.result("pg8").label("Directivity xz-plane");
    model.result("pg8").run();

//    In the Model Builder window, click Directivity 1.
//    In the Settings window for Directivity, locate the Evaluation section.
//    Find the Normal vector subsection.
//    In the y text field, type -1.

    model.result("pg8").feature("dir1").set("normal", new int[]{0, -1, 1});

//    In the z text field, type 0.

    model.result("pg8").feature("dir1").set("normal", new int[]{0, -1, 0});

//    In the Directivity xz-plane toolbar, click Plot.

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

//    Proceed with creating an export for the loudspeaker radiation data. You can choose to export data as real and imaginary parts of the sound pressure or as sound pressure level and phase.
//    In the Results toolbar, click Data and choose Radiation Pattern.

    model.result().export().create("radpt1", "RadiationPattern");

//    In the Settings window for Radiation Pattern, locate the Expressions section.
//    In the table, enter the following settings:

    model.result().export("radpt1").setIndex("expr", "real(pabe.p)", 0);
    model.result().export("radpt1").setIndex("expr", "imag(pabe.p)", 1);

//    Locate the Evaluation section.
//    Find the Sphere subsection.
//    From the Sphere list, select Manual.

    model.result().export("radpt1").set("sphere", "manual");

//    In the Radius text field, type 1000.

    model.result().export("radpt1").set("radius", 1000);

//    Locate the Output section.
//    In the Filename text field, type export_balloon_data.txt.

    model.result().export("radpt1").set("filename", "export_balloon_data.txt");

//    Click the <l>Browse</l> button to select the file location and the <l>Export</l> button to save the file.
//    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 > Eigenfrequency.
//    Click Add Study in the window toolbar.

    model.study().create("std2");
    model.study("std2").create("eig", "Eigenfrequency");
    model.study("std2").feature("eig").set("storefact", false);
    model.study("std2").feature("eig").set("plotgrouparr", new String[]{"Default"});
    model.study("std2").feature("eig").set("solnum", "auto");
    model.study("std2").feature("eig").set("notsolnum", "auto");
    model.study("std2").feature("eig").set("outputmap", new String[]{});
    model.study("std2").feature("eig").set("ngenAUX", "1");
    model.study("std2").feature("eig").set("goalngenAUX", "1");
    model.study("std2").feature("eig").set("ngenAUX", "1");
    model.study("std2").feature("eig").set("goalngenAUX", "1");
    model.study("std2").feature("eig").setSolveFor("/physics/acpr", false);
    model.study("std2").feature("eig").setSolveFor("/physics/pabe", false);
    model.study("std2").feature("eig").setSolveFor("/multiphysics/asb1", false);
    model.study("std2").feature("eig").setSolveFor("/multiphysics/asb2", false);
    model.study("std2").feature("eig").setSolveFor("/multiphysics/asb3", false);
    model.study("std2").feature("eig").setSolveFor("/multiphysics/asb4", false);
    model.study("std2").feature("eig").setSolveFor("/multiphysics/abfb1", false);

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Eigenfrequency, locate the Study Settings section.
//    Select the Desired number of eigenfrequencies checkbox.

    model.study("std2").feature("eig").set("neigsactive", true);

//    In the associated text field, type 20.

    model.study("std2").feature("eig").set("neigs", 20);

//    From the Search method around shift list, select Larger real part.

    model.study("std2").feature("eig").set("eigwhich", "lr");

//    In the Model Builder window, click Study 2.
//    In the Settings window for Study, type Study 2 - Eigenfrequency in the Label text field.

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

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

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

//    In the Study toolbar, click Compute.

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

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

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

//    In the Model Builder window, right-click Displacement and choose Duplicate.

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

//    In the Settings window for 3D Plot Group, type Mode Shape in the Label text field.

    model.result("pg9").label("Mode Shape");

//    Locate the Data section.
//    From the Dataset list, select Study 2 - Eigenfrequency/Solution 2 (sol2).

    model.result("pg9").set("data", "dset2");
    model.result("pg9").run();

//    In the Model Builder window, expand the Mode Shape node, then click Surface 1.
//    In the Settings window for Surface, locate the Coloring and Style section.
//    From the Color table list, select AuroraBorealis.

    model.result("pg9").feature("surf1").set("colortable", "AuroraBorealis");

//    In the Mode Shape toolbar, click Plot.

    model.result("pg9").run();
    model.result("pg9").run();
    model.result("pg9").run();
    model.result("pg9").set("looplevel", new int[]{2});
    model.result("pg9").run();
    model.result("pg9").set("looplevel", new int[]{6});
    model.result("pg9").run();
    model.result("pg9").set("looplevel", new int[]{9});
    model.result("pg9").run();
    model.result("pg5").run();

    model.title("Loudspeaker Driver in a Vented Enclosure");

    model
         .description("This example of a boxed loudspeaker lets you apply a nominal driving voltage and extract the resulting sound pressure level in the outside room as a function of the frequency. The electromagnetic properties of the driver are supplied from the Loudspeaker Driver model (available with the AC/DC Module). The example uses the Acoustic\u2013Shell Interaction, Frequency Domain multiphysics interface and therefore requires the Structural Mechanics Module.");

    return model;
  }

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

}
