+47 67 57 21 00
ANSYS Tutorial: Time operations in CFX
Accessing a history of variables is not supported in CFX, but is a frequently desired feature. The answer is most often to create your own Fortran routine. There is, however, a nifty set of simplified routines that can be called from within CEL functions. One of these, GET_VAR, allows us to retrieve the time derivative of a variable.
Example: Time derivatives
Say for example that you want to calculate the time derivative of the fluid velocity field. Simply create an Additional Variable according to the image below.
In the Fluid Models tab, fill in the following expressions for the variable.
That’s it! Now the fluid acceleration is ready to be calculated. GET_VAR can be used for other purposes, other than temporal gradients, see the CFX Help for more information.
Accessing values from previous time steps
Aside from the built in GET_VAR routines there is a great, albeit unsupported, way to manually access values of variables from the immediately preceding time step, using an Additional Variable with a clever modification. This could be used in order to, for example, integrate variables over time.
Example: Integrate variables over time
Let’s say you want to find out the total mass through an outlet during a transient simulation. This can be done by integrating the mass flow through this region over time.
What you need to do is to create an Additional Variable (here called “TotalMass”) where we store the value of the accumulated mass flow. In addition to the common variable properties, add “Update Loop = TRANS_LOOP” by editing the variable in Command Editor, see below. The purpose of the Update Loop command is to force the Additional Variable to stay constant throughout the coefficient loops and update only once a new time step is started.
Now create an expression (here “Mass”) for the accumulated mass, see the figure below. This expression is then assigned as an algebraic equation to the “TotalMass” Additional Variable in the Fluid Models tab.
NOTE: In order for the simulation to run, the Additional Variable needs to be initiated in a separate run, otherwise the summation will fail due to lack of starting value. To do this, just run a single iteration of the same setup, except specify the Algebraic Equation to 0 instead of “Mass”. Then use the result file as initial conditions for the next run.



