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

UDF for mass flow

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 8, 2019, 03:27
Default UDF for mass flow
  #1
New Member
 
Västerbotten
Join Date: Sep 2016
Posts: 23
Rep Power: 9
Per_Holmgren is on a distinguished road
Hi!

I'm trying to write a udf where the mass flux of the secondary phase at the face with id=7 is used as the mass flux in the boundary where I use the udf.

DEFINE_PROFILE(inlet_mass_flow,t,i)
{
real mass_in = 0;
real mass_tot = 138.30072;

int phase_domain_index = 1; /* secondary phase index is 1 */
Domain *mixture_domain;
Domain *subdomain = DOMAIN_SUB_DOMAIN(mixture_domain,phase_domain_inde x);

Thread *mixture_thread; /* mixture-level thread pointer */
Thread *subthread = THREAD_SUB_THREAD(mixture_thread,phase_domain_inde x);

face_t f;

subthread = Lookup_Thread(subdomain, 7);

mass_in = F_FLUX(f,subthread);

mass_tot = mass_in;
mass_in = 0;

begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = mass_tot;
}
end_f_loop(f,t)
}

This lead to an immediate crash when I click ok. Can anyone give me some pointers?

Last edited by Per_Holmgren; October 8, 2019 at 05:48.
Per_Holmgren is offline   Reply With Quote

Old   October 10, 2019, 13:50
Default
  #2
New Member
 
Västerbotten
Join Date: Sep 2016
Posts: 23
Rep Power: 9
Per_Holmgren is on a distinguished road
In case anyone else comes across this post, I figure I might as well post the code I came up with to solve my problem.

In my case CaCO3 enters a reactor, converts to CaO and CO2, and CaO and CaCO3 leaves at the outlet at a set volume per second (specified as a negative velocity profile in a different udf).
Based on the mass flow of solids out, and the degree of conversion, I need to refill the reactor with an equal amount of CaCO3 to match the amount of CaCO3 and CaO that leaves at the solids outlet.


DEFINE_PROFILE(adjust_inlet, t, i)
{
face_t f;
real massflow=0;
real massflow_tot=130;
real massfraction_CaCO3=0;
Domain *d;
Domain *d_sub;
Thread *t_sub;

d = Get_Domain(1);
d_sub = DOMAIN_SUB_DOMAIN(d,1); /*Find secondary phase*/
t_sub = Lookup_Thread(d_sub, 7); /*Find thread on secondary domain with id 7*/

begin_f_loop(f,t_sub) /*Loop through all face threads on domain with id 7*/
{
massflow+=F_FLUX(f,t_sub); /* Assign mass flux at given face to variable massflow for each face thread*/
massfraction_CaCO3=F_YI(f,t_sub,2); /* Find mass fraction of specie 3(CaCO3 here)to normalize massflow later*/
}
end_f_loop(f,t_sub)

massflow = PRF_GRSUM1(massflow); /*Sums the values of the cores into a single value*/
massfraction_CaCO3 = PRF_GRSUM1(massfraction_CaCO3);
massflow_tot = (massflow*((100.09/56.08)-((100.09/56.08)-1)*massfraction_CaCO3))*2*M_PI; /*Corrects for 2D-axisymmetric profile*/
massflow=0;

begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = massflow_tot; /*Inserts flow for 2D-axisymmetric profile*/
}
end_f_loop(f,t)
}

As I use parallel processing I need to use PRF_GRSUM1 to get my eight values of for example massflow into a single value, and to be able to compile PRF_GRSUM1 you need to start fluent from the Visual Basic command prompt.

Compile Fluent UDF with Windows 10

I was stuck at the compiler issue for a pretty long time, since I didn't understand that fluent actually couldn't find the compiler. I thought my code was wrong!

Last edited by Per_Holmgren; October 30, 2019 at 05:50.
Per_Holmgren 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
UDF to measure Mass Flow Rate a.lynchy Fluent UDF and Scheme Programming 31 October 4, 2018 14:10
volume flow rate for outlet boundry condition and dfine udf for it raminostadi FLUENT 0 December 24, 2016 01:52
UDF for 3D turbulent fully developed flow howhs Fluent UDF and Scheme Programming 0 August 1, 2013 11:47
UDF for time-dependent flow borhan_sd@yahoo.com Fluent UDF and Scheme Programming 2 May 30, 2013 02:59
UDF for transient pressure inlet, mass flow check at nozzle exit and volumetric heat kokoory FLUENT 0 August 17, 2011 02:07


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