Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Using a UDF for Heat Generation

    • kuuku.botchway
      Subscriber

      I'm currently attempting to use the following UDF I found off the CFD-Online forum.

      #include "udf.h"
      #include "math.h"
      
      DEFINE_ADJUST(cellheatgenerate,d)
      {
      	real SOC,ds,tm,Ri,tempu,volume,source,temp;
      	Thread *t;
      	cell_t c;
      	tm = CURRENT_TIME;
      	thread_loop_c(t,d)
      	{	
      		begin_c_loop(c,t)
      		{		
      			SOC = 1.-((90.*tm)/5400.);
      
      			if ((SOC >= 0.) && (SOC <= 0.77))
      				ds = (99.88*SOC)-76.67;
      			else if ((SOC > 0.77) && (SOC <= 0.87))
      				ds = -30.;
      			else if ((SOC >0.87) && (SOC <=1.))
      				ds = -20.;
      
      			volume = C_VOLUME(c,t);
      			tempu = C_T(c,t);
      			if (tm == 0.)
      				temp = 291.15;
      			else if (tm > 0.)
      				temp = tempu;
      			
      			if (temp <= 298.15)
      				Ri = 0.000002258*pow(SOC,-0.3952);
      			else if ((temp > 298.15) && (temp <= 308.15))
      				Ri = 0.000001857*pow(SOC,-0.2787);
      			else if (temp > 308.15)
      				Ri = 0.000001659*pow(SOC,-0.1692);
      
      			temp = C_T(c,t);
      			source = ((Ri*8100.)-(90.*temp*ds/96.485))/volume;
      			C_UDMI(c,t,0) = source;			
      		}		
      		end_c_loop(c,t)		
      	}	
      }
      
      DEFINE_SOURCE(my_heat_source,c,t,dS,eqn)
      {
      	real source;
      	source =  C_UDMI(c,t,0);	
      	dS[eqn] = 0.0;
      	return source;
      }
      

      I'm currently having problems applying this UDF to my Fluent simulation. I open up Compiled Functions, add the .C file, build it, then load it without any errors showing up, but I'm unable to see where the myheatsource and cellheatgenerate is being applied.

    • Karthik Remella
      Administrator
      Hello Can you post a screenshot of the output printed to the Fluent Console when you compile and load the UDF?
      Karthik
    • kuuku.botchway
      Subscriber
      Attached is the output from the console
    • kuuku.botchway
      Subscriber
      Attached is the text log as well
    • Karthik Remella
      Administrator
      Hello,
      Ansys employees cannot download attachments from the forum. Please embed these as screenshots into your post (use the Image option).
      Karthik
    • kuuku.botchway
      Subscriber
      Sorry about that.

    • Karthik Remella
      Administrator
      Hello Did you hook your adjust function? Also, you should see this volumetric source under cell-zones? What do you see under 'Cell-zones' when you activate 'Sources'?
      Karthik
    • kuuku.botchway
      Subscriber
      So right now I have Joule Heat in Passive Zones, and E-Chem Heat Source set as the Energy Source option. When I check the Cell Zone condition for the passive zones here is what I see:

      I believe I have hooked my adjust function here:


    • Karthik Remella
      Administrator
      Check the Source term check-box. Under the Source Term tab, add a source for Energy and see if the other function 'my_heat_source' shows up there.
      Karthik
    • kuuku.botchway
      Subscriber
      So I seem to have ran into another problem with this UDF. Everytime I attempt to run it Fluent seems to crash, I have setup the hook function and set the Source terms for each Solid I want the source to attach to.
      this is what I'm getting when I initialize the function. Then when I run the calculation it crashes.
    • Rob
      Forum Moderator
      I'd start by checking the two interface zones.
    • kuuku.botchway
      Subscriber
      So right now this is the error I'm receiving before it crashes
      I'm unable to pull the previous messages in the console because it crashes immediately after this
    • Karthik Remella
      Administrator
      I'd recommend that you start writing a transcript file before you run your simulation. This will write out an output file and will help you identify the issue.
      To write transcript: File -> Write -> Start Transcript. Fluent should write this file in your working directory.
      Karthik
    • YasserSelima
      Subscriber
      Did you allocate UDM?
    • Maher Al.
      Subscriber
      Hi Did you figure out how to solve this issue ???
      I appreciate your help


Viewing 14 reply threads
  • The topic ‘Using a UDF for Heat Generation’ is closed to new replies.
[bingo_chatbox]