Skip to content

Commit

Permalink
Merge 07c08c9 into 9a2a907
Browse files Browse the repository at this point in the history
  • Loading branch information
bocklund committed Nov 13, 2018
2 parents 9a2a907 + 07c08c9 commit f9b0dee
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -145,7 +145,7 @@

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = 'logo.png'
html_logo = 'pycalphad-logo-withtext.png'

# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Expand Up @@ -3,7 +3,7 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. |logo| image:: logo.png
.. |logo| image:: pycalphad-logo-notext.png
:height: 20pt
:width: 20pt
:alt: Logo
Expand Down
Binary file removed docs/logo.png
Binary file not shown.
Binary file added docs/pycalphad-logo-notext.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pycalphad-logo-withtext.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions pycalphad/core/eqsolver.pyx
Expand Up @@ -301,7 +301,7 @@ def _solve_eq_at_conditions(comps, properties, phase_records, grid, conds_keys,
remove_degenerate_phases(composition_sets, [], 0.5, 100, verbose)
iterations = 0
history = []
while iterations < 10:
while (iterations < 10) and (not iter_solver.ignore_convergence):
result = _solve_and_update_if_converged(composition_sets, comps, cur_conds, problem, iter_solver)

if result.converged:
Expand All @@ -316,8 +316,11 @@ def _solve_eq_at_conditions(comps, properties, phase_records, grid, conds_keys,
if changed_phases:
result = _solve_and_update_if_converged(composition_sets, comps, cur_conds, problem, iter_solver)
chemical_potentials[:] = result.chemical_potentials
converged = result.converged
remove_degenerate_phases(composition_sets, [], 1e-3, 0, verbose)
if not iter_solver.ignore_convergence:
converged = result.converged
remove_degenerate_phases(composition_sets, [], 1e-3, 0, verbose)
else:
converged = True
if converged:
if verbose:
print('Composition Sets', composition_sets)
Expand Down
7 changes: 4 additions & 3 deletions pycalphad/core/lower_convex_hull.py
Expand Up @@ -87,6 +87,7 @@ def lower_convex_hull(global_grid, result_array):
result_array_Phase_values = result_array.Phase.values
global_grid_GM_values = global_grid.GM.values
global_grid_X_values = global_grid.X.values
num_comps = result_array.dims['component']

it = np.nditer(result_array_GM_values, flags=['multi_index'])
comp_coord_shape = tuple(len(result_array.coords[cond]) for cond in comp_conds)
Expand All @@ -109,9 +110,9 @@ def lower_convex_hull(global_grid, result_array):
idx_result_array_NP_values, idx_result_array_points_values)
# Copy phase values out
points = result_array_points_values[it.multi_index]
result_array_Phase_values[it.multi_index] = global_grid.Phase.values[indep_idx].take(points, axis=0)
result_array_X_values[it.multi_index] = global_grid.X.values[indep_idx].take(points, axis=0)
result_array_Y_values[it.multi_index] = global_grid.Y.values[indep_idx].take(points, axis=0)
result_array_Phase_values[it.multi_index][:num_comps] = global_grid.Phase.values[indep_idx].take(points, axis=0)[:num_comps]
result_array_X_values[it.multi_index][:num_comps] = global_grid.X.values[indep_idx].take(points, axis=0)[:num_comps]
result_array_Y_values[it.multi_index][:num_comps] = global_grid.Y.values[indep_idx].take(points, axis=0)[:num_comps]
# Special case: Sometimes fictitious points slip into the result
# This can happen when we calculate stoichimetric phases by themselves
if '_FAKE_' in result_array_Phase_values[it.multi_index]:
Expand Down
1 change: 1 addition & 0 deletions pycalphad/core/solver.py
Expand Up @@ -8,6 +8,7 @@

class SolverBase(object):
""""Base class for solvers."""
ignore_convergence = False
def solve(self, prob):
"""
*Implement this method.*
Expand Down
22 changes: 21 additions & 1 deletion pycalphad/tests/test_equilibrium.py
Expand Up @@ -11,7 +11,7 @@
import numpy as np
from pycalphad import Database, Model, calculate, equilibrium, EquilibriumError, ConditionError
from pycalphad.codegen.callables import build_callables
from pycalphad.core.solver import SolverBase
from pycalphad.core.solver import SolverBase, InteriorPointSolver
import pycalphad.variables as v
from pycalphad.tests.datasets import *

Expand Down Expand Up @@ -418,3 +418,23 @@ def test_equilibrium_raises_with_invalid_solver():
SolverBase instances passed to equilibrium should raise an error.
"""
equilibrium(CUO_DBF, ['O'], 'GAS', {v.T: 1000, v.P: 1e5}, solver=SolverBase())


def test_equlibrium_no_opt_solver():
"""Passing in a solver with `ignore_convergence = True` gives a result."""

class NoOptSolver(InteriorPointSolver):
ignore_convergence = True

comps = ['PB', 'SN', 'VA']
phases = list(PBSN_DBF.phases.keys())
conds = {v.T: 300, v.P: 101325, v.X('SN'): 0.50}
ipopt_solver_eq_res = equilibrium(PBSN_DBF, comps, phases, conds, solver=InteriorPointSolver(), verbose=True)
no_opt_eq_res = equilibrium(PBSN_DBF, comps, phases, conds, solver=NoOptSolver(), verbose=True)

ipopt_GM = ipopt_solver_eq_res.GM.values.squeeze()
no_opt_GM = no_opt_eq_res.GM.values.squeeze()
no_opt_MU = no_opt_eq_res.MU.values.squeeze()
assert ipopt_GM != no_opt_GM # global min energy is different from lower convex hull
assert np.allclose([-17452.5115967], no_opt_GM) # energy from lower convex hull
assert np.allclose([-19540.6522632, -15364.3709302], no_opt_MU) # chempots from lower convex hull

0 comments on commit f9b0dee

Please sign in to comment.