CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Writing first UDF (https://www.cfd-online.com/Forums/fluent-udf/213741-writing-first-udf.html)

max.kozak January 7, 2019 12:29

Writing first UDF
 
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.

pakk January 8, 2019 10:38

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

max.kozak January 15, 2019 14:01

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.

pakk January 16, 2019 04:59

Quote:

Originally Posted by max.kozak (Post 722030)
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.


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