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 #362 from pyiron/code_abstraction_damask
Browse files Browse the repository at this point in the history
Code abstraction damask
  • Loading branch information
samwaseda authored Sep 3, 2024
2 parents 11bf645 + fcac73d commit 6ac4985
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 224 deletions.
12 changes: 6 additions & 6 deletions notebooks/damask/elastoplasticity_isotropic.ipynb

Large diffs are not rendered by default.

70 changes: 12 additions & 58 deletions notebooks/damask/elastoplasticity_powerlaw.ipynb

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions notebooks/damask/linearelastic.ipynb

Large diffs are not rendered by default.

30 changes: 14 additions & 16 deletions notebooks/damask/multiplerolling.ipynb

Large diffs are not rendered by default.

202 changes: 100 additions & 102 deletions notebooks/damask/tutorial.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyiron_continuum/damask/damaskjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def set_homogenization(self, **kwargs):
"""
self.input.homogenization = DAMASKCreator.homogenization(**kwargs)

def set_phase(self, composition, lattice, output_list=None):
def set_phase(self, composition, lattice=None, output_list=None):
"""
Args:
Expand Down
25 changes: 6 additions & 19 deletions pyiron_continuum/damask/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
) as damask_alarm:
from damask import GeomGrid, YAML, ConfigMaterial, seeds, Rotation
import numpy as np
import mendeleev
from pyiron_continuum.reference.mendeleev import get_atom_info

__author__ = "Muhammad Hassani"
__copyright__ = (
Expand Down Expand Up @@ -215,10 +215,13 @@ def phase(composition, elasticity, plasticity=None, lattice=None, output_list=No
"""
if lattice is None:
lattice = {"BCC": "cI", "HEX": "hP", "FCC": "cF"}[
composition_to_spacegroup(composition)
get_atom_info(name=composition)["lattice_structure"]
]
if output_list is None:
output_list = ["F", "P", "F_e", "F_p", "L_p", "O"]
if plasticity is None:
output_list = ["F", "P", "F_e"]
else:
output_list = ["F", "P", "F_e", "F_p", "L_p", "O"]
d = {
composition: {
"lattice": lattice,
Expand Down Expand Up @@ -317,19 +320,3 @@ def rotation(method="from_random", *args, **kwargs):
if isinstance(method, str):
method = getattr(Rotation, method)
return method(*args, **kwargs)


def get_element_abbreviation(name):
if len(name) <= 2:
return name
from mendeleev.fetch import fetch_table
el_table = fetch_table('elements')
cond = el_table['name'] == name
if not any(cond):
raise NameError(name, "does not exist")
return el_table[cond].iloc[0]['symbol']


def composition_to_spacegroup(composition):
abbreviation = get_element_abbreviation(composition)
return mendeleev.element(abbreviation).lattice_structure
2 changes: 1 addition & 1 deletion pyiron_continuum/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def material(rotation, elements, phase, homogenization):
return DAMASKCreator.material(rotation, elements, phase, homogenization)

@staticmethod
def phase(composition, lattice, elasticity, plasticity, output_list=None):
def phase(composition, elasticity, plasticity=None, lattice=None, output_list=None):
warnings.warn(
"Setting phase via project creator is deprecated. Use job.set_phase instead"
)
Expand Down
2 changes: 1 addition & 1 deletion pyiron_continuum/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def Homogenization(method, parameters):
return DAMASKCreator.homogenization(method, parameters)

@staticmethod
def Phase(composition, lattice, elasticity, plasticity, output_list=None):
def Phase(composition, elasticity, plasticity=None, lattice=None, output_list=None):
"""
returns a dictionary describing the phases for damask
Args:
Expand Down
7 changes: 0 additions & 7 deletions tests/unit/damask/test_damaskjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import unittest
from pyiron_base._tests import PyironTestCase
from pyiron_continuum import Project
from pyiron_continuum.damask.factory import composition_to_spacegroup


class TestDamask(PyironTestCase):
Expand Down Expand Up @@ -61,12 +60,6 @@ def test_set_phase(self):
)
self.assertIsInstance(job.input.phase, dict)

def test_composition_to_spacegroup(self):
self.assertEqual(composition_to_spacegroup("Aluminum"), "FCC")
self.assertEqual(composition_to_spacegroup("Iron"), "BCC")
self.assertEqual(composition_to_spacegroup("Magnesium"), "HEX")
self.assertRaises(NameError, composition_to_spacegroup, "Frodo")

@classmethod
def tearDownClass(cls):
cls.project.remove(enable=True)
Expand Down

0 comments on commit 6ac4985

Please sign in to comment.