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

UDF with differential equations

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By `e`

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 9, 2018, 13:43
Question UDF with differential equations
  #1
New Member
 
Edwin P
Join Date: Jun 2018
Posts: 13
Rep Power: 8
intied is on a distinguished road
Hi.
I am computing a source term of the energy equation in ANSYS Fluent.
How to add a system of differential equations in a UDF?
Each differential equation depends on time and temperature.
In particular, I want to solve a set of differential equations based on the Arrhenious equation:
dx1/dt=k1*exp(k2/(R*T)),
dx2/dt=k3*exp(k4/R*T),

where k1,k2,k3,k4 and R are constants. Thus, my source term is (dx1/dt+dx2/dt)*k5.

I know that I could use DEFINE_SOURCE(name,c,t,dS,eqn).
Any suggestion?

Regards
intied is offline   Reply With Quote

Old   June 13, 2018, 22:05
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Using the DEFINE_SOURCE macro is correct, and the temperature of each cell can be retrieved with C_T(c,t). See below for an example, and check the UDF guide for details. Was the second equation intentionally of a different form to the first, or was it supposed to follow the Arrhenius equation as well?

Code:
#define k1 1.0
#define k2 2.0
#define k3 3.0
#define k4 4.0
#define k5 5.0
#define R  6.0

DEFINE_SOURCE(arrhenious_source,c,t,dS,eqn)
{
	real term1 = k1*exp(k2/(R*C_T(c,t)));
	real term2 = k3*exp(k4/(R*C_T(c,t)));

	real source = (term1+term2)*k5;
	dS[eqn] = 0.0;

	return source;
}
`e` is offline   Reply With Quote

Old   June 14, 2018, 09:53
Default UDF with differential equations (Edited)
  #3
New Member
 
Edwin P
Join Date: Jun 2018
Posts: 13
Rep Power: 8
intied is on a distinguished road
Sorry, I forgot one term in each equation. The system of differential equations are as follow:


dx1/dt=x1*k1*exp(k2/(R*T)),
dx2/dt=x2*k3*exp(k4/R*T),


The source term is (dx1/dt+dx2/dt)*k5.


As you can see, the dependt variables are x1 and x2.



Thanks for your help
intied is offline   Reply With Quote

Old   June 14, 2018, 19:42
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
What are x1 and x2? Are they the spatial coordinates x and y? The centroid of cell volumes can be retrieved with the C_CENTROID macro.
`e` is offline   Reply With Quote

Old   June 14, 2018, 19:57
Default
  #5
New Member
 
Edwin P
Join Date: Jun 2018
Posts: 13
Rep Power: 8
intied is on a distinguished road
x1 and x2 are dimensionless concentrations (from 0 to 1). These variables represent chemical reactions. I am computing the transient increase of temperature due to these reactions.
intied is offline   Reply With Quote

Old   June 14, 2018, 20:05
Default
  #6
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
How are you modelling the concentrations? If you are using the species transport model in Fluent then the species mass fraction can be retrieved with the C_YI macro.
mingllove likes this.
`e` is offline   Reply With Quote

Old   June 14, 2018, 20:22
Default
  #7
New Member
 
Edwin P
Join Date: Jun 2018
Posts: 13
Rep Power: 8
intied is on a distinguished road
I am not modelling the concentrations because of I need to know only the temperature. For this reason, I had been thinking to solve the system of equations and get automatically the temperature.
Thanks for your suggestion about using the species transport model.
intied is offline   Reply With Quote

Old   June 14, 2018, 20:34
Default
  #8
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Sounds like the concentrations are an important and coupled component of your model. For perspective: without modelling the concentrations and trying to calculate the temperature would be similar to finding the pressure distribution on an aerofoil without solving the momentum equations.

The user-defined scalar transport equation could be used instead of the in-built species model (both methods should work, the former has more flexibility but the latter would be easier to implement).
`e` is offline   Reply With Quote

Old   June 15, 2018, 18:13
Default
  #9
New Member
 
Paul Lee
Join Date: Jun 2018
Location: Vancouver
Posts: 14
Rep Power: 8
paoching is on a distinguished road
Can I use the built-in species transport model for ionic movement in aqueous electrolyte? From the density term it seems to be built for gases reaction of an IC engine.
paoching is offline   Reply With Quote

Old   June 15, 2018, 19:25
Default
  #10
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by paoching View Post
Can I use the built-in species transport model for ionic movement in aqueous electrolyte? From the density term it seems to be built for gases reaction of an IC engine.
What equations are you trying to solve and do these equations have a similar form to the species transport model? Otherwise you could use the user-defined scalar transport equations for more flexibility.
`e` is offline   Reply With Quote

Old   June 15, 2018, 19:49
Default
  #11
New Member
 
Paul Lee
Join Date: Jun 2018
Location: Vancouver
Posts: 14
Rep Power: 8
paoching is on a distinguished road
I'm solving charged ionic movement in a galvanic corrosion system using the nernst planck equation. I think that is what species transport model use as well. what prompt me to wonder if species transport model is suitable for aqueous system is the density property of the mixture material. I've been using the "volume-weighted-mixing law" instead of the default "incompressible-ideal-gas" hopping that the solver will pick the "water-liquid" density that I entered as "selected species". I would have preferred if I could just entered a constant for the electrolyte density, but that is not an option. Perhaps I need to do this through UDF.
Have you used the species transport solver on aqueous system? How did that worked out?
paoching is offline   Reply With Quote

Old   June 15, 2018, 20:21
Default
  #12
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by paoching View Post
I would have preferred if I could just entered a constant for the electrolyte density, but that is not an option. Perhaps I need to do this through UDF.
Is there a hook available for a UDF to handle the density there? It would probably be easier and clearer to use a UDF instead of hoping that the correct relation is picked up from the material properties.

Quote:
Originally Posted by paoching View Post
Have you used the species transport solver on aqueous system?
No.
`e` is offline   Reply With Quote

Old   June 16, 2018, 06:45
Default
  #13
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi Paoching,

I have used species transport and reactions for aqueous systems, and there are no special problems. If you want a constant density, then define the same density for all the species, and then a weighted average in the mixture will always give the same answer.

With the species model, your reactions have standard Arrhenius rate laws, so they are easy to set up. You may not need UDFs at all -- and this will probably have benefits in terms of stability etc.

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   June 16, 2018, 13:12
Default
  #14
New Member
 
Paul Lee
Join Date: Jun 2018
Location: Vancouver
Posts: 14
Rep Power: 8
paoching is on a distinguished road
Thank you Ed
paoching is offline   Reply With Quote

Reply

Tags
differential equation, fluent, source terms, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
How to extract Differential Equations Matrix Coeff srodrb OpenFOAM Programming & Development 7 August 13, 2022 04:51
udf for one dimensional linear motion based on force maccheese Fluent UDF and Scheme Programming 2 September 1, 2019 02:18
Save output of udf in another udf! JuanJoMex FLUENT 0 February 8, 2018 12:43
UDF Compilation Error - Loading Library - COMMON Problem! Help! robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 00:53
UDF in Differential form Chin Fook Fluent UDF and Scheme Programming 10 July 27, 2012 13:48


All times are GMT -4. The time now is 20:38.