Common API Reference

This page documents the common types and functions shared across all phase field models.

Types

Interface Parameters

PhaseFields.InterfaceParamsType
InterfaceParams

Parameters for solid-liquid interface modeling.

Fields

  • W₀::Float64: Interface width parameter [m]
  • σ₀::Float64: Interface energy [J/m²]
  • τ::Float64: Relaxation time [s]
  • δ::Float64: Anisotropy strength [-]
  • n_fold::Int: Anisotropy symmetry (4=FCC, 6=HCP)

Example

# FCC metal with 4-fold anisotropy
params = InterfaceParams(
    W₀ = 1e-6,    # 1 μm interface width
    σ₀ = 0.3,     # 0.3 J/m² interface energy
    τ = 3e-8,     # 30 ns relaxation time
    δ = 0.04,     # 4% anisotropy
    n_fold = 4    # 4-fold cubic symmetry
)
source

Diffusion Parameters

PhaseFields.DiffusionParamsType
DiffusionParams

Temperature-dependent diffusion parameters.

Fields

  • D_liquid::Float64: Pre-exponential factor for liquid [m²/s]
  • D_solid::Float64: Pre-exponential factor for solid [m²/s]
  • Q_liquid::Float64: Activation energy for liquid [J/mol]
  • Q_solid::Float64: Activation energy for solid [J/mol]

Example

params = DiffusionParams(
    D_liquid = 1e-9,  # m²/s
    D_solid = 1e-13,  # m²/s
    Q_liquid = 40e3,  # 40 kJ/mol
    Q_solid = 80e3    # 80 kJ/mol
)
source

Material Parameters

PhaseFields.MaterialParamsType
MaterialParams

General material properties.

Fields

  • Vm::Float64: Molar volume [m³/mol]
  • L::Float64: Latent heat [J/mol]
  • Cp::Float64: Heat capacity [J/(mol·K)]
  • k::Float64: Thermal conductivity [W/(m·K)]
source

Interpolation Functions

Phase field models use interpolation functions h(φ) and double-well potentials g(φ) to smoothly transition between phases.

Interpolation h(φ)

Properties:

  • h(0) = 0, h(1) = 1
  • Smooth transition in interface region
using PhaseFields

φ = 0.5

# Polynomial: h = 3φ² - 2φ³
h = h_polynomial(φ)

# Sinusoidal: h = (1 - cos(πφ))/2
h = h_sin(φ)

# Derivative
dh = h_prime(φ)
PhaseFields.h_polynomialFunction
h_polynomial(φ::T) where T<:Real

Polynomial interpolation function h(φ) = 3φ² - 2φ³.

Most commonly used interpolation for phase field models. Properties: h(0) = 0, h(1) = 1, h'(0) = h'(1) = 0.

Arguments

  • φ: Order parameter ∈ [0, 1]

Returns

  • Interpolated value ∈ [0, 1]
source
PhaseFields.h_sinFunction
h_sin(φ::T) where T<:Real

Sinusoidal interpolation function h(φ) = (1 - cos(πφ))/2.

Alternative interpolation with similar properties to polynomial. Properties: h(0) = 0, h(1) = 1, h'(0) = h'(1) = 0.

Arguments

  • φ: Order parameter ∈ [0, 1]

Returns

  • Interpolated value ∈ [0, 1]
source
PhaseFields.h_primeFunction
h_prime(φ::T) where T<:Real

Derivative of polynomial interpolation: h'(φ) = 6φ(1-φ).

Analytical form for better performance than AD.

Arguments

  • φ: Order parameter ∈ [0, 1]

Returns

  • Derivative value
source

Double-Well g(φ)

Properties:

  • g(0) = g(1) = 0
  • Maximum at φ = 0.5
  • Provides energy barrier
# Standard: g = φ²(1-φ)²
g = g_standard(φ)

# Obstacle: g = |φ(1-φ)|
g = g_obstacle(φ)

# Derivatives
dg = g_prime(φ)
d2g = g_double_prime(φ)
PhaseFields.g_standardFunction
g_standard(φ::T) where T<:Real

Standard double-well potential g(φ) = φ²(1-φ)².

Properties: g(0) = g(1) = 0, minimum at φ = 0 and φ = 1. Maximum at φ = 0.5 with g(0.5) = 1/16.

Arguments

  • φ: Order parameter ∈ [0, 1]

Returns

  • Potential value ≥ 0
source
PhaseFields.g_obstacleFunction
g_obstacle(φ::T) where T<:Real

Obstacle double-well potential g(φ) = φ(1-φ).

Simpler form than standard, but with same zeros. Used in some thin-interface models.

Arguments

  • φ: Order parameter ∈ [0, 1]

Returns

  • Potential value ≥ 0
source
PhaseFields.g_primeFunction
g_prime(φ::T) where T<:Real

Derivative of standard double-well: g'(φ) = 2φ(1-φ)(1-2φ).

Analytical form for better performance than AD.

Arguments

  • φ: Order parameter ∈ [0, 1]

Returns

  • Derivative value
source
PhaseFields.g_double_primeFunction
g_double_prime(φ::T) where T<:Real

Second derivative of standard double-well: g''(φ) = 2(1 - 6φ + 6φ²).

Arguments

  • φ: Order parameter ∈ [0, 1]

Returns

  • Second derivative value
source

Anisotropy Functions

For dendritic growth, crystallographic anisotropy modifies the interface energy and kinetics.

Cubic Anisotropy (4-fold)

For FCC and BCC crystals:

θ = π/4  # Angle

# 4-fold anisotropy: a(θ) = 1 + ε cos(4θ)
a = anisotropy_cubic(θ; ε=0.05)
PhaseFields.anisotropy_cubicFunction
anisotropy_cubic(θ::T; δ::Real=0.04) where T<:Real

4-fold anisotropic interface energy for FCC/BCC crystals.

σ(θ) = 1 + δ·cos(4θ)

Arguments

  • θ: Interface normal angle [rad]
  • δ: Anisotropy strength (default: 0.04 = 4%)

Returns

  • Normalized interface energy (base value = 1)

Example

# Interface energy at θ = 0 (⟨100⟩ direction)
σ = anisotropy_cubic(0.0, δ=0.04)  # = 1.04

# Interface energy at θ = π/4 (⟨110⟩ direction)
σ = anisotropy_cubic(π/4, δ=0.04)  # = 0.96
source

HCP Anisotropy (6-fold)

For hexagonal crystals:

# 6-fold anisotropy: a(θ) = 1 + ε cos(6θ)
a = anisotropy_hcp(θ; ε=0.05)
PhaseFields.anisotropy_hcpFunction
anisotropy_hcp(θ::T; δ::Real=0.02) where T<:Real

6-fold anisotropic interface energy for HCP crystals.

σ(θ) = 1 + δ·cos(6θ)

Arguments

  • θ: Interface normal angle [rad]
  • δ: Anisotropy strength (default: 0.02 = 2%)

Returns

  • Normalized interface energy (base value = 1)
source

Custom Anisotropy

# n-fold anisotropy
a = anisotropy_custom(θ; ε=0.05, n=8)
PhaseFields.anisotropy_customFunction
anisotropy_custom(θ::T; n::Int, δ::Real) where T<:Real

n-fold anisotropic interface energy.

σ(θ) = 1 + δ·cos(n·θ)

Arguments

  • θ: Interface normal angle [rad]
  • n: Symmetry order (4 for cubic, 6 for hexagonal)
  • δ: Anisotropy strength

Returns

  • Normalized interface energy (base value = 1)
source

AD Configuration

PhaseFields.jl uses DifferentiationInterface.jl for automatic differentiation.

PhaseFields.set_ad_backend!Function
set_ad_backend!(backend)

Set the default AD backend for PhaseFields.jl.

Arguments

  • backend: A DifferentiationInterface backend (e.g., DI.AutoForwardDiff())

Example

using DifferentiationInterface
set_ad_backend!(DI.AutoForwardDiff())  # Default
# set_ad_backend!(DI.AutoEnzyme())     # For high performance (future)
source

Module

PhaseFieldsModule
PhaseFields.jl

Phase Field method simulation package for materials science. Provides domain-specific functionality for solidification modeling with CALPHAD thermodynamic coupling.

Features

  • Interface modeling (interpolation, double-well, anisotropy)
  • Phase field models (Allen-Cahn, Cahn-Hilliard, KKS, WBM)
  • CALPHAD coupling via OpenCALPHAD.jl (optional extension)
  • AD-compatible design using DifferentiationInterface.jl
source