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

logic of the DEFINE_PROPERTY macro in UDF manual

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 20, 2020, 06:50
Default logic of the DEFINE_PROPERTY macro in UDF manual
  #1
Senior Member
 
Weiqiang Liu
Join Date: Feb 2018
Posts: 278
Rep Power: 9
Weiqiang Liu is on a distinguished road
Hi all,

I am writting a UDF to define thermal conductivity in my model. I just copied the source code from fluent UDF manual as above picture shows. The source code can be compiled and loaded normally. However, when I tried to initialize my model, fluent complains error which I can not explain. however, if I don't use generic_property macro and give a constant value to ktc, then fluent does not complain error.

My understanding is if I use DEFINE_PROPERTY macro to define mixture thermal conductivity, then fluent will not calculte thermal conductivity for single specie. That's why fluent will complain error when generic_property is used. In other words, I have to calculate thermal conductivity of single species by myself either constant value or kinetic theory. Then mixture thermal conductivity will be calculated.

Then my question is : what's the point of generic_property macro?

is my idea about how fluent calculate thermal conductivity right?

Best regards

Weiqiang
Weiqiang Liu is offline   Reply With Quote

Old   June 20, 2020, 15:02
Default generic_property
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
The objective of the generic_property is to return required properties for all the species. It is not used to apply but fetch their values.

The error might be coming because you might have literally used copy procedure to copy the code from the manual. That will give error. You need to write the code yourself since there are hidden characters that come along. These can be removed, but it is better to write the code yourself or copy the code to a file and then select the code from that file and copy to another one. In the latter case, sometimes, hidden characters may not get copied and the code will work. Recommended is to write the code yourself and not copy it from manual.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 20, 2020, 22:37
Default
  #3
Senior Member
 
Weiqiang Liu
Join Date: Feb 2018
Posts: 278
Rep Power: 9
Weiqiang Liu is on a distinguished road
Quote:
Originally Posted by vinerm View Post
The objective of the generic_property is to return required properties for all the species. It is not used to apply but fetch their values.

The error might be coming because you might have literally used copy procedure to copy the code from the manual. That will give error. You need to write the code yourself since there are hidden characters that come along. These can be removed, but it is better to write the code yourself or copy the code to a file and then select the code from that file and copy to another one. In the latter case, sometimes, hidden characters may not get copied and the code will work. Recommended is to write the code yourself and not copy it from manual.
Hi Vinerm,

I can not really understand the logic. I am using DEFINE_PROPERTY to define thermal conductivity. Also I am using generic_property to fetch thermal conductivity. How can I fetch the data before I even define the data?

Best regards

Weiqiang
Weiqiang Liu is offline   Reply With Quote

Old   June 21, 2020, 16:09
Default Define_property
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
DEFINE_PROPERTY is executed at the time of initialization. If the properties are field dependent, then the field values used for the initialization are used to determine the properties.

generic_property is required if you want to assign properties for mixture. If you are using DEFINE_PROPERTY for a specie, then you don't need generic_property function.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 21, 2020, 22:29
Default
  #5
Senior Member
 
Weiqiang Liu
Join Date: Feb 2018
Posts: 278
Rep Power: 9
Weiqiang Liu is on a distinguished road
Quote:
Originally Posted by vinerm View Post
DEFINE_PROPERTY is executed at the time of initialization. If the properties are field dependent, then the field values used for the initialization are used to determine the properties.

generic_property is required if you want to assign properties for mixture. If you are using DEFINE_PROPERTY for a specie, then you don't need generic_property function.
yes, I found the calling sequence of macros when I trie to debugged my code in VS. The problem is I need to fetch thermal conductivity in DEFINE_PROPERTY macro. Because in the paper, thermal conductivity is the normal thermal conductivity added with additional terms. I think this does not make any sense. How can I fetch thermal conductivity with C_K_L before I even define it.

Therefore, what I did is just use equations of kinetic theory to calculate thermal conductivity of every species in the system and then use mass weighted average method to calculate mixture thermal conductivity. Finaly, the returned thermal conductivity is this mass weighted average value added by some additional terms. I think this makes sense to me.
Weiqiang Liu is offline   Reply With Quote

Old   June 22, 2020, 04:11
Default Procedure
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Yes, it does make sense.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 22, 2020, 04:15
Default
  #7
Senior Member
 
Weiqiang Liu
Join Date: Feb 2018
Posts: 278
Rep Power: 9
Weiqiang Liu is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Yes, it does make sense.
Hi Vinerm,

I finished the code. it can be compiled and loaed normally. however, the results are not very reasonable or to say not similar to literature results.

Maybe my understanding of the model is wrong or maybe somewhere of the code is wrong. I'll check further.

Thanks very much for your patience!

Best

Weiqiang
Weiqiang Liu is offline   Reply With Quote

Old   June 22, 2020, 09:21
Default
  #8
Senior Member
 
Weiqiang Liu
Join Date: Feb 2018
Posts: 278
Rep Power: 9
Weiqiang Liu is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Yes, it does make sense.
hi Vinerm,

I met an intreresting phenomenon. Just like you said, fluid will calculate volume averaged thermal conductivity if I seclet porous zone anyway. In order to make fluent use the thermal conductivity I want it to use like porosity*kg, I just return the value in DEFINE_PROPERTY macro like kg-(1-porosity)/porosity*ks . Then when fluent apply volume averaged method, the final thermal conductivity would be porosity*kg. The problem is since conductivity of solid is much higher than fluid gas, the returned value of DEFINE_PROPERTY would become negative. With this nagetive value, I can calculate without any error though results are not very good. if I just return kg which is the value I calculated, divergence would happen since this kg is a magnitude's higher than normal gas conductivity. Do you think this is normal?

Best regards

Weiqiang
Weiqiang Liu is offline   Reply With Quote

Old   June 22, 2020, 10:26
Default Thermal Conductivity
  #9
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
That's happening because your formulation is incorrect. For porosity of 1, it does return kg, I suppose that implies conductivity of the gas. But for the porosity of 0, i.e., solid, it does not return ks. A simpler solution is to use same properties for solid as that of fluid. Then, you won't need a UDF, until and unless the properties are a function of temperature that is unavailable in Fluent's list of options. If you want to use formulation, then use k_g\varepsilon + k_s(1-\varepsilon).
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Reply

Tags
define_property, generic_property, thermal conductivity


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
ANSYS FLUENT UDF Manual release 17.0 The_Immortal Fluent UDF and Scheme Programming 0 April 13, 2019 13:50
Define_source macro fluent udf Shehryar CFD Freelancers 1 October 29, 2017 06:25
what does FLUID_THREAD_P(t) macro do in udf? borhan_sd@yahoo.com Fluent UDF and Scheme Programming 2 June 10, 2013 05:49
question on UDF manual example ak6g08 FLUENT 0 June 25, 2009 11:58
DEFINE_DPM_OUTPUT macro UDF HELP Puneet FLUENT 3 November 28, 2003 10:55


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