CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

How to define a static aditional variable in CFX

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By ghorrocks
  • 1 Post By ghorrocks
  • 1 Post By ghorrocks

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 21, 2018, 10:02
Default Recursive variable: how to define a static additional variable in CFX
  #1
Member
 
Join Date: Jun 2017
Posts: 40
Rep Power: 8
cardioCFD is on a distinguished road
Hi,

I am trying to define a static additional variable in CFX which only varies with time so the transport equation for this variable,B, will be like this:

dB/dt = some function.

So there is no advection or diffusion for this variable, and this variable will only be updated at the end of each time step, a trans_loop variable.

Is there a way to do that in CFX?

Thanks a lot in advance.

Last edited by cardioCFD; January 21, 2018 at 11:34.
cardioCFD is offline   Reply With Quote

Old   January 21, 2018, 10:14
Default
  #2
Member
 
Join Date: Jun 2017
Posts: 40
Rep Power: 8
cardioCFD is on a distinguished road
I have tried to do this using a trans_loop algebraic equation additional variable BOld, for previous time step, and another additional variable called B. B will be calculated by this CEL,

B = BOld + (some function) * Time Step Size.

And

BOld = B

But CFX gives an error that some variable depends on itself and stop.
cardioCFD is offline   Reply With Quote

Old   January 21, 2018, 17:03
Default
  #3
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
How about:

Define the variable as a diffusive additional variable. Set the diffusion to zero (or at least a very small number) so that stops diffusion. Then use a source term to do the dB/dt function.
cardioCFD likes this.
ghorrocks is offline   Reply With Quote

Old   January 21, 2018, 17:27
Default
  #4
Member
 
Join Date: Jun 2017
Posts: 40
Rep Power: 8
cardioCFD is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
How about:

Define the variable as a diffusive additional variable. Set the diffusion to zero (or at least a very small number) so that stops diffusion. Then use a source term to do the dB/dt function.
Thanks a lot Glenn. Thats exactly how I have tried and am now waiting to see the results, will give an update on that.

But, in general, I do not have a positive experience with using source terms in CFX, usually have problems with convergences, and the results show wiggles overshoots and undershoots, although I use sourceB/max(B,1e-16) as source cofficient.

But I gave it a try, will update on that.
cardioCFD is offline   Reply With Quote

Old   January 21, 2018, 17:36
Default
  #5
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
Have you read section 1.3.2.1.1 in the documentation on Source Coefficients? It explains that the source term coefficient should be set to dS/dB where S is your source term and B is the current local variable value. You seem to be applying S/B.
ghorrocks is offline   Reply With Quote

Old   January 21, 2018, 18:43
Default
  #6
Member
 
Join Date: Jun 2017
Posts: 40
Rep Power: 8
cardioCFD is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
Have you read section 1.3.2.1.1 in the documentation on Source Coefficients? It explains that the source term coefficient should be set to dS/dB where S is your source term and B is the current local variable value. You seem to be applying S/B.
Thanks for reminding me of that Glenn, yes I have read that. But in this problem my source is not depending on B,
S= k*v1*v2*v3, where v1 v2 and v3 are three other variables and k is a constant. v3 is concentration of a specie in my reacting mixture, and I have a transport equation for that. B appears in the source term of v3 transport equation, so the relation between v3 and B is quite complete and I could not calculate the derivate dS/dB, that why I just used S/B. Thanks.

Any further comment is highly appreciated, Glenn.
cardioCFD is offline   Reply With Quote

Old   January 21, 2018, 18:54
Default
  #7
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
S/B is completely wrong so I would not use that. If you don't know the exact gradient then estimate it. Choose typical values of any variables you don't know of v1, v2 and v3 and work out the gradient based on the estimates. An estimated gradient is usually close enough to allow convergence.

Even better, set the source term coefficient to a CEL expression of the gradient of the complex function. This requires analytically working out the derivative which can be challenging but is the best approach if it can be done.
cardioCFD likes this.
ghorrocks is offline   Reply With Quote

Old   January 22, 2018, 04:17
Default
  #8
Member
 
Join Date: Jun 2017
Posts: 40
Rep Power: 8
cardioCFD is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
S/B is completely wrong so I would not use that. If you don't know the exact gradient then estimate it. Choose typical values of any variables you don't know of v1, v2 and v3 and work out the gradient based on the estimates. An estimated gradient is usually close enough to allow convergence.

Even better, set the source term coefficient to a CEL expression of the gradient of the complex function. This requires analytically working out the derivative which can be challenging but is the best approach if it can be done.
Hi Glenn,

Thank you so much for the advice. Let me check the way I modified the source coefficient with you.

B and A are two chemical species.

A source, rate of production of A: S_A = dA/dt = f(A,B,some other variables)
B source, rate of production of B: S_B = dB/dt = k2*A

I want to calculate the B source coefficient:

source coeff B = dS_B/dB = k2*dA/dB

dA/dB means change in concentration of A divided by change in concentration of B, in other words dA/dB = (dA/dt) / (dB/dt).

Then dA/dB = S_A/S_B and the source coefficient would be k2*S_A/S_B

Is that right? Thanks.
cardioCFD is offline   Reply With Quote

Old   January 22, 2018, 04:58
Default
  #9
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
That looks OK.
cardioCFD likes this.
ghorrocks is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recursive output of Foam::word in gdb print command chengdi OpenFOAM Programming & Development 1 July 19, 2017 20:19
An odd ERROR mdakbari Fluent UDF and Scheme Programming 7 April 4, 2016 04:30
Robin B.C. Yu FLUENT 3 May 27, 2012 04:19
UDF carbon conversion papteo Fluent UDF and Scheme Programming 1 August 18, 2011 07:32
UDF FOR UNSTEADY TIME STEP mayur FLUENT 3 August 9, 2006 10:19


All times are GMT -4. The time now is 08:14.