Merge branch 'misc-improvements' into less-shell-scripts
This commit is contained in:
commit
0fe450a033
|
@ -568,9 +568,8 @@ class Result:
|
|||
'label': 'sigma',
|
||||
'meta': {
|
||||
'Unit': P['meta']['Unit'],
|
||||
'Description': 'Cauchy stress calculated from {} ({}) '.format(P['label'],
|
||||
P['meta']['Description'])+\
|
||||
'and {} ({})'.format(F['label'],F['meta']['Description']),
|
||||
'Description': 'Cauchy stress calculated from {} ({}) and {} ({})'\
|
||||
.format(P['label'],P['meta']['Description'],F['label'],F['meta']['Description']),
|
||||
'Creator': inspect.stack()[0][3][1:]
|
||||
}
|
||||
}
|
||||
|
@ -638,17 +637,24 @@ class Result:
|
|||
|
||||
|
||||
@staticmethod
|
||||
def _add_eigenvalue(T_sym):
|
||||
def _add_eigenvalue(T_sym,eigenvalue):
|
||||
if eigenvalue == 'max':
|
||||
label,p = 'Maximum',2
|
||||
elif eigenvalue == 'mid':
|
||||
label,p = 'Intermediate',1
|
||||
elif eigenvalue == 'min':
|
||||
label,p = 'Minimum',0
|
||||
|
||||
return {
|
||||
'data': mechanics.eigenvalues(T_sym['data']),
|
||||
'label': 'lambda({})'.format(T_sym['label']),
|
||||
'data': mechanics.eigenvalues(T_sym['data'])[:,p],
|
||||
'label': 'lambda_{}({})'.format(eigenvalue,T_sym['label']),
|
||||
'meta' : {
|
||||
'Unit': T_sym['meta']['Unit'],
|
||||
'Description': 'Eigenvalues of {} ({})'.format(T_sym['label'],T_sym['meta']['Description']),
|
||||
'Description': '{} eigenvalue of {} ({})'.format(label,T_sym['label'],T_sym['meta']['Description']),
|
||||
'Creator': inspect.stack()[0][3][1:]
|
||||
}
|
||||
}
|
||||
def add_eigenvalues(self,T_sym):
|
||||
def add_eigenvalue(self,T_sym,eigenvalue='max'):
|
||||
"""
|
||||
Add eigenvalues of symmetric tensor.
|
||||
|
||||
|
@ -656,33 +662,46 @@ class Result:
|
|||
----------
|
||||
T_sym : str
|
||||
Label of symmetric tensor dataset.
|
||||
eigenvalue : str, optional
|
||||
Eigenvalue. Select from ‘max’, ‘mid’, ‘min’. Defaults to ‘max’.
|
||||
|
||||
"""
|
||||
self._add_generic_pointwise(self._add_eigenvalue,{'T_sym':T_sym})
|
||||
self._add_generic_pointwise(self._add_eigenvalue,{'T_sym':T_sym},{'eigenvalue':eigenvalue})
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _add_eigenvector(T_sym):
|
||||
def _add_eigenvector(T_sym,eigenvalue):
|
||||
if eigenvalue == 'max':
|
||||
label,p = 'maximum',2
|
||||
elif eigenvalue == 'mid':
|
||||
label,p = 'intermediate',1
|
||||
elif eigenvalue == 'min':
|
||||
label,p = 'minimum',0
|
||||
print('p',eigenvalue)
|
||||
return {
|
||||
'data': mechanics.eigenvectors(T_sym['data']),
|
||||
'label': 'v({})'.format(T_sym['label']),
|
||||
'data': mechanics.eigenvectors(T_sym['data'])[:,p],
|
||||
'label': 'v_{}({})'.format(eigenvalue,T_sym['label']),
|
||||
'meta' : {
|
||||
'Unit': '1',
|
||||
'Description': 'Eigenvectors of {} ({})'.format(T_sym['label'],T_sym['meta']['Description']),
|
||||
'Description': 'Eigenvector corresponding to {} eigenvalue of {} ({})'\
|
||||
.format(label,T_sym['label'],T_sym['meta']['Description']),
|
||||
'Creator': inspect.stack()[0][3][1:]
|
||||
}
|
||||
}
|
||||
def add_eigenvectors(self,T_sym):
|
||||
def add_eigenvector(self,T_sym,eigenvalue='max'):
|
||||
"""
|
||||
Add eigenvectors of symmetric tensor.
|
||||
Add eigenvector of symmetric tensor.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
T_sym : str
|
||||
Label of symmetric tensor dataset.
|
||||
eigenvalue : str, optional
|
||||
Eigenvalue to which the eigenvector corresponds. Select from
|
||||
‘max’, ‘mid’, ‘min’. Defaults to ‘max’.
|
||||
|
||||
"""
|
||||
self._add_generic_pointwise(self._add_eigenvector,{'T_sym':T_sym})
|
||||
self._add_generic_pointwise(self._add_eigenvector,{'T_sym':T_sym},{'eigenvalue':eigenvalue})
|
||||
|
||||
|
||||
@staticmethod
|
||||
|
@ -819,9 +838,8 @@ class Result:
|
|||
'label': 'S',
|
||||
'meta': {
|
||||
'Unit': P['meta']['Unit'],
|
||||
'Description': '2. Kirchhoff stress calculated from {} ({}) '.format(P['label'],
|
||||
P['meta']['Description'])+\
|
||||
'and {} ({})'.format(F['label'],F['meta']['Description']),
|
||||
'Description': '2. Piola-Kirchhoff stress calculated from {} ({}) and {} ({})'\
|
||||
.format(P['label'],P['meta']['Description'],F['label'],F['meta']['Description']),
|
||||
'Creator': inspect.stack()[0][3][1:]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,68 +1,4 @@
|
|||
68 header
|
||||
geom_fromVoronoiTessellation 2.0.3-1073-g6f3cb071
|
||||
<texture>
|
||||
[Grain1]
|
||||
(gauss) phi1 358.98 Phi 65.62 phi2 24.48
|
||||
[Grain2]
|
||||
(gauss) phi1 121.05 Phi 176.11 phi2 295.73
|
||||
[Grain3]
|
||||
(gauss) phi1 43.79 Phi 113.76 phi2 345.90
|
||||
[Grain4]
|
||||
(gauss) phi1 265.15 Phi 62.52 phi2 299.71
|
||||
[Grain5]
|
||||
(gauss) phi1 221.23 Phi 26.54 phi2 207.05
|
||||
[Grain6]
|
||||
(gauss) phi1 249.81 Phi 61.47 phi2 152.14
|
||||
[Grain7]
|
||||
(gauss) phi1 332.45 Phi 99.16 phi2 345.34
|
||||
[Grain8]
|
||||
(gauss) phi1 312.27 Phi 118.27 phi2 181.59
|
||||
[Grain9]
|
||||
(gauss) phi1 303.10 Phi 48.21 phi2 358.03
|
||||
[Grain10]
|
||||
(gauss) phi1 338.26 Phi 48.11 phi2 176.78
|
||||
[Grain11]
|
||||
(gauss) phi1 115.17 Phi 56.54 phi2 223.84
|
||||
[Grain12]
|
||||
(gauss) phi1 281.04 Phi 97.48 phi2 27.94
|
||||
<microstructure>
|
||||
[Grain1]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 1 fraction 1.0
|
||||
[Grain2]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 2 fraction 1.0
|
||||
[Grain3]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 3 fraction 1.0
|
||||
[Grain4]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 4 fraction 1.0
|
||||
[Grain5]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 5 fraction 1.0
|
||||
[Grain6]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 6 fraction 1.0
|
||||
[Grain7]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 7 fraction 1.0
|
||||
[Grain8]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 8 fraction 1.0
|
||||
[Grain9]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 9 fraction 1.0
|
||||
[Grain10]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 10 fraction 1.0
|
||||
[Grain11]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 11 fraction 1.0
|
||||
[Grain12]
|
||||
crystallite 1
|
||||
(constituent) phase 1 texture 12 fraction 1.0
|
||||
<!skip>
|
||||
4 header
|
||||
grid a 6 b 7 c 8
|
||||
size x 0.75 y 0.875 z 1.0
|
||||
origin x 0.0 y 0.0 z 0.0
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
4 header
|
||||
grid a 6 b 7 c 8
|
||||
size x 0.75 y 0.875 z 1.0
|
||||
origin x 0.0 y 0.0 z 0.0
|
||||
homogenization 1
|
||||
3 3 3 4 3 3
|
||||
3 1 1 1 3 3
|
||||
3 5 1 1 1 3
|
||||
1 5 5 1 1 1
|
||||
1 5 5 1 1 1
|
||||
6 3 3 4 1 6
|
||||
6 3 3 4 4 6
|
||||
6 3 3 1 3 3
|
||||
3 1 1 1 3 3
|
||||
3 1 1 1 1 1
|
||||
1 1 1 1 1 1
|
||||
6 6 3 1 1 1
|
||||
6 3 3 3 6 6
|
||||
6 3 3 3 6 6
|
||||
6 3 3 1 1 6
|
||||
3 1 1 1 1 3
|
||||
6 1 1 1 2 2
|
||||
1 6 2 2 2 2
|
||||
6 6 2 2 2 6
|
||||
6 3 3 3 6 6
|
||||
6 3 3 3 6 6
|
||||
5 6 6 6 1 6
|
||||
6 6 6 6 2 2
|
||||
6 6 6 2 2 2
|
||||
2 6 2 2 2 2
|
||||
6 5 2 2 2 2
|
||||
6 5 5 2 2 6
|
||||
5 5 5 3 6 6
|
||||
5 5 6 6 6 5
|
||||
6 6 6 6 6 6
|
||||
6 6 6 6 2 2
|
||||
4 4 6 2 2 2
|
||||
4 4 2 2 2 2
|
||||
5 5 5 2 2 2
|
||||
5 5 5 5 2 5
|
||||
5 5 5 4 4 5
|
||||
6 6 6 6 4 4
|
||||
4 4 5 5 2 4
|
||||
4 4 5 2 2 4
|
||||
4 4 2 2 2 2
|
||||
5 5 5 2 2 2
|
||||
5 5 5 4 4 5
|
||||
5 5 4 4 4 3
|
||||
4 5 5 5 4 3
|
||||
4 4 5 5 5 4
|
||||
4 4 5 5 2 4
|
||||
4 4 2 2 2 2
|
||||
5 5 2 2 2 2
|
||||
5 5 4 4 4 4
|
||||
3 4 4 4 4 3
|
||||
3 5 5 4 3 3
|
||||
4 5 5 5 3 3
|
||||
4 5 5 5 1 1
|
||||
4 4 5 2 1 1
|
||||
6 4 4 4 4 1
|
||||
3 4 4 4 4 3
|
Binary file not shown.
|
@ -124,6 +124,3 @@ a_slip 2.25
|
|||
h0_slipslip 75e6
|
||||
interaction_slipslip 1 1 1.4 1.4 1.4 1.4
|
||||
atol_resistance 1
|
||||
|
||||
<crystallite>
|
||||
[dummy]
|
||||
|
|
|
@ -20,6 +20,13 @@ def default(tmp_path,reference_dir):
|
|||
f.pick('times',20.0)
|
||||
return f
|
||||
|
||||
@pytest.fixture
|
||||
def single_phase(tmp_path,reference_dir):
|
||||
"""Single phase Result file in temp location for modification."""
|
||||
fname = '6grains6x7x8_single_phase_tensionY.hdf5'
|
||||
shutil.copy(os.path.join(reference_dir,fname),tmp_path)
|
||||
return Result(os.path.join(tmp_path,fname))
|
||||
|
||||
@pytest.fixture
|
||||
def reference_dir(reference_dir_base):
|
||||
"""Directory containing reference results."""
|
||||
|
@ -125,21 +132,23 @@ class TestResult:
|
|||
in_file = default.read_dataset(loc['s_P'],0)
|
||||
assert np.allclose(in_memory,in_file)
|
||||
|
||||
def test_add_eigenvalues(self,default):
|
||||
@pytest.mark.parametrize('eigenvalue,function',[('max',np.amax),('min',np.amin)])
|
||||
def test_add_eigenvalue(self,default,eigenvalue,function):
|
||||
default.add_Cauchy('P','F')
|
||||
default.add_eigenvalues('sigma')
|
||||
loc = {'sigma' :default.get_dataset_location('sigma'),
|
||||
'lambda(sigma)':default.get_dataset_location('lambda(sigma)')}
|
||||
in_memory = mechanics.eigenvalues(default.read_dataset(loc['sigma'],0))
|
||||
in_file = default.read_dataset(loc['lambda(sigma)'],0)
|
||||
default.add_eigenvalue('sigma',eigenvalue)
|
||||
loc = {'sigma' :default.get_dataset_location('sigma'),
|
||||
'lambda':default.get_dataset_location('lambda_{}(sigma)'.format(eigenvalue))}
|
||||
in_memory = function(mechanics.eigenvalues(default.read_dataset(loc['sigma'],0)),axis=1,keepdims=True)
|
||||
in_file = default.read_dataset(loc['lambda'],0)
|
||||
assert np.allclose(in_memory,in_file)
|
||||
|
||||
def test_add_eigenvectors(self,default):
|
||||
@pytest.mark.parametrize('eigenvalue,idx',[('max',2),('mid',1),('min',0)])
|
||||
def test_add_eigenvector(self,default,eigenvalue,idx):
|
||||
default.add_Cauchy('P','F')
|
||||
default.add_eigenvectors('sigma')
|
||||
default.add_eigenvector('sigma',eigenvalue)
|
||||
loc = {'sigma' :default.get_dataset_location('sigma'),
|
||||
'v(sigma)':default.get_dataset_location('v(sigma)')}
|
||||
in_memory = mechanics.eigenvectors(default.read_dataset(loc['sigma'],0))
|
||||
'v(sigma)':default.get_dataset_location('v_{}(sigma)'.format(eigenvalue))}
|
||||
in_memory = mechanics.eigenvectors(default.read_dataset(loc['sigma'],0))[:,idx]
|
||||
in_file = default.read_dataset(loc['v(sigma)'],0)
|
||||
assert np.allclose(in_memory,in_file)
|
||||
|
||||
|
@ -296,3 +305,7 @@ class TestResult:
|
|||
def test_vtk(self,tmp_path,default,output):
|
||||
os.chdir(tmp_path)
|
||||
default.to_vtk(output)
|
||||
|
||||
def test_XDMF(self,tmp_path,single_phase):
|
||||
os.chdir(tmp_path)
|
||||
single_phase.write_XDMF
|
||||
|
|
Loading…
Reference in New Issue