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

Modelling an ohmic resistor heating a fluid via UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 28, 2020, 03:02
Default Modelling an ohmic resistor heating a fluid via UDF
  #1
New Member
 
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5
ham551 is on a distinguished road
Hi there,

I am trying to model the heat transfer from an ohmic resistor in Argon. I don't want the resistor to interact with the fluid, so I would like to apply the heating rate via a UDF. I am new to UDF's and have written a basic one (shown below) applying a heat source to some generic zone inside the domain, but it doesn't seem to work. I have taken the coordinates when setting up the geometry in SpaceClaim ( At the moment the geometry is just a 2D rectangle with a pressure-inlet and pressure-outlet.)

Is there a problem with my code? And is there a better way to solve a problem like this in Fluent?

Code:
#include "udf.h"

DEFINE_SOURCE(sourceterm,c,t,dS,eqn)
{
real x[ND_ND];
real source;


C_CENTROID(x,c,t);

if(x[0]>=5 && x[0]<=10 && x[1]>=0 && x[1]<=12)
{
source=5000;
}
else
{
source=0;
}
return source;
}
ham551 is offline   Reply With Quote

Old   December 28, 2020, 06:34
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
the concept of code is correct, not sure about your condition statement
Code:
if(x[0]>=5 && x[0]<=10 && x[1]>=0 && x[1]<=12)
may be you should add more brackets
with one is working 100%:
Code:
if ((x[0]>=5) && (x[0]<=10))
{
	if (( x[1]>=0) && (x[1]<=12))
	{}
}
check units, check scale in Fluent, actually, if you everything in your model is in SI, 5 10 12 means 5 10 12 meters
5000 W/m3 is nothing for such huge zones
ham551 likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 29, 2020, 06:34
Default
  #3
New Member
 
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5
ham551 is on a distinguished road
Thanks for your help. I made those adjustments to my code and I also had to adjust the values of the bounds as my geometry is in mm, not m. A silly mistake by me.

However, the results I'm getting don't seem that accurate. For example for the below code, I get the following contour for source energy. As you can see the leading edge of the heat source is angular, while the trailing edge is square. I would expect the leading edge of the region to also be square for the bounds applied.



Code:
#include "udf.h"

DEFINE_SOURCE(sourceterm,c,t,dS,eqn)
{
real x[ND_ND];
real source;


C_CENTROID(x,c,t);

if ((x[1]>=0.005) && (x[1]<=0.006))
{
	if (( x[0]>=0.03 && x[0]<=0.04))
	{source=5000000;}
}
else
{
source=0;
}
return source;
}

If I use the x-coordinate in the first IF statement, for the same bounds, I get this utter mess.



Code:
#include "udf.h"

DEFINE_SOURCE(sourceterm,c,t,dS,eqn)
{
real x[ND_ND];
real source;


C_CENTROID(x,c,t);

if ((x[0]>=0.03) && (x[0]<=0.04))
{
	if (( x[1]>=0.005 && x[1]<=0.006))
	{source=5000000;}
}
else
{
source=0;
}
return source;
}
I don't understand how they can be so different as they are describing the same bounds as far as I can see.

Another issue I'm facing now, is I'm trying to expand my code to consider the heat source in a more sophisticated bounded region. I'm starting simple by trying to bound it within two linear lines. This is my code and resulting heat source contour. Again it's a mess. Any ideas?



Code:
#include "udf.h"

DEFINE_SOURCE(sourceterm,c,t,dS,eqn)
{
real x[ND_ND];
real source;
real m1;
real m2;
real c1;
real c2;
m1 = 1.22;
m2 = 1.22;
c1 = 0.01394;
c2 = 0.01619;

C_CENTROID(x,c,t);

if ((x[1]>=0) && (x[1]<=0.015))
{
	if ((x[0]>=(x[1] + c1)/m1) && (x[0]<=(x[1] + c2)/m2))
	{source=5000000;}
}
else
{
source=0;
}
return source;
}
Here's an image of the mesh for completeness.




Cheers
Attached Images
File Type: png LinearBound.PNG (25.5 KB, 22 views)
File Type: jpg Mesh.jpg (131.7 KB, 22 views)
File Type: png Xbound.PNG (17.2 KB, 20 views)
File Type: png Ybound.PNG (12.8 KB, 19 views)

Last edited by ham551; December 29, 2020 at 08:01.
ham551 is offline   Reply With Quote

Old   December 29, 2020, 09:24
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
You omitted brackets in the second if.

If you go for a complex geometry, don't code it in a UDF. Just make two zones in your geometry, and apply the source only to one of your zones.
pakk is offline   Reply With Quote

Old   December 30, 2020, 06:31
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
I have no idea, what are these contours, you suppose to have 5000000 in defined region

to plot your source add user defined memory, code will looks like this

Code:
#include "udf.h"

DEFINE_SOURCE(sourceterm,c,t,dS,eqn)
{
real x[ND_ND];
real source;


C_CENTROID(x,c,t);

if ((x[0]>=0.03) && (x[0]<=0.04))
{
	if (( x[1]>=0.005 && x[1]<=0.006))
	{
		source=5000000;
		C_UDMI(c,t,0) = source;
	}
}
else
{
source=0;
}
return source;
}
allocate 1 udm in fluent interface
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 31, 2020, 13:06
Default
  #6
New Member
 
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5
ham551 is on a distinguished road
Quote:
Originally Posted by pakk View Post
You omitted brackets in the second if.

If you go for a complex geometry, don't code it in a UDF. Just make two zones in your geometry, and apply the source only to one of your zones.
That works a lot better, thanks. Does it matter how I create a new zone? I just did a quick test and used a face split to create a new fluid zone. Works alright but looks like there might be an issue with the zone interfaces, the flow is doing weird things. Is it better practice to create two bodies and join them into a part and then mesh?
ham551 is offline   Reply With Quote

Reply

Tags
heat sources, udf source energy


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
Boundary Condition for wallHEatTransfer without modelling the Fluid Ohlzen-Wendy OpenFOAM Running, Solving & CFD 6 June 18, 2019 08:33
Divergence in non-Newtonian fluid UDF moabdi FLUENT 0 June 23, 2016 12:30
Error in Two phase (condensation) modeling adilsyyed CFX 15 June 24, 2015 20:42
Water subcooled boiling Attesz CFX 7 January 5, 2013 04:32
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 10:11


All times are GMT -4. The time now is 22:48.