diff --git a/.ci_support/environment-notebooks-integration.yml b/.ci_support/environment-notebooks-integration.yml index 80baaadb..c3be7bfd 100644 --- a/.ci_support/environment-notebooks-integration.yml +++ b/.ci_support/environment-notebooks-integration.yml @@ -2,6 +2,7 @@ channels: - conda-forge dependencies: - ase =3.22.1 +- atomistics =0.1.32 - coveralls - codacy-coverage - damask =3.0.0b diff --git a/.ci_support/environment-pypi-unit.yml b/.ci_support/environment-pypi-unit.yml index cd78fa03..71be8e56 100644 --- a/.ci_support/environment-pypi-unit.yml +++ b/.ci_support/environment-pypi-unit.yml @@ -2,6 +2,7 @@ channels: - conda-forge dependencies: - coveralls +- atomistics =0.1.32 - coverage - codacy-coverage - matplotlib =3.9.2 diff --git a/pyiron_continuum/reference/elastic_constants.py b/pyiron_continuum/reference/elastic_constants.py new file mode 100644 index 00000000..d02d378e --- /dev/null +++ b/pyiron_continuum/reference/elastic_constants.py @@ -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 diff --git a/tests/unit/reference/test_elastic_constants.py b/tests/unit/reference/test_elastic_constants.py new file mode 100644 index 00000000..9fe0651c --- /dev/null +++ b/tests/unit/reference/test_elastic_constants.py @@ -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()