CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   User defined function of mass flow rate (https://www.cfd-online.com/Forums/fluent/36408-user-defined-function-mass-flow-rate.html)

Eric April 17, 2005 12:19

User defined function of mass flow rate
 
i have encountered a question about user defined function. since i had to input a unsteady UDF of both pressure and mass flow rate at the same time. with the reference of tutorial, i easily got the desired similar UDF as below.

#include "udf.h" DEFINE_PROFILE(unsteady_pressure, thread, position) {

float t, pressure;

face_t f;

t = RP_Get_Real("flow-time");

pressure (3800*t*t*t*t*t10000*t*t*t*t*t+10000*t*t*t*t-4000*t*t*t+50*t*t+200t+100);

begin_f_loop(f, thread) {

F_PROFILE(f, thread, position) = pressure;

}

end_f_loop(f, thread) }

but when i evaluate the result carefully. i forgot the pressure function only valid for the period of from t= 0 to t=1. After that,the pressure dropped to negative value, which was incorrect for my study. So what i wanted a solution was how to combined two function in a single UDF or can Fluent load two UDF at the same time and forced FLUENT to run the UDF periodically of 1 second. For the mass flow rate, say my designed function was mass = (-3*t*t*t*t+9*t*t*t-7*t*t+1*t+1);

thanks in advance.

Saad April 22, 2005 18:15

Re: User defined function of mass flow rate
 
Dear Eric, you can use an If-else check in your UDF, i.e.,

if (t >=0 && t <=1) { ....; } else { ...; } So that you can use a single UDF.

Sincerely,

Saad


All times are GMT -4. The time now is 18:35.