Coupling Interface Programming Guide
Coupling Interface Programming Guide
Coupling Interface Programming Guide
Programming Guide
Information in this document is subject to change without notice. The software described in this
document is furnished under a license agreement or nondisclosure agreement. The software may
be used or copied only in accordance with the terms of those agreements. No part of this
publication may be reproduced, stored in a retrieval system, or transmitted in any form or any
means electronic or mechanical, including photocopying and recording for any purpose other than
the purchasers personal use without the written permission.
DEM Solutions
49 Queen Street
Edinburgh
EH2 3NH
UK
www.dem-solutions.com
EDEM incorporates CADfix translation technology. CADfix is owned, supplied by and Copyright
TranscenData Europe Limited, 2007. All Rights Reserved. This software is based in part on the
work of the Independent JPEG Group. EDEM uses the Mersenne Twister random number
generator, Copyright 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved.
EDEM includes CGNS (CFD General Notation System) software. See the Online Help for full
copyright notice.
EDEM , EDEM Creator , EDEM Simulator , EDEM Analyst and Particle Factory are registered
TM
TM
trademarks of DEM Solutions. EDEM Field Data Coupling , EDEM CFD Coupling Interface
TM
and EDEM Multibody Dynamics Coupling Interface are Trademarks of DEM Solutions. All other
brands or product names are the property of the respective owners.
Contents
INTRODUCTION........................................................................................................................................ 3
COUPLED SIMULATION SEQUENCE........................................................................................................... 4
EDEM COUPLING INTERFACE PACKAGING ............................................................................................................4
ENABLING AND RUNNING THE COUPLING SERVER ...................................................................................................5
COUPLED EDEM-CFD SIMULATION OVERVIEW ......................................................................................... 6
THE CFD COUPLING SIMULATION SEQUENCE ........................................................................................... 7
RETRIEVING PARTICLE DATA FROM EDEM ............................................................................................................8
USING SAMPLE POINTS TO REPRESENT PARTICLES ..................................................................................................9
SETTING EXTERNAL FORCE AND TORQUE ON PARTICLES .........................................................................................10
REGISTERING AND USING CUSTOM PARTICLE PROPERTIES ......................................................................................11
Registering a New Custom Particle Property ........................................................................................11
Using Custom Particle Properties ..........................................................................................................11
MULTIBODY DYNAMICS COUPLING INTERFACE...................................................................................... 13
Registering Geometries for Motion ......................................................................................................13
Retrieving the Position of a Geometry ..................................................................................................14
Setting Geometry Motion .....................................................................................................................14
Retrieving Material Forces Acting on Geometries ................................................................................15
Setting the Point of Action on a Geometry ...........................................................................................15
Multi-step Simulation with the Multibody Dynamics Coupling Interface .............................................15
Geometry Velocity Vectors ....................................................................................................................17
Force Averaging ....................................................................................................................................18
Coupling Interface Custom Properties ..................................................................................................18
DESIGN-OF-EXPERIMENT STYLE STUDIES WITH EDEM COUPLING INTERFACE ........................................ 19
Importing a Geometry ..........................................................................................................................19
Assigning a Material to a Geometry .....................................................................................................19
Deleting a Geometry .............................................................................................................................19
Assigning Dynamics to Geometry .........................................................................................................19
APPENDIX A ........................................................................................................................................... 20
CUSTOM PARTICLE PROPERTY UNIT TYPES ..........................................................................................................20
Introduction
EDEM is the leading DE (Discrete Element) simulation software platform designed for
the simulation and analysis of bulk particle handling and processing equipment in a wide
variety of industries.
This programming guide provides an overview of how to use the EDEM Coupling
Interface to couple with a generic CFD code and/ or multibody dynamics codes.
Programming implementation information for the interface is also provided and can be
found in the EDEM Coupling Interface class, IEDEMCouplingV2_2_0.h.
The EDEM Coupling Interface enables users to construct coupled fluid - particle
simulations between CFD codes and EDEM (Figure 1) or coupled rigid/ multi body
dynamics codes. It enables two independent programs to operate synchronously,
sharing data to create a single coupled simulation.
The EDEM Coupling Interface adopts TCP/IP client server architecture which uses
messages for communication between the two separate programs. Users may
implement a new coupling with a physics code, using C++, to program a solution
utilizing the EDEM Coupling Interface. The EDEM Coupling Interface is an addition to
EDEM and can only be used when its license is available.
Figure 1: Communication between EDEM and a physics code using the EDEM Coupling
Interface
Each time the EDEM Coupling Interface sends a message to EDEM it blocks any further
messages from being sent until EDEM returns a response. This synchronous behavior
effectively pauses the 3rd party code until EDEM has calculated the required simulation
step.
When the server is enabled, a coupling server widget is added below the Viewer
Controls panel. By pressing the "Start" button, the user can start the server. The server
can be stopped by pressing the "Stop" button in the same widget (Figure 5).
Note: By default EDEM will launch with the Coupling Server stopped and requires the
user to press the Start button before a coupled simulation can proceed. For running in
batch mode or for making the process more automated EDEM can be launched with the
Coupling Server already running by adding the -cs switch to the command line.
After EDEM completes the simulation-step, it is possible to retrieve the new or updated
particle data from the simulation. This data is then returned to the CFD solver (Steps 6,
8, 10), in order to update the CFD solvers variables and simulation. Any custom
properties included in the simulation can be updated and retrieved following a similar
sequence at the beginning and end of each EDEM simulation-step.
.....
0
.....
Type 0
.....
n-1
.....
.....
n+m-1
n+m+
p-1
.....
Type 1
Type 2
An example of such an implementation exists in the source code of the Ansys Fluent coupling
example.
Each point is checked to determine which CFD mesh cell it lies within. The solid volume
fraction within a particular mesh cell is, therefore, the percentage of the number of
sample points that lie within that mesh cell as, given by:
s 1
nc
Vp
particles N
Where nc is the number of sample points contained within the mesh cell of particle p and
N the total number of sample points of the particle. Vp is the volume of the particle.
Sample points are generated for each of the particle types defined in the simulation.
Using the position, orientation and scaling of the individual particles, the precise coordinates for the points representing each particle can be calculated. Provided no
additional particle types are later added to the simulation, sample points need only be
collected once, at the start of a simulation. The method used to request sample points
from EDEM is collectSamplePoints.
The sample points for a particle type are returned as an array of 3D values (C3dValue
objects) of size n. The user is responsible for allocating and deleting memory to store the
sample points for the simulation.
.....
Type 0
.....
.....
Type 1
Type 2
.....
3nn+
m
.....
3n+2
Type 0
Figure 10: Particle data array for force or torque
For a particle type 0 of a multi-particle type simulation, the array for either force or torque
should be constructed in the manner shown above. The index for the force applied to
particle n starts at position(3n) and finishes at position (3n+2) of the array. Therefore, the
correct index for the force applied to particle 0 starts at 0 and finishes at 2. Additional
particle types in the simulation are ordered after the first particle type, in the same
manner as the example for particle data.
10
11
.....
Type 0
Figure 11: Particle data array for a custom property
A value for a custom property is set by creating an array following the structure
described. It is then possible to update the custom property values in EDEM using the
setValueForCustomProp. The user must then delete the array that they have created
when the update is complete.
12
Figure 12: The Multibody Dynamics Coupling Interface. Data interaction with EDEM
The Multibody Dynamics Coupling Interface allows the exchange of contact forces and
equipment motion between EDEM and a coupled code. The coupled code can retrieve
bulk material forces resulting from contact with the equipment surfaces calculated in
EDEM and return equipment kinematics.
The simplicity of the data exchange method between EDEM and coupled multibody
dynamics code allows for the rapid development of rigid body dynamics for inclusion in
DEM simulations. The control over EDEM simulations offered by the interface is also
suitable to allow coupling and co-simulation with 3rd party multibody dynamics software
such as LMS Virtual.Lab Motion, Matlab Simulink and MSC Easy5 and Adams. Through
coupling with MBD software, modeling can be extended to contain a wide range of
components including hydraulic control systems, motors and interconnected equipment
geometries.
13
14
Linear interpolation always acts in a straight line between two points. Therefore
non-linear motions will have a degree of positional error associated with them.
This should be considered when selecting an appropriate data exchange interval.
16
By dragging the slider to the right, the user can increase the scale factor of the vector
and, consequently, their size. Dragging the slider to the left decreases the size of the
vectors. Note that the widget is only enabled when at least one of the geometries has
motions that are calculated through the multibody dynamics interface.
17
Force Averaging
To complement the motion interpolation during the EDEM simulation, forces are
averaged over the number of time-steps that EDEM is run for. Custom properties for the
time-averaged force and torques acting on a geometry are created when the geometry is
registered for control using the getGeometryID method. The average force is
updated in the custom property every EDEM time-step. The averaged values for the last
simulation-step can be retrieved from EDEM when it is not simulating a time-step. All
averaged values are reset to zero at the start of the next EDEM simulation-step.
Angular Velocity-section
Force-section (CoG)
Torque-section
Velocity-section (CoG)
18
Importing a Geometry
The loadGeometry method will create a new geometry section in the EDEM simulation
and name it using the CAD file name which is read in. The import process will use the
same default parameters as shown in the EDEM Creator Geometry import dialog, any
changes to the defaults can be specified via the setGeometryImportParameters
method, which should be invoked prior to calling the loadGeometry method.
Deleting a Geometry
Use the name of the target geometry to delete it from the simulation via a call to
removeGeometry.
19
Appendix A
Custom Particle Property Unit Types
Unit Type
Identifier
SI Units
Other
Unknown unit
None
Unitless
Acceleration
m/s2
Angle
Rad
Angular Acceleration
rad/s2
Angular Velocity
rad/s
Density
kg/m
Energy
Work Function
Force
Charge
10
Length
11
Mass
12
Kg
Moment of Inertia
13
kg/m2
Shear Modulus
14
Pa
Time
15
Torque
16
Nm
Velocity
17
m/s
Volume
18
m3
Frequency
19
Hz
Temperature
20
20
21
Stiffness
22
N/m
Stress
23
Pa
Mass Flow
24
kg/s
25
N/m3
21