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

Fluent UDF to define material properties from interpolation of data

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 26, 2021, 11:01
Default Fluent UDF to define material properties from interpolation of data
  #1
New Member
 
Gianmarco
Join Date: Nov 2021
Posts: 10
Rep Power: 4
RocketGme is on a distinguished road
Hello everyone,

I'm having some trouble writing UDFs to define fluid transport properties. I can successfully read experimental values from an external matrix (i.e. as function of p,T) and I think I managed to define properties at each cell value through DEFINE_PROPERTY with an interpolation function.

However, importing the matrix inside the DEFINE_PROPERTY function results in an eccessive cost since at each iteration the matrix is re-opened.

So the idea is to write a DEFINE_ON_DEMAND to load the property matrix (putting it into memory once and for all), and then to write a DEFINE_PROPERTY to interpolate and find the correct value. I wrote the whole process in once .c file and then compiled it with the Fluent built-in compiler. As I do so, both the matrix and the property UDF seem to be correctly loaded, but as I apply the udf in the material log, Fluent crushes (stating "the f1 process could not be started").

My guess is that I'm not able to call the matrix generated in one function, into the other. I tried storing the variable (double**) globally and I'm quite sure I'm doing that wrong. I'm totally new to both C language and Fluent UDFs, so any help would be appreciated. Thank you!

I attach a summary of my code .c

#include "udf.h"
#include <stdio.h>
#include <stdlib.h>

/* global variables */

double* P; /*defining array*/
double* T; /*defining array*/
double** Var_rho; /*defining matrix*/

DEFINE_ON_DEMAND(read_density){

P = malloc(NP * sizeof(double*));
T = malloc(NT * sizeof(double*));
Var_rho=malloc(NT*sizeof(double*));
for(i=0;i<NT;++i)
Var_rho[i]=malloc(NP*sizeof(double));

.... code to open external files and store arrays and matrix ....

}

DEFINE_PROPERTY(DensityUDF, c, t){

.... code to interpolate and define property ....
(here I call something like rho11 = Var_rho[n][m] where Var_rho is the one defined in the previous function)

return rho;
}
RocketGme 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
Fluent UDF to interpolate material properties from Temp and Pressure dependent table lablan Fluent UDF and Scheme Programming 14 June 21, 2021 22:56
Define chemkin mechanism and UDF for combustion problem in Fluent. Deepak Chauhan Main CFD Forum 0 August 13, 2020 07:02
Ansys CFX problem: unexpected very high temperatures in premix laminar combustion faizan_habib7 CFX 4 February 1, 2016 17:00
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF acasas CFD Freelancers 1 January 23, 2015 07:26
Installing OF 1.6 on Mac OS X gschaider OpenFOAM Installation 129 June 19, 2010 09:23


All times are GMT -4. The time now is 05:15.