|
[Sponsors] |
How to define a static aditional variable in CFX |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
Member
Join Date: Jun 2017
Posts: 40
Rep Power: 9 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Member
Join Date: Jun 2017
Posts: 40
Rep Power: 9 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,781
Rep Power: 143 ![]() ![]() ![]() ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#4 | |
Member
Join Date: Jun 2017
Posts: 40
Rep Power: 9 ![]() |
Quote:
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. |
||
![]() |
![]() |
![]() |
![]() |
#5 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,781
Rep Power: 143 ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
![]() |
![]() |
![]() |
#6 | |
Member
Join Date: Jun 2017
Posts: 40
Rep Power: 9 ![]() |
Quote:
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. |
||
![]() |
![]() |
![]() |
![]() |
#7 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,781
Rep Power: 143 ![]() ![]() ![]() ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#8 | |
Member
Join Date: Jun 2017
Posts: 40
Rep Power: 9 ![]() |
Quote:
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. |
||
![]() |
![]() |
![]() |
![]() |
#9 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,781
Rep Power: 143 ![]() ![]() ![]() ![]() |
That looks OK.
|
|
![]() |
![]() |
![]() |
|
|
![]() |
||||
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 |