0% found this document useful (0 votes)
573 views

MotionSolve 2019 Tutorials

hypermesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
573 views

MotionSolve 2019 Tutorials

hypermesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 273

Altair MotionSolve 2019

Tutorials

altairhyperworks.com
Intellectual Property Rights Notice
Copyrights, Trademarks, Trade Secrets, Patents & Third Party Software Licenses

Altair MotionSolve 2019 Copyright 2002-2019

The Platform for Innovation™

Altair Engineering Inc. Copyright © 1986-2019. All Rights Reserved.

Note: Pre-release versions of Altair software are provided ‘as is’, without warranty of any
kind. Usage of pre-release versions is strictly limited to non-production purposes.

Altair HyperWorks™ - The Platform for Innovation™


Altair AcuConsole™ ©2006-2019

Altair AcuSolve™ ©1997-2019


Altair ElectroFlo™ ©1992-2019

Altair ESAComp™ ©1992-2019

Altair Feko™ ©1999-2014 Altair Development S.A. (Pty) Ltd.; ©2014-2019 Altair Engineering Inc.

Altair Flux™ ©1983-2019

Altair FluxMotor™ ©2017-2019

Altair HyperCrash™ ©2001-2019

Altair HyperGraph™ ©1995-2019

Altair HyperLife™ ©1990-2019

Altair HyperMesh™ ©1990-2019

Altair HyperStudy™ ©1999-2019

Altair HyperView™ ©1999-2019

Altair Virtual Wind Tunnel™ ©2012-2019

Altair HyperXtrude™ ©1999-2019

Altair MotionSolve™ ©2002-2019

Altair MotionView™ ©1993-2019

Altair Multiscale Designer™ ©2011-2019

Altair OptiStruct™ ©1996-2019

Altair Radioss™ ©1986-2019

Altair SimLab™ ©2004-2019

Altair SimSolid™ ©2015-2019

Altair nanoFluidX™ ©2013-2018 Fluidyna GmbH, © 2018-2019 Altair Engineering Inc.

Altair ultraFluidX™ ©2010-2018 Fluidyna GmbH, © 2018-2019 Altair Engineering Inc.


MotionSolve Tutorials
Intellectual Property Rights Notice p.ii

Altair WinProp™ ©2000-2019;

Altair ConnectMe™ ©2014-2019;

Plus other products from the Altair solidThinking Platform.

Altair Packaged Solution Offerings (PSOs)


Altair Automated Reporting Director™ ©2008-2019

Altair GeoMechanics Director™ ©2011-2019

Altair Impact Simulation Director™ ©2010-2019

Altair Model Mesher Director™ ©2010-2019

Altair NVH Director™ ©2010-2019

Altair Squeak and Rattle Director™ ©2012-2019

Altair Virtual Gauge Director™ ©2012-2019

Altair Weight Analytics™ ©2013-2019

Altair Weld Certification Director™ ©2014-2019

Altair Multi-Disciplinary Optimization Director™ ©2012-2019

Altair solidThinking - Where Innovation Begins™


Altair Inspire™ ©2009-2019 including Altair Inspire Motion and Altair Inspire Structures

Altair Inspire™ Extrude-Metal ©1996-2019 (formerly Click2Extrude®-Metal)

Altair Inspire™ Extrude-Polymer ©1996-2019 (formerly Click2Extrude®-Polymer)

Altair Inspire™ Cast ©2011-2019 (formerly Click2Cast®)

Altair Inspire™ Form ©1998-2019 (formerly Click2Form®)

Altair Inspire™ Mold ©2009-2019 (initial release-Q2 2019)

Altair Inspire™ Studio ©1993-2019 (formerly ‘Evolve’)

Altair Compose™ ©2007-2019 (formerly solidThinking Compose®)

Altair Activate™ ©1989-2019 (formerly solidThinking Activate®)

Altair Embed™ ©1989-2019 (formerly solidThinking Embed®)


• Altair Embed SE™ ©1989-2019 (formerly solidThinking Embed® SE)
• Altair Embed/Digital Power Designer ©2012-2019

Altair SimLab™ ©2004-2019

Altair 365™ ©1994-2019

Altair PBSWorks™ - Accelerating Innovation in the Cloud™


Altair PBS Professional™ ©1994-2019

Altair Control™ ©2008-2019; (formerly PBS Control)

Altair Access™ ©2008-2019; (formerly PBS Access)

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Intellectual Property Rights Notice p.iii

Altair Accelerator™ ©1995-2019; (formerly NetworkComputer)

Altair Accelerator Plus™©1995-2019; (formerly WorkloadXelerator)

Altair FlowTracer™ ©1995-2019; (formerly FlowTracer)


Altair Allocator™ ©1995-2019; (formerly LicenseAllocator)

Altair Monitor™ ©1995-2019; (formerly LicenseMonitor)

Altair Hero™ ©1995-2019; (formerly HERO)


Altair Software Asset Optimization™ (SAO) ©2007-2019

Note:
Compute Manager™ ©2012-2017 is now part of Altair Access

Display Manager™ ©2013-2017 is now part of Altair Access

PBS Application Services™ ©2008-2017 is now part of Altair Access

PBS Analytics™ ©2008-2017 is now part of Altair Control

PBS Desktop™ ©2008-2012 is now part of Altair Access, specifically Altair Access
desktop, which also has Altair Access web and Altair Access mobile

e-Compute™ ©2000-2010 was replaced by “Compute Manager” which is now Altair


Access

Altair SmartWorks™ - Innovation Intelligence®


Altair SmartCore™ ©2011-2019

Altair SmartEdge™ ©2010-2019

Altair SmartSight™ ©2014-2019

Altair intellectual property rights are protected under U.S. and international laws and treaties.
Additionally, Altair software is protected under patent #6,859,792 and other patents pending. All other
marks are the property of their respective owners.

ALTAIR ENGINEERING INC. Proprietary and Confidential. Contains Trade Secret Information.

Not for use or disclosure outside of Altair and its licensed clients. Information contained in Altair
software shall not be decompiled, disassembled, “unlocked”, reverse translated, reverse engineered,
or publicly displayed or publicly performed in any manner. Usage of the software is only as explicitly
permitted in the end user software license agreement. Copyright notice does not imply publication.

Third party software licenses


AcuConsole contains material licensed from Intelligent Light (www.ilight.com) and used by permission.

Software Security Measures:

Altair Engineering Inc. and its subsidiaries and affiliates reserve the right to embed software security
mechanisms in the Software for the purpose of detecting the installation and/or use of illegal copies of
the Software. The Software may collect and transmit non-proprietary data about those illegal copies.
Data collected will not include any customer data created by or used in connection with the Software

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Intellectual Property Rights Notice p.iv

and will not be provided to any third party, except as may be required by law or legal process or to
enforce our rights with respect to the use of any illegal copies of the Software. By using the Software,
each user consents to such detection and collection of data, as well as its transmission and use if an
illegal copy of the Software is detected. No steps may be taken to avoid or detect the purpose of any
such security mechanisms.

Proprietary Information of Altair Engineering


Technical Support
Altair provides comprehensive software support via web FAQs, tutorials, training classes, telephone and
e-mail.

Altair Support on the World Wide Web


The Altair web site is a valuable online companion to Altair software. Visit www.altairhyperworks.com
for tips and tricks, training course schedules, training/tutorial videos, and other useful information.

Altair Training Classes


Altair training courses provide a hands-on introduction to our products, focusing on overall functionality.
Courses are conducted at our main and regional offices or at your facility. If you are interested in
training at your facility, please contact your account manager for more details. If you do not know who
your account manager is, please send an e-mail to [email protected] and your account manager will
contact you.

Telephone and E-mail


When contacting Altair support, please specify the product and version number you are using along with
a detailed description of the problem. Many times, it is very beneficial for the support engineer to know
what type of workstation, operating system, RAM, and graphics board you have, so please have that
information ready. If you send an e-mail, please specify the workstation type, operating system, RAM,
and graphics board information in the e-mail.

To contact an Altair support representative, reference the following table or the information available on
the HyperWorks website: www.altairhyperworks.com/ClientCenterHWSupportProduct.aspx.

Location Telephone E-mail

Australia 64.9.413.7981 [email protected]

Brazil 55.11.3884.0414 [email protected]

Canada 416.447.6463 [email protected]

China 86.400.619.6186 [email protected]

France 33.1.4133.0992 [email protected]

Germany 49.7031.6208.22 [email protected]

India 91.80.6629.4500 [email protected]

1.800.425.0234 (toll free)

Israel [email protected]

Italy 39.800.905.595 [email protected]


MotionSolve Tutorials
Technical Support p.vi

Location Telephone E-mail

Japan 81.3.6225.5830 [email protected]

Malaysia [email protected]

Mexico 55.56.58.68.08 [email protected]

South Africa 27 21 8311500 [email protected]

South Korea 82.70.4050.9200 [email protected]

Spain 34 910 810 080 [email protected]

Sweden 46.46.460.2828 [email protected]

United Kingdom 01926.468.600 [email protected]

United States 248.614.2425 [email protected]

For questions or comments about this help system, send an email to [email protected].

In addition, the following countries have resellers for Altair Engineering: Colombia, Czech Republic,
Ecuador, Israel, Russia, Netherlands, Turkey, Poland, Singapore, Vietnam, Indonesia

Official offices with resellers: Canada, China, France, Germany, India, Malaysia, Italy, Japan, Korea,
Spain, Taiwan, United Kingdom, USA

See www.altair.com for complete contact information.

Proprietary Information of Altair Engineering


Contents
Intellectual Property Rights Notice.............................................................................. i
Technical Support............................................................................................................. v

Rigid Body Dynamics....................................................................................................... 9

MV-1010: 3D Mesh to Mesh Contact Simulation.................................................................. 10


MV-1011: Extension and Retraction Analysis of the Main Landing Gear of an Aircraft................ 29
MV-1035: Importing CAD or FE into MotionView................................................................. 39
MV-1051: Understanding Sequential Simulation.................................................................. 53

Flexible Body Dynamics................................................................................................ 60

MV-2000: Introduction to Flexible Bodies........................................................................... 61


MV-2010: Flexbody Generation using Flex Prep and OptiStruct............................................. 64
MV-2020: Using Flexbodies in MBD Models.........................................................................79
MV-2021: Simulating an Automotive Door Closure Event......................................................86
MV-2035: Solving Flexbody ADM/ACF in MotionSolve...........................................................95

Optimization-DOE-Stochastics..................................................................................... 99

MV-3000: DOE using MotionView - HyperStudy................................................................. 100


MV-3010: Optimization using MotionView - HyperStudy......................................................124

Using the MotionSolve API.........................................................................................129

MV-9000: Bouncing Ball Tutorial......................................................................................130


MV-9001: Simple Pendulum Tutorial.................................................................................135
MV-9002: Slotted Link Tutorial........................................................................................ 143
MV-9003: LuGre Friction Tutorial..................................................................................... 149

User Subroutines........................................................................................................... 157

MV-1024: Using User Subroutines in MotionSolve Models................................................... 158


MV-7001: Building User Subroutines in MotionSolve.......................................................... 165
MV-7006: Python UserSub for MotionSolve....................................................................... 174

Advanced Simulation.................................................................................................... 179

MV-7000: Modeling Differential Equations Using MotionView and MotionSolve........................ 180


MV-7002: Co-simulation with Simulink............................................................................. 187

7
MV-7003: Simulating a Single Input Single Output (SISO) Control System Using
MotionView and MotionSolve........................................................................................... 199
MV-7004: Inverted Pendulum Control Using MotionSolve and MATLAB.................................. 203
MV-7005: Linking Matlab/Simulink Generated Code (Simulink Coder) with MotionSolve........... 210
MV-7008: Co-simulation with AcuSolve............................................................................ 220
MV-7009: Remote Co-simulation with Simulink................................................................. 237
Appendix...............................................................................................................250
MV-7010: Co-Simulation with Activate - Quadrotor Control................................................. 252

Index.................................................................................................................................268

8
Rigid Body Dynamics 1
Rigid Body Dynamics

This chapter covers the following:

• MV-1010: 3D Mesh to Mesh Contact Simulation (p. 10)


• MV-1011: Extension and Retraction Analysis of the Main Landing Gear of an Aircraft (p. 29)
• MV-1035: Importing CAD or FE into MotionView (p. 39)
• MV-1051: Understanding Sequential Simulation (p. 53)
MotionSolve Tutorials
Rigid Body Dynamics p.10

MV-1010: 3D Mesh to Mesh Contact Simulation


In this tutorial, you will learn about 3D rigid body contact capabilities in MotionSolve and use the mesh-
to-mesh contact approach, which makes use of surface meshes for the bodies coming in contact during
the simulation.

A surface mesh is defined as an interconnected set of triangles that accurately represent the surface of
a 3D rigid body. MotionSolve prescribes certain conditions for such a surface mesh.

• Each component mesh should form a closed volume. This means that the given mesh should not
contain any open edges (edge which is part of only one element) or T- connections (2 elements join
at the common edge in form of a T).
• Mesh should be of uniform size.
• Element surface normal should point in the direction of expected contact.

In this tutorial, you will learn how to:


• Import CAD geometry with graphic settings suitable for contact simulation.
• Setup 3D rigid body contact between meshed geometries in the multibody model.
• Perform a transient analysis to calculate the contact forces between these geometries.
• Post-process the results using a report generated automatically.

For these purposes, you will make use of a slotted link model.

For such a meshed representation of 3D rigid bodies, MotionSolve uses a numerical collision engine that
detects penetration between two or more surface meshes and subsequently calculates the penetration
depth(s) and the contact force(s).

There are numerous 3D contact applications (gears, cams, mechanisms with parts in contact etc.) that
may be solved using this approach.

Slotted Link Model


A slotted link mechanism (sometimes also referred to as a scotch-yoke mechanism) is a type of
mechanism used to convert an input rotational motion into continuous or intermittent translational
motion of a sliding link or yoke part. The motion is transferred via a contact force between parts of
the mechanism that are in contact. Both normal and friction contact force may be responsible for the
transfer of motion.

Such mechanisms find common application in valve actuators, air compressors, certain reciprocating
and rotary engines among others. The figure below illustrates a slotted link mechanism that will be
modeled in this tutorial.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.11

Figure 1: A Slotted Link Mechanism.


The cam is in contact with the slotted link as shown, whereas the pin comes into contact with the slots.

Importing CAD Geometry into MotionView


1. Copy the slotted_link.x_t file, located in the mbd_modeling\contacts folder, to your working
directory.
2. Start a new MotionView session.
3. Click Tools > Import CAD or FE, or click on the Standard toolbar.
The Import CAD or FE dialog is displayed.
4. Set the following options in this dialog:
a) Set Import Options to Import CAD or Finite Element Model with Mass and Inertias.
b) Select Input File as Parasolid and using the File Open icon.
c) Click to specify the input CAD geometry as slotted_link.x_t in your working
directory.
The Output Graphic File text field is automatically populated with the same path and name,
however it is suffixed with a _graphic.h3d extension. This is the file that will be used to
specify the graphics in the model. You may change the name or path of the graphic H3D if
you wish.
d) Expand Meshing Options for Surface Data by clicking on the expand button ( ). Ensure that
the option to Allow HyperMesh to specify mesh options is checked.
e) Activate the Control mesh coarseness for contacts check box. Set the slider to 5.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.12

This option tells HyperMesh to mesh the CAD geometry such that it can be used for 3D
contact in MotionSolve.

Note: The slider controls the coarseness of the generated mesh, with 1 being
the coarsest and 10 being the most fine. A very coarse mesh will have large
triangles, which may not represent the curvature of the CAD surfaces accurately.
Alternatively, a very fine mesh will have extremely small triangles that may
increase element numbers and thereby the solution time. The best practice is
to strike a balance between mesh fineness and performance that satisfies the
modeling purpose.

At this stage, the Import CAD or FE dialog should look like the figure below:

Figure 2: Importing CAD Using the Import CAD or FE Utility

5. Click OK.
MotionView invokes HyperMesh in the background, to mesh the geometry and calculate its volume
properties. Another dialog appears where the components in the CAD file can be reviewed along
with their mass, density, and volume properties.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.13

Figure 3: Importing CAD Using the Import CAD or FE Utility

6. Click OK and clear the Message Log.


The converted geometry is loaded into MotionView for visual inspection. You can inspect the
surface mesh by swapping the display to a meshed representation.
7. Click Entity Attributes on the Visualization toolbar.
The Entity Attributes panel is displayed.
8. Select all the graphics by clicking on Model at the top of the list at the left corner of the panel and
click on Mesh Lines .

Figure 4: Displaying Mesh Lines for all the Components of the Input CAD Geometry

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.14

Figure 5: Displaying the Surface Mesh for all the Components of the Input CAD Geometry

Creating Joints and Motion


At this stage, the model contains the following bodies along with their associated graphics:

Entity name Entity type Description

Slotted_Link Rigid Body The slotted link body.

Cam Rigid Body The cam body.

Pin Rigid Body The pin body. Together the cam and the pin bodies
engage the slotted link.

Link Rigid Body A connector body between the pin and the cam.

Slotted_Link Graphic The graphic that represents the slotted link body. This
is a tessellated graphic.

Cam Graphic The graphic that represents the cam body. This is a
tessellated graphic.

Pin Graphic The graphic that represents the pin body. This is a
tessellated graphic.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.15

Entity name Entity type Description

Link Graphic The graphics that represent the link body. This is a
tessellated graphic.

The Pin, Link, and the Cam bodies are fixed to each other and pivoted with to the Ground Body at the
Cam center. The Slotted link can translate with respect to the Ground Body.

1. Create joints as per the details given in the table below:

S.No
Label Type Body 1 Body 2 Origin Alignment
Axis

1 Pin Link Fix Fixed Joint Pin Link Pin CG

2 Link Cam Fix Fixed Joint Link Cam Link CG

3 Cam Pivot Revolute Joint Cam Ground Body Global Origin Global Y

4 Slotted Link Translation Joint Slotted_Link Ground Body Slotted_Link CG Global X


Slider

2. Apply a motion on the Cam Pivot joint of the type Displacement and the Expression as
`360d*TIME`.
3. Save your model as slotted_link_mech.mdl.

Defining Contact Between the Colliding Geometries


In this step, you will define contact between:
• Cam and the Slotted_Link
• Pin and the Slotted_Link

1. Right-click on the Force Entity toolbar.


The Add Contact dialog is displayed.
2. Change the Label to Cam Slotted Link Contact. Verify that RigidToRigidContact is selected and
click OK.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.16

Figure 6:

3. From the Connectivity tab of the Contact panel, resolve Body I to Cam and Body J to
Slotted_Link. Doing this will automatically select the respective graphics that are attached to
these bodies.

Figure 7:

4. To make sure that the geometries are well defined, ensure that the normals are oriented correctly
and there are no open edges or T-connections in the geometries.
5. Activate the Highlight contact side check box. This will color the geometries specified for
this contact force element according to the direction of the surface normals. Verify that both
geometries are completely red (to visualize clearly, you may have to deactivate the other graphic
and reactivate).

Figure 8:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.17

Figure 9: Checking for Incorrect Surface Normals

The color red indicates the direction of surface normal and is the side of the expected contact.
6. Check for open edges or T-connections. If the associated graphics mesh has any open edges or T-
connections, the Highlight mesh errors option is active. If it is active, check the box for Highlight
mesh errors.
Any open edges or T Connections in the geometry are highlighted.
The graphics associated in this contact entity don't have mesh errors. Hence you should see
Highlight mesh errors grayed out.

Figure 10:

The geometry seems to be clean and there are no free edges or T connections in the model.

Note: For every contact entity added to the model, MotionView automatically creates
an output of the type Expression that can be used to plot the contact forces for
that contact element.

7. Specify the contact properties. Click on the Properties tab to display the Normal Force and the
Friction Force property sub-tabs within the Contact panel. In this model you will use an Impact
model with the following properties:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.18

Normal Force Model Impact

Stiffness 1000.0

Exponent 2.1

Damping 0.1

Penetration Depth 0.1

Friction Force Model Disabled

Figure 11:

8. Repeat Steps 1 - 7 for creating contact between the Pin body (Body I) and the Slotted_Link (Body
J). You may define the label for this contact to be Pin Slotted Link Contact. Define the same
contact properties as listed in Step 7 above.
9. For the contact force element Pin Slotted Link Contact, you will also instruct MotionSolve to find
the precise time at which contact first occurs between the two colliding bodies.
a) Navigate to the Advanced tab.
b) Check the Find precise contact event box.
c) In the text field below, specify a value of 0.01.

Figure 12:

Note: With the Find precise contact event option, MotionView automatically
adds a sensor entity (defined by Sensor_Event in the solver deck), which has a
zero_crossing attribute. During simulation, when the contact force is detected
for the first time (force value crossing zero), MotionSolve will cut down its step
size by the given factor and try to determine the contact event more precisely.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.19

Setting Up a Transient Simulation and Running the Model


At this point, you are ready to setup a transient analysis for this model.

1. Click Run on the toolbar to open the Run panel.

2. Change the Simulation type to Transient and specify an end time of 3.0 seconds.
3. To obtain accurate results, you will specify a smaller step size than the default.
a) Click on Simulation Settings to display the Simulation Settings dialog.
b) Go to the Transient tab and set the Maximum Step Size to 1e-3.
c) Click Close.

Figure 13: Specifying the Maximum Step Size

4. From the Run panel, specify a name for your XML model and click Run.
The transient simulation is started.

Figure 14: Specify the Output File Name and Run the Model

In the HyperWorksHyperWorks Solver View dialog that appears, you should be able to see a
message from the solver that confirms that the mesh based contact method is being used for the
contact calculations.

Figure 15: Verifying That the Mesh Based Contact is Used for the Simulation

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.20

In the log file you will also see messages related to the sensor. This is related to finding the
precise contact event for the second contact element in the model.

Figure 16: Solver Message Related to Sensor Activity

Post-processing the Results


After the simulation is complete, MotionSolve prints out a summary table (both on screen and in the
log file generated) that lists the top 5 contact pairs ordered by maximum penetration depth and by
maximum contact force for this simulation. This is very useful since it can be used to verify that the
model is behaving as intended even before loading the results (ABF, MRF, PLT or H3D) files. You can also
use this table to verify that the penetration depths and contact forces are within the intended limits for
your model. The summary table for this simulation is illustrated below:

Figure 17: Contact Overview Table

1. To view a consolidated report of the results, click Analysis > View Reports.

Figure 18:

A list of the history of simulations you have completed in the past using MotionView is displayed.
2. Select the Contact Report that corresponds to this simulation.
3. Click OK.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.21

Figure 19: Create Contact Report

MotionView creates a number of pages in your current HyperWorks session.

Contact Overview via H3D

The first HyperView page (second in the session) displays a contour plot colored by maximum
penetration depth over the entire length of the simulation. You may hide one or more parts to view this
clearly in the modeling window. This is illustrated in the figure below. The cam graphic has been made
transparent to see the penetration depths better.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.22

Figure 20: The Contact Overview for Penetration Depth

Note: The contact overview colored by penetration depth is only available for meshed
geometries.

Visualizing the Penetration Depth via H3D


The third page in the session can be used to animate the results while viewing a contour plot of the
penetration depth colored by magnitude. This allows you visualize the penetration depths at different
times of the animation.

1. Set the graphic display to Transparent Elements and Feature Lines.

Figure 21:

2. Click Animation Controls on the Animation toolbar and move the Animate End slider to the

end .

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.23

3. Click Contour on the toolbar and select the Cam body as the Components collector.

4. Click Apply.
5. Click on the Start/Pause Animation button to animate the result.
The penetration depth contour animation on the cam body can be visualized.

Figure 22: The Contact Penetration Depth Contour

Visualizing the Contact Forces via H3D


The fourth page in the session can be used to visualize the contact forces in the animation of the
results. By default, the contact report plots the total contact force for each contact element.

1. Click Animation Controls on the Animation toolbar and move the Animate End slider to the

end .

2. Click on the Start/Pause Animation button to animate the result.

3. Set the graphic display to Transparent Elements and Feature Lines.


4. The forces may need to be scaled by magnitude or uniformly by a factor to be entirely visible. To
change the scale, go to the Vector panel , click on the Display tab and change the Size scaling
option as appropriate.
An example of this animation is shown in the figure below:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.24

Figure 23: The Total Contact Force Between the Cam Body and the Slotted Link

The current force vectors are displayed on each node of the mesh that is in contact at each time
step.

Visualizing the Sum Total of Force at a Given Region

1. From the Results Browser deactivate the following components: Contact Graphic(Cam Slotted
Link Contact) and Contact Graphic (Pin Slotted Link Contact).
2. Activate the Contact Region Output (by either clicking on the icon in the browser or using the
right-click context menu).

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.25

Figure 24: Deactivating and Activating Components from Results Browser

MotionSolve supports a number of outputs that can be animated in HyperView:


• The contact normal force
• The contact penetration depth
• The contact penetration velocity
• The contact point slip velocity
• The contact tangential force
• The contact total force

Visualizing MotionSolve Outputs

1. Navigate to the Vector panel .

2. For the Result type, select the type of result from the drop-down menu and click Apply.
This will plot the result type you selected for all the relevant graphics in the model. You may have
to scale the force vectors accordingly to make sure they are visible.

Figure 25: Scaling the Tangential Force

As an example, the point slip velocity vectors are plotted in the figure below:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.26

Figure 26: Point Slip Velocity Vectors

Plotting the Contact Forces via ABF

Navigate to the next page . This is the last page in the session.

Each time a new contact entity is created in MotionView, a corresponding output force request is
created that can be used to plot the contact forces between the graphics specified in the contact entity.
These can then be visualized in HyperGraph. The last page of the contact report plots the contact force
magnitude for all the contact elements in the model.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.27

Figure 27: Total Contact Force Magnitude

Manually Plotting Other Output Requests

1. Click Add Page and change the client to HyperGraph 2D (if it is not already selected).

2. Open the ABF output file for the simulated model.

3. Under Y Type, select Expressions and select a request in the Y Request window.
Select REQ/70000003 Force - Pin Slotted Link Contact as the Y Request and F4 as Y
Component to plot.
4. Click Apply.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.28

Figure 28: Visualizing the Contact Force in HyperGraph

5. Save your session as slotted_link.mvw.

Summary
In this tutorial, you learned how to create a good meshed representation from CAD geometry. Further,
you learned how to setup contact between meshed geometries. Also, you were able to inspect
the geometry to make sure the surface normals were correct and there were no open edges or T
connections.

You were also able to setup a transient analysis to calculate the contact forces between these
geometries and post-process the results via vector and contour plots in addition to plotting the contact
force requests.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.29

MV-1011: Extension and Retraction Analysis of the


Main Landing Gear of an Aircraft
In this tutorial, you will learn how to create a sequential simulation script to simulate the extension and
retraction of the landing gear.

Sequential Simulation
Often, the total dynamic behavior of a multibody model needs to be captured through more than one
solution sequence. Typical examples include:

1. The model configuration changes after a certain amount of time.


2. One type of analysis has to occur before the other. For example, a static solution is required
before a dynamic run.
3. Complex models may not solve with a single solver setting. The solver settings may need to be
changed for a certain period in the overall simulation time.

Such conditions may be simulated by providing a set of commands to the solver that achieves the
above type of sequences. Such simulations are referred to as sequential simulations. Generally, the
solver receives more than one solution (simulate) command. You'll learn to script such a simulation
sequence through this exercise.

Exercise
In this exercise, a landing gear mechanism is simulated for its extension and retraction. A sequence
of simulations need to be scripted such that the mechanism is retracted within a certain period of time
at which the simulation is halted, the model configuration is changed for retraction and the solution is
executed again for extension.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.30

Figure 29: Main Landing Gear of an Aircraft

Note: Copy the following files, located in mbd_modeling\interactive\aero, to your


working directory:
• MainLandingGear.mdl
• Aircraft_Structure.hm
• MainLandingGear.h3d

Phase 1
In this phase, you will prepare the landing gear model to simulate the retraction of the landing gear.

Opening the Landing Gear Mechanism


In this step, you will open a landing gear model and attach a graphic for the aircraft body.

1. From the toolbar, click Open Model .

Or

Open model by selecting File > Open > Model.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.31

2. From the Open model dialog, select the file MainLandingGear.mdl and click Open.
Once the model is loaded it will look as it does below. Review the model for its bodies and joints.
The model consists of linkages of the cylinder and piston that hold the wheel as well as linkages
for the extension and retraction of the whole landing gear unit within the aircraft body. The model
also contains a body defined for aircraft but without graphics. As a first step, you’ll add a graphic
for the aircraft body part for visual representation.

Figure 30: Main Landing Gear Mechanism

Use a HyperMesh file to create a graphic for the aircraft body.


3. From the Tools menu, select the Import CAD or FE utility.
4. Select the option Import CAD or Finite Element Model Only. With this selection, only the
graphics will be imported without creating any bodies.
5. For Input File, select HyperMesh. For Output File, select H3D.
6. Click Input File and select Aircraft_Structure.hm as the input file.

7. Save the file as Aircraft_Structure.H3D in your working directory.


8. Click OK.
9. When the H3D file is generated and the graphic is imported, the import success message is
displayed. Click OK.
10. Click Graphics in the MotionView toolbar.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.32

Figure 31: The Model After Importing a Graphic for the Aircraft Body

11. Select the just-added graphic from the modeling window.


The panel for the aircraft body is displayed.
12. From the Connectivity tab:
a) Resolve the Body collector to Aircraft 5.
b) Set the Component list to All.

Note: Since the H3D file has only one component, aircraft_body, the Component
list can be set to either All or select the only component from the drop-down
menu.

Figure 32:

Defining a Motion to Retract the Landing Gear


In this step, define the motion to retract the landing gear.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.33

1. From the Project Browser, right-click on Model and select Add Constraint > Motions (or right-
click Motions from the toolbar).

2. Add a motion with Label as Retraction Motion and Varname as mot_ret.


3. Resolve the Joint to the Cylindrical Joint ActPis_ActCyl_Cyl (shown in the image below), which is
defined between the bodies Activating Cylinder and Activating Piston.

Figure 33: Rev Joint

4. From the Motion panel > Properties tab, under Define by, select Expression. In the Expression
field, enter the expression STEP(TIME,0,0,5,-750).

Note: The above STEP expression ramps the value of motion from 0 at 0 second to
-750 at 5 seconds. .

5. Add another motion and name it Aligning_Motion. Resolve the Joint to the Cylindrical Joint
LnkCyl_LnkPis_Cyl defined between the MLG Cyl and MLG Pis bodies (see the image below).

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.34

Figure 34: Translation Joint

6. From the Properties tab of the panel, under Define by, select Expression. In the Expression field,
enter the expression STEP(TIME,0,0,2,-100).
7. Save your model as landinggear_motion.mdl.

Running a Dynamic Analysis to Simulate the Retraction of the Main


Landing Gear
In this step, run a transient analysis of the main landing gear mechanism.

1. From the Run panel, set the End time to 5 seconds.


2. Click Save and run current model browser and enter the name for the run file as
lg_retract.xml. Click Save.
3. Click Run. Once the simulation is completed, close the solver window and the Message Log.
4. From the Run panel, review the results animation by clicking Animate.

Phase 2
In Phase 2, write a Templex template to script and run a sequential simulation to simulate the retraction
and extension of the landing gear mechanism.

Defining an Extension Motion for the Landing Gear


In this step, model the extension motion of the landing gear.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.35

1. From the Project Browser, right-click Model and select Add Constraint > Motions (or right-click
Motions from the toolbar).

2. Add another motion with Label as Extension Motion and Variable Name as mot_ext. Resolve the
motion to the same joint for which the Retraction Motion has been defined.
3. From the Properties tab, set the type of motion as Expression and enter the following in the
Expression field: STEP(TIME,5,-750,10,0).

Defining a Template to Run the Sequential Simulation


In this step, write a template to script a sequential simulation.

1. From the Project Browser, right-click on Model and select Add > General MDL Entity >
Template (or right-click Template from the toolbar).

2. Specify a Label and Varname and click OK.


3. For Type, select Write text to solver command file.
4. Enter the script given below. The entries in the curly braces {}, refer to the idstring of either
Extension Motion or Retraction Motion. This idstring attribute can also be accessed using the
Expression builder, .

Note: The following commands are MotionSolve command statements in the XML
format. Since the solver refers to entities through their ID numbers, the element_id
value is resolved to the motion IDs. If you have used different varnames for the
motions than mentioned below, the text could differ.

<!--Deactivate the extension motion first -->


<Deactivate
element_type = "MOTION"
element_id = "{MODEL.mot_ext.idstring}"
/>
<!--Simulate for 5 seconds -->
<Simulate
analysis_type = "Transient"
end_time = "5.0"
print_interval = "0.01"
/>
<!--Deactivate the retraction motion -->
<Deactivate
element_type = "MOTION"
element_id = "{MODEL.mot_ret.idstring}"
/>
<!--Activate the extension motion that was deactivated during the first
simulation -->
<Activate
element_type = "MOTION"
element_id = "{MODEL.mot_ext.idstring}"
/>
<!--Simulate for 5 more seconds -->
<Simulate
analysis_type = "Transient"
end_time = "10.0"
print_interval = "0.01"

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.36

/>
<STOP/>

<!-- Stop the simulation. Any further commands below this command will not be
executed -->

The above script has five blocks.


Block 1 Deactivates the motion which defines the extension of the
landing gear.

Block 2 Simulates the model for the retraction of the landing gear.

Block 3 Deactivates the motion used to retract the landing gear.

Block 4 Activates the motion which defines the extension of the


landing gear.

Block 5 Simulates the model for the extension of the landing gear.

The Stop command is used to stop the simulation at the time set in the last Simulate block.

Note: A template can be used either to add modeling entities to the solver deck, such
as joints, markers, and so on, that may not be supported by MotionView, or command
entities such as simulation parameters, activation and deactivation, and so on. The
MotionSolve XML is divided into two sections.
Model Section All model elements are defined. To write to this section
from the template, for Type select Write text to
Solver input deck.

Command Section Commands for the solver simulation are defined. To


write to this section from the template, for Type select
Write text to Solver command file.

Simulating and Animating the Model


In this step, run the model to simulate the retraction and extension of the main landing gear model and
animate it.

1. From the Run panel, specify the file name as MLG_Simulation.xml and click Run.
2. Once the solution is complete, close the HyperWorks Solver View window.
3. Click Animate and review the animation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.37

Phase 3
In this phase, you will create output requests and re-run the model to measure the Angular
Displacement and Angular Velocity of the landing gear.

Creating Output Requests and Rerunning the Model


In this phase, you will create output requests and re-run the model to measure the Angular
Displacement and Angular Velocity of the landing gear.

1. From the Project Browser, right-click on Model and select Add > General MDL Entity >
Outputs (or right-click Outputs , from the toolbar).

2. Create an output request. From the Outputs panel:


a) Set Type to Displacement and Entity.
b) Use the drop-down menu to select the Joint collector.
c) For the Joint, select the Revolute Joint between the Main LG Cylinder and Aircraft-5,
MLG_Ac_Rev.
3. Create another output request to measure the velocity at the same joint as above.
4. Re-run the analysis with these output requests and plot the requested results from the generated
PLT file in HyperGraph.

Figure 35:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.38

Figure 36:

5. Save your model and exit your HyperWorks session.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.39

MV-1035: Importing CAD or FE into MotionView


In this tutorial, you will learn about an important modeling approach: Building an MBD model from CAD
data.

In this tutorial, you will learn to:


• Import a CAD assembly into MotionView.
• Import a CSV file to create Points
• Create an MBD model using the imported data.

The Import CAD or FE utility in MotionView allows you to import CAD or FE assemblies. CAD formats
include CATIA, Parasolid, Pro E, STEP, JT, SolidWorks and Unigraphics. FE formats include HyperMesh,
OptiStruct, and Nastran.

CAD or FE assemblies can be imported into MotionView as graphics only to be associated with existing
bodies, or as new bodies with calculated mass and inertia properties along with graphics.

The multibody aspects of any CAD assembly that can be imported in MotionView are:
• Component Mass
• Component Moments of Inertia
• Component Center of Gravity Location
• Component Graphics

The CAD import utility calls HyperMesh in the background to write out a graphic file (*.h3d) which holds
the geometry information in a tessellated form. While importing CAD or FE to create new bodies with
mass and inertia, the utility uses HyperMesh to calculate mass, inertia and CG location.

In the following exercise, you will import a CAD assembly into MotionView, simplify the model from a
multibody analysis point of view, and define constraints, model inputs and model outputs.

Please copy all of the files from the mbd_modeling\automation\CAD folder into your <working
directory>.

Loading the CAD file into MotionView


In this step, the focus is on understanding the process of import and model simplification.

1. Launch a new MotionView session by clicking

2. From the menu bar, select File > Import > Geometry
Or

Click Import Geometry , on the Standard toolbar.

The Import CAD or FE dialog is displayed.


3. Under Import Options, select Import CAD or Finite Element Model With Mass and Inertias.
4. From the Input File pull-down menu, select STEP.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.40

5. Click to select the STEP file.

6. Select the file Front_Assembly.step from your working directory.


7. Click Open.
The Output Graphic File field is automatically filled with Front_Assembly_graphic.h3d as the H3D
filename.
8. Click the plus button next to MDL Options and review the various options.

Figure 37:

Note: The MDL Options allow for flexibility while importing. The CAD file can be
imported either in an existing system/assembly or a new system can be created

9. For this exercise, accept the defaults.


10. Review the options under Meshing Options for Surface Data.

Figure 38:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.41

Note: This section helps control the size of mesh (or tessellation). When the MBD
model being created is used to solve non-contact problems, use the default option
under Allow HyperMesh to specify mesh options. The Launch HyperMesh to create
MDL points option allows you to select nodes in HyperMesh which can be imported
into MotionView as MDL points. This is not needed for this tutorial since you will be
creating these additional points using a macro. For models that involves contacts,
it is recommended to use Control mesh coarseness for contacts. The Interactive
mesh (launches HyperMesh) option can be used to mesh the surfaces manually. This
is particularly useful when a finer mesh may be needed, such as in case of contact
problems, to obtain better results.

11. Click the plus button next to Locator Points (must be in source reference frame) and review the
options.

Figure 39:

Note: The Locator Points options can be used in cases where the CAD model being
imported is not in the same coordinate system as the MBD model in MotionView.
This option gives you control to specify three nodes or coordinates on the source
graphic which can then be used to orient using three points in MotionView after it's
imported. This option is not needed for tutorial as the imported graphic is in the
required position.

12. Select None.


13. Click OK.
The Import CAD dialog is displayed.

Note: This dialog helps to generate mass and inertia information. The table displays
different bodies or components being imported along with the volume and mass
information based on a default density of 7.83e-6. The density value can be modified
for each of the components. Alternatively, a CAD summary file can be used to extract
mass/inertia

14. Set Input file length to Millimeter.


15. Under Component, select Wheel_body1. In the Apply density to selected components field,
change the value of the density to 8.5e-7 and click Apply.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.42

Figure 40: Import CAD Dialog

16. Leave the default value of the density for the other components. Click OK.
If the import into MotionView is successful, the message "Translating/Importing the file
succeeded!" is displayed in the message log.
17. Clear the message log.
The body, along with the associated graphics, is displayed in the modeling window.

Note: The Extract mass/inertia data from CAD summary file option can be used only
for CATIA summary file. Currently, summary files from other CAD packages are not
supported under this option.

Consolidating and Renaming the Suspension Assembly


Bodies
There are three bodies with their names prefixed with Strut_rod. These bodies in reality are joined
together and hence can be represented as one body. Having these bodies separate increases the
complexity of the model, and you are not studying their interactions with each other, so the bodies will
merge into one.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.43

1. In the Project Browser, select these bodies: Strut_rod_1_body1, Strut_rod_body1 and


Strut_rod_body2. Right-click to bring up the context menu.

Figure 41:

2. Select Merge Bodies. This option is used to merge two or more bodies into a single body.
3. From the Merge Bodies dialog, enter Strut_rod as the label and b_Strut_rod as variable name.
Click OK.

The three selected bodies are deleted and replaced by a new body with the label and variable
names as entered previously. The mass and inertia values of this body are equivalent to the
effective mass and inertia of the bodies being replaced.

Figure 42:

4. Repeat steps 1 to 3 for merging the bodies: Strut_tube_1_body1 and Strut_tube_body1.


Enter the label as Strut_tube and variable name as b_Strut_tube for the new body to be
created.
5. From the Project Browser, select Wheel_body1 (Wheel part) .
6. Press F2 or right-click on Wheel_body1 and select Rename.
7. Change the label of the selected body to Wheel.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.44

8. Similarly, rename the following parts:

S. No Original Label New Label

1 Wheel_Hub_body1 Wheel_Hub

2 Lower_Control_Arm_body1 Lower_Control_Arm

3 Axle_Shaft_body1 Axle_Shaft

9. Save the model as front_susp.mdl.

Figure 43:

Notes on the Merge Bodies option:


• Mass and inertia of the newly created body upon Merge will be equal to the effective mass and
inertias of the bodies being merged.
• A new CG point is created at the effective CG location of the bodies being merged.
• Pair bodies cannot be merged.
• The Merge option works only within same container (System/Assembly/Analysis). Merging bodies
which belong to different container entities is not supported. The context menu item will not appear
in these cases.
• If the bodies that are being merged are referred to in expressions, post Merge these expressions
need to be corrected to point to the newly created body.
• Graphics that belong to bodies being merged are automatically resolved to the new body.
• Joints, bushings etc. that are associated with the bodies being merged if any, are automatically
resolved to the new body.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.45

Creating Points
After creating the bodies, additional points are needed that will be used to specify joint locations and
joint orientations. These points can be created using the macros available in the Macros menu.

1. From the Macros menu, select Create Points > Using Coordinates or click Create points
using Coordinates .

Figure 44:

2. Click to load a point table file.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.46

Figure 45:

3. Select the file suspension_points.csv from your working directory.


4. Click Open.
All the point coordinates in the CSV file are imported into the utility.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.47

Figure 46:

5. Specify Varname prefix as p_susp.


6. Click OK.
The points are added to the model. These extra points will be used for defining joints, orientations
and other model inputs.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.48

Note: To use this macro import option, you have to create the *.csv file in the format
shown below:

Figure 47:

1st Column - X coordinates.

2nd Column - Y coordinates.

3rd Column - Z coordinates.

7. Save the model.

Creating Joints and Spring Damper


In this step, you will add the joints to connect the bodies and a spring damper between Strut tube and
Strut rod.

1. From the Project Browser, right-click Model and select Add > Constraint > Joint (or right-click
Joints from the toolbar).
The Add Joint or JointPair dialog is displayed.
2. Specify the Label and Variable as Wheel Spindle RJ and j_whl_spindle_revj, respectively.
3. For Type, select Revolute Joint.
4. Click OK.
5. Make the following selections:
a) For Body1 of the joint, specify Wheel.
b) For Body2, specify Wheel_Hub.
c) For Origin, specify Point7. (Point around the Wheel center).
d) For Axis, specify Point19. (Point around Axle Shaft center).

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.49

Figure 48:

6. Add the rest of the joints of the model using the table below:

S.NoLabel Type Body 1 Body 2 Origin(s) Orientation Ref. 1 Ref. 2


Method

1 Strut Fixed Joint Wheel_Hub Strut_rod Point8


Hub Fix

2 Strut Translation Strut_rod Strut_tube Point23 Axis(Pt) Point9


Trans Joint

3 Strut Universal Strut_tube Ground Point9 Shaft(Pt) Point23 Global


Tube Joint Body Shaft(Vect) X
Ground
UJ

4 Axle Fixed Joint Axle_Shaft Wheel_Hub Point19


Hub Fix

5 Hub Ball Joint Lower_Control Wheel_Hub Point3


Control Arm
Arm
Ball

6 Control Revolute Lower_Control Ground Point1 Axis(Pt) Point2


Arm Joint Arm Body
Ground
Rev

7. From the Project Browser, right-click Model and select Add > Force Entity > Spring Dampers
(or right-click Spring damper icon from the toolbar).

8. Specify the Label and Variable as Strut-SpringDamper and sd_strut, respectively.


9. Check Create explicit graphics check-box to create an explicit graphic for the spring damper
entity.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.50

10. Click OK.


11. For Body1 and Body2, specify Strut_tube and Strut_rod, respectively.
12. For Point1 and Point2, specify Point9 and Point0, respectively.
13. Click the Properties tab and specify a stiffness (K linear) of 10 and damping (C linear) of 0.1.
14. Save the model.

Adding a Jack to the Model


Next, add a jack to this model and use the jack exercise the wheel through a vertical motion.
1. From the Project Browser, right-click Model and select Add > Reference Entity > Body (or
right-click Bodies from the toolbar).

2. Add a body with Label and Variable as Jack and b_jack, respectively.
3. Click the body Properties tab and specify the Mass and the three principle inertia values of the
body as 0.01, 100, 100, and 100, respectively.
4. Click the CM Coordinates tab and select the Use CM Coordsys check box.
5. Pick Point10 (bottom of wheel body) as the CM Origin point for the jack body.
6. From the Project Browser, right-click Model and select Add > Reference Entity > Graphic (or
right-click Graphics from the toolbar) to add a graphic.

7. Specify the Label of the graphic as Jack Plate and select the Type as Cylinder from the drop-
down menu.
8. Accept the default variable.
9. From the Connectivity tab, select the Parent Body as Jack.
10. Pick Point10 as the Origin. For Direction, toggle to Vector and select Global Z.
11. Click the Properties tab. Specify a value of -30 in the field next to it.
12. Specify a value of 250 for Radius 1.
Notice that the Radius 2 field is updated with the same value as Radius 1.
13. From the Project Browser, right-click Model and select Add > Constraint > Joint (or right-click
Joints from the toolbar).

14. Specify the Label and Variable as Jack Wheel Inplane and j_jack_wheel, respectively.
15. For Type, select Inplane Joint from the drop-down menu.
16. Click OK.
17. From the Connectivity tab, select Wheel as Body1, select Jack as Body2.
18. Select Point10 as Origin and Vector Global Z as Normal.
19. Add another joint and specify the Label and Variable as Jack Ground Trans and j_jack_grnd,
respectively.
20. For Type, select Translational Joint.
21. Click OK.
22. From the Connectivity tab, select Jack as Body1, Ground Body as Body2.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.51

23. Pick Point10 as Origin and Vector Global Z as the Alignment Axis.
All the joints required to complete the model are now in place.
24. Save the model.

Figure 49: Front suspension

Specifying Motion Inputs and Running the Model in


MotionSolve
In this step, you will create a motion that is applied to the jack and solve the model.

1. From the Project Browser, right-click Model and select Add > Constraint > Motion (or right-
click Motion from the toolbar) to add a motion.

2. For Label, specify Jack Motion. For Variable, specify mot_jack.


3. From the Connectivity tab, select Jack Ground Trans (the translation joint between Jack and
Ground Body) as the Joint.
4. From the Properties tab, change the property type to Expression from the pull-down menu. Type
in the expression `50*sin(TIME)` as the displacement Motion expression.
5. Add another motion to arrest the free spinning of the wheel. Add a motion and specify the Label
and Variable name as Wheel Spindle and mot_wheel, respectively.
6. From the Connectivity tab, select Wheel Spindle RJ as the Joint.
7. From the Properties tab, verify that the value of the Motion is 0.0.
This motion of 0.0 radians keeps the Wheel body from spinning freely about its axis.
8. Save the model.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.52

9. Click Check Model . In the Message Log that is displayed, verify that there are no warnings or
errors. Clear the message log.
10. Go to the Run panel .

11. Specify a name for the MotionSolve input XML file by clicking Save and run current model .

12. From the Simulation type drop-down menu, select Static+Transient.


13. Click Run.
14. Once the run is complete, click Animate to view the animation of the simulation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.53

MV-1051: Understanding Sequential Simulation


In this tutorial, you will learn how to build a model with sensor elements to capture the state of a
body, use the sensor signal to activate some joints and deactivate others, and carry out a sequential
simulation.

Sequential Simulation allows you to write simulation instructions to change the model, modify the solver
settings and submit analyses.

This tutorials covers the following topics:


• Fixed joint definition between non-coinciding points using marker definitions.
• Using a sensor to activate the joint when two markers coincide during simulation.
• Using Templex statements to:
◦ Deactivate a fixed joint when markers are non-coincident.
◦ Activate a fixed joint when markers coincide.
◦ Simulate until t = 5.00 seconds.

Note: Copy all of the files located in the mbd_modeling\interactive


\sequential_simulation folder to your <working directory>.

Creating Joints, Markers and Sensors


1. Start a new MotionView session.
2. From the Standard toolbar, click Open Model .

OR

From the File menu, select Open > Model to open the model Sequential_simulation.mdl.

The model contains two bodies, namely a slider and a picker. You need to create markers, joints,
and a sensor as well as use Templex statements to perform a sequential simulation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.54

Figure 50:

3. From the Project Browser, right-click on Model and select Add > Constraint > Joint (or right-
click Joints from the toolbar).

4. Under Type, select Translational Joint. Label the joint slider trans.
5. Make the following selections:
a) For Body 1, select slider.
b) For Body 2, select Ground Body.
c) For Origin, select slider cg.
d) Define the Alignment axis using the point slider end.

Figure 51:

6. Add another joint. For Type, select Fixed Joint and label the joint picker rest fix.
7. Make the following selections: s
a) For Body 1, select picker.
b) For Body 2, select Ground Body.
c) For Origin, select part fix.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.55

This joint will be deactivated when the slider body coincides with the picker body during
simulation.

Figure 52:

When you create a fixed joint between the slider and the picker and they come in contact, you
need to define two markers which are initially not coincident, but coincide during the course of
simulation. Creating a joint based on markers must be done using Templex, as it is not possible to
create it from the user interface.
8. From the Project Browser, right-click Model and select Add Reference Entity > Marker (or
right-click Marker from the toolbar). Label it Marker Slider Track and set the properties as
shown in the image below:

Figure 53:

9. Similarly, create another marker with the label Marker Picker Track and set the properties of
the markers as shown in the image below:

Figure 54:

10. From the Project Browser, right-click Model and select Add Control Entity > Sensor (or right-
click Sensor from the toolbar) to add a new sensor.

11. From the Signal field, select the type as Expression and enter the following expression:

`DX({the_model.m_0.idstring},{the_model.m_1.idstring})`

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.56

12. In the Compare to field, enter 0.0010 for the Value and 0.0010 for Error. Set Respond if to Signal
is greater than VALUE - ERROR.
13. In the Response field, select Return to Command File.
This directs the solver to look into the template for further instruction on how to proceed once the
signal is attained.
14. From the Project Browser, right-click on Model and select Add Constraint > Motion (or right-
click Motion from the toolbar. Set the properties as shown in the figure below.

Figure 55:

Figure 56:

Creating a Fixed Joint Between Two Non-coincident


Markers Using Templex
1. To create a fixed joint between the slider and picker that is activated once the distance between
the slider and picker is zero, from the Project Browser, right-click on Model and select Add
General MDL Entity > Template (or right-click Template from the toolbar).

2. Label it Fixed Joint Defn. For Type, select Write text to solver input deck. Enter the
following commands as they are listed below in the same order.

<Constraint_Joint
id = "5000"
type = "FIXED"
i_marker_id = "{the_model.m_0.idstring}"
j_marker_id = "{the_model.m_1.idstring}"
/>

The panel should look like this:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.57

Figure 57:

Creating a Template to Define the Sequential Simulation


In this step, you will write a template to do the following:
• Set the type of Output files to be written after the simulation.
• Deactivate Joint between Slider and Picker for the initial simulation.
• Perform a transient analysis for 3.5 seconds.
• Activate Joint between Slider and Picker.
• Deactivate Joint between Picker and Ground.
• Deactivate the Sensor Element.
• Run a transient analysis for 5 seconds.

1. From the Project Browser, right-click on Model and select Add General MDL Entity > Template
(or right-click Template from the toolbar).

2. Set the Type as Write text to solver command file.


3. Type the following commands as listed below.

<ResOutput
plt_angle = "YAW_PITCH_ROLL"
/>
<ResOutput
mrf_file = "TRUE"
/>
<ResOutput
plt_file = "TRUE"
/>
<H3DOutput
switch_on = "TRUE"
increment = "1"
/>
<ResOutput
abf_file = "TRUE"
/>
<Deactivate
element_type = "JOINT"
element_id = "5000"
/>
<Simulate
analysis_type = "Transient"
end_time = "3.5"
print_interval = "0.01"
/>

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.58

<Deactivate
element_type = "JOINT"
element_id = "{the_model.j_1.idstring}"
/>
<Deactivate
element_type = "SENSOR"
element_id = "{the_model.sen_0.idstring}"
/>
<Activate
element_type = "JOINT"
element_id = "5000"
/>
<Simulate
analysis_type = "Transient"
end_time = "5."
print_interval = "0.01"
/>
<Stop/>

Running the Simulation and Animating the Results


1. Click Run Solver , and activate the Export MDL snapshot check box.
This will save your model file and export the solver data.
2. Click the Save and run current model and enter a name for the solver run file.
This will save the model in the current state to run_xml_snapshot.mdl, where run_xml is the
base name of the solver run file being provided in the next step.
3. Set End time as 5 and the Print interval as 0.01.
4. Click Simulation Settings. In the pop-up dialog, from the Transient tab, select DSTIFF for the
Integrator type. Click Close.
5. From the Main tab, click Run.
6. Once the solver procedure is complete, the Animate button on the Main tab is activated. Click
Animate to animate the model. Click to start the animation and to stop the animation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Rigid Body Dynamics p.59

Figure 58:

Proprietary Information of Altair Engineering


Flexible Body Dynamics 2
Flexible Body Dynamics

This chapter covers the following:

• MV-2000: Introduction to Flexible Bodies (p. 61)


• MV-2010: Flexbody Generation using Flex Prep and OptiStruct (p. 64)
• MV-2020: Using Flexbodies in MBD Models (p. 79)
• MV-2021: Simulating an Automotive Door Closure Event (p. 86)
• MV-2035: Solving Flexbody ADM/ACF in MotionSolve (p. 95)
MotionSolve Tutorials
Flexible Body Dynamics p.61

MV-2000: Introduction to Flexible Bodies


In this tutorial, you will learn about the fundamentals of flexible bodies.

Why Flexible Bodies?


• Traditional multibody dynamic (MBD) analyses involve the simulation of rigid body systems under
the application of forces and/or motions.
• In the real world, any continuous medium deforms under the application of force. Rigid body
simulations do not capture such deformations and this may lead to inaccurate results. Inclusion of
flexible bodies in MBD simulations accounts for flexibility.

MotionView provides the modeling tools required to incorporate flexible bodies in your MBD model.
Flexible MBD simulations allow you to:
• Capture body deformation effects in simulations.
• Acquire greater accuracy in load predictions.
• Study stress distribution in the flexible body.
• Perform fatigue analysis.

However, flexible bodies introduce an additional set of equations in the system and consequently, have
a higher computational cost as compared to rigid body systems.

What is a Flexible Body?


• Finite element models have very high number of degrees of freedom. It is hard for MBD solvers to
handle these.
• A flexible body is a modal representation of a finite element model. The finite element model is
reduced to very few modal degrees of freedom.
• The nodal displacement in physical coordinates is represented as a linear combination of a small
number of modal coordinates.
(1)

where:

is nodal displacements vector

is modal matrix

is matrix of modal participation factors or modal coordinates to be determined by the MBD


analysis.
• MotionView uses the process of Component Mode Synthesis(CMS) to reduce a finite element model
to set of orthogonal mode shapes.
Two types of CMS methods are supported in OptiStruct:
◦ Craig Bampton
◦ Craig Chang

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.62

Note: At the end of this tutorial, links to online help direct you to where you can learn more
about the theory behind flexible bodies and CMS method.

Flexbody Generation Using OptiStruct


There are two ways you can generate flexible bodies using OptiStruct:
1. Using the FlexPrep utility in MotionView.
2. Manually editing the input deck.

Using the FlexPrep Utility in the MotionView Interface


FlexPrep is a MotionView utility which allows you to generate a flexible body from a finite element
mesh. It also allows translation between various flexbody formats. These translations are
discussed in the next section, Flexbody Translation Using Flexprep

Figure 59:

Using the FlexPrep GUI, you can:


• Generate a flexible body from any OptiStruct or Nastran bulk data file.
• Create RBE2 spiders.
• Request for stresses and strains.
• Create OptiStruct preparation file which can be used in the file size reduction of a flexible
body.
Manually Editing the Input Deck
You can manually insert certain cards in the OptiStruct input deck to run the Component Mode
Synthesis routine. These cards allow file size reduction of a flexbody. This helps in faster pre/post-
processing and overall better efficiency of the process.

Note: You can manually edit the preparation file generated by FlexPrep to reduce the
size of the flexible body H3D.

By modifying the input deck, you can:


• Request only the skin elements of the flexbody to display .

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.63

• Request stress and strain information for a selected set of elements.


• Use released degrees of freedom for the interface nodes.

The following data is included in a flexbody H3D file:


1. Nodal positions.
2. Element connectivity.
3. Eigenvalues of all modes.
4. Inertia invariants (optional).
5. Nodal mass.
6. Nodal inertia (optional).
7. Translational displacement mode shapes.
8. Rotational displacement mode shapes.
9. Interface node IDs (optional).
10. Element stress/strain tensors (optional).
11. Global (rigid) inertia properties (optional).

Flexprep.exe always generates points 1, 2, 3, 4, 5, 6, 7, 8, 9, and 11 and writes them to the


H3D file. Points 4, 6, 9, and 11 are not strictly required.

Flexbody Translation Using FlexPrep


FlexPrep allows you to translate a flexbody from one format to another. Using FlexPrep, you can:
1. Mirror an existing flexible body H3D file about a plane.
2. Translate an MNF file to an Altair H3D file.
3. Translate an H3D file to an MTX file.
4. Translate an Altair H3D file to MNF file.
5. Translate an PCH file to an Altair H3D file.
6. Translate an Altair H3D file to DADS DFD file.

Once the flexbody H3D is created, it can be used in the MBD model and the model can be submitted to
either MotionSolve or ADAMS. This is covered in the following tutorials.

Stress Recovery and Fatigue Calculations


Stress recovery and fatigue calculations are done in two stages during the MBD analysis:
• For stress recovery in the pre-processing stage, element stresses are obtained using the
orthogonalized displacement modes. Every displacement mode is associated with a particular
number of stress modes, each representing a basic stress tensor. This particular number depends
on the type of elements used in the flexible body, for example, one, two, or three-dimensional
elements. These stress modes are then saved to the H3D file.
• In the post-processing stage, the actual stress recovery and fatigue index calculations are carried
out. The modal participation factors obtained from the simulation are used to linearly superimpose
the stress modes to come up with the stress tensor for each element. This stress tensor is used to
calculate the other components of stresses: Principal, Shear, or von Mises.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.64

MV-2010: Flexbody Generation using Flex Prep and


OptiStruct
In this tutorial, you will learn the fundamentals of flexbody generation, using FlexBodyPrep, MotionView,
and OptiStruct.

Tutorial Objectives
• Get familiar with the flexible body generation techniques available in MotionView and OptiStruct.
• Be introduced to all available features in FlexBodyPrep for flexbody generation.
• Be introduced to the various options available in OptiStruct to reduce the size of the H3D file.

There are two ways you can generate the flexible bodies for MBD simulation in HyperWorks:
1. Using FlexPrep utility in the MotionView interface.
2. Manually editing the input deck (*.fem) for OptiStruct solver.

Introduction to Flex Prep


Flex Prep is a tool in MotionView which is used to:
• Create flexbody H3D files using OptiStruct.
• Create flexbody H3D files from ADAMS MNF and Nastran PCH.
• Translate flexbody H3D files to ADAMS MTX, Altair H3D (mirrored), ADAMS MNF, DADS FDF, and
nCode FES.

Exercise: Creating and Simulating Flexible LCA


The previous exercise discussed flexbody generation using FlexPrep. It is possible to generate flexbodies
directly from OptiStruct by editing the input FEM file and adding the cards that invoke the flexbody
generation from OptiStruct. Steps 1 to 4 below discuss these cards in brief.

In this exercise, you will generate a flexible body for a left Lower Control Arm of a front SLA suspension.
The input file is a pre-prepared .fem file (sla_flex_left.fem) which has finite element modeling
information for the LCA (elements and nodes). Interface nodes for the flexible body are:
• The center nodes at the front and rear bushing mounts
• Location where the spring is attached
• The center of the lower ball joint attaching to the knuckle.

In the given input file, interface nodes are already created at the center of the bushing mounts and the
spring attachment location. You will create the interface node at the lower ball joint and its connection
to the LCA in the exercise.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.65

Using FlexBodyPrep
Once you provide the required input, Flex Prep generates an input deck (_prp.fem) for the OptiStruct
solver with all the required cards, and then it calls OptiStruct to run the job. Please refer to MV-2000:
Introduction to Flexible Bodies to understand all the inputs and process.

Note: Copy the sla_flex_left.fem file, located in the mbd_modeling\flexbodies folder,


to your working directory before proceeding further.

1. Open a new MotionView session.


2. From the Flex Tools menu, select Flex Prep.
3. Select OptiStruct Flexbody generation.
4. From the pull down menu, pick the option Create Optistruct prp (preparation) file and
generate the h3d flexbody.
5. Click the file browser icon next to Select Bulk Data file and select the input bulk data file
sla_flex_left.fem from your working directory.

Note: You can use any OptiStruct (FEM) or Nastran (.nas, .dat, .bdf) bulk data files.

6. For Save the *.h3d file as, enter the name of the output H3D file as sla_flex_left.h3d in your
<working directory>.
7. For the Component mode synthesis type, select Craig-Bampton to perform Craig-Bampton
component mode synthesis.
8. In the Specify Interface Node List field, enter 10001+10002+10003.

Note: If the interface node IDs are within a range, you can specify as 10001:10003.

The interface nodes are the nodes where constraints or forces are applied in the MBD analysis.
9. For the Cutoff type and value, select Highest Mode # and enter a value of 10.
Limiting Modal Information

MotionView allows you to specify a limit on the modal information contained in your H3D file. Two
methods are available to set these limits.
• Specify a maximum number of Eigen modes for which modal data is included in your H3D
• Specify an upper cut-off frequency for the Eigen modes. When a cut-off frequency is specified,
normal modes analysis can be performed using one of two algorithms: Lanczos or the automated
multi-level sub-structuring eigenvalue solution, AMSES.

The first method is used in this exercise.


10. Click Additional Options to bring up the dialog.
a) Activate Perform stress recovery.
With this option set, Flex Prep puts relevant cards in the OptiStruct input deck to calculate
the modal stresses while processing your bulk data file.
b) Activate Perform strain recovery.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.66

With this option set, Flex Prep puts relevant cards in the OptiStruct input deck to calculate
the modal strains while processing your bulk data file.

Note: The Create Recovery H3D option is useful in fatigue analysis. A smaller
flex H3D file is generated that contains the minimum amount of information
required for MBD simulation in MotionSolve. A larger file, *_recov.h3d, is
also generated that contains additional information for displacement, velocity,
acceleration, stress, and strain. Refer to Recovering MBD Analysis Results in
OptiStruct to learn more about using this method for fatigue analysis.

11. Under Specify units in bulk data file, select the following:

Mass Units Kilogram

Length Millimeter

Force Newton

Time Second

Note: HyperMesh is unit-less and you need to make sure to use consistent units, or
the flexbody generated will have incorrect modal frequencies. In the given input file,
the density used is in unit kg/mm^3. Hence, you will use kilogram as the mass unit in
this exercise.

Generally, FE analysts using mm-N-sec as Length, Force and Time units need to specify mass as
a derived unit as N-sec^2/mm (equivalent to tonne/mm^3/MEGAGRAMS). If the model that you
use in the future may have such units, use MEGAGRAMS for the mass units in FlexBodyPrep.

There are three RBE2 spiders already in sla_flex_left.fem. The fourth RBE2 spider should be
created using the Create RBE2 Spiders option explained in the next step.

Creating RBE2 Spiders


If you have a circular hole in your finite element (FE) model and need to use the center of the hole
as the interface node, you need to transfer the loads from the center node to the peripheral nodes.
This feature allows to you create RBE2 spiders at the hole in the FE model to transfer forces from the
interface node to peripheral nodes of the hole.

Note: If the finite element model definition is complete (all interface nodes and connections
already exist), this step is not required.

An RBE2 is a rigid element whose independent degrees of freedom are specified at a single grid point
and whose dependent degrees of freedom are specified at an arbitrary number of grid points. This is
usually used to model relatively stiff connections.

1. Click Create RBE2 Spider.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.67

HyperMesh is invoked. The input file, sla_flex_left.fem, is imported into HyperMesh and the FE
model is displayed in the modeling window of the screen.
2. If HyperMesh asks for a user profile, click Cancel and go to the Utility menu in the browser area.

Figure 60:

The tab area displays a Utility tab with a user-defined page with three buttons (steps 1 to 3).
3. If the user defined page with the three buttons is not displayed, follow these steps to view it:
a) From the View menu, select Utility menu.
b) From the Utility menu, click User , located at the bottom of the page.
4. Click Info to view the details regarding the procedure to create RBE2 spiders.

Figure 61:

5. Zoom into the area of the lower ball joint location as shown in the image below:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.68

Figure 62:

6. Click Step 2: Superspider to create one spider at a time.


7. Select a node on the periphery of the hole and click Proceed.
The script would create a RBE2 Spider automatically as shown in image below:

Figure 63:

8. Click Step 3: Save and Close, which will save the modified file and automatically grab the ID of
the center (interface) node. Give a new name to the file sla_flex_left_complete.fem and check
to see if the interface node ID is added to the flex prep.
The new interface node IDs are automatically added to the interface node list in FlexBodyPrep as
displayed in the image below:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.69

Figure 64:

9. Click OK to launch OptiStruct in a command window.


Based on the inputs provided here, FlexBodyPrep creates a new FEM file by appending _prp to the
input filename and submits it to OptiStruct. In this case, sla_flex_left_complete_prp.fem is
created.
Messages from the FlexBodyPrep translator are displayed in the Output window. Check the status
of the OptiStruct run and look for any error messages there.
10. Click OK in the Output window to close.

Viewing the Model and Verifying Results


In this exercise, you will verify your work in Step 1 by viewing the flexible control arm in HyperView.

1. From the Select window mode drop-down menu on the toolbar, select HyperView.
The Load model and results panel is displayed.
2. Click the Load model file browser and select the H3D flex file, <working directory>/
sla_flex_left.h3d.
HyperView automatically updates the Load results file field with the same filename. The flexible
arm model and its modal results are contained in the H3D flex file you created using the Flexprep
wizard.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.70

Figure 65: Load Model and Results Fields

3. Click Apply to load the model into the HyperView.

Figure 66: Flexible LCA Model

4. Click Select animation mode and select Set Transient Animation Mode .

5. Animate the results by clicking Start Animation .


HyperView sequentially animates the flexible control arm through its mode shapes. The mode
number and its frequency are displayed at the top-right of the window.
6. Stop the cycling of modes by clicking Pause Animation .

7. Click Select animation mode arrow and from the drop-down list, select Set Modal Animation
Mode.
8. To animate a particular mode shape, go to the Results Browser and change the mode from
Undeformed Model Frame to Mode 7.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.71

Figure 67: Selecting Specific Mode using the Simulation Selector Panel

Note: Although there is not a direct correlation possible, you can recognize the first
six modes as rigid body modes due to near zero frequency values. If there are more
than six modes that are near zero, it generally indicates a model integrity problem
(one or more elements are free and not connected to other elements).

9. Click Animation to animate the selected mode.

Figure 68:

You can similarly animate other modes of the flexible body.


10. Toggle the animation on and off by clicking the same button.
11. Click Contour to view the stresses on the flexbody.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.72

12. From the Result type drop-down menu, select Stress and vonMises. For Entity with layers, select
Z1 as shown in image below:

Figure 69:

13. Click Apply to display the contours and the legend in the modeling window.

Figure 70: vonMises Stress Contours Displayed on the Model

The above exercise demonstrated generating a flexible body using MotionView. Flexible bodies can also
be generated by using HyperMesh and OptiStruct. To learn more, you can refer to tutorial OS-1930 -
Generating a Flexible Body for use in MotionSolve.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.73

Invoking FlexPrep in Batch Mode


The FlexPrep executable can also be invoked in batch mode.

To run the FlexPrep from the command line in Unix:

<install_path>/altair/scripts/flexprep

To run the FlexPrep from the command line in DOS:

<install_path>\io\translators\bin\<os>\flexprep.exe

where <os> is either win32 or win64.

The usage options and corresponding syntax is listed if the above command is given without any
arguments.

The sla_flex_left.h3d flexbody created in the earlier exercise is the lower control arm of a left front
SLA suspension. Now, we will create a symmetric flexible body for the right front SLA suspension by
invoking flex prep in batch mode.

Note: In this exercise, you will run the FlexPrep translator from the MS DOS prompt for the
Windows operating system. You may follow analogous steps for the Unix terminal.

1. From the Start menu, open an MS DOS prompt window.


2. Use the cd command to navigate to your working directory.
3. Enter the command to launch FlexPrep <install_path>\translators\flexprep.exe
4. Go through the usage options for running the FlexPrep translator in batch mode.
5. Enter the following command: <install_path>\io\translators\bin\<os>\flexprep.exe
sla_flex_left.h3d sla_flex_right.h3d -MIRROR_XZ
FlexPrep creates the mirrored lower control arm sla_flex_right.h3d

Exercise: Manual Methods to Reduce the Size of the


Flexbody
The previous exercise discussed flexbody generation using FlexPrep. It is possible to generate flexbodies
directly from OptiStruct by editing the input FEM file and adding the cards that invoke the flexbody
generation from OptiStruct. Steps 1 to 4 below discuss these cards briefly.

Understanding the OptiStruct Input File for Flexbody Generation


Open the file sla_flex_left_complete_prp.fem in any text editor.
The first few lines of the FEM file are given below with explanation for each line:
Line 1: SUBCASE 1

Line 2: OUTFILE, sla_flex_left

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.74

Line 3: CMSMETH 1

Line 4: STRESS=ALL

Line 5: STRAIN=ALL
Line 6: BEGIN BULK

Line 7: DTI, UNITS, 1, KG, N, MM, S

Line 8: PARAM COUPMASS -1


Line 9: PARAM CHECKEL YES

Line 10: CMSMETH, 1, CB, , 10

Line 11: ASET1, 123456, 10001

Line 12: ASET1, 123456, 10002

Line 13: ASET1, 123456, 10003

Line 14: ASET1, 123456, 10004

SET DATA FOLLOWS

BULK DATA FOLLOWS

A generalized input deck (FEM file) need the cards specified above to generate a flexbody from
OptiStruct. The definition of each line is as follows:

Line 1: SUBCASE - indicates the start of a new subcase definition.

Line 2: OUTFILE - used to specify a base name for the H3D file.

Line 3: CMSMETH - is the card defining the component mode synthesis solution method used to
generate flexbodies in OptiStruct.

Line 4: STRESS=ALL - use to specify that modal stresses are to be computed by OptiStruct for all the
elements in the model.

Line 5: STRAIN=ALL - use to specify that modal strain values are to be computed by OptiStruct for all
the elements in the model.

Line 6: BEGIN BULK - defines the start of FE entities in the model.

Line 7: DTI, UNITS - defines the units for the flexbody.

Line 8: PARAM COUPMASS -1 - defines values for parameters used by OptiStruct for the generation of a
flexbody. In this case, lumped mass matrix approach is used by OptiStruct for eigenvalue analysis.

Line 9: PARAM CHECKEL YES - parameter to perform element quality check before running the job.
Specifying NO makes the solver skip the element check. Elements with poor quality may lead to
inaccurate results.

Line 10: CMSMETH CB 10 - component mode synthesis method selected is Craig Brampton and 10
modes are requested.

Lines 11 to 14: ASET1 - defines the boundary degrees of freedom for the interface nodes.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.75

With these cards specified, OptiStruct generates a flexbody H3D file. The flexbody size can be large
based on the bulk data file, number of interface nodes, and modes and stress/strain details. It is
possible to reduce the size by using any of following methods:
• MODEL Set - Reduces the model information that is used for graphical display.
• STRESS/STRAIN Set - Reduces the number of elements on which stress or strain calculation is
requested.
• OUTLINE - Reduces the model information to display only boundary edges.
• Reduced DOF - Reduces the number of DOF that contribute to the flexible body information.
Modifying the Input Deck to Incorporate Stress/Strain Set, Model Set, Outline and Released DOF into
the Flexbody

In finite element modeling, nodes or elements can be grouped together to form a SET. These groups
can then be used in other modeling cards that can take the nodes and elements as inputs collectively.
In flexible body generation, the need to incorporate these sets in the OptiStruct input deck is:
• To reduce the size of the flexbody.
• To help increase the speed of the multibody pre-processing, simulation and animation.

Defining the Stress/Strain Set in OptiStruct


The cards STRESS and STRAIN specify the elements for which the stress and strain computations have
to be carried out during flexbody generation. Use this card if you are interested in viewing stress results
for the body in your analysis. If the objective of using a flexible body is to incorporate the flexibility of
the body and not calculate stresses, then not using this card drastically reduces the size of the H3D.

Syntax of the STRESS and STRAIN cards


STRESS=[setid|ALL|NONE]
STRAIN=[setid|ALL]

setid is the ID of the set of elements.

Alternatively, if ALL is specified, the stress/strain is calculated for all elements.

If NONE is specified, the stress is not calculated on any elements. (Not having the STRESS card has the
same effect).

In the FEM file that is opened, you can observe SET cards defined for nodes (keyword GRID) and
elements (keyword ELEM).
1. Modify the cards STRESS=ALL and STRAIN=ALL as STRESS=5 and STRAIN=5, respectively.
2. Modify the OUTFILE to read as OUTFILE, sla_flex_left_stress_set.
3. Save the file as sla_flex_left_stress_set.fem and close the file.
4. Generate the flexbody using FlexBodyPrep.
a) From the OptiStruct Flexbody Generation drop-down menu, select the option Create h3d
flexbody using pre-existing prp file.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.76

Note: You can use OptiStruct to generate the flexbody. To run OptiStruct from
the command prompt, type the following the working directory: <install>
\hwsolvers\bin\win32\Optistruct.bat sla_left_stress_strain_set.fem.

5. Start a new MotionView session and change the window type to HyperView.
6. Load in the H3D file sla_flex_left_stress_set.h3d generated by OptiStruct.
7. Go to the Contour panel to apply Stress and Strain contours.
You will see that only a few elements display the contours. These are the elements that were pre-
selected for stress and strain computations using the element set.

Defining the Model Set in OptiStruct


This card lets you control the display of elements of the flexbody in the H3D file while using the H3D file
during pre- and post-processing in MotionView.

Syntax of the MODEL card:


MODEL=setid|PLOTEL

Where MODEL is the OptiStruct card that determines the elements to be written to the result file (H3D).
setid is the ID of set that defines the element displayed.

The PLOTEL option will be discussed further in this tutorial

1. Open the FEM input deck sla_flex_left_stress_set.fem in a text editor.


2. Add the model card as MODEL=4 above the line STRESS=5.
3. Change the OUTFILE line to read as OUTFILE, sla_flex_left_model_set.
4. Save the file sla_flex_left_model_set.fem to your working directory and close the file.
5. Run the FEM deck in OptiStruct or you generate the flexbody using FlexBodyPrep.
a) From the OptiStruct Flexbody Generation drop-down menu, select the option Create h3d
flexbody using pre-existing prp file.
6. In HyperView, load the H3D file generated by OptiStruct.
You will see that only a part of the flexbody is displayed. Only those elements included in the set
that is used with the MODEL card are displayed here.

Using PLOTEL Elements in OptiStruct


The size of the flexbody can be greatly reduced by using PLOTEL elements in the OptiStruct input deck
for flexbody generation. To display only the edges of the flexbody in MotionView, PLOTEL elements can
be defined in the input deck and displayed using the MODEL card. PLOTEL is a one-dimensional dummy
element for use in display. This element does not contribute any mass or stiffness to the part.

Syntax of the PLOTEL element:

PLOTEL EID G1 G2

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.77

Where PLOTEL is the element type, EID is the element ID, G1 and G2 are the nodes used to define the
element. For example:

PLOTEL 8786 4698 1702

The FEM file that you are working with already contain PLOTEL elements.

The procedure to incorporate the PLOTEL feature is briefly explained here:


• You can use the features option in HyperMesh to generate the PLOTEL elements of the feature
edges of your model automatically. The features option is available on the Tool page in HyperMesh.
• The picture below shows a flexbody model with PLOTEL elements created with the features option:

Figure 71:

• Use the MODEL card and specify the PLOTEL option.


MODEL=PLOTEL (to skip writing rigid elements like RBE2 as part of plotel, use optional keyword
NORIGID)
• Save the FEM file and run it in OptiStruct to generate the flexbody that displays only the PLOTEL
elements.

1. Open the FEM deck sla_flex_left_model_set.fem, saved earlier in your working directory.
2. Replace the MODEL=4 by MODEL=PLOTEL.
Within the BULK DATA, you will be able to see the many PLOTEL elements.
3. Change the OUTFILE line to read as OUTFILE, sla_flex_left_plotel_set.
4. Save the file as sla_flex_left_plotel_set.fem.
5. Run the FEM deck in OptiStruct or you can generate the flexbody from FlexPrep.
a) From the OptiStruct Flexbody Generation drop-down menu, select the option Create h3d
flexbody using pre-existing prp file.
6. In HyperView, load the H3D file generated by OptiStruct.
You will see that the flexbody is shown only as lines or edges defined by the PLOTEL elements.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.78

Using the Released DOF Method for Interface Nodes in OptiStruct


The released DOF (degrees of freedom) feature enables you to free some degrees of freedom of the
interface nodes. If the appropriate DOF (corresponding DOF that are free in the MBD model) are
released for a particular interface node, the simulation is not affected in any way. Depending on the
kind of kinematic constraints in the model and the MBD simulation being carried out, you can release
the appropriate degrees of freedom at the interface nodes to reduce the size of the H3D file generated.

The ASET1 card is used define the boundary degrees of freedom of an interface node of a flexbody.

Syntax of the ASET1 card:

ASET1 C G1 or ASET1, C, G1

Where ASET1 is the card name, C is the DOF to be constrained, and G1 is the node ID. For example:

ASET1, 123456, 4927

This means that the interface node of ID 4927 will be constrained for all DOF, where 123456 represents
the three translational and three rotational nodes in that order. Thus, to release a DOF from the
interface node (for example, rotation about X), the C value will be 12356.

1. Modify the ASET1 card corresponding to interface node 10004 in the deck as follows:

ASET1, 123, 10004

2. Change OUTFILE to read as OUTFILE, sla_flex_left_rdof.


3. Save the file in your working directory as sla_flex_left_rdof.fem and close the file.
4. Run the FEM deck in OptiStruct or generate the flexbody from FlexPrep.
a) From the OptiStruct Flexbody generation drop-down menu, select the option Create h3d
flexbody using pre-existing prp file.
5. Check the size of the H3D file generated and you will notice a reduction in size; this is due to the
released DOF incorporated into the flexbody.
6. Compare the sizes of all the H3D files generated using the cards mentioned in this step to know
the reduction in file size.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.79

MV-2020: Using Flexbodies in MBD Models


In this tutorial, you will use the flexible bodies created in tutorial MV-2010 in an MBD model and solve
the model using MotionSolve.

Integrating the Flexbodies into your MBD Model


In this exercise, you will integrate the flexbodies into your MBD model.

1. From the MotionView menu bar, select Model > Assembly Wizard to bring up the wizard.
2. Use the criteria from the table below to assemble a front end half vehicle model.

Panel Selection

Model Type Front-end of the vehicle

Driveline Configuration Defaults <No driveline>

Primary Systems Front Suspension = Frnt. SLA susp (1 pc LCA)


and defaults for the rest

Steering Subsystems Steering Column = Steering column 1 (not for


abaqus) and Steering boost = None

Springs, Dampers, and Defaults


Stabars

Jounce/Rebound Bumpers Defaults

Label and Varname Defaults

Attachment Wizard Compliant = Yes; Defaults for the rest

Setting Up the Assembly Wizard

1. Ensure that you have selected Frnt. SLA susp (1 pc LCA) since the flexible bodies you have
created are for this suspension geometry.
2. From the MotionView menu bar, select Analysis > Task Wizard to display the wizard.
3. Load a Static Ride Analysis task from the Task Wizard - Front end tasks. Click Next and click
Finish.
The Vehicle Parameters form is displayed.
4. Click Finish.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.80

5. From the Project Browser, select Lwr control arm from the Bodies folder (located underneath the
FrntSLA Susp (1 pc.LCA) system).
The Bodies panel is displayed.
6. Under the Properties tab for the Lwr control arm-left, deselect the symmetry check-box,
Symmetric properties.
The Remove Symmetry confirmation dialog is displayed.
7. Click Retain to retain the current values of properties of Lwr control arm-right.
8. Select the Flex Body (CMS) check box and click Yes to confirm both sides as deformable.

Figure 72:

Notice that the graphics of the rigid body lower control arm vanishes.
9. Using the file browser select the file sla_flex_left.h3d (created in earlier tutorial MV-2010)
from your working directory.
The H3D file field is populated automatically with the same path and the file name as the graphic
file you specified earlier.

Figure 73: Properties Panel

The flexible body drops into the right position.

Note: You need to specify the flexbody H3D file as the H3D file. Specify the same or
any other file as the graphic file.
Use of large flexbodies is becoming very common. For faster pre-processing, you can
use any graphic file for the display and use the flexbody H3D file to provide the data
to the solver. You can use the input FEM deck or the CAD file used for the flexbody
generation to generate a graphic H3D file using the CAD to H3D Conversion and
specify that file as the graphic file. This will make pre-processing a much more efficient
process.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.81

Relocating the Flexbody


The Locate button on the Properties panel is an optional step to relocate a flexible body if it is not
imported in the desired position. This may happen if the coordinate system used while creating the
flexible body in the original FEM model does not match the MBD model coordinate system. However, if
your flexible body is already in the desired position, you can skip this step.

1. Click Nodes.
The Nodes panel is displayed.

Figure 74:

The Nodes panel is used to resolve the flexbody's attachments with the vehicle model, since the
vehicle model is attached to the flexible body at these interface nodes.

This panel lists all markers of the connections (joints/forces) on the body which is now flexible.
These markers can interact with the flexible body only through a node. This panel is used to map
each of the markers to a node. The panel also displays the point coordinates of the marker origin
which are nothing but coordinates of a point entity that the connections are referring to.
2. Click Find All on the Nodes dialog to find nodes on the flexible body that are located closest to
the interface points on the vehicle model.
The Node ID column is populated with the interface node numbers for each row of connections.
Also, the node coordinate table is also populated along with the Offset with respect to the point
coordinates.
3. Observe a small offset for the Lwr ball jt-Marker J-left. It suggests a difference in the coordinate
values between the point at which the joint Lwr ball jt is defined and its corresponding location of
the interface node 10004. Click Align to move the point to the nodal coordinate position.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.82

Note: Many times there is a little offset between the flexible body interface node and
its corresponding point in the model. When you click Align, MotionView moves the
connection point in the model to the node location on the flexible body. This could
affect other entities that reference this point. Hence, this option should be used with
caution. Generally, it is common to have minor offsets (values between 0.001mm to
0.1mm). If the offset is more than the tolerance value, MotionView inserts a dummy
body between the flexible body and the nearest connection point. If the offset value is
too high, it could indicate an mismatch of the FE model information with respect to the
MBD model. In such an event, it is recommended to review the models and reconcile
the differences.

4. Close the Nodes dialog.


5. Click Modes.
The Modes panel is displayed. This option lets you select the modes that will be active during the
simulation. By default, the rigid body modes are deactivated. You can also change the damping
used for modes.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.83

Figure 75:

Please note that when selecting the modes, the simulation results may vary as you change the
modes to be included in the simulation.

Note: By default, for frequencies under 100Hz, 1% damping is used. For frequencies
greater than 100Hz and less than 1000Hz, 10% damping is used. Modes greater than
1000 Hz use critical damping. You can also give any initial conditions to the modes.

6. Click Close.
7. Repeat steps 1 through 5 to integrate the right side flexible body sla_flex_right.h3d (created in
MV-2010: Flexbody Generation using Flex Prep and OptiStruct) in your model.
Your model should look like the image below:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.84

Figure 76:

Reviewing the Properties of the FEM Model File


1. Click the FEM Inertia Props tab.
The following information is displayed:

Figure 77: Bodies Panel/FEM Inertia Props Tab

2. From the Tools menu, select Check Model to check your complete MBD model for errors.
3. From the Standard toolbar, click Save Model to save your model as an MDL file named
sla_flex.mdl.
4. Click Run on the toolbar and run the model with simulation type Quasi-Static, specifying the
filename as sla_flex_ride.xml.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.85

5. Once the run is complete, load the MotionSolve result file sla_flex_ride.h3d (located in your
working directory) in a HyperView window and view the animation of the run.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.86

MV-2021: Simulating an Automotive Door Closure


Event
In this tutorial, you will learn how to create flexible and rigid body models and simulate a door closure.

Tasks for this tutorial include:


• Use an FEM file to create a flexible body file.
• Use body data to create a rigid body model.
• Make the door flexible and use the flexbody file created in the model.
• Set up a door closure simulation.

Note: Copy the files metro_door.fem and car_body_graphics.hm, located in the


mbd_modeling\flexbodies folder, to your <working directory>.

Review the Finite Element Model for the Flexible Door


In this step, you will review the contents of the finite element (FE) model, which is the starting point for
creating a flexible body.

1. Import the model metro_door.fem into HyperMesh.


2. Click the Model Browser on the left of the modeling window and expand the model tree to review
all components, properties, and materials of the model.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.87

Figure 78:

The FEM model should have the following attributes:

• A decent, quality mesh on all components.


• The section properties are assigned to all components.
• All components refer to appropriate materials.
3. Identify the interface nodes of the flexible body. Check the following nodes by ID: 9751, 9750,
10090.
4. Export the FEM as metro_door_flex.fem for Flexbody Generation.

Generating the Flexbody using Flex Prep


In this step, you will use the FEM file created in Step 1 and use Flex Prep to generate a flexible body
H3D file. A pre-requisite for going through this step of the tutorial is an understanding of Flex Prep as
described in MV-2010: Flexbody Generation using Flex Prep and OptiStruct.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.88

1. In MotionView, from the FlexTools menu, select Flex Prep.


The FlexBodyPrep dialog is displayed.

Figure 79:

2. In the FlexBodyPrep dialog, enter the following information to generate the flexbody for building
the door closure model.

Figure 80: FlexPrep Utility with Data

3. Using the image above as a guide, for #2, Select Bulk Data file (fem/nas/bdf/dat):, specify the
input file metro_door_flex.fem generated in Step 1.
4. For #3, Save the h3d file as:, specify the output H3D file as metro_door_flex.h3d.
5. For #4, Specify Interface Node List, specify the interface node numbers as: 9751+9750+10090.
6. For #5, Cutoff type and value: select Highest Mode # and enter 20.
7. For #6, activate both Perform stress recovery and Perform strain recovery, and select No
for Perform element check in OptiStruct model.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.89

8. For Mass units, select Megagram.


9. Click OK to start the flexbody generation.
The flexbody H3D file is generated in the selected folder with the name metro_door_flex.h3d.

Creating the MBD Model of the Car Door


In this step, you will create the MBD model of the car door, after which the door closure simulation can
be performed.

For this model, use the following units for length, mass, force, and time, respectively: millimeter,
megagram, Newton, second.

Model Units

From the Forms panel, , change the Mass units from the default Kilogram to Megagram.

Points
For building this model, a total of six points need to be created.

From the Project Browser right-click Model and select Add Reference Entity > Point, or right click
Points from the toolbar. Add the points as shown in the table below.

Figure 81: Points Required for the Model

Bodies
In this model, there are two bodies: one body to represent the car and another to represent the flexible
door.

1. From the Project Browser right-click Model and select Add Reference Entity > Body, or right
click Bodies from the toolbar. Add a body and label it Car Body.

2. From the CM Coordinates tab, specify the center of mass of the body as the point Car Body CG.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.90

3. Click the Properties tab of the Car Body and enter the mass and inertia properties values as
shown below.

Figure 82: Mass and Inertia Properties of the Car Body

4. Add another body and label it Car Door.


5. From the Properties tab, click the Deformable check box.
6. Browse and specify the metro_door_flex.h3d file as the Graphic file and H3D file of the Door
Body. Use the flexbody file generated in Step 2 above.

Graphics
After Point 6 above, you can see that the Door Body has a graphical representation, but Car Body
does not. You can add a file graphic to the Car Body so that visualization of the model becomes more
meaningful.

1. From the Tools menu, select Import CAD or FE.


2. From the Input File drop-down menu, select HyperMesh. Use the file browser to select the
HyperMesh file car_body_graphics.hm.
The Output Graphic File field is automatically populated.

Figure 83:

3. Click OK.
The HyperMesh file is converted to H3D and imported into the MotionView window.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.91

4. From the Graphics panel, , click the graphic just added.

5. From the Connectivity tab, double-click Body and pick Car Body as the body.
This will associate the selected graphic with the Car Body.

Joints
For this body, you will need to add a total of four constraints/joints. One of these joints will need to be
added using the XML template.

1. From the Project Browser right-click Model and select Add Constraint > Joint, or right click
Joint from the toolbar.

2. Add joints as specified in the table below.

Figure 84: List of the Joints to Create and their Topology

Once the joints are specified and since there is a flexible body in the model, the interface nodes of
the flexible body have to be associated with corresponding joint markers.
3. From the Bodies panel, select Car Door.
4. From the Properties tab, click Nodes.
5. From the Nodes dialog, click Find All to find the interface node numbers and to resolve them with
the respective connection markers.

Initial Conditions
In this simulation, body initial velocity will act as the primary motion input to the model.

1. From the Project Browser select the Door Body from the filter on the left.
2. Click the Initial Conditions tab.
3. Activate WZ and specify a value of 5.0.
This will be the magnitude of the initial angular velocity about the global Z axis that will be applied
to the Door Body.
4. Do a test simulation to check how the model behaves with just the initial velocity and the
constraints.

Markers
To represent the locking mechanism of the car door, you will use a sensor activated fixed joint between
the Car Body and the Door Body that initially is deactivated. The fixed joint will need to be created

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.92

using XML templates since the MotionView interface allows joints to be created using bodies and points.
In this case, you need to create the joint between two initially non-coincident markers.

1. From the Project Browser right-click Model and select Add Reference Entity > Marker, or right
click Bodies from the toolbar.

2. Add two markers as specified in the table below.

Figure 85: List of Markers to Create and their Topology

3. Once the markers are created, repeat steps 2-4 under Joints above to resolve the node
connections of Car Door Body with the maker Door Lock Mark.

Sensors
In this model, you will use an Event Sensor to detect the closing of the door. At the instance of the
event detection, the fixed joint between the door and the car body is activated to simulate the actual
locking mechanism.

1. From the Project Browser right-click Model and select Add General MDL Entity > Sensor, or
right click Sensor from the toolbar.

2. Add a sensor and label it Lock Recognize.


3. Click the Signal tab and change the signal type from Linear to Expression.
4. Use the following expression as the signal: .

DY({MODEL.m_door.idstring},{MODEL.m_car.idstring},{MODEL.m_car.idstring})

The DY function accepts three markers as arguments. It returns the Y distance of the first marker
from the second marker in the third marker's reference frame. In this case, the first marker is
the maker labeled Door Lock Mark, which belongs to the Car Door Body. The second and the third
marker is Car Body Lock Mark, which belongs to the Car Body.
5. From the Compare To tab, specify 0.0010 for Value and 0.0001 for Error.
6. Under Respond if, select Signal is less than VALUE + ERROR.
7. From the Response tab, activate the Return to command file check box.

Templates
To simulate the door lock, you need a fixed joint between the door and the car body. The fixed joint
needs to be activated with the sensor. The activation of the joint and the deactivation of the sensor can
be done using a sequential simulation operation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.93

1. From the Project Browser right-click Model and select Add General MDL Entity > Template,
or right click Template from the toolbar. Add a template to the model and label it Lock Fix
Joint.
2. From the Properties tab of the template, under Type:, select Write text to solver input deck.
3. Type in the following definition of the fixed joint in XML format in the template are of the panel:

<Constraint_Joint
id = "1001"
type = "FIXED"
i_marker_id = "{the_model.m_door.idstring}"
j_marker_id = "{the_model.m_car.idstring}"
/>

This defines the fixed joint between the two markers Door Lock Mark and Car Body Lock Mark.
4. From the Project Browser, right-click Model and select Add General MDL Entity > Template to
add another template.
5. Specify the label as Seq Sim Commands.
6. From the Properties tab of the template, under Type, select Write text to solver command
file.
7. Below are XML Commands for the sequential simulation. Enter the following blocks of XML
commands in the template area of the panel:

<Deactivate
element_type = "JOINT"
element_id = "1001"
/>
<Simulate
analysis_type = "Transient"
end_time = "1.0"
print_interval = "0.001"
/>
<Activate
element_type = "JOINT"
element_id = "1001"
/>
<Deactivate
element_type = "SENSOR"
element_id = "{the_model.sen_0.idstring}"
/>
<Param_Transient
integrator_type = "VSTIFF"
/>
<Simulate
analysis_type = "Transient"
end_time = "2.5"
print_interval = "0.001"
/>
<Stop/>

These set of XML blocks define a sequential simulation operation as specified in the steps below:

a) Deactivate Fixed Joint (initially).


b) Simulate for 1 second.
c) Activate Fixed Joint.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.94

d) Deactivate Sensor.
e) Change the Integrator Type to VSTIFF.
f) Simulate for 1.5 seconds.
g) Stop simulation.
8. Save the model once by selecting Export > Solver Deck from File menu.
9. From the Run panel, click the file browser next to Save and run current model and specify a name
for the solver XML file.
10. Click Run to run the model in MotionSolve.
11. Once the run is complete, click Animate to animate the simulation results.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.95

MV-2035: Solving Flexbody ADM/ACF in


MotionSolve
In this tutorial, you will learn how to solve an ADM/ACF model that has flexbodies using MotionSolve,
use the Add Object panel in HyperView and view the transient analysis results from MotionSolve.

Theory
You can submit ADAMS dataset language files (ADM and ACF) directly to MotionSolve, thus avoiding
manual translation. The ADAMS model is first automatically translated into the MotionSolve XML format
and then it is solved. If the ADAMS model has a flexible body represented by the MNF and MTX files,
the MotionView Flexprep utility will be used to generate an H3D flexible body file (using the MNF file).
This H3D flexbody file is the MotionSolve equivalent of the ADAMS MNF and MTX files. It holds the mass
and inertia properties, as well as the flexibility properties which allow the body to deform under the
application of loads. The deformation is defined using a set of spatial modes and time dependent modal
coordinates.

Process
In this tutorial, an ADAMS single cylinder engine model (ADM and ACF) is provided. To improve the
accuracy of the model responses, the connecting rod is modeled as a flexbody (MNF and MTX). This
chapter deals with transient analysis of this single cylinder engine model using MotionSolve.

We will modify the ACF file to include an argument that would generate a flexbody H3D file. MotionSolve
internally calls OptiStruct, which generates the H3D flexbody file. The ADM and ACF is translated into
MotionSolve XML format and solved. MotionSolve outputs the results H3D file, which can be loaded
in HyperView for animation. In HyperView, external graphics (for piston and crank) can be added for
visualization.

MotionSolve supports most of the ADAMS statements, commands, functions, and user subroutines.
Refer to the MotionSolve User's Guide help for additional details.

Tools
Copy the following files, located in the mbd_modeling\motionsolve folder, to your <working
directory>:
• single_cylinder_engine.adm
• single_cylinder_engine.acf
• connecting_rod_flex_body.h3d
• Flexible_body.mnf
• Flexible_body.mtx
• piston.h3d
• crank.h3d

Note: Below is a table listing the flexbody files in Adams and the equivalent files for
MotionSolve:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.96

Option Adams MotionSolve

Flexbody file mnf and mtx H3D flexbody

Post processing Gra and res H3D animation


animation

Plot Req plt/abf

Modifying the ACF File


1. Start a new MotionView session.
2. Click Select Application and choose TextView .

3. From the toolbar, click the arrow next to the Open Session icon, , and select Open document ,

. Select single_cylinder_engine.acf, located in your <working directory>.

4. Add the following text in line 3:

FLEX_BODY/1, H3D_FILE=connecting_rod_flex_body.h3d

The ACF file should look like this:

Figure 86:

5. From the toolbar, click Save Document and save the file as single_cylinder_engine.acf to
your <working directory>.

Note: The connecting_rod_flex_body.h3d file that has been used in this tutorial
is generated using the FlexPrep utility in MotionView. Refer to the MotionView User's
Guide for more information on converting an ADAMS MNF file into a MotionView H3D
flexbody.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.97

Viewing Transient Analysis Results in HyperView by


Adding External Graphics
Since the ADM file does not carry the external graphic information, the results from MotionSolve will
not contain this information either. From ADAMS, you can export a Parasolid file which can be used for
visualizing results in HyperView. In this step, you will attach the piston and crank external graphic for
better result visualization.

1. Start a new HyperView session.


2. Using the Load model file browser, select: single_cylinder_engine.h3d, located in your
<working directory>.
The Load results file field will be automatically be updated with the single_cylinder_engine.h3d
file.
3. Click Apply.
The model is displayed in the window.
4. From the Add Object panel, , using the Add object from browser, select the piston.h3d
file. If the Add Object icon is not visible on the toolbar, select the View menu > Toolbars >
HyperView > Tools.
5. For Select object, select All to add all objects to the list.
6. Using the expansion button, , select Piston as the component with which you want the
selected object to move.
7. For Reference system, select the Global coordinate system.
8. Click Add.
Notice that the piston graphic is added to the model.
9. Repeat steps 5 through 8 to add the crank object to the model.

Note: Remember to select the crank.h3d file in the Add Object from browser and
attach it to Crank using the expansion button.

10. Click Contour on the toolbar. From the Result type drop-down menu, select the data type that
should be used to calculate the contours.
11. Select a data component from the second drop-down menu located below Result type.

Note: If you select Mag (Magnitude), the results system is disabled (since magnitude
is the same for any coordinate system).

12. Click Apply.


The contour is displayed.
13. Click Start Animation to animate the model.

14. Click Stop Animation to stop the animation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Flexible Body Dynamics p.98

Note: In the Add Object from browser, you can directly select a wavefront file (*.obj)
from ADAMS to add graphics. Whereas, if you have a Parasolid file (*.x_t) from
ADAMS, use the Tools menu option Import CAD or FE in MotionView to generate an
H3D file. You can then use this file to add the graphics.

Figure 87:

Proprietary Information of Altair Engineering


Optimization-DOE-Stochastics 3
Optimization-DOE-Stochastics

This chapter covers the following:

• MV-3000: DOE using MotionView - HyperStudy (p. 100)


• MV-3010: Optimization using MotionView - HyperStudy (p. 124)
MotionSolve Tutorials
Optimization-DOE-Stochastics p.100

MV-3000: DOE using MotionView - HyperStudy

In this tutorial, you will:


• Use HyperStudy to set-up a DOE study of a MotionView model
• Perform DOE study in the MotionView – HyperStudy environment
• Create approximation (using the DOE results) which can be subsequently used to perform
optimization of the MotionView model

Theory
HyperStudy allows you to perform Design of Experiments (DOE), optimization, and stochastic studies
in a CAE environment. The objective of a DOE, or Design of Experiments, study is to understand how
changes to the parameters (design variables) of a model influence its performance (response).

After a DOE study is complete, approximation can be created from the results of the DOE study. The
approximation is in the form of a polynomial equation of an output as a function of all input variables.
This is called as the regression equation.

The regression equation can then be used to perform Optimization.

Note: The goal of DOE is to develop an understanding of the behavior of the system, not to
find an optimal, single solution.

HyperStudy can be used to study different aspects of a design under various conditions, including non-
linear behavior.

HyperStudy also does the following:


• Provides a variety of DOE study types, including user-defined
• Facilitates multi-disciplinary DOE, optimization, and stochastic studies
• Provides a variety of sampling techniques and distributions for stochastic studies
• Parameterizes any solver input model via a user-friendly interface
• Uses an extensive expression builder to perform mathematical operations
• Uses a robust optimization engine
• Includes built-in support for post-processing study results
• Includes multiple results formats such as MVW, TXT for study results

Tools
In MotionView, HyperStudy can be accessed from
• From the Menu bar, select Applications >HyperStudy

You can then select MDL property data as design variables in a DOE or an optimization exercise. Solver
scripts registered in the MotionView Preferences file are available through the HyperStudy interface to
conduct sequential solver runs for DOE or optimization.

For any study, the HyperStudy process is shown below:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.101

Figure 88:

The HyperStudy Process


MotionView MDL files can be directly loaded into HyperStudy. Any solver input file, such as MotionSolve,
ADAMS, or Abaqus, can be parameterized and the template file submitted as input for HyperStudy. The
parameterized file identifies the design variables to be changed during DOE, optimization, or stochastic
studies. The solver runs are carried out accordingly and the results are then post-processed within
HyperStudy.

Copy the files hs.mdl and target_toe.csv, located in the mbd_modeling\doe folder, to your <working
directory>.

In the following steps, you will create a study to carry out subsequent DOE study on a front SLA
suspension model.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.102

Figure 89:

While performing a Static Ride Analysis, you will determine the effects of varying the coordinate
positions of the origin points of the inner and outer tie-rod joints on the toe-curve.

Step 1: Study Setup

1. Start a new MotionView session.


2. Click the Open Model icon, , on the Model-Main toolbar.

Or, from the menu bar, select File > Open > Model.
3. Select the file model hs.mdl, located in your <working directory>, and click Open.
4. Review the model and the toe-curve output request under Static Ride Analysis.
5. From the Applications menu, select HyperStudy.
HyperStudy is launched. The message "
Establishing connection between MotionView and HyperStudy
" is displayed.
6. Start new study using one of the following ways:
• From the Welcome page, click the New Study icon, .

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.103

• From the toolbar, click the New Study icon, .

• From main menu, select File > New. The HyperStudy - Add Study dialog is displayed.

Figure 90:

7. Accept the default label and variable names.


a) Under Location, click the file browser and select <working directory>\.
b) Click OK.
8. Model definition.
a) From the study Setup tree, select Define models.
b) Click to open the Add Model dialog.

c) Under Type, select MotionView to add a MotionView model to the study.


d) Accept the default variable name.
e) Click OK.
The following table with model data is created.

Figure 91:

9. Model data.
Please note that following details are automatically filled when you define the model (previous
step).
a) Under Active, check the box to activate or deactivate the model from study.
b) The label of model entered in previous step.
c) The variable name of model entered in the previous step.
d) The model type selected in previous step.
e) Point to the source file (here model file is sourced from MotionView through the MotionView –
HyperStudy interfacing).

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.104

f) Enter a name for the solver input file with the proper extension (for MotionSolve .xml) and
select the solver execution script MotionSolve - standalone ( ms).
10. Create design variables.
a) Click Import Variables to specify the design variables for the study.
b) The Model Browser window opens in MotionView, allowing you to select the variables
interactively.
c) Select the following from the Browser using the Model Parameter Tree dialog:

System Point Coordinate Function

Front SLA susp. Otr tie-rod ball-jt -left Y Double-click or Click


Add

Front SLA susp. Otr tie-rod ball-jt – Z Double-click or Click


left Add

Parallel Steering Inr tie-rod ball - left Y Double-click or Click


Add

Parallel Steering Inr tie-rod ball - left Z Double-click or Click


Add

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.105

Figure 92: Model Parameter Tree dialog

d) Click Done.
e) Click Next to go to Define Design Variables.
11. Define design variables.
a) From the Define design variables tab, edit the upper and lower bounds of the design
variables according to the following table.

Point Coordinate Lower Upper

Outer tie-rod ball-jt - Y -571.15 -559.15


left

Outer tie-rod ball-jt - Z 246.92 250.92


left

Inner tie-rod ball - Y -221.9 -209.9


left

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.106

Point Coordinate Lower Upper

Inner tie-rod ball - Z 274.86 278.86


left

Figure 93:

b) This step also includes definition of other properties to the design variables. The options
Details and Distributions specify variations of design variables in the range specified. The
option Link Variables is used to link different design variables through a mathematical
expression.
c) Click on each tab to observe these options.
d) Right click on the column header row to view more options that you may want to add.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.107

Figure 94:

e) Click Next to go to Specifications.


12. Specifications.
This section allows you to specify the initial run for DOE.
a) Select the Nominal Run radio button for this study and click the Apply button.
b) Click Next to go to Evaluate.
13. Evaluate
a) Click Evaluate Tasks to perform the nominal run.
b) Make sure that all settings for the run (Write, Execute and Extract) are activated.
c) MotionSolve runs in the background and the analysis is carried out for the base configuration.
Please note the messages in status bar of the HyperStudy interface and the MotionView
interface. If message log is not visible, click the Messages button or go to View >
Messages to display the log.
d) Once the nominal run is complete, click Next to go to Define responses.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.108

14. Define Response.


a) Click Add Response to add a new response.
b) Label the response Sum of Squared Error.
c) Accept the variable name and click OK.

Figure 95: Response table data

d) Click the ellipses, …, in the Expression cell of Response table to launch the Expression
Builder.

Figure 96: Expression builder

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.109

Note: You can move the cursor over the function to display the function help. For
this exercise, the response function requires two Data Sources:
• The elements of Data Source 1 contain actual data points of the toe curve
from the solver run for the nominal configuration.
• The elements of Data Source 2 contain data points from the target curve.

e) Click the Data Sources tab to source the data from the files.
15. Data Source 1
a) Click to add a new data source using the solver output file.

Figure 97: Response data table

b) Click the ellipses, …, in the File cell of Data Source table data to launch the Data Source
Builder: Data Source 1 (ds_1) dialog box.
c) Click the file browser button, , and select the file m_1.mrf from <working directory>
\approaches\nom_1\run__00001\m_1\.
d) This enables the Type, Request and Component fields.
e) From the Type drop-down menu, select Expressions.
f) From the Request drop-down menu, select REQ/70000033 toe-curve.
g) From the Component drop-down menu, select F2.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.110

Figure 98: Data Source 1 dialog box

You have now selected the toe curve data from the solver run as the data elements for Data
Source 1.
h) Click OK.
16. Data Source 2
a) Create a Data Source to hold the data elements from the target toe curve.
b) Click Add Data Source to add a new data source using a reference file.

Figure 99: Response data table

c) Click the … in the File cell of the Data Source 2 table data to launch the Data Source Builder:
Data Source 2 (ds_2) dialog box.
d) Click the file browser button, , and select the file target_toe.csv, located in your
<working directory>\.
• Set Type to Unknown and Request to Block 1.
• From the Component drop-down menu, select Column 1.
• Click OK.
17. In the Expression field, create the following expression:
sum((ds_1-ds_2))^2)

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.111

This expression evaluates the sum of the square of the difference between the “actual toe change”
values (from solver run) and the “targeted toe curve” (from imported file). In the next tutorial,
MV-3010, we will use HyperStudy to minimize the value of this expression to get the required
suspension configuration.

Figure 100:

18. Click Evaluate expression to verify that the expression is evaluated correctly. You should get a
value of 16.289.
19. Click OK to close the Expression builder and hit the Evaluate button.
a) If you do not encounter any error messages and were able to successfully extract the
response for the nominal run, click Next to go to Post Processing.
b) Observe the table with the design variable values used for the nominal run and other tabs
with the post-processing options.
c) Click Next to go to Report.
d) Observe various reporting formats available. The images and data captured during the post-
processing can be exported in any of the formats provided on Report page.
20. From the File menu, select Save As….
21. Save this study set-up as Setup.xml to your <working directory>\.

Step 2: DOE Study

1. Adding new DOE study.


a) Right-click in the Explorer browser area and from the context menu, click Add to display the
Add Approach dialog.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.112

Figure 101:

Or
b) From the Toolbar, click the Add Approach button to display the HyperStudy - Add dialog.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.113

Figure 102:

c) Under Select Type, select Doe.


d) Accept the default label and variable name and click OK.
The DOE study tree is displayed in the Browser with name Doe 1.
e) Click Next to go to Select design variables.
2. Select design variables for the DOE study.
a) All variables are used in the present DOE study, so make sure that all design variables are
active.
b) All the design variables in this study are controlled. Therefore, for Category, leave all
variables set to Controlled.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.114

Figure 103:

c) Click Next to go to Select Output responses.


3. Select responses for the DOE study:
a) There is only one response in the present study - make sure to select the response.
b) Click Next to go to Specifications.
4. Specifications for the DOE study:
The design space for the DOE study is created in this step. The present study has four design
variables with two levels each. A full factorial will give 24 = 16 experiments, as the number of
experiments are less. We will do a full factorial run.
a)
Click Show more... and select Full Factorial mode, .

Figure 104:

Note: Selecting any mode from the list shows all possible options in the
Parameters panel area on the left side of GUI.

b) Click the Levels tab to see the design variables and number of levels.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.115

Figure 105:

c) Click the Interaction tab to observe that it is not applicable since all interactions are
selected by default for a full factorial run.

Figure 106:

Note: Options which are not applicable will be grayed out or a message will be
shown.

5. Click Apply to generate the design space.


6. Click Next to go to Evaluate.
7. DOE run:
The Tasks tab of Evaluate shows a table of 16 rows and four columns. Column 1 shows the
experiment number while other columns corresponding to each experiment get updated with the
experiment status of failure or success in the three stages of model execution: Write, Execute and
Extract.

Design variable values used under each experiment can be seen under the Evaluation Data tab.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.116

The last column corresponds to the response value from each run. The values gets populated once
the run is completed.

a) Click Evaluate Tasks to start the DOE study.

Figure 107:

Once all the runs are finished, the tasks table gets filled up with the status for each run
(Success/Fail).
b) In the present DOE study, all runs are successfully completed. Click Next to go to Post
Processing.
8. Viewing Main Effect and Interaction plots:
The post-processing section has variety of utilities to helps user to effectively post process results.
Summary tab of Post processing page will provide a summary of design along with responses.
The New Generation HyperStudy allows you to sort data by right-clicking on the column heading
and selecting the options from context menu.

The options to post-process are available in other tabs. The main effects can be plotted by
selecting the Linear Effects tab.
9. Main Effects
a) Click the Linear Effects tab to open the main effects plot window. From the Channel page,
select Variables and Responses for which main effects need to be plotted. Press the left
mouse button and move over the variable or responses list for multiple selection.
b) Select all controlled variables and responses to plot the main effect plot. This plot shows the
effect of each parameter on the response.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.117

Figure 108: DOE – Main effects plot

Note: Click on window icon, , (highlighted above) to toggle it to multiple

windows, . Each curve is displayed in a different plot window.

10. Interactions
An interaction is the failure of one variable to produce the same effect on the output response at
different levels of another input variable. In other words, the strength or the sign (direction) of an
effect is different depending on the value (level) of some other variable(s). An interaction can be
either positive or negative.
Interactions can be plotted from the Interactions tab following the above procedure.

a) Select the design variables Otr_tierod_ball_jt-left-z and Inr_tierod_ball_jt-left-z and


response Sum of Squared Error.
b) Click the Interaction tab to observe that it is not applicable since all interactions are
selected by default for a full factorial run.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.118

This displays the interaction plot for these two variables only.

Figure 109: Controlled design variable plot for “Otr_tierod_ball_jt-left-z” & “Inr_tierod_ball_jt-left-z”
interaction

Step 3: Approximation
System response is approximated by using various curve fitting methods. An approximation for the
response with the design variables variation is calculated using the data from above DOE study. The
accuracy of the approximation can be checked and improved.

1. Adding an approximation.
a) Right-click in the Explorer browser area and from the context menu, click Add to display the
Add Approach dialog.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.119

Figure 110:

b) Under Select Type, select Fit.


c) Accept the default label and variable names and click OK.
A new tree with the name Fit 1 is created in the Browser.
d) Click Next.
2. Input matrix.
a) Click .
A matrix table is created. Check if the following options to specify the DOE results as the
input matrix have been selected by default.
b) Under Type, use the drop-down menu to select Input.
c) For Matrix Source, select Doe 1 from the drop-down menu.
In the present study, we are not using any validation matrix. So, no matrix will be added for
validation matrix.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.120

Figure 111:

Observe that the status shows “Import pending”.


d) Click Import Matrix to import the DOE results for the input matrix.
e) Click Next to go to Select Input Variables.
f) Select all design variables and click Next to go to Select Output Responses.
g) Select the response and click Next to go to Specifications.
In this section, the approximation type and it’s properties are defined.
h) Click the Show more… button and select the Moving Least Squares (MLSM):

Figure 112:

i) Click Apply to apply the approximation method.


j) Click Next to go to Evaluate.
k) Observe an empty Tasks table which corresponds to the DOE experiments.
l) Click Evaluate Tasks to evaluate the approximation for the DOE experiments.
Upon completion, the table is populated with the status value (Success or Fail).
m) Click the other tabs available to observe the fit.
n) Click the Evaluation Data tab to observe the experiment table with responses from the
MotionSolve run and responses predicted using approximation. The same can be viewed in
graph format by selecting the Evaluation plot tab.
o) Select Sum of Squared of Squared Error and Squared of Squared Error_MLSM to plot
against the experiment numbers.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.121

Figure 113:

This fit shows a good approximation to the response.


p) Click Next to go to Post Processing.
Post-processing provides you with statistical parameters and graphical tools useful in
validating the correctness of approximation.
The Residuals tab shows the difference between the response value from the solver and the
response value from the regression equation.

The residual values can be used to determine which runs are generating more errors in the
regression model.

The Trade-off tab shows the plots of the main effects vs. response from the approximation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.122

Figure 114: Trade-off: 3-D plots

q) Select Otr_tierod_ball_jt-left-y as the X axis and Otr_tierod_ball_jt-left-z as the Y axis


to plot against response from the approximation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.123

Figure 115:

r) From the toolbar, click the Save icon, , to save the study.

Note: All study files will be saved in the study directory with the folder names
that are the same as the tree varnames. For example, nom_1, doe_1, and fit_1.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.124

MV-3010: Optimization using MotionView -


HyperStudy

In this tutorial you will:


• Perform an optimization study in the MotionView-HyperStudy environment
• Compare the baseline and optimized models

Theory
In general, an optimization problem consists of:
• The design constraints
• The objective function
• The design variables

Design variables change during optimization. The design variables always have a certain range within
which they can be modified. Typical examples of design variables are thickness of shell elements, shape
vectors, and masses.

The changes in the design variables cause some change in model responses. Such responses
can become either objective function or design constraints. Examples of such responses include
displacements and forces.

The response to be minimized or maximized becomes the objective function, while the rest of the
responses that need to be within a certain tolerance range become constraints. Only one response can
be defined as objective function.

HyperStudy can be used to set-up and perform an optimization study on a MotionView model. You can
also use HyperStudy to perform optimization studies involving both linear and non-linear CAE analysis
as well as perform optimization of mathematical equations using Templex. HyperStudy creates the input
parameter files using Templex and provides iterative changes to them during the optimization process.
HyperStudy uses HyperOpt (a general purpose, wrap around software) as the optimization engine to
perform optimization, in conjunction with both linear and non-linear CAE analysis software. HyperOpt
uses a robust sequential response surface methodology for optimization.

The files needed for this tutorial are hs.mdl, target_toe.csv (used in tutorial MV-3000); Setup.xml
saved in tutorial MV-3000 and the nom_run folder created in tutorial MV-3000.

These files should be in the <working-directory> that was used in tutorial MV-3000.

Note: If you copy the Setup.xml file from the above location, the path in the <Folder> tag
in the file needs to be edited to point to your <Working directory>.

In the following steps you will perform an optimization study on a front SLA suspension model and
determine the optimum coordinate positions of the inner and outer tie-rod points while trying to achieve
a target toe curve. The baseline model will then be compared with the optimized model.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.125

Step 1: Optimization Study


1. Start a new MotionView session.
2. Open the model hs.mdl, located in <working directory>.
3. Review the model and the toe-curve output request.
4. From the SolverMode menu make sure that MotionSolve is selected.
5. From the Applications menu, launch HyperStudy.
6. Click on open file icon, , browse to your study directory and select Setup.xml file created in the
MV-3000 tutorial.
7. Add a new optimization study by doing one of the following:
a) Right-click in the Explorer Browser area and from the context menu, click Add Approach to
launch the HyperStudy - Add dialog box.
b) From the Edit menu bar, click the Add Approach icon, , to launch the HyperStudy - Add
dialog box.

Figure 116:

c) Under Select Type, select Optimization.


d) Accept the default label and variable name and click OK.
e) The Optimization tree displays in the explorer with name Optimization_1.
f) Click Next to go to the Select design variables.
8. In the Define design variables panel, verify that all the design variables are checked.
This panel displays all the variables and their upper and lower bounds.
9. Click Next to go to the Select responses.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.126

a)
Click to launch the HyperStudy - Add Objective dialog box.

Figure 117:

b) Accept the default label and variable names and click OK.
In this exercise, minimize the Sum of Squared Error response function to obtain optimum
values for the design parameters: the Y and Z coordinate positions of the inner and outer tie-
rod points.
c) Check to make sure that the type is set as Minimize from the drop-down menu.
d) Check to make sure that the Evaluate From option is set to Solver.

Figure 118:

10. There aren't any constraints and unused responses in the design, so click Apply and then click
Next to go to Specifications.
Accept the default Optimization Engine: Adaptive Response Surface Method and click Apply and
Next. The Maximum iterations and Convergence criteria are specified in the same dialog.
11. Click Apply and Next to go to Evaluate.
12. Click Evaluate Tasks to start the optimization.
MotionSolve is launched sequentially and the HyperOpt engine attempts to find a solution to the
problem.
Once the optimization is complete, an Iteration table is created with status of each run. The
present study took nine iterations to achieve the target. Browse through the other tabs of this
page to get more understanding of the iteration history.
13. Click the Iteration Plot 2D tab.
14. From the list on the right side of the GUI, select the Objective function named Objective_1.
This plots the objective function value against the iterations.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.127

Figure 119: Optimization history plot

In this panel, you can see the plots variations in the values of the objectives, constraints, design
variables, and responses during different design iterations. The Iteration History Table displays the
same data in a tabular format.

Note that in this study, iteration 6 is the optimal configuration.

Save your study to <working directory> as Study_2.xml.


15. Close HyperStudy.

Step 2: Comparing the Baseline and Optimized Models.

1. Add a page to your MotionView session.


2. From the Select application drop-down menu, select HyperView.
3. From the Load Model panel, load the animation file <working directory>\approaches
\nom_1\run__00001\m_1\m_1.h3d.
4. Click the Page Layout icon, , on the toolbar and select the two-window layout.

5. In the second window, switch to HyperGraph.


6. Click the Build Plots icon, , on the toolbar.

7. Use the Build Plots file browser, and select the file target_toe.csv, located in the <working
directory>.
8. For X-axis data, select:
a) Type = Unknown
b) Request = Block 1
c) Component = Column 1
9. For Y-axis data, select:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Optimization-DOE-Stochastics p.128

a) Type = Unknown
b) Request = Block 1
c) Component = Column 2
10. Click Apply.
11. Using the file browser on the Build Plots panel, select the file <working directory>\approaches
\nom_1\run__0001\m_1\m_1.abf.
12. For X-axis data, select:
a) Type = Expressions
b) Request = REQ/70000033 toe-curve
c) Component = F2
13. For Y-axis data, select:
a) Type = Expressions
b) Request = REQ/70000033 toe-curve
c) Component = F3
14. Click Apply.
15. Plot another curve from the file.
<working directory>\approaches\opt_1\run__00006\m_1\m_1.abf using steps 11-14
You should end up with a session looking like the one shown below. Notice the optimized toe-
curve.

Figure 120: Optimization results

You may also overlay the animation of the optimal configuration (run 6) over the nominal run.
Notice the toe angle differences.
16. Save the session as opt_toe.mvw.

Proprietary Information of Altair Engineering


Using the MotionSolve API 4
Using the MotionSolve API

This chapter covers the following:

• MV-9000: Bouncing Ball Tutorial (p. 130)


• MV-9001: Simple Pendulum Tutorial (p. 135)
• MV-9002: Slotted Link Tutorial (p. 143)
• MV-9003: LuGre Friction Tutorial (p. 149)
MotionSolve Tutorials
Using the MotionSolve API p.130

MV-9000: Bouncing Ball Tutorial


In this tutorial, you will learn how to model a simple 1 DOF mechanism using the Msolve Python API.
If you are running this tutorial as IPython notebook, you can interactively execute each code cell by
clicking SHIFT-ENTER. The output of the Python code (if any) is displayed and the execution jumps to
the next cell.

The image below illustrates the geometry and the values that you need.

Figure 121:

Loading the Msolve Module

Load the msolve module, which is done by issuing this command:

In [2]: from msolve import*

The above command requires the msolve module be in your computer path. Assuming the above is
successful, you have imported the msolve names into the current namespace. This means you have
access to all the classes and functions defined in msolve and can start creating the bouncing ball case.

Creating a Model
To create the pendulum mechanism, you must first create a model.

Issue this command:

In [3]: model = Model()

The above command requires the msolve module be in your computer path. Assuming the above is
successful, you have imported the msolve names into the current namespace. This means you have
access to all the classes and functions defined in msolve and can start creating the bouncing ball case.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.131

Adding Units and Gravity


After creating a model, you can add details, units, and other entities such as gravity and ground. Most
entities have default properties. For example, when you create the solver unit set without specifying
arguments, you are essentially creating SI units.

1. Issue this command:

In [4]: units = Units() #SI

2. Similarly, you can create the gravitational acceleration field.

In [5]: grav = 9.807


gravity = Accgrav(igrav=0, jgrav=0, kgrav=-grav)

3. You can now create the ground part by using the Part class and specifying the ground Boolean
attribute as 'True':

In [6]: ground = Part(ground=True)

Creating Markers
Next, you can create markers on the ground part. A marker is defined by a geometric point in space
and a set of three mutually perpendicular coordinate axes emanating from that point. It can be used as
a reference frame of the part that it belongs to.

Issue this command:

In [7]: global_ref = Marker(part=ground)

Creating a Geometry Object


For animation purposes, you can create a geometry object. In this case, a box representing the ground.
According to the documentation, a box requires a center marker and its x,y,z dimension.

1. Issue this command:

In [8]: box=Box(cm=global_ref, x=20, y=20, z=5)

You can similarly create the ball by first creating a part with mass and then creating a sphere
located at the cm (center of mass) of the part. Inform the solver of the mass and cm of the part
unless you are creating a ground part.

The mass of the sphere is given by:


(2)

The inertia property is given by:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.132

(3)

2. Issue the command:

In [9]: # define the cm of sphere


radius = 1
initial_offset = 10
p = Point(0,0,radius+box.z/2.0+initial_offset)

# calculate the mass and inertial property of sphere


volume = (4.0/3.0)*radius**3
density = 1522
mass = volume * density
ixx = iyy = izz = 2.0 * mass * radius ** 2 / 5.0

# create part and cm for the sphere


sphere= Part(mass = mass, ip = (ixx, iyy, izz, 0, 0, 0 ), qg=p)
sphere.cm = Marker(body=sphere)

# create the geometry


geo = Sphere(cm=sphere.cm, radius = radius)

Defining the Contact Force


You can define the contact force between the ground and the sphere. First, define a marker on each
part at the contacting point. These two markers are used in the force calculation and displacement
monitor.

1. Issue this command:

In [10]: marker_i = Marker(part = sphere, qp = (0,0,-radius), xp = (1,0,0), zp =


(0,0,100))
marker_j = Marker(part = ground, qp = (0,0,box.z/2.0), xp = (1,0,0), zp =
(0,0,box.z/2.0+1))

2. Call Sforce to calculate the contact force as the ball moves. The input function should be a
MotionSolve expression and the z axis of marker j defines the direction that the force applies.

In [11]: input_function =
"IMPACT(DZ({I}, {J}, {J}),VZ({I}, {J}, {J}),{G},{K},{E},{C},{D})"
.
format( I=marker_i.id,J=marker_j.id, K=5e9, G=0.00, E=1.0, C=0.8e5, D=0.0 )
contact_force = Sforce(i = marker_i.id, j = marker_j.id,
type=
"TRANSLATION"
, function = input_function)

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.133

Adding Joints and Requests


You can add a translational joint here to prevent the ball from flapping around (although it is not
necessary). To create a joint, define the type of the joint as well as the markers that the joint is placed
on. The z axis of marker j defines the direction of translational joint.

You can also create a request. Requests define output channels in MotionSolve and are written to
MotionSolve output files so that they may be used for plotting and signal processing by HyperGraph.
Requests can be defined using runtime expressions, built-in functions (MOTION, FORCE, FIELD, and so
on), or user-written functions.

1. Create a displacement request using the predefined "DZ" method and then create another request
to track the contact force:

In [12]: # Translational Joint, prevent the sphere flapping around


joint = Joint (type="TRANSLATIONAL",i=marker_i.id,j=marker_j.id)

# Adding monitor into the model


model.forceRequest = forceRequest = Request(f2="FZ({I},{J},
{J})".format(I=marker_i.id, J=marker_j.id))
model.dispRequest = dispRequest = Request(f2="DZ({I}, {J},
{J})".format(I=marker_i.id, J=marker_j.id))

2. Call Sforce to calculate the contact force as the ball moves. The input function should be a
MotionSolve expression and the z axis of marker j defines the direction that the force applies.

In [13]: input_function =
"IMPACT(DZ({I}, {J}, {J}),VZ({I}, {J}, {J}),{G},{K},{E},{C},{D})"
.
format( I=marker_i.id,J=marker_j.id, K=5e9, G=0.00, E=1.0, C=0.8e5, D=0.0 )
contact_force = Sforce(i = marker_i.id, j = marker_j.id,
type=
"TRANSLATION"
, function = input_function)

Running the Simulation


At this point you are ready to run a transient analysis. The simulate method is invoked on the MBS
model. A validation process is performed on each of the entities that make up the model. This is
a necessary step to ensure that only correct models are being simulated. Note that the simulate
command can be invoked with an optional flag, returnResults, set to True. This stores the results of
the simulation into a run container for further post-processing, as shown below.

1. Issue the following command:

In [14]: run=model.simulate(type="DYNAMIC", returnResults=True,


end=50, steps = 10000)

2. In the following example, you are extracting the model.despRequest from the run container. The
purpose is to have a convenient data structure for extracting time varying results.

In [15]: dz=run.getObject(model.dispRequest)

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.134

3. Use the dz object to plot the displacement along the global z axis, using the matplotlib module
available in IPython notebook. The plot is displayed inline. You can see how the magnitude of
bouncing changes as time goes.

In [16]: %matplotlibinline
frommatplotlibimport pyplot
pyplot.plot(dz.times, dz.getComponent(1))
pyplot.xlabel('Time(s)')
pyplot.ylabel('Displacement(m)')
pyplot.show()

Figure 122:

The bouncing magnitude decreases each time the ball hits the ground because a damping exists in
the definition of contact force.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.135

MV-9001: Simple Pendulum Tutorial


In this tutorial, you will learn how to model a simple 1 DOF mechanism using the Msolve MotionSolve
Python API.

If you are running this tutorial as IPython notebook, you can interactively execute each code cell by
clicking SHIFT-ENTER. The output of the Python code (if any) will be displayed and the execution will
jump to the next cell.

The image below is a graphical representation of the system that you are going to build.

Figure 123:

A rigid body is suspended by a mass-less wire and is connected to the ground via a hinge joint. The
only force acting on the system is gravity, directed along the negative vertical direction. The simulation
shows a part swinging from its initial resting position. There is no friction force in the joint, nor any
type of energy dissipating force acting on the part, therefore the ball reaches 180 degrees of angular
displacement for each full swing.

You will examine the reaction force in the joint.

Loading the Msolve Module

Load the msolve module, which is done by issuing this command:

In [1]: from msolve import*

The above command requires the msolve module to be in your computer path. Assuming the above
is successful, you have imported the msolve names into the current namespace. This means that
you have access to all classes and functions defined in msolve and you can start creating the simple
pendulum.

Creating a Model
To create the pendulum mechanism, you must first create a model. A model is nothing but a container
that serves as a parent for all the entities. The model class takes a keyword argument to specify the
output file name for MotionSolve. You can use the name 'pendulum'.

Issue this command:

In [2]: model = Model(output='pendulum')

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.136

MotionSolve creates a series of output files (such as .mrf, .abf and .h3d) using pendulum as the root
name.

Adding Units and Gravity


After creating a model, you can add details, units, and other entities such as gravity and ground. Most
entities have default properties. For example, when you create the solver unit set without specifying
arguments, you are essentially creating SI units.

1. Issue this command:

In [3]: units= Units ()

2. Since you want to model in mmks, modify the length property of the units and assign a value of
"MILLIMETERS". You can perform a simple direct assignment:.

In [4]: units.length="MILLIMETER"

3. Similarly, you can create the gravitational acceleration field with the Accgrav class.

In [5]: gravity=Accgrav(kgrav=-9810)

Notice the result of the Accgrav creation is stored in a variable called gravity. That is the name
that appears to the left of the equal sign. This is now a Python variable in the current namespace
and, as such, can be used anywhere in the scope.
Note that in msolve class names, use the CapWords convention and be aware that you can use the
Python help system to learn about each msolve class, its use, and properties. Complete the steps below
as an example.
4. To interact with the Accgrav class, call the help ( ) function with the class name as the input
argument.

In [6]: help(Accgrav)
Help on class Accgrav in module msolve.Model:
class Accgrav(Force)
| Accgrav defines the acceleration due to gravity along the global X, Y, and Z
directions.
|
| Method resolution order:
| Accgrav
| Force
| msolve.Base.SolverObject
| __builtin__.object
|
| Methods defined here:
|
| sendToSolver(self)
| Send the object to the solver
|
| setSolverValue(self, name, value)
| Set the property 'name' to 'value' between simulations
|
| ----------------------------------------------------------------------
| Data descriptors defined here:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.137

|
| igrav
| Gravity in the global X direction
| Type=Double, Optional, Default=0
| Modifiable during simulation
|
| jgrav
| Gravity in the global Y direction
| Type=Double, Optional, Default=0
| Modifiable during simulation
|
| kgrav
| Gravity in the global Z direction
| Type=Double, Optional, Default=0
| Modifiable during simulation

A lot of information is displayed when the help function is called. The most important piece of
information is the description of the class and its properties. For example, data descriptors are
defined in the code below:

igrav
Gravity in the global X direction
Type=Double, Optional, Default=0
Modifiable during simulation

In msolve, creating a class instance always returns an object. This gives you the ability to
reference the object using its name, gravity in this case. You can use gravity and its properties
anywhere in the model. For example, you can modify its properties during the model building
phase, or between MotionSolve simulations. The benefits of this approach are illustrated later in
this tutorial.

As a general rule, it's useful to store the objects being created using local variables, especially
if they will be modified or referenced elsewhere. At this point, you can proceed with the model
creation.
5. Create the ground part, use the Part class, and specify the ground Boolean attribute as 'False'.

In [7]: ground=Part(ground=True)

Defining Points
Some models in MBS are defined using points. Points are a special auxiliary object with an x, y, z
location and a handful of convenient methods. They are a powerful way to define a mechanism and can
be used anywhere in the model where an X,Y,Z quantity is needed (for example, to position a part or
position a marker origin).

In this example, use points to locate various objects (such as markers) in the three dimensional space.
You can use points when defining marker locations and orientations.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.138

To create a point at the global origin, do not include an argument, as not having an argument in the
Point class signifies that the x,y,z coordinates are set to the default values of 0,0,0. Issue the following
command:

In [8]: p0=Point()

Creating Markers
You can use this point to locate the origin of the ground marker. A marker is defined by a geometric
point in space and a set of three mutually perpendicular coordinate axes emanating from that point.

In the marker class, the property qp corresponds to the location of the marker origin in the body
reference frame. Since you are using ground as the body, the qp propery is the location of the marker in
the global reference frame. Use the zp, xp method to orient the Z and X axes.

1. In the command below, supply a point in space used to orient each of the two axes, the third
being automatically computed as an orthogonal right handed coordinate system.

In [9]: ground_mar=Marker (body=ground, qp=p0, zp=[0,100,0], xp=[100,0,0])

2. Now you can create the pendulum body. It's a rigid part with a mass of 2kg and some nominal
inertia properties.

In [10]: part=Part(mass=2.0, ip=[1e3,1e3,1e3])

3. Optional: If you type part. and the TAB key in a code cell, you will be able to see all the functions
and properties applicable to part as a drop down list.

Verifying the Part Creation


Every entity can be interactively validated. This is a way to help ensure that only correct models are
simulated. The part that you created in the code cell above has mass properties but it does not have a
Center of Mass marker. Therefore, it is incorrect. You can

1. Verify the part by calling the validate function:

In [11]: part.validate()
Part/2
ERROR:: Mass is specified but cm is not specified.
ERROR:: There are no markers on this part.
Out[11]:
False

The error message tells you the part CM is missing.


2. Rectify this issue by creating the part CM marker at position (100, 0, 0). This point represents the
location of the pendulum part.

In [12]: p1 = Point(100,0,0)
# create the marker as the part.cm

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.139

# note that the '.' operator allows us to define a the 'cm' property of the part
object.
# the marker will be positioned at (100,0,0), the X axis is pointing towards the
point (200, 0,0)
# and the z axis points to (200, 100, 0)

part.cm = Marker(body=part, qp=p1, zp=[200,100,0], xp=[200,0,0])

Creating a Geometry Object


For animation purposes, you can create a geometry object, a sphere in this case. According to the
documentation, a sphere requires a center marker and a radius.

Issue this command:

In [13]: sphere=Sphere (cm=part.cm, radius=20)

Adding Joints and Requests


You will need to properly constraint our sphere, otherwise it will fall. A pendulum can be modeled using
a revolute joint at the hinge point p0. This will effectively capture the undeformable, infinitely rigid
mass-less connection of the pendulum body to ground. The revolute joint will connect two markers, one
on the pendulum sphere and one on ground, and these markers need to be properly positioned in the
three dimensional space.

A requirement of the revolute joints is that the i and j markers need to be coincident and need to have
their Z axes properly aligned.

You will also create a request. Requests define output channels in MotionSolve and are written to
MotionSolve output files so that they may be used for plotting and signal processing by HyperGraph.
Requests can be defined using runtime expressions, built-in functions (MOTION, FORCE, FIELD, and so
on,) or user written functions.

In this case, you can create a force request using the predefined "FORCE" method and create another
request tracking angular displacement using the AX MotionSolve runtime function. AX measures the
angular displacement in radians between two markers.

1. Issue the following command:

In [14]: joint = Joint(type="REVOLUTE", i=ground_mar, j=Marker(body=part, qp=p0,


xp=[100,0,0], zp=[0,100,0]))
force_req = Request(type="FORCE", i=joint.i, j=joint.j, rm=joint.i)
angle_req = Request(f1="RTOD*AX({I}, {J})".format(I=joint.i.id, J=joint.j.id),

f2="RTOD*AY({I}, {J})".format(I=joint.i.id, J=joint.j.id),


f3="RTOD*AZ({I}, {J})".format(I=joint.i.id, J=joint.j.id))

2. Call Sforce to calculate the contact force as the ball moves. The input function should be a
MotionSolve expression and the z axis of marker j defines the direction that the force applies.

In [15]: input_function =

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.140

"IMPACT(DZ({I}, {J}, {J}),VZ({I}, {J}, {J}),{G},{K},{E},{C},{D})"


.
format( I=marker_i.id,J=marker_j.id, K=5e9, G=0.00, E=1.0, C=0.8e5, D=0.0 )
contact_force = Sforce(i = marker_i.id, j = marker_j.id,
type=
"TRANSLATION"
, function = input_function)

Running the Simulation


At this point, you are ready to run a transient analysis. The simulate method in invoked on the MBS
model. A validation process is performed on each of the entities that make up the model. This is
a necessary step to ensure that only correct models are being simulated. Note that the simulate
command can be invoked with an optional flag returnResults set to True. This stores the results of the
simulation into a run container for further post-processing, as shown in the following code.

1. Issue the following command:

In [16]: run=model.simulate (type="TRANSIENT", returnResults=True, end=2,


dtout=.01)

2. You can easily modify the part mass property by changing its value with a direct assignment:

In [17]: part.mass= 12

3. At this point you can run another simulation, starting from the end of the previous analysis. To do
that, simply issue a new simulate command and specify an end time of four seconds. Note that
this simulation is done with the new part mass, so you should be able to see the effect of that in
the joint reaction forces.

In [18]: run=model.simulate (type="TRANSIENT", returnResults=True, end=4,


dtout=.01)

4. In the following command, you are extracting the force_req from the run container. The purpose is
to have a convenient data structure for extracting time varying results.

In [19]: force=run.getObject (force_req)

5. You can use the force object to plot the longitudinal reaction force Fx. To do so, you are using the
matplotlib module available in the IPython notebook. The plot is displayed inline. You can see how
the mass modification at time = 2 sec affects the magnitude of the reaction force, generating a
peak of 350N.

In [20]: %matplotlib inline


from matplotlibimport
pyplot pyplot.plot (force.times, force.getComponent (2), label=force.labels[2])

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.141

Figure 124: Out[20]: [<matplotlib.lines.Line2D at 0x7142860>]

6. Similarly, you can plot the rotation angle. A generic runtime expression was used in the angular
displacement request, so you need to get the right component that corresponds to the AY (angle
about the Y axis of the marker j of the angle request.

In [21]: angle = run.getObject(angle_req)


pyplot.plot (angle.times, angle.getComponent(2), label="angle [deg]")

Figure 125: Out[21]: [<matplotlib.lines.Line2D at 0x72c8fd0>]

The angular displacement is a simple harmonic function and the pendulum reaches 180 degrees
because there are no dissipative forces such as viscous friction in the joint. Note that the
frequency of oscillation is governed by these equations:
(4)

(5)

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.142

As visible from the plot above, the mass swings with a frequency of about 1.5Hz. The
generateOutput() function called below creates a MotionSolve *.plt file and H3D animation files
for visualization in HyperView and HyperView Player.

In [22]: model.generateOutput()

In conclusion, you have learned how to create a simple pendulum model, run transient simulations, and
plot results.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.143

MV-9002: Slotted Link Tutorial


In this tutorial, you will learn how to import geometry and build a Poisson Contact using the msolve
MotionSolve Python API.

If you are running this tutorial as IPython notebook, you can interactively execute each code cell by
clicking SHIFT-ENTER. The output of the Python code (if any) is displayed and the execution jumps to
the next cell. If you want to run it, you also need to make sure that the file slotted_link.fem is in the
folder.

Loading the Msolve Module

Load the msolve module, which is done by issuing this command:

In [1]: from msolve import*

The above command requires the msolve module to be in your computer path. Assuming the above is
successful, you have now imported the msolve names into the current namespace. This means that you
have access to all the classes and functions defined in msolve and you can start creating the bouncing
ball case.

Creating a Model
To create the pendulum mechanism, you must first create a model. A model is nothing but a container
that serves as a parent for all of the entities.

Issue this command:

In [2]: model = Model()

Adding Units and Gravity


After creating a model, you can add details, units, and other entities, such as gravity and ground.
Most entities have default properties. For example, you only change the length unit from 'METER' to
'MILLIMETER'; everything else is in SI units.
1. Issue this command:

In [3]: units = Units(length ="MILLIMETER")

2. Similarly you can create the gravitational acceleration field. Notice that the gravity is set to zero:
it would not affect the motion of the slotted slider.

In [4]: gravity = Accgrav()

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.144

3. You can now create the ground part. To do that, use the Part class and specifying the ground
Boolean attribute as 'True'.

In [5]: ground = Part(ground=True)

Adding Parts
Next, you can create four parts representing the link, cam, pin, and slotted link. You can also specify
the mass, initial property, and the center of mass for the part. This information would not be imported
to MotionSolve from CAD or FEM file automatically.

Issue this command:

In [6]: link = Part(cm=Marker(),mass = 0.0526,ip=[20.0844,21.7819,1.9169,0,0,0])


link.cm.qp = [0, -17.499994784, 33.609856169]
pin = Part(cm=Marker(),mass = 0.0972, ip = [15.3742, 4.8085, 15.37, 0,0,0])
pin.cm.qp = [0,-0.000001527,74.999999124]
cam = Part(cm=Marker(),mass = 1.2159, ip = [372.14,961.3416,913.45,0,0,0])
cam.cm.qp = [0,0,-21.22]
slotted_link = Part(cm=Marker(),mass = 5.8943,ip = [3721.7065,1.8e5,1.7689e5,0,0,0])
slotted_link.cm.qp = [224.988, 0, -63.813495]

Defining Markers for Geometry


Before importing the geometry, you need to define the marker on the part that the geometry is linked
to. You cannot use cm marker in this case; the position of nodes in the FEM is measured in the global
reference frame while the cm marker represents a local reference for the part. So, you need to create
four markers that coincide with global origin.

Issue this command:

In [7]: link_geo_marker = Marker(part = link)


pin_geo_marker = Marker(part = pin)
cam_geo_marker = Marker(part = cam)
slotted_link_geo_marker = Marker(part = slotted_link)

Importing Geometry
Now you can import geometry for the part. To do so, create four external instances. The class External
is created to help users import a CAD file or an FEM file. If the file imported has multiple components,
you can extract them one-by-one by specifying the 'element' property. When the CAD file is imported,
you can improve the mesh by increasing the value of 'refinement_level'. The example below shows how
external instances are created in this case:

Issue this command:

In [8]: link_geo = External(rm = link_geo_marker, file ="slotted_link.fem",

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.145

element=["Link"], refinement_level = 0)
pin_geo = External(rm = pin_geo_marker, file ="slotted_link.fem",
element=["Pin"], refinement_level = 0)
cam_geo = External(rm = cam_geo_marker, file ="slotted_link.fem",
element=["Cam"], refinement_level = 0)
slotted_link_geo = External(rm = slotted_link_geo_marker, file ="slotted_link.fem",
element=["Slotted_Link"], refinement_level = 0)

Adding Joints
The next step is to create the joints between different parts. Two fixed joints are created: one between
the pin and the link, and the other connecting the link and the cam. For a fixed joint, the i marker and j
marker should be coincident with their x,y,z axis aligned.

1. Issue the command:

In [9]: ## Pin-Link-Fix at Pin cm


pin_link_i = pin.cm
pin_link_j = Marker(part = link, qp = pin.cm.qp)
pin_link_fix = Joint(type="FIXED", i = pin_link_i, j = pin_link_j)

## Link-Cam-Fix at Link cm
link_cam_i = link.cm
link_cam_j = Marker(part = cam, qp = link.cm.qp)
link_cam_fix = Joint(
type ="FIXED", i = link_cam_i, j = link_cam_j)

2. The slotted link is only allowed to slide along global x-axis. Here, create a translational joint:

In [10]: ## Slotted-link-slider-Translational at slotted link cm


marker_qp = slotted_link.cm.qp
marker_xp = marker_qp + [0,0,1]
marker_zp = marker_qp + [1,0,0]
slotted_slider_i = Marker(part = slotted_link, qp = marker_qp, xp = marker_xp, zp
= marker_zp)
slotted_slider_j = Marker(part = ground, qp = marker_qp, xp = marker_xp, zp =
marker_zp)
slotted_slider_trans = Joint(type="TRANSLATIONAL", i = slotted_slider_i, j =
slotted_slider_j)

3. You can impose a revolute motion on the pin-cam-link entity. To do so, you first need to create a
revolute joint that rotates along the global y axis.

In [11]: ## Cam-pivot-Revolute at global_origin


cam_pivot_i = Marker(part = cam, xp=[1,0,0], zp=[0,1,0])
cam_pivot_j = Marker(part = ground, xp=[1,0,0], zp=[0,1,0])
cam_pivot_revolute = Joint(type="REVOLUTE", i = cam_pivot_i, j = cam_pivot_j)

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.146

Adding Motion
The motion can be created by creating an instance of Motion in msolve. You can change the pattern
of motion by specifying the property 'function'. The property 'function' should be a MotionSolve
expression.

Issue the command:

In [12]: cam_pivot_motion = Motion(joint=cam_pivot_revolute, jtype="ROTATION",dtype=


"DISPLACEMENT",function='360d*TIME')

Adding Contact
The last step is to create contact between the geometries that you imported. Two Poisson contacts are
created here: one between the cam and slotted link, and the other between pin and slotted link.

Issue the command:

In [13]: cam_slotted_contact =
Contact(igeom=cam_geo,jgeom=slotted_link_geo,type="POISSON",
restitution_coefficient=0.5,penalty=1e5)
pin_slotted_contact = Contact(igeom=pin_geo,jgeom=slotted_link_geo,type="POISSON",
restitution_coefficient=0.5,penalty=1e5)

Creating Requests
Before running the model, create requests that track the contact force and the penetration depth. The
result can be plotted using pyplot.

Issue the command:

In [14]:#forceRequest = Request(f2="FX({I})".format(I=slotted_link_geo_marker.id))
forceRequest = Request(f1="CONTACT({ID},{JFLAG},{COMP},
{RM})".format(ID=cam_slotted_contact.id,
JFLAG=1,COMP=1,RM=0),
f2="CONTACT({ID},{JFLAG},{COMP},
{RM})".format(ID=pin_slotted_contact.id,
JFLAG=1,COMP=1,RM=0))
depthRequest = Request(f1="CONTACT({ID},{INDEX},
{RM})".format(ID=cam_slotted_contact.id,
INDEX=1,RM=0),
f2="CONTACT({ID},{INDEX},
{RM})".format(ID=pin_slotted_contact.id,
INDEX=1,RM=0))

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.147

Running the Simulation


At this point you are ready to run a transient analysis. The simulate method is invoked on the MBS
model. A validation process is performed on each of the entities that make up the model. This is
a necessary step to ensure that only correct models are being simulated. Note that the simulate
command can be invoked with an optional flag, returnResults, set to True. This stores the results of
the simulation into a run container for further post-processing, as shown below.

You can also generate an output file that can be imported into MotionView for animation.

Issue the following command:

In [15]: run=model.simulate(type="DYNAMIC", returnResults=True,


end=3, steps = 3000)
model.generateOutput()

Generating a Plot and Animation

Issue the following command:

%matplotlib inline
force = run.getObject(forceRequest)
depth = run.getObject(depthRequest)
from matplotlib import pyplot
pyplot.subplot(2,1,1)
pyplot.plot(force.times, force.get
Component(0),'r',force.times, force.getComponent(1))
pyplot.title("Contact Force Magnitude")
pyplot.xlabel("Time(s)")
pyplot.ylabel("Contact Force (N)")
pyplot.grid(True)
pyplot.legend(["Cam-Slotted Contact","Pin-Slotted Contact"],loc="upper
left",prop={'size':8})
pyplot.subplot(2,1,2)
pyplot.plot(depth.times, depth.getComponent(0),'r',depth.times,
depth.getComponent(1))
pyplot.title("Maximum Penetration Depth")
pyplot.xlabel("Time(s)")
pyplot.ylabel("Penetration Depth (m)")
pyplot.grid(True)
pyplot.legend(["Cam-Slotted Contact","Pin-Slotted Contact"],loc="upper
left",prop={'size':8})
pyplot.subplots_adjust(hspace=0.5)
pyplot.show()

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.148

Figure 126:

You can import the H3D file generated by this tutorial into MotionView for post-processing. The
animation below illustrates the motion of the slotted link when the cam rotates.

Figure 127:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.149

MV-9003: LuGre Friction Tutorial


In this tutorial, you will learn how to implement and use a new MotionSolve object.
In this tutorial, you will learn how to:
• Create a friction force on a translational joint using the LuGre friction model, and using Object
Oriented Design with classes.

A class is a blueprint, or template, that allows you to create a higher level entity and treat it just like
any other MotionSolve object.

In this example, you will combine a series of MotionSolve entities into a class called LuGre to define a
new modeling element that exhibits new behavior. This process is called aggregation and MotionSolve
provides a special composite class to represent such objects.

Composite is a special class that allows you to aggregate entities, such as parts, markers, forces,
differential equations, and other MotionSolve primitives. A composite class object behaves just like any
other solver object except it is a collection of entities conveniently packaged together. They behave as
atomic entities and can be instantiated multiple times.
The advantage of using the composite class is that the LuGre object inherits behaviors from the base
class. In particular, you will be able to modify the LuGre object at run-time, just like you would issue a
modify command on any other MotionSolve primitive object, such as a part or a marker. The example
below illustrates how you can create your own composite class. First, you'll examine the LuGre friction
model.

LuGre Friction Model


The LuGre friction uses a bristle to model the friction force. Friction is modeled as the average deflection
force of elastic springs between two mating surfaces. When a tangential motion is applied, the bristles
deflect like springs. If the deflection is sufficiently large, the bristles start to slip. The slip velocity
between the mating surfaces determines the average bristle deflection for a steady state motion. It is
lower at low velocities, which implies that the steady state deflection decreases with increasing velocity.

Figure 128:

The LuGre model is defined in terms of the following input parameters:


• = Stiction to dynamic friction transition velocity
• = Coefficient of static friction

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.150

• = Coefficient of dynamic friction

• = Bristle stiffness
• = Bristle damping
• = Viscous coefficient

These variables are used in the formulation:


• Velocity in joint v =


Stribeck factor


The normal force
• Coulomb friction
• Static Friction


ODE defining bristle deflection

• The friction force

The LuGre friction force consists of four atomic elements:


• DIFF defining the bristle deflection
• MARKER defining the point of action of the friction force
• FORCE defining the friction element
• REQUEST capturing the friction force on the block

Loading the Msolve Module

1. Load the msolve module, which is done by issuing this command:

In [1]: from msolve import*

The above command requires the msolve module to be in your computer path. Assuming the
above is successful, you have now imported the msolve names in the current namespace. This
means that you have access to all the classes and functions defined in msolve and you can start
creating the LuGre class and supporting model.

Below is the entire implementation of the class. Each section will be reviewed in the paragraphs
following the code cell.

In [2]: # Create a LuGre Composite Class


class LuGre(Composite):
joint = Reference (Joint)
vs = Double (1.E-3)
mus = Double (0.3)

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.151

mud = Double (0.2)


k0 = Double (1e5)
k1 = Double (math.sqrt(1e5))
k2 = Double (0.4)
def createChildren (self):
"""This is called when the object is created so the children objects
"""
# The DIFF defining bristle deflection
self.diff = Diff(routine=self.lugre_diff, ic=[0,0])

# The MARKER on which the friction force acts


self.im = Marker()

# The FORCE defining the friction force


self.friction = Sforce (type="TRANSLATION",
actiononly = True,
routine = self.lugre_force,
)

# The REQUEST capturing the friction force


self.request = Request (type="FORCE", comment="Friction force")
def updateChildren(self):

# Set topology
self.friction.i =self.joint.iself.friction.j =self.joint.jself.im.setValues
(body=self.joint.i.body, qp=self.joint.i.qp, zp=self.joint.i.zp)
self.request.setValues (i=self.im, j=self.joint.j, rm=self.joint.j)
def validateSelf(self, validator):
validator.checkGe0 ("vs")
validator.checkGe0 ("mus")
validator.checkGe0 ("mud")
validator.checkGe0 ("k0")
validator.checkGe0 ("k1")
validator.checkGe0 ("k2")
if self.mud > self.mus:
msg = tr("Mu dynamic({0}) needs to be smaller than Mu static ({1})",
self.mud,self.mus)
validator.sendError(msg)

2. Now that the class has been defined, you need to to fill the implementation details. The LuGre
friction uses a single component force between two bodies, and a first-order differential equation
that models the average deflection of the bristles as a function of slip velocity, coefficients of
friction, and normal force. First you'll work on the Single Component Force. The goal of the Sforce
function (normally called SfoSub) is to compute and return the scalar value of the friction force.
The three component depicted here are computed separately in the force function.

def lugre_diff(self, id, time, par, npar, dflag, iflag):


"Diff user function"
i = self.joint.i
j = self.joint.j
vs = self.vs
mus = self.mus
mud = self.mud
k0 = self.k0

z = DIF(self)
v = VZ(i,j,j,j)

N = math.sqrt (FX(i,j,j)**2 + FY(i,j,j)**2)


fs = mus*N
fc = mud*N

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.152

p = -(v/vs)**2
g = (fc + (fs - fc) * math.exp(p))/k0
def smooth_fabs(x):
returnmath.fabs(x) # temp solution
if iflag or math.fabs(g) <1e-8:
return v
else:
return v - smooth_fabs(v) * z / g
def lugre_force (self,id, time, par, npar, dflag, iflag):
"Friction Force user function"
i = self.joint.i
j = self.joint.j
diff = self.diff
k0 = self.k0
k1 = self.k1
k2 = self.k2

v = VZ(i,j,j,j)
z = DIF(diff)
zdot = DIF1(diff)

F = k0*z + k1*zdot + k2*v


#print "Time=", time, " V=", v, " Z=", z, " ZDOT=", zdot, " F=", F
#print "k0*z=", k0*z, " k1*zdot=", k1*zdot, " k2*v=", k2*v
return -F

The composite class LuGre is inherited from the built-in composite class. You have to write two
special methods, createChildren and setChildDataValue, to define the behavior of this class.
You can also optionally write a validate method, validateSelf.

Each composite class must have two methods.


1. The first method is called createChildren. It is used to create all the MotionSolve entities
that are needed by the composite class. When the composite class object is created,
the createChildren method is invoked. This happens only once, at the creation of the
composite object. In createChildren, you will instantiate various MotionSolve objects and
define their immutable properties.
2. The updateChildren method is used to define all the mutable properties of the class and
updates the class object with the new values. This facilitates modifying those values at
runtime, when the solver is running and it can be done easily just like any other primitive
MotionSolve objects. This is explained in more detail later in the tutorial.

An optional method called validateSelf can be defined. This method checks the input to ensure
that the data provided to the LuGre class interface is physically meaningful. For example, by
verifying that the static friction coefficient is larger than the dynamic friction coefficient.

After the methods described above, there are two additional functions. These are the Sforce
and Diff user written subroutines. Note that these functions are created directly within the
class definition. The advantage of doing this is to make the class properties available to the
implementation of the subroutines.

This obviates the need to pass parameters to the user subroutines.

The Sforce subroutine computes the three components of the friction Sforce, as described in the
image below.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.153

Figure 129:

Note that the function's first argument is self because Sforce and Diff user written subroutines
are Python callable class methods. Also, note that the signature of the Sforce function is in the
familiar form (id, par, npar, and so on) but you are not actually unpacking the parameters, as
there is no need to pass anything to the subroutine.

You are in fact accessing the properties of the LuGre instance by using the dot operator on the
instance itself.

Similarly, you can define the differential equation. This also accesses the LuGre properties directly.

Creating a Model
Now that you have completely defined the LuGre class and implemented the two methods (Sforce and
Diff), you have to create a suitable model for testing.

You can use a simple friction element defined between two bodies on a sliding block. The sliding block is
constrained by a translational joint and a forcing function acts upon it.

You can study the effect of changing the Static Friction Coefficient μs on the computed friction force by
modifying it between simulations.

The model is created inside a function, called _slidingblock, in the code cell below. This is done purely
for convenience.

1. Issue this command:

In [2]:
################################################################################
# Model definition #
################################################################################
def sliding_block ():
"""Test case for the LuGre friction model
Slide a block across a surface.
The block is attached to ground with a translational joint that has
LuGre friction
"""
model = Model ()

Units (mass="KILOGRAM", length="METER", time="SECOND", force="NEWTON")


Accgrav (jgrav=-9.800)

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.154

Integrator (error=1e-5)
Output (reqsave=True)

# Location for Part cm and markers used for the joint markers
qp = Point (10,0,0)
xp = Point (10,1,0)
zp = Point (11,0,0)

ground = Part (ground=True)


ground.jm = Marker (part=ground, qp=qp, zp=zp, xp=xp, label="Joint Marker")

block = Part (mass=1, ip=[1e3,1e3,1e3], label="Block")


block.cm = Marker (part=block, qp=qp, zp=zp, xp=xp, label="Block CM")

# Attach the block to ground


joint = Joint ( type="TRANSLATIONAL",
i = block.cm,
j = ground.jm,
)

# Apply the LuGre friction to the joint


model.lugre = LuGre (joint=joint)

# Push the block


Sforce (
type="TRANSLATION",
actiononly =True,
i = block.cm,
j = ground.jm,
function ="3*sin(2*pi*time)",
label ="Actuation Force",
)

# Request the DISPLACEMENT, VELOCITY and FORCE of the Joint


model.r1 = Request (
type ="DISPLACEMENT",
i = block.cm,
j = ground.jm,
rm = ground.jm,
comment ="Joint displacement",
)
model.r2 = Request (
type="VELOCITY",
i = block.cm,
j = ground.jm,
rm = ground.jm,
comment ="Joint velocity",
)
model.r3 = Request (
type="FORCE",
i = block.cm,
j = ground.jm,
rm = ground.jm,
comment ="Joint force",
)
return model

Note that the creation of the LuGre friction is done by calling one single line:

model.lugre = LuGre (joint=joint)

All you need to do is pass the Translational Joint, joint, to the LuGre class instantiation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.155

All of the properties that are used in the calculation of the Friction Force default to the values
defined in the class interface. You can, of course, pass different values to the LuGre class but for
now, you will use default values.
2. Test the model and plot some results.
a) Create a model by calling the following function:

model = sliding_block ()

b) Run a 4 second simulation and store the results of the run in an appropriate container:

run = model.simulate (type="DYNAMICS", returnResults=True, end=4, dtout=.01)

Now that you have a run container with a series of requests, you can selectively plot some of
the relevant channels, such as the magnitude of the friction force, the block velocity,and its
displacement as a function of time.
3. Import a plotting package:

# this line causes the plots to be inlined on this web page


%matplotlib inline
import matplotlib.pyplot as plt

4. Then, extract some of the data to plot. At this point, you can create a plot object and display three
separate curves.
• The friction force.
• The velocity of the block.
• The block displacement.

def plot(model):# get the channels from the model...


disp = run.getObject (model.r1)
velo = run.getObject (model.r3)
force = run.getObject (model.r2)

plt.subplot(3, 1, 1)
plt.plot(force.times, force.getComponent (3))
plt.title('Friction force')
plt.ylabel('force [N]')

plt.subplot(3, 1, 2)
plt.plot(velo.times, velo.getComponent (3),'r')
plt.title('Block Velocity')
plt.ylabel('velocity [m/s]')
plt.subplot(3, 1, 3)
plt.plot(disp.times, disp.getComponent (3),'g')
plt.title('Block Displacement')
plt.xlabel('time (s)')
plt.ylabel('travel [m]')

plt.grid(True)
plt.tight_layout()

# Show the plot


plt.show()

In [7]: plot(model)

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Using the MotionSolve API p.156

Figure 130:

5. To increase the friction static coefficient, set the LuGre to a different value and continue the
simulation for an additional four seconds.

In [8]: model.lugre.mus= 0.4


run = model.simulate (type="DYNAMICS", returnResults=True, duration=4, dtout=.01)

# replot the quantities and observe the changes to the Friction Force
plot(model)

Figure 131:

With the increased , you can see that the forcing function cannot overcome the bristle resistance
and the block is not able to move.

Proprietary Information of Altair Engineering


User Subroutines 5
User Subroutines

This chapter covers the following:

• MV-1024: Using User Subroutines in MotionSolve Models (p. 158)


• MV-7001: Building User Subroutines in MotionSolve (p. 165)
• MV-7006: Python UserSub for MotionSolve (p. 174)
MotionSolve Tutorials
User Subroutines p.158

MV-1024: Using User Subroutines in MotionSolve


Models
In this tutorial, you will learn about the benefits of user subroutines in defining motion.

User subroutines are created for various reasons. Some include:


• To describe a physical phenomenon that is determined by non-trivial logical conditions.
• When it is impractical to formulate a complicated expressions in an explicit form.
• To take full advantage of a programming language like C/C++ or Fortran and simpler programming
with interpreters like Tcl, Python, and Ruby.

To use your own subroutines in MotionSolve, follow these steps:

1. Create a C/C++, FORTRAN, Tcl, or Python source file that contains the user-defined modeling
entity.
Refer to the MotionSolve User's Guide for a list of supported solver subroutines and a general
guideline on setting up and using subroutines in your model.
2. Obtain a DLL by compiling and linking your user subroutine(s) for C/C++ or Fortran, or use the
source file directly for Tcl or Python.
MotionSolve supports two separate levels of user DLLs and the algorithm attempts to resolve the
symbols, starting from the most specific library.
1. Element Level DLL (most specific)
Specify the name of the DLL in the modeling element definition.
2. Machine Level DLL
You can create an environment variable called MS_USERSUBDLL and set it to the
DLL file. This environment variable is not defined automatically when MotionSolve is
installed. However, Fortran, and C/C++ DLLs are provided in the installation folder
<installation_directory>\hwsolvers\usersub\subdll\win32\. This allows you to run
some of the test models that use user subroutine DLLs.

Note: The DLL that is loaded is based on the "most specific" rule: number one
overrides number two.

3. Modify the corresponding entity in your multibody model to be "user defined" and point it to your
DLL. This can be done in two ways:
1. By modifying the entity in the MotionView interface.
2. By editing the MotionSolve XML file.

Regardless of the method you select, you will end up with an XML file where one or more entities
are now user defined.

For example, consider the coupler modeling element in the XML file:

<Constraint_Coupler
id = "1"
type = "TwoJoint"

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.159

i_marker_id_joint1 = "30603030"
j_marker_id_joint1 = "30602031"
body1_id_joint1 = "30603"
body2_id_joint1 = "30602"
joint_type_joint1 = " "
i_marker_id_joint2 = "30603040"
j_marker_id_joint2 = "30604040"
body1_id_joint2 = "30603"
body2_id_joint2 = "30604"
joint_type_joint2 = " "
usrsub_param_string = "USER(-8.5)"
usrsub_dll_name = "C:/work/testsub.dll">
</Constraint_Coupler>

The usrsub_dll_name argument defines C:/work/testsub.dll as the element level DLL for this
coupler element. Any element can be defined by pointing to a different DLL.

The coupler modeling element in the XML file can also be defined as:

<Constraint_Coupler
id = "1"
type = "TwoJoint"
i_marker_id_joint1 = "30603030"
j_marker_id_joint1 = "30602031"
body1_id_joint1 = "30603"
body2_id_joint1 = "30602"
joint_type_joint1 = " "
i_marker_id_joint2 = "30603040"
j_marker_id_joint2 = "30604040"
body1_id_joint2 = "30603"
body2_id_joint2 = "30604"
joint_type_joint2 = " "
usrsub_param_string = "USER(-8.5)"
usrsub_dll_name = "NULL">
</Constraint_Coupler>

In this case, MotionSolve looks for a machine level DLL as defined by the value of the
MS_USERSUBDLL environment variable.
4. Run MotionSolve, verifying that it picks up the appropriate DLL during simulation.

Copy the model file required for this exercise, Pendu_model.mdl, from the mbd_modeling\motionsolve
to your <working directory>.

Using an Expression to Define Motion


1. Launch a new MotionView session.
2. Load the MDL model file Pendu_model.mdl from your <working directory>.
3. From the Project Browser, right-click on Model and select Add Constraint > Motions (or right-
click Motions from the toolbar).

4. Add a Displacement motion to the revolute joint between the pendulum body and the ground
body.
5. Click the Properties tab.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.160

6. Set an expression of 3.142* TIME for the displacement motion.


7. Click Outputs to access the Outputs panel.
Review the output request.
8. Click Run , to access the Run panel.

9. Click Save and run current model and browse to your <working directory>. Specify the name
as Pendu_model.xml for the MotionSolve input XML file.
10. Confirm that the Simulation type is set to Transient.
11. Specify 1 as the End Time.
12. Click Check to check for any modeling errors.

13. After verifying that there are no errors, click Run.


14. Once the run is complete, the Animate button is activated. Click Animate to view the animation of
the simulation.
15. From the Run panel, click Plot to view the time-histories of the output request.

Using the MOTSUB User Subroutine to Define Motion


In this step, you will use the user subroutine MOTSUB. This user subroutine has been compiled and linked
in the DLL ms_csubdll.dll. This machine level DLL is provided in the HyperWorks installation. For
the Windows 32-bit platform, the DLL is located at: <installation_directory>\hwsolvers\usersub
\subdll\WIN32\.

You will use the ms_csubdll.dll as a machine level DLL.

1. Create an environment variable MS_USERSUBDLL and set the value to the DLL file.
a) For Windows 32-bit platform users, set the value to <installation_directory>\hwsolvers
\usersub\subdll\WIN32\ms_csubdll.dll.
b) Right-click on the My Computer icon. From the Advanced tab, select Environment
variables > New (under User variables).
c) Set Variable name to MS_USERSUBDLL.
d) Set Variable value to <installation_directory>\hwsolvers\usersub\subdll
\win32\ms_csubdll.dll.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.161

Figure 132:

2. With the Pendu_model.mdl from the previous step open in the MotionView model window, go to
the Motions panel, .

3. From the Connectivity tab, check the User-defined properties check box.
4. Click the User-Defined tab and enter USER(100001,5,2) in the text-box.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.162

Figure 133:

Note: To use an element level (specific) DLL/Interpreter function, you can check the
Use local dll and function name check-box and point to the DLL using the folder
icon, .

The string USER(100001,5,2) is used to pass arguments to the MOTSUB user subroutine.
The MOTSUB user subroutine calculates motion using the parameters par1 and par2 in
USER(branch_id, par1, par2) as follows:

motion_val= par1*TIME^par2

5. From the File menu, select Export > Model.


The Export Model panel is displayed.
6. Specify the file name as Pendu_model_usersub.mdl.
7. Click Run to access the Run panel.

8. Click Save and run current model and browse to your working directory. Specify
Pendu_model_usersub.xml for the MotionSolve input XML file.
9. Confirm that the Simulation type is set to Transient.
10. Specify 1 as the End Time.
11. From the Main tab, click Check to check for any modeling errors.
12. After verifying that there are no errors, click Run.
13. In the plot window, plot the results from the ABF file Pendu_model_usersub.abf to overlay the
results on top of the results from the Pendu_model.abf file
14. In the animation window, check the Overlay option on the Load Model panel.
15. Select the file Pendu_model_usersub.h3d using the Load model folder icon .

16. Click Apply.


This will overlay the new animation over the existing animation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.163

Figure 134:

Note: If the value of the usrsub_param_string is set as "USER(3.142, 1)" the


results from step 2 will be the same as results from step 1.

17. Open the MotionSolve XML file Pendu_model.xml (saved in step 1) from the working directory.
18. Browse through the XML file to locate the Motion_Joint block.

<Motion_Joint
id = "301001"
label = "Motion 0"
type = "EXPRESSION"
val_type = "D"
expr = "3.142*TIME"
joint_id = "301001"
joint_type = "R"
/>

19. Open the MotionSolve XML file Pendu_model_usersub.xml from the working directory.
20. Browse through the XML file to locate the Motion_Joint block.

<Motion_Joint
id = "301001"
label = "Motion 0"
type = "USERSUB"
val_type = "D"
usrsub_param_string = "USER(100001,5,2)"
usrsub_dll_name = "NULL"

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.164

usrsub_fnc_name = "MOTSUB"
joint_id = "301001"
joint_type = "R"
/>

Note: When the value for the usrsub_dll_name parameter in the above block is set to
NULL, MotionSolve looks for the subroutine in a machine level DLL. This DLL is passed
to MotionSolve by the MS_USERSUBDLL environment variable.

21. To use an element level DLL, set the value of the usrsub_dll_name parameter to point to the DLL.
The usrsub_param_string parameter is used to pass arguments to the user subroutine.
For example, the MOTSUB user subroutine calculates motion using the parameters par1 and par2 in
USER(branch_id, par1, par2) as follows:

motion_val= par1*TIME^par2

MotionSolve uses the value returned from the user subroutine to calculate the motion.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.165

MV-7001: Building User Subroutines in MotionSolve


In this tutorial, you will learn how to compile and build a MotionSolve user subroutine.
The user subroutine can be implemented as C/C++ or FORTRAN source code, C/C++ or FORTRAN
object files, or a combination of these.

For your convenience, MotionSolve contains a subroutine build tool for Windows and Linux that can
build the subroutine for you. Using this subroutine requires no programming knowledge.

You can also build your user subroutine using an integrated development environment like Microsoft®
Visual Studio® on Windows. This is explained in this tutorial.

Table 1: Minimum Software Requirements to Compile and Build MotionSolve User Subroutine DLLs

Windows Linux

Microsoft Visual Studio version 2005, both Express GCC, version 4.1.2
and Professional

Intel Visual FORTRAN Compiler 10

Using the MotionSolve Subroutine Build Tool to Create


Shared Libraries
The Altair Subroutine Builder is included in the MotionSolve installation for both Windows and Linux.

Follow these steps to build a MotionSolve-compatible shared library using available source code.

1. Launch the build tool on Windows by clicking Start > All Programs > HyperWorks (64-bit) >
Tools > MotionSolve Subroutine Builder
The MotionSolve Subroutine Builder dialog is displayed:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.166

Figure 135:

2. To launch the build tool on Linux, navigate to <altair_root>/altair/scripts/ and issue the
command:

./motionsolve_subroutine_builder

The GUI is displayed:

Figure 136:

Specifying Source Code or Object Files


The next step is to specify the source code or the object files that you will be using to build the shared
library. The following are valid source file types and can be used to build a shared library:
• C/C++ source code (*.c, *.cpp, *.cxx)
• FORTRAN source code (*.f, *.f90)
• FORTRAN or C/C++ object files (*.obj in Windows, *.o in Linux)
• A combination of the above.

Note: The remainder of this section demonstrates using the build tool on Windows. The
steps for using the tool on Linux are identical.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.167

Important: The source code or object files must all be located in the same directory.
You must have write-to-disk permissions for this directory. If you do not have write-to-
disk permissions for this directory, please copy the source code to a location where you
do have write-to-disk permissions.
Also, if your source/object code is located in different folders on your disk, please copy
all source/object code, along with any relevant files (like headers, for example) to one
common directory. Use this as your working directory in the following steps.

1. To specify the source/object files, click next to the Source File(s) field.

Figure 137:

2. Navigate to your working directory and choose the source files as required. You can choose
multiple files by holding down the CTRL button while clicking the file names, or by clicking and
dragging your mouse pointer.
3. Click Open to select these files.

Figure 138:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.168

Specifying the Output Directory


Next, you will specify the output directory where you would like the shared library to be built. Again,
you must have write-to-disk permissions for this directory.

1. Click Open next to the Output Name field.

Figure 139:

2. Navigate to the directory where you want the shared library to be built. Click Select Folder to
choose the current folder as the output directory.
3. Before building the shared library, you need to specify a name for the shared library. To do this,
simply type in the name (without the extension) into the Output Name field.

Note: The shared library name must contain only alphanumeric characters (A-Z, a-z,
0-9) with the exception of the underscore ("_") character.

Figure 140:

Building the Shared Library

1. To build your shared library, click Build.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.169

Figure 141:

2. For the Windows platform, if you have multiple compilers installed on your computer, you can
choose which compiler to use while building your shared library.

Figure 142:

Upon building the source files successfully, the following dialog is displayed:

Figure 143:

Additionally, you will see the shared library built by the tool in your working directory (C:\Test in
this case). You can use this library in a MotionSolve simulation.

The tool also creates a temporary directory inside your working directory while building the shared
library. The contents of this temporary directory can be used for debugging and informational
purposes.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.170

Note: The temporary directory created inside of your working directory contains some
useful information:
• build.bat: a batch file that contains the compiler and linker commands used to
build the shared library.
• build_output.log: a log file that contains messages from the compiler and linker.
The contents of this file are useful when debugging an unsuccessful build.
For a successful build, this directory also contains compiled objects, the linked
library and other temporary files. If you specified only C/C++ source files and/or
object files, the tool also creates a Microsoft® Visual Studio® solution file in this
directory.

If, however, your build is unsuccessful, the following dialog is displayed:

Figure 144:

3. To investigate the cause of build failure, look at the build_output.log file at the location stated
in the dialog above. This file typically contains compiler/link time errors or warnings that may help
you debug your source code.
4. After you have finished using the tool, you can exit by clicking Quit. If you built a shared library
before quitting, you are given the option to remove the temporary folder created by the tool.

Frequently Asked Questions

Can the tool build a shared library when both Fortran and C/C++ source code is
specified?
Yes, the tool can handle mixed source code as well as object files.

What platform does the tool build my library for?


The supported platforms are 64-bit Windows and 64-bit Linux.

Is my shared library a debug or release version?


The shared library created is a release version library.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.171

Where can I get sample templates for the syntax of the C/C++/Fortran code?
Sample user subroutine code is provided in the HyperWorks installation in the following locations:
• For C/C++ source code: <install>\Altair\<version>\hwsolvers\motionsolve\usersub\c_src
• For Fortran source code: <install>\Altair\<version>\hwsolvers\motionsolve\usersub\f_src

Note: For MotionSolve to use the functions defined in the source code, these functions
must be exported on the Windows platform (on Linux, all functions are automatically
exported). The syntax to do this for C/C++ and Fortran is described below.

C/C++
Include the header file msolvsub_c_include.h (located in <install>\Altair
\<version>\hwsolvers\motionsolve\usersub\c_src\include) in your code. To
export a function, use the keywords CLINKAGE, DLLFUNC, and STDCALL.

#include " msolvsub_c_include.h"


#include "stdlib.h"
CLINKAGE
DLLFUNC
void
STDCALL
ARYSUB (int *id, double *time, double *par,int *npar, int *dflag, int
*iflag, int *nvalue, double *value)
{
}

Fortran
In Fortran syntax, the same function above can be exported as shown below:

SUBROUTINE
ARYSUB (ID, TIME, PAR, NPAR, DFLAG,
& IFLAG, NVALUE, VALUE)
!DEC$ ATTRIBUTES DLLEXPORT ::
ARYSUB

Does the order in which I choose the source files matter?


Yes, this can matter in certain cases. For example, when building Fortran source code and defining
MODULES, you may want to include the source file that contains the definition of any defined modules
before the source files that refer to these modules.

I am not able to compile Fortran files even though I have a supported Intel Fortran
compiler installed. What's wrong?
The build tool relies on an environment variable to detect the version of the Intel Fortran compiler and
its location on your machine. Make sure you have the environment variable IFORT_COMPILERxx (where
xx is the version of the compiler - 10, 11 or 12) defined correctly on your system and pointing to the
installed version.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.172

Using the Microsoft® Developer Studio to Build a Shared


Library
To successfully build a shared library using the steps below, you will need to have write-to-disk
permissions for your HyperWorks installation directory.

Building a C++ User Subroutine DLL using Microsoft® Visual


Studio®
To successfully build a shared library using the steps below, you will need to have write-to-disk
permissions for your HyperWorks installation directory.
1. Open Microsoft Visual Studio 2005 (Express and Professional Editions will work).
2. From the File menu, select Open > Project/Solution.
3. Browse to <install>\Altair\<version>\hwsolvers\motionsolve\usersub\c_project, select
the file ms_csubdll.vcproj and click Open.

Note: If you are using a version newer than Visual Studio 2005, you will be prompted
to convert the project file. Please proceed with the default options for the conversion.
Once converted, the new project file is loaded to your workspace.

In the Solution Explorer, the CPP subroutines that are part of the solution are listed.
4. Double-click any of the CPP files that you want to modify/view and make the required changes.
5. Click Save to save the changes made to the file.
6. Choose the configuration for your shared library.

Figure 145:

Make sure that the target type for the shared library matches your HyperWorks installation. For
example, choose x64 for a 64-bit installation of HyperWorks.
7. Select Build > Build Solution to build the DLL. You will be prompted to save the solution. Save
the solution in a directory of your choice.
After successfully completing the build, Visual Studio displays a message as shown below:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.173

Figure 146:

The DLL ms_csubdll.dll is located in <install>\Altair\<version>\hwsolvers\motionsolve


\usersub\c_project\<platform>\<config>\ms_csubdll.dll.

Building a FORTRAN User Subroutine DLL using Microsoft® Visual


Studio®
The same steps can be repeated to build a FORTRAN user subroutine DLL for MotionSolve. The only
difference is that the Visual Studio project file to be opened is ms_fsubdll.vfproj. All the other steps
remain the same.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.174

MV-7006: Python UserSub for MotionSolve


In this tutorial, you will learn how to use Python to make a user subroutine for MotionSolve and convert
a model with six SFOSUBs, written in C, into a Python usersub.

Note: It is assumed that you are familiar with Python and MotionSolve XML syntax.

Using scripting language such as Python gives you power with reduced complexity. These scripts
are interpreted and do not require compiling. Therefore, you do not need a building tool to build
subroutines. Furthermore, scripts are easier to read and understand, and can be used for faster
prototyping.

If you do not have much programming experience, writing scripts for user-subroutines is simpler
than writing C code. For a C user, the usage is even simpler. Besides following the language syntax of
Python, you only need to follow the rules to convert the C code into Python scripts.

For your reference, a sample set of Python user subroutines is available in the hwsolvers\motionsolve
\usersub\py_src folder.

Rules for Written Python User Subroutines


It is easy to understand the usage for py_* utility functions from the usage of their c_* counterparts,
with the help of the following rules:
1. The output arguments should be moved to the left-hand-side.

c_datout(&istat);

becomes

istat = py_datout()

In C utility functions, the input and output arguments are combined in an argument list. In
Python, the arguments of the py_* utility functions are strictly the input arguments. All output
arguments should be moved to the left-side as return values of the function call.
2. In C utility functions, any input or output array argument is generally followed by an integer
argument for the array size. In Python utility functions, the integer argument for the array size is
removed because it is not necessary.

ipar[0] = (int)par[0];
ipar[1] = (int)par[1];
c_sysfnc("DM", ipar, 2, &dm, &errflg);

simply becomes

[dm, errflg] = py_sysfnc("DM", [par[0],par[1]])

and

ipar[0] = (int)par[1];
ipar[1] = (int)par[0];

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.175

c_sysary("TDISP", ipar, 2, u1, &nstates, &errflg);

becomes

[u1, errflg] = py_sysary("TDISP", [par[1],par[0]])

3. Change the function name from c_* to py_*.

c_rcnvrt(sys1, coord1, sys2, coord2, &istate);

becomes

[coord2, istate] = py_rcnvrt(sys1, coord1, sys2)

Converting C Sub into Python Sub


1. In this example, the model uses six SFOSUBs written in C code as shown below:

DLLFUNC void STDCALL SFOSUB (int *id, double *time, double


*par, int *npar, int *dflag, int *iflag, double *result)
{
// --- Add your local definitions here ---------------------
double vector[3],dm,vm;
int ipar[2], iord;
int errflg;
// --- Add your executable code here -----------------------
int itype = (int)par[0];
iord = 0;
if (itype==50)
{
ipar[0] = (int)par[1];
ipar[1] = (int)par[2];
c_sysfnc("DM", ipar, 2, &dm, &errflg);
ipar[0] = (int)par[3];
ipar[1] = (int)par[4];
c_sysfnc("VM", ipar, 2, &vm, &errflg);
c_impact(dm, vm, par[5], par[6], par[7], par[8], par[9], iord,
vector, &errflg);
*result = vector[0];
}
}

2. Following the rules specified in last section, the corresponding Python script is shown as:

def SFOSUB (id, time, par, npar, dflag, iflag):

[dm, errflg] = py_sysfnc("DM", [par[0],par[1]])


[vm, errflg] = py_sysfnc("VM", [par[2],par[3]])
[vector, errflg] = py_impact(dm, vm, par[4], par[5],
par[6], par[7],par[8],0
)return vector[0]

3. Besides the Python scripts, you also need to specify in the XML model the Python scripts that are
used in the user subroutine. MotionSolve provides this definition through two attributes in the
corresponding elements that uysrsub can be defined.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.176

1. interpreter = " Python"


2. script_name = " script_name.py

This combination replaces the attribute "usrsub_dll_name" in that element.


4. The following image shows the difference between using C user sub and Python user sub in this
example:

Figure 147:

5. In the original model, there are six Force_Scalar_TwoBody elements that use SFOSUB written in
C:

<Force_Scalar_TwoBody
id = "30701"
type = "Force"
i_marker_id = "30701010"
j_marker_id = "30701011"
usrsub_param_string =
"USER(50,30301010,30401010,30301010,30401010,10,10,2.0,0.001,0.01)"
usrsub_dll_name = "NULL"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody
id = "30801"
type = "Force"
i_marker_id = "30801010"
j_marker_id = "30801011"
usrsub_param_string = "
USER
(50,30301010,30501010,30301010,30501010,10,10,2.0,0.001,0.01)"
usrsub_dll_name = "NULL"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.177

id = "30901"
type = "Force"
i_marker_id = "30901010"
j_marker_id = "30901011"
usrsub_param_string =
"USER
(50,30301010,30601010,30301010,30601010,10,10,2.0,0.001,0.01)"
usrsub_dll_name = "NULL"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody
id = "31001"
type = "Force"
i_marker_id = "31001010"
j_marker_id = "31001011"
usrsub_param_string =
"USER(50,30401010,30501010,30401010,30501010,10,10,2.0,0.001,0.01)"
usrsub_dll_name = "NULL"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody
id = "31101"
type = "Force"
i_marker_id = "31101010"
j_marker_id = "31101011"
usrsub_param_string =
"USER(50,30401010,30601010,30401010,30601010,10,10,2.0,0.001,0.01)"
usrsub_dll_name = "NULL"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody
id = "31201"
type = "Force"
i_marker_id = "31201010"
j_marker_id = "31201011"
usrsub_param_string =
"USER(50,30501010,30601010,30501010,30601010,10,10,2.0,0.001,0.01)"
usrsub_dll_name = "NULL"
usrsub_fnc_name = "SFOSUB"
/>

6. After changing C SFOSUB into Python SFOSUB, the XML content above is replaced with the
following:

<Force_Scalar_TwoBody
id = "30701"
type = "Force"
i_marker_id = "30701010"
j_marker_id = "30701011"
usrsub_param_string =
"USER(30301010,30401010,30301010,30401010,10,10,2.0,0.001,0.01)"
interpreter = "Python"
script_name = "script/sfosub.py"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody
id = "30801"
type = "Force"
i_marker_id = "30801010"
j_marker_id = "30801011"
usrsub_param_string = "USER
(30301010,30501010,30301010,30501010,10,10,2.0,0.001,0.01)"

Proprietary Information of Altair Engineering


MotionSolve Tutorials
User Subroutines p.178

interpreter = "Python"
script_name = "script/sfosub.py"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody
id = "30901"
type = "Force"
i_marker_id = "30901010"
j_marker_id = "30901011"
usrsub_param_string =
"USER(30301010,30601010,30301010,30601010,10,10,2.0,0.001,0.01)"
interpreter = "Python"
script_name = "script/sfosub.py"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody
id = "31001"
type = "Force"
i_marker_id = "31001010"
j_marker_id = "31001011"
usrsub_param_string =
"USER(30401010,30501010,30401010,30501010,10,10,2.0,0.001,0.01)"
interpreter = "Python"
script_name = "script/sfosub.py"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody
id = "31101"
type = "Force"
i_marker_id = "31101010"
j_marker_id = "31101011"
usrsub_param_string =
"USER(30401010,30601010,30401010,30601010,10,10,2.0,0.001,0.01)"
interpreter = "Python"
script_name = "script/sfosub.py"
usrsub_fnc_name = "SFOSUB"
/>
<Force_Scalar_TwoBody
id = "31201"
type = "Force"
i_marker_id = "31201010"
j_marker_id = "31201011"
usrsub_param_string =
"USER(30501010,30601010,30501010,30601010,10,10,2.0,0.001,0.01)"
interpreter = "Python"
script_name = "script/sfosub.py"
usrsub_fnc_name = "SFOSUB"
/>

7. With these changes (C code into Python code and XML model change), the model with Python user
subroutines are ready to run with MotionSolve.

Proprietary Information of Altair Engineering


Advanced Simulation 6
Advanced Simulation

This chapter covers the following:

• MV-7000: Modeling Differential Equations Using MotionView and MotionSolve (p. 180)
• MV-7002: Co-simulation with Simulink (p. 187)
• MV-7003: Simulating a Single Input Single Output (SISO) Control System Using MotionView and
MotionSolve (p. 199)
• MV-7004: Inverted Pendulum Control Using MotionSolve and MATLAB (p. 203)
• MV-7005: Linking Matlab/Simulink Generated Code (Simulink Coder) with MotionSolve (p. 210)
• MV-7008: Co-simulation with AcuSolve (p. 220)
• MV-7009: Remote Co-simulation with Simulink (p. 237)
• MV-7010: Co-Simulation with Activate - Quadrotor Control (p. 252)
MotionSolve Tutorials
Advanced Simulation p.180

MV-7000: Modeling Differential Equations Using


MotionView and MotionSolve
In this tutorial, you will build a model and apply solver variables and differential equations before
running the model.

Differential equations are very versatile and have many different applications in modeling multibody
systems. User-defined dynamic states are commonly used to create low pass filters, apply time lags to
signals, model simple feedback loops, and integrate signals. The signal may be used to:
• define forces.
• used as independent variables for interpolating through splines or curves.
• used as input signals for generic control modeling elements.
• define program output signals.

The MotionSolve expressions and user-subroutines allow you to define fairly complex user-defined
dynamic states.

The expression type is used when the algorithm defining the differential equation is simple enough to
be expressed as a simple formula. In many situations, the dynamic state is governed by substantial
logic and data manipulation. In such cases, it is preferable to use a programming language to define the
value of a differential equation. The user-defined subroutine, DIFSUB, allows you to accomplish this.

Building and Analyzing a Simplified Model


In the following exercise, you will build and analyze a simplified model of a pressure vessel blown down
using MotionView and MotionSolve. The following steps outline the process.

1. Specify the following parameters (state variables) as solver variables:

2. Model the following differential equations:

(6)

(7)

(8)

The three states of the system are PT, TT and mT.


3. Specify the initial conditions for the system as:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.181

4. Run the model in MotionSolve and post-process the results in HyperGraph.

Adding a Solver Variable


A solver variable defines an explicit, algebraic state in MotionSolve. The algebraic state may be a
function of the state of the system or any other solver variables that are defined. Recursive or implicit
definitions are not allowed at this time.

Two types of solver variables are available. The first, and probably the most convenient, is the
expression valued variable. The second is the user-subroutine valued variable.
The expression method is used when the algorithm defining the algebraic state is simple. In many
situations, the algebraic state is governed by substantial logic and data manipulation. In those cases, it
is preferable to use a programming language to define the value of a solver variable. The user-defined
subroutine, VARSUB, enables you to do this.

Solver variables are quite versatile and have many different applications in modeling multibody
systems. They are commonly used to create signals of interest in the simulation. The signal may then
be used to define forces, independent variables for interpolation, inputs to generic control elements,
and output signals.

MotionSolve expressions and user-subroutines allow for fairly complex algebraic states to be defined.

For more information, please refer to the MotionView and MotionSolve User's Guides in the online help.

1. Launch a new session of MotionView.


2. From the Project Browser, right-click Model and select Add > Control Entity > Solver Variable
(or right-click Solver Variables from the toolbar).
The Add Solver Variable dialog is displayed.
3. In the Label field, assign the label K to the solver variable.
4. In the Variable field, assign a variable name to the solver variable or leave the default name.
5. Click OK.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.182

Figure 148:

6. From the Properties tab, under Type, select Linear and enter a value of 1.4 in the field.

Figure 149:

7. Repeat steps 1 through 6 to create the three remaining solver variables:

(9)

Modeling Differential Equations


1. From the Project Browser, right-click Model and select Add General MDL Entity > Solver

Differential Equation (or right-click Solver Differential Equation, from the toolbar.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.183

The Add SolverDiff dialog is displayed.


2. In the Label field, assign a label to the solver diff or leave the default label.
3. In the Variable field, assign a variable name to the solver diff or leave the default name.
4. Click Apply twice.
5. Click OK.
Three solver differential equations will be created.
Next, you will model the first differential equation:

This is an implicit differential equation that has a constant ( ). The initial condition of the differential
equation (IC) and its first derivative (IC dot) are known (given).
6. Select SolverDiff 0.
7. From the Properties tab, select Implicit and specify IC and IC dot as 2000 and -58875,
respectively.

Figure 150:

8. Select the type as Expression.


9.
To access the expression builder, click in the text field and select F(x) from the trio of buttons
at the top of the panel.
This will display the Expression Builder. In this dialog, you can enter expressions in text boxes
without extensive typing and memorization. It can be used to construct mathematical expressions.
10. Populate the expression as shown in the image below:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.184

Figure 151:

`-DIF1 ({diff_0.id})/DIF({diff_0.id})+{sv_3.value.lin}*DIF1({diff_1.id})/
DIF({diff_1.id})`

11. Optional: You can use the model tree to access entity variables in your model. As you can see for
the above expression, to refer to the ID of the differential equation, browse for it from the list-tree
on the Properties tab and select the ID. Click Apply.
The name of the selected entity or property is inserted into the expression.
12. Click OK.
The new expression is displayed in the text box on the panel.
13. Repeat steps 6 through 12 to modify the remaining two differential equations:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.185

Implicit: Yes

IC: 560

IC_dot: -4710

Value Expression:

`DIF1({diff_0.id})/DIF({diff_0.id})-DIF1({diff_1.id})/DIF({diff_1.id})-
DIF1({diff_2.id})/DIF({diff_2.id})`

Implicit: No

IC: 0.000256

Value Expression:

`-{sv_1.value.lin} *sqrt(abs({sv_0.value.lin}*DIF({diff_2.id})*DIF({diff_0.id}) /
{sv_2.value.lin}))*0.5787`

Running the Model in MotionSolve


1. Click Run on the toolbar.
The Run panel is displayed.
2. Specify the values as shown below:

Figure 152:

3. From the Main tab, choose Save and run current model.
4. Click on the browser icon and specify a filename of your choice.

5. Click Save.
6. Click Check Model to check the model.

7. To run the model, click Run.


The solver will get invoked here.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.186

8. Post-process the results using HyperGraph.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.187

MV-7002: Co-simulation with Simulink


In this tutorial, you will learn how to use the MotionSolve-Simulink co-simulation interface, driving the
model from Simulink via an S-Function. MotionSolve co-simulates with Simulink using the Inter Process
Communication (IPC) approach.

In IPC co-simulation, the two solvers are run on two separate processes with data being exchanged
through sockets.

Software and Hardware Requirements


Software requirements:
• MotionSolve
• MATLAB/Simulink (MATLAB Version R2015a), Simulink Version 8.5) (or newer)

Note: Older versions of MATLAB/Simulink may work, but the above minimum versions are
recommended and tested

Hardware requirements:
• PC with 64-bit CPU, running Windows 7/10 or higher
• Linux RHEL 6.6 or CentOS 7.2

Inverted Pendulum Controller


Consider an inverted pendulum, mounted on a cart. The pendulum is constrained at its base to the cart
by a revolute joint. The cart is free to translate along the X direction only. The pendulum is given an
initial rotational velocity causing it to rotate about the base.

Both the pendulum and the cart are modeled as rigid bodies. The controller, modeled in Simulink,
provides a control force to the cart to stabilize the inverted pendulum and prevent it from falling. This
control force is applied to the cart via a translational force. The model setup is illustrated in the figure
below.

Figure 153: Inverted Pendulum Model Setup

The pre-designed controller generates a control force that keeps the pendulum upright. The controller
uses the pendulum's orientation and angular velocity along with the cart's displacement and velocity as

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.188

inputs to calculate the direction and magnitude of the force needed to keep the pendulum upright. A
block diagram of the control system is shown below.

Figure 154: Block Diagram Representation of the Controller

In the image above:


• is the angular displacement of the pendulum from its model configuration
• is the angular velocity of the pendulum about its center of gravity as measured in the ground
frame of reference
• is the translational displacement of the cart measured from its model configuration in the ground
frame of reference
• is the translational velocity of the cart measured in the ground frame of reference
• is a reference signal for the pendulum's angular displacement
• is a reference signal for the pendulum's angular velocity
• is a reference signal for the cart's translational displacement
• is a reference signal for the cart's translational velocity

A disturbance is added to the computed control force to assess the system response. The controller
force acts on the cart body to control the displacement and velocity profiles of the cart mass.

In this exercise, you will do the following:


• Solve the baseline model in MotionSolve only (that is, without co-simulation) by using the inverted
pendulum model with a continuous controller modeled by a Force_Vector_OneBody element. You
can use these results to compare to an equivalent co-simulation in the next steps.
• Review a modified MotionSolve inverted pendulum model that mainly adds the
Control_PlantInput and Control_PlantOutput entities that allow this model to act as a plant for
Simulink co-simulation.
• Review the controller in Simulink.
• Perform a co-simulation and compare the results between the standalone MotionSolve model and
the co-simulation model.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.189

Before you begin, copy all the files in the <installation_directory>\tutorials\mv_hv_hg


\mbd_modeling\motionsolve\cosimulation folder to your working directory (referenced as <working
directory> in the tutorial). Here, <altair> is the full path to the HyperWorks installation.

Running the Baseline MotionSolve Model


In this step, use a single body vector force (Force_Vector_OneBody) to model the control force in
MotionSolve. The force on the cart is calculated as:

, where

is the disturbance force,

is the control force,

are gains applied to each of the error signals

is the error (difference between reference and actual values) on the input signals.

The angular displacement and velocity of the pendulum are obtained by using the AY() and WY()
expressions respectively. The translational displacement and velocity of the cart are obtained similarly,
by using the DX() and VX() expressions.

1. From the Start menu, select All Programs > HyperWorks <version> MotionView. Open the
model InvertedPendulum_NoCosimulation.mdl from your <working directory>.

Figure 155: The MotionSolve Model of the Inverted Pendulum

The MotionSolve model consists of the following components:

Component Name Component Type Description

Slider cart Rigid body Cart body

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.190

Component Name Component Type Description

Pendulum Rigid body Pendulum body

Slider Trans Joint Translational joint Translational joint between the cart body
and the ground

Pendulum Rev Joint Revolute joint Revolute joint between the pendulum body
and the cart body

Control Force Vector force The control force applied to the cart body

Output control force Output request Use this request to plot the control force

Output slider Output request Use this request to plot the cart's
displacement displacement

Output slider velocity Output request Use this request to plot the cart's velocity

Output pendulum Output request Use this request to plot the pendulum's
displacement displacement

Output pendulum Output request Use this request to plot the pendulum's
velocity velocity

Pendulum Rotation Solver variable This variable stores the rotational


Angle displacement of the pendulum via the
expression AY()

Pendulum Angular Solver variable This variable stores the rotational velocity
Velocity of the pendulum via the expressionVY()

Slider Displacement Solver variable This variable stores the translational


displacement of the cart via the expression
DX()

Slider Velocity Solver variable This variable stores the translational


velocity of the cart via the expression VX()

2. In the Run panel, specify the name InvertedPendulum_NoCosimulation.xml for the MotionSolve
model name and click Run.
The results achieved will be used as the baseline to compare the results obtained from co-
simulation.

Defining the Plant in the Control Scheme


A MotionSolve model needs a mechanism to specify the input and output connections to the Simulink
model. The MotionSolve model (XML) used above is modified to include the Control_PlantInput and

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.191

Control_PlantOutput model elements and provide these connections. In this tutorial, this has already
been done for you, and you can see this by opening the model InvertedPendulum_Cosimulation.mdl
from your <working directory>.
This model contains two additional modeling components:

Component Name Component Type Description

Plant Input Simulink Plant input This Control_PlantInput element is used


to define the inputs to the MotionSolve
model

Plant Output Simulink Plant output This Control_PlantOutput element is


used to define the outputs from the
MotionSolve model

The Control_PlantInput element defines the inputs to a mechanical system or plant. For this model, only
one input is defined in the "Plant Input Simulink" solver array. This is set to the ID of the solver variable
that holds the control force from Simulink.

Figure 156: The Definition of the Input Channel to MotionSolve

The Control_PlantOutput element defines the outputs from a mechanical system or plant. For this
model, four outputs are defined in the "Plant Output Simulink" solver array. These are the pendulum
rotation angle, the pendulum angular velocity, slider displacement and slider velocity.

Figure 157: The Definition of the Output Channels from MotionSolve

The inputs specified using the Control_PlantInput and Control_PlantOutput elements can be
accessed using the PINVAL() and POUVAL() functions, respectively. Since the Control_PlantInput and

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.192

Control_PlantOutput list the IDs of solver variables, these input and output variables may also be
accessed using the VARVAL() function. For more details, please refer to the MotionSolve User's Guide.

This model has the following connections:


• Plant Input: A single control force that will be applied to the cart.
• Plant Output: The pendulum's angular displacement and angular velocity; the cart's translational
displacement and velocity.

Setting up Environment Variables


A few environment variables are needed for successfully running a co-simulation using MATLAB. These
can be set using one of the following methods:
• Control panel (Windows)
• In the shell/command window that calls MATLAB (with the set command on Windows, or the
setenv command on Linux)
• Within MATLAB, via the setenv() command
An example of the usage of these commands is listed below:

Environment
Value Windows shell Linux shell MATLAB shell
variable

PATH \mypath set PATH=\mypath setenv PATH \mypath setenv('PATH','\mypath')

1. Set the following environment variables:

Environment Path - Windows Path - Linux


variable

NUSOL_DLL_DIR <altair>\hwsolvers\motionsolve <altair>\hwsolvers\motionsolve


\bin\win64 \bin\linux64

RADFLEX_PATH <altair>\hwsolvers\common\bin <altair>\hwsolvers\common\bin


\win64 \linux64

PATH <altair>\hwsolvers\common\bin <altair>\hwsolvers\common\bin


\win64;%PATH% \linux64:$PATH

LD_LIBRARY_PATH - <altair>\hwsolvers\motionsolve
\bin\linux64
<altair>\hwsolvers\common\bin
\linux64:$LD_LIBRARY_PATH

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.193

where <altair> is the full path to the HyperWorks installation. For example, on Windows, this
would typically be C:\Program Files\Altair\<version>.
2. Note that other optional environment variables may be set for your model. See MotionSolve
Environment Variables for more information on these environment variables.

Setup the Co-simulation


The core feature in Simulink that creates the co-simulation is an S-Function (System Function) block in
Simulink. This block requires an S-Function library (a dynamically loaded library) to define its behavior.
MotionSolve provides this library, but the S-Function needs to be able to find it. To help MATLAB/
Simulink find the S-Function, you need to add the location of the S-Function to the list of paths that
MATLAB/Simulink uses in order to search for libraries.

The S-Function library for co-simulation with MotionSolve is called mscosimipc – for Inter Process
Communication (IPC) using TCP/IP sockets for communication. This file is installed under <altair>
\hwsolvers\motionsolve\bin\<platform>.

The location of this file needs to be added to the search path of MATLAB for the S-Function to use
mscosimipc.

This can be done in one of the following ways:

1. Use the menu options.


a) From the MATLAB menu, select File > Set Path.

Figure 158: Add path through the MATLAB GUI

b) From the dialog, add the directory where the mscosimipc library resides.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.194

<altair>\hwsolvers\motionsolve\bin\win64
c) Select Save and Close.
This procedure permanently adds this directory to the MATLAB/Simulink search path.
2. Use MATLAB commands.
a) To add the directory where mscosimipc library resides into the MATLAB search path, at the
MATLAB command line, type

addpath('<altair>\hwsolvers\motionsolve\bin\<platform>')

It remains valid until you exit MATLAB.

Note: You can also create a .m script to make this process more easily
repeatable.
For example, you can set the MATLAB Path and the necessary environment
variables using MATLAB commands in a MATLAB (.m) script:

addpath('<altair>\hwsolvers\motionsolve\bin\win64')
setenv('NUSOL_DLL_DIR','<altair>\hwsolvers\motionsolve\bin\win64')
setenv('RADFLEX_PATH',['<altair>\hwsolvers\common\bin\win64')
setenv('PATH',['<altair >\hwsolvers\common\bin\win64;'
getenv('PATH')])

b) For a Linux machine, additionally enter

setenv('LD_LIBRARY_PATH', '<altair>\hwsolvers\motionsolve\bin
\linux64:<altair>\hwsolvers\common\bin\linux64\')

Viewing the Controller Modeled in Simulink


1. In the MATLAB window, select File > Open.
The Open file dialog is displayed.
2. Select the InvertedPendulum_ControlSystem.mdl file from your <working directory>.
3. Click Open.
You will see the control system that will be used in the co-simulation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.195

Figure 159: The Control System in MATLAB

4. The model contains an S-function block. Name the S-function 'mscosim'. Double click on the S-
Function named mscosim. In the dialog box that is displayed, change the name of the S-function
to ‘mscosimipc’.
The S-function (system-function) is one of the blocks provided by Simulink and represents the
MotionSolve model. It can be found in the Simulink User-Defined Functions block library. An S-
Function allows you to model any general system of equations with inputs, outputs, states, and so
on, and is somewhat analogous to a Control_StateEqn in MotionSolve. See the MATLAB/Simulink
documentation for more details.
5. Double-click the S-function with name mscosimipc. In the dialog that is displayed, under the S
Function Parameters, enter the following using single quotes:

' InvertedPendulum_Cosimulation.xml', 'InvertedPendulum_Cosimulation.mrf', ''

The three parameters are the following:


• MotionSolve XML model name
• Output MRF name
• MotionSolve user DLL name (optional); enter empty single quotes ('') if not used.

Repeating the Co-simulation

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.196

1. Click Simulation > Start to start the co-simulation.


Simulink uses ODE45 to solve the Simulink model. From this, the co-simulation should begin and
MotionSolve should create an output .mrf file for post-processing.
2. Set the Scopes in the Simulink model to display the results.
3. Check the .log file to make sure no errors or warnings were issued by MotionSolve.

Figure 160:

Comparing the MotionSolve-only Results to the Co-


simulation Results
1. From the Start menu, select All Programs > HyperWorks <version> > HyperGraph.
2. Click Build Plots .

3. Click the file browser and load the InvertedPendulum_NoCosimulation.mrf file. This was the
baseline result created by running MotionSolve by itself.
4. In the Page Controls toolbar, create two vertical plot windows.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.197

Figure 161: Create Two Plot Windows

5. Select Marker Displacement for Y-Type, REQ/70000004 Output slider displacement (on
Slider cart) for Y Request, and DX for Y Component to plot the cart's translational displacement:

Figure 162: Plot the Cart's Displacement

6. Select the window on the left and click Apply.


7. Select Marker Force for Y-Type, REQ/70000002 Output control force- (on Slider cart) for Y
Request, and FX for Y Component to plot the X component of the control force:

Figure 163: Plot the Control Force on the Cart

8. Click the file browser icon and load the InvertedPendulum_Cosimulation.mrf file. This was the
co-simulation results run with Simulink.
9. Select Marker Displacement for Y-Type, REQ/70000004 Output slider displacement (on
Slider cart) for Y Request, and DX for Y Component to overlay the plot in the left window.
10. Select Marker Force for Y-Type, REQ/70000002 Output control force- (on Slider cart) for Y
Request, and FX for Y Component to overlay the plot in the right window.
Both the signals match as shown below.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.198

Figure 164: Comparison of the Cart Displacement and Cart Control Force Between the Two Models

The blue curves represent results from the MotionSolve-only model and the red curves represent
results from the co-simulation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.199

MV-7003: Simulating a Single Input Single Output


(SISO) Control System Using MotionView and
MotionSolve
In this tutorial, you will learn how to implement a single input single output (SISO) controller in
MotionView and solve it using MotionSolve.

Consider the problem of maintaining the reference speed of a rotor in the presence of disturbances. A
block diagram of the control system is shown in the figure below.

Figure 165: Block Diagram of the Control System

One simple approach is to design a proportional integral (PI) controller (Ogata, 1995), such that:
(10)

This tutorial shows you how to implement this PI controller.

Loading the Rotor Model


1. From the Start menu, select All Programs > HyperWorks <version number> >
MotionView.
2. Load the rotor.mdl file, located in the motionsolve folder.
The model contains a body called rotor that is attached to ground by a revolute joint. The joint
axis is parallel to the global Z-axis. There is a torsional spring-damper with only damping and no
stiffness.
The model also contains output requests for the displacement and velocity of the rotor body.

Adding a Solver Variable for Reference Speed

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.200

1. From the Project Browser, right-click Model and select Add General MDL Entity > Solver
Variable (or right-click from the toolbar.
The Add SolverVariable dialog will be displayed.
2. Change Label to Reference Speed.
The variable name remains sv_0.
3. Click OK.
4. To maintain a linear speed of 3 rad/sec, from the Type drop-down menu, select Linear and enter
3 as the value of the solver variable.

Adding a SISO Controller


In this section, add a SISO controller. The input to the controller is the error between the reference
speed solver variable and the rotor angular speed. The output of the controller is the torque to be
applied to the rotor. The parameters for the simulation are chosen, somewhat arbitrarily, as Kp=1 and
K=10.
1. From the Project Browser, right-click Model and select Add General MDL Entity > Control
SISO (or right-click ).
The Add Control dialog will be displayed.
2. Click OK.
3. From the Input tab, select Expression from the Type drop-down menu and enter this expression:

'-WZ({MODEL.b_0.cm.idstring})+{sv_0.value}'

Note the single back quotes, indicating the expression is not to be processed by MDL, but by
Templex. The parameters inside the curly braces are evaluated.
4. Click the Properties tab.
5. To add Numerator coefficients, click Append.
6. Enter 10 and 1 for the coefficients of 1 and s, respectively.
7. Similarly, for Denominator coefficients, click Append and enter 0 and 1 for the coefficients of 1
and s, respectively.

Adding the Control Torque


In this section, create a control torque acting on the rotor body. The Z-component of this torque is the
output of the controller.

1. From the Project Browser, right-click Model and select Add Force Entity > Force (or right-click
Forces ).
The Add Force or ForcePair dialog is displayed.
2. Leave the label and variable name default settings and click OK.
3. From the Connectivity tab, under Force, select Action Reaction. For Properties, select
Rotational.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.201

4. Set Local ref. frame by double-clicking Ref Marker and selecting Global Frame.
5. Double-click Body 1 for Action force on: and select the rotor body.
6. Double-click Body 2 for Reaction force on: and select Ground Body.
7. Double-click Point 1 for Apply force at: and select Point 0.
8. Click the Rot Properties tab and leave Tx and Ty set to 0.
9. Under Tz, select Expression and enter '{MODEL.siso_0.OUTPUT}'.

Tip: You may also click to access the expression builder and create this expression
using the model tree.

Adding Output Requests for Control Force


1. From the Project Browser, right-click Model and select Add General MDL Entity > Output (or
right-click ).
The Add Output dialog will be displayed.
2. Enter Control force for the Label name and click OK.
3. Specify other choices as shown in the figure below:

Figure 166: Setting up the Uutput Request for Control Force

Running the Simulation


1. Click Run to display the Run panel.

2. Under Simulation type, select Transient and specify the output (.xml) filename.
3. Enter 25 for the End time.
4. Click Run.

The results are displayed in the image below.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.202

Figure 167: Simulation Results for the PI Speed Controller

Reference

K. Ogata, Modern Control Engineering, 1990, Prentice-Hall Inc., Englewood Cliffs, N.J., US

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.203

MV-7004: Inverted Pendulum Control Using


MotionSolve and MATLAB
In this tutorial, you will learn how to use MotionView and MotionSolve to design a control system that
stabilizes an inverted pendulum.

The goal of this tutorial is to design a regulator using the pole placement method. The inverted
pendulum MDL model file is supplied.

The tutorial steps include:


• Check the stability of the open loop system.
• Export linearized system matrices A,B,C, and D using MotionSolve linear analysis.
• Design a controller using MATLAB.
• Implement a controller in MotionView.
• Check the stability of a closed loop system using MotionSolve linear analysis.
• Add disturbance forces to the model and run simulation using MotionSolve.

The image below shows the classic inverted pendulum on a slider. The system has two degrees of
freedom leading to four state variables. The vertically upright position of the pendulum is unstable. The
goal is to design a regulator to stabilize this configuration.

Figure 168: Inverted Pendulum Model

You want to find a full-state feedback control law to achieve the goal. The control input is a force
applied to the slider along the global X-axis. Plant output is the pendulum angle of rotation about the
global Y-axis.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.204

Start by loading the file inv_pendu.mdl, located in the mbd_modeling\motionsolve folder, into
MotionView. Upon examination of the model topology, you will notice that everything needed for this
exercise is already included in the model. However, depending on which task you are performing, you
will need to activate or deactivate certain entities.

Determining the Stability of the Open Loop Model


Compute the eigenvalues to determine the stability of the Inverted pendulum.

1. From the Project Browser, click Forces and make sure that Control ForceOL is activated, while
Control Force - CL and Disturbance-step are deactivated.
2. From General Actions toolbar, click Run .

3. From the Simulation type drop-down menu, select Static + Linear.


4. Specify the output filename as inv_pendu_ol_eig.xml.
5. Select the MDL animation file (.maf) option.
6. Click Run.
7. Once the solution is complete, close the solver execution window and the message log.
The eigenvalues computed by MotionSolve are shown in the table below and can be viewed in the
inv_pendu_ol_eig.eig file using a text editor.

Table 2: Open Loop Eigenvalues

Number Real(HZ) IMAG_FREQ(HZ)

1 -1.625311E-02 0.00000000E+00

2 -4.003403E-01 0.00000000E+00

3 5.582627E-01 0.00000000E+00

4 -1.733216E+00 0.00000000E+00

There is one eigenvalue with a positive real part, indicating that the system is unstable in the
current configuration.
8. Click Animate.
The result animation H3D will be loaded in the adjacent window.
9. From the Results Browser select individual modes.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.205

Figure 169:

10. Click Start/Pause Animation to visualize the mode shape.

Obtaining a Linearized Model


Usually, the first step in a control system design is to obtain a linearized model of the system in the
state space form,
(11)

where , , , and are the state matrices, is the state vector, is the input vector, and is the
output vector. The A,B,C,and D matrices depend on the choice of states, inputs, and outputs. The states
are chosen automatically by MotionSolve and the chosen states are reported in one of the output files.
You only need to define the inputs and outputs.

1. Expand the Solver Variables folder in the Project Browser and examine the entities.
• Control Force Variable - CL is used to define the control input after the control law has been
found. Ignore this at this stage.
• Control Force Variable - OL is used to define the control plant input, which is a force named
Control Force - OL. This force is applied to the slider body. This variable is set to zero. It is
needed by MotionSolve to properly generate the linearized system matrices.
• Solver variable Pendulum Rotation Angle defines the control plant output and measures the
pendulum rotation about the Global Y-axis.
2. Expand the Solver Array folder in the Project Browser and examine the solver arrays that are
defined.
a) Select Plant-I. This array defines a solver array entity of type Plant-Input.
b) Ensure that Solver Variable is set to Control Force Variable - OL and click OK.
c) Select Plant-O. This array defines a solver array entity of type Plant-Output.
d) Ensure that Solver Variable is set to Pendulum Rotation Angle.

Note: Please note that the plant input and plant output IDs used in linearization
are specified automatically by MotionView while exporting the solver deck.

3. Click Run .
4. From the Simulation type drop-down menu, select Linear.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.206

5. Specify the output filename as inv_pendu_state_matrices.xml.

Figure 170: Linear Tab in Simulation Settings Dialog for Specifying the MATLAB Matrix Files Output

6. From the Simulation Settings dialog, Linear tab select the State-Space matrices (MATLAB)
option.
7. From the Main tab, click Run.
You should get six new files with base name inv_pendu_state_matrices and extensions .a,
.b, .c, .d, .pi, and .po. The .pi and .po files contain information about the input and output
variables.
The states chosen by the MotionSolve solver are:
• Angular displacement about the global-Y axis.
• Translation displacement along the global X-axis.
• Angular velocity about the global-Y axis.
• Translation velocity along the global X-axis of the pendulum body center of mass marker.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.207

Designing a Control System in MATLAB


A detailed discussion of control system design is beyond the scope of this document. However, the steps
to design a regulator using pole placement [1] to stabilize the inverted pendulum are described briefly.
For details, refer to the standard controls text and the MATLAB documentation.

It can be easily verified using MATLAB that the system is completely state controllable [1, 2]. We
employ a full-state feedback control law , where is the control input, is the gain vector,
and is the state vector. Then, assuming the desired pole locations are stored in vector , you may
use the pole placement method to compute . For desired poles at [-20 -20 -20 -20] (rad/s), the acker
function in MATLAB yields k=1e3[-2.4186 -0.0163 -0.070 -0.0033].

Implementing the Control Force in MotionView


The control force is simply . The model contains a solver variable called Control Force Variable
- CL. It is defined using the expression:

`-1e3*(-2.4186*AY({b_pendu.cm.idstring})-0.0163*DX({b_pendu.cm.idstring}),-0.070*WY({b_pendu.cm.idstring})-0.0033*VX({b_pendu.cm.idstri

Notice that it is simply the dot product between the gain vector (k) and the state vector (x) elements.
This solver variable is used to define a force named Control Force - CL.

Activate the force Control Force - CL if it is deactivated.

Checking the Stability of a Closed Loop System


1. From the SolverMode menu, select MotionSolve. Activate the force Control Force - CL if it is
deactivated.
2. From the Run panel, under Simulation type, select Linear.
3. Specify the output file as inv_pendu_cl_eig.xml and click Run.
The eigenvalues are given below.

Table 3: Closed Loop Eigenvalues

Number Real(cycles/second) Imag. (cycles/second)

1 -1.9595991E+00

2 -4.6976071E+00

3 -3.0372880E+00 +/- 1.3849641E+00

They all have negative real parts, hence the system is stabilized. Note that the negative real parts
are close to the desired poles (-20 rad/s = -3.038 Hz).

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.208

Adding Disturbance Force and Running the Simulation


1. Activate force acting on the slider titled Disturbance-step, defined using a step function:

Fx= `step(TIME,.1,0,.5,50) + step(TIME,1,0,1.5,-50)`


Fy=0
Fz=0

2. To run a dynamic simulation with MotionSolve, from the Project Browser, activate deactivated
outputs Output control force - final and Output Disturbance step.
3. From the toolbar, click Run .

4. From the Simulation type drop-down menu, select Transient.


5. Specify the output filename as inv_pendu_dyn.xml.
6. Specify the End time and Print interval as 3.0 and 0.01, respectively.
7. From the Main tab, click Run.
8. Once the job is completed, close the solver window and plot the following results in a new
HyperGraph page using inv_pendu_dyn.abf.

Output Y-Type Y-Request Y-Component

control force Marker Force REQ/70000014 Output control force - FX


final -(on Body Slider)

disturbance force Marker Force REQ/70000017 Output Disturbance FX


step -(on Body Slider)

slider Marker REQ/70000006 Output slider-disp - DX


displacement -X Displacement (on Body slider)

pendulum angular Expressions REQ/70000016 Output Pendu rotation F2


displacement

The plots of disturbance force, control force, slider x displacement, and pendulum angular
displacement are shown below.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.209

Figure 171: Plots of Disturbance and Control Forces as well as Slider Translational and Pendulum Angular
Displacements

References

Feedback Control of Dynamic Systems, G. G. Franklin, J. D. Powell, and A. Emami-Naeini, Third Edition,
Addison Wesley.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.210

MV-7005: Linking Matlab/Simulink Generated Code


(Simulink Coder) with MotionSolve
In this tutorial, you will learn how to generate a dynamic link library (DLL) using Simulink Coder
(formerly Real-Time Workshop) and link it with MotionSolve to run a co-simulation.

Before starting, you must have:


1. A working installation of MotionSolve (v12 and above)
2. A working installation of MATLAB, Simulink, MATLAB Coder, and Simulink Coder
3. A working installation of Microsoft Visual Studio (MSVS) 2010

Check for supported versions of MATLAB and MSVS at Supported Versions - Third Party Software in the
XML Format Reference Guide.

This example uses MATLAB R2011b with MSVS 2010.

Preparing the MotionSolve Model


The MotionSolve model is set up to communicate with an external solver by using the modeling
statements Control_PlantInput and Control_PlantOutput:

<Control_PlantInput
id = "30100100"
num_element = "2"
variable_id_list = "30100400, 30100500"
sampling_period = "0.01"
offset_time = "0.0"
label = "for controller 1"
usrsub_param_string = "USER(987654321)"
usrsub_dll_name = "rtw_BusSuspension2PMIMODiscrete"
usrsub_fnc_name = "PINSUB"
hold_order = "2"
/>
<Control_PlantOutput
id = "30100200"
num_element = "2"
variable_id_list = "30100200, 30100300"
sampling_period = "0.01"
offset_time = "0.0"
label = "for controller 1"
usrsub_param_string = "USER(987654321)"
usrsub_dll_name = "rtw_BusSuspension2PMIMODiscrete"
usrsub_fnc_name = "POUTSUB"
hold_order = "2"
/>
<Control_PlantInput
id = "30100300"
num_element = "2"
variable_id_list = "30100800, 30100900"
sampling_period = "0.01"
offset_time = "0.0"
label = "for controller 2"
usrsub_param_string = "USER(987654321)"
usrsub_dll_name = "rtw_BusSuspension2PMIMODiscrete"

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.211

usrsub_fnc_name = "PINSUB"
hold_order = "2"
/>
<Control_PlantOutput
id = "30100400"
num_element = "2"
variable_id_list = "30100600, 30100700"
sampling_period = "0.01"
offset_time = "0.0"
label = "for controller 2"
usrsub_param_string = "USER(987654321)"
usrsub_dll_name = "rtw_BusSuspension2PMIMODiscrete"
usrsub_fnc_name = "POUTSUB"
hold_order = "2"
/>

The key attributes of Control_PlantInput and Control_PlantOutput needed to link a Simulink Coder
DLL are listed below.
Attribute Description

usrsub_param_string Set this parameter equal to "USER(id)", where the ID is an


integer (for example, 123) that you choose. The ID identifies
the Simulink Coder library, links all Control_PlantInput's and
Control_PlantOutput's that use the library, and must be unique.

Note: There can be more than one


Control_PlantInput/Control_PlantOutput per library.

usrsub_dll_name The name of the DLL that is used (for example, from Simulink
Coder).

usrsub_fnc_name The name of the user function/subroutine that MotionSolve calls.


This has to necessarily be "PINSUB" for Control_PlantInput and
"POUTSUB" for Control_PlantOutput.

In this case, this MotionSolve model has been prepared for you. Copy the MotionSolve and Simulink
models, rtw_BusSuspension2PMIMODiscrete.xml and rtw_BusSuspension2PMIMODiscrete.mdl,
located in the motionsolve\cosimulation folder to your <working directory>.

Preparing the Simulink Model - Generating Code


Before starting with the simulation, the Simulink model needs to be created and prepared to work with
MotionSolve. After generating the contents of the Simulink model, MotionSolve requires the Simulink
components Inport and Outport, which represent the interface to the MotionSolve model. For example,
like the following (blocks labeled below as In1, In2, Out1, Out2):

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.212

Figure 172:

Note: If you have multiple inports/outports, you must retain the above illustrated naming
scheme. All your inports must be defined as In1, In2, ..., Inx. Similarly, all your outports
must be named as Out1, Out2, ..., Outx. This is a limitation within the current co-simulation
framework and will be addressed in a future release. See Appendix B for more information.

The order of these Inport's and Outport's must match the order of the Control_PlantOutput's and
Control_PlantInput's, respectively, in the MotionSolve model.

1. Open rtw_BusSuspension2PMIMODiscrete.mdl in Simulink.


2. Specify the configuration parameters in the solver, which is used by Simulink Coder. To do this,
use the Simulation > Configuration Parameters menu option as shown below.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.213

Figure 173:

3. In the left-side browser/tree, select Code Generation:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.214

Figure 174:

4. Change the System target file by clicking Browse and searching for "grt.tlc - Create Visual C/C
++ Solution File for the "grt" target". This is shown below:

Figure 175:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.215

5. Once this is done, change the Language option to "C++" in this same Code Generation window.
6. Next, in the left-side browser/tree, select the Solver option.
Simulink Coder does not allow using a variable-step integrator for the Generic Real-Time target
that is required by MotionSolve to generate this code (more details on selecting the Generic Real-
Time target later in this tutorial). So, under the Solver option on the left, choose the Fixed-step
solver, as shown below:

Figure 176:

Note: See the Mathworks documentation for more details on selecting an appropriate
fixed-step size for your model (in particular, if the model has multiple sample times,
you will likely need to choose a step size equal to the least common denominator of
the specified sample times so that each sample time is hit by the solver).

7. Next, in the left-side browser/tree, select the Code Generation option again.
8. Click Build to build the code.
The code generation creates two folders in the current directory of MATLAB (here
<Simulink_model> is the name of the model):
• <Simulink_model>_grt_rtw
• slprj

You should see messages that look similar to those below and end with: ###
Successful completion of Real-Time Workshop build procedure for model:
rtw_BusSuspension2PMIMODiscrete

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.216

… or something similar.

Figure 177:

Modifying, Compiling and Linking the Code to Create the


DLL
At this point, Simulink Coder has generated source code for the Simulink model, but this must be
modified and recompiled to generate the DLL required by MotionSolve. In the next steps, you will use a
script to automatically compile and link this code and generate the Simulink Coder DLL that will be used
in the MotionSolve model.

1. Open a command prompt in your working directory (where Simulink has generated the code).
2. Issue the following command:

"ms_rtw_pre <mdl_name> <altair_root> <msvs_root> <win32|win64>"

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.217

where,

<mdl_name> is the name of the Simulink model (without the extension .mdl)

<altair_root> is the complete path to the root folder of the HyperWorks installation
<msvs_root> is the complete path to the root folder of the MSVS installation

<win32|win64> specify win32 or win64 depending on the required platform of the DLL
3. To successfully issue the ms_rtw_pre command, please include the path of the MotionSolve
binaries in the "PATH" environment variable. This can be done locally by issuing the following
command on Windows:

set PATH = <MS_bin_path>;%PATH%

where <MS_bin_path> is the path to the MotionSolve binaries; for example, "C:\Program Files
\Altair\<version>\hwsolvers\motionsolve\bin\win64"
4. If the path to <altair_root> and/or <msvs_root> contains spaces, make sure to enclose the path
in quotes.

An example of the above command for this model is:

ms_rtw_pre
rtw_BusSuspension2PMIMODiscrete "C:\Program Files\Altair\<version>" "C:\Program Files
(x86)\Microsoft Visual Studio 10.0" "win64"

Issuing the above command does the following:


• Automatically modifies the project settings and source files of the original solution generated by
Simulink Coder
• Compiles and links the source code to generate a DLL that can be used with MotionSolve

You can confirm that this process has completed successfully by looking at the output in the command
window. On successful execution, you should see something like the following:

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


1 file(s) copied.
** RTW dll is ready **

Running a MotionSolve Model with the Generated DLL


At this point, you simply need to point MotionSolve to the Simulink library to complete the co-
simulation. By default, it assumes that it is in the same directory as the MotionSolve model.

1. In this example, the ms_pre_rtw script should have created the generated DLL into the same
folder where the MotionSolve model (.xml) resides. If the DLL is created elsewhere, copy it to the
working directory of the MotionSolve .xml file.
2. Open a command window and change the path into this folder in order to run the model.
3. You will be running the MotionSolve model on command line, so certain environment variables
must be set to be able to invoke MotionSolve. See the MotionSolve User's Guide for more details
on the options to run on the command line.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.218

4. Run the MotionSolve model in the command line by issuing the command "mbd_d x.xml x.mrf".
The simulation should run quickly and you should review your results to confirm that the process
worked as expected.

Appendix A

This section discusses the access functions CoSimAPI_SimulinkRTW_Update_U(api,model,input) and


CoSimAPI_SimulinkRTW_Update_Y(api,model,output). These are added to the Simulink model source
code in order to help perform the co-simulation via the DLL.

CoSimAPI_SimulinkRTW_Update_U(void *api, const RT_MODEL_x x_M, ExternalInputs_x &x_U)

This method updates the input data structure in the Simulink Coder generated code with the output
from MotionSolve.

The first argument requests a pointer to the API ID. The API ID is passed from the model XML in the
line usrsub_param_string = "USER(987654320)". The first parameter in the USER() string is always
the ID of the API. The MotionSolve API provides the method void * CoSimAPI_Get_API_Ptr(int
api_id) to get the API pointer, where the api_id is the number specified in the XML file in the USER()
string.

The second argument requests data structure x_M related to the generated Simulink Coder model
information where 'x' is the name of the model. The x_M data structure is inherent to the Simulink
code.

The last argument requests input x_U where x_U is the data structure used by the Simulink Coder code
to store the external inputs (see Appendix B).

CoSimAPI_SimulinkRTW_Update_Y(void *api, const RT_MODEL_x x_M, const


ExternalOutputs_x x_y)

This method updates the input for the MotionSolve solver with output from the RTW generated code.

The first and second arguments are the same as described in the previous section.

The last argument requests RTW output x_Y which is deposited to MotionSolve for that current time
step, where x_Y is the data structure used by the Simulink Coder code to store the external outputs
(see Appendix B).

Appendix B

This section describes the data structure that Simulink Coder generated code uses for representing the
external input/output ports. In the following lines, the name of the model is assumed to be rtw_MS (rtw
= Real Time Workshop, former name of Simulink Coder).

Typically, the Simulink Coder generated code (SCGC) uses the following notations:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.219

Input port to Simulink with single channel rtw_MS_U.In1, rtw_MS_U.In2 etc.

Output port from Simulink with single channel rtw_MS_Y.Out1, rtw_MS_Y.Out2 etc.

Input port with multiple channels rtw_MS_U.In1[0], rtw_MS_U.In1[1] etc.

Output port with multiple channels rtw_MS_Y.Out1[0], rtw_MS_Y.Out1[1] etc.

So for example, for a model with two Control_PlantInput (CPI) elements where the first has three
channels and the second has two channels, the corresponding data structure in Simulink Coder code
would be:

CPI #1: rtw_MS_U.In1[0], rtw_MS_U.In1[1] and rtw_MS_U.In1[2]


CPI #2: rtw_MS_U.In2[0] and rtw_MS_U.In2[1]

The same scheme is applicable for the data structure that handles Control_PlantOutput ports.

Note: If the Simulink model has labels defined for the input/output links, then these labels
will replace "In" and "Out" in the data structure described above. "In" and "Out" are the
default names used by Simulink in case the links are not named. In this scenario, you
need to change the first input variable name specified in the rtw api function template
CoSimAPI_SimulinkRTW_Update_U(api,model,input) into the one you specified.

For example, if you name the first input to be myIn instead of In1, you need to make the following
change to that function template:

double *u_ptr = (double *)&u.


myIn
;

to replace the original code:

double *u_ptr = (double *)&u.


In1
;

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.220

MV-7008: Co-simulation with AcuSolve


In this tutorial, you will learn how to setup a model in MotionView that will be coupled with AcuSolve.
With the addition of a co-simulation interface between MotionSolve and AcuSolve, you can now solve
multi-physics problems that involve complex rigid body movement, coupled with fluid flow, that
generates pressure forces on the rigid bodies. This capability lets you enhance the fidelity of your multi-
body system, letting you generate more realistic results.

In this scenario, MotionSolve computes the displacements and rotations for the rigid bodies, while
AcuSolve computes the forces and moments on those bodies. Both solvers exchange data with each
other while stepping forward in time via the TCP socket protocol. This means that the two solvers can
be located on different machines and on different platforms and still communicate with one another. For
example, the CFD simulation can run on an HPC, while the MBS simulation can run locally on a laptop.

Tutorial Objectives
You will use the MotionSolve-AcuSolve co-simulation interface to couple the rigid body dynamics of
a check valve within a pipe with the flow field. The AcuSolve model has already been setup for you
and is located at <installation_directory>\tutorials\mv_hv_hg\mbd_modeling\motionsolve
\cosimulation\Check_Valve_Coupled.acs. Steps for running this model in AcuSolve are included as
part of this tutorial.

To learn more about how to setup the model in AcuSolve, please refer to <installation_directory>
\acusolve\<platform>\help\acu\acusolve_tut\Tutorials\Check_Valve_Coupled\.

Software Requirements
To successfully complete this tutorial, the following must be installed:

Machine A Machine B

Software Platform Software Platform

MotionSolve/MotionView Windows 64-bit AcuSolve Windows 64-bit

MotionSolve/MotionView Windows 64-bit AcuSolve Linux 64-bit

MotionSolve/MotionView Windows 64-bit


and AcuSolve

From the table above, the co-simulation is currently only supported for the Windows 64-bit platform
for MotionView and MotionSolve. You may use either a Windows 64-bit or a Linux 64-bit installation of
AcuSolve.

Simulation Environment
The co-simulation interface between MotionSolve and AcuSolve consists of a “middleware” utility
executable, acuMSI.exe. This executable is responsible for:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.221

• Establishing a connection to both MotionSolve and AcuSolve.


• Communicating the displacements and rotations from MotionSolve to AcuSolve.
• Communicating the forces and moments from AcuSolve to MotionSolve.
• Managing runtime and licensing.

This is shown schematically below.

Figure 178: Co-Simulation setup

Pipe with a check valve


A check valve is a mechanical device that permits fluid to flow in only one direction. This is controlled by
a shutter body. Fluid flowing in one direction pushes the shutter body in one direction, thereby opening
the valve. Fluid flowing in the opposite direction pushes the shutter body in the other direction, which
causes the valve to shut and prevents flow reversal in the pipe. Check valves are found in pumps,
chemical and power plants, dump lines, irrigation sprinklers, hydraulic jacks, for example.

The geometry that is modeled in this tutorial is illustrated in the figure below. It consists of:
• A pipe with an inlet and outlet for the fluid flow.
• A check valve assembly that consists of a shutter plate attached to a stem.
• A stop mounted on a perforated plate downstream of the shutter body.
• The fluid flow in the pipe is assumed to be axisymmetric. This allows you to model only a part of
the check valve. In this example, a 30 degree section of the geometry is modeled, as shown by the
blue part in the figure below. The advantage of doing this is a reduced simulation time while still
capturing an accurate solution.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.222

Figure 179: Pipe with check valve model setup

The check valve assembly consists of a disc-like body mounted on a stem. When fluid flows in the
direction specified by the red arrows in the figure above, the fluid forces the shutter body to translate
in the same direction as the fluid. The motion of the shutter body is also affected by a spring damper
attached between the shutter body and the perforated plate. Finally, 3D rigid body contact is modeled
between the shutter body and the stop to arrest the motion of the shutter body in the direction of the
flow.

For the MBS model, only 1/12 of the shutter body and the perforated plate are modeled.

At the start of the simulation, the flow field is stationary. A pressure specified at the inlet drives the
flow, which varies over time as a piecewise linear function. This is illustrated in the figure below. As this
pressure rises, the flow accelerates which in turn pushes the shutter body open and allows flow through
the pipe.

Figure 180: Inlet pressure

This dynamics of this kind of model can be termed as being “tightly” coupled between the two solvers.
This means that the motion of the rigid bodies affects the fluid flow field, which in turn affects the rigid
body motion in a cyclical fashion.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.223

The rest of this tutorial assumes that this model has been correctly setup in AcuSolve. Note that
the model is designed to translate the shutter body until it collides with the perforated plate. The
MotionView model has been designed with a contact between these two bodies that causes the shutter
body to rebound appropriately. To allow the rigid bodies to come into contact without the AcuSolve finite
element mesh fully collapsing, the perforated plate in the fluid model has been offset by 0.002m in the
positive X direction. This allows the MotionView model to react as specified by the contact entity while
keeping the AcuSolve mesh from fully collapsing.

Load the Model in MotionView


1. From the Start menu, select All Programs > HyperWorks <version> (64-bit) > MotionView.
2. Open the model Valve_model.mdl from <altair>\<version>\tutorials\mv_hv_hg
\mbd_modeling\motionsolve\cosimulation.
This model is prepared to run in MotionSolve but requires modifications to run in co-simulation
with AcuSolve. These steps are outlined below.
Once the model is loaded into MotionView, the graphical window displays the shutter valve,
perforated plate, joint and spring entities, as well as a graphical representation of the spring
damper as shown in the figure below.

Figure 181: The MotionSolve model of the pressure check valve

The MotionSolve model consists of the following components:

Component Name Component Type Description

Ground Body Rigid Body Ground Body

Shutter Body Rigid Body 30 degree section of the


shutter body.

Perforated Body Rigid Body 30 degree section of the


perforated plate.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.224

Component Name Component Type Description

Contact 3D Rigid-Rigid Contact Force 3D rigid-rigid contact force


between the Shutter body and
the Perforated Body.

Solver Units Data Set The units for this model


(Newton, Meter, Kilogram and
Second).

Gravity Data Set Gravity specified for this


model. The gravity is turned
on and acts in the negative Y
direction.

Shutter Body Graphic Graphic The graphic that represents the


shutter body. This graphic is
used both for the co-simulation
and for the contact force
calculations.

Perforated Plate Graphic Graphic The graphic that represents


the perforated plate body. This
graphic is used both for the co-
simulation and for the contact
force calculations.

Spring Graphic The graphic that represents


the spring modeled between
the shutter body and the
perforated plate body. This is
only for visualization and does
not affect the co-simulation
results.

Fixed Fixed Joint This fixed joint clamps the


perforated plate body to the
ground.

Translation Translational Joint This translational joint allows


motion of the shutter body
along the X axis.

Spring Spring Damper This is a simple spring damper


mounted between the shutter
body and the perforated plate
body.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.225

Component Name Component Type Description

ContactOutput Output An output signal that measures


the contact force.

Displacement Output An output signal that measures


the displacement between the
shutter body and the ground.

Velocity Output An output signal that measures


the velocity of the shutter body
with respect to the ground.

Specify the “Wet” Body That Will Interact with AcuSolve


To couple with AcuSolve, you need to specify one or more "wet" bodies. A "wet" body is a body in the
MotionSolve model which interacts with the fluid flow and thus has forces and moments acting on it.
Such a body can translate or rotate due to the actuating fluid force/moment as computed by AcuSolve
as well as due to any actuating forces/moments in the MotionSolve model. In this example, we will
define a single "wet" body – the shutter body that translates along the X axis due to fluid impinging on
it.

To specify a body as "wet" in MotionView, you have to make use of a system definition, which is
described below.

1. Add the system definition to your model by locating the Model system in your Project Browser and
select it.
This changes the panel selection at the bottom.
2. From the Import/Export tab, select Import and click the File open icon, .

3. The system definition that is used for this co-simulation is located at <installation_directory>
\utility\mbd\fluid_force\sys_fluid_force.mdl. Click Import to import the file.
The Import Definition dialog is displayed.
4. Leave the labels as-is and click OK.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.226

Figure 182: Adding the system definition to the model

A new system called System Wet Body is created in your model.


5. Specify the "wet" body by clicking the newly created System Wet Body and clicking the
Attachments tab as shown in the figure below.

Figure 183: Defining the rigid body associated with the “wet” body

6. Click the Body collector and resolve it to Shutter Body.


If you examine the contents of this system under the project browser on the left, you will see the
following new components have been created:

Component Name Component Type Description

Shutter Body - AcuSolveForce Action Only, TransRotational The force and moment
Force calculated by AcuSolve is
applied to the “wet” body
through this force component.

Plant Input Control Plant Input AcuSolve deposits the forces


and torques into this modeling
element.

FromAS_FX Solver Variables These variables hold the forces


FromAS_FY (X, Y and Z) and the moments
(X, Y, Z) values from AcuSolve.
FromAS_FZ

FromAS_TX

FromAS_TY

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.227

Component Name Component Type Description


FromAS_TZ

Define wet_body attribute Template This template adds the


attribute is_wet_body to the
wet body that is chosen for this
system.

Define co-simulation with Data Set This template adds the


AcuSolve attribute acusolve_cosim to the
model to instruct MotionSolve
to co-simulate with AcuSolve.

At this point, you have setup the model in MotionView to interact with AcuSolve.

Run the Model without Co-simulating with AcuSolve


To make sure that the MotionView model is setup correctly, run the model in MotionSolve and make
sure there are no warning/error messages from MotionSolve.

1. To deactivate the template Define co-simulation with AcuSolve shown in the figure below,
right-click on it in the browser and select Deactivate.

Figure 184: Deactivate the co-simulation template

By doing this, you are deactivating the flag which tells MotionSolve that this model is intended
for co-simulation with AcuSolve. Thus, MotionSolve simulates this model as a stand-alone model
without co-simulating with AcuSolve

You may run this model using the Run panel in MotionView and ensure that there are no error or
warning messages reported. This is recommended to ensure that the model works properly before
attempting a co-simulation.

If you load the animation H3D generated from running this model, you will see that there is
no motion in any of the parts. This is because all of the actuation for this model comes from
AcuSolve, which was disabled for this simulation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.228

2. After you have verified the model, re-activate the template Define co-simulation with
AcuSolve to perform a co-simulation, as shown in the figure below:

Figure 185: Activate the co-simulation template

3. To activate the template, right-click on it in the browser and select Activate.


4. To export the model to your working directory, click the Export to Solver button and export the
solver deck to your working directory.
You may change the default name of the model.

Figure 186: Exporting the model to .xml

Verify the Model between MotionSolve and AcuSolve


To successfully run the co-simulation, the model created in MotionView and the model created in
AcuSolve must be consistent. The following criteria need to be met in order for the two models to be
consistent.

1. The name of the “wet” body/bodies need to match between MotionSolve and AcuSolve. The
names of the “wet” body/bodies are specified in the *.inp file on the AcuSolve side.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.229

Note: The names are case-sensitive and must match exactly (see the text in red
below).
MotionSolve (.xml):

<!-- MODEL.b_Part1 -->


<Body_Rigid
full_label = "Model-Shutter Body"

AcuSolve (.inp):

EXTERNAL_CODE_SURFACE( "Valve wall" ) {


rigid_body_name = "Model-Shutter Body"

2. The print_interval for the MotionSolve model needs to match the step size for the AcuSolve model.
For this tutorial, it is set to 0.002s.
3. You must set the MotionSolve step size, h_max, to match the print_interval (0.002s in this case).
4. Also, verify that the end times for both models are set to the same values. For this tutorial, the
end times for both the AcuSolve and MotionSolve models are set to 0.35s.
See the Run Panel in MotionView to set the print_interval, step size (h_max), and end times.
Note that the units in the MotionSolve and AcuSolve models do not need to match to run the co-
simulation; however, the units must match to overlay the results animations in HyperView. The
units in MotionView are set via the Units form shown below:

Figure 187: Setting the units in MotionView

All values in the MotionSolve model are set with respect to these units settings.

Run the MotionSolve and Middleware Executables for Co-


simulation from the MotionSolve Run Manager
1. From the Start menu, select All Programs >HyperWorks<version> 64-bit > MotionSolve to
open the HyperWorks Solver Run Manager.
Locate the model you just exported by clicking on the file open icon.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.230

Figure 188: Select the exported model from disk

2. Click the ellipsis button next to the Options field to open the Available Options dialog.

Figure 189: Selecting the co-simulation flag

3. Activate the –as_cosim option. When this flag is enabled, it tells the Run Manager to do the
following:
a) Invoke the MotionSolve executable and run the model that is specified.
b) Invoke the middleware “acuMSI”, which enables communication between MotionSolve and
AcuSolve.
When you activate this option, the following dialog is displayed and you are prompted for
additional options:

Figure 190: Specifying options for the co-simulation

You may specify the following options here:


acuMSI Options

-aport <integer> Specifies the communication port number for communication


between AcuSolve and acuMSI. The default is 48000.

Note If you need to change the default port for communication


between AcuSolve and acuMSI, in addition to changing this

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.231

acuMSI Options
argument, you also have to specify the changed port number
in the AcuSolve input file.

-mport <integer> Specifies the communication port number for communication


between MotionSolve and acuMSI. The default is 94043.

Note: If you need to change the default port for


communication between MotionSolve and acuMSI,
in addition to changing this argument, you also
have to specify the changed port number in an
environment variable MS_AS_PORT. MotionSolve
checks for this environment variable at the start
of the simulation and changes its listening port
accordingly.

-mi <integer> Specifies the maximum number of iterations per time step
between the two solvers. The default is 0.

-v <integer> Specifies the verbosity level of the output file from acuMSI.
The default is set to 0 (verbosity OFF).

4. If you retain the default options, click None.


5. Click Apply Options and click Close.

Figure 191: Specifying the co-simulation flag

6. You are now setup to start the co-simulation on the MotionSolve side. Click Run.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.232

Figure 192: Run the MotionSolve model

This launches MotionSolve as well as the acuMSI executable. The MotionSolve run is paused at the
first time step – it is now in waiting mode and the co-simulation will start as soon as AcuSolve is
run.

Figure 193: The MotionSolve simulation is waiting for a connection to AcuSolve

Run the AcuSolve Executable for Co-simulation


1. To run the co-simulation model in AcuSolve, first copy the model file Check_Valve_Coupled.acs
from <installation_directory>\tutorials\mv_hv_hg\mbd_modeling\motionsolve
\cosimulation to your working directory.
2. From the Start menu, select All Programs >HyperWorks <version> (64-bit) > AcuSolve
> AcuSolve Job Launcher. In the window that is displayed, change the field Problem name
as specified by the AcuSolve .inp file. Make sure your Problem directory is set to your current
working directory.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.233

Figure 194: Launching AcuSolve for the co-simulation

For this model, the default values are used. AcuSolve runs using a single processor, and
AcuConsole generates the input files and launches AcuSolve.
3. Press Launch to launch the solution process.
As the solution starts, an AcuTail window opens. After executing AcuPrep, AcuSolve stops at the
acuRun path step. It’s waiting for the execution of the process.MotionSolve
Soon, AcuSolve and MotionSolve should begin to communicate with one another. You should
be able to see relevant time stepping information in both solver windows. For example, you
should see something like the following in the MotionSolve window at the beginning of the co-
simulation:INFO: [AS-COSIM] Connected to AcuMsi on port 94043 INFO: [AS-COSIM] License
checked out. … Time=2.000E-06; Order=1; H=2.000E-06 [Max Phi=1.314E-16] Time=3.600E-02;
Order=2; H=2.000E-03 [Max Phi=1.653E-08] …

The co-simulation should take roughly 15 minutes to complete on a laptop (Intel i7. 2.8GHz).

Note that there is no order dependency on launching the co-simulation – either MotionSolve or v
can be launched first.

Post-process the Results from the Co-simulation


HyperView and HyperGraph can be used to post process the co-simulation results within the
HyperWorks Desktop environment.
To launch HyperView (HyperGraph), from the Start menu, select All Programs >HyperWorks
<version number> HyperView (HyperGraph).

The animation H3D generated by the MotionSolve part of the co-simulation contains only the results
from MotionSolve. Similarly, the result files from AcuSolve only contain the results for the AcuSolve
model. To animate the results from the co-simulation, follow these steps:
1. Load the animation H3D generated by MotionSolve in HyperView.
a) Go to the Load Model panel.
b) Click the file open button, , next to Load model and navigate to the results directory (the
same directory where the .xml file is located).

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.234

c) Select the .h3d file and click Open.


d) Click Apply.

Figure 195: Loading MotionSolve H3D in HyperView

2. HyperView loads the MotionSolve results file into the graphical window at the first time step. From
this point, you can animate the transient results using Start/Stop on the Animation Slider.
3. To load the AcuSolve results, they must first be converted to the .h3d format. This can be
accomplished by using the AcuSolve utility, AcuTrans. AcuTrans is available from the Start menu.
Select All Programs >HyperWorks <version> (64-bit) > AcuSolve > AcuSolve Cmd Prompt.
4. Navigate to the results directory and execute the following command to convert the AcuSolve
database into the .h3d format:

acuTrans -out -to h3d -h3dopt single -ts A

This creates a single .h3d file containing all of the time steps available for the simulation.
5. Using AcuTrans, overlay the newly-created H3D over the MotionSolve result H3D in HyperView.
This is accomplished by repeating Step 1 described above and activating Overlay when selecting
the AcuSolve result H3D.

Figure 196: Overlaying AcuSolve H3D over the MotionSolve H3D in HyperView

Once loaded, the graphical window contains both results and can be animated as before. To
visualize the information contained within the AcuSolve results, a Contour plot may be used. Click
on the Contour button to display the panel.
6. Set the options as shown in the figure below and click Apply.

Figure 197: Overlaying AcuSolve H3D over the MotionSolve H3D in HyperView

This creates a contour plot of the velocity magnitude overlaid with the results from MotionSolve in
one window.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.235

Figure 198: Velocity magnitude plot overlaid with the MotionSolve results in HyperView

Plotting the MotionSolve Results in HyperGraph


You can also interpret the results with a two dimensional plot using HyperGraph. HyperWorks Desktop
can be used in a multi-window layout, allowing both HyperView and HyperGraph to be open at the same
time.
7. First, open HyperView following the steps described in the previous section.
8. From the toolbar, click the Page Window Layout button and split the page into two vertical
pages.

Figure 199: Splitting the page into two vertical pages

This automatically adjusts the graphical window to accommodate two pages, defaulting to two
instances of HyperView.
9. Click anywhere in the page on the right and switch to HyperGraph by clicking the Page Selector
button and selecting HyperGraph 2D from the drop-down list.
10. Click the Build Plots button to load the .plt file from the same results directory.
Once the .plt file is loaded into HyperGraph, the two outputs are available for plotting.
11. Perform the following selections:
a) Under Y Type, select Displacement.
b) Under Y Request, select Displacement (on Shutter Body).
c) Under Y Component, select X.
d) Click Apply.
HyperGraph can be used to create additional traces on the same plot to generate the following
plots.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.236

Figure 200: Select the signals for plotting

Figure 201:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.237

MV-7009: Remote Co-simulation with Simulink


In this tutorial, you will learn how to use the MotionSolve-Simulink remote co-simulation interface,
driving the model from Simulink via an S-Function.

MotionSolve allows you to co-simulate with Simulink when the two software are remotely located,
through an implementation of the Inter Process Communication (IPC) approach via sockets.

Software and Hardware Requirements


Software requirements:
• MotionSolve
• MATLAB/Simulink (MATLAB Version R2015a, Simulink Version 8.5) (or newer)

Note: Older versions of MATLAB/Simulink may work, but the above minimum versions are
recommended and tested.

Hardware requirements:
• PC with 64bit CPU, running Windows 7/10 and/or
• Linux RHEL 6.6 or CentOS 7.2 64

Simulation Environment
In this tutorial, it is assumed that MATLAB is installed on Machine "A" and MotionSolve is installed on
Machine "B". The following scenarios are feasible:

Machine "A" Machine "B" IPC Co-simulation possible?

MATLAB/Simulink, Windows MotionSolve, Windows Yes


64-bit 64-bit

MATLAB/Simulink, Windows MotionSolve, Linux 64-bit Yes


64-bit

MATLAB/Simulink, Linux 64- MotionSolve, Windows Yes


bit 64-bit

MATLAB/Simulink, Linux 64- MotionSolve, Linux 64-bit Yes


bit

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.238

Note: When you start the co-simulation from Simulink, a few MotionSolve binaries are
loaded by Simulink at runtime. For this purpose, a reduced installation of MotionSolve
is needed on the machine where Simulink resides. Also, this installation of MotionSolve
must be of the same platform type as Simulink. For example, to do an IPC co-simulation
between Simulink on Linux and MotionSolve on Windows, you would need to have certain
MotionSolve Linux binaries on the same machine where the Simulink software is installed.
These libraries are listed in the appendix. The table above is updated below to reflect this.

Machine "A" Machine "B" IPC Co-simulation possible?

MATLAB/Simulink, Windows MotionSolve, Windows Yes


64-bit (Requires a Windows 64-bit
64-bit MotionSolve
installation)

MATLAB/Simulink, Windows MotionSolve, Linux 64-bit Yes


64-bit (Requires a Windows
64-bit MotionSolve
installation)

MATLAB/Simulink, Linux 64- MotionSolve, Windows Yes


bit (Requires a Linux 64-bit 64-bit
MotionSolve installation)

MATLAB/Simulink, Linux 64- MotionSolve, Linux 64-bit Yes


bit (Requires a Linux 64-bit
MotionSolve installation)

This tutorial describes the process to perform a co-simulation between a 64-bit installation of Simulink
on Machine "A" and a 64-bit installation of MotionSolve on Machine "B" (the scenario that is in blue text
in the table above). This is illustrated better in the figure below.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.239

Figure 202: Co-Simulation Environment Used for this Tutorial

Inverted Pendulum Controller


Consider an inverted pendulum, mounted on a cart. The pendulum is constrained at its base to the cart
by a revolute joint. The cart is free to translate along the X direction only. The pendulum is given an
initial rotational velocity causing it to rotate about the base.

Both the pendulum and the cart are modeled as rigid bodies. The controller, modeled in Simulink,
provides a control force to the cart to stabilize the inverted pendulum and prevent it from falling. This
control force is applied to the cart via a translational force. The model setup is illustrated in the figure
below.

Figure 203: Inverted Pendulum Model Setup

The pre-designed controller generates a control force that keeps the pendulum upright. The controller
uses the pendulum's orientation and angular velocity along with the cart's displacement and velocity as
inputs to calculate the direction and magnitude of the force needed to keep the pendulum upright. A
block diagram of the control system is shown in the figure below.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.240

Figure 204: Block Diagram Representation of the Controller

In the image above:


• is the angular displacement of the pendulum from its model configuration
• ω is the angular velocity of the pendulum about its center of gravity as measured in the ground
frame of reference
• x is the translational displacement of the cart measured from its model configuration in the ground
frame of reference
• is the translational velocity of the cart measured in the ground frame of reference
• is a reference signal for the pendulum's angular displacement
• is a reference signal for the pendulum's angular velocity
• is a reference signal for the cart's translational displacement
• is a reference signal for the cart's translational velocity

A disturbance is added to the computed control force to assess the system response. The controller
force acts on the cart body to control the displacement and velocity profiles of the cart mass.

In this exercise, you will do the following:


• Solve the baseline model in MotionSolve only (that is, without co-simulation) by using the inverted
pendulum model with a continuous controller modeled by a Force_Vector_OneBody element. You
can use these results to compare to an equivalent co-simulation in the next steps.
• Review a modified MotionSolve inverted pendulum model that mainly adds the
Control_PlantInput and Control_PlantOutput entities that allow this model to act as a plant for
Simulink co-simulation.
• Review the controller in Simulink.
• Perform a co-simulation and compare the results between the standalone MotionSolve model and
the co-simulation model.

Before you begin, copy all the files in the <altair>\tutorials\mv_hv_hg\mbd_modeling\motionsolve


\cosimulation folder to your working directory (referenced as <working directory> in the tutorial).
Here, <altair> is the full path to the HyperWorks installation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.241

Running the Baseline MotionSolve Model


In this step, use a single body vector force (Force_Vector_OneBody) to model the control force in
MotionSolve. The force on the cart is calculated as:

, where

is the disturbance force,

is the control force,

are gains applied to each of the error signals

is the error (difference between reference and actual values) on the input signals.

The angular displacement and velocity of the pendulum are obtained by using the AY() and WY()
expressions respectively. The translational displacement and velocity of the cart are obtained similarly,
by using the DX() and VX() expressions.

1. From the Start menu, select All Programs > HyperWorks <version number> >
MotionView.
2. Open the model InvertedPendulum_NoCosimulation.mdl from your <Working Directory>.

Figure 205: The MotionSolve Model of the Inverted Pendulum

The MotionSolve model consists of the following components:

Component Name Component Type Description

Slider cart Rigid body Cart body

Pendulum Rigid body Pendulum body

Slider Trans Joint Translational joint Translational joint between the cart body
and the ground

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.242

Component Name Component Type Description

Pendulum Rev Joint Revolute joint Revolute joint between the pendulum body
and the cart body

Control Force Vector force The control force applied to the cart body

Output control force Output request Use this request to plot the control force

Output slider Output request Use this request to plot the cart's
displacement displacement

Output slider velocity Output request Use this request to plot the cart's velocity

Output pendulum Output request Use this request to plot the pendulum's
displacement displacement

Output pendulum Output request Use this request to plot the pendulum's
velocity velocity

Pendulum Rotation Solver variable This variable stores the rotational


Angle displacement of the pendulum via the
expression AY()

Pendulum Angular Solver variable This variable stores the rotational velocity
Velocity of the pendulum via the expression VY()

Slider Displacement Solver variable This variable stores the translational


displacement of the cart via the expression
DX()

Slider Velocity Solver variable This variable stores the translational


velocity of the cart via the expression VX()

3. In the Run panel, specify the name InvertedPendulum_NoCosimulation.xml for the MotionSolve
model name and click Run.
The results achieved will be used as the baseline to compare the results obtained from co-
simulation.

Defining the Plant in the Control Scheme


A MotionSolve model needs a mechanism to specify the input and output connections to the Simulink
model. The MotionSolve model (XML) used above is modified to include the Control_PlantInput and
Control_PlantOutput model elements and provide these connections. In this tutorial, this has already
been done for you, and you can see this by opening the model InvertedPendulum_Cosimulation.mdl
from your <Working_Directory>.

This model contains two additional modeling components:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.243

Component Name Component Type Description

Plant Input Simulink Plant input This Control_PlantInput element


is used to define the inputs to the
MotionSolve model

Plant Output Simulink Plant output This Control_PlantOutput element


is used to define the outputs from the
MotionSolve model

• The Control_PlantInput element defines the inputs to a mechanical system or plant. For this
model, only one input is defined in the "Plant Input Simulink" solver array. This is set to the ID of
the solver variable that holds the control force from Simulink.

Figure 206: The Definition of the Input Channel to MotionSolve

• The Control_PlantOutput element defines the outputs from a mechanical system or plant. For
this model, four outputs are defined in the "Plant Output Simulink" solver array. These are the
pendulum rotation angle, the pendulum angular velocity, slider displacement and slider velocity.

Figure 207: The Definition of the Output Channels from MotionSolve

The inputs specified using the Control_PlantInput and Control_PlantOutput elements can be
accessed using the PINVAL() and POUVAL() functions, respectively. Since the Control_PlantInput
and Control_PlantOutput list the ids of solver variables, these inputs and output variables may
also be accessed using the VARVAL() function. For more details, please refer to the MotionSolve
User's Guide on-line help.

This model has the following connections:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.244

◦ Plant Input: A single control force that will be applied to the cart.
◦ Plant Output: The pendulum's angular displacement and angular velocity; the cart's
translational displacement and velocity.

Setting up Environment Variables


A few environment variables are needed for successfully running a co-simulation using MATLAB. These
can be set using one of the following methods:
• Control Panel (Windows)
• In the shell/command window that calls MATLAB (with the set command on Windows, or the
setenv command on Linux)
• Within MATLAB, via the setenv() command

An example of the usage of these commands is listed below:

Environment
Value Windows shell Linux shell MATLAB shell
variable

PATH \mypath set PATH=\mypath setenv PATH \mypath setenv('PATH','\mypath')

1. Set the following environment variables:

Environment Variable Windows Path Linux Path

NUSOL_DLL_DIR <altair> <altair>\hwsolvers\motionsolve\bin


\hwsolvers \linux64
\motionsolve\bin
\win64

PATH <altair> <altair>\hwsolvers\common\bin


\hwsolvers\common \linux64:$PATH
\bin\win64;%PATH%

LD_LIBRARY_PATH - <altair>\hwsolvers\motionsolve\bin
\linux64: $LD_LIBRARY_PATH

MS_SERVER_IP_ADDRESS IP address of IP address of Machine “B”


Machine “B”

where <altair> is the full path to the HyperWorks installation. For example, on Windows, this
would typically be C:\Program Files\Altair\<version>.
2. Note that other optional environment variables may be set for your model. See MotionSolve
Environment Variables for more information on these environment variables.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.245

Setup the Co-simulation


The core feature in Simulink that creates the co-simulation is an S-Function (System Function) block in
Simulink. This block requires an S-Function library (a dynamically loaded library) to define its behavior.
MotionSolve provides this library, but the S-Function needs to be able to find it. To help MATLAB/
Simulink find the S-Function, you need to add the location of the S-Function to the list of paths that
MATLAB/Simulink uses in order to search for libraries.

The S-Function libraries for co-simulation with MotionSolve is called mscosimipc – for Inter Process
Communication (IPC) using TCP/IP sockets for communication.

This file is located at <altair>\hwsolvers\motionsolve\bin\<platform>.

The location of this file needs to be added to the search path of MATLAB for the S-Function to use
mscosimipc.

This can be done in one of the following ways:

1. Use the menu options.


a) From the Matlab menu, select File > Set Path.

Figure 208: Add Path through the MATLAB GUI

b) From the dialog, add the directory where the mscosimipc library resides.

<altair>\hwsolvers\motionsolve\bin\win64

c) Select Save and Close.


This procedure permanently adds this directory to the MATLAB/Simulink search path.
2. Use MATLAB commands.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.246

a) To add the directory where mscosimipc library resides into the MATLAB search path, at the
MATLAB command line, type:

addpath('<altair>\hwsolvers\motionsolve\bin\<platform>')

It remains valid until you exit MATLAB.

Note: You can also create a .m script to make this process more easily
repeatable.
For example, you can set the MATLAB path and the necessary environment
variables using MATLAB commands in a MATLAB (.m) script:

addpath('<altair>\hwsolvers\motionsolve\bin\win64')
setenv('NUSOL_DLL_DIR','<altair>\hwsolvers\motionsolve\bin\win64')
setenv('RADFLEX_PATH',['<altair>\hwsolvers\common\bin\win64')
setenv('PATH',['<altair >\hwsolvers\common\bin\win64;'
getenv('PATH')])
setenv('MS_SERVER_IP_ADDRRESS','192.168.1.123')

b) For a Linux machine, additionally enter setenv('LD_LIBRARY_PATH', '<altair>\hwsolvers


\motionsolve\bin\linux64:<altair>\hwsolvers\common\bin\linux64\')

Viewing the Controller Modeled in Simulink


1. On Machine "A", in the MATLAB window, select File > Open.
The Open file dialog is displayed.
2. Select the InvertedPendulum_ControlSystem.mdl file from your <Working Directory>.
3. Click Open.
You will see the control system that will be used in the co-simulation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.247

Figure 209: The Control System in MATLAB

4. The model contains an S-function block. Name the S-function mscosimipc.


The S-function (system-function) is one of the blocks provided by Simulink and represents the
MotionSolve model. It can be found in the Simulink User-Defined Functions block library. An S-
Function allows you to model any general system of equations with inputs, outputs, states, and so
on, and is somewhat analogous to a Control_StateEqn in MotionSolve. See the MATLAB/Simulink
documentation for more details.
5. Double-click the S-function with name mscosimipc. In the dialog that is displayed, under the S
Function Parameters, enter the following using single quotes:

'InvertedPendulum_Cosimulation.xml', 'InvertedPendulum_Cosimulation.mrf', ''

The three parameters are the following:


• MotionSolve XML model name
• Output MRF name
• MotionSolve user DLL name (optional); enter empty single quotes ('') if not used.

Performing the Co-simulation


1. On Machine "B", in a shell prompt, run the command "msdaemon".

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.248

To run this command correctly, you will need to setup a few environment variables on Machine
"B". Please see MotionSolve Environment Variables for more information on these environment
variables.
The command "msdaemon" must be issued from the same working directory where the
MotionSolve XML resides. After issuing this command, you have setup MotionSolve in a "listening"
mode. The co-simulation will start whenever the simulation is started from Simulink.
2. On Machine "A", click Simulation > Start to start the co-simulation.
Simulink uses ODE45 to solve the Simulink model. From this, the co-simulation should begin and
Simulink will wait to connect to the MotionSolve model.
After starting the simulation in Simulink, MotionSolve will connect with the Simulink model and
the subsequent co-simulation will result in an output .mrf file for post-processing.
3. Set the Scopes in the Simulink model to display the results.
4. Check the .log file to make sure no errors or warnings were issued by MotionSolve.

Note: A license for MotionSolve will only be checked out on Machine B.

Figure 210: Running the Co-simulation from Simulink

Comparing the MotionSolve-only Results to the Co-


simulation Results
1. From the Start menu, select All Programs > HyperWorks <version number> > HyperGraph.
2. Click Build Plots .

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.249

3. Click the file browser and load the InvertedPendulum_NoCosimulation.mrf file. This was the
baseline result created by running MotionSolve by itself.
4. In the Page Controls toolbar, create two vertical plot windows.

Figure 211: Create Two Plot Windows

5. Select Marker Displacement for Y-Type, REQ/70000004 Output slider displacement (on
Slider cart) for Y Request, and DX for Y Component to plot the cart's translational displacement:

Figure 212: Plot the Cart's Displacement

6. Select the window on the left and click Apply.


7. Select Marker Force for Y-Type, REQ/70000002 Output control force- (on Slider cart) for Y
Request, and FX for Y Component to plot the X component of the control force:

Figure 213: Plot the Control Force on the Cart

8. Click the file browser icon and load the InvertedPendulum_Cosimulation.mrf file. This was the
co-simulation results run with Simulink.
9. Select Marker Displacement for Y-Type, REQ/70000004 Output slider displacement (on
Slider cart) for Y Request, and DX for Y Component to overlay the plot in the left window.
10. Select Marker Force for Y-Type, REQ/70000002 Output control force- (on Slider cart) for Y
Request, and FX for Y Component to overlay the plot in the right window.
Both the signals match as shown below.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.250

Figure 214: Comparison of the Cart Displacement and Cart Control Force Between the Two Models

The blue curves represent results from the MotionSolve-only model and the red curves represent
results from the co-simulation.

Appendix
For remote co-simulation, there are two options to installing MotionSolve on the machine where
Simulink is installed:
• Option 1: Fully install MotionSolve on Machine A, just like Machine B
• Option 2: Install a partial set of libraries on Machine A

If you exercise Option 2 above, then the list of files that need to be copied/installed on the machine
where Simulink is located include the following:

Windows Linux Path

mscosimipc.mexw64 mscosimipc.mexa64

msdaemon.exe msdaemon

nuclient.dll nuclient.so

pthreadVC2.dll

Also, when using Option 2, you can copy the above files to any folder of your choice, for example, ../
motionsolve/remote_cosimfiles/. In this case, the environment variables to set in Simulink will
change based on the table below:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.251

Environment Variable Windows Path Linux Path

NUSOL_DLL_DIR ..\motionsolve ../motionsolve/


\remote_cosimfiles\ remote_cosimfiles

PATH ..\motionsolve ../motionsolve/


\remote_cosimfiles\;%PATH% remote_cosimfiles:$PATH

LD_LIBRARY_PATH - ../motionsolve/
remote_cosimfiles:
$LD_LIBRARY_PATH

MS_SERVER_IP_ADDRESS IP address of Machine “B” IP address of Machine “B”

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.252

MV-7010: Co-Simulation with Activate - Quadrotor


Control
In this tutorial, you will learn how to use MotionSolve and Activate in a co-simulation to control a
Quadrotor model.

Activate is a software solution for multi-disciplinary, dynamic system modeling and simulation. The
software is especially useful for signal-processing and controller design that requires both continuous-
time and discrete-time components.

A co-simulation enables MotionSolve and Activate models to communicate with each other during
simulation. An ideal use case for co-simulation is the development of a control system for a multibody
dynamics model.

Quadrotor Model and Control


A quadrotor model is a multirotor helicopter that uses 2 sets of identical fixed pitched propellers (2
clockwise and 2 counter-clockwise) to control lift and torque.
Control of vehicle motion is achieved by altering the rotation rate of one or more rotor discs, thereby
changing its torque load and thrust or lift characteristics.

In MotionView you will create the quadrotor frame with 4 superblades and add the rotors motions. A set
of forces will be used to represent the wind disturbance.

Activate, through co-simulation with MotionSolve, will implement a controller to impose altitude and
direction in quadrotor trying to compensate against the wind effect.

Exercise
Copy the Quadrotor_start.mdl, rotor.h3d, shaft.h3d, superblade.h3d and
Quadrotor_Control_Start.scm from <installation_directory>tutorials\mv_hv_hg\mbd_modeling
\motionsolve\cosimulation\activate> to your <working directory>.

Reviewing the Model


1. Start a new MotionView session.
2. Select File Open model to load the Quadrotor_start.mdl file from your working directory.

3. Review the model.


The Quadrotor model has 9 bodies, one frame called vehicle, 4 propellers and 4 rotors. Associated
with them are their respective graphics.

To connect these 9 bodies there are 4 fixed joints connecting the rotors with the vehicle and 4
revolute joints connecting the propellers with the rotors.

Specifying the Propellers Motions

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.253

1. Right-click Motions to display the Add Motion or MotionPair dialog.

2. For Label and Variable, enter Prop_Left_Rotation and mot_Prop_Left_Rotation, and click OK.

Figure 215:

3. From the Connectivity tab, double-click Joint. Select Propeller_Left and click OK.
4. Change the Property to Velocity.

Figure 216:

5. Repeat the steps 1-4 to create motion in the other propellers.

Label Variable On Joint Property

Prop_Right_Rotation mot_ Prop_Right_Rotation Propeller_Right Velocity

Prop_Front_Rotation mot_ Prop_Front_Rotation Propeller_Front Velocity

Prop_Rear_Rotation mot_ Prop_Rear_Rotation Propeller_Rear Velocity

In a quadrotor, the velocity of the propeller is defined by the controller of pitch and roll of the
vehicle.

To define the velocity value of each propeller motion, create three solver variables that are use
further in the co-simulation.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.254

Specifying the Velocity of the Propellers


1. Before you can specify the velocity, you must first create the solver variables.
a) Right-click SolverVariable from the toolbar to display the Add SolverVariable dialog.

b) For Label, enter Throttle_Command.


c) For Variable, enter sv_Throttle_Command and click OK.

Figure 217:

Figure 218:

d) Repeat the steps a-c to create the Pitch and Roll solver variables.

Label Variable

Roll_Command sv_Roll_Command

Pitch_Command sv_Pitch_Command

2. Now you can update the propeller motion velocity.


a) From the Project Browser, browse to the Motions folder and select Prop_Left_Rotation
motion.
b) From the Motion panel, go to the Properties tab.
c) From the Properties tab, change Define by to Expression and enter:

`VARVAL({sv_Throttle_Command.idstring})+VARVAL({sv_Roll_Command.idstring})`

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.255

d) Repeat the steps above for Propeller Right, Front and Rear, following the table entries below:

Motion Expression

Prop_Right_Rotation
`VARVAL({sv_Throttle_Command.idstring})-
VARVAL({sv_Roll_Command.idstring})`

Prop_Front_Rotation
`-VARVAL({sv_Throttle_Command.idstring}) -
VARVAL({sv_Pitch_Command.idstring})`

Prop_Rear_Rotation
`-VARVAL({sv_Throttle_Command.idstring})+
VARVAL({sv_Pitch_Command.idstring})`

Note: The lateral propellers (left and right) control the Roll of the vehicle and
the vertical propellers control the Pitch. The signal difference in the expressions
determine the rotation direction of the quadrotor.

Figure 219:

Adding Wind Disturbance Forces


To represent the wind effect and thrust of the quadrotor, a set of forces and moments must be defined.

The wind disturbance is represented as a combination of torques in the X and Y axle applied at the
vehicle center.

The thrust of each propeller is represented as a Z force following this equation:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.256

(12)

Where,

= Thrust force

= Thrust factor (Defined considering the propeller geometry, air density,m and spin area. For this
analysis Tf= 2.1998e-5).

= Propeller Angular velocity

1. Create the wind disturbance force.


a) Right-click Force to display the Add Force dialog.
b) For Label, enter Wind_Disturbance.
c) For Variable, enter frc_Wind_Disturbance and click OK.
d) From the Connectivity tab, set Force to Action only and Property to Rotational.
e) For Body, select Vehicle and for Point, select Pivot.

Figure 220:

f) From the Rot Properties tab, set Tx and Ty to 0.5.

Figure 221:

2. Create the thrust force.


a) Right-click Force to display the Add Force dialog.
b) For Label, enter Thrust_Left.
c) For Variable, enter frc_Thrust_Left and click OK.
d) From the Connectivity tab, set Force to Action only and Property to Translational.
e) For Body, select the body Rotor_Left, for Point, select the point Left_Motor_Center, and
for Ref Marker select the marker Left_Rotor.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.257

Figure 222:

f) From the Trans Properties tab, change Fz to Expression and enter the expression: ` `

Figure 223:

g) Repeat the steps to create the thrust force for the right, front, and rear.

Thrust Right

Label Thrust_Right

Variable frc_Thrust_Right

Body Rotor_Right

Point Right_Motor_Center

Ref Marker Right_Rotor

Fz Expression `2.1998e-5*ABS({j_Propeller_Right.WZ})^2`

Figure 224:

Thrust Front

Label Thrust_Front

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.258

Thrust Front

Variable frc_Thrust_Front

Body Rotor_Front

Point Front_Motor_Center

Ref Marker Front_Rotor

Fz Expression `2.1998e-5*ABS({j_Propeller_Front.WZ})^2`

Figure 225:

Thrust Rear

Label Thrust_Rear

Variable frc_Thrust_Rear

Body Rotor_Rear

Point Rear_Motor_Center

Ref Marker Rear_Rotor

Fz Expression `2.1998e-5*ABS({j_Propeller_Rear.WZ})^2`

Figure 226:

3. To save your model, click Save As and save it with the name Quadrotor_tutorial.mdl

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.259

Creating Control Inputs and Plant Outputs


To modify the MBS model to work in a Co-Simulation Mode you need to add solver arrays and solver
variables entities in MotionView model. The solver variables contain the individual plant input and
output values. The solver arrays define the plant input and output to communicate with Activate.

1. Adding solver variables.


a) The individual plant input solver variables were already defined with the propellers motion in
Specifying the Velocity of the Propellers. They are Throttle_Command, Roll_Command and
Pitch_Command.
2. Next, you will define the individual plant output values, which are Altitude, Roll Angle, Pitch Angle,
X position, Y position, X velocity and Y velocity.
a) Right-click SolverVariable from the toolbar to display the Add SolverVariable dialog
and add the following solver variables:

Label Variable Expression

Altitude sv_Altitude
`DZ({m_Vehicle.idstring})`

Roll_Angle sv_Roll_Angle
`AY({m_Vehicle.idstring})`

Pitch_Angle sv_Pitch_Angle
`AX({m_Vehicle.idstring})`

PosX sv_PosX
`DX({m_Vehicle.idstring})`

PosY sv_PosY
`DY({m_Vehicle.idstring})`

VX sv_VX
`VX({m_Vehicle.idstring})`

VY sv_VY
`VY({m_Vehicle.idstring})`

Note: Remember to set the Type in the SolverVariable Properties tab to


Expression.

3. Create two solver arrays, ControlInput and PlantOutput, to communicate with Activate.
a) Right-click SolverArray from the toolbar to display the Add SolverArray dialog.
b) For Label, enter ControlInput.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.260

c) For Variable, enter sa_ControlInput and click OK.


d) From the Properties tab, change the Array type to Plant Input and enter 2 for Append (two
more signals).

Figure 227:

e) Select Roll_Command for SolverVariable 1, Throttle_Command for SolverVariable 2 and


Pitch_Command for SolverVariable 3 in this order:

Figure 228:

f) Right-click SolverArray from the toolbar to display the Add SolverArray dialog.
g) For Label, enter PlantOutput.
h) For Variable, enter sa_PlantOutput and click OK.
i) From the Properties tab, change the Array type to Plant Output and click Append 6 times to
append 6 more signals.
j) For the seven solver variables, select the Roll_Angle, Altitude, Pitch_Angle, PosX, PosY,
VX, and VY variables in this order.
4. Save your model.

Running the MBS Model in MotionSolve for Verification


1. Click Run Solver , rename the MotionSolve input to Quadrotor_tutorial.xml and run the
model.
2. Click Animate to animate the simulation results and confirm that the model works as intended
before continuing to the next step.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.261

Note: The controller is not yet connected to the model, so the input force and torque
are zero.

Connecting MotionSolve with Activate


1. From the All Programs menu, launch Activate.
2. From the menu bar, select File > Open.
3. Open Quadrotor_Control_Start .scm and review the model.
The system has 3 sections of control: Altitude of the quadrotor, X position and Y position. The X
and Y position control is defined by a target path, for this model it is a slope of 0.025.

Figure 229:

These three sections of controls defined by seven PIDs are the plant input for the MBS model. In
MotionView, it's defined as Roll_Command, Throttle_Command and Pitch_Command.

The plant output, Roll_Angle, Altitude, Pitch_Angle, PosX, PosY, VX, and VY, are input for the PID
controls.

For example, in the X position target control, you will see three inputs which come from the plant
output (PosX, VX, and Roll Angle).

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.262

Figure 230:

4. To enable co-simulation between Activate and MotionSolve, from Activate, select File >
Preferences > Paths. In the dialog that is displayed, define the MotionSolve and MotionView
license paths.

Figure 231:

5. From the Palette Browser, select Palettes > Activate > CoSimulation, and drag-and-drop the
MotionSolve block into the current diagram and connect the blocks.

Figure 232:

6. From the diagram, double-click the MS Plant block. From the dialog that is displayed, define the
following block properties:
a) XML or MDL input filename: Browse the path to your MotionView .mdl model or MotionSolve
.xml file (Quadrotor_tutorial.mdl or Quadrotor_tutorial.xml) by clicking the file
selector.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.263

Note: Activate allows you to define either MDL or XML as the input for co-
simulation with MotionSolve. When you choose MDL as the input file name, MDL
is converted to XML on run time so you may notice a delay as the co-simulation is
beginning.

b) MRF output filename: Specify the path for the output MRF file (Quadrotor_tutorial.mrf).
Use the forward slash, /, in your path definition.
c) Direct feed through: Clear (default) the checkbox. If the object is selected and the simulation
runs and encounters an algebraic loop, the option should be cleared to break the algebraic
loop.
The following parameters are populated automatically after you load the input model, *.mdl or
*.xml:
• Inputs Row Size: The value 3 indicates that three signals are supplied from Activate to the
MotionSolve model. These signals correspond to the solver array PlantInput, with variables
Roll_Command, Throttle_Command and Pitch_Command.
• Outputs Row Size: The value 7 indicates that the MotionSolve model is sending out seven
signals from one port, which is why the Demux block is added to separate the signals.
The signals correspond to the solver array PlantOutput with variables Roll_Angle, Altitude,
Pitch_Angle, PosX, PosY, VX and VY.

Figure 233:

7. Click and drag to connect the output of the block Mux to Control Input of the MS Plant. Similarly,
connect the Plant Output end of the MS Plant to the input end of Dmux. All required blocks are
now present and connected in the modeling window.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.264

Figure 234:

8. From the ribbon's Simulate tool group, select Setup tool. From the Simulation Parameters
dialog, in the Final Time field, enter 12 so that your simulation runs for twelve seconds.

Figure 235:

Note: Since Activate is the master, or calling, solver in this co-simulation scenario,
if the simulation end time in Activate is different than the MotionSolve simulation end
time, the MotionSolve simulation end time will be modified at run time to match the
end time specified in the Activate dialog above.

9. From the ribbon, click Run .


The Scope blocks in the model generate the following plots, which illustrate the altitude, roll,
pitch, x position, y position, and the path.

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.265

Figure 236: Altitude Figure 237: Roll

Figure 238: Pitch Figure 239: X Position

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.266

Figure 240: Y Position Figure 241: X Velocity

Figure 242: Y Velocity Figure 243: XY Path

10. Launch HyperView and animate the Quadrotor_tutorial.h3d file to see the quadrotor behavior.

Figure 244:

Proprietary Information of Altair Engineering


MotionSolve Tutorials
Advanced Simulation p.267

Figure 245:

11. Before exiting the applications, save your work in Activate as quadrotor_complete.scm.

Proprietary Information of Altair Engineering


Index
A
adding a jack to the model 50
adding a SISO controller 200
adding a solver variable 181
adding a solver variable for reference speed 199
adding contact 146
adding disturbance force and running the simulation 208
adding joints 145
adding joints and requests 133, 139
adding motion 146
adding output requests for control force 201
adding parts 144
adding the control torque 200
adding units and gravity 131, 136, 143
adding wind disturbance forces 255
advanced simulation tutorials 179
appendix - co-simulataion with simulink IPC approach 250
appendix A 218
appendix B 218

B
building a C++ user subroutine DLL using Microsoft® Visual Studio® 172
building a FORTRAN user subroutine DLL using Microsoft® Visual Studio® 173
building and analyzing a simplified model 180
building the shared library 168

C
checking the stability of a closed loop system 207
comparing the MotionSolve-only results to the co-simulation results 196, 248
connecting MotionSolve with Activate 261
consolidating and renaming the suspension assembly bodies 42
contact overview via H3D 21
converting C sub into Python sub 175
creating a fixed joint between two non-coincident markers using Templex 56
creating a geometry object 139
creating a model 130, 135, 143, 153
creating a template to define the sequential simulation 57
creating and simulating flexible LCA 64
creating control inputs and plant outputs 259
creating joints and motion 14
creating joints and spring damper 48
creating joints, markers and sensors 53
creating markers 131, 131, 138

268
creating output requests and rerunning the model 37
creating points 45
creating RBE2 spiders 66
creating requests 146
creating the MBD model of the car door 89

D
defining a motion to retract the landing gear 32
defining a template to run the sequential simulation 35
defining an extension motion for the landing gear 34
defining contact between the colliding geometries 15
defining markers for geometry 144, 144
defining points 137
defining stress/strain set in OptiStruct 75
defining the contact force 132
defining the model set in OptiStruct 76
defining the plant in the control scheme 190, 242
designing a control system in MATLAB 207
determining the stability of the open loop model 204

F
flexible body dynamics tutorials 60
frequently asked questions 170

G
generating a plot 147
generating the flexbody using flex prep 87

I
implementing the control force in MotionView 207
import cad geometry into MotionView 11
integrating the flexbodies into your MBD model 79
invoking FlexPrep in batch mode 73, 73

L
load the model in MotionView 223
loading the CAD file into MotionView 39
loading the msolve module 130, 135, 143, 150
loading the rotor model 199

M
manually yplotting other output requests 27
modeling differential equations 182
modifying the ACF file 96

269
modifying, compiling and linking the code to create the DLL 216
MV-1010 summary 28
MV-1010: 3D Mesh to Mesh Contact Simulation 10
mv-1011: extension and retraction analysis of the main landing gear of an aircraft 29
MV-1024: Using User Subroutines in MotionSolve Models 158
MV-1035: Importing CAD or FE into MotionView 39
MV-1051: Understanding Sequential Simulation 53
MV-2010: Flexbody Generation using Flex Prep and OptiStruct 64
MV-2020: Using Flexbodies in MBD Models 79
MV-2021: Simulating an Automotive Door Closure Event 86
MV-2035: Solving Flexbody ADM/ACF in MotionSolve 95
mv-3000: doe using MotionView-HyperStudy tutorials 100
mv-3010 optimization using MotionView - HyperStudy 124
MV-7000: Modeling Differential Equations Using MotionView and MotionSolve 180
MV-7001: Building User Subroutines in Altair MotionSolve 165
MV-7002: Co-simulation with Simulink 187
MV-7003: Simulating a Single Input Single Output (SISO) Control System Using MotionView and MotionSolve 199
MV-7004: Inverted Pendulum Control Using MotionSolve and MATLAB 203
MV-7005: Linking Matlab/Simulink Generated Code (Simulink Coder) with MotionSolve 210
MV-7006: Python UserSub for MotionSolve 174
MV-7008: co-simulation with AcuSolve 220
MV-7009: Co-simulation with Simulink - IPC Approach 237
MV-7010: Co-Simulation with Activate - Quadrotor Control 252
MV-9000: Bouncing Ball Tutorial 130
MV-9001: Simple Pendulum Tutorial 135
MV-9002: Slotted Link Tutorial 143
MV-9003: LuGre Friction Tutorial 149

O
obtaining a linearized model 205
opening the landing gear mechanism 30
optimization-doe-stochastics tutorials 99

P
performing the co-simulation 247
plotting the contact forces via ABF 26
post-process the results from the co-simulation 233
post-processing the results 20
preparing the MotionSolve model 210
preparing the Simulink model - generating code 211

R
repeating the co-simulation 195
review the finite element model for the flexible door 86
reviewing the model 252

270
rigid body dynamics tutorials 9
run the AcuSolve executable for co-simulation 232
run the model without co-simulating with AcuSolve 227
run the MotionSolve and middleware executables for co-simulation from the MotionSolve run manager 229
running a dynamic analysis to simulate the retraction of the main landing gear. 34
running a MotionSolve model with the generated DLL 217
running the baseline MotionSolve model 189, 241
running the MBS model in MotionSolve for verification 260
running the model in MotionSolve 185
running the simulation 133, 140, 147, 201
running the simulation and animating the results 58

S
setting up a transient simulation and running the model 19
setting up environment variables 192, 244
setup the co-simulation 193, 245
simulating and animating the model 36
specify the “wet” body that will interact with AcuSolve 225
specifying motion inputs and running the model in MotionSolve 51
specifying source code or object files 166
specifying the output directory 168
specifying the propellers motions 252
specifying the velocity of the propellers 254
step 1: optimization study 125
step 1: study setup 102
step 2: comparing the baseline and optimized models 127
step 2: doe study 111
step 3: approximation 118

U
user subroutines tutorials 157
using an expression to define motion 159
using FlexBodyPrep 65
using PLOTEL elements in OptiStruct 76
using the Microsoft® Developer Studio to build a shared library 172
using the MotionSolve api tutorials 129
using the MotionSolve subroutine build tool to create shared libraries 165
using the MOTSUB user subroutine to define motion 160
using the released DOF method for interface nodes in OptiStruct 78

V
verify the model between MotionSolve and AcuSolve 228
verifying the part creation 138
viewing the controller modeled in Simulink 194, 246
viewing the model and verifying results 69

271
viewing transient analysis results in HyperView by adding external graphics 97
visualizing MotionSolve outputs 25
visualizing the contact forces via H3D 23
visualizing the penetration depth via H3D 22
visualizing the sum total of force at a given region 24

272

You might also like