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

Questions about the DEFINE_SOURCE

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 16, 2020, 04:23
Default Questions about the DEFINE_SOURCE
  #1
New Member
 
Chris Hunter
Join Date: May 2020
Posts: 17
Rep Power: 5
mcc007 is on a distinguished road
Hello everybody,

I'd like to use fluent to solve Poisson equation. The Poisson equation is attached. But the simulation result is much higher than expected. I am not sure if I need to add some other terms (e.g., velocity term, transient term). in the equation. Or my code is wrong. Here is part of my code:

DEFINE_SOURCE(potential,c,t,dS,eqn)
{
real source;
source=F*(-C_UDSI(c,t,2)+C_UDSI(c,t,3));
dS[eqn]=0.0;
return source;
}

Thanks a lot
Attached Images
File Type: jpg 11.JPG (25.7 KB, 38 views)
mcc007 is offline   Reply With Quote

Old   June 16, 2020, 07:39
Default Source
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Why do you have more than one UDS? And what are c, z, and F? Source should only have the right hand part of the equation.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 16, 2020, 15:36
Default
  #3
New Member
 
Chris Hunter
Join Date: May 2020
Posts: 17
Rep Power: 5
mcc007 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Why do you have more than one UDS? And what are c, z, and F? Source should only have the right hand part of the equation.
I have defined 6 UDS. In the equation, c = charge of ions, z = ion concentrations, and F = Faraday constant. The reseason why I have two UDS in the RHS is because I need to sum all ions in the solution. And there are two different ions in the solution. That's why I have two UDS in the RHS.

Another question is that the LHS is the second derivative of phi. I checked the UDF manual. And I found all of the equation on the LHS is the first derivative. I am not sure if I need to ingrate the LHS to make it first derivative of phi.

Can you help me with this?

Thanks a lot

Last edited by mcc007; June 16, 2020 at 23:59.
mcc007 is offline   Reply With Quote

Old   June 17, 2020, 05:19
Default Uds
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Do you have six different scalar equations to be solved? If yes, then six UDS are required. If you only have one Poisson equation with one variable, then you only need one UDS. Poisson equation always has Laplace operator, i.e., second derivative. It corresponds to diffusion term. So, no convection term needs to be included. \varepsilon is the diffusion coefficient for UDS. And the right hand side is the source term.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 18, 2020, 02:34
Default
  #5
New Member
 
Chris Hunter
Join Date: May 2020
Posts: 17
Rep Power: 5
mcc007 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Do you have six different scalar equations to be solved? If yes, then six UDS are required. If you only have one Poisson equation with one variable, then you only need one UDS. Poisson equation always has Laplace operator, i.e., second derivative. It corresponds to diffusion term. So, no convection term needs to be included. \varepsilon is the diffusion coefficient for UDS. And the right hand side is the source term.
Yes I have six UDS. But they are used for different purposes. In the Poisson equation, only two UDSs are being used. In the code that I posted, I am not sure if I need to change something or not. What do you think?
mcc007 is offline   Reply With Quote

Old   June 18, 2020, 04:10
Default Source
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
DEFINE_SOURCE is used to provide source term. The RHS of the equation, i.e., \Sigma_ic_iz_iF, is the source and the UDF should return this value. But the UDF you have is not returning this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 18, 2020, 20:08
Default
  #7
New Member
 
Chris Hunter
Join Date: May 2020
Posts: 17
Rep Power: 5
mcc007 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
DEFINE_SOURCE is used to provide source term. The RHS of the equation, i.e., \Sigma_ic_iz_iF, is the source and the UDF should return this value. But the UDF you have is not returning this.
Thanks for your reply. In my code, the source term is Source = F*(-C_UDSI(c,t,2)+C_UDSI(c,t,3)). When you say the UDF doesn't return the value, what do you mean? Can you be more specific? Because I followed the UDF manual, the summation of the RHS is F*(-C_UDSI(c,t,2)+C_UDSI(c,t,3)).

Thanks a lot
mcc007 is offline   Reply With Quote

Old   June 19, 2020, 00:09
Default
  #8
New Member
 
bestucan's Avatar
 
Tu Can
Join Date: Jul 2017
Location: China
Posts: 16
Rep Power: 8
bestucan is on a distinguished road
Is't your source should be something like this ?

Code:
for(j = 0; j < i; j++) {
     source += f * c_j * z_j
 }
bestucan is offline   Reply With Quote

Old   June 19, 2020, 00:30
Default
  #9
New Member
 
Chris Hunter
Join Date: May 2020
Posts: 17
Rep Power: 5
mcc007 is on a distinguished road
Quote:
Originally Posted by bestucan View Post
Is't your source should be something like this ?

Code:
for(j = 0; j < i; j++) {
     source += f * c_j * z_j
 }
No, I don't think so.
mcc007 is offline   Reply With Quote

Old   June 19, 2020, 06:12
Default Source
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Quote:
Originally Posted by mcc007 View Post
Thanks for your reply. In my code, the source term is Source = F*(-C_UDSI(c,t,2)+C_UDSI(c,t,3)). When you say the UDF doesn't return the value, what do you mean? Can you be more specific? Because I followed the UDF manual, the summation of the RHS is F*(-C_UDSI(c,t,2)+C_UDSI(c,t,3)).

Thanks a lot
The value returned by your UDF is a product of F with difference of two scalars. Assuming these two scalars represent c and z in the RHS of the Poisson equation, then both scalars must be multiplied and not subtracted. The source term also depends on the summation parameter, i. If i implies discrete locations, then summation is not required in the UDF, however, if i represents some other parameter, such as ions, then you have to sum over all ions in each cell. Furthermore, UDF manual talks about logic and implementation; it does not mention anything about specific equations. And in case c and z are functions of potential, then dS[eqn] cannot be 0.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm 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
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 05:29
[ICEM] Complex geometry mesh general questions Jack B ANSYS Meshing & Geometry 0 August 14, 2019 13:44
General questions about how to mesh and build up my case ThunderstruckGER OpenFOAM 5 September 23, 2018 18:33
possible interview questions atturh Main CFD Forum 1 February 21, 2012 08:53
NACA0012 Validation Case Questions ozzythewise Main CFD Forum 3 August 3, 2010 14:39


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