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

Commit

Permalink
add elastic_constants
Browse files Browse the repository at this point in the history
  • Loading branch information
samwaseda committed Sep 3, 2024
1 parent 48201c2 commit 12be3d2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pyiron_continuum/reference/elastic_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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 numpy as np
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 12be3d2

Please sign in to comment.