CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Gradient of a variable in CFX (https://www.cfd-online.com/Forums/cfx/84823-gradient-variable-cfx.html)

shahpar73 February 9, 2011 09:31

Gradient of a variable in CFX
 
Hi
Is it possible in CFX to calculate the Gradient of "My defined Variable" with respect to temperature? i,e

My defined Variable.Gradient T

It is not working for me saying "T" is not recognized. When I replace "T" with "X" then it is OK.

ghorrocks February 9, 2011 18:36

You cannot do it directly. You can only do gradients like that WRT space. But dV/dT=dV/dX * 1/(dT/dX) so you should be able to calculate it from the spatial gradients of your variable and temperature.

shahpar73 February 9, 2011 23:12

Thanks Glenn. Your response always helped me.
I tried your suggestion and got the following error message. Any comments Please...

| PROBLEM ENCOUNTERED WHEN EXECUTING CFX EXPRESSION LANGUAGE |
| |
| The CFX expression language was evaluating: |
| Additional Variable Value |
| |
| The problem was: |
| DIVIDE-BY-ZERO |
| |
| FURTHER INFORMATION |
| |
| The problem was encountered in executing the expression for: |
| GradSurfTension |
| The complete expression is: |
| Surface Tension.Gradient X*(1/T.Gradient X) |
| The error occurs on sub-expression: |
| 1/T.Gradient X

Lance February 10, 2011 01:56

Your expression T.Gradient X is zero... due to uniform initial conditions maybe?

ghorrocks February 10, 2011 04:15

Um, why are you doing this? If you have a surface tension set as a function of temperature you already know the gradient of the surface tension WRT to temperature, so why get CFX to calculate it?

shahpar73 February 10, 2011 05:07

Hi Glenn,
If you look at the expression, Surface Tension is NOT set as a gradient of Temperature rather set as "X" and I want to calculate the Surface Tension as a Gradient of Temperature in a way as you mentioned in your previous reply.

ghorrocks February 10, 2011 05:59

OK, no problem.

shahpar73 February 10, 2011 08:29

Just noticed in Cfx Post that "T.Gradient X" is zero at t=0, and then nonzero. Any solution then? How to skip t=0 in transient analysis?

singer1812 February 10, 2011 15:36

Perhaps add a non zero value to the T.Gradient.X term and a step function. Like

(T.Gradient X+0.0001 [K m^-1]*step(.00001-t*1[s^-1])

for a quick and dirty solution. Make sure you change .00001 to something that suits your time step.

ghorrocks February 10, 2011 17:00

Back to my previous post.... I am still puzzled by what you are trying to do. Surface tension is usually constant (so dS/dT=0 where S is surface tension and T is temperature) so if it is not constant you must have set it to be a function of something. So why not simply work out the derivative of that function WRT temperature?

Can you explain what function you have set surface tension to?

shahpar73 February 10, 2011 22:03

I want to calculate the Marangoni Force such that MF=dS/dT*dT/dX [N m^-2] (where S is in N/m) and apply it as a BC.
So in my case S is not constant but a function of temperature and temperature is a function of "X". In CFX, as you mentioned earlier, dS/dT can not be calculated directly and that is why all this stuff come.

shahpar73 February 10, 2011 22:22

Problem solved. Thanks to all who replied to this post.
I followed Singer's instructions by adding a small value of 1e-10 [K m^-1] to T.Gradient X and it worked.


All times are GMT -4. The time now is 18:37.