July 7, 2021 at 12:41 am
Subscriber
finally, this is my code..
/*UDF that simulates the opening and closing of the inlet valve based on pressure*/
#include "udf.h"
intmy_variable;
cell_t c;
Thread *t;
DEFINE_ADJUST(invalve,d)
{
real P; /*pressure*/
P = C_P(c,t);
/* Loop and check the condition */
if( P < 100000 ) {
my_variable = 1; /*OPEN VALVE*/
}else{
my_variable = 0; /*CLOSE VALVE*/
}
}
DEFINE_PROFILE(inletvalve,t,i)
{
real a; /*viscous resistance = 1/permeability*/
begin_c_loop(c,t)
{
if( my_variable == 1)
a = 1.0;
else
a = 1e12;
F_PROFILE(c,t,i) = a;
}
end_c_loop(c,t)
}
but I don't know if there are errors.. what do you think?
/*UDF that simulates the opening and closing of the inlet valve based on pressure*/
#include "udf.h"
intmy_variable;
cell_t c;
Thread *t;
DEFINE_ADJUST(invalve,d)
{
real P; /*pressure*/
P = C_P(c,t);
/* Loop and check the condition */
if( P < 100000 ) {
my_variable = 1; /*OPEN VALVE*/
}else{
my_variable = 0; /*CLOSE VALVE*/
}
}
DEFINE_PROFILE(inletvalve,t,i)
{
real a; /*viscous resistance = 1/permeability*/
begin_c_loop(c,t)
{
if( my_variable == 1)
a = 1.0;
else
a = 1e12;
F_PROFILE(c,t,i) = a;
}
end_c_loop(c,t)
}
but I don't know if there are errors.. what do you think?