# How can I calculate the second and third derivative of different varibles (u,v,w, p,..) in CFX-5.7.1?

 To do this, you will need to write a Fortran file. Note that you will need to be particularly careful when you are trying to find the derivative of vectors as opposed to scalars.1. You need to set up a series of Additional Variables. These must be of variable type 'Unspecified', and using the 'Algebraic Equation' option you must set the first Additional Variable (AV) equal to the highest derivative you are normally allowed to get. For example, you can get Pressure.Gradient normally in CEL, but not gradient of a volume fraction for example.For example, in the case of Pressure, create the algebraic AV (called say 'mypgrad') equal to Pressure.Gradient. In this case, this will give the magnitude of the gradient If you want component gradients then put Pressure.Gradient x etc.2. Next you have to create a user CEL function, which points to a simple Fortran routine. This Fortran should contain the following:#include "cfx5ext.h"dllexport(grad2p) SUBROUTINE GRAD2P (NLOC, NRET, NARG, RET, ARGS, CRESLT, & CZ,DZ,IZ,LZ,RZ)C IMPLICIT NONECC Calculate magintude of the additional variable gradientC#include "stack_point.h"CC Result flag CHARACTER CRESLT*(*) INTEGER NLOC INTEGER NARG INTEGER NRETC REAL ARGS(NLOC,NARG) REAL RET(NLOC,NRET)C INTEGER IZ(*) CHARACTER CZ(*)*(1) DOUBLE PRECISION DZ(*) LOGICAL LZ(*) REAL RZ(*)C __stack_point__ pGradrvCC Obtain AV gradient and calculate its magnitude CALL USER_GETVAR ('mypgrad.Gradient', & CRESLT, pGradrv, CZ,DZ,IZ,LZ,RZ)C CALL SET_A_magU (RET(1,1), RZ(pGradrv), 3, NLOC)CC END3. You should then create a second algebraic/unspecified AV that is equal to this CEL function. This second AV can then be plotted in Post or used in other CEL functions and it will equal the magnitude of the second derivative of pressure.4. If you want a third derivative, you simply create a third AV and set it equal to another CEL Fortran function which gets the derivative of the second AV and so on.5. You will end up with a series of AVs and their derivatives.6. If you want the derivative of other variables (such as volume fraction) or other components (such as Velocity u.Gradient) then simply set the first AV to equal those variables instead of Pressure.Gradient as used in the example above.**** Entered By: dsclarke @ 20/02/2005 21:49 ****

 No comments yet. Be the first to add a comment!