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.3.2.tar.gz (412.8 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.3.2-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for blendpy-25.3.2.tar.gz
Algorithm Hash digest
SHA256 54035e24816400310eff17824402c00a2426b969ad2ab8a4fafaf0e9c0fe9ca4
MD5 c7c420d7eb30737a30dcd31e9bd4d189
BLAKE2b-256 51524f24f81dfb46ea20eba9be23aed5db8d4a52979669fec5f6d2055c8e9058

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blendpy-25.3.2-py3-none-any.whl
  • Upload date:
  • Size: 17.0 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.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e490032851f48a674072d70060b25279a572687d9613eff218c265499219f708
MD5 8900039f108aa4af9bd58de734128506
BLAKE2b-256 45d00ad7badbe707714e9070cc30c18445308fdc32636d98978cf9494b123930

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