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

Writing first UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 7, 2019, 13:29
Default Writing first UDF
  #1
New Member
 
Max
Join Date: Jun 2017
Posts: 21
Rep Power: 9
max.kozak is on a distinguished road
Hello All,

I need to write a UDF for monitoring a species mass fraction, which I believe should be pretty simple. However, I don't have any experience coding, so I'm hoping I can get some guidance to get started.

Essentially, I have a UDS set up for a species as a certain inlet mass fraction, and I want to include a species death rate as a function of first order kinetics. I have used data to determine this correlation, along with a k constant, but I do not know how to include this in a UDF. Does anyone have any advice or resources that can point me in the right direction for someone without any coding experience?

I greatly appreciate any help.
max.kozak is offline   Reply With Quote

Old   January 8, 2019, 11:38
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
You basically want the UDS to be removed from your volume (in a controlled way). So, essentially you want a sink.
A sink is a negative source.
So look at DEFINE_SOURCE in the Fluent manual (Fluent customization Manual, section 2.3.36).
pakk is offline   Reply With Quote

Old   January 15, 2019, 15:01
Default
  #3
New Member
 
Max
Join Date: Jun 2017
Posts: 21
Rep Power: 9
max.kozak is on a distinguished road
Thanks so much for your reply pakk. I've written some code using the DEFINE_SOURCE macro, and it's saying that I'm missing parameters for this macro. Here's what I have so far...


#include "udf.h"

DEFINE_SOURCE(cell_deathrate,c,t,i)
{
real source;
real k;
k=0.0000108840

source=-k*C_UDSI(c,t,0);

return source;
}

Basically, I want to monitor this UDS as dN/dt = -k*(local cell concentration). I thought this would do the trick to set up the first order kinetics and add a sink, but I continue to get some errors. Do you have any insight into what I may be missing? Thanks so much.
max.kozak is offline   Reply With Quote

Old   January 16, 2019, 05:59
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by max.kozak View Post
Thanks so much for your reply pakk. I've written some code using the DEFINE_SOURCE macro, and it's saying that I'm missing parameters for this macro. Here's what I have so far...


#include "udf.h"

DEFINE_SOURCE(cell_deathrate,c,t,i)
{
real source;
real k;
k=0.0000108840

source=-k*C_UDSI(c,t,0);

return source;
}

Basically, I want to monitor this UDS as dN/dt = -k*(local cell concentration). I thought this would do the trick to set up the first order kinetics and add a sink, but I continue to get some errors. Do you have any insight into what I may be missing? Thanks so much.
It's difficult to solve the errors, because I can not see which errors you get.
pakk is offline   Reply With Quote

Reply

Tags
first order, species mass fraction, udf code


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
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 03:36
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 12:04
Writing UDF to represent drag equations Dawood Al-Mosuli FLUENT 1 April 27, 2015 06:02
Seek help in writing UDF Jack Martinez FLUENT 9 June 14, 2007 11:24
New to writing UDF Sandilya FLUENT 0 May 31, 2007 13:03


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