TAGGED: 2D, ansys-student, cfd, fluent, udf-fluent
-
-
October 14, 2021 at 7:01 am
Alnado1
SubscriberHey all,
I'm new to CFD and I'm trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C - .1x, or dCa/dx = -kCa). This is my first time trying to write a UDF.
I think I have the right idea, but I have a feeling there's a more efficient way to do it. Do you mind looking at it and giving me some insight/critiques? This is for the examples dCa/dx = -kCa. I tried defining the rate in terms of the derivative of the concentration of species A as a function of time and velocity. You can ignore the real x[ND_ND].
Two Questions: 1) Are we able to use the DEFINE_VR_RATE macro to define the fraction of a species, or can we only apply it to define reaction rates? 2) Would I use the begin_f_loop in this case? The reactor is supposed to be 2D.
DEFINE_VR_RATE(pfr_react_rate,c,t,r,w,yi,rate,rr_t)
{
real x[ND_ND]; /* x[ND_ND] is a vector that holds values of face in 1, 2, or 3 dimensions */
float k = 1; /* reaction rate constant */
float Cao = .5; /* initial concentration of A */
real Ca = ; /* real value of Ca concentration */
real Y_A; /* mass fraction of calculated component */
weight_A = w[0]; /* assigns the molar mass of A to the molar mass of the first species */
real time = CURRENT_TIME; /* variable assigned to the present simulation time */
/* is this the right type of loop to use? */
begin_f_loop(f,t)
{
Y_A = yi[0]; /* Assigns the mass fraction of species to the first member of mass fraction array */
Ca = Cai*exp(-k * NODE_X(node)); /* Change in concentration as a function of x position */
Y_A = weight_A*Ca /C_R(c,t); /* This is probably unnecessary */
rate = -k*C_U(c,t)*Ca*exp(-k * C_U(c,t) * time)); /* This is supposed to calculate the rate as a function of velocity and time */
}
end_loop(f,t,);
}
Thanks!
October 14, 2021 at 9:15 pmSurya Deb
Ansys EmployeeHello,
If I understand the problem correctly, then you should not modify the concentrations using UDF. Are you trying to initialize the domain with an initial concentration profile?
Your mass fractions and subsequent concentration should be coming naturally from the flow/reaction solution.
Regards SD
October 14, 2021 at 11:29 pmAlnado1
SubscriberThanks for replying SD. I do not know exactly how to communicate the objective in Fluent terms, but I'm basically just trying to change the concentration of a component as a function of its position. This doesn't sound like a profile to me, since to my understanding profiles refer to the concentration across the area, not along the reactor's length. My professor instructed us to use a UDF, but it does seem weird to me since the reaction can be adjusted in fluent itself.
Alnado
Viewing 2 reply threads- The topic ‘UDF for plug flow reactor, change in concentration with change in position’ is closed to new replies.
Ansys Innovation SpaceTrending discussionsTop Contributors-
3492
-
1057
-
1051
-
966
-
942
Top Rated Tags© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-