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

Average Temperature

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 21, 2017, 13:34
Default Average Temperature
  #1
New Member
 
Join Date: Jan 2014
Posts: 10
Rep Power: 12
FRibeiro is on a distinguished road
Hi,

I am simulating a sub-channel flow (in a nuclear reactor), so I have 4 domains (fuel, gap, clad and fluid).
I have a volumetric heat generation into the fuel and I and to calculate the fluid average temperature by using a UDF.

I wrote something like that:

#include "udf.h"

DEFINE_TEMPERATURA(temp_ave_fluid)

{
Domain *d;
cell_t c;
Thread *tc;
ind ID = 30; */ ID of the domain fluid
d = Get_Domain(1);
real volume = 0.0;
real temper = 0.0;
real temperature_fluid;
tc = Lookup_Thread(d,ID);

begin_c_loop(c,tc)
{
volume = C_VOLUME(c,tc);
temper += C_T(c,tc)*C_VOLUME(c,tc);
vol_tot += volume;
tsum += temper
}
end_c_loop(c,tc)

temperature_fluid=tsum/vol_tot;

printf("\n Temperature sonde: %e K \n , temperature_fluid);

}

But I can not interpret the UDF, Fluent says:
"unterminated string or character constant"
"possible real start of unterminated constant"
"line 7: parse error"

Could someone helps me? Please

Thanks
FRibeiro is offline   Reply With Quote

Old   February 22, 2017, 07:53
Default
  #2
Senior Member
 
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 9
KevinZ09 is on a distinguished road
Not sure what line 7 is in your code, but a couple of things:

1: I've never heard of the DEFINE_TEMPERATURA macro. Not sure what it is or what it does, if it even exists.
2: If you want to just calculate and print a variable, I'd suggest using DEFINE_ADJUST.
3: There's a spelling error in "Ind ID = 30;". It should read "Int ID = 30;".
4: Are you trying to calculate a volume-weighted average temperature? If so, don't need a UDF for that, you can just create a monitor for it.
5: If you do absolutely want a UDF for it, I think you're making a calculation error, as you're summing C_T(c,ct)*C_VOLUME(c,ct) twice. I'd suggest to just write "volume += C_VOLUME(c,ct) and delete the vol_tot and tsum calculations/variables.

But perhaps these suggestions are irrelevant as it could be that I misunderstand what you're trying to do. I understand it's a nuclear reactor, but I figure your fluid is in a separate domain/volume from the fuel rod and cladding, right? So is it the coolant's average temperature you want?
KevinZ09 is offline   Reply With Quote

Old   February 22, 2017, 14:47
Default
  #3
New Member
 
Join Date: Jan 2014
Posts: 10
Rep Power: 12
FRibeiro is on a distinguished road
Dear Kevin,

Thank you for your response.

Actually I did some mistakes, thanks.

I really need to calculate the average temperature by UDF to use the information to perform a feedback to the fuel.

I am a little lost in UDF, I don't find a lot o material on internet to learn.

If I try to use DEFINE_ADJUST, Fluent says that I have only one argument, but it's not a error, and I also tried with DEFINE_ADJUST (temp_ave_fluid, domain).

Today my code is:

#include "udf.h"

DEFINE_EXECUTE_AT_END(temp_ave_fluid)
{
Domain *d;
cell_t c;
Thread *tc;
Int ID = 30;
d = Get_Domain(1);
real volume = 0.0;
real temper = 0.0;
real temperature_fluid;
tc = Lookup_Thread(d,ID);

begin_c_loop(c,tc)
{
volume += C_VOLUME(c,tc);
temper += C_T(c,tc)*C_VOLUME(c,tc);
}
end_c_loop(c,tc)

temperature_fluid=tsum/vol_tot;
printf("\n Temperature sonde: %e K \n , temperature_fluid);
}

But I keep having the same problems.

Thanks one again,
Felipe
FRibeiro is offline   Reply With Quote

Old   February 23, 2017, 07:18
Default
  #4
Senior Member
 
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 9
KevinZ09 is on a distinguished road
Well, you need to close the string in your printf statement, as now you've only got the opening quotation mark ", but no accompanying closing one. So put a " after the second \n in the printf statement.

Also, I noticed in your old code you used */, but that signals end of comments. Start of comments is indicated by /*.

But outside of the syntax, what is it you're really trying to do? Because the macro to use depends on what you want to accomplish. I suggested DEFINE_ADJUST for just outputting information, but perhaps you need another one if you want to feed your volume weighted average temperature back to your simulation.
KevinZ09 is offline   Reply With Quote

Old   March 7, 2017, 06:28
Default
  #5
New Member
 
Join Date: Jan 2014
Posts: 10
Rep Power: 12
FRibeiro is on a distinguished road
Kevin,

Thank you very much for your corrections.

But it still not working...

"#include "udf.h"

DEFINE_ADJUST(temp_ave_fluid)
{
Domain = Get_Domain(1);
cell_t c;
Thread *tc;
real volume = 0;
real temper = 0;
real temperature_fluid;
tc = Lookup_Thread(domain,fluid);

begin_c_loop(c,tc)
{
volume += C_VOLUME(c,tc);
temper += C_T(c,tc)*C_VOLUME(c,tc);

}
end_c_loop(c,tc)

temperature_fluid=temper/volume;
printf("\n Temperature sonde: %e K \n , temperature_fluid");

}"

And actually I have serious problems when Fluent try ti read it:


"cpp -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.7/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.7/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.7/client/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.7/multiport/src" -I. -DUDF
ONFIG_H="<udfconfig-host.h>" "C:\Documents and Settings\Lasme\Desktop\UDF_Tmedio_fluido\qv_cos_03 _copia\Tmedio_fluido3.c"
C:\\Documents and Settings\\Lasme\\Desktop\\UDF_Tmedio_fluido\\qv_co s_03_copia\\Tmedio_fluido3.c:3: macro `DEFINE_ADJUST' used with just one arg
Error: C:\\Documents and Settings\\Lasme\\Desktop\\UDF_Tmedio_fluido\\qv_co s_03_copia\\Tmedio_fluido3.c: line 5: parse error.
Error: C:\\Documents and Settings\\Lasme\\Desktop\\UDF_Tmedio_fluido\\qv_co s_03_copia\\Tmedio_fluido3.c: line 6: parse error.
Error: C:\\Documents and Settings\\Lasme\\Desktop\\UDF_Tmedio_fluido\\qv_co s_03_copia\\Tmedio_fluido3.c: line 7: parse error.
Error: C:\\Documents and Settings\\Lasme\\Desktop\\UDF_Tmedio_fluido\\qv_co s_03_copia\\Tmedio_fluido3.c: line 8: parse error.
Error: C:\\Documents and Settings\\Lasme\\Desktop\\UDF_Tmedio_fluido\\qv_co s_03_copia\\Tmedio_fluido3.c: line 9: parse error.
Error: C:\\Documents and Settings\\Lasme\\Desktop\\UDF_Tmedio_fluido\\qv_co s_03_copia\\Tmedio_fluido3.c: line 10: parse error.
Error: C:\\Documents and Settings\\Lasme\\Desktop\\UDF_Tmedio_fluido\\qv_co s_03_copia\\Tmedio_fluido3.c: line 11: tc: undeclared variable
MPI Application rank 0 exited before MPI_Finalize() with status -1073741819
The fl process could not be started."

Do you not what it's wrong now? Please

Thanks,
Felipe
FRibeiro is offline   Reply With Quote

Old   May 7, 2017, 09:40
Default
  #6
Member
 
Join Date: Nov 2016
Posts: 73
Rep Power: 9
h0rst is on a distinguished road
Did you try to go over the look up function directly?
h0rst is offline   Reply With Quote

Reply

Tags
t average, udf


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
heat transfer coefficient value in floefd jason kid FloEFD, FloWorks & FloTHERM 10 October 16, 2016 16:55
Anys Average temperature apo FLUENT 2 November 4, 2014 12:31
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 01:27
Is wall ajacent temperature equal to conservative temperature of the wall? shenying0710 CFX 8 January 4, 2013 04:03
average interior temperature less than the operating temperature Naher FLUENT 4 March 31, 2011 23:14


All times are GMT -4. The time now is 19:45.