|
[Sponsors] |
January 14, 2020, 16:43 |
Gaussian distribution for radiation BC
|
#1 |
New Member
Join Date: Jan 2020
Posts: 6
Rep Power: 6 |
I'm new to using UDF and I'm trying to write source code to set a 2D Gaussian distribution for the radiation flux as a BC.
Here is a basic code I wrote but for some reason, it doesn't distribute the flux correctly. # include <math.h> #include "udf.h" # define x_m 0 # define y_m 0 # define i_m 6750000 DEFINE_PROFILE(radiation_flux, thread, position) { int x[ND_ND]; /* this will hold the position vector */ face_t f; begin_f_loop(f, thread) { F_CENTROID(x, f, thread); F_PROFILE(f, thread, position) = i_m * exp(-1 * ((((x[0] - x_m) ^ 2) / 2) + (((x[1] - y_m) ^ 2) / 2))); } end_f_loop(f, thread) } |
|
January 14, 2020, 19:01 |
|
#2 |
Senior Member
Svetlana Tkachenko
Join Date: Oct 2013
Location: Australia, Sydney
Posts: 416
Rep Power: 15 |
Does it compile? Could you please attach a contour of the flux that you receive?
|
|
January 14, 2020, 22:54 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
#include "udf.h"
must be in the first line compile your code and read errors
__________________
best regards ****************************** press LIKE if this message was helpful |
|
January 15, 2020, 05:58 |
|
#4 |
New Member
Join Date: Jan 2020
Posts: 6
Rep Power: 6 |
It's compiled without any error. I placed the #include "udf.h" in the first line but I still get a constant radiation intensity after initializing the solution (see attached image).
|
|
January 16, 2020, 05:46 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
show exact code which you are using and which is compiled without errors from your point of view,
show compilation log
__________________
best regards ****************************** press LIKE if this message was helpful |
|
January 22, 2020, 07:36 |
|
#6 |
New Member
Join Date: Jan 2020
Posts: 6
Rep Power: 6 |
The compilation log is as follows:
HTML Code:
Copied C:\Workspace\Ansys\Steadyhalf_files\dp0\FFF-3\Fluent/C:\Workspace\Ansys\Steadyhalf_files\dp0\FFF-3\Fluent\Source2.c to libudf\src Creating user_nt.udf file for 3d ... (system "copy "C:\PROGRA~1\ANSYSI~1\v171\fluent"\fluent17.1.0\src\udf\makefile_nt.udf "libudf\win64\3d\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\3d")# Generating ud_io1.h Source2.c # Generating udf_names.c because of makefile Source2.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj Source2.obj Microsoft (R) Incremental Linker Version 14.24.28314.0 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libudf.lib and object libudf.exp Done.# Code:
#include "udf.h" # include <math.h> # define x_m 0 # define y_m 0 # define stdv 5 # define i_m 6750000 # define M_PI 3.14159265358979323846 DEFINE_PROFILE(radiation, t, i) { int x[ND_ND]; /* this will hold the position vector */ face_t f; begin_f_loop(f, t) { F_CENTROID(x, f, t); F_PROFILE(f, t, i) = i_m * (exp(-1 * ((((x[0] - x_m) ^ 2) / 2) + (((x[1] - y_m) ^ 2) / 2)))); /*F_PROFILE(f, t, i) = i_m*(1/(2*M_PI*stdv))*exp(-1*(((x[0]-x_m)^2+(x[1]-y_m)^2)/(2*stdv^2)));*/ } end_f_loop(f, thread) } |
|
January 22, 2020, 07:38 |
|
#7 |
New Member
Join Date: Jan 2020
Posts: 6
Rep Power: 6 |
The compilation log is:
HTML Code:
Copied C:\Workspace\Ansys\Steadyhalf_files\dp0\FFF-3\Fluent/C:\Workspace\Ansys\Steadyhalf_files\dp0\FFF-3\Fluent\Source2.c to libudf\src Creating user_nt.udf file for 3d ... (system "copy "C:\PROGRA~1\ANSYSI~1\v171\fluent"\fluent17.1.0\src\udf\makefile_nt.udf "libudf\win64\3d\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\3d")# Generating ud_io1.h Source2.c # Generating udf_names.c because of makefile Source2.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj Source2.obj Microsoft (R) Incremental Linker Version 14.24.28314.0 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libudf.lib and object libudf.exp Done. Code:
# #include "udf.h" # include <math.h> # define x_m 0 # define y_m 0 # define stdv 1 # define i_m 6750000 # define M_PI 3.14159265358979323846 DEFINE_PROFILE(radiation, t, i) { int x[ND_ND]; /* this will hold the position vector */ face_t f; begin_f_loop(f, t) { F_CENTROID(x, f, t); F_PROFILE(f, t, i) = i_m*(1/(2*M_PI*stdv))*exp(-1*(((x[0]-x_m)^2+(x[1]-y_m)^2)/(2*stdv^2))); } end_f_loop(f, t) } Last edited by kawkab; January 22, 2020 at 11:15. |
|
January 22, 2020, 09:40 |
|
#8 |
New Member
Join Date: Jan 2020
Posts: 6
Rep Power: 6 |
Let me clarify what I'm actually doing. It's a 3D fluent case and I'm trying to impose radiation flux on a circular boundary (window) with a 2D Gaussian distribution.
I compiled the previous code as a UDF and used it as a BC for direct radiation for the window. After I initialized the solution, the radiation intensity on the window becomes constant. But after running the solution for a few iterations, it takes a strange distribution (see the front view in the attached image). |
|
January 23, 2020, 00:05 |
|
#9 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
# include "udf.h" # include <math.h> # define x_m 0 # define y_m 0 # define stdv 1 # define i_m 6750000 DEFINE_PROFILE(radiation, t, i) { int x[ND_ND]; /* this will hold the position vector */ face_t f; begin_f_loop(f, t) { F_CENTROID(x, f, t); F_PROFILE(f, t, i) = i_m*(1/(2*M_PI*stdv))*exp(-1*((pow((x[0]-x_m),2)+pow((x[1]-y_m),2))/(2*pow(stdv,2)))); } end_f_loop(f, t) }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF for 2D gaussian distribution | slek | Fluent UDF and Scheme Programming | 13 | January 14, 2020 22:52 |
size distribution models in OpenFOAM 4.x | minzhang | OpenFOAM Running, Solving & CFD | 1 | March 30, 2018 19:10 |
UDF program for gaussian distribution in space, time and both | khattaksadia | Fluent UDF and Scheme Programming | 0 | April 18, 2017 02:39 |
Diameter distribution, Search for options ?! | souria | FLUENT | 0 | January 22, 2016 09:38 |
maintaining a logarithmic velocity distribution | Morten Andersen | CFX | 1 | January 8, 2007 12:37 |