Skip to content

Phase Field Model (Cahn-Hilliard)

Optional dependency

Phase Field Model requires calphad. Plotting/visualization support additionally requires plots.

uv add "materialsframework[calphad]"

# For plotting/visualization support
uv add "materialsframework[calphad,plots]"
pip install "materialsframework[calphad]"

# For plotting/visualization support
pip install "materialsframework[calphad,plots]"

Simulates phase separation on a 2D grid by solving the Cahn-Hilliard equation, with the local free energy landscape imported directly from a CALPHAD database.

from materialsframework.tools import MaterialParameters, PhaseFieldModel, SimulationGrid

params = MaterialParameters(
    db="Al-Ni.tdb",
    temperature=800,
    component="NI",
    composition=0.3,
    elements=["AL", "NI"],
    phase="FCC_A1",
)
grid = SimulationGrid(nx=128, ny=128)

model = PhaseFieldModel(material_properties=params, simulation_grid=grid, stop_iter=20000, wrt_cycle=2000)
model.run_simulation(plot=True)

See Theory for the derivation, or the API Reference for the full parameter list.