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.0.tar.gz (412.3 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.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: blendpy-25.3.0.tar.gz
  • Upload date:
  • Size: 412.3 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.0.tar.gz
Algorithm Hash digest
SHA256 a05a7507857f81cdbf108760b1647b617aaf60167953444067e999fa05bbbcd9
MD5 45ced60e6b6e2e04a68605bfb78fc03f
BLAKE2b-256 4d524c55484f7adb89d2464e8f625ab017061e3d3b929b86549fe1151b3ce3e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blendpy-25.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f94e2ebb7b94a059461242dd22719c99b2ba9edefc636deb855d8cc571fba353
MD5 6251e954f87550154080aa1bd7c89c9b
BLAKE2b-256 1f3a7bdff4c904d2d9dd64810559a9efa566702967f8d43648e381e769d03b82

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