|
[Sponsors] |
May 14, 2021, 12:33 |
Velocity profile UDF divergence error
|
#1 |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
Hi,
First I must say I'm pretty new to Ansys Fluent UDFs. I'm trying to solve a simple problem with a cubic domain and a custom velocity profile at inlet boundary. I've read the Ansys users' guide on UDFs and I cant find any problems with my code, however when I begin the simulation, Fluent gives me this error: "Divergence detected in amg solver: x-momentum" Sorry if my question is a bit obvious but what am I missing? Can someone please help me? BTW my Fluent version is 17.0 and I'm using MVS Express 2012. Also here is my code: Code:
#include "udf.h" #define A_f 22 /* Frontal built area */ #define A_p 22 /* Planar built area */ #define A_tot 100 /* Total land area */ #define H 10 /* Mean building height-Refrence height */ #define U_H 6 /* Wind velocity at height H */ #define A 4.4 /* Building arrangement constant */ #define Cd 1.2 /* Drag coefficient for an staggered array of cubes */ #define Beta 0.55 /* Building drag correction factor */ #define k_von 0.4 /* von-Karman constant */ DEFINE_PROFILE(x_velocity,t,i) { double lambda_f, lambda_p, a, d, zz, z0, U_s, x[ND_ND], z; /* Variable declarations */ face_t f; lambda_f = A_f/A_tot; /* Frontal area density */ lambda_p = A_p/A_tot; /* Planar area density */ a = 9.6*lambda_f; /* Building morphology constant */ d = H*(1+(pow(A,-lambda_p))*(lambda_p-1)); /* Displacement length */ zz = 0.5*Beta*Cd*pow(k_von,-2)*(1-(d/H))*lambda_f; z0 = H*(1-(d/H))*exp(-(pow(zz,-0.5))); /* Surface roughness */ U_s = (U_H*k_von)/(log((H-d)/z0)); /* Friction velocity */ begin_f_loop(f,t) { F_CENTROID(x,f,t); z = x[2]; if (z <= H) F_PROFILE(f,t,i) = U_H*exp(a*((z/H)-1)); else F_PROFILE(f,t,i) = (U_s/k_von)*log((z-d)/z0); } end_f_loop(f,t) } |
|
May 14, 2021, 14:01 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Initialize, don't solve, plot velocity on your BC.
Is it what you expect? My guess is that you made a mistake in one of the equations, which gives you to high velocities.
__________________
"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". |
|
May 15, 2021, 15:37 |
|
#3 |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
Hello again and thank you for your response,
I did as u said and plotted velocity profile on inlet BC after standard initialization (hybrid initialization gives me a similar error). Unfortunately it does not plot anything... So in order to check my equations I used Matlab to plot them and they work as they should be. I attached an image of the Matlab plot here too. I also noticed that in initial values fields, values for k, omega and x velocity are set to " 1.#QNAN " !! Any other ideas? vplot.jpg |
|
May 16, 2021, 01:35 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Fix that problem, and set them to number 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". |
|
May 16, 2021, 06:13 |
|
#5 |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
I already did that before posting the reply and it did not help.
|
|
May 16, 2021, 13:54 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
If you replace your UDF boundary with a simple boundary (velocity 10 m/s for example), do you get the same error? If so, it has nothing to do with the UDF.
And maybe your fluid properties are wrong?
__________________
"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". |
|
May 16, 2021, 18:36 |
|
#7 |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
Hi, I've tried that with a constant 6 m/s velocity at inlet and it worked fine.
Also other things that I've tried but still got the same error:
|
|
May 16, 2021, 23:20 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
check this code
Code:
#include "udf.h" DEFINE_PROFILE(vel_profile,t,i) { real x[ND_ND]; /* this will hold the position vector */ real y; face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); y = x[1]; F_PROFILE(f,t,i) = y*6; } end_f_loop(f,t) }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
May 17, 2021, 06:49 |
|
#9 |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
||
May 17, 2021, 08:29 |
|
#10 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
your code seems to be ok,
the only thing I would change is double type to real here: Code:
real lambda_f, lambda_p, a, d, zz, z0, U_s, x[ND_ND], z; /* Variable declarations */
__________________
best regards ****************************** press LIKE if this message was helpful |
|
May 17, 2021, 09:55 |
|
#11 |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
||
May 19, 2021, 19:03 |
|
#12 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You have some tabs in your #define's, which might be a problem (I don't know if that is allowed or not).
And you can write some values to show if there is an intermediate problem, like this: Code:
#include "udf.h" #define A_f 22 /* Frontal built area */ #define A_p 22 /* Planar built area */ #define A_tot 100 /* Total land area */ #define H 10 /* Mean building height-Refrence height */ #define U_H 6 /* Wind velocity at height H */ #define A 4.4 /* Building arrangement constant */ #define Cd 1.2 /* Drag coefficient for an staggered array of cubes */ #define Beta 0.55 /* Building drag correction factor */ #define k_von 0.4 /* von-Karman constant */ DEFINE_PROFILE(x_velocity,t,i) { double lambda_f, lambda_p, a, d, zz, z0, U_s, x[ND_ND], z; /* Variable declarations */ face_t f; lambda_f = A_f/A_tot; /* Frontal area density */ lambda_p = A_p/A_tot; /* Planar area density */ a = 9.6*lambda_f; /* Building morphology constant */ d = H*(1+(pow(A,-lambda_p))*(lambda_p-1)); /* Displacement length */ zz = 0.5*Beta*Cd*pow(k_von,-2)*(1-(d/H))*lambda_f; z0 = H*(1-(d/H))*exp(-(pow(zz,-0.5))); /* Surface roughness */ U_s = (U_H*k_von)/(log((H-d)/z0)); /* Friction velocity */ begin_f_loop(f,t) { F_CENTROID(x,f,t); z = x[2]; if (z <= H) F_PROFILE(f,t,i) = U_H*exp(a*((z/H)-1)); else F_PROFILE(f,t,i) = (U_s/k_von)*log((z-d)/z0); } end_f_loop(f,t) Message("z=%f ",z); Message("U_s=%f ",U_s); Message("z0=%f ",z0); Message("zz=%f ",zz); Message("d=%f ",d); }
__________________
"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". |
|
May 22, 2021, 13:32 |
|
#13 |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
Hi,
So I've finally managed to solve this error. Apparently "#define" that I used to define some constants was not working properly so constant values were set to zero in equations. I used the method below to define my constants and its working now: Code:
const float A_f=22, A_p=22, A_tot=100, H=10 ,U_H=6, A=4.4, Cd=1.2, Beta=0.55, k_von=0.4; |
|
May 22, 2021, 14:41 |
|
#14 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
Thank you for completely ignoring my message directly above yours.
__________________
"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". |
||
May 22, 2021, 15:57 |
|
#15 |
Member
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7 |
No I did not ignore it. Those are not tabs but spaces and that is how the syntax of #define works.
And about using the "Message" command, I did try it but it was not working since my simulation could not even start to run that command. Anyhow, thank you so much for taking the time to answer my question. |
|
May 23, 2021, 03:13 |
|
#16 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
The code that you posted here has tabs. If you don't believe me, check for yourself, after A_f, A_p and U_H.
But anyway, good that it is solved.
__________________
"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". |
|
Tags |
udf and programming, velocity profile 3d udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Building OpenFOAM1.7.0 from source | ata | OpenFOAM Installation | 46 | March 6, 2022 14:21 |
DPM udf error | haghshenasfard | FLUENT | 0 | April 13, 2016 07:35 |
[OpenFOAM] Native ParaView Reader Bugs | tj22 | ParaView | 270 | January 4, 2016 12:39 |
checking the system setup and Qt version | vivek070176 | OpenFOAM Installation | 22 | June 1, 2010 13:34 |
[swak4Foam] groovyBC: problems compiling: "flex: not found" and "undefined reference to ..." | sega | OpenFOAM Community Contributions | 12 | February 17, 2010 10:30 |