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

Gaussian distribution for radiation BC

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 14, 2020, 16:43
Default Gaussian distribution for radiation BC
  #1
New Member
 
Join Date: Jan 2020
Posts: 6
Rep Power: 6
kawkab is on a distinguished road
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)
}
kawkab is offline   Reply With Quote

Old   January 14, 2020, 19:01
Default
  #2
Senior Member
 
Svetlana Tkachenko
Join Date: Oct 2013
Location: Australia, Sydney
Posts: 416
Rep Power: 15
Svetlana is on a distinguished road
Does it compile? Could you please attach a contour of the flux that you receive?
Svetlana is offline   Reply With Quote

Old   January 14, 2020, 22:54
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
#include "udf.h"
must be in the first line

compile your code and read errors
__________________
best regards


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

Old   January 15, 2020, 05:58
Default
  #4
New Member
 
Join Date: Jan 2020
Posts: 6
Rep Power: 6
kawkab is on a distinguished road
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).
Attached Images
File Type: jpg radiation contour.jpg (42.1 KB, 10 views)
kawkab is offline   Reply With Quote

Old   January 16, 2020, 05:46
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
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
AlexanderZ is offline   Reply With Quote

Old   January 22, 2020, 07:36
Default
  #6
New Member
 
Join Date: Jan 2020
Posts: 6
Rep Power: 6
kawkab is on a distinguished road
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.#
And the code is:

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)
}
kawkab is offline   Reply With Quote

Old   January 22, 2020, 07:38
Default
  #7
New Member
 
Join Date: Jan 2020
Posts: 6
Rep Power: 6
kawkab is on a distinguished road
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.
While the exact code is:
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.
kawkab is offline   Reply With Quote

Old   January 22, 2020, 09:40
Default
  #8
New Member
 
Join Date: Jan 2020
Posts: 6
Rep Power: 6
kawkab is on a distinguished road
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).
Attached Images
File Type: jpg Radiation Contour Plots.jpg (60.6 KB, 11 views)
kawkab is offline   Reply With Quote

Old   January 23, 2020, 00:05
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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)
}
kawkab likes this.
__________________
best regards


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

Reply


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
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


All times are GMT -4. The time now is 21:28.