|
[Sponsors] |
Is it possible to plot momentum source defined using UDF? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 4, 2021, 19:57 |
Is it possible to plot momentum source defined using UDF?
|
#1 |
Member
Join Date: May 2012
Posts: 30
Rep Power: 14 |
Hi,
I am trying to define momentum source representing manteic field using UDF in Ansys Fluent. There will be one magnet placed above or below of the channel as it is shown in image. The problem is placing the magnet above and below of the channel cause compeletely different results. However since there is no gravity effect I was expecting these two cases should be symmetricay just like an image in mirror. Magnet position 2 gives compeletely irrevelant results.I would like to see contour plot of momentum source therefore maby I could be able to figure out the problem. Is there any way to plot momentum source. Here is my UDF code; Code:
#include "udf.h" #include <math.h> /* sin */ #define PI 3.14159265 #define a1 0.2 /* these are magnet coordinates */ #define b1 -0.5 #define a2 0.2 #define b2 0.5 DEFINE_SOURCE(B_x,c,t,dS,eqn) { real source; real pos_x; real pos_y; real x[ND_ND]; pos_x = x[0]; pos_y = x[1]; F_CENTROID(x, c, t); source = 2*0.0000001*50*-1/sqrt(pow((pos_x-a1),2)+pow((pos_y-b1),2))*0.35*(pos_x-a1)/pow((pow((pos_x-a1),2)+pow((pos_y-b1),2)),1.5); dS[eqn] = 0; return source; } Also,I got this warning during compile udf is this may be related my problem? udf_names.c(12) : warning C4113: 'void (*)()' differs in parameter lists from 'void (*)(void)' |
|
April 4, 2021, 21:52 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
that warning is normal
your source is dependent on pos_x pos_y that's why you have difference when you apply it on top and bottom plates. (cause of different y values)
__________________
best regards ****************************** press LIKE if this message was helpful |
|
April 5, 2021, 04:38 |
|
#3 | |
Member
Join Date: May 2012
Posts: 30
Rep Power: 14 |
Quote:
When I calculate the source in excel for same distances away from the magnet position 1 or 2 the equation gives same values regardless the pos_x and pos_y. pos_x and pos_y are epicenter of the source, and magnitude of the source is depend on the distance not the central position of it. |
||
April 5, 2021, 06:42 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
No, in your UDF, pos_x and pos_y is the position on which you should calculate the source.
Different pos_x and pos_y have different distances to the magnet,so different values.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
April 5, 2021, 08:09 |
|
#5 | |
Member
Join Date: May 2012
Posts: 30
Rep Power: 14 |
Quote:
Consider I am simulating magnet placed bottom of the channel, so central cooridnates of the soruce will be a1 and b1. Let's say magnetic source at pos_x = 0.2 and pos_y = -0.4 is calculated from the equation as M1. In second case I switched a1 with a2 and b1 with b2 therefore magnet will be placed at the top of the channel. Magnetic source at the same distance away from the new position which is pos_x = 0.2 and pos_y = 0.4 (distance is 0.1 in y-direction in both case) will be M2. When I calculate this in excel I get same value in both cases(M1 = M2). Same situation should be avaiable in simulation in fluent but positioning the magnet different locations gives compeletely different flow patterns. |
||
April 5, 2021, 10:49 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Can you show the code that you used for magnet 2 (just to make sure that you replaced everything correctly) and a plot of the "irrelevant results" with magnet 2?
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
April 5, 2021, 10:54 |
|
#7 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Code:
pos_x = x[0]; pos_y = x[1]; F_CENTROID(x, c, t); Put the centroid line first. And I think you should use C_CENTROID, because you work with cells, not faces. Are you really sure you compiled this code, and that there were no errors other than the names.c error?
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
April 5, 2021, 11:09 |
|
#8 |
Member
Yasser Selima
Join Date: Mar 2009
Location: Canada
Posts: 51
Rep Power: 19 |
as Pakk mentioned, these two lines must go below the C_CENTROID line
pos_x = x[0]; pos_y = x[1]; |
|
April 5, 2021, 12:04 |
|
#9 |
Member
Join Date: May 2012
Posts: 30
Rep Power: 14 |
Now it works friends. I have been struggling this for a few days since, it was compiled in each case I was not suspicious about the code. The flow pattern was not as I expected but at least I was hoping to get symetrical results. Now the flow pattern is as I expected and it is symetrical as shown pictures below.
If I know you in real life I would take you dinner tonight. Thank you very much! |
|
February 20, 2023, 18:04 |
|
#10 |
New Member
nguyen Kien
Join Date: Feb 2023
Posts: 4
Rep Power: 3 |
Hi, could you share the code and please show me how to add the magnet in Ansys fluent,
I am new in Ansys Fluent, and I want to simulate the blood flow under magnetic field created by magnet, Thank you Quote:
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] Installation Problem with OF 6 version | Aurel | OpenFOAM Community Contributions | 14 | November 18, 2020 17:18 |
[swak4Foam] Error bulding swak4Foam | sfigato | OpenFOAM Community Contributions | 18 | August 22, 2013 13:41 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 20:08 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |
Momentum source UDF | Matthew Brannock | FLUENT | 5 | May 3, 2001 22:18 |