|
[Sponsors] |
Modelling an ohmic resistor heating a fluid via UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 28, 2020, 03:02 |
Modelling an ohmic resistor heating a fluid via UDF
|
#1 |
New Member
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5 |
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; } |
|
December 28, 2020, 06:34 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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) with one is working 100%: Code:
if ((x[0]>=5) && (x[0]<=10)) { if (( x[1]>=0) && (x[1]<=12)) {} } 5000 W/m3 is nothing for such huge zones
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 29, 2020, 06:34 |
|
#3 |
New Member
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5 |
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; } 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; } Cheers Last edited by ham551; December 29, 2020 at 08:01. |
|
December 29, 2020, 09:24 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
December 30, 2020, 06:31 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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; }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 31, 2020, 13:06 |
|
#6 |
New Member
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5 |
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?
|
|
Tags |
heat sources, udf source energy |
|
|
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 |