kawin.Thermodynamics

class kawin.ExtraGibbsModel

Child of pycalphad Model with extra variable GE 
    GE represents any extra contribution to the Gibbs free energy 
    such as the Gibbs-Thomson contribution 

class kawin.GeneralThermodynamics(self, database, elements, phases, drivingForceMethod = ‘approximate’)

Class for defining driving force and essential functions for 
binary and multicomponent systems using pycalphad for equilibrium 
calculations 
 
Parameters 
---------- 
database : Database or str 
    pycalphad Database or file name for database 
elements : list 
    Elements to consider 
    Note: reference element must be the first index in the list 
phases : list 
    Phases involved 
    Note: matrix phase must be first index in the list 
drivingForceMethod : str (optional) 
    Method used to calculate driving force 
    Options are 'approximate' (default), 'sampling' and 'curvature' (not recommended) 

kawin.GeneralThermodynamics._forceDisorder(self, phase)

For phases using an order/disorder model, pycalphad will neglect the disordered phase unless 
it is the only phase set active, so the order and disordered portion of the phase will use the same model 
 
For the Gibbs-Thomson effect to be applied, the ordered and disordered parts of the model will need to be kept separate 
As a fix, a new phase is added to the database that uses only the disordered part of the model 

kawin.GeneralThermodynamics.clearCache(self)

Removes any cached data 
This is intended for surrogate training, where the cached data 
will be removed incase 

kawin.GeneralThermodynamics.setDrivingForceMethod(self, drivingForceMethod)

Sets method for calculating driving force 
 
Parameters 
---------- 
drivingForceMethod - str 
    Options are ['approximate', 'sampling', 'curvature'] 

kawin.GeneralThermodynamics.setDFSamplingDensity(self, density)

Sets sampling density for sampling method in driving 
force calculations 
 
Default upon initialization is 2000 
 
Parameters 
---------- 
density : int 
    Number of samples to take per degree of freedom in the phase 

kawin.GeneralThermodynamics.setEQSamplingDensity(self, density)

Sets sampling density for equilibrium calculations 
 
Default upon initialization is 500 
 
Parameters 
---------- 
density : int 
    Number of samples to take per degree of freedom in the phase 

kawin.GeneralThermodynamics.setMobility(self, mobility)

Allows user to define mobility functions 
 
mobility : dict 
    Dictionary of functions for each element (including reference) 
    Each function takes in (v.T, v.P, v.N, v.GE, site fractions) and returns mobility 
 
Optional - only required for multicomponent systems where 
    mobility terms are not defined in the TDB database 

kawin.GeneralThermodynamics.setDiffusivity(self, diffusivity)

Allows user to define diffusivity functions 
 
diffusivity : dict 
    Dictionary of functions for each element (including reference) 
    Each function takes in (v.T, v.P, v.N, v.GE, site fractions) and returns diffusivity 
 
Optional - only required for multicomponent systems where 
    diffusivity terms are not defined in the TDB database 
    and if mobility terms are not defined 

kawin.GeneralThermodynamics.setMobilityCorrection(self, element, factor)

Factor to multiply mobility by for each element 
 
Parameters 
---------- 
element : str 
    Element to set factor for 
    If 'all', factor will be set to all elements 
factor : float 
    Scaling factor 

kawin.GeneralThermodynamics._getConditions(self, x, T, gExtra = 0)

kawin.GeneralThermodynamics._createCompositionSet(self, eq, state_variables, phase, phase_amounts, idx)

kawin.GeneralThermodynamics.getEq(self, x, T, gExtra = 0, precPhase = None)

Calculates equilibrium at specified x, T, gExtra 
 
This is separated from the interfacial composition function so that this can be used for getting curvature for interfacial composition from mobility 
 
Parameters 
---------- 
x : float or array 
    Composition 
    Needs to be array for multicomponent systems 
T : float 
    Temperature 
gExtra : float 
    Gibbs-Thomson contribution (if applicable) 
precPhase : str 
    Precipitate phase (default is first precipitate) 
 
Returns 
------- 
Dataset from pycalphad equilibrium results 

kawin.GeneralThermodynamics.getLocalEq(self, x, T, gExtra = 0, precPhase = None, composition_sets = None)

kawin.GeneralThermodynamics.getInterdiffusivity(self, x, T, removeCache = True, phase = None)

Gets interdiffusivity at specified x and T 
Requires TDB database to have mobility or diffusivity parameters 
 
Parameters 
---------- 
x : float, array or 2D array 
    Composition 
    Float or array for binary systems 
    Array or 2D array for multicomponent systems 
T : float or array 
    Temperature 
    If array, must be same length as x 
        For multicomponent systems, must be same length as 0th axis 
removeCache : boolean 
    If True, recalculates equilibrium to get interdiffusivity (default) 
    If False, will use calculation from driving force calcs (if available) to compute diffusivity 
phase : str 
    Phase to compute diffusivity for (defaults to first or matrix phase) 
    This only needs to be used for multiphase diffusion simulations 
 
Returns 
------- 
interdiffusivity - will return array if T is an array 
    For binary case - float or array of floats 
    For multicomponent - matrix or array of matrices 

kawin.GeneralThermodynamics._interdiffusivitySingle(self, x, T, removeCache = True, phase = None)

Gets interdiffusivity at unique composition and temperature 
 
Parameters 
---------- 
x : float or array 
    Composition 
T : float 
    Temperature 
removeCache : boolean 
phase : str 
 
Returns 
------- 
Interdiffusivity as a matrix (will return float in binary case) 

kawin.GeneralThermodynamics.getTracerDiffusivity(self, x, T, removeCache = True, phase = None)

Gets tracer diffusivity for element el at specified x and T 
Requires TDB database to have mobility or diffusivity parameters 
 
Parameters 
---------- 
x : float, array or 2D array 
    Composition 
    Float or array for binary systems 
    Array or 2D array for multicomponent systems 
T : float or array 
    Temperature 
    If array, must be same length as x 
        For multicomponent systems, must be same length as 0th axis 
removeCache : boolean 
phase : str 
 
Returns 
------- 
tracer diffusivity - will return array if T is an array 

kawin.GeneralThermodynamics._tracerDiffusivitySingle(self, x, T, removeCache = True, phase = None)

Gets tracer diffusivity at unique composition and temperature 
 
Parameters 
---------- 
x : float or array 
    Composition 
T : float 
    Temperature 
el : str 
    Element to calculate diffusivity 
 
Returns 
------- 
Tracer diffusivity as a float 

kawin.GeneralThermodynamics.getDrivingForce(self, x, T, precPhase = None, returnComp = False, training = False)

Gets driving force using method defined upon initialization 
 
Parameters 
---------- 
x : float, array or 2D array 
    Composition of minor element in bulk matrix phase 
    For binary system, use an array for multiple compositions 
    For multicomponent systems, use a 2D array for multiple compositions 
        Where 0th axis is for indices of each composition 
T : float or array 
    Temperature in K 
    Must be same length as x if x is array or 2D array 
precPhase : str (optional) 
    Precipitate phase to consider (default is first precipitate phase in list) 
returnComp : bool (optional) 
    Whether to return composition of precipitate (defaults to False) 
 
Returns 
------- 
(driving force, precipitate composition) 
Driving force is positive if precipitate can form 
Precipitate composition will be None if driving force is negative or returnComp is False 

kawin.GeneralThermodynamics._getDrivingForceSampling(self, x, T, precPhase = None, returnComp = False, training = False)

Gets driving force for nucleation by sampling 
 
Parameters 
---------- 
x : float or array 
    Composition of minor element in bulk matrix phase 
    Use float for binary systems 
    Use array for multicomponent systems 
T : float 
    Temperature in K 
precPhase : str (optional) 
    Precipitate phase to consider (default is first precipitate phase in list) 
returnComp : bool (optional) 
    Whether to return composition of precipitate (defaults to False) 
 
Returns 
------- 
(driving force, precipitate composition) 
Driving force is positive if precipitate can form 
Precipitate composition will be None if driving force is negative or returnComp is False 

kawin.GeneralThermodynamics._getDrivingForceApprox(self, x, T, precPhase = None, returnComp = False, training = False)

Approximate method of driving force calculation 
Assumes equilibrium composition of precipitate phase 
 
Sampling method is used if driving force is negative 
 
Parameters 
---------- 
x : float or array 
    Composition of minor element in bulk matrix phase 
    Use float for binary systems 
    Use array for multicomponent systems 
T : float 
    Temperature in K 
precPhase : str (optional) 
    Precipitate phase to consider (default is first precipitate phase in list) 
returnComp : bool (optional) 
    Whether to return composition of precipitate (defaults to False) 
 
Returns 
------- 
(driving force, precipitate composition) 
Driving force is positive if precipitate can form 
Precipitate composition will be None if driving force is negative or returnComp is False 

kawin.GeneralThermodynamics._getDrivingForceCurvature(self, x, T, precPhase = None, returnComp = False, training = False)

Gets driving force from curvature of free energy function 
Assumes small saturation 
 
Sampling method is used if driving force is negative 
 
Parameters 
---------- 
x : float or array 
    Composition of minor element in bulk matrix phase 
    Use float for binary systems 
    Use array for multicomponent systems 
T : float 
    Temperature in K 
precPhase : str (optional) 
    Precipitate phase to consider (default is first precipitate phase in list) 
returnComp : bool (optional) 
    Whether to return composition of precipitate (defaults to False) 
 
Returns 
------- 
(driving force, precipitate composition) 
Driving force is positive if precipitate can form 
Precipitate composition will be None if driving force is negative or returnComp is False 

class kawin.BinaryThermodynamics(self, database, elements, phases, drivingForceMethod = ‘approximate’, interfacialCompMethod = ‘equilibrium’)

Class for defining driving force and interfacial composition functions 
for a binary system using pyCalphad and thermodynamic databases 
 
Parameters 
---------- 
database : str 
    File name for database 
elements : list 
    Elements to consider 
    Note: reference element must be the first index in the list 
phases : list 
    Phases involved 
    Note: matrix phase must be first index in the list 
drivingForceMethod : str (optional) 
    Method used to calculate driving force 
    Options are 'approximate' (default), 'sampling' and 'curvature' (not recommended) 
interfacialCompMethod: str (optional) 
    Method used to calculate interfacial composition 
    Options are 'eq' (default) and 'curvature' (not recommended) 

kawin.BinaryThermodynamics.setInterfacialMethod(self, interfacialCompMethod)

Changes method for caluclating interfacial composition 
 
Parameters 
---------- 
interfacialCompMethod - str 
    Options are ['equilibrium', 'curvature'] 

kawin.BinaryThermodynamics.setGuessComposition(self, conditions)

Sets initial composition when calculating equilibrium for interfacial energy 
 
Parameters 
---------- 
conditions : float, tuple or dict 
    Guess composition(s) to solve equilibrium for 
    This should encompass the region where a tieline can be found 
    between the matrix and precipitate phases 
    Options:    float - will set to all precipitate phases 
                tuple - (min, max dx) will set to all precipitate phases 
                dictionary {phase name: scalar or tuple} 

kawin.BinaryThermodynamics.getInterfacialComposition(self, T, gExtra = 0, precPhase = None)

Gets interfacial composition accounting for Gibbs-Thomson effect 
 
Parameters 
---------- 
T : float or array 
    Temperature in K 
gExtra : float or array (optional) 
    Extra contributions to the precipitate Gibbs free energy 
    Gibbs Thomson contribution defined as Vm * (2*gamma/R + g_Elastic) 
    Defaults to 0 
precPhase : str 
    Precipitate phase to consider (default is first precipitate in list) 
 
Note: for multiple conditions, only gExtra has to be an array 
    This will calculate compositions for multiple gExtra at the input Temperature 
 
    If T is also an array, then T and gExtra must be the same length 
    where each index will pertain to a single condition 
 
Returns 
------- 
(parent composition, precipitate composition) 
Both will be either float or array based off shape of gExtra 
Will return (None, None) if precipitate is unstable 

kawin.BinaryThermodynamics._interfacialCompositionFromEq(self, T, gExtra = 0, precPhase = None)

Gets interfacial composition by calculating equilibrum with Gibbs-Thomson effect 
 
Parameters 
---------- 
T : float 
    Temperature in K 
gExtra : float (optional) 
    Extra contributions to the precipitate Gibbs free energy 
    Gibbs Thomson contribution defined as Vm * (2*gamma/R + g_Elastic) 
    Defaults to 0 
precPhase : str 
    Precipitate phase to consider (default is first precipitate in list) 
 
Returns 
------- 
(parent composition, precipitate composition) 
Both will be either float or array based off shape of gExtra 
Will return (None, None) if precipitate is unstable 

kawin.BinaryThermodynamics._interfacialCompositionFromCurvature(self, T, gExtra = 0, precPhase = None)

Gets interfacial composition using free energy curvature 
G''(x - xM)(xP-xM) = 2*y*V/R 
 
Parameters 
---------- 
T : float 
    Temperature in K 
gExtra : float (optional) 
    Extra contributions to the precipitate Gibbs free energy 
    Gibbs Thomson contribution defined as Vm * (2*gamma/R + g_Elastic) 
    Defaults to 0 
precPhase : str 
    Precipitate phase to consider (default is first precipitate in list) 
 
Returns 
------- 
(parent composition, precipitate composition) 
Both will be either float or array based off shape of gExtra 
Will return (None, None) if precipitate is unstable 

kawin.BinaryThermodynamics.plotPhases(self, ax, T, gExtra = 0, plotGibbsOffset = False, *args, **kwargs)

Plots sampled points from the parent and precipitate phase 
 
Parameters 
---------- 
ax : Axis 
T : float 
    Temperature in K 
gExtra : float (optional) 
    Extra contributions to the Gibbs free energy of precipitate 
    Defaults to 0 
plotGibbsOffset : bool (optional) 
    If True and gExtra is not 0, the sampled points of the 
        precipitate phase will be plotted twice with gExtra and 
        with no extra Gibbs free energy contributions 
    Defualts to False 

class kawin.MulticomponentThermodynamics(self, database, elements, phases, drivingForceMethod = ‘approximate’)

Class for defining driving force and (possibly) interfacial composition functions 
for a multicomponent system using pyCalphad and thermodynamic databases 
 
Parameters 
---------- 
database : str 
    File name for database 
elements : list 
    Elements to consider 
    Note: reference element must be the first index in the list 
phases : list 
    Phases involved 
    Note: matrix phase must be first index in the list 
drivingForceMethod : str (optional) 
    Method used to calculate driving force 
    Options are 'approximate' (default), 'sampling' and 'curvature' (not recommended) 

kawin.MulticomponentThermodynamics.getInterfacialComposition(self, x, T, gExtra = 0, precPhase = None)

Gets interfacial composition by calculating equilibrum with Gibbs-Thomson effect 
 
Parameters 
---------- 
T : float or array 
    Temperature in K 
gExtra : float or array (optional) 
    Extra contributions to the precipitate Gibbs free energy 
    Gibbs Thomson contribution defined as Vm * (2*gamma/R + g_Elastic) 
    Defaults to 0 
precPhase : str 
    Precipitate phase to consider (default is first precipitate in list) 
 
Note: for multiple conditions, only gExtra has to be an array 
    This will calculate compositions for multiple gExtra at the input Temperature 
 
    If T is also an array, then T and gExtra must be the same length 
    where each index will pertain to a single condition 
 
Returns 
------- 
(parent composition, precipitate composition) 
Both will be either float or array based off shape of gExtra 
Will return (None, None) if precipitate is unstable 

kawin.MulticomponentThermodynamics._interfacialComposition(self, x, T, gExtra = 0, precPhase = None)

Gets interfacial composition, will return None, None if composition is in single phase region 
 
Parameters 
---------- 
T : float 
    Temperature in K 
gExtra : float (optional) 
    Extra contributions to the precipitate Gibbs free energy 
    Gibbs Thomson contribution defined as Vm * (2*gamma/R + g_Elastic) 
    Defaults to 0 
precPhase : str 
    Precipitate phase to consider (default is first precipitate in list) 
 
Returns 
------- 
(parent composition, precipitate composition) 
Both will be either float or array based off shape of gExtra 
Will return (None, None) if precipitate is unstable 

kawin.MulticomponentThermodynamics._curvatureFactorFromEq(self, chemical_potentials, composition_sets, precPhase=None, training = False)

Curvature factor (from Phillipes and Voorhees - 2013) 
 
Parameters 
---------- 
chemical_potentials : 1-D float64 array 
composition_sets : List[pycalphad.composition_set.CompositionSet] 
precPhase : str (optional) 
    Precipitate phase (defaults to first precipitate in list) 
training : bool (optional) 
    For surrogate training, will return None rather than previous results 
    if 2-phase region is not detected in equilibrium calculation 
 
Returns 
------- 
{D-1 dCbar / dCbar^T M-1 dCbar} - for calculating interfacial composition of matrix 
{1 / dCbar^T M-1 dCbar} - for calculating growth rate 
{Gb^-1 Ga} - for calculating precipitate composition 
beta - Impingement rate 
Ca - interfacial composition of matrix phase 
Cb - interfacial composition of precipitate phase 
 
Will return (None, None, None, None, None, None) if single phase 

kawin.MulticomponentThermodynamics.curvatureFactor(self, x, T, precPhase = None, training = False)

Curvature factor (from Phillipes and Voorhees - 2013) from composition and temperature 
This is the same as curvatureFactorEq, but will calculate equilibrium from x and T first 
 
Parameters 
---------- 
x : array 
    Composition of solutes 
T : float 
    Temperature 
precPhase : str (optional) 
    Precipitate phase (defaults to first precipitate in list) 
 
Returns 
------- 
{D-1 dCbar / dCbar^T M-1 dCbar} - for calculating interfacial composition of matrix 
{1 / dCbar^T M-1 dCbar} - for calculating growth rate 
{Gb^-1 Ga} - for calculating precipitate composition 
beta - Impingement rate 
Ca - interfacial composition of matrix phase 
Cb - interfacial composition of precipitate phase 
 
Will return (None, None, None, None, None, None) if single phase 

kawin.MulticomponentThermodynamics.getGrowthAndInterfacialComposition(self, x, T, dG, R, gExtra, precPhase = None, training = False)

Returns growth rate and interfacial compostion given Gibbs-Thomson contribution 
 
Parameters 
---------- 
x : array 
    Composition of solutes 
T : float 
    Temperature 
dG : float 
    Driving force at given x and T 
R : float or array 
    Precipitate radius 
gExtra : float or array 
    Gibbs-Thomson contribution (must be same shape as R) 
precPhase : str (optional) 
    Precipitate phase (defaults to first precipitate in list) 
 
Returns 
------- 
(growth rate, matrix composition, precipitate composition, equilibrium matrix comp, equilibrium precipitate comp) 
growth rate will be float or array based off shape of R 
matrix and precipitate composition will be array or 2D array based 
    off shape of R 

kawin.MulticomponentThermodynamics.impingementFactor(self, x, T, precPhase = None, training = False)

Returns impingement factor for nucleation rate calculations 
 
Parameters 
---------- 
x : array 
    Composition of solutes 
T : float 
    Temperature 
precPhase : str (optional) 
    Precipitate phase (defaults to first precipitate in list)