/*
 * loudspeaker_driver_3d.java
 */

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

/** Model exported on May 11 2026, 09:18 by COMSOL 6.4.0.417. */
public class loudspeaker_driver_3d {

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

//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    In the Model Wizard window, click 3D.
//    In the Select Physics tree, select AC/DC > Electromagnetic Fields > Magnetic Fields (mf).
//    Click Add.
//    In the Select Physics tree, select Acoustics > Pressure Acoustics > Pressure Acoustics, Frequency Domain (acpr).
//    Click Add.
//    In the Select Physics tree, select Structural Mechanics > Solid Mechanics (solid).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select Preset Studies for Some Physics Interfaces > Coil Geometry Analysis.
//    Click Done.

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

    model.component("comp1").geom().create("geom1", 3);
    model.component("comp1").geom("geom1").geomRep("comsol");

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

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

    model.study().create("std1");
    model.study("std1").create("ccc", "CoilCurrentCalculation");
    model.study("std1").feature("ccc").set("CoilName", "1");
    model.study("std1").feature("ccc").set("outputmap", new String[]{});
    model.study("std1").feature("ccc").set("ngenAUX", "1");
    model.study("std1").feature("ccc").set("goalngenAUX", "1");
    model.study("std1").feature("ccc").set("ngenAUX", "1");
    model.study("std1").feature("ccc").set("goalngenAUX", "1");

//    The model parameters are loaded from the file <c>loudspeaker_driver_3d_parameters.txt</c>.
//    In the Model Builder window, under Global Definitions, click Parameters 1.
//    In the Settings window for Parameters, locate the Parameters section.
//    Click Load from File.
//    Browse to the model's Application Library folder and double-click the file loudspeaker_driver_3d_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("N0", "100", "Number of turns in coil");
    model.param().set("V0", "3.55[V]", "Peak driving voltage");
    model.param().set("f_loss", "40[Hz]", "Frequency at which loss factor is given");
    model.param().set("omega_loss", "2*pi*f_loss", "Angular frequency at which loss factor is given");
    model.param().set("fmax", "4000[Hz]", "Maximum frequency");
    model.param().set("h_slit1", "0.2[mm]", "Magnetic gap slit 1");
    model.param().set("h_slit2", "0.4[mm]", "Magnetic gap slit 2");
    model.param().set("deltaS", "165[mm]*50", "Artificial skin depth in free space domain");

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

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

//    Locate the Advanced section.
//    From the Geometry representation list, select CAD kernel.

    model.component("comp1").geom("geom1").geomRep("cadps");

//    In this model, the geometry is imported as a sequence from the geometry file. Symmetry planes are used to only model a quarter of the geometry and reduce the number of degrees of freedom to solve for. The instructions to the geometry can be found in the appendix at the end of this document.
//    In the Geometry toolbar, click Import.

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

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

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

//    Click Import.

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

//    In the Home toolbar, click Build All.

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

//    Create selections to make the physics setup easier.
//    In the Definitions toolbar, click Explicit.

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

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

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

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

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

//    Select Boundaries 1, 2, 4, 5, 7, 8, 11, 15, 21, 25, 28, 31, 34, 37, 40, 43, 45, 48, 51, 56, 59, 62, 65, 69, 72, 75, 80, 85, 91, 97, 132, 138, 146, 152, 155, 160, 174, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 205, 212, 219, 221, 222, 223.

    model.component("comp1").selection("sel1")
         .set(1, 2, 4, 5, 7, 8, 11, 15, 21, 25, 28, 31, 34, 37, 40, 43, 45, 48, 51, 56, 59, 62, 65, 69, 72, 75, 80, 85, 91, 97, 132, 138, 146, 152, 155, 160, 174, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 205, 212, 219, 221, 222, 223);

//    Select the Group by continuous tangent checkbox.

    model.component("comp1").selection("sel1").set("groupcontang", true);

//    In the Definitions toolbar, click Explicit.

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

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

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

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

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

//    Select Domains 16, 17, 18.

    model.component("comp1").selection("sel2").set(16, 17, 18);

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel3").label("Air Domain");

//    Select Domains 1, 3, 5, 6, 12, 19, 21, 23, 29, 32.

    model.component("comp1").selection("sel3").set(1, 3, 5, 6, 12, 19, 21, 23, 29, 32);

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel4").label("Aluminum Domain");

//    Select Domains 25, 27, 30.

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

//    In the Definitions toolbar, click Explicit.

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

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

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

//    Select Domain 26.

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

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

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

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel6").label("Pole Pieces");

//    Select Domains 4, 24.

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

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel7").label("Nonconductive Solid Domains");

//    Select Domains 7, 8, 9, 10, 11, 13, 14, 20.

    model.component("comp1").selection("sel7").set(7, 8, 9, 10, 11, 13, 14, 20);

//    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 all come from a library created especially for this model (loaded from the file <c>loudspeaker_driver_materials.mph</c>). You may notice that some of the materials report missing properties. For example, the composite does not include any electromagnetic properties. This is not a problem, as the magnetic fields will not be modeled 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");

//    In the tree, select Built-in > Aluminum.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat3", "Common");
    model.component("comp1").material("mat3").propertyGroup()
         .create("Enu", "Enu", "Young's modulus and Poisson's ratio");
    model.component("comp1").material("mat3").propertyGroup().create("Murnaghan", "Murnaghan", "Murnaghan");
    model.component("comp1").material("mat3").label("Aluminum");
    model.component("comp1").material("mat3").set("family", "aluminum");
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("def").set("heatcapacity", "900[J/(kg*K)]");
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("thermalconductivity", new String[]{"238[W/(m*K)]", "0", "0", "0", "238[W/(m*K)]", "0", "0", "0", "238[W/(m*K)]"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("electricconductivity", new String[]{"3.774e7[S/m]", "0", "0", "0", "3.774e7[S/m]", "0", "0", "0", "3.774e7[S/m]"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"23e-6[1/K]", "0", "0", "0", "23e-6[1/K]", "0", "0", "0", "23e-6[1/K]"});
    model.component("comp1").material("mat3").propertyGroup("def").set("density", "2700[kg/m^3]");
    model.component("comp1").material("mat3").propertyGroup("Enu").set("E", "70[GPa]");
    model.component("comp1").material("mat3").propertyGroup("Enu").set("nu", "0.33");
    model.component("comp1").material("mat3").propertyGroup("Murnaghan").set("l", "-250[GPa]");
    model.component("comp1").material("mat3").propertyGroup("Murnaghan").set("m", "-330[GPa]");
    model.component("comp1").material("mat3").propertyGroup("Murnaghan").set("n", "-350[GPa]");

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    In the Materials toolbar, click 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 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.
//    In the tree, select loudspeaker driver materials > Composite.
//    Click Add to Component.

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

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

    model.component("comp1").material().create("mat5", "Common");
    model.component("comp1").material("mat5").label("Cloth");
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("electricconductivity", new String[]{"0", "0", "0", "0", "0", "0", "0", "0", "0"});
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat5").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat5").propertyGroup("def").set("youngsmodulus", "0.58[GPa]");
    model.component("comp1").material("mat5").propertyGroup("def").set("poissonsratio", "0.3");
    model.component("comp1").material("mat5").propertyGroup("def").set("density", "650[kg/m^3]");

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

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

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

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

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

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

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

    model.component("comp1").material().create("mat9", "Common");
    model.component("comp1").material("mat9").propertyGroup()
         .create("RemanentFluxDensity", "RemanentFluxDensity", "Remanent flux density");
    model.component("comp1").material("mat9").label("Generic Ferrite");
    model.component("comp1").material("mat9").propertyGroup("def").set("lossfactor", "0.01");

    return model;
  }

  public static Model run2(Model model) {
    model.component("comp1").material("mat9").propertyGroup("def")
         .set("electricconductivity", new String[]{"0", "0", "0", "0", "0", "0", "0", "0", "0"});
    model.component("comp1").material("mat9").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat9").propertyGroup("def").set("poissonsratio", "0.3");
    model.component("comp1").material("mat9").propertyGroup("def").set("youngsmodulus", "200[GPa]");
    model.component("comp1").material("mat9").propertyGroup("def").set("density", "5000[kg/m^3]");
    model.component("comp1").material("mat9").propertyGroup("RemanentFluxDensity")
         .set("murec", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat9").propertyGroup("RemanentFluxDensity").set("normBr", "0.4[T]");

//    Click Done.
//    In the Model Builder window, under Component 1 (comp1) > Materials, click Soft Iron (With Losses) (mat2).
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Selection list, select Pole Pieces.

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

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

    model.component("comp1").material("mat2").propertyGroup("def").set("density", new String[]{"7800[kg/m^3]"});
    model.component("comp1").material("mat2").propertyGroup()
         .create("Enu", "Enu", "Young's_modulus_and_Poisson's_ratio");
    model.component("comp1").material("mat2").propertyGroup("Enu").set("E", new String[]{"180[GPa]"});
    model.component("comp1").material("mat2").propertyGroup("Enu").set("nu", new String[]{"0.29"});

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

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

//    In the Model Builder window, click Composite (mat4).
//    Select Domains 2, 22.

    model.component("comp1").material("mat4").selection().set(2, 22);

//    In the Model Builder window, click Cloth (mat5).
//    Select Domain 20.

    model.component("comp1").material("mat5").selection().set(20);

//    In the Model Builder window, click Foam (mat6).
//    Select Domains 28, 31.

    model.component("comp1").material("mat6").selection().set(28, 31);

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

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

//    In the Model Builder window, click Glass Fiber (mat8).
//    Select Domains 7, 8, 9, 10, 11, 13, 14, 15.

    model.component("comp1").material("mat8").selection().set(7, 8, 9, 10, 11, 13, 14, 15);

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

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

//    The <l>Magnetic Fields</l> physics is 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 Manual.

    model.component("comp1").physics("mf").selection()
         .set(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);

//    Select Domains 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 29, 32.

    model.component("comp1").physics("mf").selection()
         .set(1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 29, 32);

//    The <l>Free Space</l> feature is per default assigned to all domains where the physics interface is active (and is here used in the Air domains). Add Ampère's Law in the remaining domains where different constitutive relations are needed.
//    The <l>Stabilization conductivity</l> is here defined using the <l>From skin depth</l> option. This adds an artificial electric conductivity, used to stabilize the numerical method, which gives a skin depth equal to 50 times the radius of the air domain (165 mm). This value is a bit less conservative than the automatic option and gives a faster convergence. For a frequency dependent study the stabilizing conductivity will use the given frequency solved for. For the stationary study it will use the fallback value, but here the conductivity has no influence on the solution. The fallback value becomes important for transient models.
//    In the Model Builder window, under Component 1 (comp1) > Magnetic Fields (mf), click Free Space 1.
//    In the Settings window for Free Space, locate the Stabilization section.
//    From the \[\sigma_\textrm{stab}\] list, select From skin depth.

    model.component("comp1").physics("mf").feature("fsp1").set("sigma_stab_mat", "from_delta_s");

//    Find the Skin depth subsection.
//    In the \[\delta_\textrm{s}\] text field, type deltaS.

    model.component("comp1").physics("mf").feature("fsp1").set("delta_s", "deltaS");

//    In the Physics toolbar, click Domains and choose Ampère's Law in Solids.

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

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

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

//    In the nonconductive solid domains a small conductivity value of 5 S/m is used. The exact value used will have a very small influence on the results when compared to other numerical factors like, for example, the mesh resolution. For numerical reasons it is best to avoid the use of zero conductivity.
//    In the Model Builder window, click Ampère's Law in Solids 1.
//    Locate the Constitutive Relation Jc-E section.
//    From the \[\sigma\] list, select User defined.

    model.component("comp1").physics("mf").feature("als1").set("sigma_mat", "userdef");

//    In the associated text field, type 5[S/m].

    model.component("comp1").physics("mf").feature("als1")
         .set("sigma", new String[]{"5[S/m]", "0", "0", "0", "5[S/m]", "0", "0", "0", "5[S/m]"});

//    In the Physics toolbar, click Domains and choose Ampère's Law in Solids.

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

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

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

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

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

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

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

//    Locate the Constitutive Relation Jc-E section.
//    From the \[\sigma\] list, select User defined.

    model.component("comp1").physics("mf").feature("als2").set("sigma_mat", "userdef");

//    In the associated text field, type 5[S/m].

    model.component("comp1").physics("mf").feature("als2")
         .set("sigma", new String[]{"5[S/m]", "0", "0", "0", "5[S/m]", "0", "0", "0", "5[S/m]"});

//    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("als3", "AmperesLawSolid", 3);

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

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

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

    model.component("comp1").physics("mf").feature("als3").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("als4", "AmperesLawSolid", 3);

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

    model.component("comp1").physics("mf").feature("als4").selection().named("sel4");

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

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

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

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

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

//    From the Coil type list, select Numeric.
//    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 only be active in the <l>Frequency Domain, Perturbation</l> study.
//    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-8 m<sup>2</sup>. The area of the coil domain is 6e-8 m<sup>2</sup>, making the fill factor approximately 60%.
//    In the Model Builder window, expand the Component 1 (comp1) > Magnetic Fields (mf) > Domain Coil 1 > Geometry Analysis 1 node, then click Geometry Analysis 1.
//    In the Settings window for Geometry Analysis, click to expand the Symmetry Specification section.
//    In the \[F_L\] text field, type 4.

    model.component("comp1").physics("mf").feature("coil1").feature("ccc1").set("fl", 4);

//    In the Model Builder window, click Input 1.
//    Select Boundaries 190, 191, 192.

    model.component("comp1").physics("mf").feature("coil1").feature("ccc1").feature("ct1").selection()
         .set(190, 191, 192);

//    In the Model Builder window, click Geometry Analysis 1.
//    In the Physics toolbar, click Attributes and choose Output.

    model.component("comp1").physics("mf").feature("coil1").feature("ccc1").create("cg1", "CoilGround", 2);

//    Select Boundaries 56, 59, 62.

    model.component("comp1").physics("mf").feature("coil1").feature("ccc1").feature("cg1").selection()
         .set(56, 59, 62);

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

    model.component("comp1").physics("mf").create("symp1", "SymmetryPlane", 2);

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

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

//    Select the air domains above and under the speaker.
//    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 Domain.

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

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

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

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

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

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

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

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

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

//    In the Settings window for Exterior Field Calculation, locate the Exterior Field Calculation section.
//    From the Symmetry type list, select Sector symmetry with one symmetry plane.

    model.component("comp1").physics("acpr").feature("efc1").set("SymmetryType", "SectorSymmetryWithPlane");

//    From the Transformation list, select Rotation and reflection.

    model.component("comp1").physics("acpr").feature("efc1").set("TransformationType", "RotationAndReflection");

//    In the \[n\] text field, type 4.

    model.component("comp1").physics("acpr").feature("efc1").set("n", 4);

//    In the Physics toolbar, click Boundaries and choose Perfectly Matched Boundary.

    model.component("comp1").physics("acpr").create("pmb1", "PerfectlyMatchedBoundary", 2);

//    Use the <l>Perfectly Matched Boundary</l> to model a nonreflecting condition and avoid unphysical reflections (spurious reflections) where the sound leaves the model.
//    Select Boundaries 3, 10.

    model.component("comp1").physics("acpr").feature("pmb1").selection().set(3, 10);

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

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

//    Select Domain 23.

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

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

    model.component("comp1").physics("acpr").feature("nra1").set("h", "h_slit1");

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

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

//    Select Domain 6.

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

//    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("nra2").set("DuctType", "Slit");

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

    model.component("comp1").physics("acpr").feature("nra2").set("h", "h_slit2");

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

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

//    Select Domain 12.

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

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

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

//    In the \[a\] text field, type 1.5[mm].

    model.component("comp1").physics("acpr").feature("nra3").set("a", "1.5[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.
//    Click Clear Selection.

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

//    Select Domains 2, 4, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 20, 22, 24, 25, 26, 27, 28, 30, 31.

    model.component("comp1").physics("solid").selection()
         .set(2, 4, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 20, 22, 24, 25, 26, 27, 28, 30, 31);

//    The magnet, pole piece, and top plate are left out of the above selection. These domains are considered perfectly rigid by using the default sound hard wall condition on their surfaces.
//    Add damping to some of the solid materials.
//    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", 3);

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

//    Select Domains 2, 7, 8, 9, 10, 11, 13, 14, 15, 22.

    model.component("comp1").physics("solid").feature("lemm1").feature("dmp1").selection()
         .set(2, 7, 8, 9, 10, 11, 13, 14, 15, 22);

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

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

//    Select Domain 20.

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

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

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

//    Select Domains 28, 31.

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

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

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

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

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

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

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

//    Select Boundaries 159, 168, 169, 170.

    model.component("comp1").physics("solid").feature("fix1").selection().set(159, 168, 169, 170);

//    Now is a good time to inspect the <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 Boundary > Acoustic–Structure Boundary.

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

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

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

//    Now, the <l>Magnetomechanics</l> multiphysics feature is added to handle the Lorentz force on the coil (it represents the product of the time-harmonic current and the static magnetic field in which it is traveling).
//    In the Physics toolbar, click Multiphysics Couplings and choose Domain > Magnetomechanics, Solid.

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

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

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

//    Locate the Lorentz Coupling section.
//    Select the Only use Lorentz force checkbox.

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

//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, type Study 1 - Frequency Response in the Label text field.

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

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

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

//    In the Model Builder window, under Study 1 - Frequency Response, click Step 1: Coil Geometry Analysis.
//    In the Settings window for Coil Geometry Analysis, locate the Study Settings section.
//    Clear the Include geometric nonlinearity checkbox.

    model.study("std1").feature("ccc").set("geometricNonlinearity", false);

//    The <l>Study</l> node already contains the <l>Coil Current Calculation</l> study. Add a <l>Stationary</l> study step and disable the Pressure Acoustics and Solid Mechanics interfaces.
//    In the Study toolbar, click Stationary.

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

//    In the Settings window for Stationary, locate the Physics and Variables Selection section.

    model.study("std1").feature("stat").setSolveFor("/multiphysics/mmcpl1", false);

//    In the Solve for column of the table, under Component 1 (comp1), clear the checkbox for Solid Mechanics (solid).
//    In the Solve for column of the table, under Component 1 (comp1) > Multiphysics, clear the checkbox for Magnetomechanics, Solid 1 (mmcpl1).
//    Add a <l>Frequency Domain, Perturbation</l> study step.
//    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.
//    Click Range.
//    In the Range dialog, choose ISO preferred frequencies from the Entry method list.
//    In the Start frequency text field, type 20.
//    In the Stop frequency text field, type fmax.
//    Click Replace.

    model.study("std1").feature("frlin").set("plist", "{31.5, 63, 125, 250, 500, 1e3, 2e3, 4e3}");

//    In this model, the mesh is set up manually. Proceed by directly adding the desired mesh component.
//    The mesh used to compute 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 one, preferably two 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, five to six 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 five elements per wavelength in the acoustic domains.
//    In the Mesh toolbar, click More Generators and choose Mapped.

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

//    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 343[m/s]/fmax/5.

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

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

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

//    In the Model Builder window, click Mapped 1.
//    Select Boundaries 181, 190, 191, 192, 194, 197.

    model.component("comp1").mesh("mesh1").feature("map1").selection().set(181, 190, 191, 192, 194, 197);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 288, 318.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").selection().set(288, 318);

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

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

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 283, 309, 310, 311, 313, 317, 320, 321, 330, 331, 371, 372, 377, 393.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis2").selection()
         .set(283, 309, 310, 311, 313, 317, 320, 321, 330, 331, 371, 372, 377, 393);

//    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("dis2").set("numelem", 2);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 335, 336, 342, 343, 353, 354, 355, 356, 364, 365, 380.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis3").selection()
         .set(335, 336, 342, 343, 353, 354, 355, 356, 364, 365, 380);

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

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis3").set("numelem", 4);

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

    model.component("comp1").mesh("mesh1").create("edg1", "Edge");

//    Select Edges 298, 312, 314.

    model.component("comp1").mesh("mesh1").feature("edg1").selection().set(298, 312, 314);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edge 312.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("dis1").selection().set(312);

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

    model.component("comp1").mesh("mesh1").feature("edg1").feature("dis1").set("numelem", 3);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 286, 298, 302, 314, 317.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("dis2").selection().set(286, 298, 302, 314, 317);

//    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("edg1").feature("dis2").set("numelem", 2);

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

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

//    Select Boundaries 182, 183, 184, 185, 187, 188, 189.

    model.component("comp1").mesh("mesh1").feature("map2").selection().set(182, 183, 184, 185, 187, 188, 189);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edge 301.

    model.component("comp1").mesh("mesh1").feature("map2").feature("dis1").selection().set(301);

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

    model.component("comp1").mesh("mesh1").feature("map2").feature("dis1").set("numelem", 6);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 285, 295.

    model.component("comp1").mesh("mesh1").feature("map2").feature("dis2").selection().set(285, 295);

//    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("map2").feature("dis2").set("numelem", 2);

//    In the Mesh toolbar, click Swept.

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

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

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

//    Select Domains 6, 7, 8, 9, 10, 13, 14, 15, 16, 17, 18, 20, 23.

    model.component("comp1").mesh("mesh1").feature("swe1").selection()
         .set(6, 7, 8, 9, 10, 13, 14, 15, 16, 17, 18, 20, 23);

//    In the Mesh toolbar, click Distribution.

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

//    Select Domains 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 23.

    model.component("comp1").mesh("mesh1").feature("swe1").feature("dis1").selection()
         .set(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 23);

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

    return model;
  }

  public static Model run3(Model model) {

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

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

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

//    Select Boundaries 38, 41.

    model.component("comp1").mesh("mesh1").feature("ftri1").selection().set(38, 41);

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

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

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

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

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

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

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

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

//    In the Mesh toolbar, click Swept.

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

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

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

//    Select Domains 11, 12.

    model.component("comp1").mesh("mesh1").feature("swe2").selection().set(11, 12);

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

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

//    Select Boundaries 93, 94, 111, 112, 120, 121, 122, 123, 126, 127, 128, 129, 137, 141.

    model.component("comp1").mesh("mesh1").feature("map3").selection()
         .set(93, 94, 111, 112, 120, 121, 122, 123, 126, 127, 128, 129, 137, 141);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 328, 329.

    model.component("comp1").mesh("mesh1").feature("map3").feature("dis1").selection().set(328, 329);

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

    model.component("comp1").mesh("mesh1").feature("map3").feature("dis1").set("numelem", 10);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 369, 370.

    model.component("comp1").mesh("mesh1").feature("map3").feature("dis2").selection().set(369, 370);

//    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("map3").feature("dis2").set("numelem", 2);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 375, 376.

    model.component("comp1").mesh("mesh1").feature("map3").feature("dis3").selection().set(375, 376);

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

    model.component("comp1").mesh("mesh1").feature("map3").feature("dis3").set("numelem", 3);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 358, 359.

    model.component("comp1").mesh("mesh1").feature("map3").feature("dis4").selection().set(358, 359);

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

    model.component("comp1").mesh("mesh1").feature("map3").feature("dis4").set("numelem", 4);

//    In the Mesh toolbar, click Distribution.

    model.component("comp1").mesh("mesh1").feature("map3").create("dis5", "Distribution");

//    Select Edge 190.

    model.component("comp1").mesh("mesh1").feature("map3").feature("dis5").selection().set(190);

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

    model.component("comp1").mesh("mesh1").feature("map3").feature("dis5").set("numelem", 18);

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

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

//    Select Boundaries 9, 78, 140, 151.

    model.component("comp1").mesh("mesh1").feature("ftri2").selection().set(9, 78, 140, 151);

//    Right-click Free Triangular 2 and choose Size.

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

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

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

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

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

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

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

//    Select the Curvature factor checkbox.

    model.component("comp1").mesh("mesh1").feature("ftri2").feature("size1").set("hcurveactive", true);

//    In the associated text field, type 0.4.

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

//    In the Mesh toolbar, click Swept.

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

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

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

//    Select Domains 2, 22, 28.

    model.component("comp1").mesh("mesh1").feature("swe3").selection().set(2, 22, 28);

//    In the Mesh toolbar, click Distribution.

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

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

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

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

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

//    Select Boundaries 154, 157, 161, 164, 166.

    model.component("comp1").mesh("mesh1").feature("map4").selection().set(154, 157, 161, 164, 166);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edge 439.

    model.component("comp1").mesh("mesh1").feature("map4").feature("dis1").selection().set(439);

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

    model.component("comp1").mesh("mesh1").feature("map4").feature("dis1").set("numelem", 4);

//    In the Mesh toolbar, click Distribution.

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

//    Select Edges 436, 441.

    model.component("comp1").mesh("mesh1").feature("map4").feature("dis2").selection().set(436, 441);

//    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("map4").feature("dis2").set("numelem", 2);

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

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

//    Select Boundaries 143, 148, 207, 222, 223.

    model.component("comp1").mesh("mesh1").feature("ftri3").selection().set(143, 148, 207, 222, 223);

//    Right-click Free Triangular 3 and choose Size.

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

//    Select Boundaries 143, 148, 207.

    model.component("comp1").mesh("mesh1").feature("ftri3").feature("size1").selection().set(143, 148, 207);

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

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

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

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

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

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

//    In the Mesh toolbar, click Swept.

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

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

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

//    Select Domains 30, 31.

    model.component("comp1").mesh("mesh1").feature("swe4").selection().set(30, 31);

//    In the Mesh toolbar, click Swept.

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

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

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

//    Select Domains 27, 29, 32.

    model.component("comp1").mesh("mesh1").feature("swe5").selection().set(27, 29, 32);

//    In the Mesh toolbar, click Distribution.

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

//    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("swe5").feature("dis1").set("numelem", 2);

//    In the Mesh toolbar, click Swept.

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

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

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

//    Select Domain 25.

    model.component("comp1").mesh("mesh1").feature("swe6").selection().set(25);

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

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

//    Select Boundaries 174, 198, 200.

    model.component("comp1").mesh("mesh1").feature("ftri4").selection().set(174, 198, 200);

//    Right-click Free Triangular 4 and choose Size.

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

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

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

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

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

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

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

//    In the Mesh toolbar, click Boundary Layers.

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

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

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

//    Select Boundaries 174, 198.

    model.component("comp1").mesh("mesh1").feature("bl1").selection().set(174, 198);

//    In the Model Builder window, click Boundary Layer Properties.
//    Select Edges 150, 258, 259, 260, 276, 278, 279, 280, 281, 322, 323, 324, 325, 326, 328, 357, 362.

    model.component("comp1").mesh("mesh1").feature("bl1").feature("blp").selection()
         .set(150, 258, 259, 260, 276, 278, 279, 280, 281, 322, 323, 324, 325, 326, 328, 357, 362);

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

    model.component("comp1").mesh("mesh1").feature("bl1").feature("blp").set("blnlayers", 5);

//    In the Thickness adjustment factor text field, type 1.1.

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

//    In the Mesh toolbar, click Swept.

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

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

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

//    Select Domains 4, 24, 26.

    model.component("comp1").mesh("mesh1").feature("swe7").selection().set(4, 24, 26);

//    In the Mesh toolbar, click Free Tetrahedral.

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

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

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

//    Select Domains 1, 3, 5, 19, 21.

    model.component("comp1").mesh("mesh1").feature("ftet1").selection().set(1, 3, 5, 19, 21);

//    In the Mesh toolbar, click Boundary Layers.

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

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

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

//    Select Domain 3.

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

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

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

//    In the Model Builder window, click Boundary Layer Properties.
//    Select Boundary 10.

    model.component("comp1").mesh("mesh1").feature("bl2").feature("blp").selection().set(10);

//    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("bl2").feature("blp").set("blnlayers", 1);

//    In the Mesh toolbar, click Build Mesh.

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

//    For the <l>Frequency Domain, Perturbation</l> study step, select and enable the suggested iterative solver for a more efficient solver; then <l>Compute</l>.
//    In the Study toolbar, click Show Default Solver.

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

//    In the Model Builder window, expand the Solution 1 (sol1) node.
//    In the Model Builder window, expand the Study 1 - Frequency Response > Solver Configurations > Solution 1 (sol1) > Stationary Solver 3 node.
//    Right-click Study 1 - Frequency Response > Solver Configurations > Solution 1 (sol1) > Stationary Solver 3 > Suggested Iterative Solver (GMRES with GMG) (asb1_mmcpl1) and choose Enable.

    model.sol("sol1").feature("s3").feature("i1").active(true);

//    In the Study toolbar, click Compute.

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

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

//    In the Study toolbar, click Add Study to open the Add Study window.
//    Add an <l>Eigenfrequency</l> study to investigate the modal behavior of the mechanical structure of the loudspeaker; then <l>Compute</l>. Only the <l>Solid Mechanics</l> physics is solved here.
//    Find the Studies subsection.
//    In the Select Study tree, select Preset Studies for Selected Multiphysics > Eigenfrequency.
//    Click Add Study in the window toolbar.

    model.study().create("std2");
    model.study("std2").create("eig", "Eigenfrequency");
    model.study("std2").feature("eig").set("chkeigregion", true);
    model.study("std2").feature("eig").set("storefact", false);
    model.study("std2").feature("eig").set("linpsolnum", "auto");
    model.study("std2").feature("eig").set("solnum", "auto");
    model.study("std2").feature("eig").set("notsolnum", "auto");
    model.study("std2").feature("eig").set("outputmap", new String[]{});
    model.study("std2").feature("eig").set("ngenAUX", "1");
    model.study("std2").feature("eig").set("goalngenAUX", "1");
    model.study("std2").feature("eig").set("ngenAUX", "1");
    model.study("std2").feature("eig").set("goalngenAUX", "1");

//    In the Study toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, type Study 2 - Structural Eigenmodes in the Label text field.

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

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

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

//    In the Model Builder window, under Study 2 - Structural Eigenmodes, click Step 1: Eigenfrequency.
//    In the Settings window for Eigenfrequency, locate the Study Settings section.
//    From the Search method around shift list, select Larger real part.

    model.study("std2").feature("eig").set("eigwhich", "lr");
    model.study("std2").feature("eig").setSolveFor("/physics/mf", false);

//    Locate the Physics and Variables Selection section.

    model.study("std2").feature("eig").setSolveFor("/physics/acpr", false);
    model.study("std2").feature("eig").setSolveFor("/multiphysics/asb1", false);
    model.study("std2").feature("eig").setSolveFor("/multiphysics/mmcpl1", false);

//    In the Solve for column of the table, under Component 1 (comp1), clear the checkboxes for Magnetic Fields (mf), Pressure Acoustics, Frequency Domain (acpr).
//    In the Solve for column of the table, under Component 1 (comp1) > Multiphysics, clear the checkboxes for Acoustic–Structure Boundary 1 (asb1), Magnetomechanics, Solid 1 (mmcpl1).
//    In the Study toolbar, click Compute.

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

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

//    Proceed with creating plots to analyze the results.
//    In the Model Builder window, expand the Results node.
//    In the Model Builder window, expand the Results > Datasets node.
//    Right-click Results > Datasets and choose More 3D Datasets > Sector 3D.

    model.result().dataset().create("sec1", "Sector3D");

//    Use Sector 3D datasets to exploit symmetries in the model.
//    In the Settings window for Sector 3D, locate the Symmetry section.
//    In the Number of sectors text field, type 4.

    model.result().dataset("sec1").set("sectors", 4);

//    From the Sectors to include list, select Manual.

    model.result().dataset("sec1").set("include", "manual");

//    In the Start sector text field, type 3.

    model.result().dataset("sec1").set("startsector", 3);

//    In the Number of sectors to include text field, type 3.

    model.result().dataset("sec1").set("sectorsinclude", 3);

//    From the Transformation list, select Rotation and reflection.

    model.result().dataset("sec1").set("trans", "rotrefl");

//    In the Results toolbar, click More Datasets and choose Sector 3D.

    model.result().dataset().create("sec2", "Sector3D");

//    In the Settings window for Sector 3D, locate the Data section.
//    From the Dataset list, select Study 2 - Structural Eigenmodes/Solution 4 (sol4).

    model.result().dataset("sec2").set("data", "dset4");

//    Locate the Symmetry section.
//    In the Number of sectors text field, type 4.

    model.result().dataset("sec2").set("sectors", 4);

//    From the Sectors to include list, select Manual.

    model.result().dataset("sec2").set("include", "manual");

//    In the Start sector text field, type 3.

    model.result().dataset("sec2").set("startsector", 3);

//    In the Number of sectors to include text field, type 3.

    model.result().dataset("sec2").set("sectorsinclude", 3);

//    From the Transformation list, select Rotation and reflection.

    model.result().dataset("sec2").set("trans", "rotrefl");

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

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

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

    model.result("pg1").label("Geometry");

//    Locate the Data section.
//    From the Dataset list, select Study 1 - Frequency Response/Solution Store 2 (sol3).

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

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

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

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

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

//    In the Geometry toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg1").feature("vol1").set("expr", "1");

//    Right-click Volume 1 and choose Selection.

    model.result("pg1").feature("vol1").create("sel1", "Selection");

//    Select Domains 25, 27, 30.

    model.result("pg1").feature("vol1").feature("sel1").selection().set(25, 27, 30);
    model.result("pg1").run();

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

    model.result("pg1").feature("vol1").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg1").feature("vol1").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Aluminum.

    model.result("pg1").feature("vol1").feature("mtrl1").set("family", "aluminum");

//    In the Geometry toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg1").feature("vol2").set("expr", "1");

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

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

//    From the Color list, select Custom.

    model.result("pg1").feature("vol2").set("color", "custom");

//    On Windows, click the colored bar underneath, or — if you are running the cross-platform desktop — the Color button.
//    Click Show color palette only or OK on the cross-platform desktop.
//    Click Add to custom colors.
//    Set the RGB values to 42, 49, and 76, respectively.
//    Click Define custom colors.

    model.result("pg1").feature("vol2")
         .set("customcolor", new double[]{0.16470588743686676, 0.1921568661928177, 0.2980392277240753});

//    In the Geometry toolbar, click Selection.

    model.result("pg1").feature("vol2").create("sel1", "Selection");

//    Select Domains 2, 22, 28, 31.

    model.result("pg1").feature("vol2").feature("sel1").selection().set(2, 22, 28, 31);
    model.result("pg1").run();

//    In the Model Builder window, right-click Volume 2 and choose Material Appearance.

    model.result("pg1").feature("vol2").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg1").feature("vol2").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Textile.

    model.result("pg1").feature("vol2").feature("mtrl1").set("family", "textile");

//    Locate the Color section.
//    Select the Use the plot's color checkbox.

    model.result("pg1").feature("vol2").feature("mtrl1").set("useplotcolors", true);

//    In the Geometry toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg1").feature("vol3").set("expr", "1");

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

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

//    From the Color list, select Custom.

    model.result("pg1").feature("vol3").set("color", "custom");

//    On Windows, click the colored bar underneath, or — if you are running the cross-platform desktop — the Color button.
//    Click Show color palette only or OK on the cross-platform desktop.
//    Click Add to custom colors.
//    Set the RGB values to 196, 106, and 72, respectively.
//    Click Define custom colors.

    model.result("pg1").feature("vol3")
         .set("customcolor", new double[]{0.7686274647712708, 0.4156862795352936, 0.2823529541492462});

//    In the Geometry toolbar, click Selection.

    model.result("pg1").feature("vol3").create("sel1", "Selection");

//    Select Domain 20.

    model.result("pg1").feature("vol3").feature("sel1").selection().set(20);
    model.result("pg1").run();

//    In the Model Builder window, right-click Volume 3 and choose Material Appearance.

    model.result("pg1").feature("vol3").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg1").feature("vol3").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Textile.

    model.result("pg1").feature("vol3").feature("mtrl1").set("family", "textile");

//    Locate the Color section.
//    Select the Use the plot's color checkbox.

    model.result("pg1").feature("vol3").feature("mtrl1").set("useplotcolors", true);

//    In the Geometry toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg1").feature("vol4").set("expr", "1");

//    In the Geometry toolbar, click Selection.

    model.result("pg1").feature("vol4").create("sel1", "Selection");

//    Select Domains 7, 8, 9, 10, 11, 13, 14, 15.

    model.result("pg1").feature("vol4").feature("sel1").selection().set(7, 8, 9, 10, 11, 13, 14, 15);
    model.result("pg1").run();

//    In the Model Builder window, right-click Volume 4 and choose Material Appearance.

    model.result("pg1").feature("vol4").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg1").feature("vol4").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Chrome.

    model.result("pg1").feature("vol4").feature("mtrl1").set("family", "chrome");

//    In the Geometry toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg1").feature("vol5").set("expr", "1");

//    Right-click Volume 5 and choose Selection.

    model.result("pg1").feature("vol5").create("sel1", "Selection");

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

    model.result("pg1").feature("vol5").feature("sel1").selection().named("sel2");
    model.result("pg1").run();

//    Right-click Volume 5 and choose Material Appearance.

    model.result("pg1").feature("vol5").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg1").feature("vol5").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Copper.

    model.result("pg1").feature("vol5").feature("mtrl1").set("family", "copper");

//    In the Geometry toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg1").feature("vol6").set("expr", "1");

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

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

//    From the Color list, select Custom.

    model.result("pg1").feature("vol6").set("color", "custom");

//    On Windows, click the colored bar underneath, or — if you are running the cross-platform desktop — the Color button.
//    Click Show color palette only or OK on the cross-platform desktop.
//    Click Add to custom colors.
//    Set the RGB values to 167, 176, and 193, respectively.
//    Click Define custom colors.

    model.result("pg1").feature("vol6")
         .set("customcolor", new double[]{0.6549019813537598, 0.6901960968971252, 0.7568627595901489});

//    Right-click Volume 6 and choose Selection.

    model.result("pg1").feature("vol6").create("sel1", "Selection");

//    Select Domains 4, 24.

    model.result("pg1").feature("vol6").feature("sel1").selection().set(4, 24);
    model.result("pg1").run();

//    Right-click Volume 6 and choose Material Appearance.

    model.result("pg1").feature("vol6").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg1").feature("vol6").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Iron.

    model.result("pg1").feature("vol6").feature("mtrl1").set("family", "iron");

//    Locate the Color section.
//    Select the Use the plot's color checkbox.

    model.result("pg1").feature("vol6").feature("mtrl1").set("useplotcolors", true);

//    In the Geometry toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg1").feature("vol7").set("expr", "1");

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

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

//    From the Color list, select Custom.

    model.result("pg1").feature("vol7").set("color", "custom");

//    On Windows, click the colored bar underneath, or — if you are running the cross-platform desktop — the Color button.
//    Click Show color palette only or OK on the cross-platform desktop.
//    Click Add to custom colors.
//    Set the RGB values to 105, 105, and 105, respectively.
//    Click Define custom colors.

    return model;
  }

  public static Model run4(Model model) {

    model.result("pg1").feature("vol7")
         .set("customcolor", new double[]{0.4117647111415863, 0.4117647111415863, 0.4117647111415863});

//    Right-click Volume 7 and choose Selection.

    model.result("pg1").feature("vol7").create("sel1", "Selection");

//    Select Domain 26.

    model.result("pg1").feature("vol7").feature("sel1").selection().set(26);
    model.result("pg1").run();

//    Right-click Volume 7 and choose Material Appearance.

    model.result("pg1").feature("vol7").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg1").feature("vol7").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Soil.

    model.result("pg1").feature("vol7").feature("mtrl1").set("family", "soil");

//    Locate the Color section.
//    Select the Use the plot's color checkbox.

    model.result("pg1").feature("vol7").feature("mtrl1").set("useplotcolors", true);

//    In the Geometry toolbar, click Plot.

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

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

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

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

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

//    Locate the Data section.
//    From the Dataset list, select Study 1 - Frequency Response/Solution Store 2 (sol3).

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

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

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

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

    model.result("pg2").set("edges", false);

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

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

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

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

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

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

//    Locate the Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 100 in the Selection text field.
//    Click OK.

    model.result("pg2").feature("str1").selection().set(100);

//    In the Settings window for Streamline, locate the Coloring and Style section.
//    Find the Line style subsection.
//    From the Type list, select Tube.

    model.result("pg2").feature("str1").set("linetype", "tube");

//    In the Tube radius expression text field, type 0.2.

    model.result("pg2").feature("str1").set("radiusexpr", "0.2");

//    Select the Radius scale factor checkbox.

    model.result("pg2").feature("str1").set("tuberadiusscaleactive", true);

//    In the Static Magnetic Field toolbar, click Color Expression.

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

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

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type 1.

    model.result("pg2").feature("vol1").set("expr", "1");

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

    model.result("pg2").feature("vol1").create("sel1", "Selection");

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

    model.result("pg2").feature("vol1").feature("sel1").selection().named("sel4");
    model.result("pg2").run();

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

    model.result("pg2").feature("vol1").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg2").feature("vol1").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Aluminum.

    model.result("pg2").feature("vol1").feature("mtrl1").set("family", "aluminum");

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

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

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

    model.result("pg2").feature("line1").set("expr", "1");

//    Locate the Coloring and Style section.
//    From the Line type list, select Tube.

    model.result("pg2").feature("line1").set("linetype", "tube");

//    In the Tube radius expression text field, type 0.3.

    model.result("pg2").feature("line1").set("radiusexpr", "0.3");

//    Select the Radius scale factor checkbox.

    model.result("pg2").feature("line1").set("tuberadiusscaleactive", true);

//    From the Coloring list, select Uniform.

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

//    From the Color list, select Black.

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

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

    model.result("pg2").feature("line1").create("sel1", "Selection");

//    In the Settings window for Selection, locate the Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 12-23, 27, 28, 31-36, 38, 39, 63-67, 69, 70, 92, 93, 95, 96, 102, 103, 106-108, 119-123, 132, 133, 142, 147-151, 153, 154, 159-161, 258-260, 276-279, 282, 284-287, 289, 301-303, 305, 317, 319, 323, 325, 326, 332-334, 352, 357, 360-363, 366 in the Selection text field.
//    Click OK.

    model.result("pg2").feature("line1").feature("sel1").selection()
         .set(12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 27, 28, 31, 32, 33, 34, 35, 36, 38, 39, 63, 64, 65, 66, 67, 69, 70, 92, 93, 95, 96, 102, 103, 106, 107, 108, 119, 120, 121, 122, 123, 132, 133, 142, 147, 148, 149, 150, 151, 153, 154, 159, 160, 161, 258, 259, 260, 276, 277, 278, 279, 282, 284, 285, 286, 287, 289, 301, 302, 303, 305, 317, 319, 323, 325, 326, 332, 333, 334, 352, 357, 360, 361, 362, 363, 366);
    model.result("pg2").run();

//    In the Model Builder window, under Results, click Static Magnetic Field.
//    In the Static Magnetic Field toolbar, click Plot.

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

//    In the Home toolbar, click Add Plot Group and choose 3D Plot Group.

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

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

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

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

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

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

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

//    In the Current Density toolbar, click Surface.

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

//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type mf.normJ.

    model.result("pg3").feature("surf1").set("expr", "mf.normJ");

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

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

//    In the Current Density toolbar, click Selection.

    model.result("pg3").feature("surf1").create("sel1", "Selection");

//    In the Settings window for Selection, locate the Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 11, 12, 14, 20, 85, 88, 90-92, 94, 110, 112, 132, 174, 190-192, 198, 199, 205 in the Selection text field.
//    Click OK.

    model.result("pg3").feature("surf1").feature("sel1").selection()
         .set(11, 12, 14, 20, 85, 88, 90, 91, 92, 94, 110, 112, 132, 174, 190, 191, 192, 198, 199, 205);
    model.result("pg3").run();

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

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

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

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

//    In the Settings window for 3D Plot Group, type Acoustic Pressure and SPL in the Label text field.

    model.result("pg4").label("Acoustic Pressure and SPL");

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

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

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

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

//    In the Acoustic Pressure and SPL toolbar, click Surface.

    model.result("pg4").create("surf1", "Surface");
    model.result("pg4").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("pg4").feature("surf1").set("expr", "acpr.p_t");

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

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

//    From the Scale list, select Linear symmetric.

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

//    In the Model Builder window, click Acoustic Pressure and SPL.
//    In the Acoustic Pressure and SPL toolbar, click Surface.

    model.result("pg4").create("surf2", "Surface");
    model.result("pg4").feature("surf2").set("evaluationsettings", "parent");

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

    model.result("pg4").feature("surf2").set("expr", "acpr.Lp_t");

//    In the Acoustic Pressure and SPL toolbar, click More Attributes and choose Transformation.

    model.result("pg4").feature("surf2").create("trn1", "Transformation");
    model.result("pg4").run();

//    In the Settings window for Transformation, locate the Transformation section.
//    In the x text field, type 300.

    model.result("pg4").feature("surf2").feature("trn1").set("move", new int[]{300, 0, 0});
    model.result("pg4").run();

//    In the Model Builder window, under Results, click Acoustic Pressure and SPL.
//    In the Acoustic Pressure and SPL toolbar, click Plot.

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

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

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

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

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

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

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

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

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

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

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

//    In the Displacement toolbar, click Surface.

    model.result("pg5").create("surf1", "Surface");
    model.result("pg5").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("pg5").feature("surf1").set("expr", "solid.disp");

//    From the Unit list, select µm.

    model.result("pg5").feature("surf1").set("unit", "\u00b5m");

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

    model.result("pg5").feature("surf1").set("colortable", "SpectrumLight");

//    In the Displacement toolbar, click Deformation.

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

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

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

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

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

//    In the Settings window for 3D Plot Group, type Lorentz-Force (z-Component) in the Label text field.

    model.result("pg6").label("Lorentz-Force (z-Component)");

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

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

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

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

//    In the Lorentz-Force (z-Component) toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type mmcpl1.FLtzz.

    model.result("pg6").feature("vol1").set("expr", "mmcpl1.FLtzz");

//    Select the Compute differential checkbox.

    model.result("pg6").feature("vol1").set("differential", true);
    model.result("pg6").run();

//    In the Model Builder window, click Lorentz-Force (z-Component).
//    In the Lorentz-Force (z-Component) toolbar, click Plot.

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

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

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

//    In the Settings window for 3D Plot Group, type Coil Current Density Jx in the Label text field.

    model.result("pg7").label("Coil Current Density Jx");

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

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

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

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

//    In the Coil Current Density Jx toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type mf.Jx.

    model.result("pg7").feature("vol1").set("expr", "mf.Jx");

//    Select the Compute differential checkbox.

    model.result("pg7").feature("vol1").set("differential", true);

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

    model.result("pg7").feature("vol1").set("colortable", "Thermal");

//    In the Coil Current Density Jx toolbar, click Selection.

    model.result("pg7").feature("vol1").create("sel1", "Selection");

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

    model.result("pg7").feature("vol1").feature("sel1").selection().named("sel2");
    model.result("pg7").run();

//    In the Model Builder window, under Results, click Coil Current Density Jx.
//    In the Coil Current Density Jx toolbar, click Plot.

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

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

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

//    In the Settings window for 3D Plot Group, type Coil Current Density Jy in the Label text field.

    model.result("pg8").label("Coil Current Density Jy");

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

    model.result("pg8").setIndex("looplevel", 5, 0);

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

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

//    In the Coil Current Density Jy toolbar, click Volume.

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

//    In the Settings window for Volume, locate the Expression section.
//    In the Expression text field, type mf.Jy.

    model.result("pg8").feature("vol1").set("expr", "mf.Jy");

//    Select the Compute differential checkbox.

    model.result("pg8").feature("vol1").set("differential", true);

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

    model.result("pg8").feature("vol1").set("colortable", "Thermal");

//    In the Coil Current Density Jy toolbar, click Selection.

    model.result("pg8").feature("vol1").create("sel1", "Selection");

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

    model.result("pg8").feature("vol1").feature("sel1").selection().named("sel2");
    model.result("pg8").run();

//    In the Model Builder window, under Results, click Coil Current Density Jy.
//    In the Coil Current Density Jy toolbar, click Plot.

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

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

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

//    In the Settings window for 1D Plot Group, type On-Axis Response in the Label text field.

    model.result("pg9").label("On-Axis Response");

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

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

//    Locate the Axis section.
//    Select the x-axis log scale checkbox.

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

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

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

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

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

//    Select the y-axis label checkbox.

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

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

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

//    In the On-Axis Response toolbar, click More Plots and choose Octave Band.

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

//    Locate the y-Axis Data section.
//    In the Expression text field, type pext(0,0,1[m]).

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

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

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

//    In the Model Builder window, click On-Axis Response.
//    In the On-Axis Response toolbar, click Plot.

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

//    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 Coil Electric Impedance in the Label text field.

    model.result("pg10").label("Coil Electric Impedance");

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

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

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

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

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

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

//    Select the y-axis label checkbox.

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

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

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

//    Locate the Axis section.
//    Select the x-axis log scale checkbox.

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

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

    model.result("pg10").set("legendpos", "upperleft");

//    In the Coil Electric Impedance toolbar, click Global.

    model.result("pg10").create("glob1", "Global");
    model.result("pg10").feature("glob1").set("markerpos", "datapoints");
    model.result("pg10").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("pg10").feature("glob1").setIndex("expr", "abs(mf.ZCoil_1)", 0);
    model.result("pg10").feature("glob1").setIndex("unit", "\u03a9", 0);
    model.result("pg10").feature("glob1").setIndex("descr", "abs(Z)", 0);
    model.result("pg10").feature("glob1").setIndex("expr", "real(mf.ZCoil_1)", 1);
    model.result("pg10").feature("glob1").setIndex("unit", "\u03a9", 1);
    model.result("pg10").feature("glob1").setIndex("descr", "real(Z)", 1);
    model.result("pg10").feature("glob1").setIndex("expr", "imag(mf.ZCoil_1)", 2);
    model.result("pg10").feature("glob1").setIndex("unit", "\u03a9", 2);
    model.result("pg10").feature("glob1").setIndex("descr", "imag(Z)", 2);
    model.result("pg10").run();

//    In the Model Builder window, click Coil Electric Impedance.
//    In the Coil Electric Impedance toolbar, click Plot.

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

//    In the Results toolbar, click Polar Plot Group.

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

//    In the Settings window for Polar Plot Group, type Spatial Response in the Label text field.

    model.result("pg11").label("Spatial Response");

//    Locate the Axis section.
//    From the Zero angle list, select Up.

    model.result("pg11").set("zeroangle", "up");

//    In the Spatial Response toolbar, click More Plots and choose Radiation Pattern.

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

//    In the Settings window for Radiation Pattern, locate the Evaluation section.
//    Find the Angles subsection.
//    From the Restriction list, select Manual.

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

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

    model.result("pg11").feature("rp1").set("phimin", -90);

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

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

//    Find the Normal vector subsection.
//    In the x text field, type 1.

    model.result("pg11").feature("rp1").set("normal", new int[]{1, 0, 1});

//    In the z text field, type 0.

    model.result("pg11").feature("rp1").set("normal", new int[]{1, 0, 0});

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

    model.result("pg11").feature("rp1").set("radius", "1[m]");

//    Find the Reference direction subsection.
//    In the x text field, type 0.

    model.result("pg11").feature("rp1").set("refdir", new int[]{0, 0, 0});

//    In the z text field, type 1.

    model.result("pg11").feature("rp1").set("refdir", new int[]{0, 0, 1});

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

    model.result("pg11").feature("rp1").set("legend", true);
    model.result("pg11").run();

//    In the Model Builder window, click Spatial Response.
//    In the Spatial Response toolbar, click Plot.

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

//    In the Results toolbar, click Result Templates to open the Result Templates window.
//    In the tree, select Study 2 - Structural Eigenmodes/Solution 4 (sol4) > Solid Mechanics > Mode Shape (solid).
//    Click Add Result Template in the window toolbar.

    model.result().create("pg12", "PlotGroup3D");
    model.result("pg12").set("data", "dset4");
    model.result("pg12").setIndex("looplevel", 1, 0);
    model.result("pg12").label("Mode Shape (solid)");
    model.result("pg12").set("showlegends", false);
    model.result("pg12").create("surf1", "Surface");
    model.result("pg12").feature("surf1").set("expr", new String[]{"solid.disp"});
    model.result("pg12").feature("surf1").set("threshold", "manual");
    model.result("pg12").feature("surf1").set("thresholdvalue", 0.2);
    model.result("pg12").feature("surf1").set("colortable", "AuroraBorealis");
    model.result("pg12").feature("surf1").set("colortabletrans", "none");
    model.result("pg12").feature("surf1").set("colorscalemode", "linear");
    model.result("pg12").feature("surf1").create("def", "Deform");
    model.result("pg12").feature("surf1").feature("def").set("expr", new String[]{"u", "v", "w"});
    model.result("pg12").feature("surf1").feature("def").set("descr", "Displacement field");
    model.result("pg12").label("Mode Shape (solid)");
    model.result("pg12").run();

//    In the Results toolbar, click Result Templates to close the Result Templates window.
//    In the Settings window for 3D Plot Group, locate the Data section.
//    From the Dataset list, select Sector 3D 2.

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

//    From the Eigenfrequency (Hz) list, select 1280+244.4i.

    model.result("pg12").set("looplevel", new int[]{6});

//    In the Mode Shape (solid) toolbar, click Plot.

    model.result("pg12").run();
    model.result("pg12").set("looplevel", new int[]{1});
    model.result("pg12").run();
    model.result("pg12").set("looplevel", new int[]{2});
    model.result("pg12").run();
    model.result("pg12").set("looplevel", new int[]{3});
    model.result("pg12").run();
    model.result("pg12").set("looplevel", new int[]{4});
    model.result("pg12").run();
    model.result("pg12").set("looplevel", new int[]{5});
    model.result("pg12").run();
    model.result("pg1").run();

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

    model
         .description("This tutorial shows how to best solve full 3D vibroelectroacoustic multiphysics models of loudspeakers. The model is based on a 3D representation of the existing 2D axisymmetric Application Library model loudspeaker_driver. The physics setup is essentially the same in this 3D version as in the 2D axisymmetric version. In the 3D model an iterative solver suggestion is selected for the frequency-domain analysis. This suggestion ensures that the coupled acoustic, structure, and electromagnetic problem is solved efficiently.");

    return model;
  }

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

}
