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 Defining different Diffusivity for different Cellzones

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By AlexanderZ
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 4, 2022, 05:44
Default UDF for Defining different Diffusivity for different Cellzones
  #1
New Member
 
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4
CFD27 is on a distinguished road
Hello all,
I have a problem in defining diffusivity. I want to define two different diffusion coefficients in two different cell zones. For this I use the following UDF:
Code:
DEFINE_DIFFUSIVITY(diffusion, c, t, i)
{
	Domain* d;
	Thread * tc1, * tc2;

	d = Get_Domain(1);
	
	tc1 = Lookup_Thread(d, 8);
	tc2 = Lookup_Thread(d, 9);


	if (t == tc1)
	{
		diffusivity = 1e-7;
	}
	else if (t == tc2)
	{
		diffusivity = 1e-5;
	}
	return diffusivity;
	
}
The UDF compiles without any problems. However, you can see in the post that the diffusion coefficients are not inserted correctly. Does anyone have an idea what this can be due to?
Many thanks in advance.
Many greetings
Joe
Attached Images
File Type: png Diffusivity.png (108.7 KB, 16 views)
CFD27 is offline   Reply With Quote

Old   March 6, 2022, 23:27
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
plot contour from 1e-7 to 1e-4
turn of node values in contours options
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   March 7, 2022, 04:29
Default
  #3
New Member
 
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4
CFD27 is on a distinguished road
Dear Alexander,
Thank you very much for your answer. I followed your tips, but I didn't know what to do with your second tip. I now have the Contour displayed in range from 1e-7 to 1e-4 and have changed the Location variable from Vertex to Face. Unfortunately, this did not change much.
Many thanks in advance.
Joe
Attached Images
File Type: png Diffusivity_1.png (83.9 KB, 10 views)
File Type: jpg Diffusivity_2.JPG (51.9 KB, 10 views)
CFD27 is offline   Reply With Quote

Old   March 7, 2022, 06:22
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
I thought it was the problem of plotting, which isn't

so you should compile the code.
variable diffusivity was not defined
Code:
#include "udf.h"
DEFINE_DIFFUSIVITY(diffusion, c, t, i)
{
	Domain* d;
	Thread * tc1, * tc2;
	real diffusivity;
	d = Get_Domain(1);	
	tc1 = Lookup_Thread(d, 8);
	tc2 = Lookup_Thread(d, 9);
	if (t == tc1)
	{
		diffusivity = 1e-7;
	}
	else if (t == tc2)
	{
		diffusivity = 1e-5;
	}
	return diffusivity;	
}
I'm working inside fluent stand alone, making pictures there
for me it's strange to see on your picture name diffusivity under user defined variable 7
at least its a property of scalar

so first compile code and try again.
I'm assuming that 8 and 9 zones ate rectangular and circle from your picture
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   March 7, 2022, 08:59
Default
  #5
New Member
 
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4
CFD27 is on a distinguished road
Dear Alexander,

Thank you for your reply. I have already complicated the code. The diffusivity variable is defined as a global variable and therefore not seen in the code, please excuse me. I use the diffusivity in other UDF to define the laminar diffusion. There is a species source in the circle. These species must be transported across the circle wall using sinks and sources which are adjacent to the circle walls. The cell area in the circle has the cell thread 8 and the cells outside the circle has the cell area 9. I have saved the diffusivity in a UDM to be able to look at the values of this in postprocessing. Is there another way to view the values of diffusivity?
Many thanks in advance.
Many Greetings
Joe
CFD27 is offline   Reply With Quote

Old   March 8, 2022, 00:20
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
diffusivity is applied in fluent as a material property
that's why you are using build in macro DEFINE_DIFFUSIVITY to define it

if you are saying that diffusivity is saved in a UDM somewhere else, probably that's an issue as variable "diffusivity" contains only only 1 value (not an array of values over all cells)

so to store diffusivity in UDM you may use this code ( i have no idea how you've made it, may be your way is correct either)

Code:
#include "udf.h"
DEFINE_DIFFUSIVITY(diffusion, c, t, i)
{
	Domain* d;
	Thread * tc1, * tc2;
	real diffusivity;
	d = Get_Domain(1);	
	tc1 = Lookup_Thread(d, 8);
	tc2 = Lookup_Thread(d, 9);
	if (t == tc1)
	{
		diffusivity = 1e-7;
	}
	else if (t == tc2)
	{
		diffusivity = 1e-5;
	}
esle
diffusivity = 0;
C_UDMI(c,t,0) = diffusivity;
	return diffusivity;	
}
CFD27 likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   March 8, 2022, 02:22
Default
  #7
New Member
 
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4
CFD27 is on a distinguished road
Dear Alexander,
Thank you very much for your reply. I have tried your code and it works. Previously I had saved the diffusivity in a Define on Demand macro in a UDM. Thank you very much for your help. However, I would have one more question. Is it necessary to use !RP_HOST in a Define Diffusivity macro? Thank you very much in advance.
Many greetings
Joe
Attached Images
File Type: jpg Diffusivity.jpg (26.8 KB, 17 views)
CFD27 is offline   Reply With Quote

Old   March 9, 2022, 20:13
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you don't need it while you are not doing following:
• Reading and Writing Files
• Global Reductions
• Global Sums
• Global Minimums and Maximums
• Global Logicals
• Certain Loops over Cells and Faces
• Displaying Messages on a Console
• Printing to a Host or Node Process
• Reading/writing VP_VARs
CFD27 likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   March 10, 2022, 07:33
Default
  #9
New Member
 
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4
CFD27 is on a distinguished road
Thank you for your help.

Many Greetings
Joe
CFD27 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 for valve closing a pipe using dynamic mesh chem engineer Fluent UDF and Scheme Programming 2 May 13, 2017 09:39
UDF for anisotropic diffusivity Zerzura Fluent UDF and Scheme Programming 2 December 20, 2015 09:37
UDF Fluent binary diffusivity (stefan Maxwell) natantyt Fluent UDF and Scheme Programming 0 September 19, 2011 11:42
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01
UDF, defining diffusivity Szasz Robert FLUENT 0 March 10, 2000 06:46


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