CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   how to calculate derivatives (

Senthil March 21, 2002 23:31

how to calculate derivatives

I need to get second derivative and fourth derivative of velocity and temperature. Are these quantities available directly from fluent macros. If not, then I have to use finite difference formula to calculate these derivatives. My problem is that I dont know in which order the cell variables are stored. How do I calculate these derivatives then?.

Thank you,


Greg Perkins March 22, 2002 07:27

Re: how to calculate derivatives
You'll probably have to write udfs for this...

First derivatives are available as macros, eg. C_U_G(c,t)[d] gives the derivative of the U velocity in the dth co-ordinate direction.

You can apply these successively to obtain higher copying into a UDS.

However, I've never been too clear on exactly how these are calculated. In fact I found that when I wanted to calculate the face flux for diffusion, ie q = kdthi/dx using the above macros gave incorrect results and I ended up re-applying an upwind scheme to calculate the correct flux.

I think they are defined at the centre of the cell, which might be ok for your application, but you might need to be careful if accuracy is required...


Senthil March 22, 2002 23:44

Re: how to calculate derivatives
Hi Greg,


I assume UDS mean, user defined scalar. When I went through the fluent manual, I found out that if I define a UDS, it always try to solve a transport equation for that scalar. How can I make it calculate derivative. Could you tell me how you calculated dthi/dx. May be I could write udf by the same algorithm to calcualte higher derivatives.

Thank you Senthil

Greg Perkins March 23, 2002 00:32

Re: how to calculate derivatives
You can switch off solving a UDS in the solve/control panel.

I used a simple scheme (first-order) based on neighbouring cell data. You will need to loop over cell faces to get the neighbouring cells to calculate the derivative in this manner...


keith March 25, 2002 11:53

Re: how to calculate derivatives
Greg, I was wondering if you've calculated higher order derivatives (2nd and above) in the manner you describe. I used a similar approach to calculate 2nd derivatives of the velocity field, but I found the result to be very "noisy", especially on unstructured grids. With smoothing, I can get something usable, but still not great. Have you run into this and do you have any suggestions for improving it?



Greg Perkins March 26, 2002 21:41

Re: how to calculate derivatives
I found even the C_UDSI_G etc derivatives weren't very good when compared to derivatives calculated at the faces using the approrpiate discretization scheme. I think this is partly because I'm not completely sure how these macros are defined. That's why I wasn't too keen on using them. The udf manual doesn't mention the definition, does it?

I haven't tried high-order schemes. I think increasing noise is common when taking derivatives - but I'm not up with what additional smoothing, adjustments etc are best to make. There's probably some literature on this, or see if Fluent can help....


All times are GMT -4. The time now is 05:16.