https://github.com/robert-forrest/metallurgy

Calculates approximate properties of alloy compositions

https://github.com/robert-forrest/metallurgy

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: rsc.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.1%) to scientific vocabulary

Keywords

alloys materials materials-science metallurgy
Last synced: 6 months ago · JSON representation

Repository

Calculates approximate properties of alloy compositions

Basic Info
Statistics
  • Stars: 13
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
alloys materials materials-science metallurgy
Created almost 4 years ago · Last pushed over 2 years ago
Metadata Files
Readme License

README.md

Metallurgy

Tests Documentation Status

The Metallurgy package enables calculation of approximate properties of alloy mixtures, based on the linear mixture of elemental properties.

Installation

The metallurgy package can be installed from pypi using pip:

pip install metallurgy

Usage

Alloys

Most of the features of metallurgy are based on the concept of an alloy, a mixture of elements:

```python import metallurgy as mg

Bronze = mg.Alloy("Cu88Sn12") ```

An alloy can be defined in several ways:

```pycon

mg.Alloy("Cu50Zr50") Cu50Zr50

mg.Alloy("CuZr") Cu50Zr50

mg.Alloy("CuZrFeCo") Cu25Zr25Fe25Co25

mg.Alloy("(Fe70Co30)50Ni50") Ni50Fe35Co15

mg.Alloy("(FeCo)50Ni50") Ni50Fe25Co25

mg.Alloy({"Pt": 30, "Al": 45, "Ag": 25}) Al45Pt30Ag25 ```

While formally, an alloy is defined as "a mixture of chemical elements of which at least one is a metal", no such limitation is enforced in this package -- you can create any mixture you want.

An Alloy object has access to properties containing the percentage values of the composition, the elements in the composition, and has helper functions which can convert the composition to a simple string or even a LaTeX formatted string:

```pycon

Bronze.composition {'Cu': 0.88, 'Sn': 0.12}

Bronze.elements ['Cu', 'Sn']

Bronze.to_string() 'Cu88Sn12'

Bronze.toprettystring() 'Cu${88}$Sn${12}$' ```

Calculating alloy properties

Properties of alloys may be approximated from the properties of their constituent elements via the linear mixture rule:

$$\Sigma A = \sum{i=1}^{N} ci A_i $$

where $\Sigma A$ is the approximate mixed value of a property $A$ for an alloy that contains $N$ elements with percentages $c_i$. Similarly, the deviation of these elemental property values for the elements present in an alloy can be calculated:

$$\delta A = \sqrt{\sum{i=1}^{N} ci \left(1 - \frac{A_i}{\Sigma A}\right)^2} $$

The metallurgy package can be used to calculate a variety of approximate alloy properties:

```pycon Bronze = mg.Alloy("Cu88Sn12")

mg.linear_mixture(Bronze, "mass") 70.16568

mg.linear_mixture(Bronze, "density") 8.7566

mg.linear_mixture(Bronze, "valence") 2.24

mg.deviation(Bronze, "mass") 17.926178182133523

mg.deviation(Bronze, "density") 0.5508098038343185

mg.deviation(Bronze, "valence") 0.6499230723708769

```

Elemental data is provided by the elementy package. Metallurgy can calculate a variety of other alloy properties that are more complex than simple linear mixture or deviations of elemental properties:

```pycon

mg.enthalpy.mixingGibbsfree_energy(Bronze) -2039.0961905675026

mg.entropy.ideal_entropy(Bronze) 0.3669249912727096

mg.density.theoretical_density(Bronze) 8.554783679490685

mg.valence.d_valence(Bronze) 0.8661417322834646 ```

See our June 2022 paper "Machine-learning improves understanding of glass formation in metallic systems" that used code which later became the metallurgy package for definitions of these alloy properties.

Generating alloy datasets

Metallurgy can also be used to generate collections of alloys, either randomly or across a composition-space.

```pycon

mg.generate.binary(["Fe", "Co"], step=10) [Fe100, Fe90Co10, Fe80Co20, Fe70Co30, Fe60Co40, Fe50Co50, Co60Fe40, Co70Fe30, Co80Fe20, Co90Fe10, Co100]

mg.generate.ternary(["Fe", "Co", "Al"], step=20) [Fe100, Fe80Co20, Fe80Al20, Fe60Co40, Fe60Co20Al20, Fe60Al40, Co60Fe40, Fe40Co40Al20, Fe40Al40Co20, Al60Fe40, Co80Fe20, Co60Fe20Al20, Co40Al40Fe20, Al60Fe20Co20, Al80Fe20, Co100, Co80Al20, Co60Al40, Al60Co40, Al80Co20, Al100]

mg.generate.random_alloy() Cs28.9Db25.4Hs12Ce11.9La10.6Cu9.6Kr1.6

mg.generate.random_alloy() Ba94.5Y5.5 ```

We can apply constraints to the randomly generated alloy, such as limits on the maximum and minimum number of constituent elements, requirements on the percentage range that particular elements must be within, and whitelists of allowed elements:

```pycon

mg.generate.randomalloy(minelements=2, max_elements=3) Au50.7Hf36.3Ru13

mg.generate.randomalloy(minelements=2, maxelements=3, percentageconstraints={"Cu":{"min":0.3, "max":0.8}}) Cu63.9Sr23.9Be12.2

mg.generate.randomalloy(minelements=2, maxelements=3, percentageconstraints={"Cu":{"min":0.3, "max":0.8}}, allowed_elements=["Fe", "Cu", "Co", "Ni", "Yb"]) Yb64.8Cu30Ni5.2 ```

The process of generating random alloys can be performed in bulk to create datasets of random alloys:

```pycon

mg.generate.randomalloys(10, minelements=2, max_elements=3) [Fl94.6Xe5.4, Po64.2Tl23.3Np12.5, Tb61.6Ta38.4, Lu50.8Ho38.1In11.1, Rn69Es31, S70.4Ts29.6, Pr79.3He13.4Cm7.3, As84.3V15.7, Ge45.3Xe41.2Na13.5, Ra70.4He29.6] ```

Plotting alloy information

Once you have created a dataset of alloys, you may wish to view graphically a particular material property on a population level:

```pycon

binary, percentages = mg.generate.binary(["Cu", "Zr"]) mixingenthalpies = mg.enthalpy.mixingenthalpy(binary) mg.plots.binary(binary, mixing_enthalpies, ylabel="Mixing enthalpy (kJ/mol)") ```

CuZr binary mixing enthalpy

```pycon

ternary, percentages = mg.generate.ternary(["Cu", "Zr", "Al"]) mixingenthalpies = mg.enthalpy.mixingenthalpy(ternary) mg.plots.ternary(ternary, mixing_enthalpies, label="Mixing enthalpy (kJ/mol)") ```

CuZrAl ternary mixing enthalpy

```pycon

import matplotlib.pyplot as plt alloys = mg.generate.randomalloys(10000) plt.hist(mg.linearmixture(alloys, "density")) ```

Histogram of densities

Documentation

Documentation is available here.

Owner

  • Name: Robert Forrest
  • Login: Robert-Forrest
  • Kind: user
  • Location: UK

Full-stack Engineering. Computational Materials Science + ML

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 281
  • Total Committers: 1
  • Avg Commits per committer: 281.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Robert Forrest r****t@l****m 281

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 172 last-month
  • Total dependent packages: 2
  • Total dependent repositories: 1
  • Total versions: 31
  • Total maintainers: 1
pypi.org: metallurgy

Calculates approximate properties of alloy compositions.

  • Versions: 31
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 172 Last month
Rankings
Dependent packages count: 3.1%
Stargazers count: 19.3%
Average: 19.5%
Dependent repos count: 21.6%
Downloads: 23.5%
Forks count: 29.8%
Maintainers (1)
Last synced: 6 months ago

Dependencies

docs/requirements.txt pypi
  • sphinx *
  • sphinx-autoapi *
.github/workflows/publish-to-pypi.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/tests.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite