Skip to content

Commit e646a49

Browse files
committed
change tol
1 parent 9f44b23 commit e646a49

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

burnman/optimize/nonlinear_solvers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ def constraints(x):
277277
x_j_min = (
278278
sol.x + lmda_bounds[0] * dx
279279
) # because lmda must be getting smaller, no need to check constraints
280+
281+
if np.isnan(x_j_min).any():
282+
raise Exception(f"Parameter values include np.nan: {x_j_min}.")
283+
280284
F_j_min = F(x_j_min)
281285
dxbar_j_min = lu_solve(luJ, -F_j_min)
282286
dxbar_j_min_norm = np.linalg.norm(dxbar_j_min, ord=2)

burnman/tools/equilibration.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ def set_compositions_and_state_from_parameters(assemblage, parameters):
164164
i += 1
165165

166166
if not np.all(phase_amounts > -1.0e-8):
167+
print(assemblage)
168+
print(parameters)
167169
raise Exception(
168-
f"Phase amounts should be >-1.0e-8 but they are {repr(phase_amounts)}.\n"
169-
f"Parameters: {repr(parameters)}.\n"
170-
f"{repr(assemblage)}."
170+
f"Phase amounts should be >-1.0e-8 but they are {phase_amounts}."
171171
)
172172
phase_amounts = np.abs(phase_amounts)
173173
assemblage.n_moles = sum(phase_amounts)
@@ -218,7 +218,14 @@ def F(
218218
:returns: The vector corresponding to F(x).
219219
:rtype: numpy.array
220220
"""
221-
221+
if np.isnan(x).any():
222+
raise Exception(
223+
f"Parameter values include np.nan for \n{assemblage}\n"
224+
f"Equality constraints: {equality_constraints}\n"
225+
f"Compositional vector: {reduced_composition_vector}\n"
226+
"Free compositional vectors: "
227+
f"{reduced_free_composition_vectors}."
228+
)
222229
set_compositions_and_state_from_parameters(assemblage, x)
223230
new_endmember_amounts = get_endmember_amounts(assemblage)
224231

misc/benchmarks/slb_2024_benchmarks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ def check_fig_3_fcc_ferric_fper():
190190

191191
composition = {"Fe": 1.0, "O": 1.0}
192192
assemblage = Composite([bcc, fper, mag], [0.5, 0.49, 0.01])
193-
fper.set_composition([0.05, 0.0, 0.95])
193+
fper.set_composition([0.04, 0.01, 0.95])
194194
equality_constraints = [["P", 1.0e5], ["phase_fraction", (mag, 0.0)]]
195-
sol = equilibrate(composition, assemblage, equality_constraints, tol=1.0e-5)
195+
sol = equilibrate(composition, assemblage, equality_constraints)
196196
T_a_wu_mag = sol[0].assemblage.temperature
197197
print(f"BCC-fper-mag triple point at 1 bar: {T_a_wu_mag:.2f} K")
198198

0 commit comments

Comments
 (0)