/*
 * tweeter_shape_optimization.java
 */

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

/** Model exported on May 11 2026, 10:52 by COMSOL 6.4.0.417. */
public class tweeter_shape_optimization {

  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 > Acoustic–Structure Interaction > Acoustic–Shell Interaction, Frequency Domain.
//    Click Add.
//    In the Select Physics tree, select Structural Mechanics > Solid Mechanics (solid).
//    Click Add.
//    In the Select Physics tree, select AC/DC > Electrical Circuit (cir).
//    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("shell", "Shell", "geom1");
    model.component("comp1").physics().create("solid", "SolidMechanics", "geom1");
    model.component("comp1").physics().create("cir", "Circuit", "geom1");

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

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

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

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

//    In the Geometry toolbar, click Insert Sequence and choose Insert Sequence.

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

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

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

//    In the Model Builder window, under Global Definitions, click Parameters 1.
//    In the Settings window for Parameters, type Geometry Parameters in the Label text field.

    model.param().label("Geometry Parameters");

//    In the Home toolbar, click Parameters and choose Add > Parameters.

    model.param().create("par2");

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

    model.param("par2").label("Model Parameters");

//    Locate the Parameters section.
//    Click Load from File.
//    Browse to the model's Application Library folder and double-click the file tweeter_shape_optimization_model_parameters.txt.
//    To import content from file, use:
//    model.param("par2").loadFile("FILENAME");
    model.param("par2").set("c0", "343[m/s]", "Speed of sound");
    model.param("par2").set("fmax", "20[kHz]", "Maximum frequency analyzed");
    model.param("par2").set("fmax_optim", "20[kHz]", "Maximum frequency optimized for");
    model.param("par2").set("fmin", "0.5[kHz]", "Minimum frequency analyzed");
    model.param("par2").set("fmin_optim", "5[kHz]", "Minimum frequency optimized for");
    model.param("par2").set("lam0", "c0/fmax", "Minimum wavelength");
    model.param("par2").set("nf", "150", "Number of frequencies");
    model.param("par2").set("nf_optim", "60", "Number of frequencies in the optimization");
    model.param("par2").set("V0", "sqrt(2)[V]", "Driving voltage");
    model.param("par2").set("rf_pa", "5000[Pa*s/m^2]", "Flow resistivity of the poroacoustic material");
    model.param("par2").set("th_dome", "0.5[mm]", "Thickness of the dome");
    model.param("par2").set("th_former", "0.25[mm]", "Thickness of the former");
    model.param("par2").set("th_susp", "0.25[mm]", "Thickness of the suspension");
    model.param("par2").set("damp_susp", "0.2", "Damping Ratio of the suspension");
    model.param("par2")
         .set("mesh_optim", "1[mm]", "Maximum mesh size of the shape optimization and structural boundaries");
    model.param("par2").set("target_spl", "75[dB]", "Target sound pressure level");
    model.param("par2").set("disp_dome", "3[mm]", "Maximum displacement of the dome Free Shape Boundary");
    model.param("par2").set("disp_wave", "6[mm]", "Maximum displacement of the waveguide Free Shape Boundary");

//    In the Home toolbar, click Parameters and choose Add > Parameters.

    model.param().create("par3");

//    In the Settings window for Parameters, type Thiele Small Parameters in the Label text field.

    model.param("par3").label("Thiele Small Parameters");

//    Locate the Parameters section.
//    Click Load from File.
//    Browse to the model's Application Library folder and double-click the file tweeter_shape_optimization_thiele_small_parameters.txt.
//    To import content from file, use:
//    model.param("par3").loadFile("FILENAME");
    model.param("par3").set("BL", "3.2[T*m]", "Force factor, flux density (B) times coil length (L)");
    model.param("par3").set("R_E", "4[ohm]", "Voice coil resistance");
    model.param("par3").set("L_e", "0.1[mH]", "Voice coil inductance (constant)");
    model.param("par3").set("n_e", "0.7", "Voice coil loss factor");
    model.param("par3").set("V0rms", "V0/sqrt(2)", "Driving voltage (rms)");
    model.param("par3").set("R_g", "0[ohm]", "Driver output resistance");

//    In the Definitions toolbar, click Probes and choose Domain Probe.

    model.component("comp1").probe().create("dom1", "Domain");
    model.component("comp1").probe("dom1").set("intsurface", true);
    model.component("comp1").probe("dom1").set("intvolume", true);

//    In the Settings window for Domain Probe, type Voice-Coil Velocity in the Label text field.

    model.component("comp1").probe("dom1").label("Voice-Coil Velocity");

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

    model.component("comp1").probe("dom1").selection().named("geom1_sel2");

//    In the Variable name text field, type v0.

    model.component("comp1").probe("dom1").set("probename", "v0");

//    Locate the Expression section.
//    In the Expression text field, type solid.u_tZ.

    model.component("comp1").probe("dom1").set("expr", "solid.u_tZ");

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

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

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

    model.component("comp1").variable("var1").set("L_E", "(L_e/(sin(n_e*pi/2)))*(acpr.omega[s/rad])^(n_e-1)");
    model.component("comp1").variable("var1").descr("L_E", "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]");
    model.component("comp1").variable("var1").descr("Rp_E", "Resistance (losses in magnetic system)");
    model.component("comp1").variable("var1")
         .set("obj_1", "sum((Lp_pext_opt(sin(angle_eval/8*n), cos(angle_eval/8*n))-target_spl)^2, n, 0, 4)");
    model.component("comp1").variable("var1").descr("obj_1", "Optimization objective");

//    In the Physics toolbar, click Optimization and choose Shape Optimization.

    model.component("comp1").common().create("fsd1", "FreeShapeDomain");
    model.component("comp1").common("fsd1").selection().all();

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

    model.component("comp1").common("fsd1").selection().set();

//    Select Domains 2, 3.

    model.component("comp1").common("fsd1").selection().set(2, 3);

//    In the Shape Optimization toolbar, click Free Shape Boundary.

    model.component("comp1").common().create("fsb1", "FreeShapeBoundary");

//    In the Settings window for Free Shape Boundary, locate the Boundary Selection section.
//    From the Selection list, select Dome.

    model.component("comp1").common("fsb1").selection().named("geom1_sel6");

//    Locate the Filtering section.
//    From the \[R_{\textrm{min}}\] list, select Medium.

    model.component("comp1").common("fsb1").set("filterRadiusType", "Medium");

//    Locate the Control Variable Settings section.
//    In the \[\] text field, type disp_dome.

    model.component("comp1").common("fsb1").set("maximumDisplacement", "disp_dome");

//    In the Shape Optimization toolbar, click Free Shape Boundary.

    model.component("comp1").common().create("fsb2", "FreeShapeBoundary");

//    In the Settings window for Free Shape Boundary, locate the Boundary Selection section.
//    From the Selection list, select Waveguide.

    model.component("comp1").common("fsb2").selection().named("geom1_sel10");

//    Locate the Filtering section.
//    From the \[R_{\textrm{min}}\] list, select Medium.

    model.component("comp1").common("fsb2").set("filterRadiusType", "Medium");

//    Locate the Control Variable Settings section.
//    In the \[\] text field, type disp_wave.

    model.component("comp1").common("fsb2").set("maximumDisplacement", "disp_wave");

//    In the Shape Optimization toolbar, click Symmetry/Roller.

    model.component("comp1").common().create("fsr1", "FreeShapeSymmetry");

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

    model.component("comp1").common("fsr1").selection().named("geom1_sel7");

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

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

//    In the Settings window for Perfectly Matched Layer, locate the Domain Selection section.
//    From the Selection list, select PML Domains.

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

//    Locate the Scaling section.
//    From the Coordinate stretching type list, select Rational.

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

//    Right-click Perfectly Matched Layer 1 (pml1) and choose Materials > Browse Materials.
//    In the Material Browser window, click Import Material Library.
//    From the Application Library root, browse to the folder Acoustics_Module/Electroacoustic_Transducers and double-click the file loudspeaker_driver_materials.mph.
//    Click Done.
//    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 loudspeaker driver materials > Composite.
//    Click Add to Component in the window toolbar.

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

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

    model.component("comp1").material().create("mat3", "Common");
    model.component("comp1").material("mat3").label("Cloth");
    model.component("comp1").material("mat3").propertyGroup("def")
         .set("electricconductivity", new String[]{"0", "0", "0", "0", "0", "0", "0", "0", "0"});
    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("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat3").propertyGroup("def").set("youngsmodulus", "0.58[GPa]");
    model.component("comp1").material("mat3").propertyGroup("def").set("poissonsratio", "0.3");
    model.component("comp1").material("mat3").propertyGroup("def").set("density", "650[kg/m^3]");

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

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

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

    model.component("comp1").material().create("mat5", "Common");
    model.component("comp1").material("mat5").label("Glass Fiber");
    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", "70[GPa]");
    model.component("comp1").material("mat5").propertyGroup("def").set("poissonsratio", "0.33");
    model.component("comp1").material("mat5").propertyGroup("def").set("density", "2000[kg/m^3]");
    model.component("comp1").material("mat5").propertyGroup("def").set("lossfactor", "0.04");

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    In the Settings window for Material, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

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

//    From the Selection list, select Former.

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

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

    model.component("comp1").material("mat1").selection().named("geom1_comsel1");

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

    model.component("comp1").material("mat2").selection().geom("geom1", 1);

//    From the Selection list, select Dome.

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

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

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

//    From the Selection list, select Suspension.

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

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

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

//    In the Model Builder window, under Component 1 (comp1), click Pressure Acoustics, Frequency Domain (acpr).
//    In the Settings window for Pressure Acoustics, Frequency Domain, locate the Domain Selection section.
//    From the Selection list, select Air Domains.

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

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

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

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

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

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

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

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

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

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

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

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

    model.component("comp1").physics("acpr").feature("pom1").selection().named("geom1_r3_dom");

//    Locate the Porous Matrix Properties section.
//    From the \[R_{\textrm{f}}\] list, select User defined.

    model.component("comp1").physics("acpr").feature("pom1").set("Rf_mat", "userdef");

//    In the associated text field, type rf_pa.

    model.component("comp1").physics("acpr").feature("pom1").set("Rf", "rf_pa");

//    From the Constants list, select Miki.

    model.component("comp1").physics("acpr").feature("pom1").set("Constants", "Miki");

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

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

//    In the Settings window for Exterior Field Calculation, locate the Boundary Selection section.
//    From the Selection list, select Exterior Field.

    model.component("comp1").physics("acpr").feature("efc1").selection().named("geom1_sel5");

//    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 Model Builder window, under Component 1 (comp1), click Shell (shell).
//    In the Settings window for Shell, locate the Boundary Selection section.
//    From the Selection list, select Shell Boundaries.

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

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

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

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

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

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

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

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

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

//    Locate the Damping Settings section.
//    From the Input parameters list, select Damping ratios.

    model.component("comp1").physics("shell").feature("emm1").feature("dmp2").set("InputParameters", "DampingRatios");

//    In the \[f_{1}\] text field, type fmin.

    model.component("comp1").physics("shell").feature("emm1").feature("dmp2").set("f1", "fmin");

//    In the \[\zeta_{1}\] text field, type damp_susp.

    model.component("comp1").physics("shell").feature("emm1").feature("dmp2").set("zeta1", "damp_susp");

//    In the \[f_{2}\] text field, type fmax.

    model.component("comp1").physics("shell").feature("emm1").feature("dmp2").set("f2", "fmax");

//    In the \[\zeta_{2}\] text field, type damp_susp.

    model.component("comp1").physics("shell").feature("emm1").feature("dmp2").set("zeta2", "damp_susp");

//    In the Model Builder window, under Component 1 (comp1) > Shell (shell), click Thickness and Offset 1.
//    In the Settings window for Thickness and Offset, locate the Thickness and Offset section.
//    In the \[d_0\] text field, type th_dome.

    model.component("comp1").physics("shell").feature("to1").set("d", "th_dome");

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

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

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

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

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

    model.component("comp1").physics("shell").feature("to2").set("d", "th_former");

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

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

//    In the Settings window for Thickness and Offset, locate the Boundary Selection section.

    return model;
  }

  public static Model run2(Model model) {
//    From the Selection list, select Suspension.

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

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

    model.component("comp1").physics("shell").feature("to3").set("d", "th_susp");

//    In the Physics toolbar, click Points and choose Fixed Constraint.

    model.component("comp1").physics("shell").create("fix1", "Fixed", 0);

//    In the Settings window for Fixed Constraint, locate the Point Selection section.
//    From the Selection list, select Fixed Points.

    model.component("comp1").physics("shell").feature("fix1").selection().named("geom1_sel11");

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

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

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

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

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

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

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

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

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

    model.component("comp1").physics("solid").feature("bl1").set("force", new String[]{"0", "0", "BL*cir.R1.i"});

//    In the Model Builder window, under Component 1 (comp1), click Electrical Circuit (cir).
//    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*v0.

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

//    In the Model Builder window, right-click Component 1 (comp1) > Multiphysics and choose Acoustic–Structure Boundary.

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

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

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

//    Locate the Coupled Interfaces section.
//    From the Structure list, select Solid Mechanics (solid).

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

//    In the Model Builder window, right-click Multiphysics and choose Solid–Thin Structure Connection.

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

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

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

//    In the Mesh toolbar, click Free Quad.

    model.component("comp1").mesh("mesh1").create("fq1", "FreeQuad");

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

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

//    Select Domains 1, 7, 8, 11.

    model.component("comp1").mesh("mesh1").feature("fq1").selection().set(1, 7, 8, 11);

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

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

//    In the Settings window for Size, locate the Geometric Entity Selection section.
//    From the Selection list, select Narrow Regions.

    model.component("comp1").mesh("mesh1").feature("fq1").feature("size1").selection().named("geom1_sel3");

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

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

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

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

//    In the associated text field, type air_gap.

    model.component("comp1").mesh("mesh1").feature("fq1").feature("size1").set("hmax", "air_gap");

//    In the Model Builder window, under Component 1 (comp1) > Mesh 1, click Size.
//    In the Settings window for Size, locate the Element Size section.
//    Click the Custom button.

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

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

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

//    In the Minimum element size text field, type r1_susp.

    model.component("comp1").mesh("mesh1").feature("size").set("hmin", "r1_susp");

//    Click Build All.

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

//    In the Mesh toolbar, click Free Triangular.

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

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

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

//    Select Domains 2, 3, 4, 6, 9, 10.

    model.component("comp1").mesh("mesh1").feature("ftri1").selection().set(2, 3, 4, 6, 9, 10);

//    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 Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

    model.component("comp1").mesh("mesh1").feature("ftri1").feature("size1").selection().geom("geom1", 1);

//    From the Selection list, select Dome.

    model.component("comp1").mesh("mesh1").feature("ftri1").feature("size1").selection().named("geom1_sel6");

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

    model.component("comp1").mesh("mesh1").feature("ftri1").feature("size1").set("hmax", "mesh_optim");

//    Right-click Size 1 and choose Duplicate.

    model.component("comp1").mesh("mesh1").feature("ftri1").feature().duplicate("size2", "size1");

//    In the Settings window for Size, locate the Geometric Entity Selection section.
//    From the Selection list, select Waveguide.

    model.component("comp1").mesh("mesh1").feature("ftri1").feature("size2").selection().named("geom1_sel10");

//    In the Mesh toolbar, click Mapped.

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

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

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

//    From the Selection list, select PML Domains.

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

//    Right-click Mapped 1 and choose Distribution.

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

//    Select Boundary 37.

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

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

//    Click Build All.

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

//    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 Domain Selection section.
//    From the Geometric entity level list, select Domain.

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

//    Select Domains 3, 4.

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

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

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

//    In the Model Builder window, click Boundary Layer Properties.
//    In the Settings window for Boundary Layer Properties, locate the Boundary Selection section.
//    From the Selection list, select Exterior Field.

    model.component("comp1").mesh("mesh1").feature("bl1").feature("blp").selection().named("geom1_sel5");

//    Locate the Layers section.
//    In the Number of layers text field, type 1.

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

//    Click Build All.

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

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

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

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

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

//    In the Model Builder window, under Study 1 - Initial Design, click Step 1: Frequency Domain.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    In the Frequencies text field, type range(fmin,(fmax-fmin)/(nf-1),fmax).

    model.study("std1").feature("freq").set("plist", "range(fmin,(fmax-fmin)/(nf-1),fmax)");

//    Click to expand the Results While Solving section.
//    From the Probes list, select None.

    model.study("std1").feature("freq").set("probesel", "none");
    model.study("std1").feature("freq").setSolveFor("/frame/material1", false);

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

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

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

//    In the Model Builder window, expand the Results node.
//    In the Model Builder window, expand the Results > Datasets node, then click Study 1 - Initial Design/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);

//    From the Selection list, select Visualization Domains.

    model.result().dataset("dset1").selection().named("geom1_sel4");

//    Right-click Study 1 - Initial Design/Solution 1 (sol1) and choose Duplicate.

    model.result().dataset().duplicate("dset2", "dset1");

//    In the Model Builder window, click Study 1 - Initial Design/Solution 1 (2) (sol1).
//    In the Settings window for Solution, type Study 1 - Initial Design/Revolution in the Label text field.

    model.result().dataset("dset2").label("Study 1 - Initial Design/Revolution");

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

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

//    From the Selection list, select Revolution Boundaries.

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

//    In the Results toolbar, click More Datasets and choose Revolution 2D.

    model.result().dataset().create("rev1", "Revolve2D");

//    In the Settings window for Revolution 2D, type Revolution 2D - Initial Design in the Label text field.

    model.result().dataset("rev1").label("Revolution 2D - Initial Design");

//    Locate the Data section.
//    From the Dataset list, select Study 1 - Initial Design/Revolution (sol1).

    model.result().dataset("rev1").set("data", "dset2");

//    Click to expand the Revolution Layers section.
//    In the Start angle text field, type 90.

    model.result().dataset("rev1").set("startangle", 90);

//    In the Revolution angle text field, type 90.

    model.result().dataset("rev1").set("revangle", 90);

//    Clear the Add end caps if the revolution is not full checkbox.

    model.result().dataset("rev1").set("endcaps", false);

//    In the Results toolbar, click More Datasets and choose Mirror 2D.

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

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

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

//    In the Settings window for 1D Plot Group, type On-Axis Sound Pressure Level at 1 m in the Label text field.

    model.result("pg1").label("On-Axis Sound Pressure Level at 1 m");

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

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

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

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

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

    model.result("pg1").set("xlabel", "freq (Hz)");

//    Select the y-axis label checkbox.

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

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

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

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

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

//    In the On-Axis Sound Pressure Level at 1 m toolbar, click More Plots and choose Octave Band.

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

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

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

//    Select the Description checkbox.

    model.result("pg1").feature("oct1").set("descractive", true);

//    In the associated text field, type SPL at 1 m - Initial Design.

    model.result("pg1").feature("oct1").set("descr", "SPL at 1 m - Initial Design");

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

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

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

    model.result("pg1").feature("oct1").set("legend", true);

//    In the On-Axis Sound Pressure Level at 1 m toolbar, click Plot.

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

//    In the Model Builder window, right-click On-Axis Sound Pressure Level at 1 m and choose Global.

    model.result("pg1").create("glob1", "Global");
    model.result("pg1").feature("glob1").set("markerpos", "datapoints");
    model.result("pg1").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("pg1").feature("glob1").setIndex("expr", "target_spl", 0);
    model.result("pg1").feature("glob1").setIndex("unit", "dB", 0);
    model.result("pg1").feature("glob1").setIndex("descr", "", 0);

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

    model.result("pg1").feature("glob1").set("linestyle", "dotted");

//    From the Color list, select Black.

    model.result("pg1").feature("glob1").set("linecolor", "black");

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

    model.result("pg1").feature("glob1").set("legend", false);

//    In the On-Axis Sound Pressure Level at 1 m toolbar, click Plot.

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

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

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

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

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

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

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

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

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

//    In the Settings window for Directivity, locate the Expression section.
//    From the Normalization list, select None.

    model.result("pg2").feature("dir1").set("normalization", "none");

//    In the Expression text field, type acpr.efc1.Lp_pext-target_spl.

    model.result("pg2").feature("dir1").set("expr", "acpr.efc1.Lp_pext-target_spl");

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

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

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

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

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

    model.result("pg2").feature("dir1").set("phirange", 90);

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

    model.result("pg2").feature("dir1").set("radius", 1000);

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

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

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

    model.result("pg2").feature("dir1").set("levels", "-42 -30 -24 -18 -12 -6 -3 3 6 9");

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

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

//    Clear the Color legend checkbox.

    model.result("pg2").feature("dir1").set("colorlegend", false);

//    In the Directivity toolbar, click Plot.

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

//    Right-click Directivity 1 and choose Duplicate.

    model.result("pg2").feature().duplicate("dir2", "dir1");
    model.result("pg2").run();

//    In the Settings window for Directivity, locate the Levels section.
//    In the Levels text field, type -6 -3 3 6.

    model.result("pg2").feature("dir2").set("levels", "-6 -3 3 6");

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

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

//    From the Color list, select Black.

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

//    From the Contour type list, select Line.

    model.result("pg2").feature("dir2").set("contourtype", "lines");

//    From the Width list, select 1.

    model.result("pg2").feature("dir2").set("linewidth", 1);

//    In the Directivity toolbar, click Plot.

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

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

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

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

    model.result("pg3").label("Sound Pressure Level");

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

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

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

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

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

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

//    Locate the Color Legend section.
//    Select the Show maximum and minimum values checkbox.

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

//    Select the Show units checkbox.

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

//    Right-click Sound Pressure Level and choose Surface.

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

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

    model.result("pg3").feature("surf1").set("expr", "acpr.Lp_t");

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

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

//    From the Scale list, select Linear.

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

//    Right-click Surface 1 and choose Filter.

    model.result("pg3").feature("surf1").create("filt1", "Filter");
    model.result("pg3").run();

//    In the Settings window for Filter, locate the Element Selection section.
//    In the Logical expression for inclusion text field, type mir1x<0.

    model.result("pg3").feature("surf1").feature("filt1").set("expr", "mir1x<0");

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

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

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

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

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

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

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

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

//    From the Color list, select Gray.

    model.result("pg3").feature("line1").set("color", "gray");

//    Right-click Line 1 and choose Filter.

    model.result("pg3").feature("line1").create("filt1", "Filter");
    model.result("pg3").run();

//    In the Settings window for Filter, locate the Element Selection section.
//    In the Logical expression for inclusion text field, type mir1x<0.

    model.result("pg3").feature("line1").feature("filt1").set("expr", "mir1x<0");

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

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

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

    model.result("pg3").feature().duplicate("line2", "line1");
    model.result("pg3").run();

//    In the Settings window for Line, locate the Coloring and Style section.
//    From the Line type list, select Tube.

    model.result("pg3").feature("line2").set("linetype", "tube");

//    From the Color list, select Black.

    model.result("pg3").feature("line2").set("color", "black");

//    Right-click Line 2 and choose Deformation.

    model.result("pg3").feature("line2").create("def1", "Deform");
    model.result("pg3").run();

//    In the Settings window for Deformation, locate the Scale section.
//    Select the Scale factor checkbox.

    model.result("pg3").feature("line2").feature("def1").set("scaleactive", true);

//    In the associated text field, type 10000.

    model.result("pg3").feature("line2").feature("def1").set("scale", 10000);

//    In the Sound Pressure Level 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 Geometry in the Label text field.

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

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

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

//    Right-click Geometry and choose 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 0.

    model.result("pg4").feature("surf1").set("expr", "0");

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

    model.result("pg4").feature("surf1").set("coloring", "uniform");

//    From the Color list, select Gray.

    model.result("pg4").feature("surf1").set("color", "gray");

//    Right-click Surface 1 and choose Filter.

    model.result("pg4").feature("surf1").create("filt1", "Filter");
    model.result("pg4").run();

//    In the Settings window for Filter, locate the Element Selection section.
//    In the Logical expression for inclusion text field, type (rev1y>0)*(rev1x<0).

    model.result("pg4").feature("surf1").feature("filt1").set("expr", "(rev1y>0)*(rev1x<0)");

//    In the Geometry toolbar, click Plot.

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

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

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

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

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

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

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

//    In the Study toolbar, click Optimization and choose Shape Optimization.

    model.study("std2").create("sho", "ShapeOptimization");

//    In the Settings window for Shape Optimization, locate the Optimization Solver section.
//    In the Maximum number of iterations text field, type 20.

    model.study("std2").feature("sho").set("mmamaxiter", 20);

//    Locate the Objective Function section.
//    From the Solution list, select Maximum of objectives.

    model.study("std2").feature("sho").set("objectivesolution", "max");

//    Click Add Expression in the upper-right corner of the Objective Function section.
//    From the menu, choose Component 1 (comp1) > Definitions > Variables > comp1.obj_1 - Optimization objective - dB.

    model.study("std2").feature("sho").set("optobj", new String[]{"comp1.obj_1"});
    model.study("std2").feature("sho").set("descr", new String[]{"Optimization objective"});

//    Click to expand the Output section.
//    From the Probes list, select None.

    model.study("std2").feature("sho").set("probesel", "none");

//    In the Model Builder window, click Step 1: Frequency Domain.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    In the Frequencies text field, type range(fmin_optim,(fmax_optim-fmin_optim)/(nf_optim-1),fmax_optim).

    model.study("std2").feature("freq")
         .set("plist", "range(fmin_optim,(fmax_optim-fmin_optim)/(nf_optim-1),fmax_optim)");

//    In the Study toolbar, click Get Initial Value.

    model.study("std2").createAutoSequences("sol");
    model.study("std2").createAutoSequences("jobs");

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

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

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

//    From the Selection list, select Visualization Domains.

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

    return model;
  }

  public static Model run3(Model model) {

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

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

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

    model.result("pg5").label("Shape Optimization");

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

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

//    In the Shape Optimization toolbar, click Plot.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    Locate the Title section.
//    From the Title type list, select Label.

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

//    Locate the Plot Settings section.
//    From the Color list, select Gray.

    model.result("pg5").set("edgecolor", "gray");

//    From the Frame list, select Geometry (Rg, PHIg, Zg).

    model.result("pg5").set("frametype", "geometry");

//    Right-click Shape Optimization and choose Line.

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

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

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

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

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

//    From the Color list, select Black.

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

//    In the Model Builder window, right-click Shape Optimization and choose Arrow Line.

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

//    In the Settings window for Arrow Line, locate the Expression section.
//    In the r-component text field, type fsd1.dRg.

    model.result("pg5").feature("arwl1").set("expr", new String[]{"fsd1.dRg", "shell.tleZ"});

//    In the z-component text field, type fsd1.dZg.

    model.result("pg5").feature("arwl1").set("expr", new String[]{"fsd1.dRg", "fsd1.dZg"});

//    Locate the Arrow Positioning section.
//    From the Placement list, select Mesh vertices.

    model.result("pg5").feature("arwl1").set("placement", "elements");

//    Locate the Coloring and Style section.
//    Select the Scale factor checkbox.

    model.result("pg5").feature("arwl1").set("scaleactive", true);

//    From the Arrow base list, select Head.

    model.result("pg5").feature("arwl1").set("arrowbase", "head");

//    Right-click Arrow Line 1 and choose Color Expression.

    model.result("pg5").feature("arwl1").create("col1", "Color");
    model.result("pg5").run();

//    In the Settings window for Color Expression, locate the Expression section.
//    In the Expression text field, type fsd1.rel_disp.

    model.result("pg5").feature("arwl1").feature("col1").set("expr", "fsd1.rel_disp");

//    Click to expand the Range section.
//    Select the Manual color range checkbox.

    model.result("pg5").feature("arwl1").feature("col1").set("rangecoloractive", true);

//    In the Maximum text field, type 1.

    model.result("pg5").feature("arwl1").feature("col1").set("rangecolormax", 1);

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

    model.result("pg5").feature("arwl1").feature("col1").set("colortable", "Rainbow");

//    From the Scale list, select Linear.

    model.result("pg5").feature("arwl1").feature("col1").set("colorscalemode", "linear");

//    In the Shape Optimization toolbar, click Plot.

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

//    In the Model Builder window, under Study 2 - Optimization, click Shape Optimization.
//    In the Settings window for Shape Optimization, locate the Output section.
//    Select the Plot checkbox.

    model.study("std2").feature("sho").set("plot", true);

//    In the table, enter the following settings:

    model.study("std2").feature("sho").setIndex("plotgrouparr", "pg5", 0);

//    In the Study toolbar, click Compute.

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

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

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

    model.study("std2").feature("sho").set("probewindow", "");

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

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

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    In the Frequencies text field, type range(fmin,(fmax-fmin)/(nf-1),fmax).

    model.study("std3").feature("freq").set("plist", "range(fmin,(fmax-fmin)/(nf-1),fmax)");
    model.study("std3").feature("freq").setSolveFor("/frame/material1", false);

//    Locate the Physics and Variables Selection section.
//    In the Solve for column of the table, under Component 1 (comp1), clear the checkbox for Deformed Geometry.
//    Locate the Results While Solving section.
//    From the Probes list, select None.

    model.study("std3").feature("freq").set("probesel", "none");

//    Click to expand the Values of Dependent Variables section.
//    Find the Values of variables not solved for subsection.
//    From the Settings list, select User controlled.

    model.study("std3").feature("freq").set("usesol", true);

//    From the Method list, select Solution.

    model.study("std3").feature("freq").set("notsolmethod", "sol");

//    From the Study list, select Study 2 - Optimization, Frequency Domain.

    model.study("std3").feature("freq").set("notstudy", "std2");

//    In the Model Builder window, click Study 3.
//    In the Settings window for Study, locate the Study Settings section.
//    Clear the Generate default plots checkbox.

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

//    In the Label text field, type Study 3 - Optimized Design.

    model.study("std3").label("Study 3 - Optimized Design");

//    In the Study toolbar, click Compute.

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

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

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

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

//    From the Selection list, select Visualization Domains.

    model.result().dataset("dset5").selection().named("geom1_sel4");

//    Right-click Study 3 - Optimized Design/Solution 3 (sol3) and choose Duplicate.

    model.result().dataset().duplicate("dset6", "dset5");

//    In the Settings window for Solution, type Study 3 - Optimized Design/Revolution in the Label text field.

    model.result().dataset("dset6").label("Study 3 - Optimized Design/Revolution");

//    Locate the Solution section.
//    From the Solution list, select Solution 2 (sol2).

    model.result().dataset("dset6").set("solution", "sol2");

//    In the Model Builder window, expand the Results > Datasets > Study 3 - Optimized Design/Revolution (sol2) node, then click Selection.
//    In the Settings window for Selection, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

    model.result().dataset("dset6").selection().geom("geom1", 1);

//    From the Selection list, select Revolution Boundaries.

    model.result().dataset("dset6").selection().named("geom1_sel9");

//    In the Results toolbar, click More Datasets and choose Revolution 2D.

    model.result().dataset().create("rev2", "Revolve2D");

//    In the Settings window for Revolution 2D, type Revolution 2D - Optimized Design in the Label text field.

    model.result().dataset("rev2").label("Revolution 2D - Optimized Design");

//    Locate the Data section.
//    From the Dataset list, select Study 3 - Optimized Design/Revolution (sol2).

    model.result().dataset("rev2").set("data", "dset6");

//    Locate the Revolution Layers section.
//    In the Revolution angle text field, type 90.

    model.result().dataset("rev2").set("revangle", 90);

//    Clear the Add end caps if the revolution is not full checkbox.

    model.result().dataset("rev2").set("endcaps", false);
    model.result("pg1").run();

//    In the Model Builder window, right-click Results > On-Axis Sound Pressure Level at 1 m > Octave Band 1 and choose Duplicate.

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

//    In the Settings window for Octave Band, locate the Data section.
//    From the Dataset list, select Study 3 - Optimized Design/Solution 3 (sol3).

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

//    Locate the y-Axis Data section.
//    In the Description text field, type SPL at 1 m - Optimized.

    model.result("pg1").feature("oct2").set("descr", "SPL at 1 m - Optimized");

//    Click to expand the Coloring and Style section.
//    Find the Line style subsection.
//    From the Line list, select Dashed.

    model.result("pg1").feature("oct2").set("linestyle", "dashed");
    model.result("pg2").run();

//    In the Model Builder window, right-click Results > Directivity > Directivity 1 and choose Duplicate.

    model.result("pg2").feature().duplicate("dir3", "dir1");
    model.result("pg2").run();

//    In the Settings window for Directivity, locate the Data section.
//    From the Dataset list, select Study 3 - Optimized Design/Solution 3 (sol3).

    model.result("pg2").feature("dir3").set("data", "dset5");

//    Locate the Evaluation section.
//    Find the Angles subsection.
//    In the φ start text field, type 0.

    model.result("pg2").feature("dir3").set("phimin", 0);

//    Locate the Coloring and Style section.
//    Select the Color legend checkbox.

    model.result("pg2").feature("dir3").set("colorlegend", true);
    model.result("pg2").run();

//    In the Model Builder window, right-click Results > Directivity > Directivity 2 and choose Duplicate.

    model.result("pg2").feature().duplicate("dir4", "dir2");
    model.result("pg2").run();

//    In the Settings window for Directivity, locate the Data section.
//    From the Dataset list, select Study 3 - Optimized Design/Solution 3 (sol3).

    model.result("pg2").feature("dir4").set("data", "dset5");

//    Locate the Evaluation section.
//    Find the Angles subsection.
//    In the φ start text field, type 0.

    model.result("pg2").feature("dir4").set("phimin", 0);

//    In the Directivity toolbar, click Plot.

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

//    In the Model Builder window, right-click Directivity and choose Line Segments.

    model.result("pg2").create("lnsg1", "LineSegments");
    model.result("pg2").feature("lnsg1").set("markerpos", "datapoints");
    model.result("pg2").feature("lnsg1").set("linewidth", "preference");

//    In the Settings window for Line Segments, locate the x-Coordinates section.
//    In the table, enter the following settings:

    model.result("pg2").feature("lnsg1").setIndex("xexpr", "-angle_eval/2", 0);
    model.result("pg2").feature("lnsg1").setIndex("xunit", "deg", 0);
    model.result("pg2").feature("lnsg1").setIndex("xdescr", "", 0);
    model.result("pg2").feature("lnsg1").setIndex("xexpr", "angle_eval/2", 1);
    model.result("pg2").feature("lnsg1").setIndex("xunit", "deg", 1);
    model.result("pg2").feature("lnsg1").setIndex("xdescr", "", 1);
    model.result("pg2").feature("lnsg1").setIndex("xexpr", "angle_eval/2", 2);
    model.result("pg2").feature("lnsg1").setIndex("xunit", "deg", 2);
    model.result("pg2").feature("lnsg1").setIndex("xdescr", "", 2);
    model.result("pg2").feature("lnsg1").setIndex("xexpr", "-angle_eval/2", 3);
    model.result("pg2").feature("lnsg1").setIndex("xunit", "deg", 3);
    model.result("pg2").feature("lnsg1").setIndex("xdescr", "", 3);
    model.result("pg2").feature("lnsg1").setIndex("xexpr", "-angle_eval/2", 4);
    model.result("pg2").feature("lnsg1").setIndex("xunit", "deg", 4);
    model.result("pg2").feature("lnsg1").setIndex("xdescr", "", 4);
    model.result("pg2").feature("lnsg1").setIndex("yexpr", "fmin_optim", 0);

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

    model.result("pg2").feature("lnsg1").setIndex("yunit", "Hz", 0);
    model.result("pg2").feature("lnsg1").setIndex("ydescr", "Minimum frequency optimized for", 0);
    model.result("pg2").feature("lnsg1").setIndex("yexpr", "fmin_optim", 1);
    model.result("pg2").feature("lnsg1").setIndex("yunit", "Hz", 1);
    model.result("pg2").feature("lnsg1").setIndex("ydescr", "Minimum frequency optimized for", 1);
    model.result("pg2").feature("lnsg1").setIndex("yexpr", "fmax_optim", 2);
    model.result("pg2").feature("lnsg1").setIndex("yunit", "Hz", 2);
    model.result("pg2").feature("lnsg1").setIndex("ydescr", "Maximum frequency optimized for", 2);
    model.result("pg2").feature("lnsg1").setIndex("yexpr", "fmax_optim", 3);
    model.result("pg2").feature("lnsg1").setIndex("yunit", "Hz", 3);
    model.result("pg2").feature("lnsg1").setIndex("ydescr", "Maximum frequency optimized for", 3);
    model.result("pg2").feature("lnsg1").setIndex("yexpr", "fmin_optim", 4);
    model.result("pg2").feature("lnsg1").setIndex("yunit", "Hz", 4);
    model.result("pg2").feature("lnsg1").setIndex("ydescr", "Minimum frequency optimized for", 4);

//    Click to expand the Coloring and Style section.
//    Find the Line style subsection.
//    From the Line list, select Dashed.

    model.result("pg2").feature("lnsg1").set("linestyle", "dashed");

//    From the Color list, select Gray.

    model.result("pg2").feature("lnsg1").set("linecolor", "gray");

//    From the Width list, select 1.

    model.result("pg2").feature("lnsg1").set("linewidth", 1);

//    In the Directivity toolbar, click Plot.

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

//    Right-click Directivity and choose Line Segments.

    model.result("pg2").create("lnsg2", "LineSegments");
    model.result("pg2").feature("lnsg2").set("markerpos", "datapoints");
    model.result("pg2").feature("lnsg2").set("linewidth", "preference");

//    In the Settings window for Line Segments, locate the x-Coordinates section.
//    In the table, enter the following settings:

    model.result("pg2").feature("lnsg2").setIndex("xexpr", 0, 0);
    model.result("pg2").feature("lnsg2").setIndex("xunit", 1, 0);
    model.result("pg2").feature("lnsg2").setIndex("xdescr", "", 0);
    model.result("pg2").feature("lnsg2").setIndex("xexpr", 0, 1);
    model.result("pg2").feature("lnsg2").setIndex("xunit", 1, 1);
    model.result("pg2").feature("lnsg2").setIndex("xdescr", "", 1);
    model.result("pg2").feature("lnsg2").setIndex("yexpr", "fmin", 0);

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

    model.result("pg2").feature("lnsg2").setIndex("yunit", "Hz", 0);
    model.result("pg2").feature("lnsg2").setIndex("ydescr", "Minimum frequency analyzed", 0);
    model.result("pg2").feature("lnsg2").setIndex("yexpr", "fmax", 1);
    model.result("pg2").feature("lnsg2").setIndex("yunit", "Hz", 1);
    model.result("pg2").feature("lnsg2").setIndex("ydescr", "Maximum frequency analyzed", 1);

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

    model.result("pg2").feature("lnsg2").set("linestyle", "dashdot");

//    From the Color list, select Black.

    model.result("pg2").feature("lnsg2").set("linecolor", "black");

//    From the Width list, select 1.

    model.result("pg2").feature("lnsg2").set("linewidth", 1);

//    In the Directivity toolbar, click Plot.

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

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

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

//    In the Settings window for Surface, locate the Data section.
//    From the Dataset list, select Study 3 - Optimized Design/Solution 3 (sol3).

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

//    Locate the Expression section.
//    In the Expression text field, type acpr.Lp_t.

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

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

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

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

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

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

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

//    Right-click Sound Pressure Level and choose Line.

    model.result("pg3").create("line3", "Line");
    model.result("pg3").feature("line3").set("evaluationsettings", "parent");

//    In the Settings window for Line, locate the Data section.
//    From the Dataset list, select Study 3 - Optimized Design/Solution 3 (sol3).

    model.result("pg3").feature("line3").set("data", "dset5");

//    Locate the Expression section.
//    In the Expression text field, type 0.

    model.result("pg3").feature("line3").set("expr", "0");

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

    model.result("pg3").feature("line3").set("coloring", "uniform");

//    From the Color list, select Gray.

    model.result("pg3").feature("line3").set("color", "gray");
    model.result("pg3").run();

//    Right-click Sound Pressure Level and choose Line.

    model.result("pg3").create("line4", "Line");
    model.result("pg3").feature("line4").set("evaluationsettings", "parent");

//    In the Settings window for Line, locate the Data section.
//    From the Dataset list, select Study 3 - Optimized Design/Solution 3 (sol3).

    model.result("pg3").feature("line4").set("data", "dset5");

//    Locate the Expression section.
//    In the Expression text field, type 0.

    model.result("pg3").feature("line4").set("expr", "0");

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

    model.result("pg3").feature("line4").set("linetype", "tube");

//    Click to expand the Inherit Style section.
//    From the Plot list, select Line 2.

    model.result("pg3").feature("line4").set("inheritplot", "line2");

//    Right-click Line 4 and choose Deformation.

    model.result("pg3").feature("line4").create("def1", "Deform");
    model.result("pg3").run();
    model.result("pg4").run();

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

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

//    In the Settings window for Surface, locate the Data section.
//    From the Dataset list, select Revolution 2D - Optimized Design.

    model.result("pg4").feature("surf2").set("data", "rev2");

//    Locate the Expression section.
//    In the Expression text field, type 0.

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

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

    model.result("pg4").feature("surf2").set("coloring", "uniform");

//    From the Color list, select Gray.

    model.result("pg4").feature("surf2").set("color", "gray");

//    Right-click Surface 2 and choose Filter.

    model.result("pg4").feature("surf2").create("filt1", "Filter");
    model.result("pg4").run();

//    In the Settings window for Filter, locate the Element Selection section.
//    In the Logical expression for inclusion text field, type (rev2y>0)*(rev2x>0).

    model.result("pg4").feature("surf2").feature("filt1").set("expr", "(rev2y>0)*(rev2x>0)");

//    In the Geometry toolbar, click Plot.

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

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

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

//    In the Settings window for Line, locate the Data section.
//    From the Dataset list, select Revolution 2D - Optimized Design.

    model.result("pg4").feature("line1").set("data", "rev2");

//    Locate the Expression section.
//    In the Expression text field, type 0.

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

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

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

//    From the Color list, select Black.

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

//    In the Geometry toolbar, click Plot.

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

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

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

//    Right-click Geometry and choose Contour.

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

//    In the Settings window for Contour, locate the Data section.
//    From the Dataset list, select Revolution 2D - Optimized Design.

    model.result("pg4").feature("con1").set("data", "rev2");

//    Locate the Expression section.
//    In the Expression text field, type fsd1.rel_disp.

    model.result("pg4").feature("con1").set("expr", "fsd1.rel_disp");

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

    model.result("pg4").feature("con1").set("colortable", "HeatCamera");

//    Clear the Color legend checkbox.

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

//    In the Geometry toolbar, click Plot.

    model.result("pg4").run();
    model.result("pg1").run();
    model.result("pg1").set("xlog", false);
    model.result("pg2").run();
    model.result("pg3").run();
    model.result("pg5").run();
    model.result("pg4").run();

    model.view("view3").set("showgrid", false);
    model.view("view3").set("showaxisorientation", false);

    model.title("Tweeter Dome and Waveguide Shape Optimization");

    model
         .description("A tweeter is a high frequency driver used in loudspeaker systems. An ideal tweeter will produce a constant sound pressure level at a given distance in front of the driver independently of frequency, that is, a flat response. Ideally the tweeter will also, to a certain degree, maintain this flat response when the listening point is moved off axis. The complex interactions between the dome breakup and the beaming are inherent to the loudspeaker driver design. This in turn introduces deviations from the ideal radiation characteristics.\n\nThis tutorial presents an example of shape optimization of the dome and the waveguide of the tweeter. By changing the shape of these two components, it is possible to tune the cone breakup and beaming effect so that the two cancel out through the frequency range and create a speaker that is closer to an ideal tweeter. The optimized design presents a flatter response curve through the range of frequencies and as well as improves the radiation pattern. This demonstrates the possibilities of optimization for these types of vibroacoustic problems.");

    return model;
  }

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

}
