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

Complex UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 11, 2013, 19:50
Default Complex UDF
  #1
New Member
 
N/A
Join Date: Apr 2013
Posts: 18
Rep Power: 13
Tarano is on a distinguished road
He there,

I have a questions regarding how to write this UDF. What i want is best explained in the pictures below first image is what i have. This is this UDF it incorperate the sine wave equation.

#include "udf.h"

DEFINE_PROFILE(unsteady_pressure, thread, position)
{
face_t f;

real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = -6250. + 6250.0*-sin(314.*t);
}
end_f_loop(f, thread)

This UDF is does not actually do what i want. The second picture is what i am looking for the UDF to do. I want to run the full simulation for a second atleast if possible is there an easy way of doing this without having to write the code for each cycle of sin wave?

Thank you for your help in advanced
Attached Images
File Type: png what i have.png (13.6 KB, 11 views)
File Type: png what i want.png (9.1 KB, 11 views)
Tarano is offline   Reply With Quote

Old   July 11, 2013, 22:22
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
The signal appear to be periodic so it is simple to implement.
Code:
#include "udf.h"
#define TPER 0.02
#define PAMP 12000.0

DEFINE_PROFILE(unsteady_pressure, thread, position) 
{
  face_t f;
  real t = fmod(CURRENT_TIME, TPER);
real p;

if ( TPER/4. < t && t < 3*TPER/4.0 ) p = 0.0;
else p = PAMP/2.0*(-1.0-sin(2.0*M_PI*t/TPER);

  begin_f_loop(f, thread)
    {
      F_PROFILE(f, thread, position) = p;
    }
  end_f_loop(f, thread)
blackmask is offline   Reply With Quote

Old   July 14, 2013, 20:26
Default
  #3
New Member
 
N/A
Join Date: Apr 2013
Posts: 18
Rep Power: 13
Tarano is on a distinguished road
Thank you for your reply, yes the signal is periodic.

Unfortunately that UDF code you gave me did not to be interpreted by fluent i get error with the Fmod. Also i am very confused about the coding i don't understand how it will work.
Tarano is offline   Reply With Quote

Old   July 14, 2013, 21:56
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
In order to use "fmod" you have to include "math.h", which I think "udf.h" should have included that header. You should add a line
Code:
#include <math.h>
blackmask 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
I/O of a real value by "DEFINE_RW_FILE" (UDF) Pietro Asinari Fluent UDF and Scheme Programming 1 August 15, 2015 20:08
udf for multiple reaction alihosseini63 Fluent UDF and Scheme Programming 0 July 4, 2013 19:37
Help me to check my UDF Liufeng_ustb Fluent UDF and Scheme Programming 2 May 7, 2013 11:25
On demand UDF error RS FLUENT 0 May 10, 2007 13:54
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


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