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

Giving variable mass flow rates to components in a mixture for tarnsient simulation

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 10, 2025, 02:06
Default Giving variable mass flow rates to components in a mixture for tarnsient simulation
  #1
New Member
 
cfd_enthusiast
Join Date: Jul 2024
Posts: 7
Rep Power: 2
eldhosek1987@gmail.com is on a distinguished road
I want to give variable mass flow inlet conditions for two components-Hydrogen and Helium in a mixture with respect to time. Initially, ONLY Hydrogen at a constant mass flow rate enters through the inlet for some specific time and after that ONLY Helium at a different constant mass flow rate enters. I have written a UDF for this condition. Though I am able to hook the UDF to the mass flow inlet boundary condition, the mass flow rates are not captured properly at the mass flow inlet. Only the initial mass flow rate is showing at the inlet and it is not changing thereafter. Mass flow rates are not changing accordingly with the given mass fraction conditions.

Expecting somebody's help on this.

The UDF goes like this...


#include "udf.h"
DEFINE_PROFILE(mixture_inlet_mass_flow_rate, t, nv)
{
face_t f ;
real flow_time = RP_Get_Real("flow-time");
if (flow_time < 0.005)
{
printf("Time = %f sec. \n",flow_time);
printf("Targeted mass-flow rate set at 0.001 kg/s \n");
begin_f_loop(f,t)
{
F_PROFILE(f,t,nv) = 0.001 ;
}
end_f_loop(f,t)
}
else
{
printf("Time = %f sec. \n",flow_time);
printf("Targeted mass-flow rate set at 0.002 kg/s \n") ;

begin_f_loop(f,t)
{
F_PROFILE(f,t,nv) = 0.002 ;
}
end_f_loop(f,t)
}

}

DEFINE_PROFILE(mixture_inlet_profile, t)
{
real time = CURRENT_TIME;
real X_H2, X_He;

if (time<0.005)
{
X_H2 = 1 ;
X_He = 0 ;

}

else if (t>0.005)
{
X_H2 = 0 ;
X_He = 1 ;

}

if (i == 0)
{
F_PROFILE(f, t, i) = X_H2;
}
else if (i == 1)
{
F_PROFILE(f, t, i) = X_He;
}

}
eldhosek1987@gmail.com is offline   Reply With Quote

Old   February 13, 2025, 00:36
Smile corrected UDF
  #2
New Member
 
cfd_enthusiast
Join Date: Jul 2024
Posts: 7
Rep Power: 2
eldhosek1987@gmail.com is on a distinguished road
Quote:
Originally Posted by eldhosek1987@gmail.com View Post
I want to give variable mass flow inlet conditions for two components-Hydrogen and Helium in a mixture with respect to time. Initially, ONLY Hydrogen at a constant mass flow rate enters through the inlet for some specific time and after that ONLY Helium at a different constant mass flow rate enters. I have written a UDF for this condition. Though I am able to hook the UDF to the mass flow inlet boundary condition, the mass flow rates are not captured properly at the mass flow inlet. Only the initial mass flow rate is showing at the inlet and it is not changing thereafter. Mass flow rates are not changing accordingly with the given mass fraction conditions.

Expecting somebody's help on this.

The UDF goes like this...


#include "udf.h"
DEFINE_PROFILE(mixture_inlet_mass_flow_rate, t, nv)
{
face_t f ;
real flow_time = RP_Get_Real("flow-time");
if (flow_time < 0.005)
{
printf("Time = %f sec. \n",flow_time);
printf("Targeted mass-flow rate set at 0.001 kg/s \n");
begin_f_loop(f,t)
{
F_PROFILE(f,t,nv) = 0.001 ;
}
end_f_loop(f,t)
}
else
{
printf("Time = %f sec. \n",flow_time);
printf("Targeted mass-flow rate set at 0.002 kg/s \n") ;

begin_f_loop(f,t)
{
F_PROFILE(f,t,nv) = 0.002 ;
}
end_f_loop(f,t)
}

}

DEFINE_PROFILE(mixture_inlet_profile, t)
{
real time = CURRENT_TIME;
real X_H2, X_He;

if (time<0.005)
{
X_H2 = 1 ;
X_He = 0 ;

}

else if (t>0.005)
{
X_H2 = 0 ;
X_He = 1 ;

}

if (i == 0)
{
F_PROFILE(f, t, i) = X_H2;
}
else if (i == 1)
{
F_PROFILE(f, t, i) = X_He;
}

}

hey guys,
I have got the correct udf for this condition. I have defined two profiles separately for Hydrogen and Helium and applied the boundary condition separately in the mass flow inlet. When you are defining different profiles with specific names under the same"udf.h", that profiles appear separately with those names in the boundary conditions upon interpreting. Then we can hook it to the corresponding species in the mixture.

The udf goes like this.....


#include "udf.h"

DEFINE_PROFILE(mixture_inlet_profile_Hydrogen, thread, position)
{
face_t f;
real time = CURRENT_TIME; // Get the current simulation time

real mass_flow_rate_H2 = 0.001; // Constant mass flow rate for Hydrogen (kg/s)

begin_f_loop(f, thread)
{
if (time < 0.005)
{
// Hydrogen enters with a specified mass flow rate
F_PROFILE(f, thread, position) = mass_flow_rate_H2;

}
else
{
F_PROFILE(f, thread, position) = 0;

}
}
end_f_loop(f, thread)

}

DEFINE_PROFILE(mixture_inlet_profile_Helium, thread, position)
{
face_t f;
real time = CURRENT_TIME; // Get the current simulation time

real mass_flow_rate_He = 0.002; // Constant mass flow rate for Helium (kg/s)

begin_f_loop(f, thread)
{
if (time < 0.005)
{

F_PROFILE(f, thread, position) = 0;

}
else
{
// Helium enters with a specified mass flow rate
F_PROFILE(f, thread, position) = mass_flow_rate_He;

}
}
end_f_loop(f, thread)

}


Hope it helps someone.....
eldhosek1987@gmail.com is offline   Reply With Quote

Reply

Tags
inlet boundary condition, multiphase mixture model, transient 3d, udf code

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
two different gas! Fluid pair model! saha2122 CFX 7 February 9, 2022 07:15
Match Pressure Inlet/Outlet Boundary Condition Mass Flow Rate MSchneid Fluent UDF and Scheme Programming 3 February 23, 2019 06:00
Pressure Outlet Targeted Mass Flow Rate LuckyTran FLUENT 1 November 23, 2016 10:40
mass flow rates in fluent R.Sripriya FLUENT 1 November 16, 2008 23:03
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 20:09


All times are GMT -4. The time now is 21:56.