Skip to main content

Blendpy uses atomistic simulations with ASE calculators to compute alloy properties like enthalpy of mixing. It supports binary and multicomponent systems, including alloys and pseudoalloys.

Project description

License: MIT PyPI

blendpy

Blendpy uses atomistic simulations with ASE calculators to compute alloy properties like enthalpy of mixing. It supports binary and multicomponent systems, including alloys and pseudoalloys.

Installation

Install blendpy easily using pip, Python’s package manager:

$ pip install blendpy

Getting started

First, import the necessary modules from ASE and MACE:

from ase.io import write
from ase.build import bulk
from ase.optimize import BFGSLineSearch
from ase.filters import UnitCellFilter

Next, create Atoms objects for gold (Au) and platinum (Pt) using the bulk function:

# Create Au and Pt Atoms object
gold = bulk("Au", cubic=True)
platinum = bulk("Pt", cubic=True)

Create a MACE calculator object to optimize the structures:

# Initialize the MACE calculator
from mace.calculators import mace_mp
calc_mace = mace_mp(model="small",
                    dispersion=False,
                    default_dtype="float32",
                    device='cpu')

Assign the calculator to the Atoms objects:

# Assign the calculator to the Atoms objects
gold.calc = calc_mace
platinum.calc = calc_mace

Optimize the unit cells of Au and Pt using the BFGSLineSearch optimizer:

# Optimize Au and Pt unit cells
optimizer_gold = BFGSLineSearch(UnitCellFilter(gold))
optimizer_platinum = BFGSLineSearch(UnitCellFilter(platinum))
optimizer_gold.run(fmax=0.01)
optimizer_platinum.run(fmax=0.01)

Save the optimized unit cells to CIF files:

# Save the optimized unit cells for Au and Pt
write("Au.cif", gold)
write("Pt.cif", platinum)

Now, import the DSIModel from blendpy and create a DSIModel object using the optimized structures:

from blendpy import DSIModel

# Create a DSIModel object
blendpy = DSIModel(alloy_components = ['Au.cif', 'Pt.cif'],
                   supercell = [2,2,2],
                   calculator=calc_mace)

Optimize the structures within the DSIModel object:

# Optimize the structures
blendpy.optimize(method=BFGSLineSearch, fmax=0.01)

Calculate the enthalpy of mixing for the AuPt alloy:

# Calculate the enthalpy of mixing
enthalpy_of_mixing = blendpy.get_enthalpy_of_mixing(npoints=101)

Plotting the enthalpy of mixing

import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots(1,1, figsize=(5,5))

x = np.linspace(0, 1, 101)
ax.set_xlabel("$x$", fontsize=20)
ax.set_ylabel("$\Delta H_{mix}$ (kJ/mol)", fontsize=20)
ax.set_xlim(0,1)
ax.set_ylim(-7,7)
ax.set_xticks(np.linspace(0,1,6))
ax.set_yticks(np.arange(-6,7,2))
ax.plot(x, enthalpy_of_mixing, color='#d53e4f', linewidth=3, label="Au$_{1-x}$Pt$_{x}$")
ax.legend(loc="best", fontsize=20)

ax.tick_params(direction='in', axis='both', which='major', labelsize=20, width=3, length=8)
ax.set_box_aspect(1)
for spine in ax.spines.values():
    spine.set_linewidth(3)

plt.tight_layout()
plt.show()

Figure 1 - Enthalpy of mixing for the AuPt alloy calculated with DSI model and MACE interatomic potentials.

Spinodal decomposition curve

# TODO: Add code to calculate and plot the spinodal decomposition curve

Phase diagram

# TODO: Add code to calculate and plot the phase diagram

License

This is an open source code under MIT License.

Acknowledgements

We thank financial support from FAPESP (Grant No. 2022/14549-3), INCT Materials Informatics (Grant No. 406447/2022-5), and CNPq (Grant No. 311324/2020-7).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blendpy-25.2.8.tar.gz (382.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blendpy-25.2.8-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file blendpy-25.2.8.tar.gz.

File metadata

  • Download URL: blendpy-25.2.8.tar.gz
  • Upload date:
  • Size: 382.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for blendpy-25.2.8.tar.gz
Algorithm Hash digest
SHA256 9cbdceeaaede4c9ad67cd4ae472ca50bde2df9a1e81a42162a898d158086e17e
MD5 42542e9b274c16f8cbabaca5b2798426
BLAKE2b-256 e673dbe3b2a740eb886c8ce4ac47aa3211848c5fad731473430ef4a603b29b06

See more details on using hashes here.

File details

Details for the file blendpy-25.2.8-py3-none-any.whl.

File metadata

  • Download URL: blendpy-25.2.8-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for blendpy-25.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 436da1bd7da2ee36f61485b4300f1f44c59f205ebe7025931f940695006df601
MD5 9aba44f4700bbedaa2c9c5f65c4d30e5
BLAKE2b-256 2bd35226a60f817df540b311d1eca9ea72585bc56641d2284f88e32cc7582bd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page