/*
 * loudspeaker_driver.java
 */

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

/** Model exported on May 12 2026, 14:34 by COMSOL 6.4.0.418. */
public class loudspeaker_driver {

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

//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    In the Model Wizard window, click 2D Axisymmetric.
//    In the Select Physics tree, select AC/DC > Electromagnetic Fields > Magnetic Fields (mf).
//    Click Add.
//    In the Select Physics tree, select Acoustics > Acoustic–Structure Interaction > Acoustic–Solid Interaction, Frequency Domain.
//    Click Add.
//    Click Study.
//    The Model Wizard lets you select the first one of the study steps you plan to use in the model. Select a stationary study used for solving the static magnetic fields.
//    In the Select Study tree, select Preset Studies for Some Physics Interfaces > Stationary.
//    Click Done.

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

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

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

    model.component("comp1").physics().create("mf", "InductionCurrents", "geom1");
    model.component("comp1").physics().create("acpr", "PressureAcoustics", "geom1");
    model.component("comp1").physics().create("solid", "SolidMechanics", "geom1");

    model.component("comp1").multiphysics().create("asb1", "AcousticStructureBoundary", 1);
    model.component("comp1").multiphysics("asb1").set("Acoustics_physics", "acpr");
    model.component("comp1").multiphysics("asb1").set("Structure_physics", "solid");
    model.component("comp1").multiphysics("asb1").selection().all();

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

//    When working with your own modeling project of an acoustic driver, you will typically either draw the geometry in COMSOL Multiphysics, or import a CAD file of the driver itself and add the surrounding air and PML domains. Here, the entire geometry is imported as a sequence from the geometry file. The instructions to the geometry can be found in the appendix at the end of this document.
//    In the Geometry toolbar, click Insert Sequence and choose Insert Sequence.

    model.component("comp1").geom("geom1").insertFile("loudspeaker_driver_geom_sequence.mph", "geom1");

//    Browse to the model's Application Library folder and double-click the file loudspeaker_driver_geom_sequence.mph.
//    In the Geometry toolbar, click Build All.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    Enter the model parameters or load them from the file <c>loudspeaker_driver_parameters.txt</c>. Here, as well as in all following sections, the Description field helps you keep track of what you are doing, but is completely optional.
//    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("N0", "100");
    model.param().descr("N0", "Number of turns in coil");
    model.param().set("V0", "3.55[V]");
    model.param().descr("V0", "Peak driving voltage");
    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", "8[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");

//    The loss factor frequency definition <c>f_loss</c> will be used when setting up the structural damping properties.
//    Create some selections, this will simplify setting up the physics.
//    In the Definitions toolbar, click Explicit.

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

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

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

//    Select Domains 6, 23.

    model.component("comp1").selection("sel1").set(6, 23);

//    Locate the Color section.
//    From the Color list, select Color 3.

    model.component("comp1").selection("sel1").set("color", "3");

//    In the Definitions toolbar, click Explicit.

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

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

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

//    Select Domains 3, 21.

    model.component("comp1").selection("sel2").set(3, 21);

//    Locate the Color section.
//    From the Color list, select Color 9.

    model.component("comp1").selection("sel2").set("color", "9");

//    In the Definitions toolbar, click Explicit.

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

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

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

//    Select Domain 20.

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

//    Locate the Color section.
//    From the Color list, select Color 7.

    model.component("comp1").selection("sel3").set("color", "7");

//    In the Definitions toolbar, click Explicit.

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

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

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

//    Select Domain 25.

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

//    Locate the Color section.
//    From the Color list, select Color 10.

    model.component("comp1").selection("sel4").set("color", "10");

//    In the Definitions toolbar, click Explicit.

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

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

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

//    Select Domains 17, 18, 19.

    model.component("comp1").selection("sel5").set(17, 18, 19);

//    Locate the Color section.
//    From the Color list, select Color 8.

    model.component("comp1").selection("sel5").set("color", "8");

//    In the Definitions toolbar, click Explicit.

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

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

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

//    Select Domains 9, 10, 11, 12, 13, 14, 15, 16.

    model.component("comp1").selection("sel6").set(9, 10, 11, 12, 13, 14, 15, 16);

//    Locate the Color section.
//    From the Color list, select Color 10.

    model.component("comp1").selection("sel6").set("color", "10");

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel7").label("Generic Ferrite");

//    Select Domain 24.

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

//    Locate the Color section.
//    From the Color list, select Color 17.

    model.component("comp1").selection("sel7").set("color", "17");

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel8").label("PML");

//    Select Domains 1, 5.

    model.component("comp1").selection("sel8").set(1, 5);

//    In the Definitions toolbar, click Box.

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

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

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

//    In the Definitions toolbar, click Difference.

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

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

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

//    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[]{"box1"});

//    In the Settings window for Difference, locate the Input Entities section.
//    Under Selections to subtract, click Add.
//    In the Add dialog, select Soft Iron, Composite, Cloth, Foam, Coil, Glass Fiber, Generic Ferrite in the Selections to subtract list.
//    Click OK.

    model.component("comp1").selection("dif1")
         .set("subtract", new String[]{"sel1", "sel2", "sel3", "sel4", "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 Composite, Cloth, Foam, Coil, Glass Fiber in the Selections to add list.
//    Click OK.

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

//    In the Definitions toolbar, click Union.

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

//    In the Settings window for Union, type Composite and Glass Fiber in the Label text field.

    model.component("comp1").selection("uni2").label("Composite and Glass Fiber");

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

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

//    In the Definitions toolbar, click Box.

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

//    In the Settings window for Box, type Magnetic Domains in the Label text field.

    model.component("comp1").selection("box2").label("Magnetic Domains");

//    Locate the Box Limits section.
//    In the r minimum text field, type 0[mm].

    model.component("comp1").selection("box2").set("xmin", "0[mm]");

//    In the r maximum text field, type 50[mm].

    model.component("comp1").selection("box2").set("xmax", "50[mm]");

//    In the z minimum text field, type -90[mm].

    model.component("comp1").selection("box2").set("ymin", "-90[mm]");

//    In the z maximum text field, type -42[mm].

    model.component("comp1").selection("box2").set("ymax", "-42[mm]");

//    In the Definitions toolbar, click Difference.

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

//    In the Settings window for Difference, type All Domains Without the PML in the Label text field.

    model.component("comp1").selection("dif2").label("All Domains Without the PML");

//    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("dif2").set("add", new String[]{"box1"});

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

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

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

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

//    Use the Perfectly Matched Layers (PMLs) to model a nonreflecting condition-like behavior and avoid unphysical reflections (spurious reflections) where the sound leaves the model. This feature is also set up under <l>Definitions</l>. This makes them available for any physics interface that needs them.
//    In the Settings window for Perfectly Matched Layer, locate the Domain Selection section.
//    From the Selection list, select PML.

    model.component("comp1").coordSystem("pml1").selection().named("sel8");

//    Locate the Scaling section.
//    In the PML scaling curvature parameter text field, type 3.

    model.component("comp1").coordSystem("pml1").set("PMLgamma", "3");

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

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

//    Use this integral to compute the radiated power of the loudspeaker.
//    In the Settings window for Integration, locate the Source Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    Select Boundary 93.

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

//    In the Model Builder window, right-click Definitions and choose Variables.

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

//    Add two variables to compute the acoustic efficiency of the loudspeaker. The coil power exists as a predefined results variable.
//    In the Settings window for Variables, locate the Variables section.
//    In the table, enter the following settings:

    model.component("comp1").variable("var1").set("coil_power", "mf.PCoil_1");
    model.component("comp1").variable("var1").descr("coil_power", "Coil power");
    model.component("comp1").variable("var1").set("aco_eff", "-intop1(up(acpr.Ir)*nr+up(acpr.Iz)*nz)/coil_power");
    model.component("comp1").variable("var1").descr("aco_eff", "Acoustic efficiency");

//    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", "");
    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 AC/DC > Soft Iron (With Losses).
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat2", "Common");
    model.component("comp1").material("mat2").propertyGroup().create("BHCurve", "BHCurve", "B-H Curve");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func().create("BH", "Interpolation");
    model.component("comp1").material("mat2").propertyGroup()
         .create("EffectiveBHCurve", "EffectiveBHCurve", "Effective B-H Curve");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func()
         .create("BHeff", "Interpolation");
    model.component("comp1").material("mat2").label("Soft Iron (With Losses)");
    model.component("comp1").material("mat2").set("family", "iron");
    model.component("comp1").material("mat2").propertyGroup("def")
         .set("electricconductivity", new String[]{"1.12e7[S/m]", "0", "0", "0", "1.12e7[S/m]", "0", "0", "0", "1.12e7[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("BHCurve").label("B-H Curve");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").label("Interpolation 1");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH")
         .set("table", new String[][]{{"0", "0"}, 
         {"663.146", "1"}, 
         {"1067.5", "1.1"}, 
         {"1705.23", "1.2"}, 
         {"2463.11", "1.3"}, 
         {"3841.67", "1.4"}, 
         {"5425.74", "1.5"}, 
         {"7957.75", "1.6"}, 
         {"12298.3", "1.7"}, 
         {"20462.8", "1.8"}, 
         {"32169.6", "1.9"}, 
         {"61213.4", "2"}, 
         {"111408", "2.1"}, 
         {"188487.757", "2.2"}, 
         {"267930.364", "2.3"}, 
         {"347507.836", "2.4"}});
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("extrap", "linear");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("fununit", new String[]{"T"});
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("argunit", new String[]{"A/m"});
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("plotleftextrap", false);
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("defineinv", true);
    model.component("comp1").material("mat2").propertyGroup("BHCurve").func("BH").set("defineprimfun", true);
    model.component("comp1").material("mat2").propertyGroup("BHCurve").set("normB", "BH(normHin)");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").set("normH", "BH_inv(normBin)");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").set("Wpm", "BH_prim(normHin)");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").descr("normHin", "Magnetic field norm");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").descr("normBin", "Magnetic flux density norm");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").addInput("magneticfield");
    model.component("comp1").material("mat2").propertyGroup("BHCurve").addInput("magneticfluxdensity");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").label("Effective B-H Curve");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .label("Interpolation 1");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("table", new String[][]{{"0", "0"}, 
         {"663.146", "1.000000051691021"}, 
         {"1067.5", "1.4936495124126294"}, 
         {"1705.23", "1.9415328461315795"}, 
         {"2463.11", "2.257765669366018"}, 
         {"3841.67", "2.609980642431287"}, 
         {"5425.74", "2.8664452090837504"}, 
         {"7957.75", "3.1441438097176118"}, 
         {"12298.3", "3.448538051654125"}, 
         {"20462.8", "3.7816711973679054"}, 
         {"32169.6", "4.058345590113038"}, 
         {"61213.4", "4.420646552950275"}, 
         {"111408", "4.721274089545955"}, 
         {"188487.757", "4.972148140718701"}, 
         {"267930.364", "5.145510860855953"}, 
         {"347507.836", "5.245510861426532"}});
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff").set("extrap", "linear");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("fununit", new String[]{"T"});
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("argunit", new String[]{"A/m"});
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("plotleftextrap", false);
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff").set("defineinv", true);
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").func("BHeff")
         .set("defineprimfun", true);
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").set("normBeff", "BHeff(normHeffin)");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve")
         .set("normHeff", "BHeff_inv(normBeffin)");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve")
         .set("Wpmeff", "BHeff_prim(normHeffin)");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve")
         .descr("normHeffin", "Effective magnetic field norm");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve")
         .descr("normBeffin", "Effective magnetic flux density norm");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").addInput("magneticfield");
    model.component("comp1").material("mat2").propertyGroup("EffectiveBHCurve").addInput("magneticfluxdensity");

//    First, add air which will be present everywhere in your geometry. Next, switch to using nonlinear Iron in the pole piece and top plate.
//    In the Model Builder window, click Soft Iron (With Losses) (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("sel1");

//    Right-click Soft Iron (With Losses) (mat2) 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 Material Browser 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("mat3", "Common");

    return model;
  }

  public static Model run2(Model model) {
    model.component("comp1").material("mat3").label("Composite");
    model.component("comp1").material("mat3").propertyGroup("def").set("youngsmodulus", "2[GPa]");
    model.component("comp1").material("mat3").propertyGroup("def").set("poissonsratio", "0.42");
    model.component("comp1").material("mat3").propertyGroup("def").set("density", "1200[kg/m^3]");
    model.component("comp1").material("mat3").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("mat4", "Common");
    model.component("comp1").material("mat4").label("Cloth");
    model.component("comp1").material("mat4").propertyGroup("def")
         .set("electricconductivity", new String[]{"0", "0", "0", "0", "0", "0", "0", "0", "0"});
    model.component("comp1").material("mat4").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat4").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat4").propertyGroup("def").set("youngsmodulus", "0.58[GPa]");
    model.component("comp1").material("mat4").propertyGroup("def").set("poissonsratio", "0.3");
    model.component("comp1").material("mat4").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("mat5", "Common");
    model.component("comp1").material("mat5").label("Foam");
    model.component("comp1").material("mat5").propertyGroup("def").set("youngsmodulus", "5[MPa]");
    model.component("comp1").material("mat5").propertyGroup("def").set("poissonsratio", "0.4");
    model.component("comp1").material("mat5").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("mat6", "Common");
    model.component("comp1").material("mat6").label("Coil");
    model.component("comp1").material("mat6").propertyGroup("def").set("lossfactor", "0.05");
    model.component("comp1").material("mat6").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat6").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat6").propertyGroup("def").set("youngsmodulus", "110[GPa]");
    model.component("comp1").material("mat6").propertyGroup("def").set("poissonsratio", "0.35");
    model.component("comp1").material("mat6").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("mat7", "Common");
    model.component("comp1").material("mat7").label("Glass Fiber");
    model.component("comp1").material("mat7").propertyGroup("def")
         .set("electricconductivity", new String[]{"0", "0", "0", "0", "0", "0", "0", "0", "0"});
    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", "70[GPa]");
    model.component("comp1").material("mat7").propertyGroup("def").set("poissonsratio", "0.33");
    model.component("comp1").material("mat7").propertyGroup("def").set("density", "2000[kg/m^3]");
    model.component("comp1").material("mat7").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("mat8", "Common");
    model.component("comp1").material("mat8").propertyGroup()
         .create("RemanentFluxDensity", "RemanentFluxDensity", "Remanent flux density");
    model.component("comp1").material("mat8").label("Generic Ferrite");
    model.component("comp1").material("mat8").propertyGroup("def").set("lossfactor", "0.01");
    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("poissonsratio", "0.3");
    model.component("comp1").material("mat8").propertyGroup("def").set("youngsmodulus", "200[GPa]");
    model.component("comp1").material("mat8").propertyGroup("def").set("density", "5000[kg/m^3]");
    model.component("comp1").material("mat8").propertyGroup("RemanentFluxDensity")
         .set("murec", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat8").propertyGroup("RemanentFluxDensity").set("normBr", "0.4[T]");

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

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

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

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

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

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

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

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

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

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

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

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

//    The Magnetic Fields equation needs to be solved in and around the magnetic motor. To reduce simulation time, make this physics interface active only where it is needed. You can remove all domains where you expect the magnetic field to be negligible.
//    In the Model Builder window, under Component 1 (comp1), click Magnetic Fields (mf).
//    In the Settings window for Magnetic Fields, locate the Domain Selection section.
//    From the Selection list, select Magnetic Domains.

    model.component("comp1").physics("mf").selection().named("box2");

//    Add an instance of the <l>Ampère's Law in Solids</l> domain feature in all Magnetic Fields domains, where the material is different from air.
//    In the Physics toolbar, click Domains and choose Ampère's Law in Solids.

    model.component("comp1").physics("mf").create("als1", "AmperesLawSolid", 2);

//    In the Settings window for Ampère's Law in Solids, type Ampère's Law in Solids - Generic Ferrite in the Label text field.

    model.component("comp1").physics("mf").feature("als1").label("Amp\u00e8re's Law in Solids - Generic Ferrite");

//    Locate the Domain Selection section.
//    From the Selection list, select Generic Ferrite.

    model.component("comp1").physics("mf").feature("als1").selection().named("sel7");

//    Locate the Constitutive Relation B-H section.
//    From the Magnetization model list, select Remanent flux density.

    model.component("comp1").physics("mf").feature("als1").set("ConstitutiveRelationBH", "RemanentFluxDensity");

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

    model.component("comp1").physics("mf").feature("als1").set("e_crel_BH_RemanentFluxDensity", new int[]{0, 0, 1});

//    This setting gives a static remanent flux density equal to 0.4 T in the <eqv>z</eqv> direction. This will create a static magnetic field distribution in the model, providing the linearization point for the frequency domain study.
//    In the Physics toolbar, click Domains and choose Ampère's Law in Solids.

    model.component("comp1").physics("mf").create("als2", "AmperesLawSolid", 2);

//    In the Settings window for Ampère's Law in Solids, type Ampère's Law in Solids - Soft Iron in the Label text field.

    model.component("comp1").physics("mf").feature("als2").label("Amp\u00e8re's Law in Solids - Soft Iron");

//    Locate the Domain Selection section.
//    From the Selection list, select Soft Iron.

    model.component("comp1").physics("mf").feature("als2").selection().named("sel1");

//    Locate the Constitutive Relation B-H section.
//    From the Magnetization model list, select B-H curve.

    model.component("comp1").physics("mf").feature("als2").set("ConstitutiveRelationBH", "BHCurve");

//    The B-H curve is provided by the soft iron material.
//    In the Physics toolbar, click Domains and choose Ampère's Law in Solids.

    model.component("comp1").physics("mf").create("als3", "AmperesLawSolid", 2);

//    In the Settings window for Ampère's Law in Solids, locate the Domain Selection section.
//    From the Selection list, select Structural Domains.

    model.component("comp1").physics("mf").feature("als3").selection().named("uni1");

//    In the Label text field, type Ampère's Law in Solids - Nonconductive Solids.

    model.component("comp1").physics("mf").feature("als3")
         .label("Amp\u00e8re's Law in Solids - Nonconductive Solids");

//    In the Physics toolbar, click Domains and choose Domain Coil.

    model.component("comp1").physics("mf").create("coil1", "Coil", 2);

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

    model.component("comp1").physics("mf").feature("coil1").selection().named("sel5");

//    Locate the Coil section.
//    From the Conductor model list, select Homogenized multiturn.

    model.component("comp1").physics("mf").feature("coil1").set("ConductorModel", "Multi");

//    Locate the Homogenized Conductor section.
//    In the \[N\] text field, type N0.

    model.component("comp1").physics("mf").feature("coil1").set("N", "N0");

//    From the Coil wire cross-section area list, select User defined.

    model.component("comp1").physics("mf").feature("coil1").set("AreaFrom", "UserDefined");

//    Find the High-frequency effective loss subsection.
//    Clear the Include harmonic loss checkbox.

    model.component("comp1").physics("mf").feature("coil1").set("HarmonicLoss", false);

//    In the \[a\] text field, type 3.5e-8[m^2].

    model.component("comp1").physics("mf").feature("coil1").set("coilWindArea", "3.5e-8[m^2]");

//    With <c>N0 = 100</c> turns, the total cross-sectional area covered by the wires will be 3.5e-6 m<sup>2</sup>. The area of the coil domain is 6e-6 m<sup>2</sup>, making the fill factor approximately 60%.
//    Locate the Coil section.
//    From the Coil excitation list, select Voltage.

    model.component("comp1").physics("mf").feature("coil1").set("CoilExcitation", "Voltage");

//    In the \[V_{\textrm{coil}}\] text field, type linper(V0).

    model.component("comp1").physics("mf").feature("coil1").set("VCoil", "linper(V0)");

//    This is the driving voltage. Because the <c>linper()</c> operator is used it will kick in only in the <l>Frequency Domain, Perturbation</l> study.
//    Select the air domains above and under the speaker as well as the PML regions.
//    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.

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

//    In the Physics toolbar, click Boundaries and choose Exterior Field Calculation.

    model.component("comp1").physics("acpr").create("efc1", "ExteriorFieldCalculation", 1);

//    The exterior-field calculation requires a source boundary encompassing all local sound sources, and with a symmetry plane to account for the infinite baffle. After computing the solution, you can evaluate the pressure in any point (r,z) outside the domain by entering <c>pext(r,z)</c>.
//    Select Boundary 93.

    model.component("comp1").physics("acpr").feature("efc1").selection().set(93);

//    In the Settings window for Exterior Field Calculation, locate the Exterior Field Calculation section.
//    From the Condition in the z = z₀ plane list, select Symmetric/Infinite sound hard boundary.

    model.component("comp1").physics("acpr").feature("efc1").setIndex("SymmetryCondition2", 1, 0);

//    The narrow air gaps around the voice coil have a significant effect on the damping of the back cavity modes.
//    In the Physics toolbar, click Domains and choose Narrow Region Acoustics.

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

//    Select Domain 8.

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

//    In the Settings window for Narrow Region Acoustics, 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]");

//    Select Domain 8.
//    Right-click Narrow Region Acoustics 1 and choose Duplicate.

    model.component("comp1").physics("acpr").feature().duplicate("nra2", "nra1");

//    In the Settings window for Narrow Region Acoustics, locate the Domain Selection section.
//    Click Clear Selection.

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

//    Select Domain 22.

    model.component("comp1").physics("acpr").feature("nra2").selection().set(22);

//    Locate the Duct Properties section.
//    In the \[h\] text field, type 0.2[mm].

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

//    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");

//    With the above selection, you leave out the magnet, pole piece, and top plate. You will consider these domains as perfectly rigid, by using the default sound hard wall condition on their surfaces.
//    Add damping to some of the solid material.
//    In the Model Builder window, under Component 1 (comp1) > Solid Mechanics (solid), click Linear Elastic Material 1.
//    In the Physics toolbar, click Attributes and choose Damping.

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

//    In the Settings window for Damping, locate the Domain Selection section.
//    Click Clear Selection.

    model.component("comp1").physics("solid").feature("lemm1").feature("dmp1").selection().set();

//    From the Selection list, select Composite and Glass Fiber.

    model.component("comp1").physics("solid").feature("lemm1").feature("dmp1").selection().named("uni2");

//    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");

//    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("dmp2", "Damping", 2);

//    In the Settings window for Damping, locate the Domain Selection section.
//    Click Clear Selection.

    model.component("comp1").physics("solid").feature("lemm1").feature("dmp2").selection().set();

//    From the Selection list, select Cloth.

    model.component("comp1").physics("solid").feature("lemm1").feature("dmp2").selection().named("sel3");

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

    model.component("comp1").physics("solid").feature("lemm1").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("solid").feature("lemm1").create("dmp3", "Damping", 2);

//    In the Settings window for Damping, locate the Domain Selection section.
//    Click Clear Selection.

    model.component("comp1").physics("solid").feature("lemm1").feature("dmp3").selection().set();

//    From the Selection list, select Foam.

    model.component("comp1").physics("solid").feature("lemm1").feature("dmp3").selection().named("sel4");

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

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

//    The spider and the surround are attached to the case.
//    In the Physics toolbar, click Boundaries and choose Fixed Constraint.

    model.component("comp1").physics("solid").create("fix1", "Fixed", 1);

//    Select Boundaries 81, 85.

    model.component("comp1").physics("solid").feature("fix1").selection().set(81, 85);

//    Now is a good time to inspect <l>Acoustic-Structure Boundary 1</l> multiphysics coupling under the <l>Multiphysics</l> node. When using a predefined multiphysics interface the coupling is automatically applied to all acoustic-solid boundaries.
//    In the Physics toolbar, click Multiphysics Couplings and choose Domain > Magnetomechanics, Solid.

    model.component("comp1").multiphysics().create("mmcpl1", "Magnetomechanics", 2);

//    In the Settings window for Magnetomechanics, Solid, locate the Lorentz Coupling section.
//    Select the Only use Lorentz force checkbox.

    model.component("comp1").multiphysics("mmcpl1").set("OnlyLorentz", true);

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

    model.component("comp1").multiphysics("mmcpl1").selection().named("sel5");

//    In this model, the mesh is set up manually. Proceed by directly adding the desired mesh component.
//    The mesh used in computing the impedance needs to resolve the induced eddy currents in the pole piece and the top plate. For the results to be accurate, the skin depth needs to be resolved by at least 1, preferably 2 quadratic elements.
//    With a conductivity of 1.12e7 S/m and a peak relative permeability of 1200, the skin depth in the iron at the maximum frequency of 8 kHz does not go below 0.05 mm. In practice, most of the induced currents will run in regions of the pole piece where the biased relative permeability is much less than 1200, which makes the skin depth greater. In this model, it is therefore sufficient to use a mesh size of 0.5 mm along the iron surfaces that are closest to the voice coil.
//    For the acoustic-structure interaction, the air domain and the thin moving structures also need to be well resolved. In general, 5 to 6 second-order elements per wavelength are needed to resolve the waves. For more details, see <em>Meshing (Resolving the Waves)</em> in the <em>Acoustics Module User's Guide</em>. In this model, use 5 elements per wavelength in the acoustic domains.The PML is preferably meshed with mapped elements, use 8 elements for the default polynomial scaling.
//    In the Mesh toolbar, click Mapped.

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

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

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

//    Select Domains 1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 25.

    model.component("comp1").mesh("mesh1").feature("map1").selection()
         .set(1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 25);

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

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

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

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

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

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

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

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

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

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

//    Select Domains 9, 13, 14, 15, 16, 20.

    model.component("comp1").mesh("mesh1").feature("map1").feature("size1").selection().set(9, 13, 14, 15, 16, 20);

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

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

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

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

//    In the associated text field, type 2[mm].

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

//    Right-click Mapped 1 and choose Size.

    model.component("comp1").mesh("mesh1").feature("map1").create("size2", "Size");

//    In the Settings window for Size, locate the Geometric Entity Selection section.
//    Click Clear Selection.

    model.component("comp1").mesh("mesh1").feature("map1").feature("size2").selection().set();

//    Select Domains 3, 21, 25.

    model.component("comp1").mesh("mesh1").feature("map1").feature("size2").selection().set(3, 21, 25);

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

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

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

    model.component("comp1").mesh("mesh1").feature("map1").feature("size2").set("hmaxactive", true);

//    In the associated text field, type 4[mm].

    model.component("comp1").mesh("mesh1").feature("map1").feature("size2").set("hmax", "4[mm]");

//    Right-click Mapped 1 and choose Size.

    model.component("comp1").mesh("mesh1").feature("map1").create("size3", "Size");

//    In the Settings window for Size, locate the Geometric Entity Selection section.
//    Click Clear Selection.

    model.component("comp1").mesh("mesh1").feature("map1").feature("size3").selection().set();

//    Select Domains 8, 10, 11, 12, 17, 18, 19, 22.

    model.component("comp1").mesh("mesh1").feature("map1").feature("size3").selection()
         .set(8, 10, 11, 12, 17, 18, 19, 22);

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

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

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

    model.component("comp1").mesh("mesh1").feature("map1").feature("size3").set("hmaxactive", true);

//    In the associated text field, type 0.5[mm].

    model.component("comp1").mesh("mesh1").feature("map1").feature("size3").set("hmax", "0.5[mm]");

//    Right-click Mapped 1 and choose Distribution.

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

//    Select Boundaries 22, 38, 41, 45.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").selection().set(22, 38, 41, 45);

//    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);

//    Right-click Mapped 1 and choose Distribution.

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

//    Select Boundaries 87, 88.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis2").selection().set(87, 88);

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

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

//    Click Build Selected.

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

//    In the Mesh toolbar, click Free Triangular.

    model.component("comp1").mesh("mesh1").create("ftri1", "FreeTri");

//    In the Mesh toolbar, click Boundary Layers.

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

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

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

//    Select Domains 4, 6, 23.

    model.component("comp1").mesh("mesh1").feature("bl1").selection().set(4, 6, 23);

//    Click to expand the Transition section.
//    Clear the Smooth transition to interior mesh checkbox.

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

//    In the Model Builder window, click Boundary Layer Properties.
//    Select Boundaries 12, 53, 95, 96, 97, 98.

    model.component("comp1").mesh("mesh1").feature("bl1").feature("blp").selection().set(12, 53, 95, 96, 97, 98);

//    In the Mesh toolbar, click More Attributes and choose Boundary Layer Properties.

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

//    Select Boundary 93.

    model.component("comp1").mesh("mesh1").feature("bl1").feature("blp1").selection().set(93);

//    In the Settings window for Boundary Layer Properties, locate the Layers section.
//    In the Number of layers text field, type 1.

    model.component("comp1").mesh("mesh1").feature("bl1").feature("blp1").set("blnlayers", 1);

//    Click Build All.

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

//    The image should look like this.
//    In the Model Builder window, click Mesh 1.
//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, type Study 1 - Magnetic Fields in the Label text field.

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

//    Your Study node already contains the Stationary study that you picked from the Model Wizard. Disable the Pressure Acoustics and Solid Mechanics interfaces.
//    Add a Frequency-Domain, Perturbation study.
//    Locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std1").setGenPlots(false);
    model.study("std1").feature("stat").setSolveFor("/physics/solid", false);

//    In the Model Builder window, under Study 1 - Magnetic Fields, click Step 1: Stationary.
//    In the Settings window for Stationary, locate the Physics and Variables Selection section.
//    In the Solve for column of the table, under Component 1 (comp1), clear the checkbox for Solid Mechanics (solid).
//    In the Study toolbar, click More Study Steps and choose Frequency Domain > Frequency-Domain Perturbation.

    model.study("std1").create("frlin", "Frequencylinearized");

//    In the Settings window for Frequency-Domain Perturbation, locate the Study Settings section.
//    In the Frequencies text field, type 1 2 3 4 5 6 7 8 9.

    model.study("std1").feature("frlin").set("plist", "1 2 3 4 5 6 7 8 9");

//    Click Range.
//    In the Range dialog, choose ISO preferred frequencies from the Entry method list.
//    In the Start frequency text field, type 10.
//    In the Stop frequency text field, type fmax.
//    From the Interval list, select 1/12 octave.
//    Click Add.

    model.study("std1").feature("frlin")
         .set("plist", "1 2 3 4 5 6 7 8 9 {10, 10.6, 11.2, 11.8, 12.5, 13.2, 14, 15, 16, 17, 18, 19, 20, 21.2, 22.4, 23.6, 25, 26.5, 28, 30, 31.5, 33.5, 35.5, 37.5, 40, 42.5, 45, 47.5, 50, 53, 56, 60, 63, 67, 71, 75, 80, 85, 90, 95, 100, 106, 112, 118, 125, 132, 140, 150, 160, 170, 180, 190, 200, 212, 224, 236, 250, 265, 280, 300, 315, 335, 355, 375, 400, 425, 450, 475, 500, 530, 560, 600, 630, 670, 710, 750, 800, 850, 900, 950, 1e3, 1.06e3, 1.12e3, 1.18e3, 1.25e3, 1.32e3, 1.4e3, 1.5e3, 1.6e3, 1.7e3, 1.8e3, 1.9e3, 2e3, 2.12e3, 2.24e3, 2.36e3, 2.5e3, 2.65e3, 2.8e3, 3e3, 3.15e3, 3.35e3, 3.55e3, 3.75e3, 4e3, 4.25e3, 4.5e3, 4.75e3, 5e3, 5.3e3, 5.6e3, 6e3, 6.3e3, 6.7e3, 7.1e3, 7.5e3, 8e3}");

//    This generates a few frequency points below 10 Hz and ISO preferred frequencies between 10 Hz and 8 kHz.

    model.study("std1").feature("frlin").setSolveFor("/physics/acpr", false);

//    In the Settings window for Frequency-Domain Perturbation, locate the Physics and Variables Selection section.

    model.study("std1").feature("frlin").setSolveFor("/physics/solid", false);

//    In the Solve for column of the table, under Component 1 (comp1), clear the checkboxes for Pressure Acoustics, Frequency Domain (acpr), Solid Mechanics (solid).
//    NOTE: The first solution of this model is only of the electromagnetic part of the problem, with the coil assumed to be fixed in order to extract the BL factor and the blocked coil impedance. If you would like to skip ahead to the solution of the full electroacoustic problem, you can do so by proceeding from here to the instructions starting at the section <l>Component 1 (comp1)</l>, further below. Otherwise, continue by computing the solution.
//    In the Study toolbar, click Compute.

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

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

//    First, create a 2D plot to view the magnetic field distribution from the permanent magnet.
//    In the Results toolbar, click 2D Plot Group.

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

//    In the Settings window for 2D Plot Group, type Static Magnetic Field in the Label text field.

    model.result("pg1").label("Static Magnetic Field");

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

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

//    Locate the Data section.
//    From the Dataset list, select Study 1 - Magnetic Fields/Solution Store 1 (sol2).

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

    return model;
  }

  public static Model run3(Model model) {

//    Each step in a study creates its own dataset. The numbering of the datasets begins from the last step. Hence in this model Solution 2 contains the stationary solution and Solution 1 the frequency domain perturbation.
//    Right-click Static Magnetic Field and choose Surface.

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

//    In the Settings window for Surface, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Magnetic Fields > Magnetic > mf.normH - Magnetic field norm - A/m.

    model.result("pg1").feature("surf1").set("expr", "mf.normH");
    model.result("pg1").feature("surf1").set("descr", "Magnetic field norm");

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

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

//    In the Static Magnetic Field toolbar, click Plot.

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

//    Another interesting result is the effective relative permeability distribution in the iron. Begin by duplicating the existing plot.

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

//    In the Model Builder window, right-click Static Magnetic Field and choose Duplicate.

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

//    In the Settings window for 2D Plot Group, type Effective Relative Permeability in the Label text field.

    model.result("pg2").label("Effective Relative Permeability");
    model.result("pg2").run();

//    In the Model Builder window, expand the Effective Relative Permeability node, then click Surface 1.
//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type mf.normB/(mu0_const*mf.normH).

    model.result("pg2").feature("surf1").set("expr", "mf.normB/(mu0_const*mf.normH)");

//    Select the Description checkbox.

    model.result("pg2").feature("surf1").set("descractive", true);

//    In the associated text field, type Effective relative permeability.

    model.result("pg2").feature("surf1").set("descr", "Effective relative permeability");

//    In the Effective Relative Permeability toolbar, click Plot.

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

//    Next, evaluate the BL force factor.
//    In the Results toolbar, click More Derived Values and choose Average > Surface Average.

    model.result().numerical().create("av1", "AvSurface");
    model.result().numerical("av1").set("intvolume", true);

//    In the Settings window for Surface Average, locate the Data section.
//    From the Dataset list, select Study 1 - Magnetic Fields/Solution Store 1 (sol2).

    model.result().numerical("av1").set("data", "dset2");

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

    model.result().numerical("av1").selection().named("sel5");

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

    model.result().numerical("av1").setIndex("expr", "-mf.Br*N0*2*pi*r", 0);
    model.result().numerical("av1").setIndex("unit", "N/A", 0);
    model.result().numerical("av1").setIndex("descr", "BL", 0);

//    Locate the Integration Settings section.
//    Clear the Compute volume integral checkbox.

    model.result().numerical("av1").set("intvolume", false);

//    Click Evaluate.

    model.result().table().create("tbl1", "Table");
    model.result().table("tbl1").comments("Surface Average 1");
    model.result().numerical("av1").set("table", "tbl1");
    model.result().numerical("av1").setResult();

//    The BL factor evaluates to 10.5 N/A.
//    Next, study the induced current density at a few different frequencies.
//    In the Results toolbar, click 2D Plot Group.

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

//    In the Settings window for 2D Plot Group, type Induced Current Density in the Label text field.

    model.result("pg3").label("Induced Current Density");

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

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

//    Right-click Induced Current Density and choose Surface.

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

//    In the Settings window for Surface, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Magnetic Fields > Currents and charge > Conduction current density (spatial frame) - A/m² > mf.Jiphi - Conduction current density, phi-component.

    model.result("pg3").feature("surf1").set("expr", "mf.Jiphi");
    model.result("pg3").feature("surf1").set("descr", "Conduction current density, phi-component");

//    Note that the <l>Compute differential</l> checkbox, if turned on, wraps the expression in a <c>lindev()</c> operator. For more information, search for lindev in the COMSOL Multiphysics Documentation. The use of this checkbox is only necessary when plotting expressions that are not linear in the fields and that contain components of the linearization point (the DC solution). Examples of this type of expressions include electromagnetic force expressions.
//    Locate the Coloring and Style section.
//    From the Color table list, select Prism.

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

//    From the Color table transformation list, select Reverse.

    model.result("pg3").feature("surf1").set("colortabletrans", "reverse");

//    In the Induced Current Density toolbar, click Plot.

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

//    At 3500 Hz, the induced currents (or conduction currents) are highly localized to the surfaces of the top plate and pole piece.

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

//    In the Model Builder window, click Induced Current Density.
//    In the Settings window for 2D Plot Group, locate the Data section.
//    From the Parameter value (freq (Hz)) list, select 1.

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

//    In the Induced Current Density toolbar, click Plot.

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

//    Before proceeding to the full electroacoustic analysis, plot the blocked coil inductance as a function of the frequency.
//    In the Results toolbar, click 1D Plot Group.

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

//    In the Settings window for 1D Plot Group, type Blocked Coil Inductance in the Label text field.

    model.result("pg4").label("Blocked Coil Inductance");

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

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

//    Right-click Blocked Coil Inductance and choose Global.

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

//    In the Settings window for Global, locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg4").feature("glob1").setIndex("expr", "mf.LCoil_1", 0);
    model.result("pg4").feature("glob1").setIndex("unit", "mH", 0);
    model.result("pg4").feature("glob1").setIndex("descr", "Coil inductance", 0);

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

    model.result("pg4").set("xlog", true);

//    In the Blocked Coil Inductance toolbar, click Plot.

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

//    Having extracted the force factor and the voice coil inductance, you now have most of the electromagnetic data required for a separate model of the acoustic parts of a boxed loudspeaker driver. See the <c>Loudspeaker Driver in a Vented Enclosure</c> model also in the Application Library. What remains is the real part of the blocked coil impedance. This is available as <c>mf.RCoil_1</c>, the Coil Resistance. If you would like to extract this too, you can set it up in a Global plot just like the inductance, and export the results as described in the following steps.
//    Right-click Global 1 and choose Add Plot Data to Export.

    model.result().export().create("plot1", "pg4", "glob1", "Plot");

//    If you want to export the data, you can now enter a filename and click the <l>Export</l> button.
//    It is now time to compute and evaluate the solution of the entire model, including the acoustic-structure interaction. In order to this, you will set up a new study. Although you could technically reuse the static magnetic fields solution from the first study, it can be handy to include this step in the new study too. This allows you to make changes anywhere in the model, including such that affect the static magnetic fields, and run only the new study again to get correctly updated results.
//    In the Home toolbar, click Add Study to open the Add Study window.
//    Select an empty study so that you can copy and modify the study steps from your previous study.
//    Find the Studies subsection.
//    In the Select Study tree, select Empty Study.
//    Click Add Study in the window toolbar.

    model.study().create("std2");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Model Builder window, under Study 1 - Magnetic Fields, Ctrl-click to select Step 1: Stationary, Step 2: Frequency-Domain Perturbation.
//    Right-click and choose Copy.
//    In the Model Builder window, right-click Study 2 and choose Paste Multiple Items.

    model.study("std2").feature().copy("stat", "std1/stat");
    model.study("std2").feature().copy("frlin", "std1/frlin");

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

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

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

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

//    Make the Frequency Domain, Perturbed study solve for the acoustics and the solid physics too.

    model.study("std2").feature("frlin").setSolveFor("/physics/acpr", true);

//    In the Model Builder window, under Study 2 - Complete Model, click Step 2: Frequency-Domain Perturbation.
//    In the Settings window for Frequency-Domain Perturbation, locate the Physics and Variables Selection section.

    model.study("std2").feature("frlin").setSolveFor("/physics/solid", true);

//    In the Solve for column of the table, under Component 1 (comp1), select the checkboxes for Pressure Acoustics, Frequency Domain (acpr), Solid Mechanics (solid).
//    In the Study toolbar, click Compute.

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

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

//    You will now have received two more datasets: Solution 4 containing the same static magnetic fields as Solution 2, and Solution 3 with the frequency domain electromagnetic and acoustic-structure interaction results. In order to get a good overview of the latter, begin by adding a selection of all domains except the PMLs.
//    In the Model Builder window, expand the Results > Datasets node, then click Study 2 - Complete Model/Solution 3 (sol3).
//    In the Results toolbar, click Attributes and choose Selection.
//    In the Settings window for Selection, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Domain.

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

//    From the Selection list, select All Domains Without the PML.

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

//    Create a 3D plot of the instantaneous pressure distribution at zero phase in and around the speaker.
//    In the Results toolbar, click Result Templates to open the Result Templates window.
//    In the tree, select Study 2 - Complete Model/Solution 3 (sol3) > Pressure Acoustics, Frequency Domain > Acoustic Pressure, 3D (acpr).
//    Click Add Result Template in the window toolbar.

    model.result().dataset().create("rev1", "Revolve2D");
    model.result().dataset("rev1").set("data", "dset3");
    model.result().dataset("rev1").set("revangle", 225);
    model.result().dataset("rev1").set("startangle", -90);
    model.result().dataset("rev1").set("defaultPlotIDs", new String[]{"pg7|acpr", "pg8|acpr"});
    model.result().create("pg5", "PlotGroup3D");
    model.result("pg5").set("data", "rev1");
    model.result("pg5").setIndex("looplevel", 126, 0);
    model.result("pg5").create("surf1", "Surface");
    model.result("pg5").feature("surf1").set("expr", new String[]{"acpr.p_t"});
    model.result("pg5").feature("surf1").set("colortable", "Wave");
    model.result("pg5").feature("surf1").set("colorscalemode", "linearsymmetric");
    model.result("pg5").set("showlegendsunit", true);
    model.result("pg5").label("Acoustic Pressure, 3D (acpr)");
    model.result("pg5").label("Acoustic Pressure, 3D (acpr)");
    model.result("pg5").run();

//    In the Results toolbar, click Result Templates to close the Result Templates window.
//    In the Model Builder window, right-click Acoustic Pressure, 3D (acpr) and choose Contour.

    model.result("pg5").create("con1", "Contour");
    model.result("pg5").feature("con1").set("evaluationsettings", "parent");

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

    model.result("pg5").feature("con1").set("expr", "acpr.p_t");

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

    model.result("pg5").feature("con1").set("coloring", "uniform");

//    From the Color list, select Gray.

    model.result("pg5").feature("con1").set("color", "gray");

//    Clear the Color legend checkbox.

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

//    In the Results toolbar, click Result Templates to open the Result Templates window.
//    In the tree, select Study 2 - Complete Model/Solution 3 (sol3) > Pressure Acoustics, Frequency Domain > Sound Pressure Level, 3D (acpr).
//    Click Add Result Template in the window toolbar.

    model.result().create("pg6", "PlotGroup3D");
    model.result("pg6").set("data", "rev1");
    model.result("pg6").setIndex("looplevel", 126, 0);
    model.result("pg6").create("surf1", "Surface");
    model.result("pg6").feature("surf1").set("expr", new String[]{"acpr.Lp_t"});
    model.result("pg6").feature("surf1").set("colortable", "Rainbow");
    model.result("pg6").feature("surf1").set("colorscalemode", "linear");
    model.result("pg6").set("showlegendsunit", true);
    model.result("pg6").label("Sound Pressure Level, 3D (acpr)");
    model.result("pg6").label("Sound Pressure Level, 3D (acpr)");
    model.result("pg6").run();

//    In the Results toolbar, click Result Templates to close the Result Templates window.
//    Click the Show Grid button in the Graphics toolbar.

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

//    In the Sound Pressure Level, 3D (acpr) 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 Sensitivity and Phase in the Label text field.

    model.result("pg7").label("Sensitivity and Phase");

//    Locate the Data section.
//    From the Dataset list, select Study 2 - Complete Model/Solution 3 (sol3).

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

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

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

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

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

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

    model.result("pg7").set("xlabel", "Frequency (Hz)");

//    Select the y-axis label checkbox.

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

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

    model.result("pg7").set("ylabel", "SPL (dB)");

//    Locate the Legend section.
//    From the Position list, select Lower middle.

    model.result("pg7").set("legendpos", "lowermiddle");

//    In the Sensitivity and Phase toolbar, click More Plots and choose Octave Band.

    model.result("pg7").create("oct1", "OctaveBand");
    model.result("pg7").feature("oct1").set("quantity", "bandpower");
    model.result("pg7").feature("oct1").set("markerpos", "datapoints");
    model.result("pg7").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("pg7").feature("oct1").selection().geom("geom1");

//    Use the Octave Band Plot to depict the sensitivity. Evaluate the pressure 1 m in front using <c>pext()</c> operator. The reference pressure is the default for an SPL evaluation. Plot the sensitivity both as a continuous curve and in 1/3 octave bands.
//    Locate the y-Axis Data section.
//    In the Expression text field, type pext(0,1[m]).

    model.result("pg7").feature("oct1").set("expr", "pext(0,1[m])");

//    In the Sensitivity and Phase toolbar, click Plot.

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

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

    model.result("pg7").feature("oct1").set("quantity", "bandaveragepsd");

//    From the Band type list, select 1/3 octave.

    model.result("pg7").feature("oct1").set("bandtype", "octave3");

//    Click to expand the Coloring and Style section.
//    From the Type list, select Outline.

    model.result("pg7").feature("oct1").set("type", "outline");

//    Right-click Octave Band 1 and choose Duplicate.

    model.result("pg7").feature().duplicate("oct2", "oct1");
    model.result("pg7").run();

//    In the Settings window for Octave Band, locate the Plot section.
//    From the Quantity list, select Continuous power spectral density.

    model.result("pg7").feature("oct2").set("quantity", "continuous");

//    In the Sensitivity and Phase toolbar, click Plot.

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

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

    model.result("pg7").feature("oct2").set("linewidth", 2);

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

    model.result("pg7").feature("oct2").set("legend", true);

//    From the Legends list, select Manual.

    model.result("pg7").feature("oct2").set("legendmethod", "manual");

//    In the table, enter the following settings:

    model.result("pg7").feature("oct2").setIndex("legends", "Complete Study", 0);

//    Right-click Octave Band 2 and choose Global.

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

//    In the Settings window for Global, locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg7").feature("glob1").setIndex("expr", "arg(pext(0,1[m]))", 0);
    model.result("pg7").feature("glob1").setIndex("unit", "deg", 0);
    model.result("pg7").feature("glob1").setIndex("descr", "Phase", 0);

//    Select the Unwrap phase checkbox.

    model.result("pg7").feature("glob1").set("unwrapphase", true);

//    Click to expand the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg7").feature("glob1").set("linewidth", 2);
    model.result("pg7").run();

//    In the Model Builder window, click Sensitivity and Phase.
//    In the Settings window for 1D Plot Group, locate the Plot Settings section.
//    Select the Two y-axes checkbox.

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

//    Select the Secondary y-axis label checkbox.

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

//    In the associated text field, type Phase (deg).

    model.result("pg7").set("yseclabel", "Phase (deg)");

//    In the table, enter the following settings:

    model.result("pg7").setIndex("plotonsecyaxis", true, 2, 1);

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

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

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

    model.result("pg7").set("xmin", 15);

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

    model.result("pg7").set("ymin", 64);

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

    model.result("pg7").set("ymax", 92);

//    In the Secondary y minimum text field, type -3200.

    model.result("pg7").set("yminsec", -3200);

//    In the Secondary y maximum text field, type 270.

    model.result("pg7").set("ymaxsec", 270);

//    Locate the Legend section.
//    From the Position list, select Lower right.

    model.result("pg7").set("legendpos", "lowerright");

//    In the Sensitivity and Phase toolbar, click Plot.

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

//    Finally, plot the total electric impedance versus the frequency.
//    In the Results toolbar, click 1D Plot Group.

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

//    In the Settings window for 1D Plot Group, type Total Electric Impedance in the Label text field.

    model.result("pg8").label("Total Electric Impedance");

//    Locate the Data section.
//    From the Dataset list, select Study 2 - Complete Model/Solution 3 (sol3).

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

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

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

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

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

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

    model.result("pg8").set("xlabel", "Frequency (Hz)");

//    Select the y-axis label checkbox.

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

//    In the associated text field, type Z (\Omega).

    model.result("pg8").set("ylabel", "Z (\\Omega)");

//    Right-click Total Electric Impedance and choose Global.

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

//    In the Settings window for Global, locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg8").feature("glob1").setIndex("expr", "abs(mf.ZCoil_1)", 0);
    model.result("pg8").feature("glob1").setIndex("unit", "", 0);
    model.result("pg8").feature("glob1").setIndex("descr", "abs(Z)", 0);
    model.result("pg8").feature("glob1").setIndex("expr", "real(mf.ZCoil_1)", 1);
    model.result("pg8").feature("glob1").setIndex("unit", "", 1);
    model.result("pg8").feature("glob1").setIndex("descr", "real(Z)", 1);
    model.result("pg8").feature("glob1").setIndex("expr", "imag(mf.ZCoil_1)", 2);
    model.result("pg8").feature("glob1").setIndex("unit", "", 2);
    model.result("pg8").feature("glob1").setIndex("descr", "imag(Z)", 2);

//    In the Total Electric Impedance toolbar, click Plot.

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

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

    model.result("pg8").set("xlog", true);

//    Next create a plot of the deformation of the loudspeaker showing the displacement. This can in general be used to visualize breakups in the cone and surround.
//    In the Results toolbar, click 3D Plot Group.

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

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

    model.result("pg9").label("Displacement");

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

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

//    Right-click Displacement and choose Surface.

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

//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type solid.disp.

    model.result("pg9").feature("surf1").set("expr", "solid.disp");

//    Right-click Surface 1 and choose Deformation.

    model.result("pg9").feature("surf1").create("def1", "Deform");
    model.result("pg9").feature("surf1").feature("def1").set("revcoordsys", "cylindrical");
    model.result("pg9").run();

//    In the Displacement toolbar, click Plot.

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

//    Now, visualize the directivity of the loudspeaker using the built-in <l>Directivity</l> plot. This is an important plot used to visualize and analyze the spatial response of the speaker as function of the frequency.
//    In the Results toolbar, click 1D Plot Group.

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

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

    model.result("pg10").label("Directivity Plot");

//    Locate the Data section.
//    From the Dataset list, select Study 2 - Complete Model/Solution 3 (sol3).

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

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

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

//    In the Directivity Plot toolbar, click More Plots and choose Directivity.

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

//    Per default the reference direction is along the <eqv>z</eqv>-axis. This defines what 0 deg corresponds to. Change the angles to correspond to everything in front of the speaker, that is, from -90 to 90 deg.
//    In the Settings window for Directivity, locate the Evaluation section.
//    Find the Angles subsection.
//    From the Restriction list, select Manual.

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

//    In the Number of angles text field, type 360.

    model.result("pg10").feature("dir1").set("phidisc", 360);

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

    model.result("pg10").feature("dir1").set("phimin", -90);

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

    model.result("pg10").feature("dir1").set("phirange", 180);

//    Find the Evaluation distance subsection.
//    In the Radius text field, type 1[m].

    model.result("pg10").feature("dir1").set("radius", "1[m]");

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

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

//    In the Levels text field, type -15 -12 -9 -6 -3 -2 -1 1 2 3.

    model.result("pg10").feature("dir1").set("levels", "-15 -12 -9 -6 -3 -2 -1 1 2 3");

//    In the Directivity Plot toolbar, click Plot.

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

//    The horizontal scale can also be represented using a logarithmic scale by selecting <l>x-Axis Log Scale</l> in the <l>Graphics</l> window.
//    In the Results toolbar, click 1D Plot Group.

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

//    In the Settings window for 1D Plot Group, type Coil Power and Efficiency in the Label text field.

    model.result("pg11").label("Coil Power and Efficiency");

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

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

//    Locate the Data section.
//    From the Dataset list, select Study 2 - Complete Model/Solution 3 (sol3).

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

//    Locate the Plot Settings section.
//    Select the Two y-axes checkbox.

    model.result("pg11").set("twoyaxes", true);

//    Locate the Legend section.
//    From the Position list, select Middle left.

    model.result("pg11").set("legendpos", "middleleft");

//    Right-click Coil Power and Efficiency and choose Global.

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

//    In the Settings window for Global, locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg11").feature("glob1").setIndex("expr", "coil_power", 0);
    model.result("pg11").feature("glob1").setIndex("unit", "W", 0);
    model.result("pg11").feature("glob1").setIndex("descr", "Coil power", 0);
    model.result("pg11").run();

//    In the Model Builder window, right-click Coil Power and Efficiency and choose Global.

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

//    In the Settings window for Global, locate the y-Axis section.
//    Select the Plot on secondary y-axis checkbox.

    model.result("pg11").feature("glob2").set("plotonsecyaxis", true);

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

    model.result("pg11").feature("glob2").setIndex("expr", "aco_eff", 0);
    model.result("pg11").feature("glob2").setIndex("unit", "%", 0);
    model.result("pg11").feature("glob2").setIndex("descr", "Acoustic efficiency", 0);

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

    model.result("pg11").set("xlog", true);

//    In the Coil Power and Efficiency toolbar, click Plot.

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

//    The plot should look like this.
//    In the following steps, create a new study where the <l>Narrow Region Acoustics</l> features are disabled. This will highlight how the thermoviscous losses have a large influence around the back cavity modes but negligible influence on the global response of the loudspeaker for the rest of the frequencies.
//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select Empty Study.
//    Click Add Study in the window toolbar.

    model.study().create("std3");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Model Builder window, right-click Study 2 - Complete Model > Step 1: Stationary and choose Copy.
//    In the Model Builder window, right-click Study 3 and choose Paste Stationary.

    model.study("std3").feature().copy("stat", "std2/stat");

//    In the Model Builder window, right-click Study 2 - Complete Model > Step 2: Frequency-Domain Perturbation and choose Copy.
//    In the Model Builder window, right-click Study 3 and choose Paste Frequency-Domain Perturbation.

    model.study("std3").feature().copy("frlin", "std2/frlin");

//    In the Settings window for Frequency-Domain Perturbation, locate the Physics and Variables Selection section.
//    Select the Modify model configuration for study step checkbox.

    model.study("std3").feature("frlin").set("useadvanceddisable", true);

//    In the tree, select Component 1 (comp1) > Pressure Acoustics, Frequency Domain (acpr) > Narrow Region Acoustics 1.
//    Click Disable.

    model.study("std3").feature("frlin").set("disabledphysics", new String[]{"acpr/nra1"});

//    In the tree, select Component 1 (comp1) > Pressure Acoustics, Frequency Domain (acpr) > Narrow Region Acoustics 2.
//    Click Disable.

    model.study("std3").feature("frlin").set("disabledphysics", new String[]{"acpr/nra1", "acpr/nra2"});

//    In the Model Builder window, click Study 3.
//    In the Settings window for Study, type Study 3 - Complete Model, Without Narrow Region Acoustics in the Label text field.

    model.study("std3").label("Study 3 - Complete Model, Without Narrow Region Acoustics");

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

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

//    In the Study toolbar, click Compute.

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

    return model;
  }

  public static Model run4(Model model) {

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

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

//    In the Model Builder window, under Results > Sensitivity and Phase, click Octave Band 2.
//    In the Settings window for Octave Band, locate the Data section.
//    From the Dataset list, select Study 3 - Complete Model, Without Narrow Region Acoustics/Solution 5 (sol5).

    model.result("pg7").feature("oct2").set("data", "dset5");

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

    model.result("pg7").feature("oct2").setIndex("legends", "Complete Study - Without Narrow Region Acoustics", 0);

//    Locate the Coloring and Style section.
//    Find the Line style subsection.
//    From the Line list, select Dotted.

    model.result("pg7").feature("oct2").set("linestyle", "dotted");

//    Right-click Results > Sensitivity and Phase > Octave Band 2 and choose Duplicate.

    model.result("pg7").feature().duplicate("oct3", "oct2");
    model.result("pg7").run();

//    In the Settings window for Octave Band, locate the Data section.
//    From the Dataset list, select From parent.

    model.result("pg7").feature("oct3").set("data", "parent");

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

    model.result("pg7").feature("oct3").setIndex("legends", "Complete Study", 0);

//    Locate the Coloring and Style section.
//    Find the Line style subsection.
//    From the Line list, select Solid.

    model.result("pg7").feature("oct3").set("linestyle", "solid");

//    In the Sensitivity and Phase toolbar, click Plot.

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

//    Proceed and create a mirror dataset. It will be used to visually compare the frequency distribution in the driver at different frequencies, by having them side by side.
//    In the Results toolbar, click More Datasets and choose Mirror 2D.

    model.result().dataset().create("mir1", "Mirror2D");

//    In the Settings window for Mirror 2D, locate the Data section.
//    From the Dataset list, select Study 3 - Complete Model, Without Narrow Region Acoustics/Solution 5 (sol5).

    model.result().dataset("mir1").set("data", "dset5");

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

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

//    In the Settings window for 2D Plot Group, type Acoustic Pressure - Without Narrow Region Acoustics in the Label text field.

    model.result("pg12").label("Acoustic Pressure - Without Narrow Region Acoustics");

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

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

//    Locate the Data section.
//    From the Dataset list, select Mirror 2D 1.

    model.result("pg12").set("data", "mir1");

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

    model.result("pg12").setIndex("looplevel", 81, 0);

//    Right-click Acoustic Pressure - Without Narrow Region Acoustics and choose Surface.

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

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

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

//    Locate the Coloring and Style section.
//    From the Scale list, select Linear symmetric.

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

//    From the Color table list, select Wave.

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

//    In the Acoustic Pressure - Without Narrow Region Acoustics toolbar, click Plot.

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

//    Right-click Surface 1 and choose Duplicate.

    model.result("pg12").feature().duplicate("surf2", "surf1");
    model.result("pg12").run();

//    In the Settings window for Surface, locate the Data section.
//    From the Dataset list, select Study 3 - Complete Model, Without Narrow Region Acoustics/Solution 5 (sol5).

    model.result("pg12").feature("surf2").set("data", "dset5");

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

    model.result("pg12").feature("surf2").setIndex("looplevel", 82, 0);

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

    model.result("pg12").feature("surf2").set("titletype", "none");

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

    model.result("pg12").feature("surf2").set("inheritplot", "surf1");
    model.result("pg12").run();

//    In the Model Builder window, right-click Acoustic Pressure - Without Narrow Region Acoustics and choose Annotation.

    model.result("pg12").create("ann1", "Annotation");

//    In the Settings window for Annotation, locate the Annotation section.
//    In the Text text field, type Pressure at 630 Hz.

    model.result("pg12").feature("ann1").set("text", "Pressure at 630 Hz");

//    Locate the Position section.
//    In the x text field, type 10[mm].

    model.result("pg12").feature("ann1").set("posxexpr", "10[mm]");

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

    model.result("pg12").feature("ann1").set("posyexpr", "20[mm]");

//    Locate the Coloring and Style section.
//    Clear the Show point checkbox.

    model.result("pg12").feature("ann1").set("showpoint", false);

//    Right-click Annotation 1 and choose Duplicate.

    model.result("pg12").feature().duplicate("ann2", "ann1");
    model.result("pg12").run();

//    In the Settings window for Annotation, locate the Position section.
//    In the x text field, type -140[mm].

    model.result("pg12").feature("ann2").set("posxexpr", "-140[mm]");

//    Locate the Annotation section.
//    In the Text text field, type Pressure at 600 Hz.

    model.result("pg12").feature("ann2").set("text", "Pressure at 600 Hz");
    model.result("pg12").run();

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

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

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

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

//    Locate the Data section.
//    From the Dataset list, select Mirror 2D 1.

    model.result("pg12").feature("line1").set("data", "mir1");

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

    model.result("pg12").feature("line1").set("titletype", "none");

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

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

//    From the Color list, select Black.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Acoustic Pressure - Without Narrow Region Acoustics toolbar, click Plot.

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

//    Now, proceed to set up an eigenfrequency analysis for the structural part of the loudspeaker driver.
//    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("std4");
    model.study("std4").create("eig", "Eigenfrequency");
    model.study("std4").feature("eig").set("chkeigregion", true);
    model.study("std4").feature("eig").set("storefact", false);
    model.study("std4").feature("eig").set("linpsolnum", "auto");
    model.study("std4").feature("eig").set("plotgrouparr", new String[]{"Default"});
    model.study("std4").feature("eig").set("solnum", "auto");
    model.study("std4").feature("eig").set("notsolnum", "auto");
    model.study("std4").feature("eig").set("outputmap", new String[]{});
    model.study("std4").feature("eig").set("ngenAUX", "1");
    model.study("std4").feature("eig").set("goalngenAUX", "1");
    model.study("std4").feature("eig").set("ngenAUX", "1");
    model.study("std4").feature("eig").set("goalngenAUX", "1");
    model.study("std4").feature("eig").setSolveFor("/physics/mf", false);
    model.study("std4").feature("eig").setSolveFor("/physics/acpr", false);
    model.study("std4").feature("eig").setSolveFor("/multiphysics/asb1", false);
    model.study("std4").feature("eig").setSolveFor("/multiphysics/mmcpl1", false);

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

    model.study("std4").label("Study 4 - Eigenfrequency");

//    In the Model Builder window, under Study 4 - Eigenfrequency, click Step 1: Eigenfrequency.
//    In the Settings window for Eigenfrequency, locate the Study Settings section.
//    Select the Desired number of eigenfrequencies checkbox.

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

//    In the associated text field, type 10.

    model.study("std4").feature("eig").set("neigs", 10);

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

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

//    In the Study toolbar, click Compute.

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

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

    model.result().create("pg13", "PlotGroup2D");
    model.result("pg13").set("data", "dset7");
    model.result("pg13").setIndex("looplevel", 1, 0);
    model.result("pg13").label("Mode Shape (solid)");
    model.result("pg13").set("showlegends", false);
    model.result("pg13").create("surf1", "Surface");
    model.result("pg13").feature("surf1").set("expr", new String[]{"solid.disp"});
    model.result("pg13").feature("surf1").set("threshold", "manual");
    model.result("pg13").feature("surf1").set("thresholdvalue", 0.2);
    model.result("pg13").feature("surf1").set("colortable", "Rainbow");
    model.result("pg13").feature("surf1").set("colortabletrans", "none");
    model.result("pg13").feature("surf1").set("colorscalemode", "linear");
    model.result("pg13").feature("surf1").set("colortable", "AuroraBorealis");
    model.result("pg13").feature("surf1").create("def", "Deform");
    model.result("pg13").feature("surf1").feature("def").set("expr", new String[]{"u", "w"});
    model.result("pg13").feature("surf1").feature("def").set("descr", "Displacement field");
    model.result().dataset().create("dset7solidrev", "Revolve2D");
    model.result().dataset("dset7solidrev").set("data", "dset7");
    model.result().dataset("dset7solidrev").set("revangle", 225);
    model.result().dataset("dset7solidrev").set("startangle", -90);
    model.result().dataset("dset7solidrev").set("modenumber", "solid.mk");
    model.result().create("pg14", "PlotGroup3D");
    model.result("pg14").set("data", "dset7solidrev");
    model.result("pg14").setIndex("looplevel", 1, 0);
    model.result("pg14").label("Mode Shape, 3D (solid)");
    model.result("pg14").set("showlegends", false);
    model.result("pg14").create("surf1", "Surface");
    model.result("pg14").feature("surf1").set("expr", new String[]{"solid.disp"});
    model.result("pg14").feature("surf1").set("threshold", "manual");
    model.result("pg14").feature("surf1").set("thresholdvalue", 0.2);
    model.result("pg14").feature("surf1").set("colortable", "Rainbow");
    model.result("pg14").feature("surf1").set("colortabletrans", "none");
    model.result("pg14").feature("surf1").set("colorscalemode", "linear");
    model.result("pg14").feature("surf1").set("colortable", "AuroraBorealis");
    model.result("pg14").feature("surf1").create("def", "Deform");
    model.result("pg14").feature("surf1").feature("def").set("revcoordsys", "cylindrical");
    model.result("pg14").feature("surf1").feature("def").set("expr", new String[]{"u", "v", "w"});
    model.result("pg14").feature("surf1").feature("def").set("descr", "Displacement field");
    model.result("pg14").feature("surf1").feature("def").set("descractive", true);
    model.result().evaluationGroup().create("std4EvgFrq", "EvaluationGroup");
    model.result().evaluationGroup("std4EvgFrq").set("data", "dset7");
    model.result().evaluationGroup("std4EvgFrq").label("Eigenfrequencies (Study 4 - Eigenfrequency)");
    model.result().evaluationGroup("std4EvgFrq").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("expr", "2*pi*freq", 0);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("unit", "rad/s", 0);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("descr", "Angular frequency", 0);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("expr", "imag(freq)/abs(freq)", 1);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("unit", "1", 1);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("descr", "Damping ratio", 1);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("expr", "abs(freq)/imag(freq)/2", 2);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("unit", "1", 2);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("descr", "Quality factor", 2);
    model.result().evaluationGroup("std4EvgFrq").run();
    model.result("pg13").run();

//    In the Model Builder window, under Results > Datasets, click Study 4 - Eigenfrequency/Solution 7 (sol7).
//    In the Results toolbar, click Attributes and choose Selection.
//    In the Settings window for Selection, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Domain.

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

//    From the Selection list, select Structural Domains.

    model.result().dataset("dset7").selection().named("uni1");
    model.result("pg14").run();

    model.view("view4").set("showgrid", false);

//    In the Model Builder window, under Results, click Mode Shape, 3D (solid).

    model.result("pg14").stepNext(0);
    model.result("pg14").run();
    model.result("pg14").stepNext(0);
    model.result("pg14").run();
    model.result("pg14").stepNext(0);
    model.result("pg14").run();
    model.result("pg14").stepNext(0);
    model.result("pg14").run();
    model.result("pg1").run();
    model.result("pg1").set("view", "new");
    model.result("pg1").run();
    model.result("pg2").run();
    model.result("pg2").run();
    model.result("pg3").run();
    model.result("pg3").setIndex("looplevel", 38, 0);
    model.result("pg3").run();
    model.result("pg3").setIndex("looplevel", 88, 0);
    model.result("pg3").run();
    model.result("pg6").run();

    model.title("Loudspeaker Driver \u2014 Frequency-Domain Analysis");

    model
         .description("This example shows how to model a loudspeaker driver of the dynamic cone type, common for low and medium frequencies. The analysis is carried out in the frequency domain and thus represents the linear behavior of the driver. The model analysis includes the total electric impedance and the on-axis sound pressure level at a nominal driving voltage, as functions of the frequency. The spatial characteristics of the driver are depicted in a directivity plot.\n\nThe tutorial model is set up using a combination of the Magnetic Fields interface and the Acoustic\u2013Structure Interaction multiphysics interface. The first analysis solves only the electromagnetic part of the problem when the driver is at rest. From here, the driving force factor and the blocked voice coil impedance can be extracted and exported for further use. The next analysis is of the full model, including the relevant multiphysics interactions like acoustic\u2013structure interaction and the electromagnetic force acting on the voice coil. This study also includes thermal and viscous damping in the air gap between the voice coil and pole pieces. An eigenfrequency analysis is also carried out in order to identify the cone modes and break up frequencies.");

    return model;
  }

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

}
