/*
 * saw_euler_angle_rotation.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 11 2026, 08:13 by COMSOL 6.4.0.417. */
public class saw_euler_angle_rotation {

  public static Model run() {
    Model model = ModelUtil.create("Model");

//    Start by creating a new 3D model with a <l>Piezoelectricity</l> multiphysics interface to model propagation along the <eqv>XZ</eqv>-plane. This first example shows how the Euler angle rotations are applied to obtain the material properties of the 128° YX-cut LiNbO3. Also select <l>Eigenfrequency</l> for the first study.
//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    In the Model Wizard window, click 3D.
//    In the Select Physics tree, select AC/DC > Electromagnetics and Mechanics > Piezoelectricity > Piezoelectricity, Solid.
//    Click Add.
//    Click Study.
//    In the Select Study tree, select Preset Studies for Selected Multiphysics > Eigenfrequency.
//    Click Done.

    model.component().create("comp1", true);

    model.component("comp1").geom().create("geom1", 3);
    model.component("comp1").geom("geom1").geomRep("comsol");

    model.component("comp1").mesh().create("mesh1");
    model.component("comp1").mesh("mesh1").contribute("geom/detail", true);

    model.component("comp1").physics().create("es", "Electrostatics", "geom1");
    model.component("comp1").physics("es").create("ccnp1", "ChargeConservationPiezo");
    model.component("comp1").physics("es").feature("ccnp1").selection().all();
    model.component("comp1").physics().create("solid", "SolidMechanics", "geom1");
    model.component("comp1").physics("solid").create("pzm1", "PiezoelectricMaterialModel");
    model.component("comp1").physics("solid").feature("pzm1").selection().all();

    model.component("comp1").multiphysics().create("pze1", "PiezoelectricEffect", 3);
    model.component("comp1").multiphysics("pze1").set("Solid_physics", "solid");
    model.component("comp1").multiphysics("pze1").set("Electrostatics_physics", "es");

    model.study().create("std1");
    model.study("std1").create("eig", "Eigenfrequency");
    model.study("std1").feature("eig").set("chkeigregion", true);
    model.study("std1").feature("eig").set("storefact", false);
    model.study("std1").feature("eig").set("linpsolnum", "auto");
    model.study("std1").feature("eig").set("solnum", "auto");
    model.study("std1").feature("eig").set("notsolnum", "auto");
    model.study("std1").feature("eig").set("outputmap", new String[]{});
    model.study("std1").feature("eig").set("ngenAUX", "1");
    model.study("std1").feature("eig").set("goalngenAUX", "1");
    model.study("std1").feature("eig").set("ngenAUX", "1");
    model.study("std1").feature("eig").set("goalngenAUX", "1");

    model.component("comp1").common().create("mpf1", "ParticipationFactors");

//    It is given that 128° YX-cut LiNbO3 is defined by α = alpha_128 = 0°, β = beta_128 = -38°, γ = gamma_128 = 0° based on the X-Z-X rotation sequence. Define and specify these and other parameters of the model in <l>Global Definitions</l>.
//    In the Model Builder window, under Global Definitions, click Parameters 1.
//    In the Settings window for Parameters, locate the Parameters section.
//    In the table, enter the following settings:

    model.param().set("alpha_128", "0[deg]");
    model.param().descr("alpha_128", "Euler angle alpha");
    model.param().set("beta_128", "-38[deg]");
    model.param().descr("beta_128", "Euler angle beta");
    model.param().set("gamma_128", "0[deg]");
    model.param().descr("gamma_128", "Euler angle gamma");
    model.param().set("lambdaG", "8.97[um]");
    model.param().descr("lambdaG", "Design period");
    model.param().set("c_apr", "3997.8[m/s]");
    model.param().descr("c_apr", "Expected free SAW velocity");
    model.param().set("f_apr", "0.98*c_apr/lambdaG");
    model.param().descr("f_apr", "Initial guess for eigenfrequency");

//    In the Model Builder window, click Component 1 (comp1).
//    In the Settings window for Component, type Component 1 3D X-Propagation & XZ Sagittal Plane in the Label text field.

    model.component("comp1").label("Component 1 3D X-Propagation & XZ Sagittal Plane");

//    Use microns as the geometry unit. Create the geometry for the unit cell with the <eqv>XZ</eqv>-plane as the sagittal plane.
//    In the Model Builder window, under Component 1 3D X-Propagation & XZ Sagittal Plane (comp1), click Geometry 1.
//    In the Settings window for Geometry, locate the Units section.
//    From the Length unit list, select µm.

    model.component("comp1").geom("geom1").lengthUnit("\u00b5m");

//    In the Geometry toolbar, click Block.

    model.component("comp1").geom("geom1").create("blk1", "Block");

//    In the Settings window for Block, locate the Size and Shape section.
//    In the Width text field, type lambdaG.

    model.component("comp1").geom("geom1").feature("blk1").set("size", new String[]{"lambdaG", "1", "1"});

//    In the Depth text field, type 0.01*lambdaG.

    model.component("comp1").geom("geom1").feature("blk1").set("size", new String[]{"lambdaG", "0.01*lambdaG", "1"});

//    In the Height text field, type 10*lambdaG.

    model.component("comp1").geom("geom1").feature("blk1").setIndex("size", "10*lambdaG", 2);

//    Click to expand the Layers section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("blk1").setIndex("layer", "4*lambdaG", 0);

//    In the Geometry toolbar, click Build All.

    model.component("comp1").geom("geom1").run("fin");

//    In the Model Builder window, click Geometry 1.
//    Define operators that could be useful in results processing.
//    In the Model Builder window, expand the Component 1 3D X-Propagation & XZ Sagittal Plane (comp1) > Definitions node.
//    Right-click Definitions and choose Nonlocal Couplings > Maximum.

    model.component("comp1").cpl().create("maxop1", "Maximum");

//    In the Settings window for Maximum, locate the Source Selection section.
//    From the Selection list, select All domains.

    model.component("comp1").cpl("maxop1").selection().all();

//    Define a <l>Rotated System</l> for 128° YX-cut LiNbO3 in terms of the parameters alpha_128, beta_128 and gamma_128 and use it for the <l>Piezoelectric Material</l> feature under <l>Solid Mechanics</l> to compute the material properties for 128° YX-cut LiNbO3.
//    In the Definitions toolbar, click Coordinate Systems and choose Rotated System.

    model.component("comp1").coordSystem().create("sys2", "Rotated");

//    In the Settings window for Rotated System, locate the Rotation section.
//    Find the Euler angles subsection.
//    In the α text field, type alpha_128.

    model.component("comp1").coordSystem("sys2").set("angle", new String[]{"alpha_128", "0", "0"});

//    In the β text field, type beta_128.

    model.component("comp1").coordSystem("sys2").set("angle", new String[]{"alpha_128", "beta_128", "0"});

//    In the γ text field, type gamma_128.

    model.component("comp1").coordSystem("sys2").setIndex("angle", "gamma_128", 2);

//    Define a perfectly matched layer.
//    In the Definitions toolbar, click Perfectly Matched Layer.

    model.component("comp1").coordSystem().create("pml1", "PML");

//    Select Domain 1.

    model.component("comp1").coordSystem("pml1").selection().set(1);

//    Add materials and assign the domains they belong to.
//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Piezoelectric > Lithium Niobate.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat1", "Common");
    model.component("comp1").material("mat1").propertyGroup()
         .create("StrainCharge", "StrainCharge", "Strain-charge form");
    model.component("comp1").material("mat1").propertyGroup()
         .create("StressCharge", "StressCharge", "Stress-charge form");
    model.component("comp1").material("mat1").label("Lithium Niobate");
    model.component("comp1").material("mat1").set("family", "custom");
    model.component("comp1").material("mat1").set("customspecular", new double[]{0.7843137254901961, 1, 1});
    model.component("comp1").material("mat1").set("diffuse", "custom");
    model.component("comp1").material("mat1")
         .set("customdiffuse", new double[]{0.7843137254901961, 0.7843137254901961, 0.7843137254901961});
    model.component("comp1").material("mat1").set("ambient", "custom");
    model.component("comp1").material("mat1")
         .set("customambient", new double[]{0.7843137254901961, 0.7843137254901961, 0.7843137254901961});
    model.component("comp1").material("mat1").set("noise", true);
    model.component("comp1").material("mat1").set("fresnel", 0.9);
    model.component("comp1").material("mat1").set("roughness", 0.1);
    model.component("comp1").material("mat1").set("diffusewrap", 0);
    model.component("comp1").material("mat1").set("reflectance", 0);
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("relpermittivity", new String[]{"43.6", "0", "0", "0", "43.6", "0", "0", "0", "29.16"});
    model.component("comp1").material("mat1").propertyGroup("def").set("density", "4700[kg/m^3]");
    model.component("comp1").material("mat1").propertyGroup("StrainCharge").label("Strain-charge form");
    model.component("comp1").material("mat1").propertyGroup("StrainCharge")
         .set("sE", new String[]{"5.78e-012[1/Pa]", "-1.01e-012[1/Pa]", "-1.47e-012[1/Pa]", "-1.02e-012[1/Pa]", "0[1/Pa]", "0[1/Pa]", "-1.01e-012[1/Pa]", "5.78e-012[1/Pa]", "-1.47e-012[1/Pa]", "1.02e-012[1/Pa]", 
         "0[1/Pa]", "0[1/Pa]", "-1.47e-012[1/Pa]", "-1.47e-012[1/Pa]", "5.02e-012[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "-1.02e-012[1/Pa]", "1.02e-012[1/Pa]", 
         "0[1/Pa]", "1.7e-011[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "1.7e-011[1/Pa]", "-2.04e-012[1/Pa]", 
         "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "-2.04e-012[1/Pa]", "1.36e-011[1/Pa]"});
    model.component("comp1").material("mat1").propertyGroup("StrainCharge")
         .set("dET", new String[]{"0[C/N]", "-2.1e-011[C/N]", "-1e-012[C/N]", "0[C/N]", "2.1e-011[C/N]", "-1e-012[C/N]", "0[C/N]", "0[C/N]", "6e-012[C/N]", "0[C/N]", 
         "6.8e-011[C/N]", "0[C/N]", "6.8e-011[C/N]", "0[C/N]", "0[C/N]", "-4.2e-011[C/N]", "0[C/N]", "0[C/N]"});
    model.component("comp1").material("mat1").propertyGroup("StrainCharge")
         .set("epsilonrT", new String[]{"84", "0", "0", "0", "84", "0", "0", "0", "30"});
    model.component("comp1").material("mat1").propertyGroup("StressCharge").label("Stress-charge form");
    model.component("comp1").material("mat1").propertyGroup("StressCharge")
         .set("cE", new String[]{"2.02897e+011[Pa]", "5.29177e+010[Pa]", "7.49098e+010[Pa]", "8.99874e+009[Pa]", "0[Pa]", "0[Pa]", "5.29177e+010[Pa]", "2.02897e+011[Pa]", "7.49098e+010[Pa]", "-8.99874e+009[Pa]", 
         "0[Pa]", "0[Pa]", "7.49098e+010[Pa]", "7.49098e+010[Pa]", "2.43075e+011[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "8.99874e+009[Pa]", "-8.99874e+009[Pa]", 
         "0[Pa]", "5.99034e+010[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "5.99018e+010[Pa]", "8.98526e+009[Pa]", 
         "0[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "8.98526e+009[Pa]", "7.48772e+010[Pa]"});
    model.component("comp1").material("mat1").propertyGroup("StressCharge")
         .set("eES", new String[]{"0[C/m^2]", "-2.53764[C/m^2]", "0.193644[C/m^2]", "0[C/m^2]", "2.53764[C/m^2]", "0.193644[C/m^2]", "0[C/m^2]", "0[C/m^2]", "1.30863[C/m^2]", "0[C/m^2]", 
         "3.69548[C/m^2]", "0[C/m^2]", "3.69594[C/m^2]", "0[C/m^2]", "0[C/m^2]", "-2.53384[C/m^2]", "0[C/m^2]", "0[C/m^2]"});
    model.component("comp1").material("mat1").propertyGroup("StressCharge")
         .set("epsilonrS", new String[]{"43.6", "0", "0", "0", "43.6", "0", "0", "0", "29.16"});

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    Specify the settings for the <l>Electrostatics</l> and <l>Solid Mechanics</l> interfaces in the unit cell.
//    In the Physics toolbar, click Boundaries and choose Periodic Condition.

    model.component("comp1").physics("es").create("pc1", "PeriodicCondition", 2);

//    In the Settings window for Periodic Condition, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 2 5 8 9 in the Selection text field.
//    Click OK.

    model.component("comp1").physics("es").feature("pc1").selection().set(2, 5, 8, 9);

//    In the Physics toolbar, click Boundaries and choose Periodic Condition.

    model.component("comp1").physics("es").create("pc2", "PeriodicCondition", 2);

//    In the Settings window for Periodic Condition, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 1 4 10 11 in the Selection text field.
//    Click OK.

    model.component("comp1").physics("es").feature("pc2").selection().set(1, 4, 10, 11);

//    Use the previously defined rotated system in the <l>Piezoelectric Material</l> to compute the material properties for 128° YX-cut LiNbO3.
//    In the Model Builder window, under Component 1 3D X-Propagation & XZ Sagittal Plane (comp1) > Solid Mechanics (solid), click Piezoelectric Material 1.
//    In the Settings window for Piezoelectric Material, locate the Coordinate System Selection section.
//    From the Coordinate system list, select Rotated System 2 (sys2).

    model.component("comp1").physics("solid").feature("pzm1").set("coordinateSystem", "sys2");

//    In the Physics toolbar, click Boundaries and choose Periodic Condition.

    model.component("comp1").physics("solid").create("pc1", "PeriodicCondition", 2);

//    In the Settings window for Periodic Condition, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 2 5 8 9 in the Selection text field.
//    Click OK.

    model.component("comp1").physics("solid").feature("pc1").selection().set(2, 5, 8, 9);

//    In the Physics toolbar, click Boundaries and choose Periodic Condition.

    model.component("comp1").physics("solid").create("pc2", "PeriodicCondition", 2);

//    In the Settings window for Periodic Condition, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 1 4 10 11 in the Selection text field.
//    Click OK.

    model.component("comp1").physics("solid").feature("pc2").selection().set(1, 4, 10, 11);

//    In the Physics toolbar, click Boundaries and choose Fixed Constraint.

    model.component("comp1").physics("solid").create("fix1", "Fixed", 2);

//    In the Settings window for Fixed Constraint, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 3 in the Selection text field.
//    Click OK.

    model.component("comp1").physics("solid").feature("fix1").selection().set(3);

//    Create a mesh for the unit cell with <eqv>XZ</eqv> sagittal plane.
//    In the Mesh toolbar, click More Generators and choose Mapped.

    model.component("comp1").mesh("mesh1").create("map1", "Map");

//    In the Settings window for Mapped, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 2 5 in the Selection text field.
//    Click OK.

    model.component("comp1").mesh("mesh1").feature("map1").selection().set(2, 5);

//    Right-click Mapped 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("map1").create("dis1", "Distribution");

//    In the Settings window for Distribution, locate the Edge Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 1 in the Selection text field.
//    Click OK.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").selection().set(1);

//    In the Settings window for Distribution, locate the Distribution section.
//    In the Number of elements text field, type 10.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("numelem", 10);

//    In the Mesh toolbar, click Swept.

    model.component("comp1").mesh("mesh1").create("swe1", "Sweep");

//    In the Model Builder window, click Size.
//    In the Settings window for Size, locate the Element Size section.
//    Click the Custom button.

    model.component("comp1").mesh("mesh1").feature("size").set("custom", true);

//    Locate the Element Size Parameters section.
//    In the Maximum element size text field, type lambdaG/20.

    model.component("comp1").mesh("mesh1").feature("size").set("hmax", "lambdaG/20");

//    In the Minimum element size text field, type lambdaG/20.

    model.component("comp1").mesh("mesh1").feature("size").set("hmin", "lambdaG/20");

//    In the Model Builder window, right-click Mesh 1 and choose Build All.

    model.component("comp1").mesh("mesh1").run();

//    For the second example, create a 3D component for a unit cell with <eqv>XY</eqv> sagittal plane starting by copying from <l>Component 1</l> and then rotating the geometry by -90°. Because the geometry (or the XY sagittal plane) has been rotated -90° from the first case, define <l>Rotated System</l> with beta = beta_128-90[deg] for 128° YX-cut LiNbO3.
//    In the Model Builder window, collapse the Component 1 3D X-Propagation & XZ Sagittal Plane (comp1) node.
//    In the Model Builder window, right-click Component 1 3D X-Propagation & XZ Sagittal Plane (comp1) and choose Copy.
//    In the Model Builder window, right-click the root node and choose Paste Multiple Items.

    model.component().copy("comp2", "comp1");

//    In the Messages from Paste dialog, click OK.
//    In the Settings window for Component, type Component 2 3D X-Propagation & XY Sagittal Plane in the Label text field.

    model.component("comp2").label("Component 2 3D X-Propagation & XY Sagittal Plane");

//    In the Model Builder window, under Component 2 3D X-Propagation & XY Sagittal Plane (comp2) > Definitions, click Rotated System 2 (sys4).
//    In the Settings window for Rotated System, locate the Rotation section.
//    Find the Euler angles subsection.
//    In the β text field, type beta_128-90[deg].

    model.component("comp2").coordSystem("sys4").setIndex("angle", "beta_128-90[deg]", 1);

//    In the Model Builder window, expand the Component 2 3D X-Propagation & XY Sagittal Plane (comp2) > Geometry 1 node.
//    Right-click Geometry 1 and choose Transforms > Rotate.

    model.component("comp2").geom("geom2").run("blk1");
    model.component("comp2").geom("geom2").create("rot1", "Rotate");

//    Select the object blk1.

    model.component("comp2").geom("geom2").feature("rot1").selection("input").set("blk1");

//    In the Settings window for Rotate, locate the Rotation section.
//    From the Axis type list, select x-axis.

    model.component("comp2").geom("geom2").feature("rot1").set("axistype", "x");

//    In the Angle text field, type -90.

    model.component("comp2").geom("geom2").feature("rot1").set("rot", -90);

//    Click Build Selected.

    model.component("comp2").geom("geom2").run("rot1");

//    The third example is modeled in 2D by <l>Component 3</l>. Create a 2D component for the unit cell with <eqv>XY</eqv> sagittal plane and wave propagation in the X-direction, same as in the previous case. This model will use the same rotated system as the previous case.
//    In the Model Builder window, right-click the root node and choose Add Component > 2D.

    model.component().create("comp3", true);

    model.component("comp3").geom().create("geom3", 2);

    model.component("comp3").mesh().create("mesh3");

//    In the Settings window for Geometry, locate the Units section.
//    From the Length unit list, select µm.

    model.component("comp3").geom("geom3").lengthUnit("\u00b5m");

//    In the Geometry toolbar, click Rectangle.

    model.component("comp3").geom("geom3").create("r1", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type lambdaG.

    model.component("comp3").geom("geom3").feature("r1").set("size", new String[]{"lambdaG", "1"});

//    In the Height text field, type 10*lambdaG.

    model.component("comp3").geom("geom3").feature("r1").set("size", new String[]{"lambdaG", "10*lambdaG"});

//    Click to expand the Layers section.
//    In the table, enter the following settings:

    model.component("comp3").geom("geom3").feature("r1").setIndex("layer", "4*lambdaG", 0);

//    Click Build Selected.

    model.component("comp3").geom("geom3").run("r1");

//    In the Definitions toolbar, click Nonlocal Couplings and choose Maximum.

    model.component("comp3").cpl().create("maxop3", "Maximum");

    model.component("comp3").geom("geom3").run();

//    Click in the Graphics window and then press Ctrl+A to select both Domains.

    model.component("comp3").cpl("maxop3").selection().set(1, 2);

//    Define a rotated system for the 128° YX-cut LiNbO3.
//    In the Definitions toolbar, click Coordinate Systems and choose Rotated System.

    model.component("comp3").coordSystem().create("sys6", "Rotated");

//    In the Settings window for Rotated System, locate the Rotation section.
//    From the Input method list, select General rotation.

    model.component("comp3").coordSystem("sys6").set("method", "general");

//    Find the Euler angles subsection.
//    In the α text field, type alpha_128.

    model.component("comp3").coordSystem("sys6").set("angle", new String[]{"alpha_128", "0", "0"});

//    In the β text field, type beta_128-90[deg].

    model.component("comp3").coordSystem("sys6").set("angle", new String[]{"alpha_128", "beta_128-90[deg]", "0"});

//    In the γ text field, type gamma_128.

    model.component("comp3").coordSystem("sys6").setIndex("angle", "gamma_128", 2);

//    Define a perfectly matched layer.
//    In the Definitions toolbar, click Perfectly Matched Layer.

    model.component("comp3").coordSystem().create("pml3", "PML");

//    Select Domain 1.

    model.component("comp3").coordSystem("pml3").selection().set(1);

//    Add materials and assign the domains they belong to.
//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Piezoelectric > Lithium Niobate.
//    Click Add to Component in the window toolbar.

    model.component("comp3").material().create("mat3", "Common");
    model.component("comp3").material("mat3").propertyGroup()
         .create("StrainCharge", "StrainCharge", "Strain-charge form");
    model.component("comp3").material("mat3").propertyGroup()
         .create("StressCharge", "StressCharge", "Stress-charge form");
    model.component("comp3").material("mat3").label("Lithium Niobate");
    model.component("comp3").material("mat3").set("family", "custom");
    model.component("comp3").material("mat3").set("customspecular", new double[]{0.7843137254901961, 1, 1});
    model.component("comp3").material("mat3").set("diffuse", "custom");
    model.component("comp3").material("mat3")
         .set("customdiffuse", new double[]{0.7843137254901961, 0.7843137254901961, 0.7843137254901961});
    model.component("comp3").material("mat3").set("ambient", "custom");
    model.component("comp3").material("mat3")
         .set("customambient", new double[]{0.7843137254901961, 0.7843137254901961, 0.7843137254901961});
    model.component("comp3").material("mat3").set("noise", true);
    model.component("comp3").material("mat3").set("fresnel", 0.9);
    model.component("comp3").material("mat3").set("roughness", 0.1);
    model.component("comp3").material("mat3").set("diffusewrap", 0);
    model.component("comp3").material("mat3").set("reflectance", 0);
    model.component("comp3").material("mat3").propertyGroup("def")
         .set("relpermittivity", new String[]{"43.6", "0", "0", "0", "43.6", "0", "0", "0", "29.16"});
    model.component("comp3").material("mat3").propertyGroup("def").set("density", "4700[kg/m^3]");
    model.component("comp3").material("mat3").propertyGroup("StrainCharge").label("Strain-charge form");
    model.component("comp3").material("mat3").propertyGroup("StrainCharge")
         .set("sE", new String[]{"5.78e-012[1/Pa]", "-1.01e-012[1/Pa]", "-1.47e-012[1/Pa]", "-1.02e-012[1/Pa]", "0[1/Pa]", "0[1/Pa]", "-1.01e-012[1/Pa]", "5.78e-012[1/Pa]", "-1.47e-012[1/Pa]", "1.02e-012[1/Pa]", 
         "0[1/Pa]", "0[1/Pa]", "-1.47e-012[1/Pa]", "-1.47e-012[1/Pa]", "5.02e-012[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "-1.02e-012[1/Pa]", "1.02e-012[1/Pa]", 
         "0[1/Pa]", "1.7e-011[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "1.7e-011[1/Pa]", "-2.04e-012[1/Pa]", 
         "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "0[1/Pa]", "-2.04e-012[1/Pa]", "1.36e-011[1/Pa]"});
    model.component("comp3").material("mat3").propertyGroup("StrainCharge")
         .set("dET", new String[]{"0[C/N]", "-2.1e-011[C/N]", "-1e-012[C/N]", "0[C/N]", "2.1e-011[C/N]", "-1e-012[C/N]", "0[C/N]", "0[C/N]", "6e-012[C/N]", "0[C/N]", 
         "6.8e-011[C/N]", "0[C/N]", "6.8e-011[C/N]", "0[C/N]", "0[C/N]", "-4.2e-011[C/N]", "0[C/N]", "0[C/N]"});
    model.component("comp3").material("mat3").propertyGroup("StrainCharge")
         .set("epsilonrT", new String[]{"84", "0", "0", "0", "84", "0", "0", "0", "30"});
    model.component("comp3").material("mat3").propertyGroup("StressCharge").label("Stress-charge form");
    model.component("comp3").material("mat3").propertyGroup("StressCharge")
         .set("cE", new String[]{"2.02897e+011[Pa]", "5.29177e+010[Pa]", "7.49098e+010[Pa]", "8.99874e+009[Pa]", "0[Pa]", "0[Pa]", "5.29177e+010[Pa]", "2.02897e+011[Pa]", "7.49098e+010[Pa]", "-8.99874e+009[Pa]", 
         "0[Pa]", "0[Pa]", "7.49098e+010[Pa]", "7.49098e+010[Pa]", "2.43075e+011[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "8.99874e+009[Pa]", "-8.99874e+009[Pa]", 
         "0[Pa]", "5.99034e+010[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "5.99018e+010[Pa]", "8.98526e+009[Pa]", 
         "0[Pa]", "0[Pa]", "0[Pa]", "0[Pa]", "8.98526e+009[Pa]", "7.48772e+010[Pa]"});
    model.component("comp3").material("mat3").propertyGroup("StressCharge")
         .set("eES", new String[]{"0[C/m^2]", "-2.53764[C/m^2]", "0.193644[C/m^2]", "0[C/m^2]", "2.53764[C/m^2]", "0.193644[C/m^2]", "0[C/m^2]", "0[C/m^2]", "1.30863[C/m^2]", "0[C/m^2]", 
         "3.69548[C/m^2]", "0[C/m^2]", "3.69594[C/m^2]", "0[C/m^2]", "0[C/m^2]", "-2.53384[C/m^2]", "0[C/m^2]", "0[C/m^2]"});
    model.component("comp3").material("mat3").propertyGroup("StressCharge")
         .set("epsilonrS", new String[]{"43.6", "0", "0", "0", "43.6", "0", "0", "0", "29.16"});

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    Specify the settings for the <l>Electrostatics</l> and <l>Solid Mechanics</l> interfaces in the unit cell.
//    In the Physics toolbar, click Add Physics to open the Add Physics window.
//    In the tree, select AC/DC > Electromagnetics and Mechanics > Piezoelectricity > Piezoelectricity, Solid.
//    Click Add to Component 3 in the window toolbar.

    model.component("comp3").physics().create("es3", "Electrostatics", "geom3");
    model.component("comp3").physics("es3").create("ccnp1", "ChargeConservationPiezo");
    model.component("comp3").physics("es3").feature("ccnp1").selection().all();
    model.component("comp3").physics().create("solid3", "SolidMechanics", "geom3");
    model.component("comp3").physics("solid3").create("pzm1", "PiezoelectricMaterialModel");
    model.component("comp3").physics("solid3").feature("pzm1").selection().all();

    model.component("comp3").multiphysics().create("pze3", "PiezoelectricEffect", 2);

    model.study("std1").feature("eig").setSolveFor("/multiphysics/pze3", true);

    model.component("comp3").multiphysics("pze3").set("Solid_physics", "solid3");
    model.component("comp3").multiphysics("pze3").set("Electrostatics_physics", "es3");

//    In the Physics toolbar, click Add Physics to close the Add Physics window.
//    In the Physics toolbar, click Boundaries and choose Periodic Condition.

    model.component("comp3").physics("es3").create("pc1", "PeriodicCondition", 1);

//    In the Settings window for Periodic Condition, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 1 3 6 7 in the Selection text field.
//    Click OK.

    model.component("comp3").physics("es3").feature("pc1").selection().set(1, 3, 6, 7);

//    For 2D geometry, enable Out-of-plane mode extension in <l>Solid Mechanics</l>.
//    In the Model Builder window, under Component 3 (comp3), click Solid Mechanics 3 (solid3).
//    In the Settings window for Solid Mechanics, locate the 2D Approximation section.
//    Select the Out-of-plane mode extension (time-harmonic) checkbox.

    model.component("comp3").physics("solid3").prop("Type2D").set("ModeExtension", true);

//    In the Model Builder window, under Component 3 (comp3) > Solid Mechanics 3 (solid3), click Piezoelectric Material 1.
//    In the Settings window for Piezoelectric Material, type Piezoelectric Material Rotated in the Label text field.

    model.component("comp3").physics("solid3").feature("pzm1").label("Piezoelectric Material Rotated");

//    Locate the Coordinate System Selection section.
//    From the Coordinate system list, select Rotated System 6 (sys6).

    model.component("comp3").physics("solid3").feature("pzm1").set("coordinateSystem", "sys6");

//    In this last example, you are given the material property matrices for 128° YX-cut LiNbO3. To the 2D component, add a second <l>Piezoelectric Material</l> and define the material properties manually.
//    In the Physics toolbar, click Domains and choose Piezoelectric Material.

    model.component("comp3").physics("solid3").create("pzm2", "PiezoelectricMaterialModel", 2);

//    In the Settings window for Piezoelectric Material, type Piezoelectric Material Copy-Paste Data in the Label text field.

    model.component("comp3").physics("solid3").feature("pzm2").label("Piezoelectric Material Copy-Paste Data");

//    Locate the Domain Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 1 2 in the Selection text field.
//    Click OK.

    model.component("comp3").physics("solid3").feature("pzm2").selection().set(1, 2);

//    In the Settings window for Piezoelectric Material, locate the Piezoelectric Material Properties section.
//    From the \[c_{\textrm{E}}\] list, select User defined.

    model.component("comp3").physics("solid3").feature("pzm2").set("cE_mat", "userdef");

//    Specify the associated matrix as

    model.component("comp3").physics("solid3").feature("pzm2")
         .set("cE", new String[]{"2.02897E11", "6.99850E10", "5.78425E10", "1.28464E10", "0", "0", "6.99850E10", "1.93975E11", "9.03296E10", "9.31243E9", 
         "0", "0", "5.78425E10", "9.03296E10", "2.21158E11", "8.00285E9", "0", "0", "1.28464E10", "9.31243E9", 
         "8.00285E9", "7.53232E10", "0", "0", "0", "0", "0", "0", "5.68597E10", "-5.09155E9", 
         "0", "0", "0", "0", "-5.09155E9", "7.79193E10"});

//    From the \[e_{\textrm{ES}}\] list, select User defined.

    model.component("comp3").physics("solid3").feature("pzm2").set("eES_mat", "userdef");

//    Specify the associated matrix as

    model.component("comp3").physics("solid3").feature("pzm2")
         .set("eES", new String[]{"0", "-1.88047", "1.71492", "0", "4.44672", "-2.69210", "0", "-1.52214", "2.31358", "0", 
         "0.06738", "0.63381", "4.47243", "0", "0", "0.27875", "0", "0"});

//    From the \[\epsilon_{\textrm{rS}}\] list, select User defined.

    model.component("comp3").physics("solid3").feature("pzm2").set("epsilonrS_mat", "userdef");

//    From the list, select Symmetric.
//    Specify the \[\epsilon_{\textrm{rS}}\] matrix as

    model.component("comp3").physics("solid3").feature("pzm2")
         .set("epsilonrS", new String[]{"43.600", "0", "0", "0", "38.12668", "-7.00553", "0", "-7.00553", "34.63332"});

    return model;
  }

  public static Model run2(Model model) {

//    From the \[\rho\] list, select User defined.

    model.component("comp3").physics("solid3").feature("pzm2").set("rho_mat", "userdef");

//    In the associated text field, type 4700[kg/m^3].

    model.component("comp3").physics("solid3").feature("pzm2").set("rho", "4700[kg/m^3]");

//    In the Physics toolbar, click Boundaries and choose Periodic Condition.

    model.component("comp3").physics("solid3").create("pc1", "PeriodicCondition", 1);

//    In the Settings window for Periodic Condition, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 1 3 6 7 in the Selection text field.
//    Click OK.

    model.component("comp3").physics("solid3").feature("pc1").selection().set(1, 3, 6, 7);

//    In the Physics toolbar, click Boundaries and choose Fixed Constraint.

    model.component("comp3").physics("solid3").create("fix1", "Fixed", 1);

//    In the Settings window for Fixed Constraint, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 2 in the Selection text field.
//    Click OK.

    model.component("comp3").physics("solid3").feature("fix1").selection().set(2);

//    In the Model Builder window, click Component 3 (comp3).
//    In the Settings window for Component, type Component 3 2D X-Propagation & XY Sagittal Plane in the Label text field.

    model.component("comp3").label("Component 3 2D X-Propagation & XY Sagittal Plane");

//    Create a mesh for the 2D unit cell.
//    In the Mesh toolbar, click Mapped.

    model.component("comp3").mesh("mesh3").create("map1", "Map");

//    Right-click Mapped 1 and choose Distribution.

    model.component("comp3").mesh("mesh3").feature("map1").create("dis1", "Distribution");

//    In the Settings window for Distribution, locate the Boundary Selection section.
//    Click Paste Selection.
//    In the Paste Selection dialog, type 1 in the Selection text field.
//    Click OK.

    model.component("comp3").mesh("mesh3").feature("map1").feature("dis1").selection().set(1);

//    In the Settings window for Distribution, locate the Distribution section.
//    In the Number of elements text field, type 10.

    model.component("comp3").mesh("mesh3").feature("map1").feature("dis1").set("numelem", 10);

//    In the Model Builder window, under Component 3 2D X-Propagation & XY Sagittal Plane (comp3) > Mesh 3, click Size.
//    In the Settings window for Size, locate the Element Size section.
//    Click the Custom button.

    model.component("comp3").mesh("mesh3").feature("size").set("custom", true);

//    Locate the Element Size Parameters section.
//    In the Maximum element size text field, type lambdaG/20.

    model.component("comp3").mesh("mesh3").feature("size").set("hmax", "lambdaG/20");

//    In the Minimum element size text field, type lambdaG/20.

    model.component("comp3").mesh("mesh3").feature("size").set("hmin", "lambdaG/20");

//    Click Build Selected.

    model.component("comp3").mesh("mesh3").run("size");

//    In the Model Builder window, right-click Mesh 3 and choose Build All.

    model.component("comp3").mesh("mesh3").run();

//    Set up the <l>Eigenfrequency</l> study to search around <c>f_apr</c> for the unit cell with <eqv>XZ</eqv> sagittal plane. For this study, disable Component 2 and Component 3.
//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, type Study 1: 3D X-Propagation & XZ Sagittal Plane in the Label text field.

    model.study("std1").label("Study 1: 3D X-Propagation & XZ Sagittal Plane");

//    In the Model Builder window, under Study 1: 3D X-Propagation & XZ Sagittal Plane, click Step 1: Eigenfrequency.
//    In the Settings window for Eigenfrequency, locate the Study Settings section.
//    Select the Desired number of eigenfrequencies checkbox.

    model.study("std1").feature("eig").set("neigsactive", true);

//    In the associated text field, type 2.

    model.study("std1").feature("eig").set("neigs", 2);

//    From the Unit list, select MHz.

    model.study("std1").feature("eig").set("eigunit", "MHz");

//    In the Search for eigenfrequencies around shift text field, type f_apr.

    model.study("std1").feature("eig").set("shift", "f_apr");
    model.study("std1").feature("eig").setSolveFor("/modelNode/comp2", false);

//    Locate the Physics and Variables Selection section.

    model.study("std1").feature("eig").setSolveFor("/modelNode/comp3", false);

//    In the Solve for column of the table, clear the checkboxes for Component 2 3D X-Propagation & XY Sagittal Plane (comp2), Component 3 2D X-Propagation & XY Sagittal Plane (comp3).
//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.sol("sol1").runAll();

    model.result().create("pg1", "PlotGroup3D");
    model.result("pg1").label("Electric Potential (es)");
    model.result("pg1").set("frametype", "spatial");
    model.result("pg1").set("showlegendsmaxmin", true);
    model.result("pg1").feature().create("mslc1", "Multislice");
    model.result("pg1").feature("mslc1").set("solutionparams", "parent");
    model.result("pg1").feature("mslc1").set("multiplanexmethod", "coord");
    model.result("pg1").feature("mslc1").set("xcoord", "es.CPx");
    model.result("pg1").feature("mslc1").set("multiplaneymethod", "coord");
    model.result("pg1").feature("mslc1").set("ycoord", "es.CPy");
    model.result("pg1").feature("mslc1").set("multiplanezmethod", "coord");
    model.result("pg1").feature("mslc1").set("zcoord", "es.CPz");
    model.result("pg1").feature("mslc1").set("colortable", "Dipole");
    model.result("pg1").feature("mslc1").set("evaluationsettings", "parent");
    model.result("pg1").feature("mslc1").set("data", "parent");
    model.result("pg1").feature().create("strmsl1", "StreamlineMultislice");
    model.result("pg1").feature("strmsl1").set("solutionparams", "parent");
    model.result("pg1").feature("strmsl1").set("multiplanexmethod", "coord");
    model.result("pg1").feature("strmsl1").set("xcoord", "es.CPx");
    model.result("pg1").feature("strmsl1").set("multiplaneymethod", "coord");
    model.result("pg1").feature("strmsl1").set("ycoord", "es.CPy");
    model.result("pg1").feature("strmsl1").set("multiplanezmethod", "coord");
    model.result("pg1").feature("strmsl1").set("zcoord", "es.CPz");
    model.result("pg1").feature("strmsl1").set("titletype", "none");
    model.result("pg1").feature("strmsl1").set("posmethod", "uniform");
    model.result("pg1").feature("strmsl1").set("udensity", 8);
    model.result("pg1").feature("strmsl1").set("color", "black");
    model.result("pg1").feature("strmsl1").set("evaluationsettings", "parent");
    model.result("pg1").feature("strmsl1").set("maxlen", 0.4);
    model.result("pg1").feature("strmsl1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("strmsl1").set("inheritcolor", false);
    model.result("pg1").feature("strmsl1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg1").feature("strmsl1").set("data", "parent");
    model.result("pg1").feature("strmsl1").set("inheritplot", "mslc1");
    model.result("pg1").feature("strmsl1").feature().create("tran1", "Transparency");
    model.result("pg1").feature("strmsl1").feature("tran1").set("transparency", 0.9);
    model.result("pg1").feature("strmsl1").feature().create("filt1", "Filter");
    model.result("pg1").feature("strmsl1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result().create("pg2", "PlotGroup3D");
    model.result("pg2").label("Electric Field (es)");
    model.result("pg2").set("frametype", "spatial");
    model.result("pg2").set("showlegendsmaxmin", true);
    model.result("pg2").feature().create("mslc1", "Multislice");
    model.result("pg2").feature("mslc1").set("solutionparams", "parent");
    model.result("pg2").feature("mslc1").set("expr", "es.normE");
    model.result("pg2").feature("mslc1").set("multiplanexmethod", "coord");
    model.result("pg2").feature("mslc1").set("xcoord", "es.CPx");
    model.result("pg2").feature("mslc1").set("multiplaneymethod", "coord");
    model.result("pg2").feature("mslc1").set("ycoord", "es.CPy");
    model.result("pg2").feature("mslc1").set("multiplanezmethod", "coord");
    model.result("pg2").feature("mslc1").set("zcoord", "es.CPz");
    model.result("pg2").feature("mslc1").set("colortable", "Prism");
    model.result("pg2").feature("mslc1").set("colortabletrans", "nonlinear");
    model.result("pg2").feature("mslc1").set("colorcalibration", -0.8);
    model.result("pg2").feature("mslc1").set("evaluationsettings", "parent");
    model.result("pg2").feature("mslc1").set("data", "parent");
    model.result("pg2").feature().create("strmsl1", "StreamlineMultislice");
    model.result("pg2").feature("strmsl1").set("solutionparams", "parent");
    model.result("pg2").feature("strmsl1").set("multiplanexmethod", "coord");
    model.result("pg2").feature("strmsl1").set("xcoord", "es.CPx");
    model.result("pg2").feature("strmsl1").set("multiplaneymethod", "coord");
    model.result("pg2").feature("strmsl1").set("ycoord", "es.CPy");
    model.result("pg2").feature("strmsl1").set("multiplanezmethod", "coord");
    model.result("pg2").feature("strmsl1").set("zcoord", "es.CPz");
    model.result("pg2").feature("strmsl1").set("titletype", "none");
    model.result("pg2").feature("strmsl1").set("posmethod", "uniform");
    model.result("pg2").feature("strmsl1").set("udensity", 8);
    model.result("pg2").feature("strmsl1").set("color", "black");
    model.result("pg2").feature("strmsl1").set("evaluationsettings", "parent");
    model.result("pg2").feature("strmsl1").set("maxlen", 0.4);
    model.result("pg2").feature("strmsl1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg2").feature("strmsl1").set("inheritcolor", false);
    model.result("pg2").feature("strmsl1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg2").feature("strmsl1").set("data", "parent");
    model.result("pg2").feature("strmsl1").set("inheritplot", "mslc1");
    model.result("pg2").feature("strmsl1").feature().create("tran1", "Transparency");
    model.result("pg2").feature("strmsl1").feature("tran1").set("transparency", 0.9);
    model.result("pg2").feature("strmsl1").feature().create("filt1", "Filter");
    model.result("pg2").feature("strmsl1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result().create("pg3", "PlotGroup3D");
    model.result("pg3").set("data", "dset1");
    model.result("pg3").setIndex("looplevel", 1, 0);
    model.result("pg3").label("Mode Shape (solid)");
    model.result("pg3").set("showlegends", false);
    model.result("pg3").create("surf1", "Surface");
    model.result("pg3").feature("surf1").set("expr", new String[]{"solid.disp"});
    model.result("pg3").feature("surf1").set("threshold", "manual");
    model.result("pg3").feature("surf1").set("thresholdvalue", 0.2);
    model.result("pg3").feature("surf1").set("colortable", "Rainbow");
    model.result("pg3").feature("surf1").set("colortabletrans", "none");
    model.result("pg3").feature("surf1").set("colorscalemode", "linear");
    model.result("pg3").feature("surf1").set("colortable", "AuroraBorealis");
    model.result("pg3").feature("surf1").create("def", "Deform");
    model.result("pg3").feature("surf1").feature("def").set("expr", new String[]{"u", "v", "w"});
    model.result("pg3").feature("surf1").feature("def").set("descr", "Displacement field");
    model.result().evaluationGroup().create("std1EvgFrq", "EvaluationGroup");
    model.result().evaluationGroup("std1EvgFrq").set("data", "dset1");
    model.result().evaluationGroup("std1EvgFrq")
         .label("Eigenfrequencies (Study 1: 3D X-Propagation & XZ Sagittal Plane)");
    model.result().evaluationGroup("std1EvgFrq").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("std1EvgFrq").feature("gev1").setIndex("expr", "2*pi*freq", 0);
    model.result().evaluationGroup("std1EvgFrq").feature("gev1").setIndex("unit", "rad/s", 0);
    model.result().evaluationGroup("std1EvgFrq").feature("gev1").setIndex("descr", "Angular frequency", 0);
    model.result().evaluationGroup("std1EvgFrq").feature("gev1").setIndex("expr", "imag(freq)/abs(freq)", 1);
    model.result().evaluationGroup("std1EvgFrq").feature("gev1").setIndex("unit", "1", 1);
    model.result().evaluationGroup("std1EvgFrq").feature("gev1").setIndex("descr", "Damping ratio", 1);
    model.result().evaluationGroup("std1EvgFrq").feature("gev1").setIndex("expr", "abs(freq)/imag(freq)/2", 2);
    model.result().evaluationGroup("std1EvgFrq").feature("gev1").setIndex("unit", "1", 2);
    model.result().evaluationGroup("std1EvgFrq").feature("gev1").setIndex("descr", "Quality factor", 2);
    model.result().evaluationGroup("std1EvgFrq").run();
    model.result().evaluationGroup().create("std1mpf1", "EvaluationGroup");
    model.result().evaluationGroup("std1mpf1").set("data", "dset1");
    model.result().evaluationGroup("std1mpf1")
         .label("Participation Factors (Study 1: 3D X-Propagation & XZ Sagittal Plane)");
    model.result().evaluationGroup("std1mpf1").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.pfLnormX", 0);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "1", 0);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, X-translation", 0);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.pfLnormY", 1);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "1", 1);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Y-translation", 1);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.pfLnormZ", 2);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "1", 2);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Z-translation", 2);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.pfRnormX", 3);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "1", 3);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, X-rotation", 3);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.pfRnormY", 4);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "1", 4);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Y-rotation", 4);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.pfRnormZ", 5);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "1", 5);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Z-rotation", 5);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.mEffLX", 6);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "kg", 6);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Effective modal mass, X-translation", 6);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.mEffLY", 7);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "kg", 7);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Effective modal mass, Y-translation", 7);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.mEffLZ", 8);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "kg", 8);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Effective modal mass, Z-translation", 8);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.mEffRX", 9);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "kg*m^2", 9);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Effective modal mass, X-rotation", 9);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.mEffRY", 10);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "kg*m^2", 10);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Effective modal mass, Y-rotation", 10);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("expr", "mpf1.mEffRZ", 11);
    model.result().evaluationGroup("std1mpf1").feature("gev1").setIndex("unit", "kg*m^2", 11);
    model.result().evaluationGroup("std1mpf1").feature("gev1")
         .setIndex("descr", "Effective modal mass, Z-rotation", 11);
    model.result().evaluationGroup("std1mpf1").run();
    model.result("pg1").run();

//    Add an <l>Eigenfrequency</l> study for the 3D unit cell with <eqv>XY</eqv> sagittal plane and set it up to search around <c>f_apr</c>. For this study, disable Component 1 and Component 3.
//    In the Study toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select Preset Studies for Selected Multiphysics > Eigenfrequency.
//    Click Add Study in the window toolbar.

    model.study().create("std2");
    model.study("std2").create("eig", "Eigenfrequency");
    model.study("std2").feature("eig").set("chkeigregion", true);
    model.study("std2").feature("eig").set("storefact", false);
    model.study("std2").feature("eig").set("linpsolnum", "auto");
    model.study("std2").feature("eig").set("plotgrouparr", new String[]{"Default"});
    model.study("std2").feature("eig").set("solnum", "auto");
    model.study("std2").feature("eig").set("notsolnum", "auto");
    model.study("std2").feature("eig").set("outputmap", new String[]{});
    model.study("std2").feature("eig").set("ngenAUX", "1");
    model.study("std2").feature("eig").set("goalngenAUX", "1");
    model.study("std2").feature("eig").set("ngenAUX", "1");
    model.study("std2").feature("eig").set("goalngenAUX", "1");

    model.component("comp3").common().create("mpf3", "ParticipationFactors");

//    In the Study toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Eigenfrequency, locate the Study Settings section.
//    Select the Desired number of eigenfrequencies checkbox.

    model.study("std2").feature("eig").set("neigsactive", true);

//    In the associated text field, type 2.

    model.study("std2").feature("eig").set("neigs", 2);

//    From the Unit list, select MHz.

    model.study("std2").feature("eig").set("eigunit", "MHz");

//    In the Search for eigenfrequencies around shift text field, type f_apr.

    model.study("std2").feature("eig").set("shift", "f_apr");
    model.study("std2").feature("eig").setSolveFor("/modelNode/comp1", false);

//    Locate the Physics and Variables Selection section.

    model.study("std2").feature("eig").setSolveFor("/modelNode/comp3", false);

//    In the Solve for column of the table, clear the checkboxes for Component 1 3D X-Propagation & XZ Sagittal Plane (comp1), Component 3 2D X-Propagation & XY Sagittal Plane (comp3).
//    In the Model Builder window, click Study 2.
//    In the Settings window for Study, type Study 2: 3D X-Propagation & XY Sagittal Plane in the Label text field.

    model.study("std2").label("Study 2: 3D X-Propagation & XY Sagittal Plane");

//    In the Study toolbar, click Compute.

    model.study("std2").createAutoSequences("all");

    model.sol("sol2").runAll();

    model.result().create("pg4", "PlotGroup3D");
    model.result("pg4").label("Electric Potential (es2)");
    model.result("pg4").set("data", "dset5");
    model.result("pg4").setIndex("looplevel", 1, 0);
    model.result("pg4").set("frametype", "spatial");
    model.result("pg4").set("showlegendsmaxmin", true);
    model.result("pg4").feature().create("mslc1", "Multislice");
    model.result("pg4").feature("mslc1").set("solutionparams", "parent");
    model.result("pg4").feature("mslc1").set("multiplanexmethod", "coord");
    model.result("pg4").feature("mslc1").set("xcoord", "es2.CPx");
    model.result("pg4").feature("mslc1").set("multiplaneymethod", "coord");
    model.result("pg4").feature("mslc1").set("ycoord", "es2.CPy");
    model.result("pg4").feature("mslc1").set("multiplanezmethod", "coord");
    model.result("pg4").feature("mslc1").set("zcoord", "es2.CPz");
    model.result("pg4").feature("mslc1").set("colortable", "Dipole");
    model.result("pg4").feature("mslc1").set("evaluationsettings", "parent");
    model.result("pg4").feature("mslc1").set("data", "parent");
    model.result("pg4").feature().create("strmsl1", "StreamlineMultislice");
    model.result("pg4").feature("strmsl1").set("solutionparams", "parent");
    model.result("pg4").feature("strmsl1").set("multiplanexmethod", "coord");
    model.result("pg4").feature("strmsl1").set("xcoord", "es2.CPx");
    model.result("pg4").feature("strmsl1").set("multiplaneymethod", "coord");
    model.result("pg4").feature("strmsl1").set("ycoord", "es2.CPy");
    model.result("pg4").feature("strmsl1").set("multiplanezmethod", "coord");
    model.result("pg4").feature("strmsl1").set("zcoord", "es2.CPz");
    model.result("pg4").feature("strmsl1").set("titletype", "none");
    model.result("pg4").feature("strmsl1").set("posmethod", "uniform");
    model.result("pg4").feature("strmsl1").set("udensity", 8);
    model.result("pg4").feature("strmsl1").set("color", "black");
    model.result("pg4").feature("strmsl1").set("evaluationsettings", "parent");
    model.result("pg4").feature("strmsl1").set("maxlen", 0.4);
    model.result("pg4").feature("strmsl1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("strmsl1").set("inheritcolor", false);
    model.result("pg4").feature("strmsl1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg4").feature("strmsl1").set("data", "parent");
    model.result("pg4").feature("strmsl1").set("inheritplot", "mslc1");
    model.result("pg4").feature("strmsl1").feature().create("tran1", "Transparency");
    model.result("pg4").feature("strmsl1").feature("tran1").set("transparency", 0.9);
    model.result("pg4").feature("strmsl1").feature().create("filt1", "Filter");
    model.result("pg4").feature("strmsl1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result().create("pg5", "PlotGroup3D");
    model.result("pg5").label("Electric Field (es2)");
    model.result("pg5").set("data", "dset5");
    model.result("pg5").setIndex("looplevel", 1, 0);
    model.result("pg5").set("frametype", "spatial");
    model.result("pg5").set("showlegendsmaxmin", true);
    model.result("pg5").feature().create("mslc1", "Multislice");
    model.result("pg5").feature("mslc1").set("solutionparams", "parent");
    model.result("pg5").feature("mslc1").set("expr", "es2.normE");
    model.result("pg5").feature("mslc1").set("multiplanexmethod", "coord");
    model.result("pg5").feature("mslc1").set("xcoord", "es2.CPx");
    model.result("pg5").feature("mslc1").set("multiplaneymethod", "coord");
    model.result("pg5").feature("mslc1").set("ycoord", "es2.CPy");
    model.result("pg5").feature("mslc1").set("multiplanezmethod", "coord");
    model.result("pg5").feature("mslc1").set("zcoord", "es2.CPz");
    model.result("pg5").feature("mslc1").set("colortable", "Prism");
    model.result("pg5").feature("mslc1").set("colortabletrans", "nonlinear");
    model.result("pg5").feature("mslc1").set("colorcalibration", -0.8);
    model.result("pg5").feature("mslc1").set("evaluationsettings", "parent");
    model.result("pg5").feature("mslc1").set("data", "parent");
    model.result("pg5").feature().create("strmsl1", "StreamlineMultislice");
    model.result("pg5").feature("strmsl1").set("solutionparams", "parent");
    model.result("pg5").feature("strmsl1").set("multiplanexmethod", "coord");
    model.result("pg5").feature("strmsl1").set("xcoord", "es2.CPx");
    model.result("pg5").feature("strmsl1").set("multiplaneymethod", "coord");
    model.result("pg5").feature("strmsl1").set("ycoord", "es2.CPy");
    model.result("pg5").feature("strmsl1").set("multiplanezmethod", "coord");
    model.result("pg5").feature("strmsl1").set("zcoord", "es2.CPz");
    model.result("pg5").feature("strmsl1").set("titletype", "none");
    model.result("pg5").feature("strmsl1").set("posmethod", "uniform");
    model.result("pg5").feature("strmsl1").set("udensity", 8);
    model.result("pg5").feature("strmsl1").set("color", "black");
    model.result("pg5").feature("strmsl1").set("evaluationsettings", "parent");
    model.result("pg5").feature("strmsl1").set("maxlen", 0.4);
    model.result("pg5").feature("strmsl1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg5").feature("strmsl1").set("inheritcolor", false);
    model.result("pg5").feature("strmsl1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg5").feature("strmsl1").set("data", "parent");
    model.result("pg5").feature("strmsl1").set("inheritplot", "mslc1");
    model.result("pg5").feature("strmsl1").feature().create("tran1", "Transparency");
    model.result("pg5").feature("strmsl1").feature("tran1").set("transparency", 0.9);
    model.result("pg5").feature("strmsl1").feature().create("filt1", "Filter");
    model.result("pg5").feature("strmsl1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result().create("pg6", "PlotGroup3D");
    model.result("pg6").set("data", "dset5");
    model.result("pg6").setIndex("looplevel", 1, 0);
    model.result("pg6").label("Mode Shape (solid2)");
    model.result("pg6").set("showlegends", false);
    model.result("pg6").create("surf1", "Surface");
    model.result("pg6").feature("surf1").set("expr", new String[]{"solid2.disp"});
    model.result("pg6").feature("surf1").set("threshold", "manual");
    model.result("pg6").feature("surf1").set("thresholdvalue", 0.2);
    model.result("pg6").feature("surf1").set("colortable", "Rainbow");
    model.result("pg6").feature("surf1").set("colortabletrans", "none");
    model.result("pg6").feature("surf1").set("colorscalemode", "linear");
    model.result("pg6").feature("surf1").set("colortable", "AuroraBorealis");
    model.result("pg6").feature("surf1").create("def", "Deform");
    model.result("pg6").feature("surf1").feature("def").set("expr", new String[]{"u", "v", "w"});
    model.result("pg6").feature("surf1").feature("def").set("descr", "Displacement field");
    model.result().evaluationGroup().create("std2EvgFrq", "EvaluationGroup");
    model.result().evaluationGroup("std2EvgFrq").set("data", "dset5");
    model.result().evaluationGroup("std2EvgFrq")
         .label("Eigenfrequencies (Study 2: 3D X-Propagation & XY Sagittal Plane)");
    model.result().evaluationGroup("std2EvgFrq").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("std2EvgFrq").feature("gev1").setIndex("expr", "2*pi*freq", 0);
    model.result().evaluationGroup("std2EvgFrq").feature("gev1").setIndex("unit", "rad/s", 0);
    model.result().evaluationGroup("std2EvgFrq").feature("gev1").setIndex("descr", "Angular frequency", 0);
    model.result().evaluationGroup("std2EvgFrq").feature("gev1").setIndex("expr", "imag(freq)/abs(freq)", 1);
    model.result().evaluationGroup("std2EvgFrq").feature("gev1").setIndex("unit", "1", 1);
    model.result().evaluationGroup("std2EvgFrq").feature("gev1").setIndex("descr", "Damping ratio", 1);
    model.result().evaluationGroup("std2EvgFrq").feature("gev1").setIndex("expr", "abs(freq)/imag(freq)/2", 2);
    model.result().evaluationGroup("std2EvgFrq").feature("gev1").setIndex("unit", "1", 2);
    model.result().evaluationGroup("std2EvgFrq").feature("gev1").setIndex("descr", "Quality factor", 2);
    model.result().evaluationGroup("std2EvgFrq").run();
    model.result().evaluationGroup().create("std2mpf2", "EvaluationGroup");
    model.result().evaluationGroup("std2mpf2").set("data", "dset5");
    model.result().evaluationGroup("std2mpf2")
         .label("Participation Factors (Study 2: 3D X-Propagation & XY Sagittal Plane)");
    model.result().evaluationGroup("std2mpf2").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.pfLnormX", 0);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "1", 0);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, X-translation", 0);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.pfLnormY", 1);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "1", 1);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Y-translation", 1);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.pfLnormZ", 2);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "1", 2);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Z-translation", 2);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.pfRnormX", 3);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "1", 3);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, X-rotation", 3);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.pfRnormY", 4);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "1", 4);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Y-rotation", 4);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.pfRnormZ", 5);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "1", 5);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Z-rotation", 5);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.mEffLX", 6);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "kg", 6);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Effective modal mass, X-translation", 6);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.mEffLY", 7);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "kg", 7);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Effective modal mass, Y-translation", 7);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.mEffLZ", 8);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "kg", 8);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Effective modal mass, Z-translation", 8);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.mEffRX", 9);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "kg*m^2", 9);

    return model;
  }

  public static Model run3(Model model) {
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Effective modal mass, X-rotation", 9);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.mEffRY", 10);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "kg*m^2", 10);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Effective modal mass, Y-rotation", 10);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("expr", "mpf2.mEffRZ", 11);
    model.result().evaluationGroup("std2mpf2").feature("gev1").setIndex("unit", "kg*m^2", 11);
    model.result().evaluationGroup("std2mpf2").feature("gev1")
         .setIndex("descr", "Effective modal mass, Z-rotation", 11);
    model.result().evaluationGroup("std2mpf2").run();
    model.result("pg4").run();

//    Add an <l>Eigenfrequency</l> study for the 2D unit cell with <eqv>XY</eqv> sagittal plane and set it up to search around <c>f_apr</c>. For this study, disable Component 1 and Component 2 and Piezoelectric Material 2.
//    In the Study toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select Preset Studies for Selected Multiphysics > Eigenfrequency.
//    Click Add Study in the window toolbar.

    model.study().create("std3");
    model.study("std3").create("eig", "Eigenfrequency");
    model.study("std3").feature("eig").set("chkeigregion", true);
    model.study("std3").feature("eig").set("storefact", false);
    model.study("std3").feature("eig").set("linpsolnum", "auto");
    model.study("std3").feature("eig").set("plotgrouparr", new String[]{"Default"});
    model.study("std3").feature("eig").set("solnum", "auto");
    model.study("std3").feature("eig").set("notsolnum", "auto");
    model.study("std3").feature("eig").set("outputmap", new String[]{});
    model.study("std3").feature("eig").set("ngenAUX", "1");
    model.study("std3").feature("eig").set("goalngenAUX", "1");
    model.study("std3").feature("eig").set("ngenAUX", "1");
    model.study("std3").feature("eig").set("goalngenAUX", "1");

//    In the Study toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Eigenfrequency, locate the Study Settings section.
//    Select the Desired number of eigenfrequencies checkbox.

    model.study("std3").feature("eig").set("neigsactive", true);

//    In the associated text field, type 2.

    model.study("std3").feature("eig").set("neigs", 2);

//    From the Unit list, select MHz.

    model.study("std3").feature("eig").set("eigunit", "MHz");

//    In the Search for eigenfrequencies around shift text field, type f_apr.

    model.study("std3").feature("eig").set("shift", "f_apr");
    model.study("std3").feature("eig").setSolveFor("/modelNode/comp1", false);

//    Locate the Physics and Variables Selection section.

    model.study("std3").feature("eig").setSolveFor("/modelNode/comp2", false);

//    In the Solve for column of the table, clear the checkboxes for Component 1 3D X-Propagation & XZ Sagittal Plane (comp1), Component 2 3D X-Propagation & XY Sagittal Plane (comp2).
//    Select the Modify model configuration for study step checkbox.

    model.study("std3").feature("eig").set("useadvanceddisable", true);

//    In the tree, select Component 3 2D X-Propagation & XY Sagittal Plane (comp3) > Solid Mechanics 3 (solid3) > Piezoelectric Material Copy-Paste Data.
//    Click Disable.

    model.study("std3").feature("eig").set("disabledphysics", new String[]{"solid3/pzm2"});

//    In the Model Builder window, click Study 3.
//    In the Settings window for Study, type Study 3: 2D X-Propagation & XY Sagittal Plane, Rotated in the Label text field.

    model.study("std3").label("Study 3: 2D X-Propagation & XY Sagittal Plane, Rotated");

//    In the Study toolbar, click Compute.

    model.study("std3").createAutoSequences("all");

    model.sol("sol3").runAll();

    model.result().create("pg7", "PlotGroup2D");
    model.result("pg7").label("Electric Potential (es3)");
    model.result("pg7").set("data", "dset9");
    model.result("pg7").setIndex("looplevel", 1, 0);
    model.result("pg7").set("frametype", "spatial");
    model.result("pg7").set("showlegendsmaxmin", true);
    model.result("pg7").feature().create("surf1", "Surface");
    model.result("pg7").feature("surf1").set("solutionparams", "parent");
    model.result("pg7").feature("surf1").set("colortable", "Dipole");
    model.result("pg7").feature("surf1").set("evaluationsettings", "parent");
    model.result("pg7").feature("surf1").set("data", "parent");
    model.result("pg7").feature().create("str1", "Streamline");
    model.result("pg7").feature("str1").set("solutionparams", "parent");
    model.result("pg7").feature("str1").set("titletype", "none");
    model.result("pg7").feature("str1").set("posmethod", "uniform");
    model.result("pg7").feature("str1").set("udensity", 6.5);
    model.result("pg7").feature("str1").set("color", "custom");
    model.result("pg7").feature("str1")
         .set("customcolor", new double[]{0.3764705955982208, 0.3764705955982208, 0.3764705955982208});
    model.result("pg7").feature("str1").set("evaluationsettings", "parent");
    model.result("pg7").feature("str1").set("maxlen", 0.4);
    model.result("pg7").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg7").feature("str1").set("inheritcolor", false);
    model.result("pg7").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg7").feature("str1").set("data", "parent");
    model.result("pg7").feature("str1").selection().geom("geom3", 1);
    model.result("pg7").feature("str1").selection().set(1, 2, 3, 4, 5, 6, 7);
    model.result("pg7").feature("str1").set("inheritplot", "surf1");
    model.result("pg7").feature("str1").feature().create("filt1", "Filter");
    model.result("pg7").feature("str1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result().create("pg8", "PlotGroup2D");
    model.result("pg8").label("Electric Field (es3)");
    model.result("pg8").set("data", "dset9");
    model.result("pg8").setIndex("looplevel", 1, 0);
    model.result("pg8").set("frametype", "spatial");
    model.result("pg8").set("showlegendsmaxmin", true);
    model.result("pg8").feature().create("surf1", "Surface");
    model.result("pg8").feature("surf1").set("solutionparams", "parent");
    model.result("pg8").feature("surf1").set("expr", "es3.normE");
    model.result("pg8").feature("surf1").set("colortable", "Prism");
    model.result("pg8").feature("surf1").set("colortabletrans", "nonlinear");
    model.result("pg8").feature("surf1").set("colorcalibration", -0.8);
    model.result("pg8").feature("surf1").set("evaluationsettings", "parent");
    model.result("pg8").feature("surf1").set("data", "parent");
    model.result("pg8").feature().create("str1", "Streamline");
    model.result("pg8").feature("str1").set("solutionparams", "parent");
    model.result("pg8").feature("str1").set("titletype", "none");
    model.result("pg8").feature("str1").set("posmethod", "uniform");
    model.result("pg8").feature("str1").set("udensity", 6.5);
    model.result("pg8").feature("str1").set("color", "custom");
    model.result("pg8").feature("str1")
         .set("customcolor", new double[]{0.3764705955982208, 0.3764705955982208, 0.3764705955982208});
    model.result("pg8").feature("str1").set("evaluationsettings", "parent");
    model.result("pg8").feature("str1").set("maxlen", 0.4);
    model.result("pg8").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg8").feature("str1").set("inheritcolor", false);
    model.result("pg8").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg8").feature("str1").set("data", "parent");
    model.result("pg8").feature("str1").selection().geom("geom3", 1);
    model.result("pg8").feature("str1").selection().set(1, 2, 3, 4, 5, 6, 7);
    model.result("pg8").feature("str1").set("inheritplot", "surf1");
    model.result("pg8").feature("str1").feature().create("filt1", "Filter");
    model.result("pg8").feature("str1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result().create("pg9", "PlotGroup2D");
    model.result("pg9").set("data", "dset9");
    model.result("pg9").setIndex("looplevel", 1, 0);
    model.result("pg9").label("Mode Shape (solid3)");
    model.result("pg9").set("showlegends", false);
    model.result("pg9").create("surf1", "Surface");
    model.result("pg9").feature("surf1").set("expr", new String[]{"solid3.disp"});
    model.result("pg9").feature("surf1").set("threshold", "manual");
    model.result("pg9").feature("surf1").set("thresholdvalue", 0.2);
    model.result("pg9").feature("surf1").set("colortable", "Rainbow");
    model.result("pg9").feature("surf1").set("colortabletrans", "none");
    model.result("pg9").feature("surf1").set("colorscalemode", "linear");
    model.result("pg9").feature("surf1").set("colortable", "AuroraBorealis");
    model.result("pg9").feature("surf1").create("def", "Deform");
    model.result("pg9").feature("surf1").feature("def").set("expr", new String[]{"u2", "v2"});
    model.result("pg9").feature("surf1").feature("def").set("descr", "Displacement field");
    model.result().evaluationGroup().create("std3EvgFrq", "EvaluationGroup");
    model.result().evaluationGroup("std3EvgFrq").set("data", "dset9");
    model.result().evaluationGroup("std3EvgFrq")
         .label("Eigenfrequencies (Study 3: 2D X-Propagation & XY Sagittal Plane, Rotated)");
    model.result().evaluationGroup("std3EvgFrq").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("std3EvgFrq").feature("gev1").setIndex("expr", "2*pi*freq", 0);
    model.result().evaluationGroup("std3EvgFrq").feature("gev1").setIndex("unit", "rad/s", 0);
    model.result().evaluationGroup("std3EvgFrq").feature("gev1").setIndex("descr", "Angular frequency", 0);
    model.result().evaluationGroup("std3EvgFrq").feature("gev1").setIndex("expr", "imag(freq)/abs(freq)", 1);
    model.result().evaluationGroup("std3EvgFrq").feature("gev1").setIndex("unit", "1", 1);
    model.result().evaluationGroup("std3EvgFrq").feature("gev1").setIndex("descr", "Damping ratio", 1);
    model.result().evaluationGroup("std3EvgFrq").feature("gev1").setIndex("expr", "abs(freq)/imag(freq)/2", 2);
    model.result().evaluationGroup("std3EvgFrq").feature("gev1").setIndex("unit", "1", 2);
    model.result().evaluationGroup("std3EvgFrq").feature("gev1").setIndex("descr", "Quality factor", 2);
    model.result().evaluationGroup("std3EvgFrq").run();
    model.result().evaluationGroup().create("std3mpf3", "EvaluationGroup");
    model.result().evaluationGroup("std3mpf3").set("data", "dset9");
    model.result().evaluationGroup("std3mpf3")
         .label("Participation Factors (Study 3: 2D X-Propagation & XY Sagittal Plane, Rotated)");
    model.result().evaluationGroup("std3mpf3").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.pfLnormX", 0);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "1", 0);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, X-translation", 0);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.pfLnormY", 1);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "1", 1);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Y-translation", 1);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.pfLnormZ", 2);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "1", 2);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Z-translation", 2);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.pfRnormX", 3);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "1", 3);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, X-rotation", 3);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.pfRnormY", 4);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "1", 4);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Y-rotation", 4);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.pfRnormZ", 5);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "1", 5);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Z-rotation", 5);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.mEffLX", 6);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "kg", 6);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, X-translation", 6);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.mEffLY", 7);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "kg", 7);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, Y-translation", 7);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.mEffLZ", 8);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "kg", 8);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, Z-translation", 8);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.mEffRX", 9);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "kg*m^2", 9);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, X-rotation", 9);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.mEffRY", 10);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "kg*m^2", 10);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, Y-rotation", 10);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("expr", "mpf3.mEffRZ", 11);
    model.result().evaluationGroup("std3mpf3").feature("gev1").setIndex("unit", "kg*m^2", 11);
    model.result().evaluationGroup("std3mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, Z-rotation", 11);
    model.result().evaluationGroup("std3mpf3").run();
    model.result("pg7").run();

//    Add an <l>Eigenfrequency</l> study for the 2D unit cell with <eqv>XY</eqv> sagittal plane as in the preceding study without disabling Piezoelectric Material Copy-Paste Data.
//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select Preset Studies for Selected Multiphysics > Eigenfrequency.
//    Click Add Study in the window toolbar.

    model.study().create("std4");
    model.study("std4").create("eig", "Eigenfrequency");
    model.study("std4").feature("eig").set("chkeigregion", true);
    model.study("std4").feature("eig").set("storefact", false);
    model.study("std4").feature("eig").set("linpsolnum", "auto");
    model.study("std4").feature("eig").set("plotgrouparr", new String[]{"Default"});
    model.study("std4").feature("eig").set("solnum", "auto");
    model.study("std4").feature("eig").set("notsolnum", "auto");
    model.study("std4").feature("eig").set("outputmap", new String[]{});
    model.study("std4").feature("eig").set("ngenAUX", "1");
    model.study("std4").feature("eig").set("goalngenAUX", "1");
    model.study("std4").feature("eig").set("ngenAUX", "1");
    model.study("std4").feature("eig").set("goalngenAUX", "1");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Eigenfrequency, locate the Study Settings section.
//    Select the Desired number of eigenfrequencies checkbox.

    model.study("std4").feature("eig").set("neigsactive", true);

//    In the associated text field, type 2.

    model.study("std4").feature("eig").set("neigs", 2);

//    From the Unit list, select MHz.

    model.study("std4").feature("eig").set("eigunit", "MHz");

//    In the Search for eigenfrequencies around shift text field, type f_apr.

    model.study("std4").feature("eig").set("shift", "f_apr");
    model.study("std4").feature("eig").setSolveFor("/modelNode/comp1", false);

//    Locate the Physics and Variables Selection section.

    model.study("std4").feature("eig").setSolveFor("/modelNode/comp2", false);

//    In the Model Builder window, click Study 4.
//    In the Settings window for Study, type Study 4: 2D X-Propagation & XY Sagittal Plane, Copy-Paste Data in the Label text field.

    model.study("std4").label("Study 4: 2D X-Propagation & XY Sagittal Plane, Copy-Paste Data");

//    In the Study toolbar, click Compute.

    model.study("std4").createAutoSequences("all");

    model.sol("sol4").runAll();

    model.result().create("pg10", "PlotGroup2D");
    model.result("pg10").label("Electric Potential (es3) 1");
    model.result("pg10").set("data", "dset12");
    model.result("pg10").setIndex("looplevel", 1, 0);
    model.result("pg10").set("frametype", "spatial");
    model.result("pg10").set("showlegendsmaxmin", true);
    model.result("pg10").feature().create("surf1", "Surface");
    model.result("pg10").feature("surf1").set("solutionparams", "parent");
    model.result("pg10").feature("surf1").set("colortable", "Dipole");
    model.result("pg10").feature("surf1").set("evaluationsettings", "parent");
    model.result("pg10").feature("surf1").set("data", "parent");
    model.result("pg10").feature().create("str1", "Streamline");
    model.result("pg10").feature("str1").set("solutionparams", "parent");
    model.result("pg10").feature("str1").set("titletype", "none");
    model.result("pg10").feature("str1").set("posmethod", "uniform");
    model.result("pg10").feature("str1").set("udensity", 6.5);
    model.result("pg10").feature("str1").set("color", "custom");
    model.result("pg10").feature("str1")
         .set("customcolor", new double[]{0.3764705955982208, 0.3764705955982208, 0.3764705955982208});
    model.result("pg10").feature("str1").set("evaluationsettings", "parent");
    model.result("pg10").feature("str1").set("maxlen", 0.4);
    model.result("pg10").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg10").feature("str1").set("inheritcolor", false);
    model.result("pg10").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg10").feature("str1").set("data", "parent");
    model.result("pg10").feature("str1").selection().geom("geom3", 1);
    model.result("pg10").feature("str1").selection().set(1, 2, 3, 4, 5, 6, 7);
    model.result("pg10").feature("str1").set("inheritplot", "surf1");
    model.result("pg10").feature("str1").feature().create("filt1", "Filter");
    model.result("pg10").feature("str1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result().create("pg11", "PlotGroup2D");
    model.result("pg11").label("Electric Field (es3) 1");
    model.result("pg11").set("data", "dset12");
    model.result("pg11").setIndex("looplevel", 1, 0);
    model.result("pg11").set("frametype", "spatial");
    model.result("pg11").set("showlegendsmaxmin", true);
    model.result("pg11").feature().create("surf1", "Surface");
    model.result("pg11").feature("surf1").set("solutionparams", "parent");
    model.result("pg11").feature("surf1").set("expr", "es3.normE");
    model.result("pg11").feature("surf1").set("colortable", "Prism");
    model.result("pg11").feature("surf1").set("colortabletrans", "nonlinear");
    model.result("pg11").feature("surf1").set("colorcalibration", -0.8);
    model.result("pg11").feature("surf1").set("evaluationsettings", "parent");
    model.result("pg11").feature("surf1").set("data", "parent");
    model.result("pg11").feature().create("str1", "Streamline");
    model.result("pg11").feature("str1").set("solutionparams", "parent");
    model.result("pg11").feature("str1").set("titletype", "none");
    model.result("pg11").feature("str1").set("posmethod", "uniform");
    model.result("pg11").feature("str1").set("udensity", 6.5);
    model.result("pg11").feature("str1").set("color", "custom");
    model.result("pg11").feature("str1")
         .set("customcolor", new double[]{0.3764705955982208, 0.3764705955982208, 0.3764705955982208});
    model.result("pg11").feature("str1").set("evaluationsettings", "parent");
    model.result("pg11").feature("str1").set("maxlen", 0.4);
    model.result("pg11").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg11").feature("str1").set("inheritcolor", false);
    model.result("pg11").feature("str1").set("maxtime", Double.POSITIVE_INFINITY);
    model.result("pg11").feature("str1").set("data", "parent");
    model.result("pg11").feature("str1").selection().geom("geom3", 1);
    model.result("pg11").feature("str1").selection().set(1, 2, 3, 4, 5, 6, 7);
    model.result("pg11").feature("str1").set("inheritplot", "surf1");
    model.result("pg11").feature("str1").feature().create("filt1", "Filter");
    model.result("pg11").feature("str1").feature("filt1").set("expr", "!isScalingSystemDomain");
    model.result().create("pg12", "PlotGroup2D");
    model.result("pg12").set("data", "dset12");
    model.result("pg12").setIndex("looplevel", 1, 0);
    model.result("pg12").label("Mode Shape (solid3) 1");
    model.result("pg12").set("showlegends", false);
    model.result("pg12").create("surf1", "Surface");
    model.result("pg12").feature("surf1").set("expr", new String[]{"solid3.disp"});
    model.result("pg12").feature("surf1").set("threshold", "manual");
    model.result("pg12").feature("surf1").set("thresholdvalue", 0.2);
    model.result("pg12").feature("surf1").set("colortable", "Rainbow");
    model.result("pg12").feature("surf1").set("colortabletrans", "none");
    model.result("pg12").feature("surf1").set("colorscalemode", "linear");
    model.result("pg12").feature("surf1").set("colortable", "AuroraBorealis");
    model.result("pg12").feature("surf1").create("def", "Deform");
    model.result("pg12").feature("surf1").feature("def").set("expr", new String[]{"u2", "v2"});
    model.result("pg12").feature("surf1").feature("def").set("descr", "Displacement field");
    model.result().evaluationGroup().create("std4EvgFrq", "EvaluationGroup");
    model.result().evaluationGroup("std4EvgFrq").set("data", "dset12");
    model.result().evaluationGroup("std4EvgFrq")
         .label("Eigenfrequencies (Study 4: 2D X-Propagation & XY Sagittal Plane, Copy-Paste Data)");
    model.result().evaluationGroup("std4EvgFrq").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("expr", "2*pi*freq", 0);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("unit", "rad/s", 0);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("descr", "Angular frequency", 0);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("expr", "imag(freq)/abs(freq)", 1);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("unit", "1", 1);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("descr", "Damping ratio", 1);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("expr", "abs(freq)/imag(freq)/2", 2);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("unit", "1", 2);
    model.result().evaluationGroup("std4EvgFrq").feature("gev1").setIndex("descr", "Quality factor", 2);
    model.result().evaluationGroup("std4EvgFrq").run();
    model.result().evaluationGroup().create("std4mpf3", "EvaluationGroup");
    model.result().evaluationGroup("std4mpf3").set("data", "dset12");
    model.result().evaluationGroup("std4mpf3")
         .label("Participation Factors (Study 4: 2D X-Propagation & XY Sagittal Plane, Copy-Paste Data)");
    model.result().evaluationGroup("std4mpf3").create("gev1", "EvalGlobal");
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.pfLnormX", 0);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "1", 0);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, X-translation", 0);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.pfLnormY", 1);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "1", 1);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Y-translation", 1);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.pfLnormZ", 2);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "1", 2);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Z-translation", 2);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.pfRnormX", 3);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "1", 3);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, X-rotation", 3);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.pfRnormY", 4);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "1", 4);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Y-rotation", 4);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.pfRnormZ", 5);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "1", 5);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Participation factor, normalized, Z-rotation", 5);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.mEffLX", 6);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "kg", 6);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, X-translation", 6);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.mEffLY", 7);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "kg", 7);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, Y-translation", 7);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.mEffLZ", 8);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "kg", 8);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, Z-translation", 8);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.mEffRX", 9);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "kg*m^2", 9);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, X-rotation", 9);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.mEffRY", 10);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "kg*m^2", 10);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, Y-rotation", 10);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("expr", "mpf3.mEffRZ", 11);
    model.result().evaluationGroup("std4mpf3").feature("gev1").setIndex("unit", "kg*m^2", 11);
    model.result().evaluationGroup("std4mpf3").feature("gev1")
         .setIndex("descr", "Effective modal mass, Z-rotation", 11);
    model.result().evaluationGroup("std4mpf3").run();
    model.result("pg10").run();

    model.title("Euler Angle Rotation in Surface Acoustic Wave Modeling");

    model
         .description("The surface acoustic waves industry uses different crystal cuts of piezoelectric materials, for example 128\u00b0\u00a0YX LiNbO3, AT&ST quartz, and 42\u00b0\u00a0YX LiTaO3. Direct data is not available for all cuts, so the standard modeling approach is to use the Euler angle rotation realized by the Rotated System functionality. This tutorial demonstrates conversion from the default lithium niobate material to 128\u00a0YX cut using 2D and 3D piezoelectric unit cells.");

    return model;
  }

  public static void main(String[] args) {
    Model model = run();
    model = run2(model);
    run3(model);
  }

}
