Submodules¶

The model module provides support for using a Database to perform calculations under specified conditions.

exception pycalphad.model.DofError[source]

Bases: Exception

Error due to missing degrees of freedom.

class pycalphad.model.Model(dbe, comps, phase_name, parameters=None)[source]

Bases: object

Models use an abstract representation of the function for calculation of values under specified conditions.

Parameters: dbe (Database) – Database containing the relevant parameters. comps (list) – Names of components to consider in the calculation. phase_name (str) – Name of phase model to build. parameters (dict) – Optional dictionary of parameters to be substituted in the model. This will overwrite parameters specified in the database
None yet.

Examples

None yet.

CPM
CPM_MIX
DOO
GM
GM_MIX
HM
HM_MIX
NT = 0
SM
SM_MIX
TC = 0
ast

Return the full abstract syntax tree of the model.

atomic_ordering_energy(dbe)[source]

Return the atomic ordering contribution in symbolic form. Description follows Servant and Ansara, Calphad, 2001.

build_phase(dbe)[source]

Generate the symbolic form of all the contributions to this phase.

Parameters: dbe (Database) –
contributions = [('ref', 'reference_energy'), ('idmix', 'ideal_mixing_energy'), ('xsmix', 'excess_mixing_energy'), ('mag', 'magnetic_energy'), ('2st', 'twostate_energy'), ('ein', 'einstein_energy'), ('ord', 'atomic_ordering_energy')]
curie_temperature = 0
degree_of_ordering
einstein_energy(dbe)[source]

Return the energy based on the Einstein model. Note that THETA parameters are actually LN(THETA). All Redlich-Kister summation is done in log-space, then exp() is called on the result.

energy
enthalpy
entropy
excess_mixing_energy(dbe)[source]

Build the binary, ternary and higher order interaction term Here we use Redlich-Kister polynomial basis by default Here we use the Muggianu ternary extension by default Replace y_i -> y_i + (1 - sum(y involved in parameter)) / m, where m is the arity of the interaction parameter

gradient = None
heat_capacity
ideal_mixing_energy(dbe)[source]

Returns the ideal mixing energy in symbolic form.

magnetic_energy(dbe)[source]

Return the energy from magnetic ordering in symbolic form. The implemented model is the Inden-Hillert-Jarl formulation. The approach follows from the background of W. Xiong et al, Calphad, 2012.

mixing_energy
mixing_enthalpy
mixing_entropy
mixing_heat_capacity
static mole_fraction(phase_name, constituent_array, site_ratios)[source]

Return an abstract syntax tree of the mole fraction of the given species as a function of its constituent site fractions.

Note that this will treat vacancies the same as any other component, i.e., this will not give the correct _overall_ composition for sublattices containing vacancies with other components by normalizing by a factor of 1 - y_{VA}. This is because we use this routine in the order-disorder model to calculate the disordered site fractions from the ordered site fractions, so we need _all_ site fractions, including VA, to sum to unity.

moles(species)[source]

Number of moles of species or elements.

neel_temperature = 0
redlich_kister_sum(phase, param_search, param_query)[source]

Construct parameter in Redlich-Kister polynomial basis, using the Muggianu ternary parameter extension.

reference_energy(dbe)[source]

Returns the weighted average of the endmember energies in symbolic form.

static symbol_replace(symbols)[source]

Substitute values of symbols into ‘obj’.

Parameters: obj (SymPy object) – symbols (dict mapping sympy.Symbol to SymPy object) – SymPy object
twostate_energy(dbe)[source]

Return the energy from liquid-amorphous two-state model.

variables

Return state variables in the model.

xiong_magnetic_energy(dbe)[source]

Return the energy from magnetic ordering in symbolic form. The approach follows W. Xiong et al, Calphad, 2012.

class pycalphad.model.TestModel(dbf, comps, phase, solution=None, kmax=None)[source]

Test Model object for global minimization.

Equation 15.2 in: P.M. Pardalos, H.E. Romeijn (Eds.), Handbook of Global Optimization, vol. 2. Kluwer Academic Publishers, Boston/Dordrecht/London (2002)

Parameters: dbf (Database) – Ignored by TestModel but retained for API compatibility. comps (sequence) – Names of components to consider in the calculation. phase (str) – Name of phase model to build. solution (sequence, optional) – Float array locating the true minimum. Same length as ‘comps’. If not specified, randomly generated and saved to self.solution
None yet.

Examples

None yet.

Classes and constants for representing thermodynamic variables.

class pycalphad.variables.ChemicalPotential[source]

Chemical potentials are symbols with built-in assumptions of being real.

default_assumptions = {}
class pycalphad.variables.Composition[source]

Compositions are symbols with built-in assumptions of being real and nonnegative.

default_assumptions = {}
pycalphad.variables.MU
class pycalphad.variables.PhaseFraction[source]

Phase fractions are symbols with built-in assumptions of being real and nonnegative. The constructor handles formatting of the name.

default_assumptions = {}
class pycalphad.variables.SiteFraction[source]

Site fractions are symbols with built-in assumptions of being real and nonnegative. The constructor handles formatting of the name.

default_assumptions = {}
class pycalphad.variables.Species[source]

Bases: object

A chemical species.

name

string – Name of the specie

constituents

dict – Dictionary of {element: quantity} where the element is a string and the quantity a float.

charge

int – Integer charge. Can be positive or negative.

escaped_name

Name safe to embed in the variable name of complex arithmetic expressions.

number_of_atoms

Number of atoms per formula unit. Vacancies do not count as atoms.

weight

Number of grams per formula unit.

class pycalphad.variables.StateVariable[source]

Bases: sympy.core.symbol.Symbol

State variables are symbols with built-in assumptions of being real.

default_assumptions = {}
pycalphad.variables.X
pycalphad.variables.Y
pycalphad.variables.site_fraction