temperature at a point
Hi,
Does anyone know how to write the UDF to calculate the temperature at a point? I know surface monitors allow me to check the temperature at a point. However, the temperature at the particular point is needed to change the boundary condition. Thank you. Sincerely, EH |
Quote:
|
Quote:
if (Tpoint < 333) F_PROFILE(f,t,i)=10000 else F_PROFILE(f,t,i)=0 end Kind of like a heater to ensure that the temperature of the domain is always greater than a specified level. I know the coordinates where Tpoint is to be determined but how do I calculate it in UDF. |
ehooi,
Try something like the following. Code:
DEFINE_PROFILE(heat_flux_profile,t,i) See the following thread for time dependent flow: Time-dependent flows You can modify the code I've posted to account for transient heat flux, temperature cutoffs, etc. You'll also need to modify the lower and upper bounds on the x,y, and z coordinates. ComputerGuy |
Quote:
Thank you very much. This is very helpful. Let me see if I interpret this correctly. The 'begin_c_loop' basically calculates the centroid of every cell in my domain. The upper and lower bounds of x, y and z basically defines the limits or the region where the specific point which I want to calculate the temperature is located. So when the x, y and z is within the bounds, and when the temperature is less than the cutoff temperature, F_PROFILE specifies the required heat flux. In this case, I guess set_point_temperature is redundant? Am I right? Thank you again for your guidance. |
Hi ComputerGuy,
I have tried ammending the codes that you have shown earlier and I came up with this: Code:
After interpreting this code, I obtain the following error: cpp -I"C:\PROGRA~1\ANSYSI~1\v121\fluent\fluent12.1.4/src" -I"C:\PROGRA~1\ANSYSI~1\v121\fluent\fluent12.1.4/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v121\fluent\fluent12.1.4/client/src" -I"C:\PROGRA~1\ANSYSI~1\v121\fluent\fluent12.1.4/multiport/src" -I. -DUDF ONFIG_H="<C:/Users/EHOOI/AppData/Local/Temp/udfconfig-node1.h>" "C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c" Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 49: parse error. Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 71: parse error. Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 72: parse error. Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 74: parse error. Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 76: cutoff_temperature: undeclared variable The lines where the error are located are pointed out as comments in the code. I cant detect the error that is mentioned. Could you please help me with this? Thank you. |
First, use && instead of "and" in your logic. Not sure if "and" actually works (I get my languages jumbled).
Next, in the following lines: thermosensor_temperature=thermosensor_temperature + C_T(c,t) /* get thermocouple temperature */ nt=nt+1.0 /* count number */ You need semicolons after each line, before the comment. Additionally, why are you adding a thermosensor temperature to the cell temperature? Perhaps I'm confused about the logic, but wouldn't it just be thermosensor_temp=C_T(c,t);? Try and fix those things and see how it goes. ComputerGuy |
I add them up and divide it by the number of added values to obtain the average. My logic behind it is that there may be more than one cell within the lower and upper bounds specified (I may not be right in this assumption). Hence, I calculate the average of it.
Thanks for your pointers. I will try them out now. Can't believe I overlooked the semi-colons there :o |
Hi ComputerGuy,
I have successfully interpreted the code. Couldn;t run it at the moment because my model still needs some tweaking but the successful interpretation of the code is a good sign. In case anyone else is interested, the code is listed here: Code:
|
Good job -- glad I could help. I understand the volume averaging scheme on temperature; I just didn't see the piece of code where you divided by the cell count.
Thanks for sharing your final code with us. ComputerGuy |
Hi ComputerGuy,
In the code that I have written, there are two define macros, DEFINE_ADJUST and DEFINE_PROFILE. In DEFINE_ADJUST, I calculated the value for the variable thermosensor_temperature and in DEFINE_PROFILE, I use the value of thermosensor_temperature. Can I know if the value of thermosensor_temperature calculated in DEFINE_ADJUST will be automatically stored such that the macro DEFINE_PROFILE can access it or do I have to write some code to store it? Thanks. EH |
It won't be automatically stored as written. You can simply write the value to a user-defined memory location (look up: C_UDMI).
ComputerGuy |
I tried to used the below code but I have faced with "warning"
warning C4700: uninitialized local variable 'thermosensor_temperature' used warning C4700: uninitialized local variable 'thermosensor_temperature' used how to solve this warning? any helps ? what is the reason of this kind of warnings ? Code:
/*********************************************************************** |
Quote:
Code:
real thermosensor_temperature = 0.0; |
how to assign temp from first part of program to second part
Quote:
Hi ehooi, Thank you very much for sharing the program with us. I interpreted your program with some modifications but it was showing udf tsensor and udf heater, both are running fine individually. while combining both as single program, the thermocouple sensor temperature obtained in the first part of program i.e.,udf tsensor is not assigning as input to second part of program i.e., udf heater. I would like to know how to assign thermocouple temperate form first part of program (output) to second part of program as a input Thanks in advance |
Have a look at this post:
http://www.cfd-online.com/Forums/flu...ide-model.html If I remember well it is an update of this post. The problem you have is that the variable that is passed to the second block must be defined as global variable. |
Quote:
Thank u very much for reply ghost82 I defined as you told but still heater is in on position only after crossing higher limit also. below is my code.... #include "udf.h" real p; /* Obtain the mean temperature at the location of thermocouple */ /* Thermocouple located at coordinates (x,y,z) = (0.115,0.135,0.25) */ DEFINE_EXECUTE_AT_END(tsensor) /* exectued at the end of time step in trasient and iteration in steadddy state*/ { real thermosensor_coordinate[ND_ND]; real thermosensor_temperature; real xmin; real xmax; real ymin; real ymax; real zmin; real zmax; real x,y,z; int nt; cell_t c; Domain *d; Thread *t; d = Get_Domain(1); xmin=0.115; xmax=0.135; ymin=0.115; ymax=0.135; zmin=0.243; zmax=0.250; /* Begin loop to determine the temperature at the centroid of cells near the thermocouple */ nt=0; thread_loop_c(t,d) { begin_c_loop(c,t) { C_CENTROID(thermosensor_coordinate,c,t); x=thermosensor_coordinate[0]; y=thermosensor_coordinate[1]; z=thermosensor_coordinate[2]; if ((x >= xmin) && (x <= xmax)) { if ((y >= ymin) && (y <= ymax)) { if ((z >= zmin) && (z <= zmax)) { printf("X-cord = %f\n",x); printf("y-cord = %f\n",y); printf("Z-cord = %f\n",z); thermosensor_temperature=thermosensor_temperature + C_T(c,t); /* get thermocouple temperature */ printf("thermosensor_temperature = %f\n",thermosensor_temperature); nt=nt+1.0; /* count number */ printf("value_nt = %d\n",nt); } } } } end_c_loop(c,t) } thermosensor_temperature=thermosensor_temperature/nt; printf("final_temp = %f\n",thermosensor_temperature); p = thermosensor_temperature; } DEFINE_SOURCE(heater,c,t,ds,eqn) { real cutoff_temperature; real source; cutoff_temperature = 301.0; if (p <= cutoff_temperature) { source = 327680; } else { source = 0; } return source; } I dont know what might be the problem can u plz help me Thanks in advance |
Look at udf in message #4 of the other post.
I think you have to reinizialize also "p" in the first block (just after of before initializing nt, for example), what I'm calling thermosensor_temperature Code:
thermosensor_temperature=0.0; |
Quote:
As you told, "p" i defined as global variable and reinitialized as p=0 before the command nt=0 but still the temperature is increasing mode only( heater on only) i tried to print "p" values in second block but it was showing zero and same "p" value i printed in first block, it was showing correct value. the problem what i thought was '"p" value is not assigning from first block to second block, even though it is global variable. Can u plz identify the problem.... |
Try to declare nt as real, not integer, maybe the division returns 0 if nt is defined as int.
can you also change name p to something else?maybe 'p' is reserved? |
All times are GMT -4. The time now is 09:45. |