pycalphad package

Submodules

pycalphad.model module

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

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 or list) – Optional dictionary of parameters to be substituted in the model. A list of parameters will cause those symbols to remain symbolic. This will overwrite parameters specified in the database

None yet.

Examples

None yet.

property CPM
property CPM_MIX
property DOO
property GM
property GM_MIX
property HM
property HM_MIX
NT = 0
property SM
property SM_MIX
TC = 0
property 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
property 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.

property energy
property enthalpy
property 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

get_internal_constraints()[source]
get_multiphase_constraints(conds)[source]
gradient = None
property 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.

property mixing_energy
property mixing_enthalpy
property mixing_entropy
property mixing_heat_capacity
static mole_fraction(species_name, 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.

property reference_model

Return a Model containing only energy contributions from endmembers.

Returns

Return type

Model

Notes

The reference_model is defined such that subtracting it from the model will set the energy of the endmembers for the _MIX properties of this class to zero. The _MIX properties generated here allow users to see mixing energies on the internal degrees of freedom of this phase.

The reference_model AST can be modified in the same way as the current Model.

Ideal mixing is always added to the AST, we need to set it to zero here so that it’s not subtracted out of the reference however, we have this option so users can just see the mixing properties in terms of the parameters.

If the current model has an ordering energy as part of a partitioned model, then this special reference state is not well defined because the endmembers in the model have energetic contributions from the ordered endmember energies and the disordered mixing energies. Therefore, this reference state cannot be used sensibly for partitioned models and the energies of all reference_model.models are set to nan.

Since build_reference_model requires that Database instances are copied and new instances of Model are created, it can be computationally expensive to build the reference Model by default. This property delays building the reference_model until it is used.

shift_reference_state(reference_states, dbe, contrib_mods=None, output=('GM', 'HM', 'SM', 'CPM'), fmt_str='{}R')[source]

Add new attributes for calculating properties w.r.t. an arbitrary pure element reference state.

Parameters
  • reference_states (Iterable of ReferenceState) – Pure element ReferenceState objects. Must include all the pure elements defined in the current model.

  • dbe (Database) – Database containing the relevant parameters.

  • output (Iterable, optional) – Parameters to subtract the ReferenceState from, defaults to (‘GM’, ‘HM’, ‘SM’, ‘CPM’).

  • contrib_mods (Mapping, optional) – Map of {model contribution: new value}. Used to adjust the pure reference model contributions at the time this is called, since the models attribute of the pure element references are effectively static after calling this method.

  • fmt_str (str, optional) – String that will be formatted with the output parameter name. Defaults to “{}R”, e.g. the transformation of ‘GM’ -> ‘GMR’

static symbol_replace(obj, symbols)[source]

Substitute values of symbols into ‘obj’.

Parameters
  • obj (SymPy object) –

  • symbols (dict mapping sympy.Symbol to SymPy object) –

Returns

Return type

SymPy object

twostate_energy(dbe)[source]

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

property 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.ReferenceState(species, reference_phase, fixed_statevars=None)[source]

Bases: object

Define the phase and any fixed state variables as a reference state for a component.

fixed_statevars

Dictionary of {StateVariable: value} that will be fixed, e.g. {v.T: 298.15, v.P: 101325}

Type

dict

phase_name

Name of phase

Type

str

species

pycalphad Species variable

Type

Species

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

Bases: pycalphad.model.Model

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.

pycalphad.refdata module

pycalphad.variables module

Classes and constants for representing thermodynamic variables.

class pycalphad.variables.ChemicalPotential[source]

Bases: pycalphad.variables.StateVariable

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

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

Bases: pycalphad.variables.StateVariable

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

default_assumptions = {}
name
pycalphad.variables.MU

alias of pycalphad.variables.ChemicalPotential

class pycalphad.variables.PhaseFraction[source]

Bases: pycalphad.variables.StateVariable

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

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

Bases: pycalphad.variables.StateVariable

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

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

Bases: object

A chemical species.

name

Name of the specie

Type

string

constituents

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

Type

dict

charge

Integer charge. Can be positive or negative.

Type

int

property escaped_name

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

property number_of_atoms

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

property 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 = {}
name
pycalphad.variables.X

alias of pycalphad.variables.Composition

pycalphad.variables.Y

alias of pycalphad.variables.SiteFraction

pycalphad.variables.site_fraction

alias of pycalphad.variables.SiteFraction

Module contents