Skip to content

Commit 8ff0135

Browse files
committed
increase default numerical accuracy (by decreasing tolerance)
1 parent 1e6420a commit 8ff0135

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

thermosteam/equilibrium/bubble_point.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ class BubblePoint:
112112
__slots__ = ('chemicals', 'IDs', 'gamma', 'phi', 'pcf',
113113
'Psats', 'Tmin', 'Tmax', 'Pmin', 'Pmax')
114114
_cached = {}
115-
maxiter = 50
116-
T_tol = 1e-9
117-
P_tol = 1e-3
115+
maxiter = 100
116+
T_tol = 1e-12
117+
P_tol = 1e-6
118118
def __new__(cls, chemicals=None, thermo=None):
119119
thermo = settings.get_default_thermo(thermo)
120120
if chemicals is None:

thermosteam/equilibrium/vle.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
@njit(cache=True)
3131
def xy(x, Ks):
32-
x[x < 0] = 1e-16
32+
x[x < 0] = 1e-64
3333
x /= x.sum()
3434
y = x * Ks
3535
y /= y.sum()
@@ -66,13 +66,13 @@ def xVlogK_iter_2n(xVlogK, pcf_Psat_over_P, T, P, z, f_gamma, gamma_args, f_phi,
6666
V = binary.compute_phase_fraction_2N(z, Ks)
6767
if gas_conversion:
6868
z = z + gas_conversion(material=y * V, T=T, P=P, phase='g')
69-
z[z <= 0] = 1e-16
69+
z[z <= 0] = 1e-64
7070
z /= z.sum()
7171
if liquid_conversion:
7272
z = z + liquid_conversion(material=x * (1 - V), T=T, P=P, phase='l')
73-
z[z <= 0] = 1e-16
73+
z[z <= 0] = 1e-64
7474
z /= z.sum()
75-
Ks[Ks < 1e-16] = 1e-16
75+
Ks[Ks < 1e-64] = 1e-64
7676
xVlogK[n] = V = binary.compute_phase_fraction_2N(z, Ks)
7777
xVlogK[:n] = z/(1. + V * (Ks - 1.))
7878
xVlogK[n+1:] = np.log(Ks)
@@ -94,13 +94,13 @@ def xVlogK_iter(
9494
if gas_conversion or liquid_conversion:
9595
if gas_conversion:
9696
z = z + gas_conversion(material=y * V, T=T, P=P, phase='g')
97-
z[z <= 0] = 1e-16
97+
z[z <= 0] = 1e-64
9898
z /= z.sum()
9999
if liquid_conversion:
100100
z = z + liquid_conversion(material=x * (1 - V), T=T, P=P, phase='l')
101-
z[z <= 0] = 1e-16
101+
z[z <= 0] = 1e-64
102102
z /= z.sum()
103-
Ks[Ks < 1e-16] = 1e-16
103+
Ks[Ks < 1e-64] = 1e-64
104104
xVlogK[n] = V = binary.solve_phase_fraction_Rashford_Rice(z, Ks, V, z_light, z_heavy)
105105
xVlogK[:n] = z / (1. + V * (Ks - 1.))
106106
xVlogK[n+1:] = np.log(Ks)
@@ -313,14 +313,14 @@ class VLE(Equilibrium, phases='lg'):
313313
'_dF_mol',
314314
'_vle_chemicals',
315315
)
316-
maxiter = 20
317-
T_tol = 5e-8
318-
P_tol = 1.
319-
H_hat_tol = 1e-6
320-
S_hat_tol = 1e-6
321-
V_tol = 1e-6
322-
x_tol = 1e-8
323-
y_tol = 1e-8
316+
maxiter = 50
317+
T_tol = 1e-12
318+
P_tol = 1e-6
319+
H_hat_tol = 1e-9
320+
S_hat_tol = 1e-9
321+
V_tol = 1e-16
322+
x_tol = 1e-16
323+
y_tol = 1e-16
324324
default_method = 'fixed-point'
325325

326326
def __init__(self, imol=None, thermal_condition=None,
@@ -1384,7 +1384,7 @@ def _solve_v_fixed_point(self, pcf_Psat_over_P, T, P, gas_conversion, liquid_con
13841384
gas_conversion, liquid_conversion)
13851385
xVlogK = np.zeros(2 * n + 1)
13861386
xVlogK[n] = V = self._V
1387-
K[K < 1e-16] = 1e-16
1387+
K[K < 1e-64] = 1e-64
13881388
xVlogK[:n] = z/(1. + V * (K - 1.))
13891389
xVlogK[n+1:] = np.log(K)
13901390
xVlogK = flx.aitken(

0 commit comments

Comments
 (0)