Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #360 from pyiron/import_atomistics
Browse files Browse the repository at this point in the history
Import atomistics
  • Loading branch information
samwaseda authored Sep 3, 2024
2 parents 81e8741 + 1475ecb commit 9cf8365
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions .ci_support/environment-notebooks-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ channels:
- conda-forge
dependencies:
- ase =3.22.1
- atomistics =0.1.32
- coveralls
- codacy-coverage
- damask =3.0.0b
Expand Down
1 change: 1 addition & 0 deletions .ci_support/environment-pypi-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ channels:
- conda-forge
dependencies:
- coveralls
- atomistics =0.1.32
- coverage
- codacy-coverage
- matplotlib =3.9.2
Expand Down
27 changes: 27 additions & 0 deletions pyiron_continuum/reference/elastic_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# coding: utf-8
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.


from atomistics.referencedata.wikipedia import get_elastic_properties


def get_elastic_constants(chemical_symbol):
"""
Get the elastic tensor of a material from the wikipedia database.
Args:
chemical_symbol (str): Chemical symbol of the element.
Returns:
dict: Dictionary with the elastic tensor of the material (isotropic).
"""
d = get_elastic_properties(chemical_symbol)
G = d["shear_modulus"]
v = d["poissons_ratio"]
E = d["youngs_modulus"]
C_11 = E * (1 - v) / (1 + v) / (1 - 2 * v)
C_12 = E * v / (1 + v) / (1 - 2 * v)
C_44 = G
d.update({"C_11": C_11, "C_12": C_12, "C_44": C_44})
return d
20 changes: 20 additions & 0 deletions tests/unit/reference/test_elastic_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# coding: utf-8
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.

import unittest
from pyiron_continuum.reference.elastic_constants import get_elastic_constants
import numpy as np


class TestDecorators(unittest.TestCase):
def test_elastic_constants(self):
d = get_elastic_constants("Fe")
self.assertTrue(all(key in d for key in ["C_11", "C_12", "C_44"]))
for value in d.values():
self.assertTrue(np.isscalar(value))
self.assertGreater(value, 0)


if __name__ == "__main__":
unittest.main()

0 comments on commit 9cf8365

Please sign in to comment.