MercuryDPM
Alpha
|
File CoilSelfTest.cpp treats particles placed in a feeder being driven forward by a rotating coil. The entire code of this problem can be viewed here: Particles driven by a rotating coil (code).
The following headers are included:
These are basically the headers used for the beginner tutorials, except for the additional Coil class.
CoilSelfTest, like many of the previous tutorials, inherits from the Mercury3D class.
The different components of the class will be explained in turn in the following.
CoilSelfTest only has one (public) data member, namely a pointer to the coil:
The method which sets up the initial conditions of the problem takes up the major part of the driver.
The method starts by a specification of some elementary problem properties, like direction of gravity (-Y), particle radius and the geometrical size of the system.
Next, the particle species is defined. The particles in this problem will use a linear visco-elastic (normal) contact model. The dissipation and stiffness defining the contact model can be set in different ways. In this example the contact model properties are set by giving a collision time, coefficient of restitution and the particle mass.
The particles are initially contained by a container made up of six walls, five of which are defined to be infinite. The wall in the positive Z-direction is different. Its normal is set (rightWall->set(...
) in the positive Z-direction (Vec3D(0, 0, 1)
), is set a distance zMax_
(which is returned by getZMax()
) from the origin, and contains a 'hole' (which is practically a horizontal tube, since the wall is 'infinite') around the X-axis of radius 1.0
in order to let the particles through.
After that the Coil object is added. Its geometrical properties are subsequently set by using the Coil::set() method, specifying its starting position (the origin, i.e. Vec3D(0,0,0)
), its length (1.0
), its radius (1.0 - particleRadius
), its number of turns (2.0
), its rotation speed (-1.0
revelations per second) and its thickness (0.5 * particleRadius
).
NB: its direction or central axis is not specified, since these are the Z-direction and the Z-axis, respectively, by default.
The particle properties are set subsequently. The particleHandler is cleared just to be sure it is empty, then the particle to be copied into the container is created and the previously set species is assigned to it. The particle is assigned a zero velocity and the previously defined particle radius.
After specifying the particle properties, the container is filled with copies of the particle. In this example, particles are placed in a rectangular grid pattern, on evenly spaced positions. First, the number of particles that fit in each direction is computed. Then, a triple for-loop passes every possible particle position, and a particle is placed on the position if there's no part of the coil there.
The actionsBeforeTimeStep() method specifies all actions that need to be performed at the beginning of each time step, i.e. before the actual numerical solution at that time step is computed. In this case, it states that from 1 second into the simulation time and onward, the coil should turn with the given rotational speed.
int main()
In the main program, a CoilSelfTest object is created, after which some of its basic properties are set like its number of dimensions (three), time step and saving parameters. Lastly, the problem is actually solved by calling its solve() method.
(Return to Overview of advanced tutorials)