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

viscosity udf don't use correct temperature and strain rate

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

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 24, 2021, 08:08
Default viscosity udf don't use correct temperature and strain rate
  #1
New Member
 
yahya rezvani
Join Date: Aug 2019
Posts: 18
Rep Power: 7
rezvani is on a distinguished road
hello. im use udf for calculate strain rate and temperature dependent viscosity. but viscosity udf don't use correct temperature and strain rate. how to solve this problem? this is my udf
Code:
# include <udf.h>
int counter=0;
DEFINE_PROPERTY(U_Visc,c,t)
{
real Temp;
real Visc;
real str;
real stress;
real asinh_input;
real asinh_output;
real b;
real Z;
real  A;
real alfa;
real blfa;
real n ;
real  Q;
real  R;/* Specific gas constant */
real  strlimit;
real Visc_limit;
real viscmin;
 A = 2.095E11 ;/* Material constant 304 ss*/
 blfa =  3.233E5;
 alfa= 0.0000050867;
 n = 1.812;
 Q = 74640;
 R = 8.314;
 Visc_limit = 2.E5;


Temp = C_T(c,t); /*0.7Tm*/
begin_c_loop(c, t)
{
 str = C_STRAIN_RATE_MAG(c,t);
b=exp(Q/(R*Temp));
Z = str*b;
asinh_input = pow(Z/A,1./n);
asinh_output = log(asinh_input + sqrt(asinh_input * asinh_input + 1));
stress = (1. /alfa)*asinh_output;
Visc = stress/(3. *str);
if ( (Visc > Visc_limit) || (str == 0) )
{
    Visc = Visc_limit;
}

if ( (Visc < 0) )
{
    Visc = 0;
}
C_UDMI(c,t,0)=stress;
C_UDMI(c,t,1)=Visc;
C_UDMI(c,t,2)=str;
C_UDMI(c,t,3)=Temp;
C_UDMI(c,t,4)=Z;
C_UDMI(c,t,5)=asinh_input;
C_UDMI(c,t,6)=asinh_output;
C_UDMI(c,t,7)=b;

if(counter<=20)
{
counter++;CX_Message("Strain= %E(1/s) Viscosity =%E PaS\n", str, Visc);
/* CX_Message("Strain*1e6= %E\n", str*1e6); */
}

return Visc;
end_c_loop(c, t)
}

}
and this is themprature diagram in udm
thank you
best regards
Rezvani
Attached Images
File Type: jpg temperror2.jpg (103.0 KB, 9 views)
File Type: jpg errortemp1d.jpg (104.9 KB, 8 views)
rezvani is offline   Reply With Quote

Old   May 24, 2021, 11:31
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Temp = C_T(c,t); /*0.7Tm*/
begin_c_loop(c, t)


Switch these two lines.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   May 24, 2021, 18:24
Default
  #3
New Member
 
yahya rezvani
Join Date: Aug 2019
Posts: 18
Rep Power: 7
rezvani is on a distinguished road
thank you .still udm s are wrong. how to fix udm?
rezvani is offline   Reply With Quote

Old   May 24, 2021, 23:06
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
try this code
Code:
# include <udf.h>
int counter=0;
DEFINE_PROPERTY(U_Visc,c,t)
{
real Temp;
real Visc;
real str;
real stress;
real asinh_input;
real asinh_output;
real b;
real Z;
real  A;
real alfa;
real blfa;
real n ;
real  Q;
real  R;/* Specific gas constant */
real  strlimit;
real Visc_limit;
real viscmin;
 A = 2.095E11 ;/* Material constant 304 ss*/
 blfa =  3.233E5;
 alfa= 0.0000050867;
 n = 1.812;
 Q = 74640;
 R = 8.314;
 Visc_limit = 2.E5;

Temp = C_T(c,t); /*0.7Tm*/
str = C_STRAIN_RATE_MAG(c,t);
b=exp(Q/(R*Temp));
Z = str*b;
asinh_input = pow(Z/A,1./n);
asinh_output = log(asinh_input + sqrt(asinh_input * asinh_input + 1));
stress = (1. /alfa)*asinh_output;
Visc = stress/(3. *str);
if ( (Visc > Visc_limit) || (str == 0) )
{
    Visc = Visc_limit;
}

if ( (Visc < 0) )
{
    Visc = 0;
}
C_UDMI(c,t,0)=stress;
C_UDMI(c,t,1)=Visc;
C_UDMI(c,t,2)=str;
C_UDMI(c,t,3)=Temp;
C_UDMI(c,t,4)=Z;
C_UDMI(c,t,5)=asinh_input;
C_UDMI(c,t,6)=asinh_output;
C_UDMI(c,t,7)=b;

if(counter<=20)
{
counter++;
Message0("Strain= %E(1/s) Viscosity =%E PaS\n", str, Visc);
/* Message0("Strain*1e6= %E\n", str*1e6); */
}

return Visc;
}
__________________
best regards


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

Old   May 25, 2021, 16:06
Default
  #5
New Member
 
yahya rezvani
Join Date: Aug 2019
Posts: 18
Rep Power: 7
rezvani is on a distinguished road
hello. if dont use begin_c_loop(c, t) fluent show this error

Code:
     4  1.0000e+00  4.1831e-02  1.6884e-02  1.7000e-02  3.5638e-04  0:22:44   46
        Stabilizing temperature to enhance linear solver robustness.
 temperature limited to 1.000000e+00 in 4967024 cells on zone 4 in domain 1
  temperature limited to 5.000000e+03 in 19391 cells on zone 4 in domain 1
 
 Artificial walls on 82 faces (0.7% area) of pressure-outlet 9 to prevent fluid from flowing into the boundary.
     5  1.0000e+00  3.9380e-02  2.1037e-02  2.0857e-02  1.6664e-03  0:27:24   45


Error at Node 1: floating point exceptiEon
rror at Node 0: floating point exception
        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing pressure correction to enhance linear solver robustness.
        Stabilizing pressure correction using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: pressure correction        Stabilizing temperature to enhance linear solver robustness.
        Stabilizing temperature using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: temperature
 Artificial walls on 5428 faces (46.2% area) of pressure-outlet 9 to prevent fluid from flowing into the boundary.

Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: pressure correction
Divergence detected in AMG solver: temperature
Error at host: floating point exception

===============Message from the Cortex Process================================

Compute processes interrupted. Processing can be resumed.

==============================================================================
how to prevent this error?
thank you
rezvani is offline   Reply With Quote

Old   May 25, 2021, 16:31
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Check those UDMs that you used. Plot them, see which one is not what you expect.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   May 26, 2021, 05:14
Default
  #7
New Member
 
yahya rezvani
Join Date: Aug 2019
Posts: 18
Rep Power: 7
rezvani is on a distinguished road
Quote:
Originally Posted by pakk View Post
Check those UDMs that you used. Plot them, see which one is not what you expect.
Hello. viscosity works well. and it match with temperature and ... .
but udm s(temperature, stress,... ) are wrong.
if i use begin_c_loop(c, t) udm s are wrong. if i dont use begin_c_loop(c, t) then give error!!
thank you.
best regards.
rezvani is offline   Reply With Quote

Old   May 26, 2021, 09:11
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
If temperature and stress are wrong, focus on that.
You don't give me much to work with, so I can't help more.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   May 27, 2021, 06:40
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
begin_c_loop(c, t) is already included in DEFINE_PROPERTY macro

you don't need to make additional loop over cell

from your log I can see the error comes out on 4th iteration. look at domain on 3th iteration, check udms distribution, analyse all variable you have applied to model:
temperature, stresses so on

Quote:
Hello. viscosity works well. and it match with temperature and ... .
if viscosity works well. and it match with temperature it means UDF works well.
in that case simulation doesn't work cause of viscosity values you've applied
rezvani likes this.
__________________
best regards


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

Reply

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 10:21
UDF srivastava and sundaresan friction model - divergence of the solutor Luca_Panariello Fluent Multiphase 1 January 18, 2017 11:07
Problem in convergence regarding constant viscosity and UDF related Viscosity. alexskerhut FLUENT 0 May 9, 2016 09:43
Problems in converging viscosity UDF dependent upon strain rate and temperature. alexskerhut Fluent UDF and Scheme Programming 1 March 17, 2016 08:19
Temperature dependent Non-Newtonian viscosity UDF cric92 Fluent UDF and Scheme Programming 0 April 14, 2013 07:31


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