/*
 * lumped_loudspeaker_driver_mechanical.java
 */

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

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

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

//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    In the Model Wizard window, click 2D Axisymmetric.
//    In the Select Physics tree, select Acoustics > Pressure Acoustics > Pressure Acoustics, Frequency Domain (acpr).
//    Click Add.
//    In the Select Physics tree, select AC/DC > Electrical Circuit (cir).
//    Click Add.
//    In the Select Physics tree, select Structural Mechanics > Lumped Mechanical System (lms).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Frequency Domain.
//    Click Done.

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

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

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

    model.component("comp1").physics().create("acpr", "PressureAcoustics", "geom1");
    model.component("comp1").physics().create("cir", "Circuit", "geom1");
    model.component("comp1").physics().create("lms", "LumpedMechanicalSystem", "geom1");

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

//    Load small signal and geometric parameters from a file.
//    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 lumped_loudspeaker_driver_mechanical_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("fmax", "10[kHz]", "Maximal study frequency");
    model.param().set("c0", "343[m/s]", "Speed of sound in air");
    model.param().set("rho0", "1.2[kg/m^3]", "Density of air");
    model.param().set("M_MD", "33.4[g]", "Moving mass (voice coil and diaphragm)");
    model.param().set("C_MS", "1.18e-3[m/N]", "Suspension compliance");
    model.param().set("R_MS", "1.85[N*s/m]", "Suspension mechanical losses");
    model.param().set("BL", "11.4[T*m]", "Force factor, flux density (B) times coil length (L)");
    model.param().set("R_E", "7[ohm]", "Voice coil resistance");
    model.param().set("L_e", "6.89[mH]", "Voice coil inductance (constant)");
    model.param().set("n_e", "0.7", "Voice coil loss factor");
    model.param().set("V0", "sqrt(2)[V]", "Driving voltage (peak)");
    model.param().set("V0rms", "V0/sqrt(2)", "Driving voltage (rms)");
    model.param().set("R_g", "0[ohm]", "Driver output resistance");
    model.param().set("a", "12[cm]", "Piston radius of driver (equivalent)");
    model.param().set("Rair", "20[cm]", "Air domain radius");
    model.param().set("Rpml", "6[cm]", "PML layer thickness");

//    Import a simple 2D axisymmetric geometry of the speaker driver.
//    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 lumped_loudspeaker_driver_mechanical.mphbin.

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

//    Click Import.

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

//    In the Geometry toolbar, click Build All.

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

//    Now, set up all the variables, selections, and component couplings under the <l>Definitions</l> node.
//    In the Definitions toolbar, click Local Variables.

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

//    In the Settings window for Variables, type Model variables in the Label text field.

    model.component("comp1").variable("var1").label("Model variables");

//    Locate the Variables section.
//    Click Load from File.
//    Browse to the model's Application Library folder and double-click the file lumped_loudspeaker_driver_mechanical_variables.txt.
//    To import content from file, use:
//    model.component("comp1").variable("var1").loadFile("FILENAME");
    model.component("comp1").variable("var1")
         .set("L_E", "(L_e/(sin(n_e*pi/2)))*(acpr.omega[s/rad])^(n_e-1)", "Voice coil inductance (frequency dependent)");
    model.component("comp1").variable("var1")
         .set("Rp_E", "(L_e/(cos(n_e*pi/2)))*(acpr.omega[s/rad])^(n_e)[ohm/H]", "Resistance (losses in magnetic system)");
    model.component("comp1").variable("var1").set("F_D", "intop((down(p)-up(p))*nz)", "Axial pressure force");
    model.component("comp1").variable("var1").set("P_AR", "intop(up(acpr.Ir)*nr+up(acpr.Iz)*nz)", "Radiated power");
    model.component("comp1").variable("var1").set("P_E", "0.5*realdot(V0,cir.R1.i)", "Electric input power (rms)");
    model.component("comp1").variable("var1").set("eta", "P_AR/P_E", "Driver efficiency");
    model.component("comp1").variable("var1").set("k0", "acpr.omega/c0", "Free space wave number");

//    In the Definitions toolbar, click Explicit.

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

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

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

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

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

//    Select Boundaries 6, 11, 14.

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

//    In the Definitions toolbar, click Explicit.

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

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

    model.component("comp1").selection("sel2").label("Internal wall");

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

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

//    Select Boundaries 7, 8, 15.

    model.component("comp1").selection("sel2").set(7, 8, 15);

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

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

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

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

//    From the Selection list, select Speaker.

    model.component("comp1").cpl("intop1").selection().named("sel1");

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

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

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

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

//    Select Domains 1, 4.

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

//    In the Settings window for Perfectly Matched Layer, locate the Scaling section.
//    From the Coordinate stretching type list, select Rational.

    model.component("comp1").coordSystem("pml1").set("stretchingType", "rational");

//    In the PML scaling factor text field, type 0.5.

    model.component("comp1").coordSystem("pml1").set("PMLfactor", "0.5");

//    In the PML scaling curvature parameter text field, type 5.

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

//    You have now changed the default settings for the perfectly matched layer (PML). The new settings will improve the performance of the PML at very low frequencies.
//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Built-in > Air.
//    Click Add to Component in the window toolbar.

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

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    Now, set up the physics and the boundary conditions for the model.
//    In the Physics toolbar, click Boundaries and choose Interior Sound Hard Boundary (Wall).

    model.component("comp1").physics("acpr").create("ishb1", "InteriorSoundHard", 1);

//    In the Settings window for Interior Sound Hard Boundary (Wall), locate the Boundary Selection section.
//    From the Selection list, select Internal wall.

    model.component("comp1").physics("acpr").feature("ishb1").selection().named("sel2");

//    In the Physics toolbar, click Boundaries and choose Interior Normal Acceleration.

    model.component("comp1").physics("acpr").create("ina1", "InteriorNormalAcceleration", 1);

//    In the Settings window for Interior Normal Acceleration, locate the Boundary Selection section.
//    From the Selection list, select Speaker.

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

//    Locate the Interior Normal Acceleration section.
//    Specify the \[\mathbf{a}_0\] vector as

    model.component("comp1").physics("acpr").feature("ina1").set("acc", new String[]{"0", "0", "lms.M1.a"});

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

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

//    Select Boundary 12.

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

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

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

//    In the Electrical Circuit toolbar, click Voltage Source.

    model.component("comp1").physics("cir").create("V1", "VoltageSource", -1);

//    In the Settings window for Voltage Source, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("cir").feature("V1").setIndex("Connections", 1, 0, 0);
    model.component("comp1").physics("cir").feature("V1").setIndex("Connections", 0, 1, 0);

//    Locate the Device Parameters section.
//    In the \[v_{\textrm{src}}\] text field, type V0.

    model.component("comp1").physics("cir").feature("V1").set("value", "V0");

//    In the Electrical Circuit toolbar, click Resistor.

    model.component("comp1").physics("cir").create("R1", "Resistor", -1);

//    In the Settings window for Resistor, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("cir").feature("R1").setIndex("Connections", 1, 0, 0);
    model.component("comp1").physics("cir").feature("R1").setIndex("Connections", 2, 1, 0);

//    Locate the Device Parameters section.
//    In the \[R\] text field, type R_g.

    model.component("comp1").physics("cir").feature("R1").set("R", "R_g");

//    In the Electrical Circuit toolbar, click Resistor.

    model.component("comp1").physics("cir").create("R2", "Resistor", -1);

//    In the Settings window for Resistor, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("cir").feature("R2").setIndex("Connections", 2, 0, 0);
    model.component("comp1").physics("cir").feature("R2").setIndex("Connections", 3, 1, 0);

//    Locate the Device Parameters section.
//    In the \[R\] text field, type R_E.

    model.component("comp1").physics("cir").feature("R2").set("R", "R_E");

//    In the Electrical Circuit toolbar, click Inductor.

    model.component("comp1").physics("cir").create("L1", "Inductor", -1);

//    In the Settings window for Inductor, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("cir").feature("L1").setIndex("Connections", 3, 0, 0);
    model.component("comp1").physics("cir").feature("L1").setIndex("Connections", 4, 1, 0);

//    Locate the Device Parameters section.
//    In the \[L\] text field, type L_E.

    model.component("comp1").physics("cir").feature("L1").set("L", "L_E");

//    In the Electrical Circuit toolbar, click Resistor.

    model.component("comp1").physics("cir").create("R3", "Resistor", -1);

//    In the Settings window for Resistor, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("cir").feature("R3").setIndex("Connections", 3, 0, 0);
    model.component("comp1").physics("cir").feature("R3").setIndex("Connections", 4, 1, 0);

//    Locate the Device Parameters section.
//    In the \[R\] text field, type Rp_E.

    model.component("comp1").physics("cir").feature("R3").set("R", "Rp_E");

//    In the Electrical Circuit toolbar, click Voltage Source.

    model.component("comp1").physics("cir").create("V2", "VoltageSource", -1);

//    In the Settings window for Voltage Source, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("cir").feature("V2").setIndex("Connections", 4, 0, 0);
    model.component("comp1").physics("cir").feature("V2").setIndex("Connections", 0, 1, 0);

//    Locate the Device Parameters section.
//    In the \[v_{\textrm{src}}\] text field, type BL*lms.M1.v.

    model.component("comp1").physics("cir").feature("V2").set("value", "BL*lms.M1.v");

//    In the Physics toolbar, click Global and choose Spring.

    model.component("comp1").physics("lms").create("K1", "Spring", -1);

//    In the Settings window for Spring, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("lms").feature("K1").setIndex("Connections", 0, 0, 0);
    model.component("comp1").physics("lms").feature("K1").setIndex("Connections", 1, 1, 0);

//    Locate the Component Parameters section.
//    In the \[k\] text field, type 1/C_MS.

    model.component("comp1").physics("lms").feature("K1").set("k", "1/C_MS");

//    Locate the Results section.
//    Find the Add the following to default results subsection.
//    Clear the Displacement checkbox.

    model.component("comp1").physics("lms").feature("K1").set("includeDisplacement", false);

//    In the Physics toolbar, click Global and choose Damper.

    model.component("comp1").physics("lms").create("C1", "Damper", -1);

//    In the Settings window for Damper, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("lms").feature("C1").setIndex("Connections", 0, 0, 0);
    model.component("comp1").physics("lms").feature("C1").setIndex("Connections", 1, 1, 0);

//    Locate the Component Parameters section.
//    In the \[c\] text field, type R_MS.

    model.component("comp1").physics("lms").feature("C1").set("c", "R_MS");

//    Locate the Results section.
//    Find the Add the following to default results subsection.
//    Clear the Displacement checkbox.

    model.component("comp1").physics("lms").feature("C1").set("includeDisplacement", false);

//    In the Physics toolbar, click Global and choose Mass.

    model.component("comp1").physics("lms").create("M1", "Mass", -1);

//    In the Settings window for Mass, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("lms").feature("M1").setIndex("Connections", 1, 0, 0);
    model.component("comp1").physics("lms").feature("M1").setIndex("Connections", 2, 1, 0);

//    Locate the Component Parameters section.
//    In the \[m\] text field, type M_MD.

    model.component("comp1").physics("lms").feature("M1").set("m", "M_MD");

//    Locate the Results section.
//    Find the Add the following to default results subsection.
//    Clear the Displacement checkbox.

    model.component("comp1").physics("lms").feature("M1").set("includeDisplacement", false);

//    Select the Velocity checkbox.

    model.component("comp1").physics("lms").feature("M1").set("includeVelocity", true);

//    In the Physics toolbar, click Global and choose Force Node.

    model.component("comp1").physics("lms").create("frc1", "ForceNode", -1);

//    In the Settings window for Force Node, locate the Node Connections section.
//    In the table, enter the following settings:

    model.component("comp1").physics("lms").feature("frc1").setIndex("Connections", 2, 0, 0);

//    Locate the Terminal Parameters section.
//    In the \[f_\textrm{p10}\] text field, type BL*cir.R2.i+F_D.

    model.component("comp1").physics("lms").feature("frc1").set("fp1", "BL*cir.R2.i+F_D");

//    Proceed and generate the mesh using the <l>Physics-controlled mesh</l> functionality. The frequency controlling the maximum element size is per default taken <l>From study</l>. Set the desired <l>Frequencies</l> in the study step. In general, 5 to 6 second-order elements per wavelength are needed to resolve the waves. For more details, see <em>Meshing (Resolving the Waves)</em> in the <em>Acoustics Module User's Guide</em>. In this model, use 8 elements per wavelength; the default <l>Automatic</l> is to have 5.
//    In the Model Builder window, under Component 1 (comp1), click Mesh 1.
//    In the Settings window for Mesh, locate the Physics-Controlled Mesh section.
//    In the table, enter the following settings:

    model.component("comp1").mesh("mesh1").contribute("physics/cir", false);
    model.component("comp1").mesh("mesh1").contribute("physics/lms", false);

//    Locate the Pressure Acoustics, Frequency Domain (acpr) section.
//    From the Number of mesh elements per wavelength list, select User defined.

    model.component("comp1").physics("acpr").prop("MeshControl").set("ElementsPerWavelength", "UserDefined");

//    In the text field, type 8.

    model.component("comp1").physics("acpr").prop("MeshControl").set("nperlambda", 8);

//    Now, proceed to the study and set the frequencies, before building the mesh and solving.
//    In the Model Builder window, under Study 1, click Step 1: Frequency Domain.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    Click Range.
//    In the Range dialog, choose ISO preferred frequencies from the Entry method list.
//    In the Start frequency text field, type 10.
//    In the Stop frequency text field, type 10000.
//    From the Interval list, select 1/24 octave.
//    Click Replace.

    model.study("std1").feature("freq")
         .set("plist", "{10, 10.3, 10.6, 10.9, 11.2, 11.5, 11.8, 12.2, 12.5, 12.8, 13.2, 13.6, 14, 14.5, 15, 15.5, 16, 16.5, 17, 17.5, 18, 18.5, 19, 19.5, 20, 20.6, 21.2, 21.8, 22.4, 23, 23.6, 24.3, 25, 25.8, 26.5, 27.2, 28, 29, 30, 30.7, 31.5, 32.5, 33.5, 34.5, 35.5, 36.5, 37.5, 38.7, 40, 41.2, 42.5, 43.7, 45, 46.2, 47.5, 48.7, 50, 51.5, 53, 54.5, 56, 58, 60, 61.5, 63, 65, 67, 69, 71, 73, 75, 77.5, 80, 82.5, 85, 87.5, 90, 92.5, 95, 97.5, 100, 103, 106, 109, 112, 115, 118, 122, 125, 128, 132, 136, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 206, 212, 218, 224, 230, 236, 243, 250, 258, 265, 272, 280, 290, 300, 307, 315, 325, 335, 345, 355, 365, 375, 387, 400, 412, 425, 437, 450, 462, 475, 487, 500, 515, 530, 545, 560, 580, 600, 615, 630, 650, 670, 690, 710, 730, 750, 775, 800, 825, 850, 875, 900, 925, 950, 975, 1e3, 1.03e3, 1.06e3, 1.09e3, 1.12e3, 1.15e3, 1.18e3, 1.22e3, 1.25e3, 1.28e3, 1.32e3, 1.36e3, 1.4e3, 1.45e3, 1.5e3, 1.55e3, 1.6e3, 1.65e3, 1.7e3, 1.75e3, 1.8e3, 1.85e3, 1.9e3, 1.95e3, 2e3, 2.06e3, 2.12e3, 2.18e3, 2.24e3, 2.3e3, 2.36e3, 2.43e3, 2.5e3, 2.58e3, 2.65e3, 2.72e3, 2.8e3, 2.9e3, 3e3, 3.07e3, 3.15e3, 3.25e3, 3.35e3, 3.45e3, 3.55e3, 3.65e3, 3.75e3, 3.87e3, 4e3, 4.12e3, 4.25e3, 4.37e3, 4.5e3, 4.62e3, 4.75e3, 4.87e3, 5e3, 5.15e3, 5.3e3, 5.45e3, 5.6e3, 5.8e3, 6e3, 6.15e3, 6.3e3, 6.5e3, 6.7e3, 6.9e3, 7.1e3, 7.3e3, 7.5e3, 7.75e3, 8e3, 8.25e3, 8.5e3, 8.75e3, 9e3, 9.25e3, 9.5e3, 9.75e3, 1e4}");

//    In the Model Builder window, right-click Component 1 (comp1) > Mesh 1 and choose Build All.

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

//    In the Study toolbar, click Compute.

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

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

    model.result().create("pg1", "PlotGroup2D");
    model.result("pg1").set("data", "dset1");
    model.result("pg1").setIndex("looplevel", 241, 0);
    model.result("pg1").create("surf1", "Surface");
    model.result("pg1").feature("surf1").set("expr", new String[]{"acpr.p_t"});
    model.result("pg1").feature("surf1").set("colortable", "Wave");
    model.result("pg1").feature("surf1").set("colorscalemode", "linearsymmetric");
    model.result("pg1").set("showlegendsunit", true);
    model.result("pg1").label("Acoustic Pressure (acpr)");
    model.result().create("pg2", "PlotGroup2D");
    model.result("pg2").set("data", "dset1");
    model.result("pg2").setIndex("looplevel", 241, 0);
    model.result("pg2").create("surf1", "Surface");
    model.result("pg2").feature("surf1").set("expr", new String[]{"acpr.Lp_t"});
    model.result("pg2").feature("surf1").set("colortable", "Rainbow");
    model.result("pg2").feature("surf1").set("colorscalemode", "linear");
    model.result("pg2").set("showlegendsunit", true);
    model.result("pg2").label("Sound Pressure Level (acpr)");
    model.result().dataset().create("rev1", "Revolve2D");
    model.result().dataset("rev1").set("data", "dset1");
    model.result().dataset("rev1").set("revangle", 225);
    model.result().dataset("rev1").set("startangle", -90);
    model.result().create("pg3", "PlotGroup3D");
    model.result("pg3").set("data", "rev1");
    model.result("pg3").setIndex("looplevel", 241, 0);
    model.result("pg3").create("surf1", "Surface");
    model.result("pg3").feature("surf1").set("expr", new String[]{"acpr.p_t"});
    model.result("pg3").feature("surf1").set("colortable", "Wave");
    model.result("pg3").feature("surf1").set("colorscalemode", "linearsymmetric");
    model.result("pg3").set("showlegendsunit", true);
    model.result("pg3").label("Acoustic Pressure, 3D (acpr)");
    model.result().create("pg4", "PlotGroup3D");
    model.result("pg4").set("data", "rev1");

    return model;
  }

  public static Model run2(Model model) {
    model.result("pg4").setIndex("looplevel", 241, 0);
    model.result("pg4").create("surf1", "Surface");
    model.result("pg4").feature("surf1").set("expr", new String[]{"acpr.Lp_t"});
    model.result("pg4").feature("surf1").set("colortable", "Rainbow");
    model.result("pg4").feature("surf1").set("colorscalemode", "linear");
    model.result("pg4").set("showlegendsunit", true);
    model.result("pg4").label("Sound Pressure Level, 3D (acpr)");
    model.result().create("pg5", "PolarGroup");
    model.result("pg5").set("data", "dset1");
    model.result("pg5").create("rp1", "RadiationPattern");
    model.result("pg5").feature("rp1").set("expr", new String[]{"acpr.efc1.Lp_pext"});
    model.result("pg5").feature("rp1").set("legend", true);
    model.result("pg5").feature("rp1").set("phidisc", 180);
    model.result("pg5").label("Exterior-Field Sound Pressure Level (acpr)");
    model.result("pg5").setIndex("looplevelinput", "last", 0);
    model.result().create("pg6", "PolarGroup");
    model.result("pg6").set("data", "dset1");
    model.result("pg6").create("rp1", "RadiationPattern");
    model.result("pg6").feature("rp1").set("expr", new String[]{"acpr.efc1.pext"});
    model.result("pg6").feature("rp1").set("legend", true);
    model.result("pg6").feature("rp1").set("phidisc", 180);
    model.result("pg6").label("Exterior-Field Pressure (acpr)");
    model.result("pg6").setIndex("looplevelinput", "last", 0);
    model.result("pg5").set("symmetricangle", true);
    model.result("pg5").set("zeroangle", "up");
    model.result("pg5").set("rotdir", "cw");
    model.result("pg6").set("symmetricangle", true);
    model.result("pg6").set("zeroangle", "up");
    model.result("pg6").set("rotdir", "cw");
    model.result().create("pg7", "PlotGroup1D");
    model.result("pg7").label("Force, Amplitude (K1)");
    model.result("pg7").set("titletype", "manual");
    model.result("pg7").set("title", "Force");
    model.result("pg7").set("ylabel", "Force");
    model.result("pg7").set("smooth", "internal");
    model.result("pg7").feature().create("glob1", "Global");
    model.result("pg7").feature("glob1").set("expr", new String[]{"lms.K1.fAmp"});
    model.result("pg7").feature("glob1").set("linemarker", "cycle");
    model.result("pg7").feature("glob1").set("data", "parent");
    model.result().create("pg8", "PlotGroup1D");
    model.result("pg8").label("Force, Phase (K1)");
    model.result("pg8").set("titletype", "manual");
    model.result("pg8").set("title", "Phase");
    model.result("pg8").set("ylabel", "Phase");
    model.result("pg8").set("smooth", "internal");
    model.result("pg8").feature().create("glob1", "Global");
    model.result("pg8").feature("glob1").set("expr", new String[]{"lms.K1.fPhase"});
    model.result("pg8").feature("glob1").set("linemarker", "cycle");
    model.result("pg8").feature("glob1").set("data", "parent");
    model.result("pg7").label("Force, Amplitude (lms)");
    model.result("pg7").feature("glob1").set("expr", new String[]{});
    model.result("pg7").feature("glob1").set("descr", new String[]{});
    model.result("pg7").feature("glob1").set("expr", new String[]{"lms.C1.fAmp"});
    model.result("pg7").feature("glob1")
         .set("descr", new String[]{"Spring force, amplitude (K1)", "Damping force, amplitude (C1)"});
    model.result("pg7").feature("glob1").set("expr", new String[]{"lms.K1.fAmp", "lms.C1.fAmp"});
    model.result("pg8").label("Force, Phase (lms)");
    model.result("pg8").feature("glob1").set("expr", new String[]{});
    model.result("pg8").feature("glob1").set("descr", new String[]{});
    model.result("pg8").feature("glob1").set("expr", new String[]{"lms.C1.fPhase"});
    model.result("pg8").feature("glob1")
         .set("descr", new String[]{"Spring force, phase (K1)", "Damping force, phase (C1)"});
    model.result("pg8").feature("glob1").set("expr", new String[]{"lms.K1.fPhase", "lms.C1.fPhase"});
    model.result("pg7").label("Force, Amplitude (lms) 1");
    model.result("pg7").feature("glob1").set("expr", new String[]{});
    model.result("pg7").feature("glob1").set("descr", new String[]{});
    model.result("pg7").feature("glob1").set("expr", new String[]{"lms.M1.fAmp"});
    model.result("pg7").feature("glob1")
         .set("descr", new String[]{"Spring force, amplitude (K1)", "Damping force, amplitude (C1)", "Inertial force, amplitude (M1)"});
    model.result("pg7").feature("glob1").set("expr", new String[]{"lms.K1.fAmp", "lms.C1.fAmp", "lms.M1.fAmp"});
    model.result("pg8").label("Force, Phase (lms) 1");
    model.result("pg8").feature("glob1").set("expr", new String[]{});
    model.result("pg8").feature("glob1").set("descr", new String[]{});
    model.result("pg8").feature("glob1").set("expr", new String[]{"lms.M1.fPhase"});
    model.result("pg8").feature("glob1")
         .set("descr", new String[]{"Spring force, phase (K1)", "Damping force, phase (C1)", "Inertial force, phase (M1)"});
    model.result("pg8").feature("glob1").set("expr", new String[]{"lms.K1.fPhase", "lms.C1.fPhase", "lms.M1.fPhase"});
    model.result().create("pg9", "PlotGroup1D");
    model.result("pg9").label("Velocity, Amplitude (M1)");
    model.result("pg9").set("titletype", "manual");
    model.result("pg9").set("title", "Velocity");
    model.result("pg9").set("ylabel", "Velocity");
    model.result("pg9").set("smooth", "internal");
    model.result("pg9").feature().create("glob1", "Global");
    model.result("pg9").feature("glob1").set("expr", new String[]{"lms.M1.vAmp"});
    model.result("pg9").feature("glob1").set("linemarker", "cycle");
    model.result("pg9").feature("glob1").set("data", "parent");
    model.result().create("pg10", "PlotGroup1D");
    model.result("pg10").label("Velocity, Phase (M1)");
    model.result("pg10").set("titletype", "manual");
    model.result("pg10").set("title", "Phase");
    model.result("pg10").set("ylabel", "Phase");
    model.result("pg10").set("smooth", "internal");
    model.result("pg10").feature().create("glob1", "Global");
    model.result("pg10").feature("glob1").set("expr", new String[]{"lms.M1.vPhase"});
    model.result("pg10").feature("glob1").set("linemarker", "cycle");
    model.result("pg10").feature("glob1").set("data", "parent");
    model.result("pg1").run();

//    First, look at the default plots. Investigate the 2D <l>Sound Pressure Level (acpr)</l> plot to verify the performance of the perfectly matched layer (PML). After doing this you can disable plotting in the PML region, which is unphysical. Secondly, look at the default exterior-field plots and make a few changes, before setting up a range of plots to investigate the loudspeaker driver performance.

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

//    Look at the sound pressure level (SPL) plots at the frequencies of 10 kHz, 1 kHz, and 10 Hz. Note that the SPL decreases nearly 100 dB over the width of the thickness of the PML. This means that the outgoing waves are extremely damped.
//    In the Model Builder window, click Sound Pressure Level (acpr).
//    In the Settings window for 2D Plot Group, locate the Data section.
//    From the Parameter value (freq (Hz)) list, select 1000.

    model.result("pg2").setIndex("looplevel", 161, 0);

//    In the Sound Pressure Level (acpr) toolbar, click Plot.

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

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

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

//    In the Sound Pressure Level (acpr) toolbar, click Plot.

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

//    In the Model Builder window, expand the Results > Datasets node, then click Study 1/Solution 1 (sol1).
//    In the Results toolbar, click Attributes and choose Selection.
//    In the Settings window for Selection, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Domain.

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

//    Select Domains 2, 3.

    model.result().dataset("dset1").selection().geom("geom1", 2);
    model.result().dataset("dset1").selection().set(2, 3);
    model.result("pg1").run();

//    In the Model Builder window, under Results, click Acoustic Pressure (acpr).
//    In the Settings window for 2D Plot Group, locate the Data section.
//    From the Parameter value (freq (Hz)) list, select 1000.

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

//    In the Acoustic Pressure (acpr) toolbar, click Plot.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    From the Parameter value (freq (Hz)) list, select 5000.

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

//    In the Acoustic Pressure (acpr) toolbar, click Plot.

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

//    In the Model Builder window, expand the Exterior-Field Sound Pressure Level (acpr) node, then click Radiation Pattern 1.
//    In the Settings window for Radiation Pattern, locate the Evaluation section.
//    Find the Angles subsection.
//    From the Restriction list, select Manual.

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

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

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

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

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

//    In the Exterior-Field Sound Pressure Level (acpr) toolbar, click Plot.

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

//    In the Model Builder window, expand the Exterior-Field Pressure (acpr) node, then click Radiation Pattern 1.
//    In the Settings window for Radiation Pattern, locate the Evaluation section.
//    Find the Angles subsection.
//    From the Restriction list, select Manual.

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

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

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

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

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

//    In the Exterior-Field Pressure (acpr) toolbar, click Plot.

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

//    In the Model Builder window, under Results, click Force, Amplitude (lms) 1.
//    In the Settings window for 1D Plot Group, type Mechanical Force, Amplitude in the Label text field.

    model.result("pg7").label("Mechanical Force, Amplitude");

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

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

//    Locate the Plot Settings section.
//    In the y-axis label text field, type Force (N).

    model.result("pg7").set("ylabel", "Force (N)");

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

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

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

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

//    In the Mechanical Force, Amplitude toolbar, click Plot.

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

//    In the Model Builder window, under Results, click Force, Phase (lms) 1.
//    In the Settings window for 1D Plot Group, type Mechanical Force, Phase in the Label text field.

    model.result("pg8").label("Mechanical Force, Phase");

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

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

//    Locate the Plot Settings section.
//    In the y-axis label text field, type Phase (rad).

    model.result("pg8").set("ylabel", "Phase (rad)");

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

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

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

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

//    In the Mechanical Force, Phase toolbar, click Plot.

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

//    In the Model Builder window, under Results, click Velocity, Amplitude (M1).
//    In the Settings window for 1D Plot Group, type Diaphragm Velocity, Amplitude in the Label text field.

    model.result("pg9").label("Diaphragm Velocity, Amplitude");

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

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

//    Locate the Plot Settings section.
//    In the y-axis label text field, type Velocity (m/s).

    model.result("pg9").set("ylabel", "Velocity (m/s)");

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

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

//    In the Diaphragm Velocity, Amplitude toolbar, click Plot.

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

//    In the Model Builder window, under Results, click Velocity, Phase (M1).
//    In the Settings window for 1D Plot Group, type Diaphragm Velocity, Phase in the Label text field.

    model.result("pg10").label("Diaphragm Velocity, Phase");

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

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

//    Locate the Plot Settings section.
//    In the y-axis label text field, type Phase (rad).

    model.result("pg10").set("ylabel", "Phase (rad)");

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

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

//    In the Diaphragm Velocity, Phase toolbar, click Plot.

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

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

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

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

    model.result("pg11").label("Acoustic Radiated Power");

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

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

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

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

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

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

//    Select the y-axis label checkbox.

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

//    In the associated text field, type Power (W).

    model.result("pg11").set("ylabel", "Power (W)");

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

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

//    Right-click Acoustic Radiated Power and choose Global.

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

//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Definitions > Variables > P_AR - Radiated power - W.

    model.result("pg11").feature("glob1").set("expr", new String[]{"P_AR"});
    model.result("pg11").feature("glob1").set("descr", new String[]{"Radiated power"});
    model.result("pg11").feature("glob1").set("unit", new String[]{"W"});

//    In the Acoustic Radiated Power toolbar, click Plot.

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

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

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

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

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

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

    model.result("pg12").label("Electric Input Power");

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

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

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

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

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

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

//    Select the y-axis label checkbox.

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

//    In the associated text field, type Power (W).

    model.result("pg12").set("ylabel", "Power (W)");

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

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

//    Right-click Electric Input Power and choose Global.

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

//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Definitions > Variables > P_E - Electric input power (rms) - W.

    model.result("pg12").feature("glob1").set("expr", new String[]{"P_E"});
    model.result("pg12").feature("glob1").set("descr", new String[]{"Electric input power (rms)"});
    model.result("pg12").feature("glob1").set("unit", new String[]{"W"});

//    In the Electric Input Power toolbar, click Plot.

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

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

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

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

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

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

    model.result("pg13").label("Driver Efficiency");

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

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

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

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

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

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

//    Select the y-axis label checkbox.

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

//    In the associated text field, type Efficiency (%).

    model.result("pg13").set("ylabel", "Efficiency (%)");

//    Right-click Driver Efficiency and choose Global.

    model.result("pg13").create("glob1", "Global");
    model.result("pg13").feature("glob1").set("markerpos", "datapoints");
    model.result("pg13").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("pg13").feature("glob1").setIndex("expr", "eta*100", 0);
    model.result("pg13").feature("glob1").setIndex("unit", 1, 0);
    model.result("pg13").feature("glob1").setIndex("descr", "Driver efficiency", 0);

//    In the Driver Efficiency toolbar, click Plot.

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

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

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

//    Set up a parametric curve used to evaluate the exterior-field outside of the computational mesh.
//    In the Results toolbar, click More Datasets and choose Parametric Curve 2D.

    model.result().dataset().create("pc1", "ParCurve2D");

//    In the Settings window for Parametric Curve 2D, locate the Expressions section.
//    In the z text field, type s*5[m]+(1-s)*Rair.

    model.result().dataset("pc1").set("expry", "s*5[m]+(1-s)*Rair");

//    Select the Only evaluate globally defined expressions checkbox.

    model.result().dataset("pc1").set("global", true);

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

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

//    In the Settings window for 1D Plot Group, type On-axis Pressure Field in the Label text field.

    model.result("pg14").label("On-axis Pressure Field");

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

    model.result("pg14").set("data", "pc1");

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

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

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

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

//    In the associated text field, type z (m).

    model.result("pg14").set("xlabel", "z (m)");

//    Select the y-axis label checkbox.

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

//    In the associated text field, type Pressure (Pa).

    model.result("pg14").set("ylabel", "Pressure (Pa)");

//    Locate the Data section.
//    From the Parameter selection (freq) list, select From list.

    model.result("pg14").setIndex("looplevelinput", "manual", 0);

//    In the Parameter values (freq (Hz)) list, select 1000.

    model.result("pg14").setIndex("looplevel", new int[]{161}, 0);

//    select 1000 in the Parameter values (freq (Hz)) list.
//    Locate the Legend section.
//    Clear the Show legends checkbox.

    model.result("pg14").set("showlegends", false);

//    Right-click On-axis Pressure Field and choose Line Graph.

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

//    Select Boundary 4.

    model.result("pg14").feature("lngr1").selection().set(4);

//    In the Settings window for Line Graph, locate the y-Axis Data section.
//    In the Expression text field, type pext(r,z).

    model.result("pg14").feature("lngr1").set("expr", "pext(r,z)");

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

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

//    In the Expression text field, type z.

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

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

    model.result("pg14").feature("lngr1").set("evaluationsettings", "manual");

//    From the Resolution list, select Extra fine.

    model.result("pg14").feature("lngr1").set("resolution", "extrafine");

//    In the On-axis Pressure Field toolbar, click Plot.

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

//    Create a 2D intensity plot that includes the magnitude of the intensity vector <c>acpr.I_rms</c> as well as an arrow surface (vector field plot) of the intensity vector, with the components (<c>acpr.Ir</c>,<c>acpr.Iz</c>).
//    In the Results toolbar, click 2D Plot Group.

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

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

    model.result("pg15").label("Intensity");

//    Right-click Intensity and choose Surface.

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

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

    model.result("pg15").feature("surf1").set("expr", "acpr.I_rms");
    model.result("pg15").run();

//    In the Model Builder window, right-click Intensity and choose Arrow Surface.

    model.result("pg15").create("arws1", "ArrowSurface");
    model.result("pg15").feature("arws1").set("evaluationsettings", "parent");

//    In the Settings window for Arrow Surface, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Pressure Acoustics, Frequency Domain > Intensity > acpr.Ir,acpr.Iz - Intensity.

    model.result("pg15").feature("arws1").set("expr", new String[]{"acpr.Ir", "acpr.Iz"});
    model.result("pg15").feature("arws1").set("descr", "Intensity");

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

    model.result("pg15").feature("arws1").set("color", "black");
    model.result("pg15").run();

//    Right-click Intensity and choose Arrow Line.

    model.result("pg15").create("arwl1", "ArrowLine");
    model.result("pg15").feature("arwl1").set("evaluationsettings", "parent");

//    In the Settings window for Arrow Line, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Pressure Acoustics, Frequency Domain > Geometry > acpr.nr,acpr.nz - Normal vector.

    model.result("pg15").feature("arwl1").set("expr", new String[]{"acpr.nr", "acpr.nz"});
    model.result("pg15").feature("arwl1").set("descr", "Normal vector");

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

    model.result("pg15").feature("arwl1").set("color", "black");

//    In the Intensity toolbar, click Plot.

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

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

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

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

    model.result("pg15").setIndex("looplevel", 217, 0);

//    In the Intensity toolbar, click Plot.

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

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

    model.result("pg15").setIndex("looplevel", 161, 0);

//    In the Intensity toolbar, click Plot.

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

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

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

//    In the Intensity toolbar, click Plot.

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

//    Next create the directivity plot of the speaker.
//    In the Results toolbar, click 1D Plot Group.

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

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

    model.result("pg16").label("Directivity");

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

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

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

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

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

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

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

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

//    Click to expand the Coloring and Style section.
//    From the Layout list, select Frequency on y-axis.

    model.result("pg16").feature("dir1").set("layout", "frequencyy");

//    In the Directivity toolbar, click Plot.

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

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

    model.result("pg16").set("ylog", true);
    model.result("pg3").run();
    model.result("pg3").setIndex("looplevel", 217, 0);
    model.result("pg3").run();

    model.title("Lumped Loudspeaker Driver Using a Lumped Mechanical System");

    model
         .description("This is a model of a moving-coil loudspeaker where a lumped parameter analogy represents the behavior of the electrical and mechanical speaker components. The Thiele\u2013Small parameters (small-signal parameters) serve as input to the lumped model, which is represented by an Electrical Circuit interface. The lumped model is coupled to a 2D axisymmetric Pressure Acoustics model describing the surrounding air domain. The output from the model includes, among many things, the impedance and the radiated acoustic power.\n\nIn this model, the mechanical speaker components such as moving mass, suspension compliance, and suspension mechanical losses are modeled using the Lumped Mechanical System interface.");

    return model;
  }

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

}
