|
[Sponsors] |
November 6, 2019, 07:21 |
Divergence detected in AMG solver
|
#1 |
New Member
Rahul
Join Date: Jun 2019
Location: Pune
Posts: 23
Rep Power: 7 |
hello everyone i'm writing udf to calulate density of sf6 at given pressure and temperature. i have written a code as below but it is showing an error as
: Divergence detected in AMG solver im not able to find the cause of the error. someone please help me out. DEFINE_PROPERTY(density_SF6,c,t) { real tempe; real pres; real DEN_1; real DEN_2; real DEN_3; real DEN; tempe=C_T(c,t); pres=C_P(c,t); if(pres>=0 && pres<=303975) { if( tempe>=300 && tempe<=500) {DEN_1 = ((tempe-300)/200)*(-2.35e+00) +5.86e+00; DEN_2 = ((tempe-300)/200)*(-9.30e+00) +2.34e+01;} else if( tempe>=500 && tempe<=1000) {DEN_1 = ((tempe-500)/500)*(-1.75e+00) +3.51e+00; DEN_2 = ((tempe-500)/500)*(-7.07e+00) +1.41e+01;} else if( tempe>=1000 && tempe<=1500) {DEN_1 = ((tempe-1000)/500)*(-6.50e-01) +1.76e+00; DEN_2 = ((tempe-1000)/500)*(-2.45e+00) +7.03e+00;} else if( tempe>=1500 && tempe<=1800) {DEN_1 = ((tempe-1500)/300)*(-6.47e-01) +1.11e+00; DEN_2 = ((tempe-1500)/300)*(-1.81e+00) +4.58e+00;} else if( tempe>=1800 && tempe<=2000) {DEN_1 = ((tempe-1800)/200)*(-1.78e-01) +4.63e-01; DEN_2 = ((tempe-1800)/200)*(-1.40e+00) +2.77e+00;} else if( tempe>=2000 && tempe<=2200) {DEN_1 = ((tempe-2000)/200)*(-7.80e-02) +2.85e-01; DEN_2 = ((tempe-2000)/200)*(-3.60e-01) +1.37e+00;} else if( tempe>=2200 && tempe<=2400) {DEN_1 = ((tempe-2200)/200)*(-5.20e-02) +2.07e-01; DEN_2 = ((tempe-2200)/200)*(-2.55e-01) +1.01e+00;} else if( tempe>=2400 && tempe<=2600) {DEN_1 = ((tempe-2400)/200)*(-2.30e-02) +1.55e-01; DEN_2 = ((tempe-2400)/200)*(-1.71e-01) +7.55e-01;} else if( tempe>=2600 && tempe<=2800) {DEN_1 = ((tempe-2600)/200)*(-2.10e-02) +1.32e-01; DEN_2 = ((tempe-2600)/200)*(-8.60e-02) +5.84e-01;} else if( tempe>=2800 && tempe<=3000) {DEN_1 = ((tempe-2800)/200)*(-1.68e-02) +1.11e-01; DEN_2 = ((tempe-2800)/200)*(-6.90e-02) +4.98e-01;} else if( tempe>=3000 && tempe<=3200) {DEN_1 = ((tempe-3000)/200)*(-1.02e-02) +9.42e-02; DEN_2 = ((tempe-3000)/200)*(-6.20e-02) +4.29e-01;} else if( tempe>=3200 && tempe<=3400) {DEN_1 = ((tempe-3200)/200)*(-7.10e-03) +8.40e-02; DEN_2 = ((tempe-3200)/200)*(-4.20e-02) +3.67e-01;} else if( tempe>=3400 && tempe<=3600) {DEN_1 = ((tempe-3400)/200)*(-5.50e-03) +7.69e-02; DEN_2 = ((tempe-3400)/200)*(-2.80e-02) +3.25e-01;} else if( tempe>=3600 && tempe<=3800) {DEN_1 = ((tempe-3600)/200)*(-4.40e-03) +7.14e-02; DEN_2 = ((tempe-3600)/200)*(-2.20e-02) +2.97e-01;} else if( tempe>=3800 && tempe<=4000) {DEN_1 = ((tempe-3800)/200)*(-3.80e-03) +6.70e-02; DEN_2 = ((tempe-3800)/200)*(-1.80e-02) +2.75e-01;} else if( tempe>=4000 && tempe<=5000) {DEN_1 = ((tempe-4000)/1000)*(-1.30e-02) +6.32e-02; DEN_2 = ((tempe-4000)/1000)*(-5.60e-02) +2.57e-01;} else if( tempe>=5000 && tempe<=6000) {DEN_1 = ((tempe-5000)/1000)*(-8.40e-03) +5.02e-02; DEN_2 = ((tempe-5000)/1000)*(-3.40e-02) +2.01e-01;} else if( tempe>=6000 && tempe<=7000) {DEN_1 = ((tempe-6000)/1000)*(-6.00e-03) +4.18e-02; DEN_2 = ((tempe-6000)/1000)*(-2.40e-02) +1.67e-01;} else if( tempe>=7000 && tempe<=8000) {DEN_1 = ((tempe-7000)/1000)*(-4.70e-03) +3.58e-02; DEN_2 = ((tempe-7000)/1000)*(-1.80e-02) +1.43e-01;} else if( tempe>=8000 && tempe<=9000) {DEN_1 = ((tempe-8000)/1000)*(-3.90e-03) +3.11e-02; DEN_2 = ((tempe-8000)/1000)*(-1.50e-02) +1.25e-01;} else if( tempe>=9000 && tempe<=10000) {DEN_1 = ((tempe-9000)/1000)*(-3.30e-03) +2.72e-02; DEN_2 = ((tempe-9000)/1000)*(-1.22e-02) +1.10e-01;} else if( tempe>=10000 && tempe<=12000) {DEN_1 = ((tempe-10000)/2000)*(-5.10e-03) +2.39e-02; DEN_2 = ((tempe-10000)/2000)*(-2.00e-02) +9.78e-02;} else if( tempe>=12000 && tempe<=14000) {DEN_1 = ((tempe-12000)/2000)*(-3.80e-03) +1.88e-02; DEN_2 = ((tempe-12000)/2000)*(-1.48e-02) +7.78e-02;} else if( tempe>=14000 && tempe<=16000) {DEN_1 = ((tempe-14000)/2000)*(-3.80e-03) +1.50e-02; DEN_2 = ((tempe-14000)/2000)*(-1.27e-02) +6.30e-02;} else if( tempe>=16000 && tempe<=18000) {DEN_1 = ((tempe-16000)/2000)*(-2.90e-03) +1.12e-02; DEN_2 = ((tempe-16000)/2000)*(-1.17e-02) +5.03e-02;} else if( tempe>=18000 && tempe<=20000) {DEN_1 = ((tempe-18000)/2000)*(-1.65e-03) +8.30e-03; DEN_2 = ((tempe-18000)/2000)*(-8.80e-03) +3.86e-02;} else if( tempe>=20000 && tempe<=22000) {DEN_1 = ((tempe-20000)/2000)*(-9.50e-04) +6.65e-03; DEN_2 = ((tempe-20000)/2000)*(-5.40e-03) +2.98e-02;} else if( tempe>=22000 && tempe<=24000) {DEN_1 = ((tempe-22000)/2000)*(-2.00e-04) +5.70e-03; DEN_2 = ((tempe-22000)/2000)*(-3.20e-03) +2.44e-02;} else if( tempe>=24000 && tempe<=26000) {DEN_1 = ((tempe-24000)/2000)*(-9.50e-04) +5.50e-03; DEN_2 = ((tempe-24000)/2000)*(-2.30e-03) +2.12e-02;} else if( tempe>=26000 && tempe<=28000) {DEN_1 = ((tempe-26000)/2000)*(-4.10e-04) +4.55e-03; DEN_2 = ((tempe-26000)/2000)*(-1.80e-03) +1.89e-02;} else if( tempe>=28000 && tempe<=30000) {DEN_1 = ((tempe-28000)/2000)*(-4.20e-04) +4.14e-03; DEN_2 = ((tempe-28000)/2000)*(-1.71e-02) +1.71e-02;} } if(pres>=303975 && pres<=911925) { if( tempe>=300 && tempe<=500) {DEN_2 = ((tempe-300)/200)*(-9.30e+00) +2.34e+01; DEN_3 = ((tempe-300)/200)*(-2.34E+01) +5.85E+01;} else if( tempe>=500 && tempe<=1000) {DEN_2 = ((tempe-500)/500)*(-7.07e+00) +1.41e+01; DEN_3 = ((tempe-500)/500)*(-1.75E+01) +3.51E+01;} else if( tempe>=1000 && tempe<=1500) {DEN_2 = ((tempe-1000)/500)*(-2.45e+00) +7.03e+00; DEN_3 = ((tempe-1000)/500)*(-6.00E+00) +1.76E+01;} else if( tempe>=1500 && tempe<=1800) {DEN_2 = ((tempe-1500)/300)*(-1.81e+00) +4.58e+00; DEN_3 = ((tempe-1500)/300)*(-3.53E+00) +1.16E+01;} else if( tempe>=1800 && tempe<=2000) {DEN_2 = ((tempe-1800)/200)*(-1.40e+00) +2.77e+00; DEN_3 = ((tempe-1800)/200)*(-3.55E+00) +8.07;} else if( tempe>=2000 && tempe<=2200) {DEN_2 = ((tempe-2000)/200)*(-3.60e-01) +1.37e+00; DEN_3 = ((tempe-2000)/200)*(-1.78E+00) +4.52;} else if( tempe>=2200 && tempe<=2400) {DEN_2 = ((tempe-2200)/200)*(-2.55e-01) +1.01e+00; DEN_3 = ((tempe-2200)/200)*(-5.60E-01) +2.74;} else if( tempe>=2400 && tempe<=2600) {DEN_2 = ((tempe-2400)/200)*(-1.71e-01) +7.55e-01; DEN_3 = ((tempe-2400)/200)*(-5.20E-01) +2.18;} else if( tempe>=2600 && tempe<=2800) {DEN_2 = ((tempe-2600)/200)*(-8.60e-02) +5.84e-01; DEN_3 = ((tempe-2600)/200)*(-3.20E-01) +1.66;} else if( tempe>=2800 && tempe<=3000) {DEN_2 = ((tempe-2800)/200)*(-6.90e-02) +4.98e-01; DEN_3 = ((tempe-2800)/200)*(-1.80E-01) +1.34E+00;} else if( tempe>=3000 && tempe<=3200) {DEN_2 = ((tempe-3000)/200)*(-6.20e-02) +4.29e-01; DEN_3 = ((tempe-3000)/200)*(-1.50E-01) +1.16;} else if( tempe>=3200 && tempe<=3400) {DEN_2 = ((tempe-3200)/200)*(-4.20e-02) +3.67e-01; DEN_3 = ((tempe-3200)/200)*(-1.37E-01) +1.01E+00;} else if( tempe>=3400 && tempe<=3600) {DEN_2 = ((tempe-3400)/200)*(-2.80e-02) +3.25e-01; DEN_3 = ((tempe-3400)/200)*(-9.50E-02) +8.73E-01;} else if( tempe>=3600 && tempe<=3800) {DEN_2 = ((tempe-3600)/200)*(-2.20e-02) +2.97e-01; DEN_3 = ((tempe-3600)/200)*(-6.70E-02) +7.78E-01;} else if( tempe>=3800 && tempe<=4000) {DEN_2 = ((tempe-3800)/200)*(-1.80e-02) +2.75e-01; DEN_3 = ((tempe-3800)/200)*(-5.50E-02) +7.11E-01;} else if( tempe>=4000 && tempe<=5000) {DEN_2 = ((tempe-4000)/1000)*(-5.60e-02) +2.57e-01; DEN_3 = ((tempe-4000)/1000)*(-1.50E-01) +6.56E-01;} else if( tempe>=5000 && tempe<=6000) {DEN_2 = ((tempe-5000)/1000)*(-3.40e-02) +2.01e-01; DEN_3 = ((tempe-5000)/1000)*(-8.70E-02) +5.06E-01;} else if( tempe>=6000 && tempe<=7000) {DEN_2 = ((tempe-6000)/1000)*(-2.40e-02) +1.67e-01; DEN_3 = ((tempe-6000)/1000)*(-6.10E-02) +4.19E-01;} else if( tempe>=7000 && tempe<=8000) {DEN_2 = ((tempe-7000)/1000)*(-1.80e-02) +1.43e-01; DEN_3 = ((tempe-7000)/1000)*(-4.50E-02) +3.58E-01;} else if( tempe>=8000 && tempe<=9000) {DEN_2 = ((tempe-8000)/1000)*(-1.50e-02) +1.25e-01; DEN_3 = ((tempe-8000)/1000)*(-3.60E-02) +3.13E-01;} else if( tempe>=9000 && tempe<=10000) {DEN_2 = ((tempe-9000)/1000)*(-1.22e-02) +1.10e-01; DEN_3 = ((tempe-9000)/1000)*(-3.00E-02) +2.77E-01;} else if( tempe>=10000 && tempe<=12000) {DEN_2 = ((tempe-10000)/2000)*(-2.00e-02) +9.78e-02; DEN_3 = ((tempe-10000)/2000)*(-4.90E-02) +2.47E-01;} else if( tempe>=12000 && tempe<=14000) {DEN_2 = ((tempe-12000)/2000)*(-1.48e-02) +7.78e-02; DEN_3 = ((tempe-12000)/2000)*(-3.60E-02) +1.98E-01;} else if( tempe>=14000 && tempe<=16000) {DEN_2 = ((tempe-14000)/2000)*(-1.27e-02) +6.30e-02; DEN_3 = ((tempe-14000)/2000)*(-3.00E-02) +1.62E-01;} else if( tempe>=16000 && tempe<=18000) {DEN_2 = ((tempe-16000)/2000)*(-1.17e-02) +5.03e-02; DEN_3 = ((tempe-16000)/2000)*(-2.70E-02) +1.32E-01;} else if( tempe>=18000 && tempe<=20000) {DEN_2 = ((tempe-18000)/2000)*(-8.80e-03) +3.86e-02; DEN_3 = ((tempe-18000)/2000)*(-2.29E-02) +1.05E-01;} else if( tempe>=20000 && tempe<=22000) {DEN_2 = ((tempe-20000)/2000)*(-5.40e-03) +2.98e-02; DEN_3 = ((tempe-20000)/2000)*(-1.63E-02) +8.21E-02;} else if( tempe>=22000 && tempe<=24000) {DEN_2 = ((tempe-22000)/2000)*(-3.20e-03) +2.44e-02; DEN_3 = ((tempe-22000)/2000)*(-1.02E-02) +6.58E-02;} else if( tempe>=24000 && tempe<=26000) {DEN_2 = ((tempe-24000)/2000)*(-2.30e-03) +2.12e-02; DEN_3 = ((tempe-24000)/2000)*(-6.80E-03) +5.56E-02;} else if( tempe>=26000 && tempe<=28000) {DEN_2 = ((tempe-26000)/2000)*(-1.80e-03) +1.89e-02; DEN_3 = ((tempe-26000)/2000)*(-4.90E-03) +4.88E-02;} else if( tempe>=28000 && tempe<=30000) {DEN_2 = ((tempe-28000)/2000)*(-1.71e-02) +1.71e-02; DEN_3 = ((tempe-28000)/2000)*(-3.90E-03) +4.39e-02;} } if (pres == 0 ) {DEN = DEN_1;} if (pres == 303975) {DEN = DEN_2;} if (pres == 911925) {DEN = DEN_3;} if(pres>0 && pres<303975) {DEN = ((DEN_2-DEN_1)/(303975-0))*(pres-0)+ DEN_1;} if(pres>303975 && pres<1) {DEN = ((DEN_3-DEN_2)/(911925-303975))*(pres-303975)+ DEN_2;} //printf("density %f \n",DEN); return DEN; } |
|
November 6, 2019, 10:06 |
|
#2 |
Member
Join Date: Jun 2017
Posts: 39
Rep Power: 9 |
Simple question: are you using the density or the pressure based solver?
|
|
November 6, 2019, 21:20 |
|
#3 |
New Member
Rahul
Join Date: Jun 2019
Location: Pune
Posts: 23
Rep Power: 7 |
||
November 6, 2019, 21:55 |
|
#4 | |
New Member
Rahul
Join Date: Jun 2019
Location: Pune
Posts: 23
Rep Power: 7 |
Quote:
And some source term to model MHD modeling |
||
November 7, 2019, 05:36 |
|
#5 |
Member
Join Date: Jun 2017
Posts: 39
Rep Power: 9 |
I'm almost sure that this would not solve completely your problem, but:
"if(pres>303975 && pres<1)" is a condition you will never meet, since pres cannot be higher than 303975 and lower than 1 at the same time. It might be that pres never meet any conditions that you imposed, therefore no numbers are assigned to DEN. I imagine that you get some NaN in the residuals chart because of this. If you are completely sure that this routine always correctly define your density, you should check that your fluid physical properties do not violate the first and second principle of thermodynamics. That is to say: no negative cp and no negative bulk modulus. |
|
November 7, 2019, 05:57 |
|
#6 | |
New Member
Rahul
Join Date: Jun 2019
Location: Pune
Posts: 23
Rep Power: 7 |
Quote:
|
||
November 7, 2019, 06:27 |
|
#7 |
Member
Join Date: Jun 2017
Posts: 39
Rep Power: 9 |
I suggest you to use the User Defined Real Gas Model and to switch to the density based solver.
It looks like you're working at temperature and pressures levels similar to those encountered in HVCB systems. I'm I wrong? |
|
November 7, 2019, 06:39 |
|
#8 |
New Member
Rahul
Join Date: Jun 2019
Location: Pune
Posts: 23
Rep Power: 7 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PEMFC model with FLUENT | brahimchoice | FLUENT | 22 | April 19, 2020 16:44 |
Divergence detected in AMG solver: pressure correction | xinquanzhoucn | FLUENT | 5 | July 21, 2014 05:49 |
Floating point error and divergence detected | aannjj | FLUENT | 0 | July 2, 2013 04:44 |
3d vof | Smaras | FLUENT | 2 | February 19, 2013 07:58 |
Quarter Burner mesh with periosic condition | SamCanuck | FLUENT | 2 | August 31, 2011 12:34 |