CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   viscosity udf don't use correct temperature and strain rate (https://www.cfd-online.com/Forums/fluent-udf/236306-viscosity-udf-dont-use-correct-temperature-strain-rate.html)

 rezvani May 24, 2021 07:08

viscosity udf don't use correct temperature and strain rate

2 Attachment(s)
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

 pakk May 24, 2021 10:31

Temp = C_T(c,t); /*0.7Tm*/
begin_c_loop(c, t)

Switch these two lines.

 rezvani May 24, 2021 17:24

thank you .still udm s are wrong. how to fix udm?

 AlexanderZ May 24, 2021 22:06

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; }```

 rezvani May 25, 2021 15:06

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

 pakk May 25, 2021 15:31

Check those UDMs that you used. Plot them, see which one is not what you expect.

 rezvani May 26, 2021 04:14

Quote:
 Originally Posted by pakk (Post 804653) 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.

 pakk May 26, 2021 08:11

If temperature and stress are wrong, focus on that.
You don't give me much to work with, so I can't help more.

 AlexanderZ May 27, 2021 05:40

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

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