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

UDF to define Direct Solar Irradiation

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 14, 2017, 17:36
Default UDF to define Direct Solar Irradiation
  #1
New Member
 
Augustin R
Join Date: Nov 2017
Posts: 2
Rep Power: 0
Auge2009 is on a distinguished road
Hello everyone,

I'm kinda new to the usage of UDFs in ANSYS Fluent, but I've got the following problem:
I want to simulate the radiation and fluid flow in a closed room with two windows. I got the simulation running using the S2S Model. Now I want to add the solar ray tracing to my model.
I was also able to manage that and in Fluent Post I can see the sun beam moving within the room. But now I would like to define the Direct Solar Irradiation and the Diffuse Solar Irradiation with own values. I thought, I could do that by using a UDF with "DEFINE_SOLAR_INTENSITY" and doing something like this:

Code:
DEFINE_SOLAR_INTENSITY(sol_direct_int, sun_x, sun_y, sun_z, S_hour, S_minute)
{
	real intensity;

        if(S_hour = 11 && S_minute <= 15){intensity=120;}

	printf("solar-time=%f intensity=%e\n", minute, intensity);
        return intensity;
	
}
After defining and compiling this UDF and setting up the solar calculator (with a time i.e. 11:12) I close the Radiation window and get:

Code:
Error:  received a fatal signal (Segmentation fault).
Error Object: #f
What am I doing wrong? And is there another way to set the Direct Solar Irradiation for every timestep differently?
The UDF works totally fine with changing for example the wall temperature with every 5 timesteps.

I hope I could describe my problem well. Thanks for your time and your answers
Auge2009 is offline   Reply With Quote

Old   December 19, 2017, 05:29
Default
  #2
New Member
 
Augustin R
Join Date: Nov 2017
Posts: 2
Rep Power: 0
Auge2009 is on a distinguished road
Does nobody have an answer? Does anyone at least have an idea for a way to avoid this problem?
Auge2009 is offline   Reply With Quote

Old   December 20, 2017, 00:46
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
try this code
Code:
DEFINE_SOLAR_INTENSITY(sol_direct_int, sun_x, sun_y, sun_z, S_hour, S_minute)
{
	real intensity;

        if(S_hour == 11 && S_minute <= 15){intensity=120;}

	Message("solar-time=%f intensity=%e\n", minute, intensity);
        return intensity;
	
}
Best regards
pakk likes this.
AlexanderZ is offline   Reply With Quote

Old   May 6, 2020, 03:22
Default
  #4
Member
 
Join Date: Oct 2019
Posts: 35
Rep Power: 7
Morice is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
try this code
Code:
DEFINE_SOLAR_INTENSITY(sol_direct_int, sun_x, sun_y, sun_z, S_hour, S_minute)
{
	real intensity;

        if(S_hour == 11 && S_minute <= 15){intensity=120;}

	Message("solar-time=%f intensity=%e\n", minute, intensity);
        return intensity;
	
}
Best regards
I know this is an old thread but please bear with me

Was this UDF able to work for anyone who tried to implement it this way?

I keep getting an error message, the screenshot is attached.

My UDF simply defines the intensity values.

#include "udf.h"

DEFINE_SOLAR_INTENSITY(sol_direct_intensity,sun_x, sun_y,sun_z,hour,minute)
{
real intensity;
intensity = 35;
Message("solar-time=%f intensity=%e\n", minute, intensity);
return intensity;
}

DEFINE_SOLAR_INTENSITY(sol_diffuse_intensity,sun_x ,sun_y,sun_z,hour,minute)
{
real intensity;
intensity = 77;
Message("solar-time=%f intensity-diff=%e\n", minute, intensity);
return intensity;
}
Attached Images
File Type: jpg UDF Error.jpg (42.1 KB, 28 views)
Morice is offline   Reply With Quote

Old   May 6, 2020, 05:00
Default Compilation
  #5
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
You appear to be interpreting the library while you need to compile it. If you do not have a compiler then remove Message command. Rest of the code will work.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   May 6, 2020, 07:50
Default Compilation
  #6
Member
 
Join Date: Oct 2019
Posts: 35
Rep Power: 7
Morice is on a distinguished road
Quote:
Originally Posted by vinerm View Post
You appear to be interpreting the library while you need to compile it. If you do not have a compiler then remove Message command. Rest of the code will work.
When I tried compiling it, I kept getting the "n-make" error and the UDF library not compiled for parallel use. That is the reason I tried to interpret it instead.

Even with the VS installed, the error still persists but I found I workaround on youtube of using the x86_x64 Cross Tools command prompt in VS.

Thanks for the response
Morice is offline   Reply With Quote

Old   May 6, 2020, 08:10
Default Compilation
  #7
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Just the installation of VS or Build Tools is not sufficient. Either you need to ensure that udf.bat file installed with Fluent has correct path or use any of the VS command prompts to start Fluent. Once compiled, it will work with normally started Fluent as long as you use the library for same OS, same precision, and same mode (serial or parallel).
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   May 6, 2020, 19:32
Default Successful compilation
  #8
Member
 
Join Date: Oct 2019
Posts: 35
Rep Power: 7
Morice is on a distinguished road
Morning Vinerm,

Thanks for the response.

Yes you are right. I used the VS x86_x64 Command Prompt in VS to start FlUENT and the UDFs compiled successful.

I was able to run the simulation as well.

Thank you for your assistance. much appreciated
Morice is offline   Reply With Quote

Reply

Tags
define_solar_intensity, direct, solar, udf


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
Please help UDF error!!!! dinhanh Fluent UDF and Scheme Programming 3 September 26, 2014 05:10
use of pointers in specific heat udf mdakbari Fluent UDF and Scheme Programming 0 April 18, 2014 12:37
Solar Calculator Dorasemon FLUENT 1 July 25, 2013 10:20
UDF: exporting a variable between two DEFINE function Carlo FLUENT 3 August 19, 2009 13:21
Free surface boudary conditions with SOLA-VOF Fan Main CFD Forum 10 September 9, 2006 13:24


All times are GMT -4. The time now is 17:14.