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

Uploaded Python 3

File details

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

File metadata

  • Download URL: blendpy-25.3.3.tar.gz
  • Upload date:
  • Size: 412.9 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.3.tar.gz
Algorithm Hash digest
SHA256 59dae02999d4854209a1dae845e3c561fca5d1e078a5e326d2f8f0499dda0f08
MD5 21537d2e6540fc5c78204edc284dfa4c
BLAKE2b-256 c25290bdefb43065460de8dabd82198226b56b8b27a57f567cc217313b98b1ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blendpy-25.3.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 35ad5ff9d241c4c17a6d675fb8f5108f896f336c7d5f3a3c12353fe155185f51
MD5 346188ce5788b339ca85fd11571fbf71
BLAKE2b-256 9f5412eed38de577fea66e0150fb03803df5b657df98a93c7c36bb6129809f9a

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