From 6c7201610e4c56a06cfb03d8459dc3efae502e90 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 17 Feb 2021 17:56:39 +0100 Subject: [PATCH 01/39] Bugfix for access of unallocated variable IntelMPI seems to access sendbuf for root!=0 in MPI_Scatterv --- src/grid/discretization_grid.f90 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/grid/discretization_grid.f90 b/src/grid/discretization_grid.f90 index 48ad5b7e1..bb6fa9d8d 100644 --- a/src/grid/discretization_grid.f90 +++ b/src/grid/discretization_grid.f90 @@ -68,8 +68,11 @@ subroutine discretization_grid_init(restart) print'(/,a)', ' <<<+- discretization_grid init -+>>>'; flush(IO_STDOUT) - if(worldrank == 0) call readVTR(grid,geomSize,origin,materialAt_global) - + if(worldrank == 0) then + call readVTR(grid,geomSize,origin,materialAt_global) + else + allocate(materialAt_global(0)) ! needed for IntelMPI + endif call MPI_Bcast(grid,3,MPI_INTEGER,0,PETSC_COMM_WORLD, ierr) if (ierr /= 0) error stop 'MPI error' From 7c6ce525a3bf020bb0956ab2f09f4c2480809230 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 19 Feb 2021 06:51:32 +0100 Subject: [PATCH 02/39] ask for minimum version --- DAMASK_prerequisites.sh | 6 +----- python/setup.py | 35 ++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/DAMASK_prerequisites.sh b/DAMASK_prerequisites.sh index 25a2e46e0..181fd46b5 100755 --- a/DAMASK_prerequisites.sh +++ b/DAMASK_prerequisites.sh @@ -84,7 +84,7 @@ for executable in python python3; do done secondLevel "Details on $DEFAULT_PYTHON:" echo $(ls -la $(which $DEFAULT_PYTHON)) -for module in numpy scipy pandas;do +for module in numpy scipy pandas matplotlib yaml h5py;do thirdLevel $module $DEFAULT_PYTHON -c "import $module; \ print('Version: {}'.format($module.__version__)); \ @@ -94,10 +94,6 @@ thirdLevel vtk $DEFAULT_PYTHON -c "import vtk; \ print('Version: {}'.format(vtk.vtkVersion.GetVTKVersion())); \ print('Location: {}'.format(vtk.__file__))" -thirdLevel h5py -$DEFAULT_PYTHON -c "import h5py; \ - print('Version: {}'.format(h5py.version.version)); \ - print('Location: {}'.format(h5py.__file__))" firstLevel "GNU Compiler Collection" for executable in gcc g++ gfortran ;do diff --git a/python/setup.py b/python/setup.py index 19fbdcd13..3df226141 100644 --- a/python/setup.py +++ b/python/setup.py @@ -6,28 +6,29 @@ with open(Path(__file__).parent/'damask/VERSION') as f: version = re.sub(r'(-([^-]*)).*$',r'.\2',re.sub(r'^v(\d+\.\d+(\.\d+)?)',r'\1',f.readline().strip())) setuptools.setup( - name="damask", + name='damask', version=version, - author="The DAMASK team", - author_email="damask@mpie.de", - description="DAMASK library", - long_description="Python library for pre and post processing of DAMASK simulations", - url="https://damask.mpie.de", + author='The DAMASK team', + author_email='damask@mpie.de', + description='DAMASK library', + long_description='Python library for pre and post processing of DAMASK simulations', + url='https://damask.mpie.de', packages=setuptools.find_packages(), include_package_data=True, + python_requires = '>=3.6' install_requires = [ - "pandas", # requires numpy - "scipy", - "h5py", # requires numpy - "vtk", - "matplotlib", # requires numpy, pillow - "pyaml" + 'pandas>=0.24', # requires numpy + 'scipy>=1.2', + 'h5py>=2.9', # requires numpy + 'vtk>=8.1', + 'matplotlib>=3.0', # requires numpy, pillow + 'pyaml>=3.12' ], classifiers = [ - "Intended Audience :: Science/Research", - "Topic :: Scientific/Engineering", - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", - "Operating System :: OS Independent", + 'Intended Audience :: Science/Research', + 'Topic :: Scientific/Engineering', + 'Programming Language :: Python :: 3', + 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', + 'Operating System :: OS Independent', ], ) From ab9661d9513b98d30cf1d2390bba9fec84858130 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 19 Feb 2021 07:04:34 +0100 Subject: [PATCH 03/39] don't see how ':=' should help here --- python/damask/_configmaterial.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 0adc494b8..1362c239c 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -103,7 +103,6 @@ class ConfigMaterial(Config): """Check for completeness.""" ok = True for top_level in ['homogenization','phase','material']: - # ToDo: With python 3.8 as prerequisite we can shorten with := ok &= top_level in self if top_level not in self: print(f'{top_level} entry missing') From f5f993435b6f59f1ea50eefbc63b1ded186e55e0 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 19 Feb 2021 16:34:28 +0100 Subject: [PATCH 04/39] make intention clear --- python/damask/_configmaterial.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 1362c239c..70019e26e 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -202,7 +202,7 @@ class ConfigMaterial(Config): """ dup = self.copy() for i,m in enumerate(dup['material']): - if ID and i not in ID: continue + if ID is not None and i not in ID: continue for c in m['constituents']: if constituent is not None and c not in constituent: continue try: @@ -226,7 +226,7 @@ class ConfigMaterial(Config): """ dup = self.copy() for i,m in enumerate(dup['material']): - if ID and i not in ID: continue + if ID is not None and i not in ID: continue try: m['homogenization'] = mapping[m['homogenization']] except KeyError: From b00b4bb0ad42b780c463edf0efed88319a6b8844 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 19 Feb 2021 16:37:02 +0100 Subject: [PATCH 05/39] more general handling of precision Anaconda on windows does not have np.float128 defined, but aliases should work https://numpy.org/devdocs/user/basics.types.html --- python/damask/_grid.py | 2 +- python/damask/_vtk.py | 4 ++-- python/setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 103538349..7e4ef2ac1 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -760,7 +760,7 @@ class Grid: """ if fill is None: fill = np.nanmax(self.material) + 1 - dtype = float if np.isnan(fill) or int(fill) != fill or self.material.dtype==np.float else int + dtype = float if isinstance(fill,float) or self.material.dtype in np.sctypes['float'] else int material = self.material # These rotations are always applied in the reference coordinate system, i.e. (z,x,z) not (z,x',z'') diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index 00a07efa5..b9f237297 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -246,8 +246,8 @@ class VTK: raise ValueError('No label defined for numpy.ndarray') N_data = data.shape[0] - d = np_to_vtk((data.astype(np.float32) if data.dtype in [np.float64, np.float128] - else data).reshape(N_data,-1),deep=True) # avoid large files + d = np_to_vtk((data.astype(np.single) if data.dtype in [np.double, np.longdouble] else + data).reshape(N_data,-1),deep=True) # avoid large files d.SetName(label) if N_data == N_points: diff --git a/python/setup.py b/python/setup.py index 3df226141..0642c0b7d 100644 --- a/python/setup.py +++ b/python/setup.py @@ -15,7 +15,7 @@ setuptools.setup( url='https://damask.mpie.de', packages=setuptools.find_packages(), include_package_data=True, - python_requires = '>=3.6' + python_requires = '>=3.6', install_requires = [ 'pandas>=0.24', # requires numpy 'scipy>=1.2', From 9a550a5e88b00b3bf682ac36b1d8f85476471c4a Mon Sep 17 00:00:00 2001 From: Ruxin Zhang Date: Fri, 19 Feb 2021 23:31:28 -0500 Subject: [PATCH 06/39] lattice and mechanics should be parallel --- examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Ferrite.yaml | 2 +- examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Martensite.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Ferrite.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Ferrite.yaml index ce3bbadb7..7cb84eb4f 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Ferrite.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Ferrite.yaml @@ -2,8 +2,8 @@ # Tasan et.al. 2015 International Journal of Plasticity # Diehl et.al. 2015 Meccanica Ferrite: + lattice: cI mechanics: - lattice: cI elasticity: {C_11: 233.3e9, C_12: 135.5e9, C_44: 118.0e9, type: hooke} plasticity: N_sl: [12, 12] diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Martensite.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Martensite.yaml index ab79ceeb1..3a5becc57 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Martensite.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_BCC-Martensite.yaml @@ -2,8 +2,8 @@ # Tasan et.al. 2015 International Journal of Plasticity # Diehl et.al. 2015 Meccanica Martensite: + lattice: cI mechanics: - lattice: cI elasticity: {C_11: 417.4e9, C_12: 242.4e9, C_44: 211.1e9, type: hooke} plasticity: N_sl: [12, 12] From e658d2d480e707d63dbfe28c35ffaf2dbd96fd12 Mon Sep 17 00:00:00 2001 From: Ruxin Zhang Date: Sat, 20 Feb 2021 01:19:28 -0500 Subject: [PATCH 07/39] generated yaml files according to config files --- .../Phase_Phenopowerlaw_Aluminum.yaml | 15 ++++++++++ .../ConfigFiles/Phase_Phenopowerlaw_Gold.yaml | 20 +++++++++++++ .../Phase_Phenopowerlaw_Magnesium.yaml | 30 +++++++++++++++++++ .../Phase_Phenopowerlaw_cpTi-alpha.yaml | 18 +++++++++++ 4 files changed, 83 insertions(+) create mode 100644 examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.yaml create mode 100644 examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml create mode 100644 examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.yaml create mode 100644 examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.yaml new file mode 100644 index 000000000..01b354b89 --- /dev/null +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.yaml @@ -0,0 +1,15 @@ +Aluminum: + lattice: cF + mechanics: + elasticity: {C_11: 106.75e9, C_12: 60.41e9, C_44: 28.34e9, type: hooke} + plasticity: + N_sl: [12] + a_sl: 2.25 + 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, gamma_sl] + type: phenopowerlaw + xi_0_sl: [31e6] + xi_inf_sl: [63e6] diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml new file mode 100644 index 000000000..39db9d65c --- /dev/null +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml @@ -0,0 +1,20 @@ +# parameters fitted by D. Ma to: +# I. Kovács, G. Vörös +# On the mathematical description of the tensile stress-strain curves of polycrystalline face centered cubic metals +# International Journal of Plasticity, Volume 12, Issue 1, 1996, Pages 35–43 +# DOI: 10.1016/S0749-6419(95)00043-7 +Gold: + lattice: cF + mechanics: + elasticity: {C_11: 191.0e9, C_12: 162.0e9, C_44: 42.20e9, type: hooke} + plasticity: + N_sl: [12] + a_sl: 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: 83.3 + output: [xi_sl] + type: phenopowerlaw + xi_0_sl: [26.25e6] + xi_inf_sl: [53.00e6] diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.yaml new file mode 100644 index 000000000..dd5f6064e --- /dev/null +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.yaml @@ -0,0 +1,30 @@ +# Tromans 2011, Elastic Anisotropy of HCP Metal Crystals and Polycrystals +Magnesium: + lattice: hP + c/a: 1.62350 + mechanics: + elasticity: {C_11: 59.3e9, C_12: 25.7e9, C_13: 21.4e9, C_33: 61.5e9, C_44: 16.4e9, type: hooke} + plasticity: + N_sl: [3, 3, 0, 6, 0, 6] + N_tw: [6, 0, 0, 6] + h_0_tw_tw: 50.0e6 + h_0_sl_sl: 500.0e6 + h_0_tw_sl: 150.0e6 + h_sl_sl: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + h_tw_tw: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + h_sl_tw: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + h_tw_sl: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + output: [xi_sl, xi_tw] + type: phenopowerlaw + xi_0_sl: [10.0e6, 55.0e6, 0, 60.0e6, 0.0, 60.0e6] + xi_inf_sl: [40.0e6, 135.0e6, 0, 150.0e6, 0.0, 150.0e6] + xi_0_tw: [40e6, 0.0, 0.0, 60.0e6] +#################################################### +# open for discussion +#################################################### + a_sl: 2.25 + dot_gamma_0_sl: 0.001 + dot_gamma_0_tw: 0.001 + n_sl: 20 + n_tw: 20 + f_sl_sat_tw: 10.0 diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml new file mode 100644 index 000000000..4fa40924e --- /dev/null +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml @@ -0,0 +1,18 @@ +# M. Levy, Handbook of Elastic Properties of Solids, Liquids, and Gases (2001) +# C. Zambaldi, "Orientation informed nanoindentation of a-titanium: Indentation pileup in hexagonal metals deforming by prismatic slip", J. Mater. Res., Vol. 27, No. 1, Jan 14, 2012 +Ti-alpha: + lattice: hP + c/a: 1.587 + mechanics: + elasticity: {C_11: 160.0e9, C_12: 90.0e9, C_13: 211.1e9, C_33: 181.7e9, C_44: 46.5e9, type: hooke} + plasticity: + N_sl: [3, 3, 0, 6] + a_sl: 2.0 + dot_gamma_0_sl: 0.001 + h_0_sl_sl: 15e6 + h_sl_sl: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + n_sl: 20 + output: [gamma_sl] + type: phenopowerlaw + xi_0_sl: [349.3e6, 150e6, 0, 1107.9e6] + xi_inf_sl: [568.6e6, 1502.2e6, 0, 3420.1e6] From 5d0e9b186386bbceb12f8d795321dbf6a38d2d5d Mon Sep 17 00:00:00 2001 From: Ruxin Zhang Date: Sat, 20 Feb 2021 01:39:29 -0500 Subject: [PATCH 08/39] some letters in annotation raised error, got rid of them --- examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml index 39db9d65c..850becf6c 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml @@ -1,5 +1,5 @@ # parameters fitted by D. Ma to: -# I. Kovács, G. Vörös +# I. Kovacs, G. Voros # On the mathematical description of the tensile stress-strain curves of polycrystalline face centered cubic metals # International Journal of Plasticity, Volume 12, Issue 1, 1996, Pages 35–43 # DOI: 10.1016/S0749-6419(95)00043-7 From b04a05c2ea5e56280f060159e7d991eb2d2094bc Mon Sep 17 00:00:00 2001 From: Ruxin Zhang Date: Sat, 20 Feb 2021 01:41:29 -0500 Subject: [PATCH 09/39] some letters in annotation raised error, got rid of them --- examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml index 850becf6c..370009dde 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml @@ -1,8 +1,3 @@ -# parameters fitted by D. Ma to: -# I. Kovacs, G. Voros -# On the mathematical description of the tensile stress-strain curves of polycrystalline face centered cubic metals -# International Journal of Plasticity, Volume 12, Issue 1, 1996, Pages 35–43 -# DOI: 10.1016/S0749-6419(95)00043-7 Gold: lattice: cF mechanics: From 14b16fd6465f09c4ee9bb2ec6bd13f146d8e8a9c Mon Sep 17 00:00:00 2001 From: Ruxin Zhang Date: Sat, 20 Feb 2021 04:36:52 -0500 Subject: [PATCH 10/39] added output under mechanics --- examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.yaml | 1 + examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml | 1 + examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.yaml | 1 + examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml | 1 + 4 files changed, 4 insertions(+) diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.yaml index 01b354b89..1c15206b7 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.yaml @@ -1,6 +1,7 @@ Aluminum: lattice: cF mechanics: + output: [F, P, F_e, F_p, L_p, O] elasticity: {C_11: 106.75e9, C_12: 60.41e9, C_44: 28.34e9, type: hooke} plasticity: N_sl: [12] diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml index 370009dde..6f55af739 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml @@ -1,6 +1,7 @@ Gold: lattice: cF mechanics: + output: [F, P, F_e, F_p, L_p, O] elasticity: {C_11: 191.0e9, C_12: 162.0e9, C_44: 42.20e9, type: hooke} plasticity: N_sl: [12] diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.yaml index dd5f6064e..7ae4699e0 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.yaml @@ -3,6 +3,7 @@ Magnesium: lattice: hP c/a: 1.62350 mechanics: + output: [F, P, F_e, F_p, L_p, O] elasticity: {C_11: 59.3e9, C_12: 25.7e9, C_13: 21.4e9, C_33: 61.5e9, C_44: 16.4e9, type: hooke} plasticity: N_sl: [3, 3, 0, 6, 0, 6] diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml index 4fa40924e..789986138 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml @@ -4,6 +4,7 @@ Ti-alpha: lattice: hP c/a: 1.587 mechanics: + output: [F, P, F_e, F_p, L_p, O] elasticity: {C_11: 160.0e9, C_12: 90.0e9, C_13: 211.1e9, C_33: 181.7e9, C_44: 46.5e9, type: hooke} plasticity: N_sl: [3, 3, 0, 6] From c299585b67364f43d0587e46868d99d6ff436452 Mon Sep 17 00:00:00 2001 From: Ruxin Zhang Date: Sun, 21 Feb 2021 17:36:45 -0500 Subject: [PATCH 11/39] For Ti-alpha, corrected the inconsistencies according to reference by C. Zambaldi et al --- .../ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.config | 8 ++++---- .../ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.config b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.config index 93d45def7..b6c35c1cb 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.config +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.config @@ -14,10 +14,10 @@ c44 46.5e9 # C. Zambaldi, "Orientation informed nanoindentation of a-titanium: Indentation pileup in hexagonal metals deforming by prismatic slip", J. Mater. Res., Vol. 27, No. 1, Jan 14, 2012 gdot0_slip 0.001 n_slip 20 -nslip 3 3 0 6 -tau0_slip 349.3e6 150e6 0 1107.9e6 -tausat_slip 568.6e6 1502.2e6 0 3420.1e6 +nslip 3 3 0 0 12 +tau0_slip 349e6 150e6 0 0 1107e6 +tausat_slip 568e6 1502e6 0 0 3420e6 a_slip 2 -h0_slipslip 15e6 +h0_slipslip 200e6 interaction_slipslip 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml index 789986138..7931ec267 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml @@ -5,15 +5,15 @@ Ti-alpha: c/a: 1.587 mechanics: output: [F, P, F_e, F_p, L_p, O] - elasticity: {C_11: 160.0e9, C_12: 90.0e9, C_13: 211.1e9, C_33: 181.7e9, C_44: 46.5e9, type: hooke} + elasticity: {C_11: 160.0e9, C_12: 90.0e9, C_13: 66.0e9, C_33: 181.7e9, C_44: 46.5e9, type: hooke} plasticity: - N_sl: [3, 3, 0, 6] + N_sl: [3, 3, 0, 0, 12] a_sl: 2.0 dot_gamma_0_sl: 0.001 - h_0_sl_sl: 15e6 + h_0_sl_sl: 200e6 h_sl_sl: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] n_sl: 20 output: [gamma_sl] type: phenopowerlaw - xi_0_sl: [349.3e6, 150e6, 0, 1107.9e6] - xi_inf_sl: [568.6e6, 1502.2e6, 0, 3420.1e6] + xi_0_sl: [349e6, 150e6, 0, 0, 1107e6] + xi_inf_sl: [568e6, 1502e6, 0, 0, 3420e6] From 67f0ab2ce8871fa0c999ac5cf1b687f80d3eb9b4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 22 Feb 2021 08:35:15 +0100 Subject: [PATCH 12/39] silence deprecation warning --- python/damask/util.py | 2 +- python/tests/test_Grid.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/util.py b/python/damask/util.py index fb122bd11..cda532bc0 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -183,7 +183,7 @@ def scale_to_coprime(v): # Python 3.9 provides math.lcm, see https://stackoverflow.com/questions/51716916. return a * b // np.gcd(a, b) - m = (np.array(v) * reduce(lcm, map(lambda x: int(get_square_denominator(x)),v)) ** 0.5).astype(np.int) + m = (np.array(v) * reduce(lcm, map(lambda x: int(get_square_denominator(x)),v)) ** 0.5).astype(int) m = m//reduce(np.gcd,m) with np.errstate(invalid='ignore'): diff --git a/python/tests/test_Grid.py b/python/tests/test_Grid.py index 48831f917..a239165db 100644 --- a/python/tests/test_Grid.py +++ b/python/tests/test_Grid.py @@ -347,7 +347,7 @@ class TestGrid: @pytest.mark.parametrize('approach',['Laguerre','Voronoi']) def test_tessellate_bicrystal(self,approach): cells = np.random.randint(5,10,3)*2 - size = cells.astype(np.float) + size = cells.astype(float) seeds = np.vstack((size*np.array([0.5,0.25,0.5]),size*np.array([0.5,0.75,0.5]))) material = np.zeros(cells) material[:,cells[1]//2:,:] = 1 From 5517be5078893e79f0146a2ac04bcf0b995d8de7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 22 Feb 2021 08:49:44 +0100 Subject: [PATCH 13/39] warn the caller of deprecated functions --- python/damask/_grid.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 7e4ef2ac1..8125fb045 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -202,7 +202,7 @@ class Grid: Geometry file to read. """ - warnings.warn('Support for ASCII-based geom format will be removed in DAMASK 3.1.0', DeprecationWarning) + warnings.warn('Support for ASCII-based geom format will be removed in DAMASK 3.1.0', DeprecationWarning,2) try: f = open(fname) except TypeError: @@ -541,7 +541,7 @@ class Grid: Compress geometry with 'x of y' and 'a to b'. """ - warnings.warn('Support for ASCII-based geom format will be removed in DAMASK 3.1.0', DeprecationWarning) + warnings.warn('Support for ASCII-based geom format will be removed in DAMASK 3.1.0', DeprecationWarning,2) header = [f'{len(self.comments)+4} header'] + self.comments \ + ['grid a {} b {} c {}'.format(*self.cells), 'size x {} y {} z {}'.format(*self.size), From d54e49e3bc8437228d9cee2cc076265c3bccb782 Mon Sep 17 00:00:00 2001 From: Vitesh Date: Mon, 22 Feb 2021 13:37:21 +0100 Subject: [PATCH 14/39] restore functionality to write non-parallel not needed at the moment, but in general useful. If PETSc = parallel should always hold, we can simplify much more --- PRIVATE | 2 +- src/CPFEM2.f90 | 9 +-- src/HDF5_utilities.f90 | 72 +++++++++++--------- src/grid/grid_mech_FEM.f90 | 10 +-- src/grid/grid_mech_spectral_basic.f90 | 9 +-- src/grid/grid_mech_spectral_polarisation.f90 | 9 +-- src/homogenization.f90 | 4 +- src/results.f90 | 41 +++-------- 8 files changed, 62 insertions(+), 94 deletions(-) diff --git a/PRIVATE b/PRIVATE index 2ed5cd4ba..751a45927 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 2ed5cd4ba97b44ad9c8b61ced94060aee57a2dd8 +Subproject commit 751a45927708e9157b6e02b645249afb27cccf70 diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index e57de7f67..bf044bef9 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -75,7 +75,6 @@ end subroutine CPFEM_initAll subroutine CPFEM_init integer(HID_T) :: fileHandle - character(len=pStringLen) :: fileName print'(/,a)', ' <<<+- CPFEM init -+>>>'; flush(IO_STDOUT) @@ -83,8 +82,8 @@ subroutine CPFEM_init if (interface_restartInc > 0) then print'(/,a,i0,a)', ' reading restart information of increment from file'; flush(IO_STDOUT) - write(fileName,'(a,i0,a)') trim(getSolverJobName())//'_',worldrank,'.hdf5' - fileHandle = HDF5_openFile(fileName) + + fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r') call homogenization_restartRead(fileHandle) call phase_restartRead(fileHandle) @@ -101,13 +100,11 @@ end subroutine CPFEM_init subroutine CPFEM_restartWrite integer(HID_T) :: fileHandle - character(len=pStringLen) :: fileName print*, ' writing field and constitutive data required for restart to file';flush(IO_STDOUT) - write(fileName,'(a,i0,a)') trim(getSolverJobName())//'_',worldrank,'.hdf5' - fileHandle = HDF5_openFile(fileName,'a') + fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','a') call homogenization_restartWrite(fileHandle) call phase_restartWrite(fileHandle) diff --git a/src/HDF5_utilities.f90 b/src/HDF5_utilities.f90 index 781089ad8..ce00c4913 100644 --- a/src/HDF5_utilities.f90 +++ b/src/HDF5_utilities.f90 @@ -71,6 +71,12 @@ module HDF5_utilities module procedure HDF5_addAttribute_real_array end interface HDF5_addAttribute +#ifdef PETSc + logical, parameter, private :: parallel_default = .true. +#else + logical, parameter, private :: parallel_default = .false. +#endif + contains @@ -105,16 +111,16 @@ end subroutine HDF5_utilities_init !-------------------------------------------------------------------------------------------------- !> @brief open and initializes HDF5 output file !-------------------------------------------------------------------------------------------------- -integer(HID_T) function HDF5_openFile(fileName,mode,parallel) +integer(HID_T) function HDF5_openFile(fileName,mode) character(len=*), intent(in) :: fileName character, intent(in), optional :: mode - logical, intent(in), optional :: parallel character :: m integer(HID_T) :: plist_id integer :: hdferr + if (present(mode)) then m = mode else @@ -125,10 +131,8 @@ integer(HID_T) function HDF5_openFile(fileName,mode,parallel) if(hdferr < 0) error stop 'HDF5 error' #ifdef PETSc - if (present(parallel)) then; if (parallel) then - call h5pset_fapl_mpio_f(plist_id, PETSC_COMM_WORLD, MPI_INFO_NULL, hdferr) - if(hdferr < 0) error stop 'HDF5 error' - endif; endif + call h5pset_fapl_mpio_f(plist_id, PETSC_COMM_WORLD, MPI_INFO_NULL, hdferr) + if(hdferr < 0) error stop 'HDF5 error' #endif if (m == 'w') then @@ -547,7 +551,7 @@ subroutine HDF5_read_real1(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,& @@ -587,7 +591,7 @@ subroutine HDF5_read_real2(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,& @@ -627,7 +631,7 @@ subroutine HDF5_read_real3(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,& @@ -667,7 +671,7 @@ subroutine HDF5_read_real4(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,& @@ -707,7 +711,7 @@ subroutine HDF5_read_real5(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,& @@ -747,7 +751,7 @@ subroutine HDF5_read_real6(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,& @@ -787,7 +791,7 @@ subroutine HDF5_read_real7(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_DOUBLE,dataset,totalShape, hdferr,& @@ -829,7 +833,7 @@ subroutine HDF5_read_int1(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,& @@ -869,7 +873,7 @@ subroutine HDF5_read_int2(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,& @@ -909,7 +913,7 @@ subroutine HDF5_read_int3(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,& @@ -949,7 +953,7 @@ subroutine HDF5_read_int4(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,& @@ -989,7 +993,7 @@ subroutine HDF5_read_int5(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,& @@ -1029,7 +1033,7 @@ subroutine HDF5_read_int6(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,& @@ -1069,7 +1073,7 @@ subroutine HDF5_read_int7(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,parallel) else call initialize_read(dset_id, filespace_id, memspace_id, plist_id, aplist_id, & - myStart, totalShape, loc_id,myShape,datasetName,.false.) + myStart, totalShape, loc_id,myShape,datasetName,parallel_default) endif call h5dread_f(dset_id, H5T_NATIVE_INTEGER,dataset,totalShape, hdferr,& @@ -1109,7 +1113,7 @@ subroutine HDF5_write_real1(loc_id,dataset,datasetName,parallel) myStart, totalShape,loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape,loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,.false.) + myStart, totalShape,loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel_default) endif if (product(totalShape) /= 0) then @@ -1150,7 +1154,7 @@ subroutine HDF5_write_real2(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel_default) endif if (product(totalShape) /= 0) then @@ -1191,7 +1195,7 @@ subroutine HDF5_write_real3(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel_default) endif if (product(totalShape) /= 0) then @@ -1232,7 +1236,7 @@ subroutine HDF5_write_real4(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel_default) endif if (product(totalShape) /= 0) then @@ -1274,7 +1278,7 @@ subroutine HDF5_write_real5(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel_default) endif if (product(totalShape) /= 0) then @@ -1315,7 +1319,7 @@ subroutine HDF5_write_real6(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel_default) endif if (product(totalShape) /= 0) then @@ -1356,7 +1360,7 @@ subroutine HDF5_write_real7(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_DOUBLE,parallel_default) endif if (product(totalShape) /= 0) then @@ -1398,7 +1402,7 @@ subroutine HDF5_write_int1(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel_default) endif if (product(totalShape) /= 0) then @@ -1439,7 +1443,7 @@ subroutine HDF5_write_int2(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel_default) endif if (product(totalShape) /= 0) then @@ -1480,7 +1484,7 @@ subroutine HDF5_write_int3(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel_default) endif if (product(totalShape) /= 0) then @@ -1521,7 +1525,7 @@ subroutine HDF5_write_int4(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel_default) endif if (product(totalShape) /= 0) then @@ -1562,7 +1566,7 @@ subroutine HDF5_write_int5(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel_default) endif if (product(totalShape) /= 0) then @@ -1603,7 +1607,7 @@ subroutine HDF5_write_int6(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel_default) endif if (product(totalShape) /= 0) then @@ -1644,7 +1648,7 @@ subroutine HDF5_write_int7(loc_id,dataset,datasetName,parallel) myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel) else call initialize_write(dset_id, filespace_id, memspace_id, plist_id, & - myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,.false.) + myStart, totalShape, loc_id,myShape,datasetName,H5T_NATIVE_INTEGER,parallel_default) endif if (product(totalShape) /= 0) then diff --git a/src/grid/grid_mech_FEM.f90 b/src/grid/grid_mech_FEM.f90 index 806973a4d..609561c80 100644 --- a/src/grid/grid_mech_FEM.f90 +++ b/src/grid/grid_mech_FEM.f90 @@ -108,8 +108,6 @@ subroutine grid_mechanical_FEM_init u_current,u_lastInc PetscInt, dimension(0:worldsize-1) :: localK integer(HID_T) :: fileHandle, groupHandle - character(len=pStringLen) :: & - fileName class(tNode), pointer :: & num_grid, & debug_grid @@ -234,8 +232,7 @@ subroutine grid_mechanical_FEM_init restartRead: if (interface_restartInc > 0) then print'(/,a,i0,a)', ' reading restart data of increment ', interface_restartInc, ' from file' - write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' - fileHandle = HDF5_openFile(fileName) + fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r') groupHandle = HDF5_openGroup(fileHandle,'solver') call HDF5_read(groupHandle,P_aim, 'P_aim') @@ -422,7 +419,7 @@ subroutine grid_mechanical_FEM_restartWrite PetscErrorCode :: ierr integer(HID_T) :: fileHandle, groupHandle PetscScalar, dimension(:,:,:,:), pointer :: u_current,u_lastInc - character(len=pStringLen) :: fileName + call DMDAVecGetArrayF90(mechanical_grid,solution_current,u_current,ierr) CHKERRQ(ierr) @@ -431,8 +428,7 @@ subroutine grid_mechanical_FEM_restartWrite print*, 'writing solver data required for restart to file'; flush(IO_STDOUT) - write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' - fileHandle = HDF5_openFile(fileName,'w') + fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','w') groupHandle = HDF5_addGroup(fileHandle,'solver') call HDF5_write(groupHandle,P_aim, 'P_aim') diff --git a/src/grid/grid_mech_spectral_basic.f90 b/src/grid/grid_mech_spectral_basic.f90 index f3f30c0af..faf58c85e 100644 --- a/src/grid/grid_mech_spectral_basic.f90 +++ b/src/grid/grid_mech_spectral_basic.f90 @@ -99,8 +99,6 @@ subroutine grid_mechanical_spectral_basic_init PetscInt, dimension(0:worldsize-1) :: localK integer(HID_T) :: fileHandle, groupHandle integer :: fileUnit - character(len=pStringLen) :: & - fileName class (tNode), pointer :: & num_grid, & debug_grid @@ -182,8 +180,7 @@ subroutine grid_mechanical_spectral_basic_init restartRead: if (interface_restartInc > 0) then print'(/,a,i0,a)', ' reading restart data of increment ', interface_restartInc, ' from file' - write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' - fileHandle = HDF5_openFile(fileName) + fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r') groupHandle = HDF5_openGroup(fileHandle,'solver') call HDF5_read(groupHandle,P_aim, 'P_aim') @@ -365,14 +362,12 @@ subroutine grid_mechanical_spectral_basic_restartWrite PetscErrorCode :: ierr integer(HID_T) :: fileHandle, groupHandle PetscScalar, dimension(:,:,:,:), pointer :: F - character(len=pStringLen) :: fileName call DMDAVecGetArrayF90(da,solution_vec,F,ierr); CHKERRQ(ierr) print*, 'writing solver data required for restart to file'; flush(IO_STDOUT) - write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' - fileHandle = HDF5_openFile(fileName,'w') + fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','w') groupHandle = HDF5_addGroup(fileHandle,'solver') call HDF5_write(groupHandle,P_aim, 'P_aim') diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index 633fced7f..8caf41b31 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -112,8 +112,6 @@ subroutine grid_mechanical_spectral_polarisation_init PetscInt, dimension(0:worldsize-1) :: localK integer(HID_T) :: fileHandle, groupHandle integer :: fileUnit - character(len=pStringLen) :: & - fileName class (tNode), pointer :: & num_grid, & debug_grid @@ -204,8 +202,7 @@ subroutine grid_mechanical_spectral_polarisation_init restartRead: if (interface_restartInc > 0) then print'(/,a,i0,a)', ' reading restart data of increment ', interface_restartInc, ' from file' - write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' - fileHandle = HDF5_openFile(fileName) + fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','r') groupHandle = HDF5_openGroup(fileHandle,'solver') call HDF5_read(groupHandle,P_aim, 'P_aim') @@ -419,7 +416,6 @@ subroutine grid_mechanical_spectral_polarisation_restartWrite PetscErrorCode :: ierr integer(HID_T) :: fileHandle, groupHandle PetscScalar, dimension(:,:,:,:), pointer :: FandF_tau, F, F_tau - character(len=pStringLen) :: fileName call DMDAVecGetArrayF90(da,solution_vec,FandF_tau,ierr); CHKERRQ(ierr) F => FandF_tau(0: 8,:,:,:) @@ -427,8 +423,7 @@ subroutine grid_mechanical_spectral_polarisation_restartWrite print*, 'writing solver data required for restart to file'; flush(IO_STDOUT) - write(fileName,'(a,a,i0,a)') trim(getSolverJobName()),'_',worldrank,'.hdf5' - fileHandle = HDF5_openFile(fileName,'w') + fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','w') groupHandle = HDF5_addGroup(fileHandle,'solver') call HDF5_write(groupHandle,F_aim, 'P_aim') diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 3e1b939b5..497b6cbaf 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -451,7 +451,7 @@ subroutine homogenization_restartWrite(fileHandle) groupHandle(2) = HDF5_addGroup(groupHandle(1),material_name_homogenization(ho)) - call HDF5_read(groupHandle(2),homogState(ho)%state,'omega') ! ToDo: should be done by mech + call HDF5_write(groupHandle(2),homogState(ho)%state,'omega') ! ToDo: should be done by mech call HDF5_closeGroup(groupHandle(2)) @@ -478,7 +478,7 @@ subroutine homogenization_restartRead(fileHandle) groupHandle(2) = HDF5_openGroup(groupHandle(1),material_name_homogenization(ho)) - call HDF5_write(groupHandle(2),homogState(ho)%state,'omega') ! ToDo: should be done by mech + call HDF5_read(groupHandle(2),homogState(ho)%state,'omega') ! ToDo: should be done by mech call HDF5_closeGroup(groupHandle(2)) diff --git a/src/results.f90 b/src/results.f90 index 7cb518e83..c9c51b9a2 100644 --- a/src/results.f90 +++ b/src/results.f90 @@ -65,7 +65,7 @@ subroutine results_init(restart) print*, 'https://doi.org/10.1007/s40192-017-0084-5'//IO_EOL if(.not. restart) then - resultsFile = HDF5_openFile(trim(getSolverJobName())//'.hdf5','w',.true.) + resultsFile = HDF5_openFile(getSolverJobName()//'.hdf5','w') call results_addAttribute('DADF5_version_major',0) call results_addAttribute('DADF5_version_minor',11) call results_addAttribute('DAMASK_version',DAMASKVERSION) @@ -83,7 +83,7 @@ end subroutine results_init !-------------------------------------------------------------------------------------------------- subroutine results_openJobFile - resultsFile = HDF5_openFile(trim(getSolverJobName())//'.hdf5','a',.true.) + resultsFile = HDF5_openFile(getSolverJobName()//'.hdf5','a') end subroutine results_openJobFile @@ -289,11 +289,7 @@ subroutine results_writeScalarDataset_real(group,dataset,label,description,SIuni groupHandle = results_openGroup(group) -#ifdef PETSc - call HDF5_write(groupHandle,dataset,label,.true.) -#else - call HDF5_write(groupHandle,dataset,label,.false.) -#endif + call HDF5_write(groupHandle,dataset,label) if (HDF5_objectExists(groupHandle,label)) & call HDF5_addAttribute(groupHandle,'Description',description,label) @@ -320,11 +316,7 @@ subroutine results_writeVectorDataset_real(group,dataset,label,description,SIuni groupHandle = results_openGroup(group) -#ifdef PETSc - call HDF5_write(groupHandle,dataset,label,.true.) -#else - call HDF5_write(groupHandle,dataset,label,.false.) -#endif + call HDF5_write(groupHandle,dataset,label) if (HDF5_objectExists(groupHandle,label)) & call HDF5_addAttribute(groupHandle,'Description',description,label) @@ -362,7 +354,7 @@ subroutine results_writeTensorDataset_real(group,dataset,label,description,SIuni endif if(transposed_) then - if(size(dataset,1) /= size(dataset,2)) call IO_error(0,ext_msg='transpose non-symmetric tensor') + if(size(dataset,1) /= size(dataset,2)) error stop 'transpose non-symmetric tensor' allocate(dataset_transposed,mold=dataset) do i=1,size(dataset_transposed,3) dataset_transposed(:,:,i) = transpose(dataset(:,:,i)) @@ -373,11 +365,7 @@ subroutine results_writeTensorDataset_real(group,dataset,label,description,SIuni groupHandle = results_openGroup(group) -#ifdef PETSc - call HDF5_write(groupHandle,dataset_transposed,label,.true.) -#else - call HDF5_write(groupHandle,dataset_transposed,label,.false.) -#endif + call HDF5_write(groupHandle,dataset_transposed,label) if (HDF5_objectExists(groupHandle,label)) & call HDF5_addAttribute(groupHandle,'Description',description,label) @@ -405,11 +393,7 @@ subroutine results_writeVectorDataset_int(group,dataset,label,description,SIunit groupHandle = results_openGroup(group) -#ifdef PETSc - call HDF5_write(groupHandle,dataset,label,.true.) -#else - call HDF5_write(groupHandle,dataset,label,.false.) -#endif + call HDF5_write(groupHandle,dataset,label) if (HDF5_objectExists(groupHandle,label)) & call HDF5_addAttribute(groupHandle,'Description',description,label) @@ -437,11 +421,7 @@ subroutine results_writeTensorDataset_int(group,dataset,label,description,SIunit groupHandle = results_openGroup(group) -#ifdef PETSc - call HDF5_write(groupHandle,dataset,label,.true.) -#else - call HDF5_write(groupHandle,dataset,label,.false.) -#endif + call HDF5_write(groupHandle,dataset,label) if (HDF5_objectExists(groupHandle,label)) & call HDF5_addAttribute(groupHandle,'Description',description,label) @@ -577,7 +557,7 @@ subroutine results_mapping_phase(phaseAt,memberAtLocal,label) !-------------------------------------------------------------------------------------------------- ! write the components of the compound type individually - call h5pset_preserve_f(plist_id, .TRUE., hdferr) + call h5pset_preserve_f(plist_id, .true., hdferr) if(hdferr < 0) error stop 'HDF5 error' loc_id = results_openGroup('/mapping') @@ -733,7 +713,8 @@ subroutine results_mapping_homogenization(homogenizationAt,memberAtLocal,label) !-------------------------------------------------------------------------------------------------- ! write the components of the compound type individually - call h5pset_preserve_f(plist_id, .TRUE., hdferr) + call h5pset_preserve_f(plist_id, .true., hdferr) + if(hdferr < 0) error stop 'HDF5 error' loc_id = results_openGroup('/mapping') call h5dcreate_f(loc_id, 'homogenization', dtype_id, filespace_id, dset_id, hdferr) From 5348305ac87810401ad78b04fbc1ae088582df5d Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Mon, 22 Feb 2021 14:42:54 +0100 Subject: [PATCH 15/39] restart key part of loadstep and not time discretization --- PRIVATE | 2 +- src/grid/DAMASK_grid.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PRIVATE b/PRIVATE index 751a45927..3efdf7dd9 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 751a45927708e9157b6e02b645249afb27cccf70 +Subproject commit 3efdf7dd9de96fe6c55240ecf6d0d78d9d0e36ec diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index ed1ada171..d250e2f53 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -225,8 +225,8 @@ program DAMASK_grid loadCases(l)%t = step_discretization%get_asFloat('t') loadCases(l)%N = step_discretization%get_asInt ('N') loadCases(l)%r = step_discretization%get_asFloat('r', defaultVal= 1.0_pReal) - loadCases(l)%f_restart = step_discretization%get_asInt ('f_restart', defaultVal=huge(0)) + loadCases(l)%f_restart = load_step%get_asInt('f_restart', defaultVal=huge(0)) loadCases(l)%f_out = load_step%get_asInt('f_out', defaultVal=1) loadCases(l)%estimate_rate = (load_step%get_asBool('estimate_rate',defaultVal=.true.) .and. & merge(.true.,.false.,l > 1)) From 5d4c1a9795c8124b950dc5d5e16066c5cc97f400 Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 22 Feb 2021 15:55:02 +0100 Subject: [PATCH 16/39] [skip ci] updated version information after successful test of v3.0.0-alpha2-486-g23a3354ac --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 26e9be190..24632bfa8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-478-gc9e4dc21f +v3.0.0-alpha2-486-g23a3354ac From 5c2b3846a21f6b50e1b4e2c08620dc259948566b Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 22 Feb 2021 10:20:04 -0500 Subject: [PATCH 17/39] fixed more yaml example configs --- .../Phase_Isotropic_AluminumIsotropic.yaml | 4 ++-- .../Phase_Isotropic_FreeSurface.yaml | 4 ++-- .../ConfigFiles/Phase_Phenopowerlaw_Gold.yaml | 20 ++++++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/examples/ConfigFiles/Phase_Isotropic_AluminumIsotropic.yaml b/examples/ConfigFiles/Phase_Isotropic_AluminumIsotropic.yaml index 7b05140cb..cd6c2eb24 100644 --- a/examples/ConfigFiles/Phase_Isotropic_AluminumIsotropic.yaml +++ b/examples/ConfigFiles/Phase_Isotropic_AluminumIsotropic.yaml @@ -1,9 +1,9 @@ # Kuo, J. C., Mikrostrukturmechanik von Bikristallen mit Kippkorngrenzen. Shaker-Verlag 2004. http://edoc.mpg.de/204079 Aluminum: + lattice: aP mechanics: - lattice: aP - elasticity: {C_11: 110.9e9, C_12: 58.34e9, type: hooke} output: [F, P, Fe, Fp, Lp] + elasticity: {type: hooke, C_11: 110.9e9, C_12: 58.34e9} plasticity: type: isotropic output: [xi] diff --git a/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml b/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml index 4d9690f44..db1636f28 100644 --- a/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml +++ b/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml @@ -1,9 +1,9 @@ # Maiti and Eisenlohr 2018 Scripta Materialia Air: + lattice: aP mechanics: - lattice: aP - elasticity: {C_11: 10e9, C_12: 0.0, type: hooke} output: [F, P, Fe, Fp, Lp] + elasticity: {type: hooke, C_11: 10e9, C_12: 0.0} plasticity: type: isotropic output: [xi] diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml index 6f55af739..475abfac3 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml @@ -1,16 +1,22 @@ +# parameters fitted by D. Ma to: +# I. Kovács, G. Vörös +# On the mathematical description of the tensile stress-strain curves of polycrystalline face centered cubic metals +# International Journal of Plasticity, Volume 12, Issue 1, 1996, Pages 35–43 +# DOI: 10.1016/S0749-6419(95)00043-7 + Gold: lattice: cF mechanics: output: [F, P, F_e, F_p, L_p, O] - elasticity: {C_11: 191.0e9, C_12: 162.0e9, C_44: 42.20e9, type: hooke} + elasticity: {type: hooke, C_11: 191e9, C_12: 162e9, C_44: 42.2e9} plasticity: + type: phenopowerlaw + output: [xi_sl] N_sl: [12] - a_sl: 1.0 + n_sl: 83 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: 83.3 - output: [xi_sl] - type: phenopowerlaw - xi_0_sl: [26.25e6] - xi_inf_sl: [53.00e6] + a_sl: 1.0 + xi_0_sl: [26e6] + xi_inf_sl: [53e6] From e7e5f9a57c2da12a791bd3ac75e67a504aa8b93e Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 22 Feb 2021 10:30:34 -0500 Subject: [PATCH 18/39] more robust air stiffness values --- examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml b/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml index db1636f28..3e245cc6e 100644 --- a/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml +++ b/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml @@ -1,9 +1,8 @@ -# Maiti and Eisenlohr 2018 Scripta Materialia Air: lattice: aP mechanics: output: [F, P, Fe, Fp, Lp] - elasticity: {type: hooke, C_11: 10e9, C_12: 0.0} + elasticity: {type: hooke, C_11: 1e8, C_12: 1e6} plasticity: type: isotropic output: [xi] @@ -14,4 +13,4 @@ Air: M: 3 h_0: 1e6 a: 2 - dilatation: true + dilatation: True From 164d216df450ff4b0e8ea16fe9bd370b3b345122 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 22 Feb 2021 10:41:05 -0500 Subject: [PATCH 19/39] added updated PRIVATE that includes tests for examples/ConfigFiles --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 2ed5cd4ba..f22de7476 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 2ed5cd4ba97b44ad9c8b61ced94060aee57a2dd8 +Subproject commit f22de7476efb703b91fe66310c75dce98772b21f From e86a7a931510f40be9e3804fd60fafb8459e06d0 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 22 Feb 2021 10:48:04 -0500 Subject: [PATCH 20/39] dropping "alpha" for cpTi as it is by definition hexagonal --- ...powerlaw_cpTi-alpha.config => Phase_Phenopowerlaw_cpTi.config} | 0 ...henopowerlaw_cpTi-alpha.yaml => Phase_Phenopowerlaw_cpTi.yaml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename examples/ConfigFiles/{Phase_Phenopowerlaw_cpTi-alpha.config => Phase_Phenopowerlaw_cpTi.config} (100%) rename examples/ConfigFiles/{Phase_Phenopowerlaw_cpTi-alpha.yaml => Phase_Phenopowerlaw_cpTi.yaml} (100%) diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.config b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.config similarity index 100% rename from examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.config rename to examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.config diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml similarity index 100% rename from examples/ConfigFiles/Phase_Phenopowerlaw_cpTi-alpha.yaml rename to examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml From e9422efe652721c2b477023af0569a1aae03f8b5 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 22 Feb 2021 10:49:32 -0500 Subject: [PATCH 21/39] removed unencodable characters --- examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml index 475abfac3..f84b2eb05 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.yaml @@ -1,7 +1,6 @@ # parameters fitted by D. Ma to: -# I. Kovács, G. Vörös # On the mathematical description of the tensile stress-strain curves of polycrystalline face centered cubic metals -# International Journal of Plasticity, Volume 12, Issue 1, 1996, Pages 35–43 +# International Journal of Plasticity, Volume 12, Issue 1, 1996, Pages 35-43 # DOI: 10.1016/S0749-6419(95)00043-7 Gold: From a62f7a90a8c8eb77f2d43ee2d2c7ac5ed2c6b13a Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 22 Feb 2021 11:24:44 -0500 Subject: [PATCH 22/39] fixed Fe --> F_e and such --- examples/ConfigFiles/Phase_Isotropic_AluminumIsotropic.yaml | 2 +- examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ConfigFiles/Phase_Isotropic_AluminumIsotropic.yaml b/examples/ConfigFiles/Phase_Isotropic_AluminumIsotropic.yaml index cd6c2eb24..02e2d9a28 100644 --- a/examples/ConfigFiles/Phase_Isotropic_AluminumIsotropic.yaml +++ b/examples/ConfigFiles/Phase_Isotropic_AluminumIsotropic.yaml @@ -2,7 +2,7 @@ Aluminum: lattice: aP mechanics: - output: [F, P, Fe, Fp, Lp] + output: [F, P, F_e, F_p, L_p] elasticity: {type: hooke, C_11: 110.9e9, C_12: 58.34e9} plasticity: type: isotropic diff --git a/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml b/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml index 3e245cc6e..90f88d679 100644 --- a/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml +++ b/examples/ConfigFiles/Phase_Isotropic_FreeSurface.yaml @@ -1,7 +1,7 @@ Air: lattice: aP mechanics: - output: [F, P, Fe, Fp, Lp] + output: [F, P, F_e, F_p, L_p] elasticity: {type: hooke, C_11: 1e8, C_12: 1e6} plasticity: type: isotropic From 802c51998456d4bfdc4f3dd88166d930e87e79cb Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 22 Feb 2021 17:29:38 +0100 Subject: [PATCH 23/39] [skip ci] updated version information after successful test of v3.0.0-alpha2-488-ge2c41acc6 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 26e9be190..12226a0b9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-478-gc9e4dc21f +v3.0.0-alpha2-488-ge2c41acc6 From 0461c404f77fe32ccdd3febe4229da3df89804bd Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 22 Feb 2021 18:52:06 +0100 Subject: [PATCH 24/39] numpy uses __array__ for casting avoids infinite loop of __init__, __getitem__, and shape. Found on https://github.com/scikit-hep/awkward-0.x/pull/26/commits/8cf07f6113aa9f78bbfa4d84fbec10135878500e --- python/damask/_configmaterial.py | 2 +- python/damask/_rotation.py | 11 ++++++++++- python/tests/test_Rotation.py | 10 +++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 70019e26e..1cda2e46b 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -248,7 +248,7 @@ class ConfigMaterial(Config): Examples -------- >>> import damask - >>> O = damask.Rotation.from_random(3).as_quaternion() + >>> O = damask.Rotation.from_random(3) >>> phase = ['Aluminum','Steel','Aluminum'] >>> m = damask.ConfigMaterial().material_add(constituents={'phase':phase,'O':O}, ... homogenization='SX') diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 4109c181e..86311546e 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -125,9 +125,18 @@ class Rotation: return np.logical_not(self==other) + def __array__(self): + """Initializer for numpy.""" + return self.quaternion + + + @property + def size(self): + return self.quaternion[...,0].size + @property def shape(self): - return self.quaternion.shape[:-1] + return self.quaternion[...,0].shape def __len__(self): diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 6bee44e7f..b28a849c5 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -689,6 +689,10 @@ class TestRotation: with pytest.raises(TypeError): Rotation(np.ones(3)) + def test_to_numpy(self): + r = Rotation.from_random(np.random.randint(0,10,4)) + assert np.all(r.as_quaternion() == np.array(r)) + @pytest.mark.parametrize('degrees',[True,False]) def test_Eulers(self,set_of_rotations,degrees): for rot in set_of_rotations: @@ -804,7 +808,11 @@ class TestRotation: r = Rotation.from_random() assert r == ~~r - @pytest.mark.parametrize('shape',[None,1,(1,),(4,2),(1,1,1)]) + @pytest.mark.parametrize('shape',[1,(1,),(4,2),(1,1,1),tuple(np.random.randint(0,10,4))]) + def test_size(self,shape): + assert Rotation.from_random(shape).size == np.prod(shape) + + @pytest.mark.parametrize('shape',[None,1,(1,),(4,2),(1,1,1),tuple(np.random.randint(0,10,4))]) def test_shape(self,shape): r = Rotation.from_random(shape=shape) assert r.shape == (shape if isinstance(shape,tuple) else (shape,) if shape else ()) From 2d49ebc460a76c32f6f20d7fdd9145333d3027fc Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 22 Feb 2021 19:08:00 +0100 Subject: [PATCH 25/39] [skip ci] updated version information after successful test of v3.0.0-alpha2-490-g4d5e5cfb7 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 26e9be190..aae4cbbae 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-478-gc9e4dc21f +v3.0.0-alpha2-490-g4d5e5cfb7 From fe674ba7b67c1ccbe7e685ab4d53a23a9ed7d2d9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 22 Feb 2021 19:08:33 +0100 Subject: [PATCH 26/39] not needed --- .../Homogenization_multiField.config | 8 --- .../Phase_Phenopowerlaw_Aluminum.config | 21 ------- .../Phase_Phenopowerlaw_Gold.config | 27 --------- .../Phase_Phenopowerlaw_Magnesium.config | 56 ------------------- .../Phase_Phenopowerlaw_cpTi.config | 23 -------- examples/ConfigFiles/Texture_Gauss_001.config | 2 - examples/ConfigFiles/Texture_Gauss_101.config | 2 - examples/ConfigFiles/Texture_Gauss_111.config | 2 - examples/ConfigFiles/Texture_Gauss_123.config | 2 - examples/ConfigFiles/material.config | 20 ------- 10 files changed, 163 deletions(-) delete mode 100644 examples/ConfigFiles/Homogenization_multiField.config delete mode 100644 examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.config delete mode 100644 examples/ConfigFiles/Phase_Phenopowerlaw_Gold.config delete mode 100644 examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.config delete mode 100644 examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.config delete mode 100644 examples/ConfigFiles/Texture_Gauss_001.config delete mode 100644 examples/ConfigFiles/Texture_Gauss_101.config delete mode 100644 examples/ConfigFiles/Texture_Gauss_111.config delete mode 100644 examples/ConfigFiles/Texture_Gauss_123.config delete mode 100644 examples/ConfigFiles/material.config diff --git a/examples/ConfigFiles/Homogenization_multiField.config b/examples/ConfigFiles/Homogenization_multiField.config deleted file mode 100644 index 7dd63cc73..000000000 --- a/examples/ConfigFiles/Homogenization_multiField.config +++ /dev/null @@ -1,8 +0,0 @@ -[SX] -type isostrain -Ngrains 1 -{./Homogenization_Damage_NonLocal.config} -{./Homogenization_Thermal_Conduction.config} -{./Homogenization_VacancyFlux_CahnHilliard.config} -{./Homogenization_Porosity_PhaseField.config} -{./Homogenization_HydrogenFlux_CahnHilliard.config} diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.config b/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.config deleted file mode 100644 index 72421a640..000000000 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Aluminum.config +++ /dev/null @@ -1,21 +0,0 @@ -[Aluminum] -elasticity hooke -plasticity phenopowerlaw - -(output) resistance_slip -(output) accumulatedshear_slip - -lattice_structure fcc -Nslip 12 # per family - -c11 106.75e9 -c12 60.41e9 -c44 28.34e9 - -gdot0_slip 0.001 -n_slip 20 -tau0_slip 31e6 # per family -tausat_slip 63e6 # per family -a_slip 2.25 -h0_slipslip 75e6 -interaction_slipslip 1 1 1.4 1.4 1.4 1.4 diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.config b/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.config deleted file mode 100644 index c7fc670ac..000000000 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Gold.config +++ /dev/null @@ -1,27 +0,0 @@ -# parameters fitted by D. Ma to: -# I. Kovács, G. Vörös -# On the mathematical description of the tensile stress-strain curves of polycrystalline face centered cubic metals -# International Journal of Plasticity, Volume 12, Issue 1, 1996, Pages 35–43 -# DOI: 10.1016/S0749-6419(95)00043-7 - -[gold_phenopowerlaw] -elasticity hooke -plasticity phenopowerlaw - -(output) resistance_slip - -lattice_structure fcc -Nslip 12 # per family - -c11 191.0e9 -c12 162.0e9 -c44 42.20e9 - -gdot0_slip 0.001 -n_slip 83.3 -tau0_slip 26.25e6 # per family -tausat_slip 53.00e6 # per family -a_slip 1.0 -h0_slipslip 75e6 -interaction_slipslip 1 1 1.4 1.4 1.4 1.4 - diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.config b/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.config deleted file mode 100644 index 4647a868f..000000000 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_Magnesium.config +++ /dev/null @@ -1,56 +0,0 @@ -#-------------------# - -#-------------------# -/echo/ -[Mg] -plasticity phenopowerlaw -elasticity hooke - -(output) resistance_slip -(output) resistance_twin - -lattice_structure hex -c/a 1.62350 # from Tromans 2011, Elastic Anisotropy of HCP Metal Crystals and Polycrystals -c11 59.3e9 # - " - -c33 61.5e9 # - " - -c44 16.4e9 # - " - -c12 25.7e9 # - " - -c13 21.4e9 # - " - - -# basal prism prism pyr(a) pyr(c+a) pyr(c+a) -Nslip 3 3 0 6 0 6 # from Agnew et al 2006, Validating a polycrystal model for the elastoplastic response of mg alloy AZ32 using in situ neutron diffraction -# T1 C1 T2 C2 -Ntwin 6 0 0 6 # - " - -# basal prism prism pyr(a) pyr(c+a) pyr(c+a) -tau0_slip 10.0e6 55.0e6 0 60.0e6 0.0 60.0e6 # - " - table 1, pyr(a) set to pyr(c+a) -tausat_slip 40.0e6 135.0e6 0 150.0e6 0.0 150.0e6 # - " - table 1, pyr(a) set to pyr(c+a) -# T1 C1 T2 C2 -tau0_twin 40e6 0.0 0.0 60.0e6 # - " - table 1, compressive twin guessed by Steffi, tensile twin modified to match experimental results - -h0_twintwin 50.0e6 # - " - table 1, same range as theta_0 -h0_slipslip 500.0e6 # - " - table 1, same range as theta_0 -h0_twinslip 150.0e6 # guessing - -interaction_slipslip 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 # just guessing -interaction_twintwin 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 # - " - -interaction_sliptwin 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 # - " - -interaction_twinslip 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 # - " - - - - -#################################################### -# open for discussion -#################################################### -n_twin 20 -n_slip 20 - -gdot0_twin 0.001 -gdot0_slip 0.001 - -twin_b 0 -twin_c 0 -twin_d 20 -twin_e 20 - -a_slip 2.25 -s_pr 10.0 # push-up factor for slip saturation due to twinning diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.config b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.config deleted file mode 100644 index b6c35c1cb..000000000 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.config +++ /dev/null @@ -1,23 +0,0 @@ -[cpTi-alpha] -plasticity phenopowerlaw -elasticity hooke - -lattice_structure hex -covera_ratio 1.587 - -# M. Levy, Handbook of Elastic Properties of Solids, Liquids, and Gases (2001) -c11 160.0e9 -c12 90.0e9 -c13 66.0e9 -c33 181.7e9 -c44 46.5e9 -# C. Zambaldi, "Orientation informed nanoindentation of a-titanium: Indentation pileup in hexagonal metals deforming by prismatic slip", J. Mater. Res., Vol. 27, No. 1, Jan 14, 2012 -gdot0_slip 0.001 -n_slip 20 -nslip 3 3 0 0 12 -tau0_slip 349e6 150e6 0 0 1107e6 -tausat_slip 568e6 1502e6 0 0 3420e6 -a_slip 2 -h0_slipslip 200e6 - -interaction_slipslip 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 diff --git a/examples/ConfigFiles/Texture_Gauss_001.config b/examples/ConfigFiles/Texture_Gauss_001.config deleted file mode 100644 index 4fb519f08..000000000 --- a/examples/ConfigFiles/Texture_Gauss_001.config +++ /dev/null @@ -1,2 +0,0 @@ -[001] -(gauss) phi1 0.000 Phi 0.000 phi2 0.000 diff --git a/examples/ConfigFiles/Texture_Gauss_101.config b/examples/ConfigFiles/Texture_Gauss_101.config deleted file mode 100644 index c6c1b5dbe..000000000 --- a/examples/ConfigFiles/Texture_Gauss_101.config +++ /dev/null @@ -1,2 +0,0 @@ -[101] -(gauss) phi1 0.000 Phi 45.000 phi2 90.000 diff --git a/examples/ConfigFiles/Texture_Gauss_111.config b/examples/ConfigFiles/Texture_Gauss_111.config deleted file mode 100644 index 0d685a66e..000000000 --- a/examples/ConfigFiles/Texture_Gauss_111.config +++ /dev/null @@ -1,2 +0,0 @@ -[111] -(gauss) phi1 0.000 Phi 54.7356 phi2 45.000 diff --git a/examples/ConfigFiles/Texture_Gauss_123.config b/examples/ConfigFiles/Texture_Gauss_123.config deleted file mode 100644 index da4fa30ab..000000000 --- a/examples/ConfigFiles/Texture_Gauss_123.config +++ /dev/null @@ -1,2 +0,0 @@ -[123] -(gauss) phi1 209.805 Phi 29.206 phi2 63.435 diff --git a/examples/ConfigFiles/material.config b/examples/ConfigFiles/material.config deleted file mode 100644 index c863ca8a2..000000000 --- a/examples/ConfigFiles/material.config +++ /dev/null @@ -1,20 +0,0 @@ -# The material.config file needs to specify five parts: -# homogenization, microstructure, crystallite, phase, and texture. -# You can either put the full text in here or include suited separate files - - -{./Homogenization_Isostrain_SX.config} - - -[one_only] -crystallite 1 -(constituent) phase 1 texture 1 fraction 1.0 - - -{./Crystallite_All.config} - - -{./Phase_Phenopowerlaw_Aluminum.config} - - -{./Texture_Gauss_001.config} From 9fca65083cbb602fa4d44df107131e294c69d334 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 22 Feb 2021 19:18:41 +0100 Subject: [PATCH 27/39] fixed test --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index f22de7476..866ed0725 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit f22de7476efb703b91fe66310c75dce98772b21f +Subproject commit 866ed072549a3794f78339dedfb518a305c62d16 From d3726a08b15bce757f8207eb17490813b577c71f Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 23 Feb 2021 04:18:28 +0100 Subject: [PATCH 28/39] [skip ci] updated version information after successful test of v3.0.0-alpha2-500-gfdb182b40 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 24632bfa8..41ac4ffd3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-486-g23a3354ac +v3.0.0-alpha2-500-gfdb182b40 From 4a00254dba52e60f813c563fad94d32b8a88e2c1 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 22 Feb 2021 22:44:12 -0500 Subject: [PATCH 29/39] shortened material_add and allow for multi-constituent; broken from_table... --- python/damask/_configmaterial.py | 98 +++++++++++------------------ python/tests/test_ConfigMaterial.py | 61 +++++++----------- 2 files changed, 60 insertions(+), 99 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 1cda2e46b..a19f07a3a 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -3,6 +3,7 @@ import numpy as np from . import Config from . import Rotation from . import Orientation +from . import util class ConfigMaterial(Config): """Material configuration.""" @@ -46,7 +47,7 @@ class ConfigMaterial(Config): @staticmethod - def from_table(table,constituents={},**kwargs): + def from_table(table,**kwargs): """ Load from an ASCII table. @@ -54,12 +55,9 @@ class ConfigMaterial(Config): ---------- table : damask.Table Table that contains material information. - constituents : dict, optional - Entries for 'constituents'. The key is the name and the value specifies - the label of the data column in the table **kwargs - Keyword arguments where the key is the name and the value specifies - the label of the data column in the table + Keyword arguments where the key is the name and the value specifies + the label of the data column in the table. Examples -------- @@ -70,7 +68,7 @@ class ConfigMaterial(Config): pos pos pos qu qu qu qu phase homog 0 0 0 0 0.19 0.8 0.24 -0.51 Aluminum SX 1 1 0 0 0.8 0.19 0.24 -0.51 Steel SX - >>> cm.from_table(t,{'O':'qu','phase':'phase'},homogenization='homog') + >>> cm.from_table(t,O='qu',phase='phase',homogenization='homog') material: - constituents: - O: [0.19, 0.8, 0.24, -0.51] @@ -86,16 +84,17 @@ class ConfigMaterial(Config): phase: {} """ - constituents_ = {k:table.get(v) for k,v in constituents.items()} + # constituents_ = {k:table.get(v) for k,v in constituents.items()} kwargs_ = {k:table.get(v) for k,v in kwargs.items()} - _,idx = np.unique(np.hstack(list({**constituents_,**kwargs_}.values())),return_index=True,axis=0) + _,idx = np.unique(kwargs_.values(),return_index=True,axis=0) + # _,idx = np.unique(np.hstack(list({**constituents_,**kwargs_}.values())),return_index=True,axis=0) idx = np.sort(idx) - constituents_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in constituents_.items()} + # constituents_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in constituents_.items()} kwargs_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in kwargs_.items()} - return ConfigMaterial().material_add(constituents_,**kwargs_) + return ConfigMaterial().material_add(**kwargs_) @property @@ -234,7 +233,7 @@ class ConfigMaterial(Config): return dup - def material_add(self,constituents=None,**kwargs): + def material_add(self,**kwargs): """ Add material entries. @@ -248,10 +247,9 @@ class ConfigMaterial(Config): Examples -------- >>> import damask - >>> O = damask.Rotation.from_random(3) - >>> phase = ['Aluminum','Steel','Aluminum'] - >>> m = damask.ConfigMaterial().material_add(constituents={'phase':phase,'O':O}, - ... homogenization='SX') + >>> m = damask.ConfigMaterial().material_add(phase = ['Aluminum','Steel','Aluminum'], + ... O = damask.Rotation.from_random(3)}, + ... homogenization = 'SX') >>> m material: - constituents: @@ -273,54 +271,30 @@ class ConfigMaterial(Config): phase: {} """ - length = -1 - for v in kwargs.values(): - if hasattr(v,'__len__') and not isinstance(v,str): - if length != -1 and len(v) != length: - raise ValueError('Cannot add entries of different length') - else: - length = len(v) - length = max(1,length) - - c = [{} for _ in range(length)] if constituents is None else \ - [{'constituents':u} for u in ConfigMaterial._constituents(**constituents)] - - if len(c) == 1: c = [c[0] for _ in range(length)] - - if length != 1 and length != len(c): - raise ValueError('Cannot add entries of different length') + N,n,shaped = 1,1,{} for k,v in kwargs.items(): - if hasattr(v,'__len__') and not isinstance(v,str): - for i,vv in enumerate(v): - c[i][k] = vv.item() if isinstance(vv,np.generic) else vv - else: - for i in range(len(c)): - c[i][k] = v + shaped[k] = np.array(v) + s = shaped[k].shape[:-1] if k=='O' else shaped[k].shape + N = max(N,s[0]) if len(s)>0 else N + n = max(n,s[1]) if len(s)>1 else n + + mat = [{'constituents':[{} for _ in range(n)]} for _ in range(N)] + + if 'v' not in kwargs: + shaped['v'] = np.broadcast_to(1/n,(N,n)) + + for k,v in shaped.items(): + obj = np.broadcast_to(v.reshape(util.shapeshifter(v.shape,(N,n,4))),(N,n,4)) if k=='O' else \ + np.broadcast_to(v.reshape(util.shapeshifter(v.shape,(N,n ))),(N,n)) + for i in range(N): + if k in ['phase','O','v']: + for j in range(n): + mat[i]['constituents'][j][k] = obj[i,j].item() if isinstance(obj[i,j],np.generic) else obj[i,j] + else: + mat[i][k] = obj[i,0].item() if isinstance(obj[i,0],np.generic) else obj[i,0] + dup = self.copy() - dup['material'] = dup['material'] + c if 'material' in dup else c + dup['material'] = dup['material'] + mat if 'material' in dup else mat return dup - - - @staticmethod - def _constituents(N=1,**kwargs): - """Construct list of constituents.""" - N_material=1 - for v in kwargs.values(): - if hasattr(v,'__len__') and not isinstance(v,str): N_material = len(v) - - if N == 1: - m = [[{'v':1.0}] for _ in range(N_material)] - for k,v in kwargs.items(): - if hasattr(v,'__len__') and not isinstance(v,str): - if len(v) != N_material: - raise ValueError('Cannot add entries of different length') - for i,vv in enumerate(np.array(v)): - m[i][0][k] = vv.item() if isinstance(vv,np.generic) else vv - else: - for i in range(N_material): - m[i][0][k] = v - return m - else: - raise NotImplementedError diff --git a/python/tests/test_ConfigMaterial.py b/python/tests/test_ConfigMaterial.py index 4ad0d31ca..ae99a0bc6 100644 --- a/python/tests/test_ConfigMaterial.py +++ b/python/tests/test_ConfigMaterial.py @@ -5,6 +5,7 @@ import numpy as np from damask import ConfigMaterial from damask import Table +from damask import Rotation @pytest.fixture def ref_path(ref_path_base): @@ -85,42 +86,28 @@ class TestConfigMaterial: def test_from_table(self): N = np.random.randint(3,10) - a = np.vstack((np.hstack((np.arange(N),np.arange(N)[::-1])),np.ones(N*2),np.zeros(N*2),np.ones(N*2))).T - t = Table(a,{'varying':2,'constant':2}) - c = ConfigMaterial.from_table(t,constituents={'a':'varying','b':'1_constant'},c='2_constant') + a = np.vstack((np.hstack((np.arange(N),np.arange(N)[::-1])),np.ones(N*2),np.zeros(N*2),np.ones(N*2),np.ones(N*2))).T + print(a) + t = Table(a,{'varying':1,'constant':4}) + c = ConfigMaterial.from_table(t,**{'phase':'varying','O':'constant'}) assert len(c['material']) == N - for i,m in enumerate(c['material']): - c = m['constituents'][0] - assert m['c'] == 1 and c['b'] == 0 and (c['a'] == [i,1]).all() + print(c) + # for i,m in enumerate(c['material']): + # c = m['constituents'][0] + # assert m['c'] == 1 and c['b'] == 0 and (c['a'] == [i,1]).all() - def test_constituents(self): - c = ConfigMaterial._constituents(c=1,v=[2,3]) - assert c[0][0]['c'] == c[1][0]['c'] == 1 - assert c[0][0]['v'] == c[1][0]['v'] -1 ==2 - - @pytest.mark.parametrize('constituents',[{'W':1,'X':[2,3]},{'Y':4},{'Z':[5,6]}]) - @pytest.mark.parametrize('a',[[7.,8.],9.]) - @pytest.mark.parametrize('b',['bd',['efg','hi']]) - def test_material_add(self,tmp_path,constituents,a,b): - len_c = len(ConfigMaterial()._constituents(1,**constituents)) - len_a = len(a) if isinstance(a,list) else 1 - len_b = len(b) if isinstance(b,list) else 1 - m = ConfigMaterial().material_add(constituents,a=a,b=b) - m.save() - assert len(m['material']) == np.max([len_a,len_b,len_c]) - - @pytest.mark.parametrize('constituents',[{'W':1,'X':np.array([2,3])},{'Y':4},{'Z':np.array([5,6])}]) - @pytest.mark.parametrize('a',[np.array([7,8]),9]) - def test_material_add_np(self,tmp_path,constituents,a): - len_c = len(ConfigMaterial()._constituents(1,**constituents)) - len_a = len(a) if isinstance(a,np.ndarray) else 1 - m = ConfigMaterial().material_add(constituents,ld=a) - m.save() - assert len(m['material']) == np.max([len_a,len_c]) - - @pytest.mark.parametrize('constituents',[{'X':np.array([2,3,4,5])},{'Y':4}]) - @pytest.mark.parametrize('a',[np.array([1,2,3]),[4,5,6]]) - @pytest.mark.parametrize('b',[np.array([6.,7.]),[8.,9.]]) - def test_material_add_invalid(self,constituents,a,b): - with pytest.raises(ValueError): - ConfigMaterial().material_add(constituents,a=a,u=b) + @pytest.mark.parametrize('N,n,kw',[ + (1,1,{'phase':'Gold', + 'O':[1,0,0,0], + 'homogenization':'SX'}), + (3,1,{'phase':'Gold', + 'O':Rotation.from_random(3), + 'homogenization':'SX'}), + (2,3,{'phase':np.broadcast_to(['a','b','c'],(2,3)), + 'O':Rotation.from_random((2,3)), + 'homogenization':['SX','PX']}), + ]) + def test_material_add(self,kw,N,n): + m = ConfigMaterial().material_add(**kw) + assert len(m['material']) == N + assert len(m['material'][0]['constituents']) == n From 1b2081774ac04bbd0c3c8612f1d944f7bb465eaf Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 23 Feb 2021 08:16:56 +0100 Subject: [PATCH 30/39] [skip ci] updated version information after successful test of v3.0.0-alpha2-503-g8a1c73ebc --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 41ac4ffd3..04962f227 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-500-gfdb182b40 +v3.0.0-alpha2-503-g8a1c73ebc From dfe7ded893dcbca244b431dc46b04524724c9a21 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 23 Feb 2021 17:03:15 +0100 Subject: [PATCH 31/39] [skip ci] updated version information after successful test of v3.0.0-alpha2-520-g5ee538a38 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 04962f227..f00a64a89 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-503-g8a1c73ebc +v3.0.0-alpha2-520-g5ee538a38 From 69316f186b6271ca4fa8abe38af8cc7433b3a32a Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 23 Feb 2021 11:50:13 -0500 Subject: [PATCH 32/39] fixed ConfigMaterial.from_table; 2D grid.from_table now acceptable --- python/damask/_configmaterial.py | 9 +++------ python/damask/_grid.py | 4 ++-- python/tests/test_ConfigMaterial.py | 8 +++----- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index a19f07a3a..54cc4fd7d 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -68,6 +68,7 @@ class ConfigMaterial(Config): pos pos pos qu qu qu qu phase homog 0 0 0 0 0.19 0.8 0.24 -0.51 Aluminum SX 1 1 0 0 0.8 0.19 0.24 -0.51 Steel SX + 1 1 1 0 0.8 0.19 0.24 -0.51 Steel SX >>> cm.from_table(t,O='qu',phase='phase',homogenization='homog') material: - constituents: @@ -84,15 +85,11 @@ class ConfigMaterial(Config): phase: {} """ - # constituents_ = {k:table.get(v) for k,v in constituents.items()} kwargs_ = {k:table.get(v) for k,v in kwargs.items()} - _,idx = np.unique(kwargs_.values(),return_index=True,axis=0) - # _,idx = np.unique(np.hstack(list({**constituents_,**kwargs_}.values())),return_index=True,axis=0) - + _,idx = np.unique(np.hstack(list(kwargs_.values())),return_index=True,axis=0) idx = np.sort(idx) - # constituents_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in constituents_.items()} - kwargs_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in kwargs_.items()} + kwargs_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in kwargs_.items()} return ConfigMaterial().material_add(**kwargs_) diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 8125fb045..a58f2ca2c 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -122,7 +122,7 @@ class Grid: @size.setter def size(self,size): - if len(size) != 3 or any(np.array(size) <= 0): + if len(size) != 3 or any(np.array(size) < 0): raise ValueError(f'invalid size {size}') else: self._size = np.array(size) @@ -303,7 +303,7 @@ class Grid: Need to be ordered (1./x fast, 3./z slow). labels : str or list of str Label(s) of the columns containing the material definition. - Each unique combintation of values results in one material ID. + Each unique combination of values results in one material ID. """ cells,size,origin = grid_filters.cellsSizeOrigin_coordinates0_point(table.get(coordinates)) diff --git a/python/tests/test_ConfigMaterial.py b/python/tests/test_ConfigMaterial.py index ae99a0bc6..6c316aeaa 100644 --- a/python/tests/test_ConfigMaterial.py +++ b/python/tests/test_ConfigMaterial.py @@ -89,12 +89,10 @@ class TestConfigMaterial: a = np.vstack((np.hstack((np.arange(N),np.arange(N)[::-1])),np.ones(N*2),np.zeros(N*2),np.ones(N*2),np.ones(N*2))).T print(a) t = Table(a,{'varying':1,'constant':4}) - c = ConfigMaterial.from_table(t,**{'phase':'varying','O':'constant'}) + c = ConfigMaterial.from_table(t,**{'phase':'varying','O':'constant','homogenization':'4_constant'}) assert len(c['material']) == N - print(c) - # for i,m in enumerate(c['material']): - # c = m['constituents'][0] - # assert m['c'] == 1 and c['b'] == 0 and (c['a'] == [i,1]).all() + for i,m in enumerate(c['material']): + assert m['homogenization'] == 1 and (m['constituents'][0]['O'] == [1,0,1,1]).all() @pytest.mark.parametrize('N,n,kw',[ (1,1,{'phase':'Gold', From d72fc404e43e9b33dce68e6c4b2bcab92f6126a5 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 23 Feb 2021 15:07:21 -0500 Subject: [PATCH 33/39] updated PRIVATE tests --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 751a45927..e214896b6 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 751a45927708e9157b6e02b645249afb27cccf70 +Subproject commit e214896b6a5402bea8113cc89a7e86c9b59ed713 From dcc42204ec1550109547e912b934fc137d7b8141 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 23 Feb 2021 18:40:32 -0500 Subject: [PATCH 34/39] expanded help on material_add --- python/damask/_configmaterial.py | 44 ++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 54cc4fd7d..59339d056 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -236,16 +236,20 @@ class ConfigMaterial(Config): Parameters ---------- - constituents : dict, optional - Entries for 'constituents' as key-value pair. **kwargs Key-value pairs. + Returns + ------- + cfg : damask.ConfigMaterial + Updated material configuration. + Examples -------- + >>> import numpy as np >>> import damask - >>> m = damask.ConfigMaterial().material_add(phase = ['Aluminum','Steel','Aluminum'], - ... O = damask.Rotation.from_random(3)}, + >>> m = damask.ConfigMaterial().material_add(phase = ['Aluminum','Steel'], + ... O = damask.Rotation.from_random(2), ... homogenization = 'SX') >>> m material: @@ -259,11 +263,31 @@ class ConfigMaterial(Config): v: 1.0 phase: Steel homogenization: SX + homogenization: {} + phase: {} + + >>> m = damask.ConfigMaterial().material_add(phase = np.array(['Austenite','Martensite']).reshape(1,2), + ... O = damask.Rotation.from_random((2,2)), + ... v = np.array([0.2,0.8]).reshape(1,2), + ... homogenization = ['A','B']) + >>> m + material: - constituents: - - O: [0.0886257, -0.144848, 0.615674, -0.769487] - v: 1.0 - phase: Aluminum - homogenization: SX + - phase: Austenite + O: [0.659802978293224, 0.6953785848195171, 0.22426295326327111, -0.17554139512785227] + v: 0.2 + - phase: Martensite + O: [0.49356745891301596, 0.2841806579193434, -0.7487679215072818, -0.339085707289975] + v: 0.8 + homogenization: A + - constituents: + - phase: Austenite + O: [0.26542221365204055, 0.7268854930702071, 0.4474726435701472, -0.44828201137283735] + v: 0.2 + - phase: Martensite + O: [0.6545817158479885, -0.08004812803625233, -0.6226561293931374, 0.4212059104577611] + v: 0.8 + homogenization: B homogenization: {} phase: {} @@ -282,8 +306,8 @@ class ConfigMaterial(Config): shaped['v'] = np.broadcast_to(1/n,(N,n)) for k,v in shaped.items(): - obj = np.broadcast_to(v.reshape(util.shapeshifter(v.shape,(N,n,4))),(N,n,4)) if k=='O' else \ - np.broadcast_to(v.reshape(util.shapeshifter(v.shape,(N,n ))),(N,n)) + obj = np.broadcast_to(v.reshape(util.shapeshifter(v.shape,(N,n,4),mode='right')),(N,n,4)) if k=='O' else \ + np.broadcast_to(v.reshape(util.shapeshifter(v.shape,(N,n ),mode='right')),(N,n)) for i in range(N): if k in ['phase','O','v']: for j in range(n): From 0b08b3d2335a08de9de26bfbbde5cb2fa54b6c0d Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 23 Feb 2021 18:54:55 -0500 Subject: [PATCH 35/39] expanded help texts --- python/damask/_configmaterial.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 59339d056..51f18d53e 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -149,7 +149,7 @@ class ConfigMaterial(Config): @property def is_valid(self): - """Check for valid file layout.""" + """Check for valid content.""" ok = True if 'phase' in self: @@ -158,8 +158,7 @@ class ConfigMaterial(Config): try: Orientation(lattice=v['lattice']) except KeyError: - s = v['lattice'] - print(f"Invalid lattice: '{s}' in phase '{k}'") + print(f"Invalid lattice '{v['lattice']}' in phase '{k}'") ok = False if 'material' in self: @@ -167,16 +166,15 @@ class ConfigMaterial(Config): if 'constituents' in m: v = 0.0 for c in m['constituents']: - v+= float(c['v']) + v += float(c['v']) if 'O' in c: try: Rotation.from_quaternion(c['O']) except ValueError: - o = c['O'] - print(f"Invalid orientation: '{o}' in material '{i}'") + print(f"Invalid orientation '{c['O']}' in material '{i}'") ok = False if not np.isclose(v,1.0): - print(f"Invalid total fraction (v) '{v}' in material '{i}'") + print(f"Total fraction v = {v} ≠ 1 in material '{i}'") ok = False return ok @@ -195,6 +193,11 @@ class ConfigMaterial(Config): constituent: list of ints, optional Limit renaming to selected constituents. + Returns + ------- + cfg : damask.ConfigMaterial + Updated material configuration. + """ dup = self.copy() for i,m in enumerate(dup['material']): @@ -219,6 +222,11 @@ class ConfigMaterial(Config): ID: list of ints, optional Limit renaming to selected homogenization IDs. + Returns + ------- + cfg : damask.ConfigMaterial + Updated material configuration. + """ dup = self.copy() for i,m in enumerate(dup['material']): From 2dea705fa926ec8abd766c2bdae8cae7708898d4 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 23 Feb 2021 19:01:10 -0500 Subject: [PATCH 36/39] polishing/shortening --- python/damask/_configmaterial.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 51f18d53e..e2f34e92a 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -314,8 +314,8 @@ class ConfigMaterial(Config): shaped['v'] = np.broadcast_to(1/n,(N,n)) for k,v in shaped.items(): - obj = np.broadcast_to(v.reshape(util.shapeshifter(v.shape,(N,n,4),mode='right')),(N,n,4)) if k=='O' else \ - np.broadcast_to(v.reshape(util.shapeshifter(v.shape,(N,n ),mode='right')),(N,n)) + target = (N,n,4) if k=='O' else (N,n) + obj = np.broadcast_to(v.reshape(util.shapeshifter(v.shape,target,mode='right')),target) for i in range(N): if k in ['phase','O','v']: for j in range(n): From 086cec670c9a3487312aaf78f6a35d39b8e91c02 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 23 Feb 2021 23:09:53 -0500 Subject: [PATCH 37/39] using fixed tests --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index a8e76a140..0289c1bbf 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit a8e76a140f3f08a4dcfd3858d4b722cacd2bb2fd +Subproject commit 0289c1bbfec1a1aef77a8cbaeed134035549e738 From 2549d7a05a5dc94930a674d09aaa3456a583bb6e Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 24 Feb 2021 15:50:06 +0100 Subject: [PATCH 38/39] [skip ci] removed debug print statement --- python/tests/test_ConfigMaterial.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/tests/test_ConfigMaterial.py b/python/tests/test_ConfigMaterial.py index 6c316aeaa..5eb9a6c85 100644 --- a/python/tests/test_ConfigMaterial.py +++ b/python/tests/test_ConfigMaterial.py @@ -87,7 +87,6 @@ class TestConfigMaterial: def test_from_table(self): N = np.random.randint(3,10) a = np.vstack((np.hstack((np.arange(N),np.arange(N)[::-1])),np.ones(N*2),np.zeros(N*2),np.ones(N*2),np.ones(N*2))).T - print(a) t = Table(a,{'varying':1,'constant':4}) c = ConfigMaterial.from_table(t,**{'phase':'varying','O':'constant','homogenization':'4_constant'}) assert len(c['material']) == N From 9d93d4028d0d143c911e869e4b21a4906885f4d6 Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 24 Feb 2021 16:31:15 +0100 Subject: [PATCH 39/39] [skip ci] updated version information after successful test of v3.0.0-alpha2-530-g0d0226f70 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f00a64a89..3a0d0e38b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-520-g5ee538a38 +v3.0.0-alpha2-530-g0d0226f70