better name

damask.Result is more appropriate then damask.DADF5
This commit is contained in:
Martin Diehl 2020-03-02 23:05:35 +01:00
parent c4a0bf62f0
commit 4970f22e13
7 changed files with 26 additions and 26 deletions

View File

@ -14,8 +14,8 @@ from .asciitable import ASCIItable # noqa
from .config import Material # noqa from .config import Material # noqa
from .colormaps import Colormap, Color # noqa from .colormaps import Colormap, Color # noqa
from .orientation import Symmetry, Lattice, Rotation, Orientation # noqa from .orientation import Symmetry, Lattice, Rotation, Orientation # noqa
from .dadf5 import DADF5 # noqa from .result import Result # noqa
from .dadf5 import DADF5 as Result # noqa from .result import Result as DADF5 # noqa
from .geom import Geom # noqa from .geom import Geom # noqa
from .solver import Solver # noqa from .solver import Solver # noqa

View File

@ -17,11 +17,11 @@ from . import Orientation
from . import Environment from . import Environment
from . import grid_filters from . import grid_filters
class DADF5(): class Result():
""" """
Read and write to DADF5 files. Read and write to DADF5 files.
DADF5 files contain DAMASK results. DADF5 (DAKMASK HDF5) files contain DAMASK results.
""" """
def __init__(self,fname): def __init__(self,fname):
@ -454,7 +454,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': x['meta']['Unit'], 'Unit': x['meta']['Unit'],
'Description': 'Absolute value of {} ({})'.format(x['label'],x['meta']['Description']), 'Description': 'Absolute value of {} ({})'.format(x['label'],x['meta']['Description']),
'Creator': 'dadf5.py:add_abs v{}'.format(version) 'Creator': 'result.py:add_abs v{}'.format(version)
} }
} }
def add_absolute(self,x): def add_absolute(self,x):
@ -482,7 +482,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': kwargs['unit'], 'Unit': kwargs['unit'],
'Description': '{} (formula: {})'.format(kwargs['description'],kwargs['formula']), 'Description': '{} (formula: {})'.format(kwargs['description'],kwargs['formula']),
'Creator': 'dadf5.py:add_calculation v{}'.format(version) 'Creator': 'result.py:add_calculation v{}'.format(version)
} }
} }
def add_calculation(self,label,formula,unit='n/a',description=None,vectorized=True): def add_calculation(self,label,formula,unit='n/a',description=None,vectorized=True):
@ -521,7 +521,7 @@ class DADF5():
'Description': 'Cauchy stress calculated from {} ({}) '.format(P['label'], 'Description': 'Cauchy stress calculated from {} ({}) '.format(P['label'],
P['meta']['Description'])+\ P['meta']['Description'])+\
'and {} ({})'.format(F['label'],F['meta']['Description']), 'and {} ({})'.format(F['label'],F['meta']['Description']),
'Creator': 'dadf5.py:add_Cauchy v{}'.format(version) 'Creator': 'result.py:add_Cauchy v{}'.format(version)
} }
} }
def add_Cauchy(self,P='P',F='F'): def add_Cauchy(self,P='P',F='F'):
@ -547,7 +547,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': T['meta']['Unit'], 'Unit': T['meta']['Unit'],
'Description': 'Determinant of tensor {} ({})'.format(T['label'],T['meta']['Description']), 'Description': 'Determinant of tensor {} ({})'.format(T['label'],T['meta']['Description']),
'Creator': 'dadf5.py:add_determinant v{}'.format(version) 'Creator': 'result.py:add_determinant v{}'.format(version)
} }
} }
def add_determinant(self,T): def add_determinant(self,T):
@ -574,7 +574,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': T['meta']['Unit'], 'Unit': T['meta']['Unit'],
'Description': 'Deviator of tensor {} ({})'.format(T['label'],T['meta']['Description']), 'Description': 'Deviator of tensor {} ({})'.format(T['label'],T['meta']['Description']),
'Creator': 'dadf5.py:add_deviator v{}'.format(version) 'Creator': 'result.py:add_deviator v{}'.format(version)
} }
} }
def add_deviator(self,T): def add_deviator(self,T):
@ -598,7 +598,7 @@ class DADF5():
'meta' : { 'meta' : {
'Unit': S['meta']['Unit'], 'Unit': S['meta']['Unit'],
'Description': 'Eigenvalues of {} ({})'.format(S['label'],S['meta']['Description']), 'Description': 'Eigenvalues of {} ({})'.format(S['label'],S['meta']['Description']),
'Creator': 'dadf5.py:add_eigenvalues v{}'.format(version) 'Creator': 'result.py:add_eigenvalues v{}'.format(version)
} }
} }
def add_eigenvalues(self,S): def add_eigenvalues(self,S):
@ -622,7 +622,7 @@ class DADF5():
'meta' : { 'meta' : {
'Unit': '1', 'Unit': '1',
'Description': 'Eigenvectors of {} ({})'.format(S['label'],S['meta']['Description']), 'Description': 'Eigenvectors of {} ({})'.format(S['label'],S['meta']['Description']),
'Creator': 'dadf5.py:add_eigenvectors v{}'.format(version) 'Creator': 'result.py:add_eigenvectors v{}'.format(version)
} }
} }
def add_eigenvectors(self,S): def add_eigenvectors(self,S):
@ -658,7 +658,7 @@ class DADF5():
'Unit': 'RGB (8bit)', 'Unit': 'RGB (8bit)',
'Lattice': lattice, 'Lattice': lattice,
'Description': 'Inverse Pole Figure (IPF) colors for direction/plane [{} {} {})'.format(*m), 'Description': 'Inverse Pole Figure (IPF) colors for direction/plane [{} {} {})'.format(*m),
'Creator': 'dadf5.py:add_IPFcolor v{}'.format(version) 'Creator': 'result.py:add_IPFcolor v{}'.format(version)
} }
} }
def add_IPFcolor(self,q,l): def add_IPFcolor(self,q,l):
@ -684,7 +684,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': S['meta']['Unit'], 'Unit': S['meta']['Unit'],
'Description': 'Maximum shear component of {} ({})'.format(S['label'],S['meta']['Description']), 'Description': 'Maximum shear component of {} ({})'.format(S['label'],S['meta']['Description']),
'Creator': 'dadf5.py:add_maximum_shear v{}'.format(version) 'Creator': 'result.py:add_maximum_shear v{}'.format(version)
} }
} }
def add_maximum_shear(self,S): def add_maximum_shear(self,S):
@ -711,7 +711,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': S['meta']['Unit'], 'Unit': S['meta']['Unit'],
'Description': 'Mises equivalent {} of {} ({})'.format(t,S['label'],S['meta']['Description']), 'Description': 'Mises equivalent {} of {} ({})'.format(t,S['label'],S['meta']['Description']),
'Creator': 'dadf5.py:add_Mises v{}'.format(version) 'Creator': 'result.py:add_Mises v{}'.format(version)
} }
} }
def add_Mises(self,S): def add_Mises(self,S):
@ -747,7 +747,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': x['meta']['Unit'], 'Unit': x['meta']['Unit'],
'Description': '{}-norm of {} {} ({})'.format(o,t,x['label'],x['meta']['Description']), 'Description': '{}-norm of {} {} ({})'.format(o,t,x['label'],x['meta']['Description']),
'Creator': 'dadf5.py:add_norm v{}'.format(version) 'Creator': 'result.py:add_norm v{}'.format(version)
} }
} }
def add_norm(self,x,ord=None): def add_norm(self,x,ord=None):
@ -775,7 +775,7 @@ class DADF5():
'Description': '2. Kirchhoff stress calculated from {} ({}) '.format(P['label'], 'Description': '2. Kirchhoff stress calculated from {} ({}) '.format(P['label'],
P['meta']['Description'])+\ P['meta']['Description'])+\
'and {} ({})'.format(F['label'],F['meta']['Description']), 'and {} ({})'.format(F['label'],F['meta']['Description']),
'Creator': 'dadf5.py:add_PK2 v{}'.format(version) 'Creator': 'result.py:add_PK2 v{}'.format(version)
} }
} }
def add_PK2(self,P='P',F='F'): def add_PK2(self,P='P',F='F'):
@ -813,7 +813,7 @@ class DADF5():
'Unit': '1', 'Unit': '1',
'Description': '{} coordinates of stereographic projection of pole (direction/plane) in crystal frame'\ 'Description': '{} coordinates of stereographic projection of pole (direction/plane) in crystal frame'\
.format('Polar' if polar else 'Cartesian'), .format('Polar' if polar else 'Cartesian'),
'Creator' : 'dadf5.py:add_pole v{}'.format(version) 'Creator' : 'result.py:add_pole v{}'.format(version)
} }
} }
def add_pole(self,q,p,polar=False): def add_pole(self,q,p,polar=False):
@ -843,7 +843,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': F['meta']['Unit'], 'Unit': F['meta']['Unit'],
'Description': 'Rotational part of {} ({})'.format(F['label'],F['meta']['Description']), 'Description': 'Rotational part of {} ({})'.format(F['label'],F['meta']['Description']),
'Creator': 'dadf5.py:add_rotational_part v{}'.format(version) 'Creator': 'result.py:add_rotational_part v{}'.format(version)
} }
} }
def add_rotational_part(self,F): def add_rotational_part(self,F):
@ -870,7 +870,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': T['meta']['Unit'], 'Unit': T['meta']['Unit'],
'Description': 'Spherical component of tensor {} ({})'.format(T['label'],T['meta']['Description']), 'Description': 'Spherical component of tensor {} ({})'.format(T['label'],T['meta']['Description']),
'Creator': 'dadf5.py:add_spherical v{}'.format(version) 'Creator': 'result.py:add_spherical v{}'.format(version)
} }
} }
def add_spherical(self,T): def add_spherical(self,T):
@ -897,7 +897,7 @@ class DADF5():
'meta': { 'meta': {
'Unit': F['meta']['Unit'], 'Unit': F['meta']['Unit'],
'Description': 'Strain tensor of {} ({})'.format(F['label'],F['meta']['Description']), 'Description': 'Strain tensor of {} ({})'.format(F['label'],F['meta']['Description']),
'Creator': 'dadf5.py:add_strain_tensor v{}'.format(version) 'Creator': 'result.py:add_strain_tensor v{}'.format(version)
} }
} }
def add_strain_tensor(self,F='F',t='V',m=0.0): def add_strain_tensor(self,F='F',t='V',m=0.0):
@ -932,7 +932,7 @@ class DADF5():
'Unit': F['meta']['Unit'], 'Unit': F['meta']['Unit'],
'Description': '{} stretch tensor of {} ({})'.format('Left' if t == 'V' else 'Right', 'Description': '{} stretch tensor of {} ({})'.format('Left' if t == 'V' else 'Right',
F['label'],F['meta']['Description']), F['label'],F['meta']['Description']),
'Creator': 'dadf5.py:add_stretch_tensor v{}'.format(version) 'Creator': 'result.py:add_stretch_tensor v{}'.format(version)
} }
} }
def add_stretch_tensor(self,F='F',t='V'): def add_stretch_tensor(self,F='F',t='V'):

View File

@ -4,25 +4,25 @@ import os
import pytest import pytest
import numpy as np import numpy as np
from damask import DADF5 from damask import Result
from damask import mechanics from damask import mechanics
@pytest.fixture @pytest.fixture
def default(tmp_path,reference_dir): def default(tmp_path,reference_dir):
"""Small DADF5 file in temp location for modification.""" """Small Result file in temp location for modification."""
fname = '12grains6x7x8_tensionY.hdf5' fname = '12grains6x7x8_tensionY.hdf5'
shutil.copy(os.path.join(reference_dir,fname),tmp_path) shutil.copy(os.path.join(reference_dir,fname),tmp_path)
f = DADF5(os.path.join(tmp_path,fname)) f = Result(os.path.join(tmp_path,fname))
f.set_by_time(20.0,20.0) f.set_by_time(20.0,20.0)
return f return f
@pytest.fixture @pytest.fixture
def reference_dir(reference_dir_base): def reference_dir(reference_dir_base):
"""Directory containing reference results.""" """Directory containing reference results."""
return os.path.join(reference_dir_base,'DADF5') return os.path.join(reference_dir_base,'Result')
class TestDADF5: class TestResult:
def test_time_increments(self,default): def test_time_increments(self,default):
shape = default.read_dataset(default.get_dataset_location('F'),0).shape shape = default.read_dataset(default.get_dataset_location('F'),0).shape