# MV-2021: Simulate 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.

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.

## Generate 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.

1. In MotionView, from the FlexTools menu, select Flex Prep.
The FlexBodyPrep dialog is displayed.
2. In the FlexBodyPrep dialog, enter the following information to generate the flexbody for building the door closure model.
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.
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.

## Create 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.

### 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.
3. Click the Properties tab of the Car Body and enter the mass and inertia properties values as shown below.
4. Add another body and label it Car Door.
5. From the Properties tab, click the Flex Body 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.
3. Click OK.
The HyperMesh file is converted to H3D and imported into the MotionView window.
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.

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 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.
3. Once the markers are created, repeat steps 3-5 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.

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}"
/>
<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:

1. Deactivate Fixed Joint (initially).
2. Simulate for 1 second.
3. Activate Fixed Joint.
4. Deactivate Sensor.
5. Simulate for 1.5 seconds.
6. 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.