# kawin.GrainBoundaries

class kawin.GBFactors(self)

Defines nucleation factors for bulk, dislocation,
surface, edge and corner nucleation

This includes: surface area, volume, GB area removal, Rcrit and Gcrit

Attributes
----------
gbRemoval - factor to multiply by r**2 to get area of grain boundary removed
areaFactor - factor to multiply by r**2 to get surface area of precipitate
volumeFactor - factor to multiply by r**3 to get volume of precipitate


kawin.GBFactors.setNucleationType(self, site)

Sets nucleation site type

Parameters
----------
site - int
Index for site type based off list on top of this file


kawin.GBFactors.setFactors(self, gbEnergy, gamma)

Calculated area, volume and GB removal factors

Parameters
----------
gbEnergy - float
Grain boundary energy
gamma - float
Interfacial energy between precipitate and bulk


kawin.GBFactors.Rcrit(self, dG)

Critical radius for nucleation
This is only done for GB nucleation
Bulk and dislocation nucleation needs to account for shape factors

R* = 2 * (b * \gamma_{\alpha \alpha} - a * \gamma_{\alpha \beta}) / (3 * c * dG)

Parameters
----------
dG - float
Volumetric driving force


kawin.GBFactors.Gcrit(self, dG, Rcrit)

Critical driving force for nucleation

G* = 4/27 * (b * \gamma_{\alpha \alpha} - a * \gamma_{\alpha \beta})^3 / (c * dG)^2

or in terms of R*
G* = -R*^2 * (b * \gamma_{\alpha \alpha} - a * \gamma_{\alpha \beta} + c * r* * dG)

This is calculated in terms of R* since there is a check in the nucleation calculation that will
increase R* to minimum radius if R* is too small (very low nucleation barriers)

Parameters
----------
dG - float
Volumetric driving force
Rcrit - float