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

solving a conduction problem in FLUENT using UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 13, 2010, 01:49
Default solving a conduction problem in FLUENT using UDF
  #1
New Member
 
Avinash
Join Date: Apr 2010
Posts: 2
Rep Power: 0
Avin2407 is on a distinguished road
Hi,

I am working on cooling of multi-core processors using core hopping. The way it works is - Say, I have a quad core processor. Initially I power "ON" one core. That core keeps running till it crosses a particular temperature threshold. Once, that temperature threshold is reached, I will turn that core "OFF" and turn "ON" another core in its place. Lets say, I do this for a period of 500 seconds.

I created my model in ICEPAK. I simulated a "core" using a heat source. However, I need to write a UDF to perform the switching of cores based on temperature and, ICEPAK does not allow you to write UDFs. Thats the reason I had to learn to do this in FLUENT. I have no prior experience of working with FLUENT and I need to get this done immediately.

I imported my model into FLUENT by reading in the case file generated by icepak and I did not find any meshing errors. I then wrote my UDF s to perform the switching but when I tried interpreting/compiling them, I found a host of errors that I couldn't resolve. I request you to kindly help me out.

My UDFs are given as follows. I have commented them to try and make them as self-explanatory as possible. I have listed the errors after each UDF. The cores are labelled 1, 14, 5 and 7. What I am trying to simulate through these UDFs is that : Initially - Core 1 is powered ON. If the temperature of core 1 goes above 70 deg C, then turn it off and Turn ON core 14. Similarly, if core 14 goes above 0 deg C, turn ON core 5, if core 5 goes above 70 deg C, turn ON core 7 and if Core 7 goes above 70, go back to Core 1.

I am posting just the UDFs for core 1 and core 14 as the rest are just repeats of the code for core 14 and have the same errors.

1.)

#include"udf.h"
/* function for giving power to core 1 */
DEFINE_PROFILE(core_1_power,t,i)
{
face_t f;
face_t f1;
real temp1;
/* Check Temperature of Core 1 */

begin_f_loop(f,t)
{
temp1=F_T(f,t);
}
end_f_loop(f,t)
while(temp1<343)
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=0.394527e+006; /* As long as temperature of core 1 is < 70 deg C,Keep it turned ON */
}
end_f_loop(f,t)
} /* end of while loop */
if(temp1>343)
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=0; /* If temperature of core 1 is > 70 deg C, turn it OFF */
}
end_f_loop(f,t)

Thread *t1=Lookup_Thread(domain,26); /* Get thread for core 14 */
begin_f_loop(f1,t1)
{
F_PROFILE(f1,t1,i)=0.394527e+006; /* Switch Core 14 ON instead of core 1 */
}
end_f_loop(f1,t1)
}
else
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=0.394527e+006; /* Otherwise Keep Core 1 ON */
}
end_f_loop(f,t)
}
}

Errors :

(37) : error C2275: 'Thread' : illegal use of this type as an expression
(37) : error C2065: 't1' : undeclared identifier
(37) : error C2065: 'domain' : undeclared identifier
(37) : warning C4047: 'function' : 'Domain *' differs in levels of indirection from 'int'
(37) : warning C4024: 'Lookup_Thread' : different types for formal and actual parameter 1
(39) : error C2065: 't1' : undeclared identifier
(39) : error C2223: left of '->nelements' must point to struct/union
(41) : error C2065: 't1' : undeclared identifier
(41) : error C2223: left of '->storage' must point to struct/union


2. Code for Core 14

#include"udf.h"
/* Function for assigning power to core 14 */
/* Core 14 will be turned ON only if Core 1 Exceeds 70 Deg C */
DEFINE_PROFILE(core_14_power,t,i)
{
face_t f;
face_t f1;
face_t f2;
real temp1;
real temp2;
Thread *t1=Lookup_Thread(domain,16); /* Lookup Thread for core 1 */
begin_f_loop(f1,t1)
{
temp1=F_T(f1,t1); /* get temperature of core 1 */
}
end_f_loop(f1,t1)
while(temp1<343)
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=0; /* As long as core 1 is not > 70 deg C, core 14 remains turned OFF */
}
end_f_loop(f,t)
} /* End of while loop */
if(temp1>343) /* Provided Core 1 is > 70 Deg C */
{
begin_f_loop(f,t)
{
temp2=F_T(f,t); /* Get Temperature of core 14 */
}
end_f_loop(f,t)

if(temp2<343)
{
begin_f_looop(f,t)
{
F_PROFILE(f,t,i)=0.394527e+006; /* If core 14 is < 70 Deg C (while core 1 is > 70 Deg C)
turn ON core 14 and keep it ON for as long as it
is below 70 Deg C */

}
end_f_loop(f,t)
}
else
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=0; /* If temperature of core 14 is also > 70 Deg C,
do NOT turn it ON */
}
end_f_loop(f,t)
Thread *t2=Lookup_Thread(domain,19); /* Lookup Thread for core 5 */

begin_f_loop(f2,t2)
{
F_PROFILE(f2,t2,i)=0.394527e+006; /* Turn ON core 5 */
}
end_f_loop(f2,t2)
} /* end of nested if-else loop */
else
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=0; /* If core 1 is not > 70 Deg C, then core 14 power is anyway zero */
}
end_f_loop(f,t)
} /* End of outer if-else loop */
}

Errors:

(16) : error C2065: 'domain' : undeclared identifier
(16) : warning C4047: 'function' : 'Domain *' differs in levels of indirection from 'int'
(16) : warning C4024: 'Lookup_Thread' : different types for formal and actual parameter 1
(45) : error C2143: syntax error : missing ';' before '{'
(52) : error C2059: syntax error : 'else'
(69) : error C2059: syntax error : 'else'
(77) : error C2059: syntax error : '}'

I apologize for the very long post and also if any of my errors are really trivial. I would appreciate any prompt help with this as I dont know of anybody here who has worked with UDF and also, I need to get it done immediately.

Thank you very much.

Regards,
Avinash Raghu.
Graduate Student,
University of Texas at Arlington.
Avin2407 is offline   Reply With Quote

Old   March 13, 2015, 02:02
Default Errors
  #2
Member
 
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 11
Bharadwaj B S is on a distinguished road
Hi avinash,

As per my knowledge most your errors are typing mistakes. That is the reason why you are getting syntax errors. Try to go through how the basic syntax of C programming works.

I had faced the same problem. And some variables like Thread, Domain, etc they are never defined but are being used in your program. Declare them and I think your program should work fine.

Bharadwaj B S
Bharadwaj B S is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Forces in OF15 richard OpenFOAM Running, Solving & CFD 180 July 9, 2018 10:54
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 06:05
problem with loading udf in fluent 6.3 James Fluent UDF and Scheme Programming 6 January 22, 2015 05:51
MRFSimpleFOAM goes divergenced! renyun0511 OpenFOAM Running, Solving & CFD 0 November 19, 2009 02:11
On the damBreak4phaseFine cases paean OpenFOAM Running, Solving & CFD 0 November 14, 2008 21:14


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