better not have a "Lattice" object with "lattice" parameter

This commit is contained in:
Martin Diehl 2021-06-07 21:49:04 +02:00
parent 41e5f0c06c
commit 5202da13ea
4 changed files with 19 additions and 19 deletions

View File

@ -18,7 +18,7 @@ from . import grid_filters # noqa
#For example, '_colormap' containsa class called 'Colormap' which is imported as 'damask.Colormap'.
from ._rotation import Rotation # noqa
from ._lattice_family import LatticeFamily # noqa
from ._lattice import Lattice # noqa
from ._crystal import Crystal # noqa
from ._orientation import Orientation # noqa
from ._table import Table # noqa
from ._vtk import VTK # noqa

View File

@ -26,7 +26,7 @@ lattice_symmetries = {
}
class Lattice(LatticeFamily):
class Crystal(LatticeFamily):
"""Lattice."""
def __init__(self,*,

View File

@ -4,7 +4,7 @@ import copy
import numpy as np
from . import Rotation
from . import Lattice
from . import Crystal
from . import util
from . import tensor
@ -55,7 +55,7 @@ _parameter_doc = \
"""
class Orientation(Rotation,Lattice):
class Orientation(Rotation,Crystal):
"""
Representation of crystallographic orientation as combination of rotation and either crystal family or Bravais lattice.
@ -131,7 +131,7 @@ class Orientation(Rotation,Lattice):
"""
Rotation.__init__(self,rotation)
Lattice.__init__(self,family=family, lattice=lattice,
Crystal.__init__(self,family=family, lattice=lattice,
a=a,b=b,c=c, alpha=alpha,beta=beta,gamma=gamma, degrees=degrees)
@ -831,7 +831,7 @@ class Orientation(Rotation,Lattice):
"""
lattice,o = self.relation_operations(model)
target = Lattice(lattice=lattice)
target = Crystal(lattice=lattice)
o = o.broadcast_to(o.shape+self.shape,mode='right')
return Orientation(rotation=o*Rotation(self.quaternion).broadcast_to(o.shape,mode='left'),
lattice=lattice,

View File

@ -1,19 +1,19 @@
import pytest
import numpy as np
from damask import Lattice
from damask import Crystal
class TestLattice:
class TestCrystal:
def test_double_to_lattice(self):
L = Lattice(lattice='cF')
c = Crystal(lattice='cF')
with pytest.raises(KeyError):
L.to_lattice(direction=np.ones(3),plane=np.ones(3))
c.to_lattice(direction=np.ones(3),plane=np.ones(3))
def test_double_to_frame(self):
L = Lattice(lattice='cF')
c = Crystal(lattice='cF')
with pytest.raises(KeyError):
L.to_frame(uvw=np.ones(3),hkl=np.ones(3))
c.to_frame(uvw=np.ones(3),hkl=np.ones(3))
@pytest.mark.parametrize('lattice,a,b,c,alpha,beta,gamma',
[
@ -25,10 +25,10 @@ class TestLattice:
('cF',1.0,1.0,None,np.pi/2,np.pi/2,np.pi/2),
])
def test_bases_contraction(self,lattice,a,b,c,alpha,beta,gamma):
L = Lattice(lattice=lattice,
c = Crystal(lattice=lattice,
a=a,b=b,c=c,
alpha=alpha,beta=beta,gamma=gamma)
assert np.allclose(np.eye(3),np.einsum('ik,jk',L.basis_real,L.basis_reciprocal))
assert np.allclose(np.eye(3),np.einsum('ik,jk',c.basis_real,c.basis_reciprocal))
@pytest.mark.parametrize('keyFrame,keyLattice',[('uvw','direction'),('hkl','plane'),])
@ -50,15 +50,15 @@ class TestLattice:
('cF',1.0,1.0,1.0,np.pi/2,np.pi/2,np.pi/2),
])
def test_to_frame_to_lattice(self,lattice,a,b,c,alpha,beta,gamma,vector,keyFrame,keyLattice):
L = Lattice(lattice=lattice,
c = Crystal(lattice=lattice,
a=a,b=b,c=c,
alpha=alpha,beta=beta,gamma=gamma)
assert np.allclose(vector,
L.to_frame(**{keyFrame:L.to_lattice(**{keyLattice:vector})}))
c.to_frame(**{keyFrame:c.to_lattice(**{keyLattice:vector})}))
@pytest.mark.parametrize('model',['Bain','KS','GT','GT_prime','NW','Pitsch','Burgers'])
def test_relationship_definition(self,model):
m,o = list(Lattice._orientation_relationships[model])
assert Lattice._orientation_relationships[model][m].shape[:-1] == \
Lattice._orientation_relationships[model][o].shape[:-1]
m,o = list(Crystal._orientation_relationships[model])
assert Crystal._orientation_relationships[model][m].shape[:-1] == \
Crystal._orientation_relationships[model][o].shape[:-1]