CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   derivative in CEL expressions (https://www.cfd-online.com/Forums/cfx/82488-derivative-cel-expressions.html)

 alinik November 28, 2010 00:47

derivative in CEL expressions

Hi

How can I use derivative or gradient in CEL expressions?

I need to use derivative of velocity with respect to time in one of my boundary conditions.

Regards

 joey2007 November 28, 2010 15:09

Guess it requires user fortran.

 ghorrocks November 28, 2010 18:02

Read the documentation about derivative and gradient functions. But you are out of luck - CEL does not support time derivatives. You might be able to grab the variable from something else eg the time derivative of mass is a mass flow rate and MFR can be read directly. If that is not possible then you will have to use fortran.

 cfdgremlin November 30, 2010 05:03

Actually, you can get the Time Derivative of variables, but you have to employ user fortran (e.g. a User CEL Function). For example:

...
CALL USER_GETVAR('Water.Temperature.Time Derivative',CRESLT,
& pTDer,CZ,DZ,IZ,LZ,RZ)
...

 singer1812 November 30, 2010 19:03

Actuallly you can get the derivative from last time step to current time step via use of additional variables settings. If you create an additional variable of the velocity, and add the term using ccl in the ADDITIONAL VARIABLE term:

Update Loop = TRANS_LOOP

This will cause that variable to take the old value of the velocity. You can use it to create your derivative.

 ghorrocks November 30, 2010 19:25

That is a nice trick Edmind, I did not know that one. Very useful.

 alinik December 1, 2010 02:33

I didn't get it right. Still I need to use USER_FORTRAN. isn't it?

 singer1812 December 1, 2010 10:44

No need to use user Fortran. As an example, edit the additional variable in your LIBRARY with the update loop as follows:

Option = Definition
Tensor Type = SCALAR
Units = [m s^-1]
Variable Type = Specific
Update Loop = TRANS_LOOP
END

You can then use this to create your derivative.

 alinik December 1, 2010 10:54

Thank you very much edmund!

 Matjaz April 4, 2011 09:05

Hello,
could this procedure be also used to sum the calculated velocities for every time step in the past? How could this be achieved anyway?
Thank you!
Matjaz

 singer1812 April 4, 2011 09:32

Yes this can. But you need to initialize the variable with a separate artifical run.

For example if you use additional variable Q=Q+1, this will work fine except for the first iteration if Q hasn't been intialized, because CFX will complain that Q doesnt exist for the right hand side of the equation.

CFX doesn't let you initialize an algebraic AV (at least at V12.1, havent checked into V13). The workaround is to run a sinlge iteration with the AV set to zero. This result will be saved to the res file. On the next run you set up your AV with the summing expression and use the res file from the first run to initialize it

 Matjaz April 4, 2011 10:12

Thank you very much, exactly that happens in my Ansys v13.
Regards, Matjaz

 Matjaz April 5, 2011 03:59

Hello,
another question regarding my problem, could this accumulation of delta velocities from all the previous timesteps using this technique, my AV can not be used as a source velocity for the current timestep. Is it possible to pass it around?
Thank you, Matjaz

 singer1812 April 5, 2011 09:28

I am unclear on what you are asking.

 Matjaz April 5, 2011 10:04

I can not use my AV as a source for a velocity at a start of next time step. Should there be used some callback function, as areaAve, which would return a value? Even when i try to monitor the value during the run, i recive an error, because the AV isn't single valued or sth. like that.
I don't know much about these additional variables, haven't use them much.
Regards, Matjaz

 singer1812 April 5, 2011 10:24

Ohh, yes of course. Use one of the functions to evaluate it and make it single valued.

 Matjaz April 6, 2011 05:18

Hello, i still need some more guidelines for this procedure;
I did edit my AV in cmd editor with trans_loop, then checked name of this AV in both of my domains, where i also wrote expression for AV: velocity = velocity + delta_velocity. Then i created new expression, using areaAve of AV on a 2d locator in my moving domain, and created monitor point of that expression.
Unfortunately simulation runs, but my velocity doesn't sum all the previous ones, or it does it much too slow. Did I miss something here?
Thank you, Matjaz

 singer1812 April 6, 2011 09:27

Where are you getting your delta_velocity from?

 Matjaz April 6, 2011 09:32

I get it from user fortran routine, it works fine, just need to accumulate all the past values for current time stem; my trouble is, that i can not save it to a file, but also don't want to bother with mms, which i'm also not familiar with.

 singer1812 April 6, 2011 09:35

You are getting it from a fortran routine that you are calling while CFX is running (User Fortran?)

Or are you getting it from a pre-ran fortran routine, and delta_velocity is already set for the CFX run.

All times are GMT -4. The time now is 23:41.