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

Non-linear equation system (DEFINE_source)

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

Like Tree1Likes
  • 1 Post By CeesH

Reply
 
LinkBack Thread Tools Display Modes
Old   February 21, 2014, 05:02
Default Non-linear equation system (DEFINE_source)
  #1
New Member
 
Alexey
Join Date: Jan 2014
Posts: 18
Rep Power: 4
Laexzzz is on a distinguished road
Hello!

I model system with 4 species.

I want to define source terms with UDF.

But my sources are described by the system of non-linear equation

S(1) = -2*k1*[1]
S(2) = -k2*[2][3] - k2*[2][4]
S(3) = +2*k1*[1]-k2*[2][3]
S(4) = -k3*[4][4] - k2*[2][4]

[1] - molar concentration of species 1 at the moment

So, sources affect each other.

I create UDF, but obviously it does not work correct

#include "udf.h"
#define kd0 1.58e+15
#define ki0 4.27e+7
#define kp0 4.27e+7
#define kt0 1.255e+9


DEFINE_SOURCE(InicSource,c,t,dS,eqn)
{
real InicSource;
real Dens = C_R(c,t);
real temp = C_T(c,t);
real kd = kd0*exp(-15501/temp);
real InicMC;

InicMC = (C_YI(c,t,1)*Dens) / 164;
InicSource = -kd*InicMC*164;
dS[eqn] = 0;
return InicSource;
}

DEFINE_SOURCE(styrene_source,c,t,dS,eqn)
{
real StyreneMC;
real Radicals1MC;
real LivradMC;
real Styrene_sourceMC;
real temp = C_T(c,t);
real Dens = C_R(c,t);
real styrene_source;
real kp = kp0*exp(-3910/temp);


StyreneMC = (C_YI(c,t,0)*Dens) / 104;
Radicals1MC =(C_YI(c,t,2)*Dens) / 82;
LivradMC = (C_YI(c,t,3)*Dens) / 100000;
Styrene_sourceMC = -kp*StyreneMC*Radicals1MC-kp*StyreneMC*LivradMC;
styrene_source = Styrene_sourceMC*104;
dS[eqn] = 0;
return styrene_source;
}

DEFINE_SOURCE(radicals1_source,c,t,dS,eqn)
{
real radicals1_source;
real temp = C_T(c,t);
real Dens = C_R(c,t);
real kd = kd0*exp(-15501/temp);
real ki = ki0*exp(-3910/temp);
real kp = kp0*exp(-3910/temp);
real StyreneMC1;
real InicMC1;
real radicals1MC1;
real radicals1MC_source;

StyreneMC1 = (C_YI(c,t,0)*Dens) / 104.12;
InicMC1 = (C_YI(c,t,1)*Dens) / 164;
radicals1MC1 = (C_YI(c,t,2)*Dens)/82;
radicals1MC_source = 2.0* kd*InicMC1-kp*radicals1MC1*StyreneMC1;
radicals1_source = radicals1MC_source*82;
dS[eqn] = 0;
return radicals1_source;
}

DEFINE_SOURCE(Livrad_source,c,t,dS,eqn)
{

real Livrad_source;
real temp = C_T(c,t);
real Dens = C_R(c,t);
real kd = kd0*exp(-15501/temp);
real ki = ki0*exp(-3910/temp);
real kp = kp0*exp(-3910/temp);
real kt = kt0*exp(-844/temp);
real StyreneMC2;
real radicals1MC2;
real LivradMC2;
real LivradMC_source;

StyreneMC2 = (C_YI(c,t,0)*Dens) / 104.12;
LivradMC2 = (C_YI(c,t,3)*Dens) / 100000;
LivradMC_source = -kt*LivradMC2*LivradMC2-kp*StyreneMC2*LivradMC2;
Livrad_source = LivradMC_source*100000;
dS[eqn] = 0;
return Livrad_source;
}

Sources can not be linearized

So, any ideas?

I want to solve that system and then set as sources S1, 2,3,4 values ​​obtained by the simultaneous solution of all equations

Last edited by Laexzzz; February 21, 2014 at 06:21.
Laexzzz is offline   Reply With Quote

Old   February 24, 2014, 11:05
Default
  #2
New Member
 
Alexey
Join Date: Jan 2014
Posts: 18
Rep Power: 4
Laexzzz is on a distinguished road
Pls, any ideas?
Laexzzz is offline   Reply With Quote

Old   February 11, 2015, 07:39
Default
  #3
Senior Member
 
B_Kia
Join Date: May 2014
Location: Ir
Posts: 118
Rep Power: 4
HyperNova is on a distinguished road
hi , please forgive because i don have any idea , i just have a question,
what does dS[eqn] = 0; do in code ?
i want to introduce a source to epsilon equation for my model.
thank you very much
HyperNova is offline   Reply With Quote

Old   February 11, 2015, 09:16
Default
  #4
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 440
Rep Power: 9
CeesH is on a distinguished road
Hi

@ Hypernova; that's a source term linearization function which you can add for stability of the solver. Basically, the source term is outputted as
Code:
S = A + B*X
where A is the constant part which you typically calculate as a source, and B = dS/dX. The FLUENT UDF manual gives an example where S is a function of Vx, so you can add the derivative dS/dVx.

@ Laexzz; It seems to me there is no choice but to linearize your equation set. This happens automatically during iteration, for example S(2) is calculated while holding C(2),(3),(4) constant (alternatively, you can link the derivative as outlined above). Of course, your set of equations is still coupled and eventually the result should converge.

I don't think the problem with your set of equations is the linearization, but I'm afraid it's a stiff set of equations. The time constant of the first equation is much higher than all the other ones, and I am guessing this causes problems. What happens if you run your model for a simple configuration (so excluding any flow) in say, MATLAB? Do you get good, smooth results? Does ODE45 interation work at all or do you need a special stiff routine.

FLUENT should have some options to deal with stiff chemistry (I have no experience with that however), alternatively you may want to use a quasi-equilibrium assumption or so to deal with the fast reaction step.
HyperNova likes this.
CeesH is offline   Reply With Quote

Old   February 11, 2015, 17:11
Default
  #5
Senior Member
 
B_Kia
Join Date: May 2014
Location: Ir
Posts: 118
Rep Power: 4
HyperNova is on a distinguished road
thank you very much for spending time to explain, i don know any thing on species topic otherwise i help you , but in near future i have to learn because i need it in my work , thank you very much
HyperNova is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
about convergence of a linear system harbinyg Main CFD Forum 2 June 22, 2011 06:22
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 18:56
Q: how to solve linear equation dut_thinker FLOW-3D 2 September 2, 2010 22:17
New linear system solvers chegdan OpenFOAM Running, Solving & CFD 11 April 30, 2010 10:22
solver for linear system with large sparse matrix Yangang Bao Main CFD Forum 1 October 25, 1999 04:22


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