/*
 * slider_crank_mechanism.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 15 2026, 11:58 by COMSOL 6.4.0.421. */
public class slider_crank_mechanism {

  public static Model run() {
    Model model = ModelUtil.create("Model");

//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    In the Model Wizard window, click 2D.
//    In the Select Physics tree, select Structural Mechanics > Multibody Dynamics (mbd).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Time Dependent.
//    Click Done.

    model.component().create("comp1", true);

    model.component("comp1").geom().create("geom1", 2);

    model.component("comp1").mesh().create("mesh1");

    model.component("comp1").physics().create("mbd", "MultibodyDynamics", "geom1");

    model.study().create("std1");
    model.study("std1").create("time", "Transient");

//    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("d", "0.1[m]");
    model.param().descr("d", "Thickness");
    model.param().set("l", "1[m]");
    model.param().descr("l", "Length");
    model.param().set("m", "1[kg]");
    model.param().descr("m", "Mass");

//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").create("r1", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type d.

    model.component("comp1").geom("geom1").feature("r1").set("size", new String[]{"d", "1"});

//    Locate the Position section.
//    In the x text field, type -d/2.

    model.component("comp1").geom("geom1").feature("r1").set("pos", new String[]{"-d/2", "0"});

//    In the Geometry toolbar, click Transforms and choose Rotate.

    model.component("comp1").geom("geom1").run("r1");
    model.component("comp1").geom("geom1").create("rot1", "Rotate");

//    Select the object r1.

    model.component("comp1").geom("geom1").feature("rot1").selection("input").set("r1");

//    In the Settings window for Rotate, locate the Rotation section.
//    In the Angle text field, type -45.

    model.component("comp1").geom("geom1").feature("rot1").set("rot", -45);

//    In the Geometry toolbar, click Transforms and choose Mirror.

    model.component("comp1").geom("geom1").run("rot1");
    model.component("comp1").geom("geom1").create("mir1", "Mirror");

//    Select the object rot1.

    model.component("comp1").geom("geom1").feature("mir1").selection("input").set("rot1");

//    In the Settings window for Mirror, locate the Input section.
//    Select the Keep input objects checkbox.

    model.component("comp1").geom("geom1").feature("mir1").set("keep", true);

//    Locate the Point on Line of Reflection section.
//    In the x text field, type l/sqrt(2).

    model.component("comp1").geom("geom1").feature("mir1").set("pos", new String[]{"l/sqrt(2)", "0"});

//    In the Model Builder window, under Component 1 (comp1) > Geometry 1, click Form Union (fin).
//    In the Settings window for Form Union/Assembly, locate the Form Union/Assembly section.
//    From the Action list, select Form an assembly.

    model.component("comp1").geom("geom1").feature("fin").set("action", "assembly");

//    In the Geometry toolbar, click Build All.

    model.component("comp1").geom("geom1").run("fin");

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Model Builder window, right-click Component 1 (comp1) > Materials and choose Blank Material.

    model.component("comp1").material().create("mat1", "Common");

//    Define the density of the material using the mass and geometric-property parameters.
//    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[]{"m/(l*d^2)"});

//    In the Model Builder window, under Component 1 (comp1), click Multibody Dynamics (mbd).
//    In the Settings window for Multibody Dynamics, locate the Thickness section.
//    In the \[d\] text field, type d.

    model.component("comp1").physics("mbd").prop("d").set("d", "d");

//    In the Physics toolbar, click Domains and choose Rigid Material.

    model.component("comp1").physics("mbd").create("rd1", "RigidDomain", 2);

//    Select Domain 1.

    model.component("comp1").physics("mbd").feature("rd1").selection().set(1);

//    In the Physics toolbar, click Domains and choose Rigid Material.

    model.component("comp1").physics("mbd").create("rd2", "RigidDomain", 2);

//    Select Domain 2.

    model.component("comp1").physics("mbd").feature("rd2").selection().set(2);

//    Define the initial velocity of the slider and force the same to consistently initialize the remaining degrees of freedom.
//    In the Settings window for Rigid Material, locate the Initial Values section.
//    From the list, select Locally defined.

    model.component("comp1").physics("mbd").feature("rd2").set("InitialValueType", "locallyDefined");

//    From the Consistent initialization list, select Force initial values.

    model.component("comp1").physics("mbd").feature("rd2").set("ConsistentInitialization", "ForceInitialValues");

//    Select the Translation along first axis checkbox.

    model.component("comp1").physics("mbd").feature("rd2").set("TranslationFirstAxis", true);
    model.component("comp1").physics("mbd").feature("rd2").feature("init1").set("ut", new int[]{-4, 0, 0});
    model.component("comp1").physics("mbd").feature("rd2").feature("init1")
         .set("CenterOfRotationType", "CentroidOfSelectedEntities");

//    Initial Values 1
//    In the <l>Model Builder</l> window, expand the <l>Rigid Material 2</l> node, then click <l>Initial Values</l>.
//    In the <l>Settings</l> window for Initial Values, locate the <l>Initial Values: Translational</l> section.
//    Specify the d\[\textbf{u}\]/dt vector as
//    Locate the <l>Center of Rotation</l> section. From the list, choose <l>Centroid of selected entities</l>.
//    In the Model Builder window, under Component 1 (comp1) > Multibody Dynamics (mbd) > Rigid Material 2 > Initial Values 1, click Center of Rotation: Boundary 1.
//    Select Boundary 8.

    model.component("comp1").physics("mbd").feature("rd2").feature("init1").feature("crb1").selection().set(8);

//    In the Physics toolbar, click Global and choose Hinge Joint.

    model.component("comp1").physics("mbd").create("hgj1", "HingeJoint", -1);

//    In the Settings window for Hinge Joint, locate the Attachment Selection section.
//    From the Source list, select Fixed.

    model.component("comp1").physics("mbd").feature("hgj1").set("Source", "fixed");

//    From the Destination list, select Rigid Material 1.

    model.component("comp1").physics("mbd").feature("hgj1").set("Destination", "rd1");

//    In the Model Builder window, click Center of Joint: Boundary 1.
//    Select Boundary 1.

    model.component("comp1").physics("mbd").feature("hgj1").feature("cjb1").selection().set(1);

//    In the Physics toolbar, click Global and choose Hinge Joint.

    model.component("comp1").physics("mbd").create("hgj2", "HingeJoint", -1);

//    In the Settings window for Hinge Joint, locate the Attachment Selection section.
//    From the Source list, select Rigid Material 1.

    model.component("comp1").physics("mbd").feature("hgj2").set("Source", "rd1");

//    From the Destination list, select Rigid Material 2.

    model.component("comp1").physics("mbd").feature("hgj2").set("Destination", "rd2");

//    In the Model Builder window, click Center of Joint: Boundary 1.
//    Select Boundary 5.

    model.component("comp1").physics("mbd").feature("hgj2").feature("cjb1").selection().set(5);

//    In the Physics toolbar, click Global and choose Reduced Slot Joint.

    model.component("comp1").physics("mbd").create("rslj1", "ReducedSlotJoint", -1);

//    In the Settings window for Reduced Slot Joint, locate the Attachment Selection section.
//    From the Source list, select Fixed.

    model.component("comp1").physics("mbd").feature("rslj1").set("Source", "fixed");

//    From the Destination list, select Rigid Material 2.

    model.component("comp1").physics("mbd").feature("rslj1").set("Destination", "rd2");

//    Locate the Axes of Joint section.
//    From the Joint translational axis list, select Attached on source.

    model.component("comp1").physics("mbd").feature("rslj1").set("JointTranslationalAxis", "AttachedOnSource");

//    The default value of the joint axis can be used here.
//    In the Model Builder window, click Center of Joint: Boundary 1.
//    Select Boundary 8.

    model.component("comp1").physics("mbd").feature("rslj1").feature("cjb1").selection().set(8);

//    In the Model Builder window, under Component 1 (comp1) > Multibody Dynamics (mbd), Ctrl-click to select Rigid Material 1, Rigid Material 2.
//    Right-click and choose Group.

    model.nodeGroup().create("grp1", "Physics", "mbd");
    model.nodeGroup("grp1").placeAfter("init1");
    model.nodeGroup("grp1").add("rd1");
    model.nodeGroup("grp1").add("rd2");

//    In the Settings window for Group, type Rigid Materials in the Label text field.

    model.nodeGroup("grp1").label("Rigid Materials");

//    In the Model Builder window, under Component 1 (comp1) > Multibody Dynamics (mbd), Ctrl-click to select Hinge Joint 1, Hinge Joint 2, Reduced Slot Joint 1.
//    Right-click and choose Group.

    model.nodeGroup().create("grp2", "Physics", "mbd");
    model.nodeGroup("grp2").placeAfter("init1");
    model.nodeGroup("grp2").add("hgj1");
    model.nodeGroup("grp2").add("hgj2");
    model.nodeGroup("grp2").add("rslj1");

//    In the Settings window for Group, type Joints in the Label text field.

    model.nodeGroup("grp2").label("Joints");

//    Use the <l>Gravity</l> node to apply the gravity load.
//    In the Physics toolbar, click Global and choose Gravity.

    model.component("comp1").physics("mbd").create("gacc1", "GravityAcceleration", -1);

//    Since both components are rigid, a single element is sufficient for computing the inertial properties.
//    In the Mesh toolbar, click Mapped.

    model.component("comp1").mesh("mesh1").create("map1", "Map");

//    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 Boundary Selection section.
//    From the Selection list, select All boundaries.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").selection().all();

//    Locate the Distribution section.
//    In the Number of elements text field, type 1.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("numelem", 1);

//    Click Build All.

    model.component("comp1").mesh("mesh1").run();

//    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);

//    Click in the Graphics window and then press Ctrl+A to select both Domains.

    model.component("comp1").cpl("intop1").selection().set(1, 2);

//    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("Wp", "intop1(mbd.rho*g_const*y*d)");
    model.component("comp1").variable("var1").descr("Wp", "Total potential energy");
    model.component("comp1").variable("var1").set("W", "Wp+mbd.Wk_tot");
    model.component("comp1").variable("var1").descr("W", "Total energy");

//    In the Model Builder window, under Study 1, click Step 1: Time Dependent.
//    In the Settings window for Time Dependent, locate the Study Settings section.
//    In the Output times text field, type range(0,0.005,10).

    model.study("std1").feature("time").set("tlist", "range(0,0.005,10)");

//    Increase the BDF order for the accurate evaluation of acceleration.
//    In the Study toolbar, click Show Default Solver.

    model.study("std1").showAutoSequences("all");

//    In the Model Builder window, expand the Solution 1 (sol1) node, then click Time-Dependent Solver 1.
//    In the Settings window for Time-Dependent Solver, click to expand the Time Stepping section.
//    From the Maximum BDF order list, select 3.

    model.sol("sol1").feature("t1").set("maxorder", 3);

//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.sol("sol1").runAll();

    model.result().create("pg1", "PlotGroup2D");
    model.result("pg1").label("Displacement (mbd)");
    model.result("pg1").set("frametype", "spatial");
    model.result("pg1").set("smooth", "internal");
    model.result("pg1").feature().create("surf1", "Surface");
    model.result("pg1").feature("surf1").label("Surface");
    model.result("pg1").feature("surf1").set("colortable", "SpectrumLight");
    model.result("pg1").feature("surf1").set("data", "parent");
    model.result("pg1").feature("surf1").feature().create("def1", "Deform");
    model.result("pg1").feature("surf1").feature("def1").label("Deformation");
    model.result("pg1").feature("surf1").feature("def1").set("scaleactive", true);
    model.result().create("pg2", "PlotGroup2D");
    model.result("pg2").label("Velocity (mbd)");
    model.result("pg2").set("frametype", "spatial");
    model.result("pg2").set("smooth", "internal");
    model.result("pg2").feature().create("surf1", "Surface");
    model.result("pg2").feature("surf1").label("Domain Numbers");
    model.result("pg2").feature("surf1").set("descractive", true);
    model.result("pg2").feature("surf1").set("expr", "mod(dom,10)");
    model.result("pg2").feature("surf1").set("descr", "Domain numbers");
    model.result("pg2").feature("surf1").set("rangecoloractive", "on");
    model.result("pg2").feature("surf1").set("rangecolormin", -0.5);
    model.result("pg2").feature("surf1").set("rangecolormax", 9.5);
    model.result("pg2").feature("surf1").set("colortable", "Cyclic");
    model.result("pg2").feature("surf1").set("colorlegend", false);
    model.result("pg2").feature("surf1").set("colortabletype", "discrete");
    model.result("pg2").feature("surf1").set("smooth", "none");
    model.result("pg2").feature("surf1").set("data", "parent");
    model.result("pg2").feature("surf1").feature().create("def1", "Deform");
    model.result("pg2").feature("surf1").feature("def1").label("Deformation");
    model.result("pg2").feature("surf1").feature("def1").set("scaleactive", true);
    model.result("pg2").feature().create("arwl1", "ArrowLine");
    model.result("pg2").feature("arwl1").label("Arrow Line");
    model.result("pg2").feature("arwl1").set("expr", new String[]{"mbd.u_tX", "mbd.u_tY"});
    model.result("pg2").feature("arwl1").set("placement", "elements");
    model.result("pg2").feature("arwl1").set("data", "parent");
    model.result("pg2").feature("arwl1").feature().create("def1", "Deform");
    model.result("pg2").feature("arwl1").feature("def1").label("Deformation");
    model.result("pg2").feature("arwl1").feature("def1").set("scaleactive", true);
    model.result("pg1").run();

//    Create the cut points on the arm at various locations to plot the trajectory.
//    In the Results toolbar, click Cut Point 2D.

    model.result().dataset().create("cpt1", "CutPoint2D");

//    In the Settings window for Cut Point 2D, locate the Point Data section.
//    In the X text field, type 1/sqrt(2) 1.5/sqrt(2) sqrt(2).

    model.result().dataset("cpt1").set("pointx", "1/sqrt(2) 1.5/sqrt(2) sqrt(2)");

//    In the Y text field, type 1/sqrt(2) 0.5/sqrt(2) 0.

    model.result().dataset("cpt1").set("pointy", "1/sqrt(2) 0.5/sqrt(2) 0");

//    Right-click Cut Point 2D 1 and choose Duplicate.

    model.result().dataset().duplicate("cpt2", "cpt1");

//    In the Settings window for Cut Point 2D, locate the Point Data section.
//    In the X text field, type 1/sqrt(2).

    model.result().dataset("cpt2").set("pointx", "1/sqrt(2)");

//    In the Y text field, type 1/sqrt(2).

    model.result().dataset("cpt2").set("pointy", "1/sqrt(2)");
    model.result("pg1").run();

//    In the Model Builder window, under Results, click Displacement (mbd).
//    In the Displacement (mbd) toolbar, click More Plots and choose Point Trajectories.

    model.result("pg1").create("pttraj1", "PointTrajectories");

//    In the Settings window for Point Trajectories, locate the Data section.
//    From the Dataset list, select Cut Point 2D 1.

    model.result("pg1").feature("pttraj1").set("data", "cpt1");

//    From the Solution parameters list, select From parent.

    model.result("pg1").feature("pttraj1").set("solutionparams", "parent");

//    Locate the Coloring and Style section.
//    Find the Line style subsection.
//    From the Type list, select Tube.

    model.result("pg1").feature("pttraj1").set("linetype", "tube");

//    Right-click Point Trajectories 1 and choose Color Expression.

    model.result("pg1").feature("pttraj1").create("col1", "Color");
    model.result("pg1").run();

//    In the Settings window for Color Expression, locate the Expression section.
//    In the Expression text field, type X.

    model.result("pg1").feature("pttraj1").feature("col1").set("expr", "X");

//    Locate the Coloring and Style section.
//    From the Color table list, select RainbowLight.

    model.result("pg1").feature("pttraj1").feature("col1").set("colortable", "RainbowLight");

//    Clear the Color legend checkbox.

    model.result("pg1").feature("pttraj1").feature("col1").set("colorlegend", false);

//    In the Displacement (mbd) toolbar, click Plot.

    model.result("pg1").run();
    model.result("pg1").run();

//    In the Model Builder window, under Results, click Displacement (mbd).
//    In the Settings window for 2D Plot Group, locate the Plot Settings section.
//    From the Frame list, select Material (X, Y, Z).

    model.result("pg1").set("frametype", "material");

//    In the Displacement (mbd) toolbar, click Plot.

    model.result("pg1").run();

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Results toolbar, click Table.

    model.result().table().create("tbl1", "Table");

//    In the Settings window for Table, locate the Data section.
//    Click Import.
//    Browse to the model's Application Library folder and double-click the file slider_crank_mechanism_aA.txt.

    model.result().table("tbl1").importData("slider_crank_mechanism_aA.txt");

//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg3", "PlotGroup1D");
    model.result("pg3").run();

//    In the Settings window for 1D Plot Group, locate the Data section.
//    From the Dataset list, select Cut Point 2D 2.

    model.result("pg3").set("data", "cpt2");

//    In the Label text field, type Acceleration: point A.

    model.result("pg3").label("Acceleration: point A");

//    Right-click Acceleration: point A and choose Point Graph.

    model.result("pg3").create("ptgr1", "PointGraph");
    model.result("pg3").feature("ptgr1").set("markerpos", "datapoints");
    model.result("pg3").feature("ptgr1").set("linewidth", "preference");

//    In the Settings window for Point Graph, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Multibody Dynamics > Acceleration and velocity > Acceleration - m/s² > mbd.u_ttX - Acceleration, X-component.

    model.result("pg3").feature("ptgr1").set("expr", "mbd.u_ttX");
    model.result("pg3").feature("ptgr1").set("descr", "Acceleration, X-component");

//    Click to expand the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg3").feature("ptgr1").set("linewidth", 2);

//    Click to expand the Legends section.
//    Select the Show legends checkbox.

    model.result("pg3").feature("ptgr1").set("legend", true);

//    From the Legends list, select Manual.

    model.result("pg3").feature("ptgr1").set("legendmethod", "manual");

//    In the table, enter the following settings:

    model.result("pg3").feature("ptgr1").setIndex("legends", "COMSOL", 0);
    model.result("pg3").run();

//    In the Model Builder window, right-click Acceleration: point A and choose Table Graph.

    model.result("pg3").create("tblp1", "Table");
    model.result("pg3").feature("tblp1").set("markerpos", "datapoints");
    model.result("pg3").feature("tblp1").set("linewidth", "preference");

//    In the Settings window for Table Graph, locate the Coloring and Style section.
//    Find the Line style subsection.
//    From the Line list, select None.

    model.result("pg3").feature("tblp1").set("linestyle", "none");

//    Find the Line markers subsection.
//    From the Marker list, select Circle.

    model.result("pg3").feature("tblp1").set("linemarker", "circle");

//    Click to expand the Legends section.
//    Select the Show legends checkbox.

    model.result("pg3").feature("tblp1").set("legend", true);

//    From the Legends list, select Manual.

    model.result("pg3").feature("tblp1").set("legendmethod", "manual");

//    In the table, enter the following settings:

    model.result("pg3").feature("tblp1").setIndex("legends", "Ref. 1", 0);

//    In the Acceleration: point A toolbar, click Plot.

    model.result("pg3").run();

//    Click the Zoom Extents button in the Graphics toolbar.

    model.result("pg3").run();

//    In the Model Builder window, click Acceleration: point A.
//    In the Settings window for 1D Plot Group, locate the Axis section.
//    Select the Manual axis limits checkbox.

    model.result("pg3").set("axislimits", true);

//    In the y maximum text field, type 60.

    model.result("pg3").set("ymax", 60);

//    Click to expand the Title section.
//    From the Title type list, select None.

    model.result("pg3").set("titletype", "none");

//    Locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg3").set("xlabelactive", true);

//    In the associated text field, type Time (s).

    model.result("pg3").set("xlabel", "Time (s)");

//    Select the y-axis label checkbox.

    model.result("pg3").set("ylabelactive", true);

//    In the associated text field, type Acceleration of point A, x-component (m/s^2).

    model.result("pg3").set("ylabel", "Acceleration of point A, x-component (m/s^2)");

//    In the Acceleration: point A toolbar, click Plot.

    model.result("pg3").run();

//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg4", "PlotGroup1D");
    model.result("pg4").run();

//    In the Settings window for 1D Plot Group, type Energy in the Label text field.

    model.result("pg4").label("Energy");

//    Right-click Energy and choose Global.

    model.result("pg4").create("glob1", "Global");
    model.result("pg4").feature("glob1").set("markerpos", "datapoints");
    model.result("pg4").feature("glob1").set("linewidth", "preference");

//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Definitions > Variables > Wp - Total potential energy - J.

    model.result("pg4").feature("glob1").set("expr", new String[]{"Wp"});
    model.result("pg4").feature("glob1").set("descr", new String[]{"Total potential energy"});
    model.result("pg4").feature("glob1").set("unit", new String[]{"J"});

//    Click Add Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Multibody Dynamics > Global > mbd.Wk_tot - Total kinetic energy - J.

    model.result("pg4").feature("glob1").set("expr", new String[]{"Wp", "mbd.Wk_tot"});
    model.result("pg4").feature("glob1")
         .set("descr", new String[]{"Total potential energy", "Total kinetic energy"});

//    Click Add Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Definitions > Variables > W - Total energy - J.

    model.result("pg4").feature("glob1").set("expr", new String[]{"Wp", "mbd.Wk_tot", "W"});
    model.result("pg4").feature("glob1")
         .set("descr", new String[]{"Total potential energy", "Total kinetic energy", "Total energy"});

//    Click to expand the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg4").feature("glob1").set("linewidth", 2);

//    Find the Line markers subsection.
//    From the Marker list, select Cycle.

    model.result("pg4").feature("glob1").set("linemarker", "cycle");

//    From the Positioning list, select Interpolated.

    model.result("pg4").feature("glob1").set("markerpos", "interp");

//    In the Number text field, type 24.

    model.result("pg4").feature("glob1").set("markers", 24);
    model.result("pg4").run();

//    In the Model Builder window, click Energy.
//    In the Settings window for 1D Plot Group, locate the Axis section.
//    Select the Manual axis limits checkbox.

    model.result("pg4").set("axislimits", true);

//    In the Energy toolbar, click Plot.

    model.result("pg4").run();

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the y maximum text field, type 35.

    model.result("pg4").set("ymax", 35);

//    Locate the Title section.
//    From the Title type list, select None.

    model.result("pg4").set("titletype", "none");

//    Locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg4").set("xlabelactive", true);

//    Select the y-axis label checkbox.

    model.result("pg4").set("ylabelactive", true);

//    In the associated text field, type Energy (J).

    model.result("pg4").set("ylabel", "Energy (J)");

//    In the Energy toolbar, click Plot.

    model.result("pg4").run();

//    Finally, to generate an animation of the slider crank mechanism, follow these instructions:
//    In the Results toolbar, click Animation and choose Player.

    model.result().export().create("anim1", "Animation");
    model.result().export("anim1").set("target", "player");
    model.result().export("anim1").set("fontsize", "9");
    model.result().export("anim1").set("colortheme", "globaltheme");
    model.result().export("anim1").set("customcolor", new double[]{1, 1, 1});
    model.result().export("anim1").set("background", "color");
    model.result().export("anim1").set("gltfincludelines", "on");
    model.result().export("anim1").set("title1d", "on");
    model.result().export("anim1").set("legend1d", "on");
    model.result().export("anim1").set("logo1d", "on");
    model.result().export("anim1").set("options1d", "on");
    model.result().export("anim1").set("title2d", "on");
    model.result().export("anim1").set("legend2d", "on");
    model.result().export("anim1").set("logo2d", "on");
    model.result().export("anim1").set("options2d", "off");
    model.result().export("anim1").set("title3d", "on");
    model.result().export("anim1").set("legend3d", "on");
    model.result().export("anim1").set("logo3d", "on");
    model.result().export("anim1").set("options3d", "off");
    model.result().export("anim1").set("axisorientation", "on");
    model.result().export("anim1").set("grid", "on");
    model.result().export("anim1").set("axes1d", "on");
    model.result().export("anim1").set("axes2d", "on");
    model.result().export("anim1").set("showgrid", "on");
    model.result().export("anim1").showFrame();

//    In the Settings window for Animation, locate the Frames section.
//    In the Number of frames text field, type 100.

    model.result().export("anim1").set("maxframes", 100);
    model.result("pg1").run();

    model.title("Slider Crank Mechanism");

    model
         .description("This is a benchmark problem for multibody dynamics where a slider crank mechanism is studied. The links in the mechanism are rigid. Two hinge joints and a reduced slot joint are used to create the connections between the links. The time history of the acceleration at a certain point is compared with the result from the reference.");

    return model;
  }

  public static void main(String[] args) {
    run();
  }

}
