update to use variable-length strings

This commit is contained in:
Martin Diehl 2020-11-05 22:14:49 +01:00
parent e26bb962c8
commit e649fb195f
8 changed files with 131 additions and 13 deletions

View File

@ -470,7 +470,8 @@ class Result:
def get_crystal_structure(self): # ToDo: extension to multi constituents/phase def get_crystal_structure(self): # ToDo: extension to multi constituents/phase
"""Info about the crystal structure.""" """Info about the crystal structure."""
with h5py.File(self.fname,'r') as f: with h5py.File(self.fname,'r') as f:
return f[self.get_dataset_location('orientation')[0]].attrs['Lattice'].astype('str') # np.bytes_ to string return f[self.get_dataset_location('O')[0]].attrs['Lattice'] if h5py3 else \
f[self.get_dataset_location('O')[0]].attrs['Lattice'].decode()
def enable_user_function(self,func): def enable_user_function(self,func):

View File

@ -0,0 +1,103 @@
---
homogenization:
SX:
N_constituents: 1
mech: {type: none}
phase:
pheno_fcc:
elasticity: {C_11: 106.75e9, C_12: 60.41e9, C_44: 28.34e9, type: hooke}
generic:
output: [F, P, F_e, F_p, L_p, O]
lattice: fcc
plasticity:
N_sl: [12]
a_sl: 2.25
atol_xi: 1.0
dot_gamma_0_sl: 0.001
h_0_sl_sl: 75e6
h_sl_sl: [1, 1, 1.4, 1.4, 1.4, 1.4]
n_sl: 20
output: [xi_sl]
type: phenopowerlaw
xi_0_sl: [31e6]
xi_inf_sl: [63e6]
pheno_bcc:
elasticity: {C_11: 106.75e9, C_12: 60.41e9, C_44: 28.34e9, type: hooke}
generic:
output: [F, P, F_e, F_p, L_p, O]
lattice: bcc
plasticity:
N_sl: [12]
a_sl: 2.25
atol_xi: 1.0
dot_gamma_0_sl: 0.001
h_0_sl_sl: 75e6
h_sl_sl: [1, 1, 1.4, 1.4, 1.4, 1.4]
n_sl: 20
output: [xi_sl]
type: phenopowerlaw
xi_0_sl: [31e6]
xi_inf_sl: [63e6]
material:
- constituents:
- fraction: 1.0
O: [0.8229200444892315, 0.5284940239127993, -0.11958598847729246, 0.17086795611292308]
phase: pheno_fcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.029934934533052786, -0.0463822071939717, 0.9983440440417412, 0.01617900728410769]
phase: pheno_fcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.5285808688806949, 0.7326575088838098, 0.4051997815944012, 0.1401013087924221]
phase: pheno_fcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.1839974517790312, 0.49550065903084944, -0.1541415483910751, -0.8347840545305227]
phase: pheno_fcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.8055693100147384, -0.22778497057116814, -0.028331746016454287, 0.5462320075864553]
phase: pheno_fcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.8025842700117737, -0.33640019337884963, -0.3847408071640489, 0.3076815085881779]
phase: pheno_fcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.6048933483394416, 0.7565005822419409, -0.08545681892422426, -0.2334695661144201]
phase: pheno_bcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.2012339360745425, -0.3580127491130033, -0.7798091137625135, 0.47247171400774884]
phase: pheno_bcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.7949688202267222, 0.3623793306926909, -0.18836147613310203, -0.4485819321629098]
phase: pheno_bcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.19733162113429173, -0.06559103894055797, -0.40230149937129567, 0.8915781236183501]
phase: pheno_bcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.8659916384140512, -0.2761459420825848, 0.38479354764225004, -0.1604238964779258]
phase: pheno_bcc
homogenization: SX
- constituents:
- fraction: 1.0
O: [0.5951846978175659, 0.4476701545571293, -0.6038886363266418, -0.2840160613735736]
phase: pheno_bcc
homogenization: SX

View File

@ -1 +1,14 @@
fdot * 0 0 0 1.0e-3 0 0 0 * stress 0 * * * * * * * 0 time 20 incs 40 freq 4 ---
step:
- discretization:
t: 20
N: 40
f_out: 4
mech:
dot_F: [x, 0, 0,
0, 1.0e-3, 0,
0, 0, x]
P: [0, x, x,
x, x, x,
x, x, 0]

View File

@ -94,11 +94,11 @@ class TestResult:
default.pick('invalid',True) default.pick('invalid',True)
def test_add_absolute(self,default): def test_add_absolute(self,default):
default.add_absolute('Fe') default.add_absolute('F_e')
loc = {'Fe': default.get_dataset_location('Fe'), loc = {'F_e': default.get_dataset_location('F_e'),
'|Fe|': default.get_dataset_location('|Fe|')} '|F_e|': default.get_dataset_location('|F_e|')}
in_memory = np.abs(default.read_dataset(loc['Fe'],0)) in_memory = np.abs(default.read_dataset(loc['F_e'],0))
in_file = default.read_dataset(loc['|Fe|'],0) in_file = default.read_dataset(loc['|F_e|'],0)
assert np.allclose(in_memory,in_file) assert np.allclose(in_memory,in_file)
@pytest.mark.parametrize('mode',['direct','function']) @pytest.mark.parametrize('mode',['direct','function'])
@ -168,8 +168,8 @@ class TestResult:
@pytest.mark.parametrize('d',[[1,0,0],[0,1,0],[0,0,1]]) @pytest.mark.parametrize('d',[[1,0,0],[0,1,0],[0,0,1]])
def test_add_IPF_color(self,default,d): def test_add_IPF_color(self,default,d):
default.add_IPF_color('orientation',d) default.add_IPF_color('O',d)
loc = {'orientation': default.get_dataset_location('orientation'), loc = {'orientation': default.get_dataset_location('O'),
'color': default.get_dataset_location('IPFcolor_[{} {} {}]'.format(*d))} 'color': default.get_dataset_location('IPFcolor_[{} {} {}]'.format(*d))}
qu = default.read_dataset(loc['orientation']).view(np.double).reshape(-1,4) qu = default.read_dataset(loc['orientation']).view(np.double).reshape(-1,4)
crystal_structure = default.get_crystal_structure() crystal_structure = default.get_crystal_structure()
@ -231,8 +231,8 @@ class TestResult:
@pytest.mark.parametrize('polar',[True,False]) @pytest.mark.parametrize('polar',[True,False])
def test_add_pole(self,default,polar): def test_add_pole(self,default,polar):
pole = np.array([1.,0.,0.]) pole = np.array([1.,0.,0.])
default.add_pole('orientation',pole,polar) default.add_pole('O',pole,polar)
loc = {'orientation': default.get_dataset_location('orientation'), loc = {'orientation': default.get_dataset_location('O'),
'pole': default.get_dataset_location('p^{}_[1 0 0)'.format(u'' if polar else 'xy'))} 'pole': default.get_dataset_location('p^{}_[1 0 0)'.format(u'' if polar else 'xy'))}
rot = Rotation(default.read_dataset(loc['orientation']).view(np.double)) rot = Rotation(default.read_dataset(loc['orientation']).view(np.double))
rotated_pole = rot * np.broadcast_to(pole,rot.shape+(3,)) rotated_pole = rot * np.broadcast_to(pole,rot.shape+(3,))

View File

@ -305,7 +305,7 @@ subroutine HDF5_addAttribute_str(loc_id,attrLabel,attrValue,path)
p = '.' p = '.'
endif endif
attrValue_ = attrValue//C_NULL_CHAR attrValue_ = trim(attrValue)//C_NULL_CHAR
ptr(1) = c_loc(attrValue_) ptr(1) = c_loc(attrValue_)
call h5screate_f(H5S_SCALAR_F,space_id,hdferr) call h5screate_f(H5S_SCALAR_F,space_id,hdferr)

View File

@ -736,7 +736,8 @@ subroutine crystallite_results
integer :: p,o integer :: p,o
real(pReal), allocatable, dimension(:,:,:) :: selected_tensors real(pReal), allocatable, dimension(:,:,:) :: selected_tensors
type(rotation), allocatable, dimension(:) :: selected_rotations type(rotation), allocatable, dimension(:) :: selected_rotations
character(len=pStringLen) :: group,structureLabel character(len=pStringLen) :: group
character(len=:),allocatable :: structureLabel
do p=1,size(material_name_phase) do p=1,size(material_name_phase)
group = trim('current/constituent')//'/'//trim(material_name_phase(p))//'/generic' group = trim('current/constituent')//'/'//trim(material_name_phase(p))//'/generic'