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

UDF for Density

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 1 Post By Priyank Mehta
  • 1 Post By Priyank Mehta
  • 1 Post By pakk
  • 1 Post By Priyank Mehta
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2017, 14:04
Default UDF for Density
  #1
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
Hello I want to make UDF for density in which density will depend on temperature , pressure and also on species..here I am attaching my density formula and my UDF ...Please help thank you in adavnce
lonoe likes this.
Priyank Mehta is offline   Reply With Quote

Old   November 30, 2017, 14:05
Default
  #2
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
Quote:
Originally Posted by Priyank Mehta View Post
Hello I want to make UDF for density in which density will depend on temperature , pressure and also on species..here I am attaching my density formula and my UDF ...Please help thank you in adavnce
#include "udf.h"

#include "mem.h"

#include " materials.h"

DEFINE_PROPERTY(dust, c, t)

{

real rho_s,rho_g,alphav,dT,dP,totaly,al,o2,al2,n2,Dust_ rho;

rho_g=1.225;

rho_s=2700;

alphav=0.0001859;

totaly=0;

dT=C_T(c,t);

dP=C_P(c,t);



mixture_species_loop (m,sp,i)

al=C_YI(c,t,1);

o2=C_YI(c,t,2);

al2=C_YI(c,t,3);

n2=C_YI(c,t,4);





totaly=(al/26.9815)+(o2/31.9988)+(al2/101.96)+(n2/28.0134);



dust_rho = (1+alphav*((rho_s/rho_g)-1))*(dP/(dT*totaly*8314.34));



return dust_rho;





}
Priyank Mehta is offline   Reply With Quote

Old   November 30, 2017, 14:17
Default
  #3
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
sen2.PNG

Here I am attaching my required density which is a function of Pressure, Temperature and species mass fraction.


Hoping for your reply thank you
Priyank Mehta is offline   Reply With Quote

Old   December 1, 2017, 03:41
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
So, you want a UDF, and you have a UDF. What is the problem that you want us to solve?
pakk is offline   Reply With Quote

Old   December 1, 2017, 04:57
Default
  #5
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
Quote:
Originally Posted by pakk View Post
So, you want a UDF, and you have a UDF. What is the problem that you want us to solve?
Thank you for your reply....This UDF is not working.... I am getting many errors..like structure reference not implemented...So write now I am confuse with two things...1. I have to interpret or compile this code.
2. The probable reason of my error is extracting mass fraction...


Hoping for your reply
Thank you
Priyank Mehta is offline   Reply With Quote

Old   December 1, 2017, 05:48
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
If you want help, be specific! Don't let us guess what you need help with!

So something is wrong with your UDF. You get errors. But be specific: which errors??? Show them here! If there are too many errors to show, the first ones are usually the most relevant.

And about compiling or interpreting: if possible, compile.
pakk is offline   Reply With Quote

Old   December 1, 2017, 06:00
Default
  #7
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
Quote:
Originally Posted by pakk View Post
If you want help, be specific! Don't let us guess what you need help with!

So something is wrong with your UDF. You get errors. But be specific: which errors??? Show them here! If there are too many errors to show, the first ones are usually the most relevant.

And about compiling or interpreting: if possible, compile.
Thank you for your response...And sorry for the inconvenience...
1. While interpret...It is showing structure reference not implemented...
2. While compile..It is showing the system can not find the path specified...

This are the problem related to the UDF error..

Other then this I am facing problem while writing a code.
1. I don't understand how to extract value for the mass fraction..As it is required in density formula.


Hope now you understand my problem..Thank you in advance
Priyank Mehta is offline   Reply With Quote

Old   December 1, 2017, 07:40
Default
  #8
Member
 
Kirill-MIPT's Avatar
 
Kirill Borodin
Join Date: Mar 2016
Posts: 60
Rep Power: 10
Kirill-MIPT is on a distinguished road
Hello! Study user defined real gas model in the udf guide. Only in such a way you can hook your own density law
Kirill-MIPT is offline   Reply With Quote

Old   December 1, 2017, 08:52
Default
  #9
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Priyank Mehta View Post
Thank you for your response...And sorry for the inconvenience...
1. While interpret...It is showing structure reference not implemented...
2. While compile..It is showing the system can not find the path specified...

This are the problem related to the UDF error..

Other then this I am facing problem while writing a code.
1. I don't understand how to extract value for the mass fraction..As it is required in density formula.


Hope now you understand my problem..Thank you in advance
No, you don't understand what I wrote. If you want help, you have to really show what happens. Not describe it, but copy and paste. I am 95% sure that the answer to your question is easy once I can see what is written on your screen, but I can not see your screen. So show it. Copy the text.
pakk is offline   Reply With Quote

Old   December 1, 2017, 10:42
Default
  #10
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
Hello....This is error I am getting while compiling


The system can not find the file specified.


The UDF library you are trying to load (D:\fluent _thesis \ dp0\ FFF\Fluent\libudf) is not compiled for 2ddp on the current platform (win64).

Thank you in advance

Last edited by Priyank Mehta; December 1, 2017 at 12:50.
Priyank Mehta is offline   Reply With Quote

Old   December 1, 2017, 12:51
Default
  #11
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
The system can not find the file specified.

The UDF library you are trying to load (D:\fluent _thesis \ dp0\ FFF\Fluent\libudf) is not compiled for 2ddp on the current platform (win64).
Priyank Mehta is offline   Reply With Quote

Old   December 1, 2017, 13:32
Default
  #12
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 156
Rep Power: 18
Micael is on a distinguished road
At first glance, there is at least a problem with "mixture_species_loop"

It needs brackets
Code:
mixture_species_loop(m,sp,i)
{
   /* some instruction goes here */
}
Micael is offline   Reply With Quote

Old   December 4, 2017, 05:03
Default
  #13
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Priyank Mehta View Post
Hello....This is error I am getting while compiling


The system can not find the file specified.


The UDF library you are trying to load (D:\fluent _thesis \ dp0\ FFF\Fluent\libudf) is not compiled for 2ddp on the current platform (win64).

Thank you in advance
This is not the error that you get when you are compiling. This is the error that you get when you are loading. The error that you get when you are compiling is above this.
pakk is offline   Reply With Quote

Old   December 5, 2017, 13:02
Default
  #14
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
Hello thank you for suggestion
please help me to solve this error

Received a fatal Signal (segmental fault)
Error object: #f



#include "udf.h"

DEFINE_PROPERTY(dust,c,t)
{
int i;
float dT,dP,r,al,o2,al2,n2;
float Mw_i(int i);
Material *sp;
float rho_g=1.225;
float rho_s=2700;
float alp=0.0001859;
float sum=0.0;
dT=C_T(c, t);
dP=C_P(c, t);

mixture_species_loop(THREAD_MATERIAL(t),sp,i)
{
al=C_YI(c,t,1)/26.9815;
o2=C_YI(c,t,2)/31.9988;
al2=C_YI(c,t,3)/101.96;
n2=C_YI(c,t,4)/28.0134;

sum=al+o2+al2+n2;
}
r = (1+alp*((rho_s/rho_g)-1))*(dP/(sum*dT*8314.34));

return r;
}

hoping for reply thank you
Attached Files
File Type: c dividewt.c (576 Bytes, 27 views)
Priyank Mehta is offline   Reply With Quote

Old   December 5, 2017, 15:26
Default
  #15
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Priyank Mehta View Post
Hello thank you for suggestion
please help me to solve this error

Received a fatal Signal (segmental fault)
Error object: #f
That is the error you get when you try to run. Also can not be used to help you...

Please read carefully: you have to give the error that comes up after you compile.
You click 'build', and something comes on your screen. What? Show me!
pakk is offline   Reply With Quote

Old   December 5, 2017, 16:35
Default
  #16
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 156
Rep Power: 18
Micael is on a distinguished road
How many species do you have defined? If you have 4, then C_YI(c,t,4) is not going to work as index starts at zero (fourth species would be index 3).
Micael is offline   Reply With Quote

Old   December 6, 2017, 01:33
Default
  #17
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
Thank you, Micael...this is very helpful and now it is working.

Thank you very much "pakk" and "Micael" for the help


One more question I have while using

dP=C_P(c, t); which pressure it will give static pressure of that cell or total
pressure (operating pressure + over pressure)
souza.emer likes this.
Priyank Mehta is offline   Reply With Quote

Old   December 6, 2017, 04:00
Default
  #18
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Static pressure.

To get absolute pressure, do
Code:
dP=C_P(c, t)+RP_Get_Float("operating-pressure");
souza.emer likes this.
pakk is offline   Reply With Quote

Old   December 6, 2017, 06:32
Default
  #19
New Member
 
Priyank
Join Date: Sep 2017
Posts: 16
Rep Power: 8
Priyank Mehta is on a distinguished road
Thank you pakk

So what is the difference between
dP=C_P(c, t)+ p_operating;

dP=C_P(c, t)+RP_Get_Float("operating-pressure");

where o_operating I will define it as 101325 Pa



Thank you
souza.emer likes this.
Priyank Mehta is offline   Reply With Quote

Old   December 6, 2017, 07:07
Default
  #20
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
The difference is that RP_Get_Float("operating-pressure") takes the value that you put into the Fluent simulation. If you change it in the Fluent set-up, it will also be changed in the UDF. So fewer chances of making a mistake.
souza.emer likes this.
pakk 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
UDF Compilation Error - Loading Library - COMMON Problem! Help! robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 00:53
Parallelize UDF? Which kind of UDF? Lilly FLUENT 5 March 25, 2014 02:05
Help! Delete the UDM codes in the UDF Messi Fluent UDF and Scheme Programming 2 January 28, 2014 09:01
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


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