CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   How to update operating pressure using UDF DEFINE_ADJUST (https://www.cfd-online.com/Forums/fluent/228289-how-update-operating-pressure-using-udf-define_adjust.html)

arunraj June 26, 2020 01:58

How to update operating pressure using UDF DEFINE_ADJUST
 
Hello everyone,

I have written an UDF to update the operating pressure. I would like to know what should I do for operating pressure to be updated with the value of p_op_new. Is the below format right.

arunraj June 26, 2020 06:24

I solved

RP_Set_Real("operating-pressure", p_op_new)
/define/operating-conditions/operating-pressure (rpgetvar 'p_op_new)

homay95 June 30, 2020 11:05

Hi
I have written a code by DEFINE_ADJUST for temperature jump as follows :

DEFINE_ADJUST(temperaturejump3, domain)
{
Domain *d;
int zone_ID = 16;
Thread *f_thread = Lookup_Thread(domain, zone_ID);
Thread *c_thread;
cell_t cell;
face_t face;
double dTdy, temp, walltemp;
double b = 0.000001;
thread_loop_f (f_thread,domain)
{
begin_f_loop(face,f_thread)
{
cell = F_C0(face,f_thread);
c_thread = THREAD_T0(f_thread);
walltemp = F_T(face,f_thread);
dTdy = C_T_G(cell,c_thread)[1];
F_PROFILE(face, f_thread, zone_ID) = (b*dTdy) + walltemp;
}
end_f_loop(face,f_thread)
}
}

is it correct or does it need any modifying??

Thanks in advance

arunraj June 30, 2020 22:20

Use 'message' in udf and check if your udf works. though it seems fine to me. I belive you can simply wirte

thread_loop_f (f,d)
{
begin_f_loop(f,t)



}
end_f_loop(f,t)

homay95 July 1, 2020 01:52

thanks for your help but how could I use 'message'? could you be please more specific? and I had a problem that when I hooked DEFINE_ADJUST to hooked functions and start calculation, it says there is "SIGSEGV" error and closes the FLUENT immediately! what should I do? what is wrong with my code?

arunraj July 1, 2020 01:55

something like this can help. Inside f_loop

Message ("Text %g \n", var_name);

homay95 July 1, 2020 01:58

okay thank you. and where should I put this line? inside f-loop or outside?

homay95 July 1, 2020 02:14

I got your message and thank you very much. but I think my condition is different with that in the UDF. I need to write a DEFINE_ADJUST for this:
T)f = T)s + b(dT/dy)
in which T)f is fluid temperature and T)s is solid wall temperature and b is temperature jump coefficient and I also need to apply 'coupled' condition between the face and its shadow to maintain thermal conservation (the heat flux entering one is equal to heat flux exiting the other)

arunraj July 1, 2020 02:45

Okay I understand. Take a sample udf from cfd online. search for it. modify it and use. As you are new, it is difficult to do directly. Mainly the format of UDF is important. Also, you need to explain the problem, How do I know if you are looking for which problem?

homay95 July 1, 2020 03:13

yes actually Im new with UDF coding so Im just looking for a DEFINE_ADJUST UDF template so I could modify it, I mean I need to know which arguments and expressions I have to write in my code for applying a temperature jump on a face. the temperature jump function is as follows :
T)f = T)s + b(dT/dy)
in which T)f is fluid temperature and T)s is solid wall temperature and b is temperature jump coefficient

arunraj July 1, 2020 03:22

You just repeated what you mentioned earlier. whats your problem and domain.

homay95 July 1, 2020 03:27

Im sorry I didnt understand before. Im simulating a heat-sink with rectangular michrochannel which have hydrophobic inside walls and water flowing through it, so I need to write a UDF for the temperature jump on liquid-solid interfaces (I have a slip flow on interfaces). can you please help me?

arunraj July 1, 2020 03:38

First search for some phd thesis and see if someone has already written udf for this. or of similar nature.

homay95 July 1, 2020 03:40

I have searched already but I didnt find any useful source. do you have any recommendation about where could I find some better Thesis? I mean an University website or something like that?!

arunraj July 1, 2020 03:43

I beleive you need to apply udf both on wall as well as shadow wall. So whatever udf i sent could be a reference. work on that improve that for your model.

homay95 July 1, 2020 03:44

okay thank you very much

arunraj July 1, 2020 03:46

This could help you i guess

# include "udf.h2"
DEFINE_ADJUST(match_boundary_at_end, d)
{

FILE *fp;

Thread *tc1, *tc2;
Thread *tf1, *tf2 ;
cell_t c1, c2;
face_t f1, f2;
real f_c1[ND_ND], f_c2[ND_ND];
real dist;

tf1 = Lookup_Thread(d,WALLSIDE1);
tf2 = Lookup_Thread(d,WALLSIDE2);

begin_f_loop(f1,tf1)
{

-----
}
end_f_loop(f1,tf1)

begin_f_loop(f2,tf2)
{

----
}
end_f_loop(f2,tf2)
}

homay95 July 1, 2020 03:51

yes I can use that as a template. thanks


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