FLUENT - How to create animations of particle tracks?
For a steady state flow simulation, how do I create an animation of particle tracks?
In FLUENT you can display the particle tracks in pulse mode. However, FLUENT doesn't have an inbuilt function to save the animation of particle tracks which you see in pulse mode. This solution provides a method for creating an animation of these particle tracks.
This solution provides step by step instructions to create animation of particle tracks:-
Step 1: Read your steady-state case and data files into FLUENT 6.2.16.
Step 2: Set up one or more injections in the usual way using Define->Injections. If you want to mimic the pathline plot, make sure to use small particles (e.g. 1 micron). Display the particle tracks from the newly created injection(s). Please make sure that the injections defined above do result in some particles entering the domain. This is an important step as this allocates memory for particle tracks.
Step 3: Turn on the unsteady solver in Define->Models->Solver (use First Order - this is actually arbitrary).
Step 4: Enable Unsteady Particle Tracking in Define->Models->Discrete Phase Model (DPM) (use default settings).
Step 5: To automatically plot the DPM particles and export the graphics files for animations, use Solve->Execute Command as follows:
A. Create a macro to display the DPM particle positions for all injections using Display->Particle Tracks.
Option-1:- Use GUI generated Macro:-
This macro can be created using the Define Macro button. This function records the steps performed by the user in a function called macro. This macro will be executed at the frequency specified in the Solve Execute commands panel. The procedure to create a GUI based macro is given below:-
1. Increment No. of Execute commands by 1. Hit the Define Macro button. A panel will open up asking for the macro name. The default macro name will be "macro-1", either use the default name or customize it if you wish to.
2. Now you need to visit Display-->Particle Tracks panel. Select the coloring attributes for particle tracks (which can be velocity, particle ID or temperature) . Select the injection source and hit display.
3. The above step will display the particle tracks along with the other attributes(e.g. grid display etc.)
4. Visit Solve--> Execute Commands panel again and hit End Macro. Now FLUENT console window will show a message like:-
Macro macro-1 defined.
5. Now enter the macro name in the field "Command" (from Step 5 above) and set the frequency of execution as 2 time steps.
Option-2:- Use of TUI (text user Interface) command.
This option uses a TUI command to display the particle tracks.
Enter the following in the field for Command (from Step 5 above):
/display particle-tracks particle-tracks velocity-magnitude "injection-0" , , ,
In the above command we are coloring the particle tracks with velocity magnitude. Similarly one can change the coloring method (e.g. pressure, temperature etc).
You can either use Option-1 or Option-2 for displaying particle tracks.
B. Create a second macro to save a tif file to disk (using filename such as particle%t.tif, where %t will be the current time step). The command can be "/disp hc particle-tracks%t.tif" . One can change the hard copy attributes before executing this command. This can be done either through the GUI panel or through TUI commands. Its easy to set the attributes through GUI panel for Hardcopy. Go to File -->Hardcopy, set hardcopy format to tiff, coloring to color. Set preferred orientation and Foreground Background options and hit Apply. The attributes set in this panel will be used while saving the hardcopies.
C. Set the "When" input to "Time Step" and "Every" input as desired (e.g. 2 = run the macros every two time steps).
Step 6: Access Solve->Controls->Solution and deselect (disable) ALL equations (e.g. flow, turbulence, etc.). This will allow you to update the DPM model without changing your steady-state flow field solution.
Step 7: In the Solve->Iterate panel, choose a time step which is suitable for updating the particles. A good choice is to use dt = dx / Vc, where dx is the minimum cell size in the domain and Vc is a characteristic velocity. Also, set the number of sub iterations to 0.
Step 8: Run the model for as many time steps as desired (e.g. the number of time steps it takes for particles to traverse the entire domain). As the calculation proceeds, the Command macros will be executed, thereby saving graphics images of the particle positions to tif files. When the calculation is complete, you can use xanimate, gif construction set, or similar software to animate the images.
Some notes on the foregoing method...
* For plotting the particles, use "Style" of Point, with a point size (under "Attributes") of about 0.2. Also, showing an outline or feature lines of of the geometry is recommended, in order to provide a point of reference for the particles.
* Note that the unsteady DPM model is updated every time step when you run the model using Solve->Iterate. So when you access Display->Particle Tracks, you will display the current positions of the particles at a given time.
* There are "Start Time" and "Stop Time" parameters for each injection that you can specify in Define->Injections. These control when particles are released and removed from the domain. This can be useful for creating interesting displays (waves of particles initiated at different times, for example).
* In general for injections defined above, the stop time is set to same as "time step" in the flow iteration panel. This will ensure that the particles are injected only once in the domain.
* If one wants to perform the particle animation once again then the following needs to be done.
(1) Clear the particles which are in the domain through Define-->Models-->Discrete Phase panel. Hit the button "Clear particles"
(2) Reset the Flow time and time step counter using the following scheme commands. These commands (including their brackets) must be entered in the FLUENT console window.
(rpsetvar 'flow-time 0)
(rpsetvar 'time-step 0)
* Before proceeding for final animation generation, just perform two time step iterations and see the tiff file saved in the working directory. Change the hardcopy attributes as needed and restart the animation process by reseting the flow time and time step as mentioned above.