|
[Sponsors] |
February 21, 2014, 05:02 |
Non-linear equation system (DEFINE_source)
|
#1 |
New Member
Alexey
Join Date: Jan 2014
Posts: 18
Rep Power: 12 |
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. |
|
February 24, 2014, 11:05 |
|
#2 |
New Member
Alexey
Join Date: Jan 2014
Posts: 18
Rep Power: 12 |
Pls, any ideas?
|
|
February 11, 2015, 07:39 |
|
#3 |
Senior Member
B_Kia
Join Date: May 2014
Location: Ir
Posts: 123
Rep Power: 12 |
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 |
|
February 11, 2015, 09:16 |
|
#4 |
Senior Member
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0 |
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 @ 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. |
|
February 11, 2015, 17:11 |
|
#5 |
Senior Member
B_Kia
Join Date: May 2014
Location: Ir
Posts: 123
Rep Power: 12 |
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
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
about convergence of a linear system | harbinyg | Main CFD Forum | 2 | June 22, 2011 07:22 |
CFX11 + Fortran compiler ? | Mohan | CFX | 20 | March 30, 2011 19:56 |
Q: how to solve linear equation | dut_thinker | FLOW-3D | 2 | September 2, 2010 23:17 |
New linear system solvers | chegdan | OpenFOAM Running, Solving & CFD | 11 | April 30, 2010 11:22 |
solver for linear system with large sparse matrix | Yangang Bao | Main CFD Forum | 1 | October 25, 1999 05:22 |