/*
 * modular_mixer.java
 */

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

/** Model exported on May 12 2026, 08:35 by COMSOL 6.4.0.418. */
public class modular_mixer {

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

//    Begin by loading the geometry file.
//    From the File menu, choose Application Libraries.
//    In the Application Libraries window, select Mixer Module > Tutorials > modular_mixer_geom in the tree.
//    Click Open.

    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.param().set("H", "0.0805[m]");
    model.param().descr("H", "Vessel height");
    model.param().set("T", "H");
    model.param().descr("T", "Vessel diameter");
    model.param().set("C", "1/3*H");
    model.param().descr("C", "Clearance");
    model.param().set("B", "4");
    model.param().descr("B", "Number of baffles");
    model.param().set("bw", "T/10");
    model.param().descr("bw", "Baffle width");
    model.param().set("Da", "1/3*T");
    model.param().descr("Da", "Impeller diameter");
    model.param().set("shaft_diameter", "1/10*Da");
    model.param().descr("shaft_diameter", "Shaft diameter");
    model.param().set("blade_length", "Da/4");
    model.param().descr("blade_length", "Blade length for Rushton turbine");
    model.param().set("blade_width", "Da/5");
    model.param().descr("blade_width", "Width of impeller blade");

    model.geom()
         .load(new String[]{"part1"}, "Mixer_Module\\Impellers,_Surface_Blades\\Impellers,_Radial\\rushton_impeller.mph", new String[]{"part1"});
    model.component("comp1").geom("geom1").create("pi1", "PartInstance");
    model.component("comp1").geom("geom1").feature("pi1").set("selkeepnoncontr", false);
    model.component("comp1").geom("geom1").feature("pi1").set("part", "part1");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "d_hu", "shaft_diameter+Da/20");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "l_ib", "blade_length");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "w_ib", "blade_width");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "d_id", "Da-2*(blade_length*3/4)");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "d_im", "Da");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "hp_im", "-blade_width/2");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("inputexpr", "d_is", "shaft_diameter");
    model.component("comp1").geom("geom1").selection().create("csel1", "CumulativeSelection");
    model.component("comp1").geom("geom1").selection("csel1").label("Impeller Domains");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepobj", "pi1_csel4", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetoobj", "pi1_csel4", "csel1");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepobj", "pi1_csel6", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetoobj", "pi1_csel6", "none");
    model.component("comp1").geom("geom1").selection().create("csel2", "CumulativeSelection");
    model.component("comp1").geom("geom1").selection("csel2").label("Rotating Interior Wall");
    model.component("comp1").geom("geom1").selection().create("csel3", "CumulativeSelection");
    model.component("comp1").geom("geom1").selection("csel3").label("Rotating Wall");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_csel1.bnd", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_csel1.bnd", "csel2");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_csel2.bnd", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_csel2.bnd", "csel2");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_csel3.bnd", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_csel3.bnd", "csel3");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_csel10.bnd", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_csel10.bnd", "none");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_csel7.bnd", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_csel7.bnd", "none");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_csel8.bnd", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_csel8.bnd", "none");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepbnd", "pi1_csel9.bnd", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetobnd", "pi1_csel9.bnd", "none");
    model.component("comp1").geom("geom1").selection().create("csel4", "CumulativeSelection");
    model.component("comp1").geom("geom1").selection("csel4").label("Remove Edges");
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selkeepedg", "pi1_cylsel1", false);
    model.component("comp1").geom("geom1").feature("pi1").setEntry("selcontributetoedg", "pi1_cylsel1", "csel4");
    model.component("comp1").geom("geom1").feature("pi1").set("selkeepnoncontr", true);
    model.geom().load(new String[]{"part2"}, "Mixer_Module\\Shafts\\impeller_shaft.mph", new String[]{"part1"});
    model.component("comp1").geom("geom1").run("pi1");
    model.component("comp1").geom("geom1").create("pi2", "PartInstance");
    model.component("comp1").geom("geom1").feature("pi2").set("selkeepnoncontr", false);
    model.component("comp1").geom("geom1").feature("pi2").set("part", "part2");
    model.component("comp1").geom("geom1").feature("pi2").setEntry("inputexpr", "hp_im", "-blade_width/2");
    model.component("comp1").geom("geom1").feature("pi2").setEntry("inputexpr", "d_is", "shaft_diameter");
    model.component("comp1").geom("geom1").feature("pi2").setEntry("inputexpr", "l_is", "H-C+blade_width");
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selkeepobj", "pi2_csel1", false);
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selcontributetoobj", "pi2_csel1", "csel1");
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selkeepbnd", "pi2_cylsel1", false);
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selcontributetobnd", "pi2_cylsel1", "none");
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selkeepbnd", "pi2_csel1.bnd", false);
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selcontributetobnd", "pi2_csel1.bnd", "csel3");
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selkeepedg", "pi2_sel1", false);
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selcontributetoedg", "pi2_sel1", "csel4");
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selkeepedg", "pi2_csel1.edg", false);
    model.component("comp1").geom("geom1").feature("pi2").setEntry("selcontributetoedg", "pi2_csel1.edg", "none");
    model.component("comp1").geom("geom1").feature("pi2").set("selkeepnoncontr", true);
    model.component("comp1").geom("geom1").run("pi2");
    model.component("comp1").geom("geom1").create("uni1", "Union");
    model.component("comp1").geom("geom1").feature("uni1").selection("input").set("pi1", "pi2");
    model.component("comp1").geom("geom1").feature("uni1").set("repairtoltype", "relative");
    model.geom().load(new String[]{"part3"}, "Mixer_Module\\Tanks\\flat_bottom_tank.mph", new String[]{"part1"});
    model.component("comp1").geom("geom1").run("uni1");
    model.component("comp1").geom("geom1").create("pi3", "PartInstance");
    model.component("comp1").geom("geom1").feature("pi3").set("selkeepnoncontr", false);
    model.component("comp1").geom("geom1").feature("pi3").set("part", "part3");
    model.component("comp1").geom("geom1").feature("pi3").set("rot", 90);
    model.component("comp1").geom("geom1").feature("pi3").setEntry("inputexpr", "n_ba", "B");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("inputexpr", "w_ba", "bw");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("inputexpr", "d_im", "Da");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("inputexpr", "d_ta", "T");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("inputexpr", "h_ta", "H");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("inputexpr", "hp_ta", "-C");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("inputexpr", "rf_ta", 0);
    model.component("comp1").geom("geom1").feature("pi3").setEntry("inputexpr", "t_ta", 0);
    model.component("comp1").geom("geom1").feature("pi3").setEntry("inputexpr", "t_ba", 0);
    model.component("comp1").geom("geom1").selection().create("csel5", "CumulativeSelection");
    model.component("comp1").geom("geom1").selection("csel5").label("Symmetry");
    model.component("comp1").geom("geom1").selection().create("csel6", "CumulativeSelection");
    model.component("comp1").geom("geom1").selection("csel6").label("Tank Walls");
    model.component("comp1").geom("geom1").selection().create("csel7", "CumulativeSelection");
    model.component("comp1").geom("geom1").selection("csel7").label("Interior Walls");
    model.component("comp1").geom("geom1").selection().create("csel8", "CumulativeSelection");
    model.component("comp1").geom("geom1").selection("csel8").label("View Suppression");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("selcontributetobnd", "pi3_ext1.bnd", "csel7");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("selcontributetobnd", "pi3_boxsel1", "csel5");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("selcontributetobnd", "pi3_cylsel2", "csel6");
    model.component("comp1").geom("geom1").feature("pi3").setEntry("selcontributetobnd", "pi3_unisel1", "csel8");
    model.component("comp1").geom("geom1").feature("pi3").set("selkeepnoncontr", true);
    model.component("comp1").geom("geom1").run("pi3");
    model.component("comp1").geom("geom1").create("dif1", "Difference");
    model.component("comp1").geom("geom1").feature("dif1").label("Fluid Domain");
    model.component("comp1").geom("geom1").feature("dif1").selection("input").named("pi3_uni1");
    model.component("comp1").geom("geom1").feature("dif1").selection("input2").named("csel1");
    model.component("comp1").geom("geom1").feature("dif1").set("repairtoltype", "relative");
    model.component("comp1").geom("geom1").feature("dif1").set("selresult", true);
    model.component("comp1").geom("geom1").feature("dif1").set("selresultshow", "all");
    model.component("comp1").geom("geom1").run("dif1");
    model.component("comp1").geom("geom1").create("sel1", "ExplicitSelection");
    model.component("comp1").geom("geom1").feature("sel1").label("Flat Pressure Point");
    model.component("comp1").geom("geom1").feature("sel1").selection("selection").init(0);
    model.component("comp1").geom("geom1").feature("sel1").selection("selection").set("dif1", 34);
    model.component("comp1").geom("geom1").selection().create("csel9", "CumulativeSelection");
    model.component("comp1").geom("geom1").selection("csel9").label("Pressure Point Constraint");
    model.component("comp1").geom("geom1").feature("sel1").set("contributeto", "csel9");
    model.component("comp1").geom("geom1").run("sel1");
    model.component("comp1").geom("geom1").create("sel2", "ExplicitSelection");
    model.component("comp1").geom("geom1").feature("sel2").label("Edges to Remove");
    model.component("comp1").geom("geom1").feature("sel2").selection("selection").init(1);
    model.component("comp1").geom("geom1").feature("sel2").selection("selection").set("dif1", 9, 61, 78, 79);

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

    model.component("comp1").geom("geom1").feature("sel2").set("contributeto", "csel4");
    model.component("comp1").geom("geom1").run("fin");
    model.component("comp1").geom("geom1").create("ige1", "IgnoreEdges");
    model.component("comp1").geom("geom1").feature("ige1").selection("input").named("csel4");
    model.component("comp1").geom("geom1").feature("ige1").set("ignorevtx", false);
    model.component("comp1").geom("geom1").run("ige1");
    model.component("comp1").geom("geom1").create("unisel1", "UnionSelection");
    model.component("comp1").geom("geom1").feature("unisel1").label("Union Selection: All Walls");
    model.component("comp1").geom("geom1").feature("unisel1").set("entitydim", 2);
    model.component("comp1").geom("geom1").feature("unisel1")
         .set("input", new String[]{"csel2", "csel3", "csel6", "csel7"});

    model.component("comp1").view("view1").set("transparency", false);

    model.title("Laminar Modular Mixer \u2014 Template File");

    model
         .description("This example is a template MPH-file used by the laminar case of the Modular Mixer models. The geometry is a combination of a Rushton impeller and a flat bottom tank. The geometry subsequences to build the impeller and vessel are imported from the Part Libraries.");

    model.label("modular_mixer_geom.mph");

//    In the Home toolbar, click Add Physics to open the Add Physics window.
//    In the tree, select Fluid Flow > Single-Phase Flow > Rotating Machinery, Fluid Flow > Laminar Flow.
//    Click Add to Component 1 in the window toolbar.

    model.component("comp1").physics().create("spf", "LaminarFlow", "geom1");

    model.component("comp1").common().create("rot1", "RotatingDomain");
    model.component("comp1").common("rot1").set("rotationType", "rotationalVelocity");
    model.component("comp1").common("rot1").set("rotationalVelocityExpression", "generalRevolutionsPerTime");
    model.component("comp1").common("rot1").selection().all();

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

//    In the Home toolbar, click Add Physics to close the Add Physics window.
//    Add the values for Silicone oil Si1000.
//    In the Model Builder window, right-click Component 1 (comp1) > Materials and choose Blank Material.

    model.component("comp1").material().create("mat1", "Common");

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

    model.component("comp1").material("mat1").propertyGroup("def").set("density", new String[]{"972"});
    model.component("comp1").material("mat1").propertyGroup("def").set("dynamicviscosity", new String[]{"1"});

//    In the Label text field, type Silicone oil Si1000.

    model.component("comp1").material("mat1").label("Silicone oil Si1000");

//    Set up the rotating domain conditions in Definitions.
//    In the Model Builder window, under Component 1 (comp1) > Moving Mesh, click Rotating Domain 1.
//    In the Settings window for Rotating Domain, locate the Domain Selection section.
//    From the Selection list, select Rotating_Domain (Revolve 1) (Flat Bottom Tank 1).

    model.component("comp1").common("rot1").selection().named("geom1_pi3_rev1_wp1_r2_dom");

//    Locate the Rotation section.
//    In the \[f\] text field, type 40.

    model.component("comp1").common("rot1").set("revolutionsPerTime", 40);

//    Use the predefined selections to set up the physics features.
//    In the Physics toolbar, click Boundaries and choose Interior Wall.

    model.component("comp1").physics("spf").create("iwbc1", "InteriorWallBC", 2);

//    In the Settings window for Interior Wall, locate the Boundary Selection section.
//    From the Selection list, select Interior Walls.

    model.component("comp1").physics("spf").feature("iwbc1").selection().named("geom1_csel7_bnd");

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

    model.component("comp1").physics("spf").create("iwbc2", "InteriorWallBC", 2);

//    In the Settings window for Interior Wall, locate the Boundary Selection section.
//    From the Selection list, select Rotating Interior Wall.

    model.component("comp1").physics("spf").feature("iwbc2").selection().named("geom1_csel2_bnd");

//    As an alternative, the union selection for <l>Interior Wall 1</l> and <l>Interior Wall 2</l> can be done.
//    In the Physics toolbar, click Boundaries and choose Symmetry.

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

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

    model.component("comp1").physics("spf").feature("sym1").selection().named("geom1_csel5_bnd");

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

    model.component("comp1").physics("spf").create("prpc1", "PressurePointConstraint", 0);

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

    model.component("comp1").physics("spf").feature("prpc1").selection().named("geom1_csel9_pnt");

//    Define the postprocessing variables for the torque and power draw.
//    In the Definitions toolbar, click Local Variables.

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

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

    model.component("comp1").variable("var1")
         .set("tau_riw", "x*(spf.T_trac_uy+spf.T_trac_dy)-y*(spf.T_trac_ux+spf.T_trac_dx)");
    model.component("comp1").variable("var1").descr("tau_riw", "Torque per area (interior walls)");
    model.component("comp1").variable("var1").set("tau_rw", "x*(spf.T_tracy)-y*(spf.T_tracx)");
    model.component("comp1").variable("var1").descr("tau_rw", "Torque per area (rotating walls)");
    model.component("comp1").variable("var1").set("P_riw", "tau_riw*rot1.alphat");
    model.component("comp1").variable("var1").descr("P_riw", "Power draw per area (rotating interior walls)");
    model.component("comp1").variable("var1").set("P_rw", "tau_rw*rot1.alphat");
    model.component("comp1").variable("var1").descr("P_rw", "Power draw per area (rotating walls)");

//    Define a nonlocal integration coupling on <l>Rotating Interior Wall</l> to evaluate its contributions to the torque and power draw.
//    In the Definitions toolbar, click Nonlocal Couplings and choose Integration.

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

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

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

//    From the Selection list, select Rotating Interior Wall.

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

//    Define a nonlocal integration coupling on <l>Rotating Wall</l> to evaluate its contributions to the torque and power draw.
//    In the Definitions toolbar, click Nonlocal Couplings and choose Integration.

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

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

    model.component("comp1").cpl("intop2").selection().geom("geom1", 2);

//    From the Selection list, select Rotating Wall.

    model.component("comp1").cpl("intop2").selection().named("geom1_csel3_bnd");

//    In the Model Builder window, under Component 1 (comp1), click Mesh 1.
//    In the Settings window for Mesh, locate the Physics-Controlled Mesh section.
//    In the table, enter the following settings:

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

//    Click Build All.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    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 Physics Interfaces > Frozen Rotor.
//    Click Add Study in the window toolbar.

    model.study().create("std1");
    model.study("std1").create("frrot", "FrozenRotor");
    model.study("std1").feature("frrot").set("solnum", "auto");
    model.study("std1").feature("frrot").set("notsolnum", "auto");
    model.study("std1").feature("frrot").set("outputmap", new String[]{});
    model.study("std1").feature("frrot").set("ngenAUX", "1");
    model.study("std1").feature("frrot").set("goalngenAUX", "1");
    model.study("std1").feature("frrot").set("ngenAUX", "1");
    model.study("std1").feature("frrot").set("goalngenAUX", "1");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, locate the Study Settings section.
//    Clear the Generate default plots checkbox.

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

//    , because the plot can be added later using the <l>Result Templates</l>.
//    In the Study toolbar, click Compute.

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

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

//    In the Home toolbar, click Windows and choose Result Templates.
//    In the tree, select Study 1/Solution 1 (sol1) > Laminar Flow > Velocity (spf).
//    Click Add Result Template in the window toolbar.

    model.result().create("pg1", "PlotGroup3D");
    model.result("pg1").label("Velocity (spf)");
    model.result("pg1").set("frametype", "spatial");
    model.result("pg1").set("smooth", "internal");
    model.result("pg1").feature().create("mslc1", "Multislice");
    model.result("pg1").feature("mslc1").set("smooth", "internal");
    model.result("pg1").feature("mslc1").set("data", "parent");
    model.result("pg1").label("Velocity (spf)");
    model.result("pg1").run();

//    In the Results toolbar, click Result Templates to close the Result Templates window.
//    In the Results toolbar, click Cut Plane.

    model.result().dataset().create("cpl1", "CutPlane");
    model.result("pg1").run();
    model.result("pg1").run();

//    In the Model Builder window, expand the Velocity (spf) node, then click Multislice 1.
//    In the Settings window for Multislice, locate the Multiplane Data section.
//    Find the x-planes subsection.
//    In the Planes text field, type 0.

    model.result("pg1").feature("mslc1").set("xnumber", "0");

//    Find the z-planes subsection.
//    In the Planes text field, type 0.

    model.result("pg1").feature("mslc1").set("znumber", "0");

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

    model.result("pg1").feature("mslc1").set("colortable", "Prism");
    model.result("pg1").run();

//    In the Model Builder window, right-click Velocity (spf) and choose Arrow Surface.

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

//    In the Settings window for Arrow Surface, locate the Data section.
//    From the Dataset list, select Cut Plane 1.

    model.result("pg1").feature("arws1").set("data", "cpl1");

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

    model.result("pg1").feature("arws1").set("expr", new String[]{"0", "v", "w"});

//    Locate the Arrow Positioning section.
//    In the Number of arrows text field, type 1000.

    model.result("pg1").feature("arws1").set("arrowcount", 1000);

//    Locate the Coloring and Style section.
//    From the Arrow length list, select Logarithmic.

    model.result("pg1").feature("arws1").set("arrowlength", "logarithmic");

//    Select the Scale factor checkbox.

    model.result("pg1").feature("arws1").set("scaleactive", true);

//    In the associated text field, type 0.005.

    model.result("pg1").feature("arws1").set("scale", 0.005);

//    From the Color list, select White.

    model.result("pg1").feature("arws1").set("color", "white");
    model.result("pg1").run();

//    Right-click Velocity (spf) and choose Surface.

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

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

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

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

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

//    From the Color list, select Gray.

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

//    Right-click Surface 1 and choose Selection.

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

//    In the Settings window for Selection, locate the Selection section.
//    From the Selection list, select Union Selection: All Walls.

    model.result("pg1").feature("surf1").feature("sel1").selection().named("geom1_unisel1");
    model.result("pg1").run();

//    In the Model Builder window, under Results, click Velocity (spf).
//    In the Settings window for 3D Plot Group, type Velocity: Magnitude and Vectors in the Label text field.

    model.result("pg1").label("Velocity: Magnitude and Vectors");

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

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

//    In the Title text area, type Velocity: magnitude and in-plane vectors.

    model.result("pg1").set("title", "Velocity: magnitude and in-plane vectors");

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

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

//    Before finalizing the plot, generate a dedicated view with a <l>Hide for Physics</l> subfeature that allows an unobstructed view of the impeller inside the vessel.
//    In the Model Builder window, right-click Component 1 (comp1) > Definitions and choose View.

    model.component("comp1").view().create("view5", "geom1");

//    In the Model Builder window, right-click View 5 and choose Hide for Physics.

    model.component("comp1").view("view5").hideEntities().create("hide1");

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

    model.component("comp1").view("view5").hideEntities("hide1").geom("geom1", 2);

//    From the Selection list, select View Suppression.

    model.component("comp1").view("view5").hideEntities("hide1").named("geom1_csel8_bnd");

//    In the Model Builder window, click View 5.
//    In the Settings window for View, locate the View section.
//    Select the Lock camera checkbox.

    model.component("comp1").view("view5").set("locked", true);

//     having rotated the geometry to give a good view of the impeller.

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

//    In the Model Builder window, under Results, click Velocity: Magnitude and Vectors.
//    In the Settings window for 3D Plot Group, locate the Plot Settings section.
//    From the View list, select View 5.

    model.result("pg1").set("view", "view5");

//    In the Velocity: Magnitude and Vectors toolbar, click Plot.

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

//    Define the surface used to calculate the flow number.
//    In the Results toolbar, click More Datasets and choose Parametric Surface.

    model.result().dataset().create("ps1", "ParSurface");

//    In the Settings window for Parametric Surface, locate the Parameters section.
//    Find the First parameter subsection.
//    In the Maximum text field, type 2*pi.

    model.result().dataset("ps1").set("parmax1", "2*pi");

//    Find the Second parameter subsection.
//    In the Minimum text field, type -Da/10.

    model.result().dataset("ps1").set("parmin2", "-Da/10");

//    In the Maximum text field, type Da/10.

    model.result().dataset("ps1").set("parmax2", "Da/10");

//    Locate the Expressions section.
//    In the x text field, type 0.186*T*cos(s1).

    model.result().dataset("ps1").set("exprx", "0.186*T*cos(s1)");

//    In the y text field, type 0.186*T*sin(s1).

    model.result().dataset("ps1").set("expry", "0.186*T*sin(s1)");

//    In the z text field, type s2.

    model.result().dataset("ps1").set("exprz", "s2");

//    Click Plot.
//    The surface for the calculation of the flow number is now visualized in the <l>Graphics</l> window.
//    Evaluate the torque on the impeller and the power draw using the postprocessing variables you defined.
//    In the Results toolbar, click Global Evaluation.

    model.result().numerical().create("gev1", "EvalGlobal");

//    In the Settings window for Global Evaluation, type Torque in the Label text field.

    model.result().numerical("gev1").label("Torque");

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

    model.result().numerical("gev1").setIndex("expr", "abs(intop1(tau_riw)+intop2(tau_rw))", 0);

//    Click Evaluate.

    model.result().table().create("tbl1", "Table");
    model.result().table("tbl1").comments("Torque");
    model.result().numerical("gev1").set("table", "tbl1");
    model.result().numerical("gev1").setResult();

//    In the Results toolbar, click Global Evaluation.

    model.result().numerical().create("gev2", "EvalGlobal");

//    In the Settings window for Global Evaluation, type Power Draw in the Label text field.

    model.result().numerical("gev2").label("Power Draw");

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

    model.result().numerical("gev2").setIndex("expr", "abs(intop1(P_riw)+intop2(P_rw))", 0);

//    Click Evaluate.

    model.result().table().create("tbl2", "Table");
    model.result().table("tbl2").comments("Power Draw");
    model.result().numerical("gev2").set("table", "tbl2");
    model.result().numerical("gev2").setResult();

//    Evaluate the flow number.
//    In the Results toolbar, click More Derived Values and choose Integration > Surface Integration.

    model.result().numerical().create("int1", "IntSurface");
    model.result().numerical("int1").set("intvolume", true);

//    In the Settings window for Surface Integration, type Flow Number in the Label text field.

    model.result().numerical("int1").label("Flow Number");

//    Locate the Data section.
//    From the Dataset list, select Parametric Surface 1.

    model.result().numerical("int1").set("data", "ps1");

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

    model.result().numerical("int1").setIndex("expr", "(u*cos(s1)+v*sin(s1))/40[1/s]/Da^3", 0);

//    Click Evaluate.

    model.result().table().create("tbl3", "Table");
    model.result().table("tbl3").comments("Flow Number");
    model.result().numerical("int1").set("table", "tbl3");
    model.result().numerical("int1").setResult();
    model.result("pg1").run();

    model.title("Modular Mixer");

    model
         .description("This example is built from a supplied geometry model file which contains geometry parts to build baffled flat and dished bottom mixers with either a pitched blade impeller or a Rushton turbine. The model features a simulation of laminar mixing in a flat bottom vessel with a Rushton turbine.\n\nThe examples use the Frozen Rotor simulation method, for which the rotating parts are kept frozen in position together with the vessel wall and baffles, and the rotation is accounted for by the inclusion of centrifugal and Coriolis forces.");

    return model;
  }

  public static void main(String[] args) {
    run();
  }

}
