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

Temperature and Strain Rate Dependent Viscosity UDF Code

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 28, 2022, 02:45
Exclamation Temperature and Strain Rate Dependent Viscosity UDF Code
  #1
New Member
 
SANDIPSINH
Join Date: Mar 2022
Posts: 2
Rep Power: 0
SANDIPSINH JODDHA is on a distinguished road
#include "udf.h"

#include "mem.h"



#define Q 145000 //J/mol

#define A 8.86e+6

#define n 3.55

#define R 8.314 //J/molK

#define alpha 0.045

DEFINE_PROPERTY(cell_viscosity, c, t)

{

real temp = C_T(c, t);

real mu_lam;

real Z;

real Flow_stress;

real x;

real strain;

if (strain < 0)

{

strain = 10;

}

else


{
strain = C_STRAIN_RATE_MAG(c, t);

}


Z = (strain)*exp(Q / (R*temp));

x = pow((Z / A), (1. / n));

Flow_stress = (1. / alpha)*(log(x + sqrt(pow(x, 2) + 1.)));

mu_lam = Flow_stress / (3.*strain);

if (mu_lam > 0)

return mu_lam;

}

we are trying to define the viscosity in term of strain rate and temperature using UDF code but, we are not getting value as expected.
SANDIPSINH JODDHA is offline   Reply With Quote

Old   March 31, 2022, 22:57
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
you should specify what exactly is different from your expectations
compile the code and you will get following output:
Code:
warning C4715: 'cell_viscosity' : not all control paths return a value
warning C4700: uninitialized local variable 'strain' used
fix that

take into account that DEFINE_PROPERTY macro is a loop over all cells in domain, but your variable strain contains only 1 value for the last cell, it overwrites each other cell. You may use used defined memory to store strain on each cell

Also I would initialize strain for the 0-time moment
__________________
best regards


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

Old   April 5, 2022, 11:48
Default
  #3
New Member
 
SANDIPSINH
Join Date: Mar 2022
Posts: 2
Rep Power: 0
SANDIPSINH JODDHA is on a distinguished road
Can you please show us how to do that because I am new to this and when I try this code every cell get's same viscosity value.
SANDIPSINH JODDHA is offline   Reply With Quote

Reply

Tags
ansys fluent, strain rate dependent, temperature dependent, udf code, viscosity

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 09:21
viscosity udf don't use correct temperature and strain rate rezvani Fluent UDF and Scheme Programming 8 May 27, 2021 05:40
Problem in convergence regarding constant viscosity and UDF related Viscosity. alexskerhut FLUENT 0 May 9, 2016 08:43
Problems in converging viscosity UDF dependent upon strain rate and temperature. alexskerhut Fluent UDF and Scheme Programming 1 March 17, 2016 07:19
Temperature dependent Non-Newtonian viscosity UDF cric92 Fluent UDF and Scheme Programming 0 April 14, 2013 06:31


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