CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   user expression- value from previous time step (https://www.cfd-online.com/Forums/cfx/196165-user-expression-value-previous-time-step.html)

Vishnu_bharathi November 27, 2017 12:16

user expression- value from previous time step
 
Hello all,
I have created a user expression, net energy = inlet energy - outlet energy.

and defined this in solver monitor. I need to calculate the accumulated value of net energy over the solver run. I introduced a dummy variable D where D = net energy, so that net energy = (inlet energy - outlet energy)+D; It calculates 2 times the net energy by this expression. I believed the expression will work in step by step in the order defined like in C++ or matlab but it dose'nt work like the way. Any suggestions on how to access the previous timestep of user defined variable?

Светлана November 27, 2017 18:06

Over time? Monitor it?
 
Do you want to integrate this variable over time? I would suggest to add a monitor point for it. After the run is complete, export the monitor point plot data to another program such as GNU Octave to perform the integration.

https://www.gnu.org/software/octave/...f-One-Variable has details on the numerical integration function that I would use.

Vishnu_bharathi November 28, 2017 01:43

Quote:

Originally Posted by Светлана (Post 673068)
Do you want to integrate this variable over time? I would suggest to add a monitor point for it. After the run is complete, export the monitor point plot data to another program such as GNU Octave to perform the integration.

https://www.gnu.org/software/octave/...f-One-Variable has details on the numerical integration function that I would use.

Thankyou for your reply:)
I do not want to integrate it. I want to store an expression in the current time step and need to use in the next time step and it goes on like that.because from timestep number 1 i need to use a expression value which is calculated fron the previous time step.

ghorrocks November 28, 2017 04:04

The recommended way of doing this is with user fortran. There is a work-around using the TRANS_LOOP variables (do a search of the forum to get more information on it) but it is not supported and definitely use at your own risk.

JuPa November 28, 2017 04:30

Quote:

Originally Posted by ghorrocks (Post 673124)
The recommended way of doing this is with user fortran. There is a work-around using the TRANS_LOOP variables (do a search of the forum to get more information on it) but it is not supported and definitely use at your own risk.

I tried that approach a few times and it's unstable at the best of times.

Opaque November 28, 2017 09:17

In your example, are "inlet energy" and "outlet energy" singled valued quantities?

If so, you can benefit from the monitor Expression features which includes a few additional operations in time for the underlying expression.

Vishnu_bharathi November 28, 2017 11:55

accumated addition of an user expression
 
Quote:

Originally Posted by Opaque (Post 673175)
In your example, are "inlet energy" and "outlet energy" singled valued quantities?

If so, you can benefit from the monitor Expression features which includes a few additional operations in time for the underlying expression.

Thank you for the reply:). What do you mean by singled value quantities? I calculate inlet energy as = (mass flow@inlet* Total enthalpy@inlet) and similarly for outlet energy.

Quote:

Originally Posted by Opaque (Post 673175)
few additional operations in time for the underlying expression.

are you mentioning Monitor statistics check box under the monitor tab in Output control? If so, what is the interval option(and Statistics list) and Interval definition(and time)?

Vishnu_bharathi November 28, 2017 11:56

Quote:

Originally Posted by ghorrocks (Post 673124)
The recommended way of doing this is with user fortran. There is a work-around using the TRANS_LOOP variables (do a search of the forum to get more information on it) but it is not supported and definitely use at your own risk.

Thank you for the suggestion. I will try to read about Trans_loop and get back.


All times are GMT -4. The time now is 21:35.