From 665dd3020da1a1d45a7631e25ed7433825d4966b Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Fri, 4 Dec 2020 03:30:39 +0100 Subject: [PATCH 001/352] new gmsh version --- PRIVATE | 2 +- src/mesh/discretization_mesh.f90 | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/PRIVATE b/PRIVATE index 68cde5229..113f44413 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 68cde52291ebb683ca6f610879f2ae28372597a7 +Subproject commit 113f44413c88e9b577f3781012592ea9a4836458 diff --git a/src/mesh/discretization_mesh.f90 b/src/mesh/discretization_mesh.f90 index 7dbd05e46..d998c84db 100644 --- a/src/mesh/discretization_mesh.f90 +++ b/src/mesh/discretization_mesh.f90 @@ -69,7 +69,7 @@ subroutine discretization_mesh_init(restart) integer, allocatable, dimension(:) :: chunkPos integer :: dimPlex, & mesh_Nnodes, & !< total number of nodes in mesh - j, l, & + j, l, k, & debug_element, debug_ip PetscSF :: sf DM :: globalMesh @@ -96,7 +96,6 @@ subroutine discretization_mesh_init(restart) debug_element = config_debug%get_asInt('element',defaultVal=1) debug_ip = config_debug%get_asInt('integrationpoint',defaultVal=1) - call DMPlexCreateFromFile(PETSC_COMM_WORLD,interface_geomFile,PETSC_TRUE,globalMesh,ierr) CHKERRQ(ierr) call DMGetDimension(globalMesh,dimPlex,ierr) @@ -137,11 +136,14 @@ subroutine discretization_mesh_init(restart) l = l + 1 if (trim(fileContent(l)) == '$EndElements') exit chunkPos = IO_stringPos(fileContent(l)) - if (chunkPos(1) == 3+IO_intValue(fileContent(l),chunkPos,3)+dimPlex+1) then - call DMSetLabelValue(globalMesh,'material',j,IO_intValue(fileContent(l),chunkPos,4),ierr) - CHKERRQ(ierr) - j = j + 1 + if(IO_intValue(fileContent(l),chunkPos,1) == 3) then + do k = 1, IO_intValue(fileContent(l),chunkPos,4) + call DMSetLabelValue(globalMesh,'material',j,IO_intValue(fileContent(l),chunkPos,2),ierr) + CHKERRQ(ierr) + j = j + 1 + enddo endif + l = l + IO_intValue(fileContent(l),chunkPos,4) enddo exit endif From 579d2a91471d6b8735bf0ccc1b8a819989077042 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Fri, 4 Dec 2020 13:05:54 +0100 Subject: [PATCH 002/352] test file updated --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 113f44413..df8eb2621 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 113f44413c88e9b577f3781012592ea9a4836458 +Subproject commit df8eb262174f2e07b3c5d6a8655022940c9fc5c9 From f563313ce97c61720d0daafe6f01498278e964fe Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Sat, 5 Dec 2020 23:52:30 +0100 Subject: [PATCH 003/352] PETSc provides subroutine to read physical tags --- src/mesh/discretization_mesh.f90 | 47 ++++++++++---------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/src/mesh/discretization_mesh.f90 b/src/mesh/discretization_mesh.f90 index d998c84db..69c86798e 100644 --- a/src/mesh/discretization_mesh.f90 +++ b/src/mesh/discretization_mesh.f90 @@ -83,6 +83,7 @@ subroutine discretization_mesh_init(restart) class(tNode), pointer :: & num_mesh integer :: integrationOrder !< order of quadrature rule required + print'(/,a)', ' <<<+- discretization_mesh init -+>>>' @@ -96,12 +97,16 @@ subroutine discretization_mesh_init(restart) debug_element = config_debug%get_asInt('element',defaultVal=1) debug_ip = config_debug%get_asInt('integrationpoint',defaultVal=1) + ! vol_tag = 10 call DMPlexCreateFromFile(PETSC_COMM_WORLD,interface_geomFile,PETSC_TRUE,globalMesh,ierr) CHKERRQ(ierr) call DMGetDimension(globalMesh,dimPlex,ierr) CHKERRQ(ierr) call DMGetStratumSize(globalMesh,'depth',dimPlex,mesh_NcpElemsGlobal,ierr) CHKERRQ(ierr) + call DMView(globalMesh, PETSC_VIEWER_STDOUT_WORLD,ierr) + CHKERRQ(ierr) + ! get number of IDs in face sets (for boundary conditions?) call DMGetLabelSize(globalMesh,'Face Sets',mesh_Nboundaries,ierr) CHKERRQ(ierr) @@ -109,6 +114,14 @@ subroutine discretization_mesh_init(restart) call MPI_Bcast(mesh_NcpElemsGlobal,1,MPI_INTEGER,0,PETSC_COMM_WORLD,ierr) call MPI_Bcast(dimPlex,1,MPI_INTEGER,0,PETSC_COMM_WORLD,ierr) + if (worldrank == 0) then + call DMClone(globalMesh,geomMesh,ierr) + CHKERRQ(ierr) + else + call DMPlexDistribute(globalMesh,0,sf,geomMesh,ierr) + CHKERRQ(ierr) + endif + allocate(mesh_boundaries(mesh_Nboundaries), source = 0) call DMGetLabelSize(globalMesh,'Face Sets',nFaceSets,ierr) CHKERRQ(ierr) @@ -123,38 +136,6 @@ subroutine discretization_mesh_init(restart) endif call MPI_Bcast(mesh_boundaries,mesh_Nboundaries,MPI_INTEGER,0,PETSC_COMM_WORLD,ierr) - if (worldrank == 0) then - fileContent = IO_readlines(interface_geomFile) - l = 0 - do - l = l + 1 - if (IO_isBlank(fileContent(l))) cycle ! need also to ignore C and C++ style comments? - if (trim(fileContent(l)) == '$Elements') then - j = 0 - l = l + 1 - do - l = l + 1 - if (trim(fileContent(l)) == '$EndElements') exit - chunkPos = IO_stringPos(fileContent(l)) - if(IO_intValue(fileContent(l),chunkPos,1) == 3) then - do k = 1, IO_intValue(fileContent(l),chunkPos,4) - call DMSetLabelValue(globalMesh,'material',j,IO_intValue(fileContent(l),chunkPos,2),ierr) - CHKERRQ(ierr) - j = j + 1 - enddo - endif - l = l + IO_intValue(fileContent(l),chunkPos,4) - enddo - exit - endif - enddo - call DMClone(globalMesh,geomMesh,ierr) - CHKERRQ(ierr) - else - call DMPlexDistribute(globalMesh,0,sf,geomMesh,ierr) - CHKERRQ(ierr) - endif - call DMDestroy(globalMesh,ierr); CHKERRQ(ierr) call DMGetStratumSize(geomMesh,'depth',dimPlex,mesh_NcpElems,ierr) @@ -169,7 +150,7 @@ subroutine discretization_mesh_init(restart) allocate(materialAt(mesh_NcpElems)) do j = 1, mesh_NcpElems - call DMGetLabelValue(geomMesh,'material',j-1,materialAt(j),ierr) + call DMGetLabelValue(geomMesh,'Cell Sets',j-1,materialAt(j),ierr) CHKERRQ(ierr) end do From 21faee4eaa9f5dddfa11f68a6795906eff55e9f5 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Mon, 7 Dec 2020 13:03:18 +0100 Subject: [PATCH 004/352] '0' based indexing --- PRIVATE | 2 +- src/mesh/discretization_mesh.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PRIVATE b/PRIVATE index df8eb2621..899f0ae9e 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit df8eb262174f2e07b3c5d6a8655022940c9fc5c9 +Subproject commit 899f0ae9e25ddad62530ec8a9381cf520aad083b diff --git a/src/mesh/discretization_mesh.f90 b/src/mesh/discretization_mesh.f90 index 69c86798e..0a9c5adaa 100644 --- a/src/mesh/discretization_mesh.f90 +++ b/src/mesh/discretization_mesh.f90 @@ -97,7 +97,6 @@ subroutine discretization_mesh_init(restart) debug_element = config_debug%get_asInt('element',defaultVal=1) debug_ip = config_debug%get_asInt('integrationpoint',defaultVal=1) - ! vol_tag = 10 call DMPlexCreateFromFile(PETSC_COMM_WORLD,interface_geomFile,PETSC_TRUE,globalMesh,ierr) CHKERRQ(ierr) call DMGetDimension(globalMesh,dimPlex,ierr) @@ -153,6 +152,7 @@ subroutine discretization_mesh_init(restart) call DMGetLabelValue(geomMesh,'Cell Sets',j-1,materialAt(j),ierr) CHKERRQ(ierr) end do + materialAt(:) = materialAt(:) + 1 if (debug_element < 1 .or. debug_element > mesh_NcpElems) call IO_error(602,ext_msg='element') if (debug_ip < 1 .or. debug_ip > mesh_maxNips) call IO_error(602,ext_msg='IP') From 6a58efeffe36e1843af85e670ec91468cdc0ce58 Mon Sep 17 00:00:00 2001 From: Vitesh Shah Date: Mon, 14 Dec 2020 09:14:03 +0100 Subject: [PATCH 005/352] Enabled sigterm handling --- src/DAMASK_interface.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index 41f421eb8..7490cb083 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -205,7 +205,7 @@ subroutine DAMASK_interface_init if (interface_restartInc > 0) & print'(a,i6.6)', ' Restart from increment: ', interface_restartInc - !call signalterm_c(c_funloc(catchSIGTERM)) + call signalterm_c(c_funloc(catchSIGTERM)) call signalusr1_c(c_funloc(catchSIGUSR1)) call signalusr2_c(c_funloc(catchSIGUSR2)) call interface_setSIGTERM(.false.) From 40bd5db361abbdbf71e595c05b149dec6d8de312 Mon Sep 17 00:00:00 2001 From: Vitesh Shah Date: Mon, 14 Dec 2020 09:17:15 +0100 Subject: [PATCH 006/352] signals enabling writing results,restart and termination --- src/grid/DAMASK_grid.f90 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index a8271cffc..f461fbf90 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -442,18 +442,19 @@ program DAMASK_grid print'(/,a,i0,a)', ' increment ', totalIncsCounter, ' NOT converged' endif; flush(IO_STDOUT) - if (mod(inc,loadCases(l)%f_out) == 0) then + if (mod(inc,loadCases(l)%f_out) == 0 .or. interface_SIGUSR1) then print'(1/,a)', ' ... writing results to file ......................................' flush(IO_STDOUT) call CPFEM_results(totalIncsCounter,time) endif - if (mod(inc,loadCases(l)%f_restart) == 0) then + if (mod(inc,loadCases(l)%f_restart) == 0 .or. interface_SIGUSR2) then call mech_restartWrite call CPFEM_restartWrite endif + if (interface_SIGTERM) exit loadCaseLooping endif skipping - enddo incLooping + enddo incLooping enddo loadCaseLooping From 768d139768be00bb61b08a80f9c2b63635007276 Mon Sep 17 00:00:00 2001 From: Vitesh Shah Date: Mon, 14 Dec 2020 09:34:35 +0100 Subject: [PATCH 007/352] reset the signal terms to false after task is done --- src/grid/DAMASK_grid.f90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index f461fbf90..4b9ee561a 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -446,10 +446,12 @@ program DAMASK_grid print'(1/,a)', ' ... writing results to file ......................................' flush(IO_STDOUT) call CPFEM_results(totalIncsCounter,time) + call interface_setSIGUSR1(.false.) endif if (mod(inc,loadCases(l)%f_restart) == 0 .or. interface_SIGUSR2) then call mech_restartWrite call CPFEM_restartWrite + call interface_setSIGUSR2(.false.) endif if (interface_SIGTERM) exit loadCaseLooping endif skipping From da1b006315c88abe8a19a775b354a8667ebeb927 Mon Sep 17 00:00:00 2001 From: Vitesh Shah Date: Thu, 17 Dec 2020 12:42:17 +0100 Subject: [PATCH 008/352] MPI communication for SIGUSRXXX --- src/grid/DAMASK_grid.f90 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 4b9ee561a..78e88b9b2 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -61,10 +61,13 @@ program DAMASK_grid logical :: & guess, & !< guess along former trajectory stagIterate, & - cutBack = .false. + cutBack = .false.,& + set_signal,& + set_signal1 integer :: & i, j, m, field, & errorID = 0, & + ierr,& cutBackLevel = 0, & !< cut back level \f$ t = \frac{t_{inc}}{2^l} \f$ stepFraction = 0, & !< fraction of current time interval l = 0, & !< current load case @@ -445,13 +448,17 @@ program DAMASK_grid if (mod(inc,loadCases(l)%f_out) == 0 .or. interface_SIGUSR1) then print'(1/,a)', ' ... writing results to file ......................................' flush(IO_STDOUT) + call MPI_ALLREDUCE(interface_SIGUSR1,set_signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) call CPFEM_results(totalIncsCounter,time) call interface_setSIGUSR1(.false.) + call MPI_ALLREDUCE(interface_SIGUSR1,set_signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) endif if (mod(inc,loadCases(l)%f_restart) == 0 .or. interface_SIGUSR2) then + call MPI_ALLREDUCE(interface_SIGUSR2,set_signal1,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) call mech_restartWrite call CPFEM_restartWrite call interface_setSIGUSR2(.false.) + call MPI_ALLREDUCE(interface_SIGUSR2,set_signal1,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) endif if (interface_SIGTERM) exit loadCaseLooping endif skipping From d83e8dac597a7d4865a6e3e04fcc478ff639b698 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 17 Dec 2020 13:20:18 +0100 Subject: [PATCH 009/352] need to share variable before if --- src/grid/DAMASK_grid.f90 | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 78e88b9b2..ef5546f7e 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -62,8 +62,7 @@ program DAMASK_grid guess, & !< guess along former trajectory stagIterate, & cutBack = .false.,& - set_signal,& - set_signal1 + signal integer :: & i, j, m, field, & errorID = 0, & @@ -445,22 +444,21 @@ program DAMASK_grid print'(/,a,i0,a)', ' increment ', totalIncsCounter, ' NOT converged' endif; flush(IO_STDOUT) - if (mod(inc,loadCases(l)%f_out) == 0 .or. interface_SIGUSR1) then + call MPI_ALLREDUCE(interface_SIGUSR1,signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) + call interface_setSIGUSR1(.false.) + if (mod(inc,loadCases(l)%f_out) == 0 .or. signal) then print'(1/,a)', ' ... writing results to file ......................................' flush(IO_STDOUT) - call MPI_ALLREDUCE(interface_SIGUSR1,set_signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) call CPFEM_results(totalIncsCounter,time) - call interface_setSIGUSR1(.false.) - call MPI_ALLREDUCE(interface_SIGUSR1,set_signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) endif - if (mod(inc,loadCases(l)%f_restart) == 0 .or. interface_SIGUSR2) then - call MPI_ALLREDUCE(interface_SIGUSR2,set_signal1,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) + call MPI_ALLREDUCE(interface_SIGUSR2,signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) + call interface_setSIGUSR2(.false.) + if (mod(inc,loadCases(l)%f_restart) == 0 .or. signal) then call mech_restartWrite call CPFEM_restartWrite - call interface_setSIGUSR2(.false.) - call MPI_ALLREDUCE(interface_SIGUSR2,set_signal1,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) endif - if (interface_SIGTERM) exit loadCaseLooping + call MPI_ALLREDUCE(interface_SIGTERM,signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) + if (signal) exit loadCaseLooping endif skipping enddo incLooping From 0a3d43e0fc6be8b908dc2e6ca9354e73bb09e3a4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 17 Dec 2020 15:17:20 +0100 Subject: [PATCH 010/352] only one process gets the signal: use OR, not AND --- src/grid/DAMASK_grid.f90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index ef5546f7e..d09469322 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -444,20 +444,23 @@ program DAMASK_grid print'(/,a,i0,a)', ' increment ', totalIncsCounter, ' NOT converged' endif; flush(IO_STDOUT) - call MPI_ALLREDUCE(interface_SIGUSR1,signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) + call MPI_Allreduce(interface_SIGUSR1,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) + if (ierr /= 0) error stop 'MPI error' call interface_setSIGUSR1(.false.) if (mod(inc,loadCases(l)%f_out) == 0 .or. signal) then print'(1/,a)', ' ... writing results to file ......................................' flush(IO_STDOUT) call CPFEM_results(totalIncsCounter,time) endif - call MPI_ALLREDUCE(interface_SIGUSR2,signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) + call MPI_Allreduce(interface_SIGUSR2,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) + if (ierr /= 0) error stop 'MPI error' call interface_setSIGUSR2(.false.) if (mod(inc,loadCases(l)%f_restart) == 0 .or. signal) then call mech_restartWrite call CPFEM_restartWrite endif - call MPI_ALLREDUCE(interface_SIGTERM,signal,1,MPI_LOGICAL,MPI_LAND,PETSC_COMM_WORLD,ierr) + call MPI_Allreduce(interface_SIGTERM,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) + if (ierr /= 0) error stop 'MPI error' if (signal) exit loadCaseLooping endif skipping From 615909a1bc934c7057b84bfbd74ecbc2dff901d8 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 09:47:20 +0100 Subject: [PATCH 011/352] consistent naming --- src/constitutive.f90 | 16 ++++++++-------- src/homogenization_mech.f90 | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 7e380f8cd..bed21cb92 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -1089,7 +1089,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) el !< counter in element loop integer :: & o, & - p, pp, m + p, ph, me real(pReal), dimension(3,3) :: devNull, & invSubFp0,invSubFi0,invFp,invFi, & @@ -1109,19 +1109,19 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) real(pReal), dimension(9,9):: temp_99 logical :: error - pp = material_phaseAt(co,el) - m = material_phaseMemberAt(co,ip,el) + ph = material_phaseAt(co,el) + me = material_phaseMemberAt(co,ip,el) call constitutive_hooke_SandItsTangents(devNull,dSdFe,dSdFi, & crystallite_Fe(1:3,1:3,co,ip,el), & - constitutive_mech_Fi(pp)%data(1:3,1:3,m),co,ip,el) + constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) call constitutive_LiAndItsTangents(devNull,dLidS,dLidFi, & crystallite_S (1:3,1:3,co,ip,el), & - constitutive_mech_Fi(pp)%data(1:3,1:3,m), & + constitutive_mech_Fi(ph)%data(1:3,1:3,me), & co,ip,el) - invFp = math_inv33(constitutive_mech_Fp(pp)%data(1:3,1:3,m)) - invFi = math_inv33(constitutive_mech_Fi(pp)%data(1:3,1:3,m)) + invFp = math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me)) + invFi = math_inv33(constitutive_mech_Fi(ph)%data(1:3,1:3,me)) invSubFp0 = math_inv33(crystallite_subFp0(1:3,1:3,co,ip,el)) invSubFi0 = math_inv33(crystallite_subFi0(1:3,1:3,co,ip,el)) @@ -1150,7 +1150,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) call constitutive_plastic_LpAndItsTangents(devNull,dLpdS,dLpdFi, & crystallite_S (1:3,1:3,co,ip,el), & - constitutive_mech_Fi(pp)%data(1:3,1:3,m),co,ip,el) + constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) dLpdS = math_mul3333xx3333(dLpdFi,dFidS) + dLpdS !-------------------------------------------------------------------------------------------------- diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index 56f1e554f..e4499e9b7 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -128,35 +128,35 @@ module subroutine mech_homogenize(ip,el) integer, intent(in) :: & ip, & !< integration point el !< element number - integer :: c,m + integer :: co,ce real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) - m = (el-1)* discretization_nIPs + ip + ce = (el-1)* discretization_nIPs + ip chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) case (HOMOGENIZATION_NONE_ID) chosenHomogenization - homogenization_P(1:3,1:3,m) = crystallite_P(1:3,1:3,1,ip,el) - homogenization_dPdF(1:3,1:3,1:3,1:3,m) = crystallite_stressTangent(1,ip,el) + homogenization_P(1:3,1:3,ce) = crystallite_P(1:3,1:3,1,ip,el) + homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = crystallite_stressTangent(1,ip,el) case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization - do c = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,c) = crystallite_stressTangent(c,ip,el) + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + dPdFs(:,:,:,:,co) = crystallite_stressTangent(co,ip,el) enddo call mech_isostrain_averageStressAndItsTangent(& - homogenization_P(1:3,1:3,m), & - homogenization_dPdF(1:3,1:3,1:3,1:3,m),& + homogenization_P(1:3,1:3,ce), & + homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & dPdFs, & homogenization_typeInstance(material_homogenizationAt(el))) case (HOMOGENIZATION_RGC_ID) chosenHomogenization - do c = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,c) = crystallite_stressTangent(c,ip,el) + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + dPdFs(:,:,:,:,co) = crystallite_stressTangent(co,ip,el) enddo call mech_RGC_averageStressAndItsTangent(& - homogenization_P(1:3,1:3,m), & - homogenization_dPdF(1:3,1:3,1:3,1:3,m),& + homogenization_P(1:3,1:3,ce), & + homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & dPdFs, & homogenization_typeInstance(material_homogenizationAt(el))) From ddb59b6ad07be5439a4ce0f0997c72c7b20bd9d1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 10:19:39 +0100 Subject: [PATCH 012/352] simplified --- src/homogenization.f90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 27fdb6064..896e4e790 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -255,10 +255,7 @@ subroutine materialpoint_stressAndItsTangent(dt) do co = 1, myNgrains converged = converged .and. crystallite_stress(dt*subStep,co,ip,el) enddo - endif - - if (requested .and. .not. doneAndHappy(1)) then if (.not. converged) then doneAndHappy = [.true.,.false.] else From cee04c9b5f0400d3435304331909f553db527857 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 10:22:03 +0100 Subject: [PATCH 013/352] not needed --- src/homogenization.f90 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 896e4e790..fc6b115ad 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -157,13 +157,12 @@ subroutine materialpoint_stressAndItsTangent(dt) subFrac, & subStep logical :: & - requested, & converged logical, dimension(2) :: & doneAndHappy -!$OMP PARALLEL DO PRIVATE(ce,myNgrains,NiterationMPstate,NiterationHomog,subFrac,converged,subStep,requested,doneAndHappy) +!$OMP PARALLEL DO PRIVATE(ce,myNgrains,NiterationMPstate,NiterationHomog,subFrac,converged,subStep,doneAndHappy) do el = FEsolving_execElem(1),FEsolving_execElem(2) do ip = FEsolving_execIP(1),FEsolving_execIP(2) @@ -174,7 +173,6 @@ subroutine materialpoint_stressAndItsTangent(dt) subFrac = 0.0_pReal converged = .false. ! pretend failed step ... subStep = 1.0_pReal/num%subStepSizeHomog ! ... larger then the requested calculation - requested = .true. ! everybody requires calculation if (homogState(material_homogenizationAt(el))%sizeState > 0) & homogState(material_homogenizationAt(el))%subState0(:,material_homogenizationMemberAt(ip,el)) = & @@ -231,13 +229,12 @@ subroutine materialpoint_stressAndItsTangent(dt) endif if (subStep > num%subStepMinHomog) then - requested = .true. doneAndHappy = [.false.,.true.] endif NiterationMPstate = 0 - convergenceLooping: do while (.not. terminallyIll .and. requested & + convergenceLooping: do while (.not. terminallyIll & .and. .not. doneAndHappy(1) & .and. NiterationMPstate < num%nMPstate) NiterationMPstate = NiterationMPstate + 1 @@ -245,7 +242,7 @@ subroutine materialpoint_stressAndItsTangent(dt) !-------------------------------------------------------------------------------------------------- ! deformation partitioning - if(requested .and. .not. doneAndHappy(1)) then ! requested but not yet done + if(.not. doneAndHappy(1)) then ce = (el-1)*discretization_nIPs + ip call mech_partition(homogenization_F0(1:3,1:3,ce) & + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce))& From e8ea815d9258c02afd60a47c829e638810cda56d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 11:48:02 +0100 Subject: [PATCH 014/352] simplified --- src/CPFEM.f90 | 5 +- src/CPFEM2.f90 | 1 - src/DAMASK_marc.f90 | 1 - src/FEsolving.f90 | 15 ------ src/commercialFEM_fileList.f90 | 1 - src/constitutive.f90 | 39 +++++--------- src/grid/discretization_grid.f90 | 4 -- src/grid/grid_mech_FEM.f90 | 1 - src/grid/grid_mech_spectral_basic.f90 | 1 - src/grid/grid_mech_spectral_polarisation.f90 | 1 - src/grid/spectral_utilities.f90 | 4 +- src/homogenization.f90 | 57 +++++++++++--------- src/marc/discretization_marc.f90 | 4 -- src/mesh/DAMASK_mesh.f90 | 1 - src/mesh/FEM_utilities.f90 | 2 +- src/mesh/discretization_mesh.f90 | 6 +-- 16 files changed, 49 insertions(+), 94 deletions(-) delete mode 100644 src/FEsolving.f90 diff --git a/src/CPFEM.f90 b/src/CPFEM.f90 index abbcce04a..240688a8c 100644 --- a/src/CPFEM.f90 +++ b/src/CPFEM.f90 @@ -5,7 +5,6 @@ !-------------------------------------------------------------------------------------------------- module CPFEM use prec - use FEsolving use math use rotations use YAML_types @@ -197,11 +196,9 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature_inp, dt, elFE, ip, cauchyS CPFEM_dcsde(1:6,1:6,ip,elCP) = ODD_JACOBIAN * math_eye(6) else validCalculation - FEsolving_execElem = elCP - FEsolving_execIP = ip if (debugCPFEM%extensive) & print'(a,i8,1x,i2)', '<< CPFEM >> calculation for elFE ip ',elFE,ip - call materialpoint_stressAndItsTangent(dt) + call materialpoint_stressAndItsTangent(dt,[ip,ip],[elCP,elCP]) terminalIllness: if (terminallyIll) then diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index 44b93d1cb..5a500875d 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -6,7 +6,6 @@ module CPFEM2 use prec use config - use FEsolving use math use rotations use YAML_types diff --git a/src/DAMASK_marc.f90 b/src/DAMASK_marc.f90 index ea7430c6b..0ad68445c 100644 --- a/src/DAMASK_marc.f90 +++ b/src/DAMASK_marc.f90 @@ -176,7 +176,6 @@ subroutine hypela2(d,g,e,de,s,t,dt,ngens,m,nn,kcus,matus,ndi,nshear,disp, & use DAMASK_interface use config use YAML_types - use FEsolving use discretization_marc use homogenization use CPFEM diff --git a/src/FEsolving.f90 b/src/FEsolving.f90 deleted file mode 100644 index 3fc1482d3..000000000 --- a/src/FEsolving.f90 +++ /dev/null @@ -1,15 +0,0 @@ -!-------------------------------------------------------------------------------------------------- -!> @author Franz Roters, Max-Planck-Institut für Eisenforschung GmbH -!> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH -!> @brief global variables for flow control -!-------------------------------------------------------------------------------------------------- -module FEsolving - - implicit none - public - - integer, dimension(2) :: & - FEsolving_execElem, & !< for ping-pong scheme always whole range, otherwise one specific element - FEsolving_execIP !< for ping-pong scheme always range to max IP, otherwise one specific IP - -end module FEsolving diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 08e7b9c1c..d8ab6390d 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -13,7 +13,6 @@ #include "math.f90" #include "quaternions.f90" #include "rotations.f90" -#include "FEsolving.f90" #include "element.f90" #include "HDF5_utilities.f90" #include "results.f90" diff --git a/src/constitutive.f90 b/src/constitutive.f90 index bed21cb92..b3fb0b246 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -16,7 +16,6 @@ module constitutive use parallelization use HDF5_utilities use DAMASK_interface - use FEsolving use results implicit none @@ -940,8 +939,8 @@ subroutine crystallite_init flush(IO_STDOUT) !$OMP PARALLEL DO PRIVATE(ph,me) - do el = FEsolving_execElem(1),FEsolving_execElem(2) - do ip = FEsolving_execIP(1), FEsolving_execIP(2); do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + do el = 1, size(material_phaseMemberAt,3) + do ip = 1, size(material_phaseMemberAt,2); do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) @@ -967,14 +966,14 @@ subroutine crystallite_init crystallite_partitionedF0 = crystallite_F0 crystallite_partitionedF = crystallite_F0 - call crystallite_orientations() !$OMP PARALLEL DO PRIVATE(ph,me) - do el = FEsolving_execElem(1),FEsolving_execElem(2) - do ip = FEsolving_execIP(1),FEsolving_execIP(2) + do el = 1, size(material_phaseMemberAt,3) + do ip = 1, size(material_phaseMemberAt,2) do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) + call crystallite_orientations(co,ip,el) call constitutive_plastic_dependentState(crystallite_partitionedF0(1:3,1:3,co,ip,el),co,ip,el) ! update dependent state variables to be consistent with basic states enddo enddo @@ -1210,34 +1209,20 @@ end function crystallite_stressTangent !-------------------------------------------------------------------------------------------------- !> @brief calculates orientations !-------------------------------------------------------------------------------------------------- -subroutine crystallite_orientations +subroutine crystallite_orientations(co,ip,el) - integer & + integer, intent(in) :: & co, & !< counter in integration point component loop ip, & !< counter in integration point loop el !< counter in element loop - !$OMP PARALLEL DO - do el = FEsolving_execElem(1),FEsolving_execElem(2) - do ip = FEsolving_execIP(1),FEsolving_execIP(2) - do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - call crystallite_orientation(co,ip,el)%fromMatrix(transpose(math_rotationalPart(crystallite_Fe(1:3,1:3,co,ip,el)))) - enddo; enddo; enddo - !$OMP END PARALLEL DO + call crystallite_orientation(co,ip,el)%fromMatrix(transpose(math_rotationalPart(crystallite_Fe(1:3,1:3,co,ip,el)))) + + if (plasticState(material_phaseAt(1,el))%nonlocal) & + call plastic_nonlocal_updateCompatibility(crystallite_orientation, & + phase_plasticityInstance(material_phaseAt(1,el)),ip,el) - nonlocalPresent: if (any(plasticState%nonlocal)) then - !$OMP PARALLEL DO - do el = FEsolving_execElem(1),FEsolving_execElem(2) - if (plasticState(material_phaseAt(1,el))%nonlocal) then - do ip = FEsolving_execIP(1),FEsolving_execIP(2) - call plastic_nonlocal_updateCompatibility(crystallite_orientation, & - phase_plasticityInstance(material_phaseAt(1,el)),ip,el) - enddo - endif - enddo - !$OMP END PARALLEL DO - endif nonlocalPresent end subroutine crystallite_orientations diff --git a/src/grid/discretization_grid.f90 b/src/grid/discretization_grid.f90 index 1b3700c14..48ad5b7e1 100644 --- a/src/grid/discretization_grid.f90 +++ b/src/grid/discretization_grid.f90 @@ -19,7 +19,6 @@ module discretization_grid use results use discretization use geometry_plastic_nonlocal - use FEsolving implicit none private @@ -117,9 +116,6 @@ subroutine discretization_grid_init(restart) (grid(1)+1) * (grid(2)+1) * grid3,& ! ...unless not last process worldrank+1==worldsize)) - FEsolving_execElem = [1,product(myGrid)] ! parallel loop bounds set to comprise all elements - FEsolving_execIP = [1,1] ! parallel loop bounds set to comprise the only IP - !-------------------------------------------------------------------------------------------------- ! store geometry information for post processing if(.not. restart) then diff --git a/src/grid/grid_mech_FEM.f90 b/src/grid/grid_mech_FEM.f90 index cdf806b35..003f568c6 100644 --- a/src/grid/grid_mech_FEM.f90 +++ b/src/grid/grid_mech_FEM.f90 @@ -18,7 +18,6 @@ module grid_mech_FEM use math use rotations use spectral_utilities - use FEsolving use config use homogenization use discretization diff --git a/src/grid/grid_mech_spectral_basic.f90 b/src/grid/grid_mech_spectral_basic.f90 index ebaaf3b55..9bc36165f 100644 --- a/src/grid/grid_mech_spectral_basic.f90 +++ b/src/grid/grid_mech_spectral_basic.f90 @@ -18,7 +18,6 @@ module grid_mech_spectral_basic use math use rotations use spectral_utilities - use FEsolving use config use homogenization use discretization_grid diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index 9f2a17c97..7160c1adc 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -18,7 +18,6 @@ module grid_mech_spectral_polarisation use math use rotations use spectral_utilities - use FEsolving use config use homogenization use discretization_grid diff --git a/src/grid/spectral_utilities.f90 b/src/grid/spectral_utilities.f90 index c0c84233d..e8bae223a 100644 --- a/src/grid/spectral_utilities.f90 +++ b/src/grid/spectral_utilities.f90 @@ -810,9 +810,9 @@ subroutine utilities_constitutiveResponse(P,P_av,C_volAvg,C_minmaxAvg,& print'(/,a)', ' ... evaluating constitutive response ......................................' flush(IO_STDOUT) - homogenization_F = reshape(F,[3,3,product(grid(1:2))*grid3]) ! set materialpoint target F to estimated field + homogenization_F = reshape(F,[3,3,product(grid(1:2))*grid3]) ! set materialpoint target F to estimated field - call materialpoint_stressAndItsTangent(timeinc) ! calculate P field + call materialpoint_stressAndItsTangent(timeinc,[1,1],[1,product(grid(1:2))*grid3]) ! calculate P field P = reshape(homogenization_P, [3,3,grid(1),grid(2),grid3]) P_av = sum(sum(sum(P,dim=5),dim=4),dim=3) * wgt ! average of P diff --git a/src/homogenization.f90 b/src/homogenization.f90 index fc6b115ad..13e098ac0 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -11,7 +11,6 @@ module homogenization use math use material use constitutive - use FEsolving use discretization use thermal_isothermal use thermal_conduction @@ -144,15 +143,16 @@ end subroutine homogenization_init !-------------------------------------------------------------------------------------------------- !> @brief parallelized calculation of stress and corresponding tangent at material points !-------------------------------------------------------------------------------------------------- -subroutine materialpoint_stressAndItsTangent(dt) +subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execElem) real(pReal), intent(in) :: dt !< time increment + integer, dimension(2), intent(in) :: FEsolving_execElem, FEsolving_execIP integer :: & NiterationHomog, & NiterationMPstate, & ip, & !< integration point number el, & !< element number - myNgrains, co, ce + myNgrains, co, ce, ho real(pReal) :: & subFrac, & subStep @@ -162,8 +162,10 @@ subroutine materialpoint_stressAndItsTangent(dt) doneAndHappy -!$OMP PARALLEL DO PRIVATE(ce,myNgrains,NiterationMPstate,NiterationHomog,subFrac,converged,subStep,doneAndHappy) +!$OMP PARALLEL DO PRIVATE(ce,ho,myNgrains,NiterationMPstate,NiterationHomog,subFrac,converged,subStep,doneAndHappy) do el = FEsolving_execElem(1),FEsolving_execElem(2) + ho = material_homogenizationAt(el) + myNgrains = homogenization_Nconstituents(ho) do ip = FEsolving_execIP(1),FEsolving_execIP(2) !-------------------------------------------------------------------------------------------------- @@ -174,18 +176,19 @@ subroutine materialpoint_stressAndItsTangent(dt) converged = .false. ! pretend failed step ... subStep = 1.0_pReal/num%subStepSizeHomog ! ... larger then the requested calculation - if (homogState(material_homogenizationAt(el))%sizeState > 0) & - homogState(material_homogenizationAt(el))%subState0(:,material_homogenizationMemberAt(ip,el)) = & - homogState(material_homogenizationAt(el))%State0( :,material_homogenizationMemberAt(ip,el)) + if (homogState(ho)%sizeState > 0) & + homogState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) = & + homogState(ho)%State0( :,material_homogenizationMemberAt(ip,el)) + + if (damageState(ho)%sizeState > 0) & + damageState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) = & + damageState(ho)%State0( :,material_homogenizationMemberAt(ip,el)) - if (damageState(material_homogenizationAt(el))%sizeState > 0) & - damageState(material_homogenizationAt(el))%subState0(:,material_homogenizationMemberAt(ip,el)) = & - damageState(material_homogenizationAt(el))%State0( :,material_homogenizationMemberAt(ip,el)) NiterationHomog = 0 cutBackLooping: do while (.not. terminallyIll .and. subStep > num%subStepMinHomog) - myNgrains = homogenization_Nconstituents(material_homogenizationAt(el)) + if (converged) then subFrac = subFrac + subStep @@ -196,12 +199,12 @@ subroutine materialpoint_stressAndItsTangent(dt) ! wind forward grain starting point call constitutive_windForward(ip,el) - if(homogState(material_homogenizationAt(el))%sizeState > 0) & - homogState(material_homogenizationAt(el))%subState0(:,material_homogenizationMemberAt(ip,el)) = & - homogState(material_homogenizationAt(el))%State (:,material_homogenizationMemberAt(ip,el)) - if(damageState(material_homogenizationAt(el))%sizeState > 0) & - damageState(material_homogenizationAt(el))%subState0(:,material_homogenizationMemberAt(ip,el)) = & - damageState(material_homogenizationAt(el))%State (:,material_homogenizationMemberAt(ip,el)) + if(homogState(ho)%sizeState > 0) & + homogState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) = & + homogState(ho)%State (:,material_homogenizationMemberAt(ip,el)) + if(damageState(ho)%sizeState > 0) & + damageState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) = & + damageState(ho)%State (:,material_homogenizationMemberAt(ip,el)) endif steppingNeeded @@ -219,12 +222,12 @@ subroutine materialpoint_stressAndItsTangent(dt) call crystallite_restore(ip,el,subStep < 1.0_pReal) call constitutive_restore(ip,el) - if(homogState(material_homogenizationAt(el))%sizeState > 0) & - homogState(material_homogenizationAt(el))%State( :,material_homogenizationMemberAt(ip,el)) = & - homogState(material_homogenizationAt(el))%subState0(:,material_homogenizationMemberAt(ip,el)) - if(damageState(material_homogenizationAt(el))%sizeState > 0) & - damageState(material_homogenizationAt(el))%State( :,material_homogenizationMemberAt(ip,el)) = & - damageState(material_homogenizationAt(el))%subState0(:,material_homogenizationMemberAt(ip,el)) + if(homogState(ho)%sizeState > 0) & + homogState(ho)%State( :,material_homogenizationMemberAt(ip,el)) = & + homogState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) + if(damageState(ho)%sizeState > 0) & + damageState(ho)%State( :,material_homogenizationMemberAt(ip,el)) = & + damageState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) endif endif @@ -275,10 +278,14 @@ subroutine materialpoint_stressAndItsTangent(dt) !$OMP END PARALLEL DO if (.not. terminallyIll ) then - call crystallite_orientations() ! calculate crystal orientations - !$OMP PARALLEL DO + !$OMP PARALLEL DO PRIVATE(ho,myNgrains) elementLooping3: do el = FEsolving_execElem(1),FEsolving_execElem(2) + ho = material_homogenizationAt(el) + myNgrains = homogenization_Nconstituents(ho) IpLooping3: do ip = FEsolving_execIP(1),FEsolving_execIP(2) + do co = 1, myNgrains + call crystallite_orientations(co,ip,el) + enddo call mech_homogenize(ip,el) enddo IpLooping3 enddo elementLooping3 diff --git a/src/marc/discretization_marc.f90 b/src/marc/discretization_marc.f90 index ca0b54b73..675e57bd3 100644 --- a/src/marc/discretization_marc.f90 +++ b/src/marc/discretization_marc.f90 @@ -12,7 +12,6 @@ module discretization_marc use DAMASK_interface use IO use config - use FEsolving use element use discretization use geometry_plastic_nonlocal @@ -89,9 +88,6 @@ subroutine discretization_marc_init if (debug_e < 1 .or. debug_e > nElems) call IO_error(602,ext_msg='element') if (debug_i < 1 .or. debug_i > elem%nIPs) call IO_error(602,ext_msg='IP') - FEsolving_execElem = [1,nElems] - FEsolving_execIP = [1,elem%nIPs] - allocate(cellNodeDefinition(elem%nNodes-1)) allocate(connectivity_cell(elem%NcellNodesPerCell,elem%nIPs,nElems)) call buildCells(connectivity_cell,cellNodeDefinition,& diff --git a/src/mesh/DAMASK_mesh.f90 b/src/mesh/DAMASK_mesh.f90 index 1e353892c..7369520c1 100644 --- a/src/mesh/DAMASK_mesh.f90 +++ b/src/mesh/DAMASK_mesh.f90 @@ -15,7 +15,6 @@ program DAMASK_mesh use IO use math use CPFEM2 - use FEsolving use config use discretization_mesh use FEM_Utilities diff --git a/src/mesh/FEM_utilities.f90 b/src/mesh/FEM_utilities.f90 index cb81f1f0c..2f3633e11 100644 --- a/src/mesh/FEM_utilities.f90 +++ b/src/mesh/FEM_utilities.f90 @@ -160,7 +160,7 @@ subroutine utilities_constitutiveResponse(timeinc,P_av,forwardData) print'(/,a)', ' ... evaluating constitutive response ......................................' - call materialpoint_stressAndItsTangent(timeinc) ! calculate P field + call materialpoint_stressAndItsTangent(timeinc,[1,mesh_maxNips],[1,mesh_NcpElems]) ! calculate P field cutBack = .false. ! reset cutBack status diff --git a/src/mesh/discretization_mesh.f90 b/src/mesh/discretization_mesh.f90 index 7dbd05e46..21c5feace 100644 --- a/src/mesh/discretization_mesh.f90 +++ b/src/mesh/discretization_mesh.f90 @@ -18,7 +18,6 @@ module discretization_mesh use config use discretization use results - use FEsolving use FEM_quadrature use YAML_types use prec @@ -30,7 +29,7 @@ module discretization_mesh mesh_Nboundaries, & mesh_NcpElemsGlobal - integer :: & + integer, public, protected :: & mesh_NcpElems !< total number of CP elements in mesh !!!! BEGIN DEPRECATED !!!!! @@ -174,9 +173,6 @@ subroutine discretization_mesh_init(restart) if (debug_element < 1 .or. debug_element > mesh_NcpElems) call IO_error(602,ext_msg='element') if (debug_ip < 1 .or. debug_ip > mesh_maxNips) call IO_error(602,ext_msg='IP') - FEsolving_execElem = [1,mesh_NcpElems] ! parallel loop bounds set to comprise all DAMASK elements - FEsolving_execIP = [1,mesh_maxNips] - allocate(mesh_node0(3,mesh_Nnodes),source=0.0_pReal) call discretization_init(materialAt,& From 609d69a3e7bc41f5e6868307c7f9f35b687ca865 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 13:33:14 +0100 Subject: [PATCH 015/352] polishing --- src/homogenization.f90 | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 13e098ac0..ebf5fd50d 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -188,8 +188,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE NiterationHomog = 0 cutBackLooping: do while (.not. terminallyIll .and. subStep > num%subStepMinHomog) - - if (converged) then subFrac = subFrac + subStep subStep = min(1.0_pReal-subFrac,num%stepIncreaseHomog*subStep) ! introduce flexibility for step increase/acceleration @@ -207,14 +205,12 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE damageState(ho)%State (:,material_homogenizationMemberAt(ip,el)) endif steppingNeeded - else if ( (myNgrains == 1 .and. subStep <= 1.0 ) .or. & ! single grain already tried internal subStepping in crystallite num%subStepSizeHomog * subStep <= num%subStepMinHomog ) then ! would require too small subStep ! cutback makes no sense - if (.not. terminallyIll) then ! so first signals terminally ill... + if (.not. terminallyIll) & ! so first signals terminally ill... print*, ' Integration point ', ip,' at element ', el, ' terminally ill' - endif terminallyIll = .true. ! ...and kills all others else ! cutback makes sense subStep = num%subStepSizeHomog * subStep ! crystallite had severe trouble, so do a significant cutback @@ -231,10 +227,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE endif endif - if (subStep > num%subStepMinHomog) then - doneAndHappy = [.false.,.true.] - endif - + if (subStep > num%subStepMinHomog) doneAndHappy = [.false.,.true.] NiterationMPstate = 0 convergenceLooping: do while (.not. terminallyIll & @@ -245,7 +238,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE !-------------------------------------------------------------------------------------------------- ! deformation partitioning - if(.not. doneAndHappy(1)) then + if (.not. doneAndHappy(1)) then ce = (el-1)*discretization_nIPs + ip call mech_partition(homogenization_F0(1:3,1:3,ce) & + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce))& From 2eed6fdfdbebf6bfdc68f98062cbad6979e393ef Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 16:13:31 +0100 Subject: [PATCH 016/352] not needed as global variable --- src/constitutive.f90 | 28 +++++++-------- src/constitutive_mech.f90 | 73 ++++++++++++++++----------------------- 2 files changed, 41 insertions(+), 60 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index b3fb0b246..e65ce864d 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -64,10 +64,6 @@ module constitutive real(pReal), dimension(:,:,:,:,:), allocatable, public :: & crystallite_partitionedF !< def grad to be reached at end of homog inc - logical, dimension(:,:,:), allocatable :: & - crystallite_converged !< convergence flag - - type :: tTensorContainer real(pReal), dimension(:,:,:), allocatable :: data end type @@ -185,10 +181,10 @@ module constitutive ! == cleaned:end =================================================================================== - module function crystallite_stress(dt,co,ip,el) + module function crystallite_stress(dt,co,ip,el) result(converged_) real(pReal), intent(in) :: dt integer, intent(in) :: co, ip, el - logical :: crystallite_stress + logical :: converged_ end function crystallite_stress module function constitutive_homogenizedC(co,ip,el) result(C) @@ -872,10 +868,8 @@ subroutine crystallite_init source = crystallite_partitionedF) allocate(crystallite_subdt(cMax,iMax,eMax),source=0.0_pReal) - allocate(crystallite_orientation(cMax,iMax,eMax)) - allocate(crystallite_converged(cMax,iMax,eMax), source=.true.) num_crystallite => config_numerics%get('crystallite',defaultVal=emptyDict) @@ -1253,7 +1247,7 @@ end function crystallite_push33ToRef !> @brief integrate stress, state with adaptive 1st order explicit Euler method !> using Fixed Point Iteration to adapt the stepsize !-------------------------------------------------------------------------------------------------- -subroutine integrateSourceState(co,ip,el) +function integrateSourceState(co,ip,el) result(broken) integer, intent(in) :: & el, & !< element index in element loop @@ -1273,12 +1267,13 @@ subroutine integrateSourceState(co,ip,el) r ! state residuum real(pReal), dimension(constitutive_source_maxSizeDotState,2,maxval(phase_Nsources)) :: source_dotState logical :: & - broken + broken, converged_ ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) + converged_ = .true. broken = constitutive_thermal_collectDotState(ph,me) broken = broken .or. constitutive_damage_collectDotState(crystallite_S(1:3,1:3,co,ip,el), co,ip,el,ph,me) if(broken) return @@ -1313,19 +1308,20 @@ subroutine integrateSourceState(co,ip,el) - sourceState(ph)%p(so)%dotState (1:size_so(so),me) * crystallite_subdt(co,ip,el) sourceState(ph)%p(so)%state(1:size_so(so),me) = sourceState(ph)%p(so)%state(1:size_so(so),me) & - r(1:size_so(so)) - crystallite_converged(co,ip,el) = & - crystallite_converged(co,ip,el) .and. converged(r(1:size_so(so)), & - sourceState(ph)%p(so)%state(1:size_so(so),me), & - sourceState(ph)%p(so)%atol(1:size_so(so))) + converged_ = converged_ .and. converged(r(1:size_so(so)), & + sourceState(ph)%p(so)%state(1:size_so(so),me), & + sourceState(ph)%p(so)%atol(1:size_so(so))) enddo - if(crystallite_converged(co,ip,el)) then + if(converged_) then broken = constitutive_damage_deltaState(crystallite_Fe(1:3,1:3,co,ip,el),co,ip,el,ph,me) exit iteration endif enddo iteration + broken = broken .or. .not. converged_ + contains @@ -1349,7 +1345,7 @@ subroutine integrateSourceState(co,ip,el) end function damper -end subroutine integrateSourceState +end function integrateSourceState !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 7a2224ede..de6f2ae9f 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -951,7 +951,7 @@ end function integrateStress !> @brief integrate stress, state with adaptive 1st order explicit Euler method !> using Fixed Point Iteration to adapt the stepsize !-------------------------------------------------------------------------------------------------- -subroutine integrateStateFPI(F_0,F,Delta_t,co,ip,el) +function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) real(pReal), intent(in),dimension(3,3) :: F_0,F real(pReal), intent(in) :: Delta_t @@ -1004,11 +1004,7 @@ subroutine integrateStateFPI(F_0,F,Delta_t,co,ip,el) - plasticState(ph)%dotState (1:size_pl,me) * Delta_t plasticState(ph)%state(1:size_pl,me) = plasticState(ph)%state(1:size_pl,me) & - r(1:size_pl) - crystallite_converged(co,ip,el) = converged(r(1:size_pl), & - plasticState(ph)%state(1:size_pl,me), & - plasticState(ph)%atol(1:size_pl)) - - if(crystallite_converged(co,ip,el)) then + if (converged(r(1:size_pl),plasticState(ph)%state(1:size_pl,me),plasticState(ph)%atol(1:size_pl))) then broken = constitutive_deltaState(crystallite_S(1:3,1:3,co,ip,el), & constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) exit iteration @@ -1016,7 +1012,6 @@ subroutine integrateStateFPI(F_0,F,Delta_t,co,ip,el) enddo iteration - contains !-------------------------------------------------------------------------------------------------- @@ -1039,13 +1034,13 @@ subroutine integrateStateFPI(F_0,F,Delta_t,co,ip,el) end function damper -end subroutine integrateStateFPI +end function integrateStateFPI !-------------------------------------------------------------------------------------------------- !> @brief integrate state with 1st order explicit Euler method !-------------------------------------------------------------------------------------------------- -subroutine integrateStateEuler(F_0,F,Delta_t,co,ip,el) +function integrateStateEuler(F_0,F,Delta_t,co,ip,el) result(broken) real(pReal), intent(in),dimension(3,3) :: F_0,F real(pReal), intent(in) :: Delta_t @@ -1075,15 +1070,14 @@ subroutine integrateStateEuler(F_0,F,Delta_t,co,ip,el) if(broken) return broken = integrateStress(F,Delta_t,co,ip,el) - crystallite_converged(co,ip,el) = .not. broken -end subroutine integrateStateEuler +end function integrateStateEuler !-------------------------------------------------------------------------------------------------- !> @brief integrate stress, state with 1st order Euler method with adaptive step size !-------------------------------------------------------------------------------------------------- -subroutine integrateStateAdaptiveEuler(F_0,F,Delta_t,co,ip,el) +function integrateStateAdaptiveEuler(F_0,F,Delta_t,co,ip,el) result(broken) real(pReal), intent(in),dimension(3,3) :: F_0,F real(pReal), intent(in) :: Delta_t @@ -1123,24 +1117,22 @@ subroutine integrateStateAdaptiveEuler(F_0,F,Delta_t,co,ip,el) broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) if(broken) return + broken = .not. converged(residuum_plastic(1:sizeDotState) + 0.5_pReal * plasticState(ph)%dotState(:,me) * Delta_t, & + plasticState(ph)%state(1:sizeDotState,me), & + plasticState(ph)%atol(1:sizeDotState)) - sizeDotState = plasticState(ph)%sizeDotState - crystallite_converged(co,ip,el) = converged(residuum_plastic(1:sizeDotState) & - + 0.5_pReal * plasticState(ph)%dotState(:,me) * Delta_t, & - plasticState(ph)%state(1:sizeDotState,me), & - plasticState(ph)%atol(1:sizeDotState)) - -end subroutine integrateStateAdaptiveEuler +end function integrateStateAdaptiveEuler !--------------------------------------------------------------------------------------------------- !> @brief Integrate state (including stress integration) with the classic Runge Kutta method !--------------------------------------------------------------------------------------------------- -subroutine integrateStateRK4(F_0,F,Delta_t,co,ip,el) +function integrateStateRK4(F_0,F,Delta_t,co,ip,el) result(broken) real(pReal), intent(in),dimension(3,3) :: F_0,F real(pReal), intent(in) :: Delta_t integer, intent(in) :: co,ip,el + logical :: broken real(pReal), dimension(3,3), parameter :: & A = reshape([& @@ -1153,19 +1145,20 @@ subroutine integrateStateRK4(F_0,F,Delta_t,co,ip,el) real(pReal), dimension(4), parameter :: & B = [1.0_pReal/6.0_pReal, 1.0_pReal/3.0_pReal, 1.0_pReal/3.0_pReal, 1.0_pReal/6.0_pReal] - call integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C) + broken = integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C) -end subroutine integrateStateRK4 +end function integrateStateRK4 !--------------------------------------------------------------------------------------------------- !> @brief Integrate state (including stress integration) with the Cash-Carp method !--------------------------------------------------------------------------------------------------- -subroutine integrateStateRKCK45(F_0,F,Delta_t,co,ip,el) +function integrateStateRKCK45(F_0,F,Delta_t,co,ip,el) result(broken) real(pReal), intent(in),dimension(3,3) :: F_0,F real(pReal), intent(in) :: Delta_t integer, intent(in) :: co,ip,el + logical :: broken real(pReal), dimension(5,5), parameter :: & A = reshape([& @@ -1185,16 +1178,16 @@ subroutine integrateStateRKCK45(F_0,F,Delta_t,co,ip,el) [2825.0_pReal/27648.0_pReal, .0_pReal, 18575.0_pReal/48384.0_pReal,& 13525.0_pReal/55296.0_pReal, 277.0_pReal/14336.0_pReal, 1._pReal/4._pReal] - call integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) + broken = integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) -end subroutine integrateStateRKCK45 +end function integrateStateRKCK45 !-------------------------------------------------------------------------------------------------- !> @brief Integrate state (including stress integration) with an explicit Runge-Kutta method or an !! embedded explicit Runge-Kutta method !-------------------------------------------------------------------------------------------------- -subroutine integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) +function integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) result(broken) real(pReal), intent(in),dimension(3,3) :: F_0,F real(pReal), intent(in) :: Delta_t @@ -1205,15 +1198,14 @@ subroutine integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) el, & !< element index in element loop ip, & !< integration point index in ip loop co !< grain index in grain loop + logical :: broken - integer :: & + integer :: & stage, & ! stage index in integration stage loop n, & ph, & me, & sizeDotState - logical :: & - broken real(pReal), dimension(constitutive_plasticity_maxSizeDotState,size(B)) :: plastic_RKdotState @@ -1266,10 +1258,8 @@ subroutine integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) if(broken) return broken = integrateStress(F,Delta_t,co,ip,el) - crystallite_converged(co,ip,el) = .not. broken - -end subroutine integrateStateRK +end function integrateStateRK !-------------------------------------------------------------------------------------------------- @@ -1479,15 +1469,14 @@ end function constitutive_homogenizedC !-------------------------------------------------------------------------------------------------- !> @brief calculate stress (P) !-------------------------------------------------------------------------------------------------- -module function crystallite_stress(dt,co,ip,el) +module function crystallite_stress(dt,co,ip,el) result(converged_) real(pReal), intent(in) :: dt integer, intent(in) :: & co, & ip, & el - - logical :: crystallite_stress + logical :: converged_ real(pReal) :: & formerSubStep @@ -1519,7 +1508,7 @@ module function crystallite_stress(dt,co,ip,el) subFrac = 0.0_pReal subStep = 1.0_pReal/num%subStepSizeCryst todo = .true. - crystallite_converged(co,ip,el) = .false. ! pretend failed step of 1/subStepSizeCryst + converged_ = .false. ! pretend failed step of 1/subStepSizeCryst todo = .true. NiterationCrystallite = 0 @@ -1528,7 +1517,7 @@ module function crystallite_stress(dt,co,ip,el) !-------------------------------------------------------------------------------------------------- ! wind forward - if (crystallite_converged(co,ip,el)) then + if (converged_) then formerSubStep = subStep subFrac = subFrac + subStep subStep = min(1.0_pReal - subFrac, num%stepIncreaseCryst * subStep) @@ -1579,17 +1568,13 @@ module function crystallite_stress(dt,co,ip,el) math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) crystallite_subdt(co,ip,el) = subStep * dt - crystallite_converged(co,ip,el) = .false. - call integrateState(subF0,crystallite_subF(1:3,1:3,co,ip,el),& - crystallite_subdt(co,ip,el),co,ip,el) - call integrateSourceState(co,ip,el) + converged_ = .not. integrateState(subF0,crystallite_subF(1:3,1:3,co,ip,el),& + crystallite_subdt(co,ip,el),co,ip,el) + converged_ = converged_ .and. .not. integrateSourceState(co,ip,el) endif enddo cutbackLooping -! return whether converged or not - crystallite_stress = crystallite_converged(co,ip,el) - end function crystallite_stress end submodule constitutive_mech From 6efc61c4798fafd88eb2aa4c28dde82e7c07c4a1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 20:07:36 +0100 Subject: [PATCH 017/352] easier to understand --- src/constitutive.f90 | 10 +++++----- src/constitutive_mech.f90 | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index e65ce864d..5bee8b97c 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -1247,8 +1247,9 @@ end function crystallite_push33ToRef !> @brief integrate stress, state with adaptive 1st order explicit Euler method !> using Fixed Point Iteration to adapt the stepsize !-------------------------------------------------------------------------------------------------- -function integrateSourceState(co,ip,el) result(broken) +function integrateSourceState(dt,co,ip,el) result(broken) + real(pReal), intent(in) :: dt integer, intent(in) :: & el, & !< element index in element loop ip, & !< integration point index in ip loop @@ -1281,8 +1282,7 @@ function integrateSourceState(co,ip,el) result(broken) do so = 1, phase_Nsources(ph) size_so(so) = sourceState(ph)%p(so)%sizeDotState sourceState(ph)%p(so)%state(1:size_so(so),me) = sourceState(ph)%p(so)%subState0(1:size_so(so),me) & - + sourceState(ph)%p(so)%dotState (1:size_so(so),me) & - * crystallite_subdt(co,ip,el) + + sourceState(ph)%p(so)%dotState (1:size_so(so),me) * dt source_dotState(1:size_so(so),2,so) = 0.0_pReal enddo @@ -1304,8 +1304,8 @@ function integrateSourceState(co,ip,el) result(broken) sourceState(ph)%p(so)%dotState(:,me) = sourceState(ph)%p(so)%dotState(:,me) * zeta & + source_dotState(1:size_so(so),1,so)* (1.0_pReal - zeta) r(1:size_so(so)) = sourceState(ph)%p(so)%state (1:size_so(so),me) & - - sourceState(ph)%p(so)%subState0(1:size_so(so),me) & - - sourceState(ph)%p(so)%dotState (1:size_so(so),me) * crystallite_subdt(co,ip,el) + - sourceState(ph)%p(so)%subState0(1:size_so(so),me) & + - sourceState(ph)%p(so)%dotState (1:size_so(so),me) * dt sourceState(ph)%p(so)%state(1:size_so(so),me) = sourceState(ph)%p(so)%state(1:size_so(so),me) & - r(1:size_so(so)) converged_ = converged_ .and. converged(r(1:size_so(so)), & diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index de6f2ae9f..51822d898 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1569,8 +1569,8 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) crystallite_subdt(co,ip,el) = subStep * dt converged_ = .not. integrateState(subF0,crystallite_subF(1:3,1:3,co,ip,el),& - crystallite_subdt(co,ip,el),co,ip,el) - converged_ = converged_ .and. .not. integrateSourceState(co,ip,el) + subStep * dt,co,ip,el) + converged_ = converged_ .and. .not. integrateSourceState(subStep * dt,co,ip,el) endif enddo cutbackLooping From a13a6624fe878c127f53de35ab263bee9be0c804 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 21:20:54 +0100 Subject: [PATCH 018/352] clearer logic --- src/homogenization.f90 | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index ebf5fd50d..b550ae207 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -205,26 +205,24 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE damageState(ho)%State (:,material_homogenizationMemberAt(ip,el)) endif steppingNeeded - else - if ( (myNgrains == 1 .and. subStep <= 1.0 ) .or. & ! single grain already tried internal subStepping in crystallite + elseif ( (myNgrains == 1 .and. subStep <= 1.0 ) .or. & ! single grain already tried internal subStepping in crystallite num%subStepSizeHomog * subStep <= num%subStepMinHomog ) then ! would require too small subStep ! cutback makes no sense - if (.not. terminallyIll) & ! so first signals terminally ill... - print*, ' Integration point ', ip,' at element ', el, ' terminally ill' - terminallyIll = .true. ! ...and kills all others - else ! cutback makes sense - subStep = num%subStepSizeHomog * subStep ! crystallite had severe trouble, so do a significant cutback + if (.not. terminallyIll) & ! so first signals terminally ill... + print*, ' Integration point ', ip,' at element ', el, ' terminally ill' + terminallyIll = .true. ! ...and kills all others + else ! cutback makes sense + subStep = num%subStepSizeHomog * subStep ! crystallite had severe trouble, so do a significant cutback - call crystallite_restore(ip,el,subStep < 1.0_pReal) - call constitutive_restore(ip,el) + call crystallite_restore(ip,el,subStep < 1.0_pReal) + call constitutive_restore(ip,el) - if(homogState(ho)%sizeState > 0) & - homogState(ho)%State( :,material_homogenizationMemberAt(ip,el)) = & - homogState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) - if(damageState(ho)%sizeState > 0) & - damageState(ho)%State( :,material_homogenizationMemberAt(ip,el)) = & - damageState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) - endif + if(homogState(ho)%sizeState > 0) & + homogState(ho)%State( :,material_homogenizationMemberAt(ip,el)) = & + homogState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) + if(damageState(ho)%sizeState > 0) & + damageState(ho)%State( :,material_homogenizationMemberAt(ip,el)) = & + damageState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) endif if (subStep > num%subStepMinHomog) doneAndHappy = [.false.,.true.] From 4a839053eba299224fb7ba12b7e7638514772d16 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 21:25:28 +0100 Subject: [PATCH 019/352] not used was only used for reporting (see v.2.0.0) --- src/homogenization.f90 | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index b550ae207..6745cceb1 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -148,7 +148,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE real(pReal), intent(in) :: dt !< time increment integer, dimension(2), intent(in) :: FEsolving_execElem, FEsolving_execIP integer :: & - NiterationHomog, & NiterationMPstate, & ip, & !< integration point number el, & !< element number @@ -162,7 +161,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE doneAndHappy -!$OMP PARALLEL DO PRIVATE(ce,ho,myNgrains,NiterationMPstate,NiterationHomog,subFrac,converged,subStep,doneAndHappy) +!$OMP PARALLEL DO PRIVATE(ce,ho,myNgrains,NiterationMPstate,subFrac,converged,subStep,doneAndHappy) do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) myNgrains = homogenization_Nconstituents(ho) @@ -184,8 +183,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE damageState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) = & damageState(ho)%State0( :,material_homogenizationMemberAt(ip,el)) - - NiterationHomog = 0 cutBackLooping: do while (.not. terminallyIll .and. subStep > num%subStepMinHomog) if (converged) then @@ -261,8 +258,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE endif enddo convergenceLooping - NiterationHomog = NiterationHomog + 1 - enddo cutBackLooping enddo enddo From f861120f9102bd6788c3152f528a0c447777da39 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 21:45:31 +0100 Subject: [PATCH 020/352] separation of responsibility --- src/constitutive.f90 | 58 +++++++++++++-------------------------- src/constitutive_mech.f90 | 32 +++++++++++++++++++++ src/homogenization.f90 | 3 +- 3 files changed, 52 insertions(+), 41 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 5bee8b97c..3c1f0e8c1 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -179,6 +179,14 @@ module constitutive module subroutine constitutive_mech_forward end subroutine constitutive_mech_forward + module subroutine mech_restore(ip,el,includeL) + integer, intent(in) :: & + ip, & + el + logical, intent(in) :: & + includeL + end subroutine mech_restore + ! == cleaned:end =================================================================================== module function crystallite_stress(dt,co,ip,el) result(converged_) @@ -392,8 +400,7 @@ module constitutive crystallite_restartRead, & constitutive_initializeRestorationPoints, & constitutive_windForward, & - crystallite_restore, & - PLASTICITY_UNDEFINED_ID, & + PLASTICITY_UNDEFINED_ID, & PLASTICITY_NONE_ID, & PLASTICITY_ISOTROPIC_ID, & PLASTICITY_PHENOPOWERLAW_ID, & @@ -756,22 +763,27 @@ end subroutine constitutive_allocateState !-------------------------------------------------------------------------------------------------- !> @brief Restore data after homog cutback. !-------------------------------------------------------------------------------------------------- -subroutine constitutive_restore(ip,el) +subroutine constitutive_restore(ip,el,includeL) + logical, intent(in) :: includeL integer, intent(in) :: & ip, & !< integration point number el !< element number + integer :: & co, & !< constituent number - s + so + do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - do s = 1, phase_Nsources(material_phaseAt(co,el)) - sourceState(material_phaseAt(co,el))%p(s)%state( :,material_phasememberAt(co,ip,el)) = & - sourceState(material_phaseAt(co,el))%p(s)%partitionedState0(:,material_phasememberAt(co,ip,el)) + do so = 1, phase_Nsources(material_phaseAt(co,el)) + sourceState(material_phaseAt(co,el))%p(so)%state( :,material_phasememberAt(co,ip,el)) = & + sourceState(material_phaseAt(co,el))%p(so)%partitionedState0(:,material_phasememberAt(co,ip,el)) enddo enddo + call mech_restore(ip,el,includeL) + end subroutine constitutive_restore @@ -1038,38 +1050,6 @@ subroutine constitutive_windForward(ip,el) end subroutine constitutive_windForward -!-------------------------------------------------------------------------------------------------- -!> @brief Restore data after homog cutback. -!-------------------------------------------------------------------------------------------------- -subroutine crystallite_restore(ip,el,includeL) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - logical, intent(in) :: & - includeL !< protect agains fake cutback - integer :: & - co, p, m !< constituent number - - do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - p = material_phaseAt(co,el) - m = material_phaseMemberAt(co,ip,el) - if (includeL) then - crystallite_Lp(1:3,1:3,co,ip,el) = crystallite_partitionedLp0(1:3,1:3,co,ip,el) - constitutive_mech_Li(p)%data(1:3,1:3,m) = constitutive_mech_partitionedLi0(p)%data(1:3,1:3,m) - endif ! maybe protecting everything from overwriting makes more sense - - constitutive_mech_Fp(p)%data(1:3,1:3,m) = constitutive_mech_partitionedFp0(p)%data(1:3,1:3,m) - constitutive_mech_Fi(p)%data(1:3,1:3,m) = constitutive_mech_partitionedFi0(p)%data(1:3,1:3,m) - crystallite_S (1:3,1:3,co,ip,el) = crystallite_partitionedS0 (1:3,1:3,co,ip,el) - - plasticState (material_phaseAt(co,el))%state( :,material_phasememberAt(co,ip,el)) = & - plasticState (material_phaseAt(co,el))%partitionedState0(:,material_phasememberAt(co,ip,el)) - enddo - -end subroutine crystallite_restore - - !-------------------------------------------------------------------------------------------------- !> @brief Calculate tangent (dPdF). !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 51822d898..3914283d2 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1577,5 +1577,37 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) end function crystallite_stress + +!-------------------------------------------------------------------------------------------------- +!> @brief Restore data after homog cutback. +!-------------------------------------------------------------------------------------------------- +module subroutine mech_restore(ip,el,includeL) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + logical, intent(in) :: & + includeL !< protect agains fake cutback + integer :: & + co, p, m !< constituent number + + do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) + p = material_phaseAt(co,el) + m = material_phaseMemberAt(co,ip,el) + if (includeL) then + crystallite_Lp(1:3,1:3,co,ip,el) = crystallite_partitionedLp0(1:3,1:3,co,ip,el) + constitutive_mech_Li(p)%data(1:3,1:3,m) = constitutive_mech_partitionedLi0(p)%data(1:3,1:3,m) + endif ! maybe protecting everything from overwriting makes more sense + + constitutive_mech_Fp(p)%data(1:3,1:3,m) = constitutive_mech_partitionedFp0(p)%data(1:3,1:3,m) + constitutive_mech_Fi(p)%data(1:3,1:3,m) = constitutive_mech_partitionedFi0(p)%data(1:3,1:3,m) + crystallite_S (1:3,1:3,co,ip,el) = crystallite_partitionedS0 (1:3,1:3,co,ip,el) + + plasticState (material_phaseAt(co,el))%state( :,material_phasememberAt(co,ip,el)) = & + plasticState (material_phaseAt(co,el))%partitionedState0(:,material_phasememberAt(co,ip,el)) + enddo + +end subroutine mech_restore + end submodule constitutive_mech diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 6745cceb1..05fa5f690 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -211,8 +211,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE else ! cutback makes sense subStep = num%subStepSizeHomog * subStep ! crystallite had severe trouble, so do a significant cutback - call crystallite_restore(ip,el,subStep < 1.0_pReal) - call constitutive_restore(ip,el) + call constitutive_restore(ip,el,subStep < 1.0_pReal) if(homogState(ho)%sizeState > 0) & homogState(ho)%State( :,material_homogenizationMemberAt(ip,el)) = & From 6f4aa0ebd9f0539bc0f0ef00d4e7c2f47eba04ee Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 22:22:08 +0100 Subject: [PATCH 021/352] consistent names --- src/constitutive.f90 | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 3c1f0e8c1..9d2754a68 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -945,8 +945,8 @@ subroutine crystallite_init flush(IO_STDOUT) !$OMP PARALLEL DO PRIVATE(ph,me) - do el = 1, size(material_phaseMemberAt,3) - do ip = 1, size(material_phaseMemberAt,2); do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + do el = 1, size(material_phaseMemberAt,3); do ip = 1, size(material_phaseMemberAt,2) + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) @@ -965,8 +965,8 @@ subroutine crystallite_init constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) - enddo; enddo - enddo + enddo + enddo; enddo !$OMP END PARALLEL DO crystallite_partitionedF0 = crystallite_F0 @@ -990,9 +990,6 @@ subroutine crystallite_init end subroutine crystallite_init - - - !-------------------------------------------------------------------------------------------------- !> @brief Backup data for homog cutback. !-------------------------------------------------------------------------------------------------- @@ -1003,7 +1000,7 @@ subroutine constitutive_initializeRestorationPoints(ip,el) el !< element number integer :: & co, & !< constituent number - s,ph, me + so,ph, me do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) @@ -1014,9 +1011,9 @@ subroutine constitutive_initializeRestorationPoints(ip,el) call mech_initializeRestorationPoints(ph,me) - do s = 1, phase_Nsources(material_phaseAt(co,el)) - sourceState(material_phaseAt(co,el))%p(s)%partitionedState0(:,material_phasememberAt(co,ip,el)) = & - sourceState(material_phaseAt(co,el))%p(s)%state0( :,material_phasememberAt(co,ip,el)) + do so = 1, phase_Nsources(material_phaseAt(co,el)) + sourceState(material_phaseAt(co,el))%p(so)%partitionedState0(:,material_phasememberAt(co,ip,el)) = & + sourceState(material_phaseAt(co,el))%p(so)%state0( :,material_phasememberAt(co,ip,el)) enddo enddo @@ -1033,7 +1030,7 @@ subroutine constitutive_windForward(ip,el) el !< element number integer :: & co, & !< constituent number - s, ph, me + so, ph, me do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) @@ -1042,8 +1039,8 @@ subroutine constitutive_windForward(ip,el) crystallite_partitionedS0 (1:3,1:3,co,ip,el) = crystallite_S (1:3,1:3,co,ip,el) call constitutive_mech_windForward(ph,me) - do s = 1, phase_Nsources(material_phaseAt(co,el)) - sourceState(ph)%p(s)%partitionedState0(:,me) = sourceState(ph)%p(s)%state(:,me) + do so = 1, phase_Nsources(material_phaseAt(co,el)) + sourceState(ph)%p(so)%partitionedState0(:,me) = sourceState(ph)%p(so)%state(:,me) enddo enddo From 822fafc9b6559a1a100752d2314b163ec0bf44d9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 22:49:08 +0100 Subject: [PATCH 022/352] subF and partitionedF should have the same value at the end of a cycle --- src/constitutive.f90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 9d2754a68..eb94e539c 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -1126,8 +1126,8 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) !-------------------------------------------------------------------------------------------------- ! calculate dSdF temp_33_1 = transpose(matmul(invFp,invFi)) - temp_33_2 = matmul(crystallite_subF(1:3,1:3,co,ip,el),invSubFp0) - temp_33_3 = matmul(matmul(crystallite_subF(1:3,1:3,co,ip,el),invFp), invSubFi0) + temp_33_2 = matmul(crystallite_partitionedF(1:3,1:3,co,ip,el),invSubFp0) + temp_33_3 = matmul(matmul(crystallite_partitionedF(1:3,1:3,co,ip,el),invFp), invSubFi0) do o=1,3; do p=1,3 rhs_3333(p,o,1:3,1:3) = matmul(dSdFe(p,o,1:3,1:3),temp_33_1) @@ -1158,7 +1158,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) ! assemble dPdF temp_33_1 = matmul(crystallite_S(1:3,1:3,co,ip,el),transpose(invFp)) temp_33_2 = matmul(invFp,temp_33_1) - temp_33_3 = matmul(crystallite_subF(1:3,1:3,co,ip,el),invFp) + temp_33_3 = matmul(crystallite_partitionedF(1:3,1:3,co,ip,el),invFp) temp_33_4 = matmul(temp_33_3,crystallite_S(1:3,1:3,co,ip,el)) dPdF = 0.0_pReal @@ -1167,7 +1167,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) enddo do o=1,3; do p=1,3 dPdF(1:3,1:3,p,o) = dPdF(1:3,1:3,p,o) & - + matmul(matmul(crystallite_subF(1:3,1:3,co,ip,el), & + + matmul(matmul(crystallite_partitionedF(1:3,1:3,co,ip,el), & dFpinvdF(1:3,1:3,p,o)),temp_33_1) & + matmul(matmul(temp_33_3,dSdF(1:3,1:3,p,o)), & transpose(invFp)) & @@ -1214,7 +1214,7 @@ function crystallite_push33ToRef(co,ip,el, tensor33) T = matmul(material_orientation0(co,ip,el)%asMatrix(), & ! ToDo: initial orientation correct? - transpose(math_inv33(crystallite_subF(1:3,1:3,co,ip,el)))) + transpose(math_inv33(crystallite_partitionedF(1:3,1:3,co,ip,el)))) crystallite_push33ToRef = matmul(transpose(T),matmul(tensor33,T)) end function crystallite_push33ToRef From ba9ad3a8c2098e2fb8a460f073b77294af25255d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 27 Dec 2020 22:56:21 +0100 Subject: [PATCH 023/352] only needed in one loop --- src/constitutive.f90 | 2 -- src/constitutive_mech.f90 | 18 ++++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index eb94e539c..e34cfc015 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -48,7 +48,6 @@ module constitutive crystallite_orientation !< current orientation real(pReal), dimension(:,:,:,:,:), allocatable :: & crystallite_F0, & !< def grad at start of FE inc - crystallite_subF, & !< def grad to be reached at end of crystallite inc crystallite_Fe, & !< current "elastic" def grad (end of converged time step) crystallite_subFp0,& !< plastic def grad at start of crystallite inc crystallite_subFi0,& !< intermediate def grad at start of crystallite inc @@ -875,7 +874,6 @@ subroutine crystallite_init crystallite_partitionedLp0, & crystallite_S,crystallite_P, & crystallite_Fe,crystallite_Lp, & - crystallite_subF, & crystallite_subFp0,crystallite_subFi0, & source = crystallite_partitionedF) diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 3914283d2..1dac6fffd 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1488,7 +1488,8 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) real(pReal), dimension(3,3) :: & subLp0, & !< plastic velocity grad at start of crystallite inc subLi0, & !< intermediate velocity grad at start of crystallite inc - subF0 + subF0, & + subF ph = material_phaseAt(co,el) @@ -1525,7 +1526,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) todo = subStep > 0.0_pReal ! still time left to integrate on? if (todo) then - subF0 = crystallite_subF(1:3,1:3,co,ip,el) + subF0 = subF subLp0 = crystallite_Lp (1:3,1:3,co,ip,el) subLi0 = constitutive_mech_Li(ph)%data(1:3,1:3,me) crystallite_subFp0(1:3,1:3,co,ip,el) = constitutive_mech_Fp(ph)%data(1:3,1:3,me) @@ -1561,15 +1562,12 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) !-------------------------------------------------------------------------------------------------- ! prepare for integration if (todo) then - crystallite_subF(1:3,1:3,co,ip,el) = subF0 & - + subStep *( crystallite_partitionedF (1:3,1:3,co,ip,el) & - -crystallite_partitionedF0(1:3,1:3,co,ip,el)) - crystallite_Fe(1:3,1:3,co,ip,el) = matmul(crystallite_subF(1:3,1:3,co,ip,el), & - math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & - constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) + subF = subF0 & + + subStep * (crystallite_partitionedF(1:3,1:3,co,ip,el) -crystallite_partitionedF0(1:3,1:3,co,ip,el)) + crystallite_Fe(1:3,1:3,co,ip,el) = matmul(subF,math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & + constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) crystallite_subdt(co,ip,el) = subStep * dt - converged_ = .not. integrateState(subF0,crystallite_subF(1:3,1:3,co,ip,el),& - subStep * dt,co,ip,el) + converged_ = .not. integrateState(subF0,subF,subStep * dt,co,ip,el) converged_ = converged_ .and. .not. integrateSourceState(subStep * dt,co,ip,el) endif From 820aa25e12f1606de56390eb9456e249e260b52b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 09:07:35 +0100 Subject: [PATCH 024/352] consistent names --- src/constitutive.f90 | 58 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index e34cfc015..9ec21f69c 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -1026,9 +1026,12 @@ subroutine constitutive_windForward(ip,el) integer, intent(in) :: & ip, & !< integration point number el !< element number + integer :: & co, & !< constituent number so, ph, me + + do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) @@ -1055,10 +1058,10 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) co, & !< counter in constituent loop ip, & !< counter in integration point loop el !< counter in element loop + integer :: & o, & p, ph, me - real(pReal), dimension(3,3) :: devNull, & invSubFp0,invSubFi0,invFp,invFi, & temp_33_1, temp_33_2, temp_33_3, temp_33_4 @@ -1077,6 +1080,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) real(pReal), dimension(9,9):: temp_99 logical :: error + ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) @@ -1346,7 +1350,7 @@ end function converged !-------------------------------------------------------------------------------------------------- subroutine crystallite_restartWrite - integer :: i + integer :: ph integer(HID_T) :: fileHandle, groupHandle character(len=pStringLen) :: fileName, datasetName @@ -1360,22 +1364,22 @@ subroutine crystallite_restartWrite call HDF5_write(fileHandle,crystallite_S, 'S') groupHandle = HDF5_addGroup(fileHandle,'phase') - do i = 1,size(material_name_phase) - write(datasetName,'(i0,a)') i,'_omega' - call HDF5_write(groupHandle,plasticState(i)%state,datasetName) - write(datasetName,'(i0,a)') i,'_F_i' - call HDF5_write(groupHandle,constitutive_mech_Fi(i)%data,datasetName) - write(datasetName,'(i0,a)') i,'_L_i' - call HDF5_write(groupHandle,constitutive_mech_Li(i)%data,datasetName) - write(datasetName,'(i0,a)') i,'_F_p' - call HDF5_write(groupHandle,constitutive_mech_Fp(i)%data,datasetName) + do ph = 1,size(material_name_phase) + write(datasetName,'(i0,a)') ph,'_omega' + call HDF5_write(groupHandle,plasticState(ph)%state,datasetName) + write(datasetName,'(i0,a)') ph,'_F_i' + call HDF5_write(groupHandle,constitutive_mech_Fi(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_L_i' + call HDF5_write(groupHandle,constitutive_mech_Li(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_F_p' + call HDF5_write(groupHandle,constitutive_mech_Fp(ph)%data,datasetName) enddo call HDF5_closeGroup(groupHandle) groupHandle = HDF5_addGroup(fileHandle,'homogenization') - do i = 1, size(material_name_homogenization) - write(datasetName,'(i0,a)') i,'_omega' - call HDF5_write(groupHandle,homogState(i)%state,datasetName) + do ph = 1, size(material_name_homogenization) + write(datasetName,'(i0,a)') ph,'_omega' + call HDF5_write(groupHandle,homogState(ph)%state,datasetName) enddo call HDF5_closeGroup(groupHandle) @@ -1390,7 +1394,7 @@ end subroutine crystallite_restartWrite !-------------------------------------------------------------------------------------------------- subroutine crystallite_restartRead - integer :: i + integer :: ph integer(HID_T) :: fileHandle, groupHandle character(len=pStringLen) :: fileName, datasetName @@ -1404,22 +1408,22 @@ subroutine crystallite_restartRead call HDF5_read(fileHandle,crystallite_S0, 'S') groupHandle = HDF5_openGroup(fileHandle,'phase') - do i = 1,size(material_name_phase) - write(datasetName,'(i0,a)') i,'_omega' - call HDF5_read(groupHandle,plasticState(i)%state0,datasetName) - write(datasetName,'(i0,a)') i,'_F_i' - call HDF5_read(groupHandle,constitutive_mech_Fi0(i)%data,datasetName) - write(datasetName,'(i0,a)') i,'_L_i' - call HDF5_read(groupHandle,constitutive_mech_Li0(i)%data,datasetName) - write(datasetName,'(i0,a)') i,'_F_p' - call HDF5_read(groupHandle,constitutive_mech_Fp0(i)%data,datasetName) + do ph = 1,size(material_name_phase) + write(datasetName,'(i0,a)') ph,'_omega' + call HDF5_read(groupHandle,plasticState(ph)%state0,datasetName) + write(datasetName,'(i0,a)') ph,'_F_i' + call HDF5_read(groupHandle,constitutive_mech_Fi0(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_L_i' + call HDF5_read(groupHandle,constitutive_mech_Li0(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_F_p' + call HDF5_read(groupHandle,constitutive_mech_Fp0(ph)%data,datasetName) enddo call HDF5_closeGroup(groupHandle) groupHandle = HDF5_openGroup(fileHandle,'homogenization') - do i = 1,size(material_name_homogenization) - write(datasetName,'(i0,a)') i,'_omega' - call HDF5_read(groupHandle,homogState(i)%state0,datasetName) + do ph = 1,size(material_name_homogenization) + write(datasetName,'(i0,a)') ph,'_omega' + call HDF5_read(groupHandle,homogState(ph)%state0,datasetName) enddo call HDF5_closeGroup(groupHandle) From 830e2a3a990b8b86717973618cd7bf31f3312567 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 09:13:56 +0100 Subject: [PATCH 025/352] shortened --- src/homogenization.f90 | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 05fa5f690..d0f7baf5a 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -151,7 +151,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE NiterationMPstate, & ip, & !< integration point number el, & !< element number - myNgrains, co, ce, ho + myNgrains, co, ce, ho, me real(pReal) :: & subFrac, & subStep @@ -164,6 +164,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE !$OMP PARALLEL DO PRIVATE(ce,ho,myNgrains,NiterationMPstate,subFrac,converged,subStep,doneAndHappy) do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) + me = material_homogenizationMemberAt(ip,el) myNgrains = homogenization_Nconstituents(ho) do ip = FEsolving_execIP(1),FEsolving_execIP(2) @@ -176,12 +177,9 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE subStep = 1.0_pReal/num%subStepSizeHomog ! ... larger then the requested calculation if (homogState(ho)%sizeState > 0) & - homogState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) = & - homogState(ho)%State0( :,material_homogenizationMemberAt(ip,el)) - + homogState(ho)%subState0(:,me) = homogState(ho)%State0(:,me) if (damageState(ho)%sizeState > 0) & - damageState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) = & - damageState(ho)%State0( :,material_homogenizationMemberAt(ip,el)) + damageState(ho)%subState0(:,me) = damageState(ho)%State0(:,me) cutBackLooping: do while (.not. terminallyIll .and. subStep > num%subStepMinHomog) @@ -195,11 +193,9 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE call constitutive_windForward(ip,el) if(homogState(ho)%sizeState > 0) & - homogState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) = & - homogState(ho)%State (:,material_homogenizationMemberAt(ip,el)) + homogState(ho)%subState0(:,me) = homogState(ho)%State(:,me) if(damageState(ho)%sizeState > 0) & - damageState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) = & - damageState(ho)%State (:,material_homogenizationMemberAt(ip,el)) + damageState(ho)%subState0(:,me) = damageState(ho)%State(:,me) endif steppingNeeded elseif ( (myNgrains == 1 .and. subStep <= 1.0 ) .or. & ! single grain already tried internal subStepping in crystallite @@ -214,11 +210,9 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE call constitutive_restore(ip,el,subStep < 1.0_pReal) if(homogState(ho)%sizeState > 0) & - homogState(ho)%State( :,material_homogenizationMemberAt(ip,el)) = & - homogState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) + homogState(ho)%State(:,me) = homogState(ho)%subState0(:,me) if(damageState(ho)%sizeState > 0) & - damageState(ho)%State( :,material_homogenizationMemberAt(ip,el)) = & - damageState(ho)%subState0(:,material_homogenizationMemberAt(ip,el)) + damageState(ho)%State(:,me) = damageState(ho)%subState0(:,me) endif if (subStep > num%subStepMinHomog) doneAndHappy = [.false.,.true.] From e6f27e91b1a8a9e8cdab418fcfbc743a1b4636a2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 09:18:20 +0100 Subject: [PATCH 026/352] consistent names --- src/homogenization.f90 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index d0f7baf5a..6b2a43836 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -161,7 +161,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE doneAndHappy -!$OMP PARALLEL DO PRIVATE(ce,ho,myNgrains,NiterationMPstate,subFrac,converged,subStep,doneAndHappy) + !$OMP PARALLEL DO PRIVATE(ce,ho,myNgrains,NiterationMPstate,subFrac,converged,subStep,doneAndHappy) do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) me = material_homogenizationMemberAt(ip,el) @@ -321,29 +321,30 @@ subroutine homogenization_results use material, only: & material_homogenization_type => homogenization_type - integer :: p + integer :: ph character(len=:), allocatable :: group_base,group + call results_closeGroup(results_addGroup('current/homogenization/')) - do p=1,size(material_name_homogenization) - group_base = 'current/homogenization/'//trim(material_name_homogenization(p)) + do ph=1,size(material_name_homogenization) + group_base = 'current/homogenization/'//trim(material_name_homogenization(ph)) call results_closeGroup(results_addGroup(group_base)) - call mech_results(group_base,p) + call mech_results(group_base,ph) group = trim(group_base)//'/damage' call results_closeGroup(results_addGroup(group)) - select case(damage_type(p)) + select case(damage_type(ph)) case(DAMAGE_NONLOCAL_ID) - call damage_nonlocal_results(p,group) + call damage_nonlocal_results(ph,group) end select group = trim(group_base)//'/thermal' call results_closeGroup(results_addGroup(group)) - select case(thermal_type(p)) + select case(thermal_type(ph)) case(THERMAL_CONDUCTION_ID) - call thermal_conduction_results(p,group) + call thermal_conduction_results(ph,group) end select enddo @@ -359,6 +360,7 @@ subroutine homogenization_forward integer :: ho + do ho = 1, size(material_name_homogenization) homogState (ho)%state0 = homogState (ho)%state damageState(ho)%state0 = damageState(ho)%state From 190df4830c10283b4bb83c19a438c526facb8afb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 09:27:48 +0100 Subject: [PATCH 027/352] simplified --- src/homogenization.f90 | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 6b2a43836..2bc3545e3 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -289,18 +289,17 @@ function updateState(subdt,subF,ip,el) integer, intent(in) :: & ip, & !< integration point el !< element number - integer :: c logical, dimension(2) :: updateState + + integer :: co real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) - updateState = .true. - chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) - case (HOMOGENIZATION_RGC_ID) chosenHomogenization - do c=1,homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,c) = crystallite_stressTangent(c,ip,el) + + if (homogenization_type(material_homogenizationAt(el)) == HOMOGENIZATION_RGC_ID) then + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + dPdFs(:,:,:,:,co) = crystallite_stressTangent(co,ip,el) enddo updateState = & - updateState .and. & mech_RGC_updateState(crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & crystallite_partitionedF(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & crystallite_partitionedF0(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el),& @@ -309,7 +308,9 @@ function updateState(subdt,subF,ip,el) dPdFs, & ip, & el) - end select chosenHomogenization + else + updateState = .true. + endif end function updateState @@ -318,33 +319,31 @@ end function updateState !> @brief writes homogenization results to HDF5 output file !-------------------------------------------------------------------------------------------------- subroutine homogenization_results - use material, only: & - material_homogenization_type => homogenization_type - integer :: ph + integer :: ho character(len=:), allocatable :: group_base,group call results_closeGroup(results_addGroup('current/homogenization/')) - do ph=1,size(material_name_homogenization) - group_base = 'current/homogenization/'//trim(material_name_homogenization(ph)) + do ho=1,size(material_name_homogenization) + group_base = 'current/homogenization/'//trim(material_name_homogenization(ho)) call results_closeGroup(results_addGroup(group_base)) - call mech_results(group_base,ph) + call mech_results(group_base,ho) group = trim(group_base)//'/damage' call results_closeGroup(results_addGroup(group)) - select case(damage_type(ph)) + select case(damage_type(ho)) case(DAMAGE_NONLOCAL_ID) - call damage_nonlocal_results(ph,group) + call damage_nonlocal_results(ho,group) end select group = trim(group_base)//'/thermal' call results_closeGroup(results_addGroup(group)) - select case(thermal_type(ph)) + select case(thermal_type(ho)) case(THERMAL_CONDUCTION_ID) - call thermal_conduction_results(ph,group) + call thermal_conduction_results(ho,group) end select enddo From 7d767522812c7092eaf0ff9473e97620de9fc250 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 09:55:54 +0100 Subject: [PATCH 028/352] intended hierarchy --- src/homogenization.f90 | 74 +++++++-------------------------- src/homogenization_mech.f90 | 54 ++++++++++++++++++++++++ src/homogenization_mech_RGC.f90 | 27 ++++++++---- 3 files changed, 87 insertions(+), 68 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 2bc3545e3..bc3098300 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -70,29 +70,22 @@ module homogenization end subroutine mech_homogenize module subroutine mech_results(group_base,h) - character(len=*), intent(in) :: group_base integer, intent(in) :: h - end subroutine mech_results -! -------- ToDo --------------------------------------------------------- - module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) - logical, dimension(2) :: mech_RGC_updateState - real(pReal), dimension(:,:,:), intent(in) :: & - P,& !< partitioned stresses - F,& !< partitioned deformation gradients - F0 !< partitioned initial deformation gradients - real(pReal), dimension(:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses - real(pReal), dimension(3,3), intent(in) :: avgF !< average F - real(pReal), intent(in) :: dt !< time increment - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - end function mech_RGC_updateState + module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) + real(pReal), intent(in) :: & + subdt !< current time step + real(pReal), intent(in), dimension(3,3) :: & + subF + integer, intent(in) :: & + ip, & !< integration point + el !< element number + logical, dimension(2) :: doneAndHappy + end function mech_updateState end interface -! ----------------------------------------------------------------------- public :: & homogenization_init, & @@ -241,11 +234,11 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE doneAndHappy = [.true.,.false.] else ce = (el-1)*discretization_nIPs + ip - doneAndHappy = updateState(dt*subStep, & - homogenization_F0(1:3,1:3,ce) & - + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce)) & + doneAndHappy = mech_updateState(dt*subStep, & + homogenization_F0(1:3,1:3,ce) & + + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce)) & *(subStep+subFrac), & - ip,el) + ip,el) converged = all(doneAndHappy) endif endif @@ -276,45 +269,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE end subroutine materialpoint_stressAndItsTangent -!-------------------------------------------------------------------------------------------------- -!> @brief update the internal state of the homogenization scheme and tell whether "done" and -!> "happy" with result -!-------------------------------------------------------------------------------------------------- -function updateState(subdt,subF,ip,el) - - real(pReal), intent(in) :: & - subdt !< current time step - real(pReal), intent(in), dimension(3,3) :: & - subF - integer, intent(in) :: & - ip, & !< integration point - el !< element number - logical, dimension(2) :: updateState - - integer :: co - real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) - - - if (homogenization_type(material_homogenizationAt(el)) == HOMOGENIZATION_RGC_ID) then - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = crystallite_stressTangent(co,ip,el) - enddo - updateState = & - mech_RGC_updateState(crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - crystallite_partitionedF(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - crystallite_partitionedF0(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el),& - subF,& - subdt, & - dPdFs, & - ip, & - el) - else - updateState = .true. - endif - -end function updateState - - !-------------------------------------------------------------------------------------------------- !> @brief writes homogenization results to HDF5 output file !-------------------------------------------------------------------------------------------------- diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index e4499e9b7..8eda278b2 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -52,6 +52,21 @@ submodule(homogenization) homogenization_mech end subroutine mech_RGC_averageStressAndItsTangent + module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHappy) + logical, dimension(2) :: doneAndHappy + real(pReal), dimension(:,:,:), intent(in) :: & + P,& !< partitioned stresses + F,& !< partitioned deformation gradients + F0 !< partitioned initial deformation gradients + real(pReal), dimension(:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses + real(pReal), dimension(3,3), intent(in) :: avgF !< average F + real(pReal), intent(in) :: dt !< time increment + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + end function mech_RGC_updateState + + module subroutine mech_RGC_results(instance,group) integer, intent(in) :: instance !< homogenization instance character(len=*), intent(in) :: group !< group name in HDF5 file @@ -166,6 +181,45 @@ module subroutine mech_homogenize(ip,el) end subroutine mech_homogenize +!-------------------------------------------------------------------------------------------------- +!> @brief update the internal state of the homogenization scheme and tell whether "done" and +!> "happy" with result +!-------------------------------------------------------------------------------------------------- +module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) + + real(pReal), intent(in) :: & + subdt !< current time step + real(pReal), intent(in), dimension(3,3) :: & + subF + integer, intent(in) :: & + ip, & !< integration point + el !< element number + logical, dimension(2) :: doneAndHappy + + integer :: co + real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) + + + if (homogenization_type(material_homogenizationAt(el)) == HOMOGENIZATION_RGC_ID) then + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + dPdFs(:,:,:,:,co) = crystallite_stressTangent(co,ip,el) + enddo + doneAndHappy = & + mech_RGC_updateState(crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & + crystallite_partitionedF(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & + crystallite_partitionedF0(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el),& + subF,& + subdt, & + dPdFs, & + ip, & + el) + else + doneAndHappy = .true. + endif + +end function mech_updateState + + !-------------------------------------------------------------------------------------------------- !> @brief Write results to file. !-------------------------------------------------------------------------------------------------- diff --git a/src/homogenization_mech_RGC.f90 b/src/homogenization_mech_RGC.f90 index a89008e96..10148715d 100644 --- a/src/homogenization_mech_RGC.f90 +++ b/src/homogenization_mech_RGC.f90 @@ -242,7 +242,18 @@ end subroutine mech_RGC_partitionDeformation !> @brief update the internal state of the homogenization scheme and tell whether "done" and ! "happy" with result !-------------------------------------------------------------------------------------------------- -module procedure mech_RGC_updateState +module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHappy) + logical, dimension(2) :: doneAndHappy + real(pReal), dimension(:,:,:), intent(in) :: & + P,& !< partitioned stresses + F,& !< partitioned deformation gradients + F0 !< partitioned initial deformation gradients + real(pReal), dimension(:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses + real(pReal), dimension(3,3), intent(in) :: avgF !< average F + real(pReal), intent(in) :: dt !< time increment + integer, intent(in) :: & + ip, & !< integration point number + el !< element number integer, dimension(4) :: intFaceN,intFaceP,faceID integer, dimension(3) :: nGDim,iGr3N,iGr3P @@ -256,7 +267,7 @@ module procedure mech_RGC_updateState real(pReal), dimension(:), allocatable :: resid,relax,p_relax,p_resid,drelax zeroTimeStep: if(dEq0(dt)) then - mech_RGC_updateState = .true. ! pretend everything is fine and return + doneAndHappy = .true. ! pretend everything is fine and return return endif zeroTimeStep @@ -327,12 +338,12 @@ module procedure mech_RGC_updateState stresMax = maxval(abs(P)) ! get the maximum of first Piola-Kirchhoff (material) stress residMax = maxval(abs(tract)) ! get the maximum of the residual - mech_RGC_updateState = .false. + doneAndHappy = .false. !-------------------------------------------------------------------------------------------------- ! If convergence reached => done and happy if (residMax < num%rtol*stresMax .or. residMax < num%atol) then - mech_RGC_updateState = .true. + doneAndHappy = .true. !-------------------------------------------------------------------------------------------------- ! compute/update the state for postResult, i.e., all energy densities computed by time-integration @@ -354,7 +365,7 @@ module procedure mech_RGC_updateState !-------------------------------------------------------------------------------------------------- ! if residual blows-up => done but unhappy elseif (residMax > num%relMax*stresMax .or. residMax > num%absMax) then ! try to restart when residual blows up exceeding maximum bound - mech_RGC_updateState = [.true.,.false.] ! with direct cut-back + doneAndHappy = [.true.,.false.] ! with direct cut-back return endif @@ -484,7 +495,7 @@ module procedure mech_RGC_updateState enddo; enddo stt%relaxationVector(:,of) = relax + drelax ! Updateing the state variable for the next iteration if (any(abs(drelax) > num%maxdRelax)) then ! Forcing cutback when the incremental change of relaxation vector becomes too large - mech_RGC_updateState = [.true.,.false.] + doneAndHappy = [.true.,.false.] !$OMP CRITICAL (write2out) print'(a,i3,a,i3,a)',' RGC_updateState: ip ',ip,' | el ',el,' enforces cutback' print'(a,e15.8)',' due to large relaxation change = ',maxval(abs(drelax)) @@ -535,7 +546,7 @@ module procedure mech_RGC_updateState Gmoduli = equivalentModuli(iGrain,ip,el) muGrain = Gmoduli(1) ! collecting the equivalent shear modulus of grain bgGrain = Gmoduli(2) ! and the lengthh of Burgers vector - iGrain3 = grain1to3(iGrain,prm%N_constituents) ! get the grain ID in local 3-dimensional index (x,y,z)-position + iGrain3 = grain1to3(iGrain,prm%N_constituents) ! get the grain ID in local 3-dimensional index (doneAndHappy,y,z)-position interfaceLoop: do iFace = 1,6 intFace = getInterface(iFace,iGrain3) ! get the 4-dimensional index of the interface in local numbering system of the grain @@ -729,7 +740,7 @@ module procedure mech_RGC_updateState end subroutine grainDeformation -end procedure mech_RGC_updateState +end function mech_RGC_updateState !-------------------------------------------------------------------------------------------------- From d59cb81ca8172561a7c47070951dd8acd1c4b0ea Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 10:27:52 +0100 Subject: [PATCH 029/352] too early (depends on IP) --- src/homogenization.f90 | 5 ++--- src/homogenization_mech_RGC.f90 | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index bc3098300..52553b57b 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -154,13 +154,12 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE doneAndHappy - !$OMP PARALLEL DO PRIVATE(ce,ho,myNgrains,NiterationMPstate,subFrac,converged,subStep,doneAndHappy) + !$OMP PARALLEL DO PRIVATE(ce,me,ho,myNgrains,NiterationMPstate,subFrac,converged,subStep,doneAndHappy) do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) - me = material_homogenizationMemberAt(ip,el) myNgrains = homogenization_Nconstituents(ho) do ip = FEsolving_execIP(1),FEsolving_execIP(2) - + me = material_homogenizationMemberAt(ip,el) !-------------------------------------------------------------------------------------------------- ! initialize restoration points call constitutive_initializeRestorationPoints(ip,el) diff --git a/src/homogenization_mech_RGC.f90 b/src/homogenization_mech_RGC.f90 index 10148715d..3db4bb0f5 100644 --- a/src/homogenization_mech_RGC.f90 +++ b/src/homogenization_mech_RGC.f90 @@ -546,7 +546,7 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa Gmoduli = equivalentModuli(iGrain,ip,el) muGrain = Gmoduli(1) ! collecting the equivalent shear modulus of grain bgGrain = Gmoduli(2) ! and the lengthh of Burgers vector - iGrain3 = grain1to3(iGrain,prm%N_constituents) ! get the grain ID in local 3-dimensional index (doneAndHappy,y,z)-position + iGrain3 = grain1to3(iGrain,prm%N_constituents) ! get the grain ID in local 3-dimensional index (x,y,z)-position interfaceLoop: do iFace = 1,6 intFace = getInterface(iFace,iGrain3) ! get the 4-dimensional index of the interface in local numbering system of the grain From 1ac5465d65668a7e08b72a682e073d4bb0bd7cd1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 11:03:29 +0100 Subject: [PATCH 030/352] using central functionality --- src/homogenization_mech_RGC.f90 | 57 +++++++++++---------------------- src/lattice.f90 | 34 +++++++++++--------- 2 files changed, 38 insertions(+), 53 deletions(-) diff --git a/src/homogenization_mech_RGC.f90 b/src/homogenization_mech_RGC.f90 index 3db4bb0f5..04ec73845 100644 --- a/src/homogenization_mech_RGC.f90 +++ b/src/homogenization_mech_RGC.f90 @@ -8,6 +8,7 @@ !-------------------------------------------------------------------------------------------------- submodule(homogenization:homogenization_mech) homogenization_mech_RGC use rotations + use lattice type :: tParameters integer, dimension(:), allocatable :: & @@ -524,8 +525,10 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa real(pReal), dimension (3) :: nVect,surfCorr real(pReal), dimension (2) :: Gmoduli integer :: iGrain,iGNghb,iFace,i,j,k,l - real(pReal) :: muGrain,muGNghb,nDefNorm,bgGrain,bgGNghb - real(pReal), parameter :: nDefToler = 1.0e-10_pReal + real(pReal) :: muGrain,muGNghb,nDefNorm + real(pReal), parameter :: & + nDefToler = 1.0e-10_pReal, & + b = 2.5e-10_pReal ! Length of Burgers vector nGDim = param(instance)%N_constituents rPen = 0.0_pReal @@ -543,9 +546,7 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa !----------------------------------------------------------------------------------------------- ! computing the mismatch and penalty stress tensor of all grains grainLoop: do iGrain = 1,product(prm%N_constituents) - Gmoduli = equivalentModuli(iGrain,ip,el) - muGrain = Gmoduli(1) ! collecting the equivalent shear modulus of grain - bgGrain = Gmoduli(2) ! and the lengthh of Burgers vector + muGrain = equivalentMu(iGrain,ip,el) iGrain3 = grain1to3(iGrain,prm%N_constituents) ! get the grain ID in local 3-dimensional index (x,y,z)-position interfaceLoop: do iFace = 1,6 @@ -557,9 +558,7 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa where(iGNghb3 < 1) iGNghb3 = nGDim where(iGNghb3 >nGDim) iGNghb3 = 1 iGNghb = grain3to1(iGNghb3,prm%N_constituents) ! get the ID of the neighboring grain - Gmoduli = equivalentModuli(iGNghb,ip,el) ! collect the shear modulus and Burgers vector of the neighbor - muGNghb = Gmoduli(1) - bgGNghb = Gmoduli(2) + muGNghb = equivalentMu(iGNghb,ip,el) gDef = 0.5_pReal*(fDef(1:3,1:3,iGNghb) - fDef(1:3,1:3,iGrain)) ! difference/jump in deformation gradeint across the neighbor !------------------------------------------------------------------------------------------- @@ -579,7 +578,7 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa !------------------------------------------------------------------------------------------- ! compute the stress penalty of all interfaces do i = 1,3; do j = 1,3; do k = 1,3; do l = 1,3 - rPen(i,j,iGrain) = rPen(i,j,iGrain) + 0.5_pReal*(muGrain*bgGrain + muGNghb*bgGNghb)*prm%xi_alpha & + rPen(i,j,iGrain) = rPen(i,j,iGrain) + 0.5_pReal*(muGrain*b + muGNghb*b)*prm%xi_alpha & *surfCorr(abs(intFace(1)))/prm%D_alpha(abs(intFace(1))) & *cosh(prm%c_alpha*nDefNorm) & *0.5_pReal*nVect(l)*nDef(i,k)/nDefNorm*math_LeviCivita(k,l,j) & @@ -666,44 +665,26 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa end function surfaceCorrection - !-------------------------------------------------------------------------------------------------- + !------------------------------------------------------------------------------------------------- !> @brief compute the equivalent shear and bulk moduli from the elasticity tensor - !-------------------------------------------------------------------------------------------------- - function equivalentModuli(grainID,ip,el) - - real(pReal), dimension(2) :: equivalentModuli + !------------------------------------------------------------------------------------------------- + real(pReal) function equivalentMu(grainID,ip,el) integer, intent(in) :: & grainID,& ip, & !< integration point number el !< element number - real(pReal), dimension(6,6) :: elasTens - real(pReal) :: & - cEquiv_11, & - cEquiv_12, & - cEquiv_44 - - elasTens = constitutive_homogenizedC(grainID,ip,el) - - !---------------------------------------------------------------------------------------------- - ! compute the equivalent shear modulus after Turterltaub and Suiker, JMPS (2005) - cEquiv_11 = (elasTens(1,1) + elasTens(2,2) + elasTens(3,3))/3.0_pReal - cEquiv_12 = (elasTens(1,2) + elasTens(2,3) + elasTens(3,1) + & - elasTens(1,3) + elasTens(2,1) + elasTens(3,2))/6.0_pReal - cEquiv_44 = (elasTens(4,4) + elasTens(5,5) + elasTens(6,6))/3.0_pReal - equivalentModuli(1) = 0.2_pReal*(cEquiv_11 - cEquiv_12) + 0.6_pReal*cEquiv_44 - - !---------------------------------------------------------------------------------------------- - ! obtain the length of Burgers vector (could be model dependend) - equivalentModuli(2) = 2.5e-10_pReal - - end function equivalentModuli - !-------------------------------------------------------------------------------------------------- + equivalentMu = lattice_equivalent_mu(constitutive_homogenizedC(grainID,ip,el),'voigt') + + end function equivalentMu + + + !------------------------------------------------------------------------------------------------- !> @brief calculating the grain deformation gradient (the same with ! homogenization_RGC_partitionDeformation, but used only for perturbation scheme) - !-------------------------------------------------------------------------------------------------- + !------------------------------------------------------------------------------------------------- subroutine grainDeformation(F, avgF, instance, of) real(pReal), dimension(:,:,:), intent(out) :: F !< partitioned F per grain @@ -718,7 +699,7 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa integer, dimension(3) :: iGrain3 integer :: iGrain,iFace,i,j - !------------------------------------------------------------------------------------------------- + !----------------------------------------------------------------------------------------------- ! compute the deformation gradient of individual grains due to relaxations associate(prm => param(instance)) diff --git a/src/lattice.f90 b/src/lattice.f90 index 676232efe..6af135e4e 100644 --- a/src/lattice.f90 +++ b/src/lattice.f90 @@ -421,6 +421,8 @@ module lattice lattice_BCT_ID, & lattice_HEX_ID, & lattice_ORT_ID, & + lattice_equivalent_nu, & + lattice_equivalent_mu, & lattice_applyLatticeSymmetry33, & lattice_SchmidMatrix_slip, & lattice_SchmidMatrix_twin, & @@ -508,8 +510,8 @@ subroutine lattice_init lattice_C66(1:6,1:6,p) = applyLatticeSymmetryC66(lattice_C66(1:6,1:6,p),phase%get_asString('lattice')) - lattice_mu(p) = equivalent_mu(lattice_C66(1:6,1:6,p),'voigt') - lattice_nu(p) = equivalent_nu(lattice_C66(1:6,1:6,p),'voigt') + lattice_nu(p) = lattice_equivalent_nu(lattice_C66(1:6,1:6,p),'voigt') + lattice_mu(p) = lattice_equivalent_mu(lattice_C66(1:6,1:6,p),'voigt') lattice_C66(1:6,1:6,p) = math_sym3333to66(math_Voigt66to3333(lattice_C66(1:6,1:6,p))) ! Literature data is in Voigt notation do i = 1, 6 @@ -2188,15 +2190,16 @@ end function getlabels !> @brief Equivalent Poisson's ratio (ν) !> @details https://doi.org/10.1143/JPSJ.20.635 !-------------------------------------------------------------------------------------------------- -function equivalent_nu(C,assumption) result(nu) +function lattice_equivalent_nu(C,assumption) result(nu) real(pReal), dimension(6,6), intent(in) :: C !< Stiffness tensor (Voigt notation) character(len=*), intent(in) :: assumption !< Assumption ('Voigt' = isostrain, 'Reuss' = isostress) - real(pReal) :: K, mu, nu + logical :: error real(pReal), dimension(6,6) :: S + if (IO_lc(assumption) == 'voigt') then K = (C(1,1)+C(2,2)+C(3,3) +2.0_pReal*(C(1,2)+C(2,3)+C(1,3))) & / 9.0_pReal @@ -2210,25 +2213,26 @@ function equivalent_nu(C,assumption) result(nu) K = 0.0_pReal endif - mu = equivalent_mu(C,assumption) + mu = lattice_equivalent_mu(C,assumption) nu = (1.5_pReal*K -mu)/(3.0_pReal*K+mu) -end function equivalent_nu +end function lattice_equivalent_nu !-------------------------------------------------------------------------------------------------- !> @brief Equivalent shear modulus (μ) !> @details https://doi.org/10.1143/JPSJ.20.635 !-------------------------------------------------------------------------------------------------- -function equivalent_mu(C,assumption) result(mu) +function lattice_equivalent_mu(C,assumption) result(mu) real(pReal), dimension(6,6), intent(in) :: C !< Stiffness tensor (Voigt notation) character(len=*), intent(in) :: assumption !< Assumption ('Voigt' = isostrain, 'Reuss' = isostress) - real(pReal) :: mu + logical :: error real(pReal), dimension(6,6) :: S + if (IO_lc(assumption) == 'voigt') then mu = (1.0_pReal*(C(1,1)+C(2,2)+C(3,3)) -1.0_pReal*(C(1,2)+C(2,3)+C(1,3)) +3.0_pReal*(C(4,4)+C(5,5)+C(6,6))) & / 15.0_pReal @@ -2242,7 +2246,7 @@ function equivalent_mu(C,assumption) result(mu) mu = 0.0_pReal endif -end function equivalent_mu +end function lattice_equivalent_mu !-------------------------------------------------------------------------------------------------- @@ -2266,14 +2270,14 @@ subroutine selfTest call random_number(C) C(1,1) = C(1,1) + 1.0_pReal C = applyLatticeSymmetryC66(C,'aP') - if(dNeq(C(6,6),equivalent_mu(C,'voigt'),1.0e-12_pReal)) error stop 'equivalent_mu/voigt' - if(dNeq(C(6,6),equivalent_mu(C,'voigt'),1.0e-12_pReal)) error stop 'equivalent_mu/reuss' + if(dNeq(C(6,6),lattice_equivalent_mu(C,'voigt'),1.0e-12_pReal)) error stop 'equivalent_mu/voigt' + if(dNeq(C(6,6),lattice_equivalent_mu(C,'voigt'),1.0e-12_pReal)) error stop 'equivalent_mu/reuss' lambda = C(1,2) - if(dNeq(lambda*0.5_pReal/(lambda+equivalent_mu(C,'voigt')),equivalent_nu(C,'voigt'),1.0e-12_pReal)) & - error stop 'equivalent_nu/voigt' - if(dNeq(lambda*0.5_pReal/(lambda+equivalent_mu(C,'reuss')),equivalent_nu(C,'reuss'),1.0e-12_pReal)) & - error stop 'equivalent_nu/reuss' + if(dNeq(lambda*0.5_pReal/(lambda+lattice_equivalent_mu(C,'voigt')), & + lattice_equivalent_nu(C,'voigt'),1.0e-12_pReal)) error stop 'equivalent_nu/voigt' + if(dNeq(lambda*0.5_pReal/(lambda+lattice_equivalent_mu(C,'reuss')), & + lattice_equivalent_nu(C,'reuss'),1.0e-12_pReal)) error stop 'equivalent_nu/reuss' end subroutine selfTest From 6207432f7ae0e2270303248c8b1d54c7d1b59a01 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 21:34:14 +0100 Subject: [PATCH 031/352] modern Fortran --- src/math.f90 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/math.f90 b/src/math.f90 index 8005b5406..6b89a9923 100644 --- a/src/math.f90 +++ b/src/math.f90 @@ -279,9 +279,12 @@ real(pReal) pure function math_LeviCivita(i,j,k) integer, intent(in) :: i,j,k - if (all([i,j,k] == [1,2,3]) .or. all([i,j,k] == [2,3,1]) .or. all([i,j,k] == [3,1,2])) then + integer :: o + + + if (any([(all(cshift([i,j,k],o) == [1,2,3]),o=0,2)])) then math_LeviCivita = +1.0_pReal - elseif (all([i,j,k] == [3,2,1]) .or. all([i,j,k] == [2,1,3]) .or. all([i,j,k] == [1,3,2])) then + elseif (any([(all(cshift([i,j,k],o) == [3,2,1]),o=0,2)])) then math_LeviCivita = -1.0_pReal else math_LeviCivita = 0.0_pReal From bb9fa228ab71fba9d104947c583d91faf55fe94b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 21:34:34 +0100 Subject: [PATCH 032/352] 'present' propagates to called function --- src/prec.f90 | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/prec.f90 b/src/prec.f90 index 95b1116cd..4d73462c4 100644 --- a/src/prec.f90 +++ b/src/prec.f90 @@ -108,8 +108,10 @@ logical elemental pure function dEq(a,b,tol) real(pReal), intent(in) :: a,b real(pReal), intent(in), optional :: tol + real(pReal) :: eps + if (present(tol)) then eps = tol else @@ -132,11 +134,8 @@ logical elemental pure function dNeq(a,b,tol) real(pReal), intent(in) :: a,b real(pReal), intent(in), optional :: tol - if (present(tol)) then - dNeq = .not. dEq(a,b,tol) - else - dNeq = .not. dEq(a,b) - endif + + dNeq = .not. dEq(a,b,tol) end function dNeq @@ -151,8 +150,10 @@ logical elemental pure function dEq0(a,tol) real(pReal), intent(in) :: a real(pReal), intent(in), optional :: tol + real(pReal) :: eps + if (present(tol)) then eps = tol else @@ -175,11 +176,8 @@ logical elemental pure function dNeq0(a,tol) real(pReal), intent(in) :: a real(pReal), intent(in), optional :: tol - if (present(tol)) then - dNeq0 = .not. dEq0(a,tol) - else - dNeq0 = .not. dEq0(a) - endif + + dNeq0 = .not. dEq0(a,tol) end function dNeq0 @@ -195,8 +193,10 @@ logical elemental pure function cEq(a,b,tol) complex(pReal), intent(in) :: a,b real(pReal), intent(in), optional :: tol + real(pReal) :: eps + if (present(tol)) then eps = tol else @@ -220,11 +220,8 @@ logical elemental pure function cNeq(a,b,tol) complex(pReal), intent(in) :: a,b real(pReal), intent(in), optional :: tol - if (present(tol)) then - cNeq = .not. cEq(a,b,tol) - else - cNeq = .not. cEq(a,b) - endif + + cNeq = .not. cEq(a,b,tol) end function cNeq @@ -238,6 +235,7 @@ pure function prec_bytesToC_FLOAT(bytes) real(C_FLOAT), dimension(size(bytes,kind=pI64)/(storage_size(0._C_FLOAT,pI64)/8_pI64)) :: & prec_bytesToC_FLOAT + prec_bytesToC_FLOAT = transfer(bytes,prec_bytesToC_FLOAT,size(prec_bytesToC_FLOAT)) end function prec_bytesToC_FLOAT @@ -252,6 +250,7 @@ pure function prec_bytesToC_DOUBLE(bytes) real(C_DOUBLE), dimension(size(bytes,kind=pI64)/(storage_size(0._C_DOUBLE,pI64)/8_pI64)) :: & prec_bytesToC_DOUBLE + prec_bytesToC_DOUBLE = transfer(bytes,prec_bytesToC_DOUBLE,size(prec_bytesToC_DOUBLE)) end function prec_bytesToC_DOUBLE @@ -266,6 +265,7 @@ pure function prec_bytesToC_INT32_T(bytes) integer(C_INT32_T), dimension(size(bytes,kind=pI64)/(storage_size(0_C_INT32_T,pI64)/8_pI64)) :: & prec_bytesToC_INT32_T + prec_bytesToC_INT32_T = transfer(bytes,prec_bytesToC_INT32_T,size(prec_bytesToC_INT32_T)) end function prec_bytesToC_INT32_T @@ -280,6 +280,7 @@ pure function prec_bytesToC_INT64_T(bytes) integer(C_INT64_T), dimension(size(bytes,kind=pI64)/(storage_size(0_C_INT64_T,pI64)/8_pI64)) :: & prec_bytesToC_INT64_T + prec_bytesToC_INT64_T = transfer(bytes,prec_bytesToC_INT64_T,size(prec_bytesToC_INT64_T)) end function prec_bytesToC_INT64_T @@ -295,6 +296,7 @@ subroutine selfTest integer(pInt), dimension(1) :: i real(pReal), dimension(2) :: r + realloc_lhs_test = [1,2] if (any(realloc_lhs_test/=[1,2])) error stop 'LHS allocation' From 1832646089321eae8dead848db12a26407a47731 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 21:35:15 +0100 Subject: [PATCH 033/352] lattice is a property of the phase --- examples/FEM/polyXtal/material.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/FEM/polyXtal/material.yaml b/examples/FEM/polyXtal/material.yaml index c7d17657d..333073150 100644 --- a/examples/FEM/polyXtal/material.yaml +++ b/examples/FEM/polyXtal/material.yaml @@ -5,8 +5,8 @@ homogenization: phase: Aluminum: + lattice: cF mechanics: - lattice: cF output: [F, P, F_e, F_p, L_p] elasticity: {C_11: 106.75e9, C_12: 60.41e9, C_44: 28.34e9, type: hooke} plasticity: From f2402f7ad633b66ba269ec6b7776710b2fd163ab Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 21:41:48 +0100 Subject: [PATCH 034/352] consistent names --- src/constitutive.f90 | 53 ++++++++++++++++--------------- src/constitutive_mech.f90 | 63 ++++++++++++++++++------------------- src/homogenization_mech.f90 | 8 ++--- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 9ec21f69c..bd9ef400e 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -59,9 +59,8 @@ module constitutive crystallite_P, & !< 1st Piola-Kirchhoff stress per grain crystallite_Lp, & !< current plastic velocitiy grad (end of converged time step) crystallite_S, & !< current 2nd Piola-Kirchhoff stress vector (end of converged time step) - crystallite_partitionedF0 !< def grad at start of homog inc - real(pReal), dimension(:,:,:,:,:), allocatable, public :: & - crystallite_partitionedF !< def grad to be reached at end of homog inc + crystallite_partitionedF0, & !< def grad at start of homog inc + crystallite_F !< def grad to be reached at end of homog inc type :: tTensorContainer real(pReal), dimension(:,:,:), allocatable :: data @@ -740,20 +739,21 @@ subroutine constitutive_allocateState(state, & sizeDotState, & sizeDeltaState + state%sizeState = sizeState state%sizeDotState = sizeDotState state%sizeDeltaState = sizeDeltaState state%offsetDeltaState = sizeState-sizeDeltaState ! deltaState occupies latter part of state by definition - allocate(state%atol (sizeState), source=0.0_pReal) - allocate(state%state0 (sizeState,Nconstituents), source=0.0_pReal) + allocate(state%atol (sizeState), source=0.0_pReal) + allocate(state%state0 (sizeState,Nconstituents), source=0.0_pReal) allocate(state%partitionedState0(sizeState,Nconstituents), source=0.0_pReal) - allocate(state%subState0 (sizeState,Nconstituents), source=0.0_pReal) - allocate(state%state (sizeState,Nconstituents), source=0.0_pReal) + allocate(state%subState0 (sizeState,Nconstituents), source=0.0_pReal) + allocate(state%state (sizeState,Nconstituents), source=0.0_pReal) - allocate(state%dotState (sizeDotState,Nconstituents), source=0.0_pReal) + allocate(state%dotState (sizeDotState,Nconstituents), source=0.0_pReal) - allocate(state%deltaState(sizeDeltaState,Nconstituents), source=0.0_pReal) + allocate(state%deltaState (sizeDeltaState,Nconstituents), source=0.0_pReal) end subroutine constitutive_allocateState @@ -794,7 +794,7 @@ subroutine constitutive_forward integer :: i, j - crystallite_F0 = crystallite_partitionedF + crystallite_F0 = crystallite_F crystallite_Lp0 = crystallite_Lp crystallite_S0 = crystallite_S @@ -841,12 +841,13 @@ subroutine crystallite_init Nconstituents, & ph, & me, & - co, & !< counter in integration point component loop - ip, & !< counter in integration point loop - el, & !< counter in element loop + co, & !< counter in integration point component loop + ip, & !< counter in integration point loop + el, & !< counter in element loop cMax, & !< maximum number of integration point components iMax, & !< maximum number of integration points - eMax !< maximum number of elements + eMax, & !< maximum number of elements + so class(tNode), pointer :: & num_crystallite, & @@ -865,7 +866,7 @@ subroutine crystallite_init iMax = discretization_nIPs eMax = discretization_Nelems - allocate(crystallite_partitionedF(3,3,cMax,iMax,eMax),source=0.0_pReal) + allocate(crystallite_F(3,3,cMax,iMax,eMax),source=0.0_pReal) allocate(crystallite_S0, & crystallite_F0,crystallite_Lp0, & @@ -875,7 +876,7 @@ subroutine crystallite_init crystallite_S,crystallite_P, & crystallite_Fe,crystallite_Lp, & crystallite_subFp0,crystallite_subFi0, & - source = crystallite_partitionedF) + source = crystallite_F) allocate(crystallite_subdt(cMax,iMax,eMax),source=0.0_pReal) allocate(crystallite_orientation(cMax,iMax,eMax)) @@ -968,7 +969,7 @@ subroutine crystallite_init !$OMP END PARALLEL DO crystallite_partitionedF0 = crystallite_F0 - crystallite_partitionedF = crystallite_F0 + crystallite_F = crystallite_F0 !$OMP PARALLEL DO PRIVATE(ph,me) @@ -1035,9 +1036,9 @@ subroutine constitutive_windForward(ip,el) do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - crystallite_partitionedF0 (1:3,1:3,co,ip,el) = crystallite_partitionedF(1:3,1:3,co,ip,el) - crystallite_partitionedLp0(1:3,1:3,co,ip,el) = crystallite_Lp (1:3,1:3,co,ip,el) - crystallite_partitionedS0 (1:3,1:3,co,ip,el) = crystallite_S (1:3,1:3,co,ip,el) + crystallite_partitionedF0 (1:3,1:3,co,ip,el) = crystallite_F (1:3,1:3,co,ip,el) + crystallite_partitionedLp0(1:3,1:3,co,ip,el) = crystallite_Lp(1:3,1:3,co,ip,el) + crystallite_partitionedS0 (1:3,1:3,co,ip,el) = crystallite_S (1:3,1:3,co,ip,el) call constitutive_mech_windForward(ph,me) do so = 1, phase_Nsources(material_phaseAt(co,el)) @@ -1128,8 +1129,8 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) !-------------------------------------------------------------------------------------------------- ! calculate dSdF temp_33_1 = transpose(matmul(invFp,invFi)) - temp_33_2 = matmul(crystallite_partitionedF(1:3,1:3,co,ip,el),invSubFp0) - temp_33_3 = matmul(matmul(crystallite_partitionedF(1:3,1:3,co,ip,el),invFp), invSubFi0) + temp_33_2 = matmul(crystallite_F(1:3,1:3,co,ip,el),invSubFp0) + temp_33_3 = matmul(matmul(crystallite_F(1:3,1:3,co,ip,el),invFp), invSubFi0) do o=1,3; do p=1,3 rhs_3333(p,o,1:3,1:3) = matmul(dSdFe(p,o,1:3,1:3),temp_33_1) @@ -1160,7 +1161,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) ! assemble dPdF temp_33_1 = matmul(crystallite_S(1:3,1:3,co,ip,el),transpose(invFp)) temp_33_2 = matmul(invFp,temp_33_1) - temp_33_3 = matmul(crystallite_partitionedF(1:3,1:3,co,ip,el),invFp) + temp_33_3 = matmul(crystallite_F(1:3,1:3,co,ip,el),invFp) temp_33_4 = matmul(temp_33_3,crystallite_S(1:3,1:3,co,ip,el)) dPdF = 0.0_pReal @@ -1169,7 +1170,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) enddo do o=1,3; do p=1,3 dPdF(1:3,1:3,p,o) = dPdF(1:3,1:3,p,o) & - + matmul(matmul(crystallite_partitionedF(1:3,1:3,co,ip,el), & + + matmul(matmul(crystallite_F(1:3,1:3,co,ip,el), & dFpinvdF(1:3,1:3,p,o)),temp_33_1) & + matmul(matmul(temp_33_3,dSdF(1:3,1:3,p,o)), & transpose(invFp)) & @@ -1216,7 +1217,7 @@ function crystallite_push33ToRef(co,ip,el, tensor33) T = matmul(material_orientation0(co,ip,el)%asMatrix(), & ! ToDo: initial orientation correct? - transpose(math_inv33(crystallite_partitionedF(1:3,1:3,co,ip,el)))) + transpose(math_inv33(crystallite_F(1:3,1:3,co,ip,el)))) crystallite_push33ToRef = matmul(transpose(T),matmul(tensor33,T)) end function crystallite_push33ToRef @@ -1359,7 +1360,7 @@ subroutine crystallite_restartWrite write(fileName,'(a,i0,a)') trim(getSolverJobName())//'_',worldrank,'.hdf5' fileHandle = HDF5_openFile(fileName,'a') - call HDF5_write(fileHandle,crystallite_partitionedF,'F') + call HDF5_write(fileHandle,crystallite_F,'F') call HDF5_write(fileHandle,crystallite_Lp, 'L_p') call HDF5_write(fileHandle,crystallite_S, 'S') diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 1dac6fffd..96dc9809a 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -800,7 +800,7 @@ function integrateStress(F,Delta_t,co,ip,el) result(broken) broken = .true. - call constitutive_plastic_dependentState(crystallite_partitionedF(1:3,1:3,co,ip,el),co,ip,el) + call constitutive_plastic_dependentState(crystallite_F(1:3,1:3,co,ip,el),co,ip,el) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) @@ -959,6 +959,9 @@ function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) el, & !< element index in element loop ip, & !< integration point index in ip loop co !< grain index in grain loop + logical :: & + broken + integer :: & NiterationState, & !< number of iterations in state loop ph, & @@ -970,8 +973,7 @@ function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) r ! state residuum real(pReal), dimension(constitutive_plasticity_maxSizeDotState,2) :: & plastic_dotState - logical :: & - broken + ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) @@ -1048,12 +1050,14 @@ function integrateStateEuler(F_0,F,Delta_t,co,ip,el) result(broken) el, & !< element index in element loop ip, & !< integration point index in ip loop co !< grain index in grain loop + logical :: & + broken + integer :: & ph, & me, & sizeDotState - logical :: & - broken + ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) @@ -1085,13 +1089,13 @@ function integrateStateAdaptiveEuler(F_0,F,Delta_t,co,ip,el) result(broken) el, & !< element index in element loop ip, & !< integration point index in ip loop co !< grain index in grain loop + logical :: & + broken + integer :: & ph, & me, & sizeDotState - logical :: & - broken - real(pReal), dimension(constitutive_plasticity_maxSizeDotState) :: residuum_plastic @@ -1105,7 +1109,7 @@ function integrateStateAdaptiveEuler(F_0,F,Delta_t,co,ip,el) result(broken) residuum_plastic(1:sizeDotState) = - plasticState(ph)%dotstate(1:sizeDotState,me) * 0.5_pReal * Delta_t plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%subState0(1:sizeDotState,me) & - + plasticState(ph)%dotstate(1:sizeDotState,me) * Delta_t + + plasticState(ph)%dotstate(1:sizeDotState,me) * Delta_t broken = constitutive_deltaState(crystallite_S(1:3,1:3,co,ip,el), & constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) @@ -1145,6 +1149,7 @@ function integrateStateRK4(F_0,F,Delta_t,co,ip,el) result(broken) real(pReal), dimension(4), parameter :: & B = [1.0_pReal/6.0_pReal, 1.0_pReal/3.0_pReal, 1.0_pReal/3.0_pReal, 1.0_pReal/6.0_pReal] + broken = integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C) end function integrateStateRK4 @@ -1178,6 +1183,7 @@ function integrateStateRKCK45(F_0,F,Delta_t,co,ip,el) result(broken) [2825.0_pReal/27648.0_pReal, .0_pReal, 18575.0_pReal/48384.0_pReal,& 13525.0_pReal/55296.0_pReal, 277.0_pReal/14336.0_pReal, 1._pReal/4._pReal] + broken = integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) end function integrateStateRKCK45 @@ -1215,18 +1221,18 @@ function integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) result(broken) broken = mech_collectDotState(Delta_t,co,ip,el,ph,me) if(broken) return + sizeDotState = plasticState(ph)%sizeDotState + do stage = 1, size(A,1) - sizeDotState = plasticState(ph)%sizeDotState + plastic_RKdotState(1:sizeDotState,stage) = plasticState(ph)%dotState(:,me) plasticState(ph)%dotState(:,me) = A(1,stage) * plastic_RKdotState(1:sizeDotState,1) do n = 2, stage - sizeDotState = plasticState(ph)%sizeDotState plasticState(ph)%dotState(:,me) = plasticState(ph)%dotState(:,me) & - + A(n,stage) * plastic_RKdotState(1:sizeDotState,n) + + A(n,stage) * plastic_RKdotState(1:sizeDotState,n) enddo - sizeDotState = plasticState(ph)%sizeDotState plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%subState0(1:sizeDotState,me) & + plasticState(ph)%dotState (1:sizeDotState,me) * Delta_t @@ -1239,7 +1245,6 @@ function integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) result(broken) enddo if(broken) return - sizeDotState = plasticState(ph)%sizeDotState plastic_RKdotState(1:sizeDotState,size(B)) = plasticState (ph)%dotState(:,me) plasticState(ph)%dotState(:,me) = matmul(plastic_RKdotState(1:sizeDotState,1:size(B)),B) @@ -1282,7 +1287,7 @@ subroutine crystallite_results(group,ph) select case (output_constituent(ph)%label(ou)) case('F') - selected_tensors = select_tensors(crystallite_partitionedF,ph) + selected_tensors = select_tensors(crystallite_F,ph) call results_writeDataset(group//'/mechanics/',selected_tensors,output_constituent(ph)%label(ou),& 'deformation gradient','1') case('F_e') @@ -1482,7 +1487,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) formerSubStep integer :: & NiterationCrystallite, & ! number of iterations in crystallite loop - s, ph, me + so, ph, me logical :: todo real(pReal) :: subFrac,subStep real(pReal), dimension(3,3) :: & @@ -1496,12 +1501,10 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) me = material_phaseMemberAt(co,ip,el) subLi0 = constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) subLp0 = crystallite_partitionedLp0(1:3,1:3,co,ip,el) - plasticState (material_phaseAt(co,el))%subState0( :,material_phaseMemberAt(co,ip,el)) = & - plasticState (material_phaseAt(co,el))%partitionedState0(:,material_phaseMemberAt(co,ip,el)) - do s = 1, phase_Nsources(material_phaseAt(co,el)) - sourceState(material_phaseAt(co,el))%p(s)%subState0( :,material_phaseMemberAt(co,ip,el)) = & - sourceState(material_phaseAt(co,el))%p(s)%partitionedState0(:,material_phaseMemberAt(co,ip,el)) + plasticState(ph)%subState0(:,me) = plasticState(ph)%partitionedState0(:,me) + do so = 1, phase_Nsources(ph) + sourceState(ph)%p(so)%subState0(:,me) = sourceState(ph)%p(so)%partitionedState0(:,me) enddo crystallite_subFp0(1:3,1:3,co,ip,el) = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) crystallite_subFi0(1:3,1:3,co,ip,el) = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) @@ -1531,11 +1534,9 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) subLi0 = constitutive_mech_Li(ph)%data(1:3,1:3,me) crystallite_subFp0(1:3,1:3,co,ip,el) = constitutive_mech_Fp(ph)%data(1:3,1:3,me) crystallite_subFi0(1:3,1:3,co,ip,el) = constitutive_mech_Fi(ph)%data(1:3,1:3,me) - plasticState( material_phaseAt(co,el))%subState0(:,material_phaseMemberAt(co,ip,el)) & - = plasticState(material_phaseAt(co,el))%state( :,material_phaseMemberAt(co,ip,el)) - do s = 1, phase_Nsources(material_phaseAt(co,el)) - sourceState( material_phaseAt(co,el))%p(s)%subState0(:,material_phaseMemberAt(co,ip,el)) & - = sourceState(material_phaseAt(co,el))%p(s)%state( :,material_phaseMemberAt(co,ip,el)) + plasticState(ph)%subState0(:,me) = plasticState(ph)%state(:,me) + do so = 1, phase_Nsources(ph) + sourceState(ph)%p(so)%subState0(:,me) = sourceState(ph)%p(so)%state(:,me) enddo endif !-------------------------------------------------------------------------------------------------- @@ -1549,11 +1550,9 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) crystallite_Lp (1:3,1:3,co,ip,el) = subLp0 constitutive_mech_Li(ph)%data(1:3,1:3,me) = subLi0 endif - plasticState (material_phaseAt(co,el))%state( :,material_phaseMemberAt(co,ip,el)) & - = plasticState(material_phaseAt(co,el))%subState0(:,material_phaseMemberAt(co,ip,el)) - do s = 1, phase_Nsources(material_phaseAt(co,el)) - sourceState( material_phaseAt(co,el))%p(s)%state( :,material_phaseMemberAt(co,ip,el)) & - = sourceState(material_phaseAt(co,el))%p(s)%subState0(:,material_phaseMemberAt(co,ip,el)) + plasticState(ph)%state(:,me) = plasticState(ph)%subState0(:,me) + do so = 1, phase_Nsources(ph) + sourceState(ph)%p(so)%state(:,me) = sourceState(ph)%p(so)%subState0(:,me) enddo todo = subStep > num%subStepMinCryst ! still on track or already done (beyond repair) @@ -1563,7 +1562,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) ! prepare for integration if (todo) then subF = subF0 & - + subStep * (crystallite_partitionedF(1:3,1:3,co,ip,el) -crystallite_partitionedF0(1:3,1:3,co,ip,el)) + + subStep * (crystallite_F(1:3,1:3,co,ip,el) - crystallite_partitionedF0(1:3,1:3,co,ip,el)) crystallite_Fe(1:3,1:3,co,ip,el) = matmul(subF,math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) crystallite_subdt(co,ip,el) = subStep * dt diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index 8eda278b2..641e960fd 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -116,16 +116,16 @@ module subroutine mech_partition(subF,ip,el) chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) case (HOMOGENIZATION_NONE_ID) chosenHomogenization - crystallite_partitionedF(1:3,1:3,1,ip,el) = subF + crystallite_F(1:3,1:3,1,ip,el) = subF case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization call mech_isostrain_partitionDeformation(& - crystallite_partitionedF(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & + crystallite_F(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & subF) case (HOMOGENIZATION_RGC_ID) chosenHomogenization call mech_RGC_partitionDeformation(& - crystallite_partitionedF(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & + crystallite_F(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & subF,& ip, & el) @@ -206,7 +206,7 @@ module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) enddo doneAndHappy = & mech_RGC_updateState(crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - crystallite_partitionedF(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & + crystallite_F(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & crystallite_partitionedF0(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el),& subF,& subdt, & From b41dc7db2893979fc1e11167dd9b11523f94d22f Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 22:17:28 +0100 Subject: [PATCH 035/352] simplified --- src/constitutive.f90 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index bd9ef400e..f69ae604c 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -1065,7 +1065,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) p, ph, me real(pReal), dimension(3,3) :: devNull, & invSubFp0,invSubFi0,invFp,invFi, & - temp_33_1, temp_33_2, temp_33_3, temp_33_4 + temp_33_1, temp_33_2, temp_33_3 real(pReal), dimension(3,3,3,3) :: dSdFe, & dSdF, & dSdFi, & @@ -1160,21 +1160,20 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) !-------------------------------------------------------------------------------------------------- ! assemble dPdF temp_33_1 = matmul(crystallite_S(1:3,1:3,co,ip,el),transpose(invFp)) - temp_33_2 = matmul(invFp,temp_33_1) - temp_33_3 = matmul(crystallite_F(1:3,1:3,co,ip,el),invFp) - temp_33_4 = matmul(temp_33_3,crystallite_S(1:3,1:3,co,ip,el)) + temp_33_2 = matmul(crystallite_F(1:3,1:3,co,ip,el),invFp) + temp_33_3 = matmul(temp_33_2,crystallite_S(1:3,1:3,co,ip,el)) dPdF = 0.0_pReal do p=1,3 - dPdF(p,1:3,p,1:3) = transpose(temp_33_2) + dPdF(p,1:3,p,1:3) = transpose(matmul(invFp,temp_33_1)) enddo do o=1,3; do p=1,3 dPdF(1:3,1:3,p,o) = dPdF(1:3,1:3,p,o) & + matmul(matmul(crystallite_F(1:3,1:3,co,ip,el), & dFpinvdF(1:3,1:3,p,o)),temp_33_1) & - + matmul(matmul(temp_33_3,dSdF(1:3,1:3,p,o)), & + + matmul(matmul(temp_33_2,dSdF(1:3,1:3,p,o)), & transpose(invFp)) & - + matmul(temp_33_4,transpose(dFpinvdF(1:3,1:3,p,o))) + + matmul(temp_33_3,transpose(dFpinvdF(1:3,1:3,p,o))) enddo; enddo end function crystallite_stressTangent From f08fbbaaa29658c17435794987b14063a4ca847c Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Dec 2020 22:33:04 +0100 Subject: [PATCH 036/352] consistent names --- src/constitutive.f90 | 2 +- src/constitutive_mech.f90 | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index f69ae604c..b7e587f51 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -872,7 +872,7 @@ subroutine crystallite_init crystallite_F0,crystallite_Lp0, & crystallite_partitionedS0, & crystallite_partitionedF0,& - crystallite_partitionedLp0, & + crystallite_partitionedLp0, & crystallite_S,crystallite_P, & crystallite_Fe,crystallite_Lp, & crystallite_subFp0,crystallite_subFi0, & diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 96dc9809a..158ed098e 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -966,13 +966,13 @@ function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) NiterationState, & !< number of iterations in state loop ph, & me, & - size_pl + sizeDotState real(pReal) :: & zeta real(pReal), dimension(constitutive_plasticity_maxSizeDotState) :: & r ! state residuum real(pReal), dimension(constitutive_plasticity_maxSizeDotState,2) :: & - plastic_dotState + dotState ph = material_phaseAt(co,el) @@ -981,15 +981,15 @@ function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) if(broken) return - size_pl = plasticState(ph)%sizeDotState - plasticState(ph)%state(1:size_pl,me) = plasticState(ph)%subState0(1:size_pl,me) & - + plasticState(ph)%dotState (1:size_pl,me) * Delta_t - plastic_dotState(1:size_pl,2) = 0.0_pReal + sizeDotState = plasticState(ph)%sizeDotState + plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%subState0(1:sizeDotState,me) & + + plasticState(ph)%dotState (1:sizeDotState,me) * Delta_t + dotState(1:sizeDotState,2) = 0.0_pReal iteration: do NiterationState = 1, num%nState - if(nIterationState > 1) plastic_dotState(1:size_pl,2) = plastic_dotState(1:size_pl,1) - plastic_dotState(1:size_pl,1) = plasticState(ph)%dotState(:,me) + if(nIterationState > 1) dotState(1:sizeDotState,2) = dotState(1:sizeDotState,1) + dotState(1:sizeDotState,1) = plasticState(ph)%dotState(:,me) broken = integrateStress(F,Delta_t,co,ip,el) if(broken) exit iteration @@ -997,16 +997,16 @@ function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) if(broken) exit iteration - zeta = damper(plasticState(ph)%dotState(:,me),plastic_dotState(1:size_pl,1),& - plastic_dotState(1:size_pl,2)) + zeta = damper(plasticState(ph)%dotState(:,me),dotState(1:sizeDotState,1),& + dotState(1:sizeDotState,2)) plasticState(ph)%dotState(:,me) = plasticState(ph)%dotState(:,me) * zeta & - + plastic_dotState(1:size_pl,1) * (1.0_pReal - zeta) - r(1:size_pl) = plasticState(ph)%state (1:size_pl,me) & - - plasticState(ph)%subState0(1:size_pl,me) & - - plasticState(ph)%dotState (1:size_pl,me) * Delta_t - plasticState(ph)%state(1:size_pl,me) = plasticState(ph)%state(1:size_pl,me) & - - r(1:size_pl) - if (converged(r(1:size_pl),plasticState(ph)%state(1:size_pl,me),plasticState(ph)%atol(1:size_pl))) then + + dotState(1:sizeDotState,1) * (1.0_pReal - zeta) + r(1:sizeDotState) = plasticState(ph)%state (1:sizeDotState,me) & + - plasticState(ph)%subState0(1:sizeDotState,me) & + - plasticState(ph)%dotState (1:sizeDotState,me) * Delta_t + plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%state(1:sizeDotState,me) & + - r(1:sizeDotState) + if (converged(r(1:sizeDotState),plasticState(ph)%state(1:sizeDotState,me),plasticState(ph)%atol(1:sizeDotState))) then broken = constitutive_deltaState(crystallite_S(1:3,1:3,co,ip,el), & constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) exit iteration From f560b33db0a727423ee48b30a22a5a86e60e7c0f Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 00:13:49 +0100 Subject: [PATCH 037/352] avoid global variables --- src/constitutive.f90 | 11 ++-- src/constitutive_mech.f90 | 108 +++++++++++++++++++++----------------- 2 files changed, 65 insertions(+), 54 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index b7e587f51..808870059 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -49,8 +49,6 @@ module constitutive real(pReal), dimension(:,:,:,:,:), allocatable :: & crystallite_F0, & !< def grad at start of FE inc crystallite_Fe, & !< current "elastic" def grad (end of converged time step) - crystallite_subFp0,& !< plastic def grad at start of crystallite inc - crystallite_subFi0,& !< intermediate def grad at start of crystallite inc crystallite_Lp0, & !< plastic velocitiy grad at start of FE inc crystallite_partitionedLp0, & !< plastic velocity grad at start of homog inc crystallite_S0, & !< 2nd Piola-Kirchhoff stress vector at start of FE inc @@ -748,7 +746,6 @@ subroutine constitutive_allocateState(state, & allocate(state%atol (sizeState), source=0.0_pReal) allocate(state%state0 (sizeState,Nconstituents), source=0.0_pReal) allocate(state%partitionedState0(sizeState,Nconstituents), source=0.0_pReal) - allocate(state%subState0 (sizeState,Nconstituents), source=0.0_pReal) allocate(state%state (sizeState,Nconstituents), source=0.0_pReal) allocate(state%dotState (sizeDotState,Nconstituents), source=0.0_pReal) @@ -875,7 +872,6 @@ subroutine crystallite_init crystallite_partitionedLp0, & crystallite_S,crystallite_P, & crystallite_Fe,crystallite_Lp, & - crystallite_subFp0,crystallite_subFi0, & source = crystallite_F) allocate(crystallite_subdt(cMax,iMax,eMax),source=0.0_pReal) @@ -936,6 +932,9 @@ subroutine crystallite_init allocate(constitutive_mech_Li(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Li0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_partitionedLi0(ph)%data(3,3,Nconstituents)) + do so = 1, phase_Nsources(ph) + allocate(sourceState(ph)%p(so)%subState0,source=sourceState(ph)%p(so)%state0) ! ToDo: hack + enddo enddo print'(a42,1x,i10)', ' # of elements: ', eMax @@ -1095,8 +1094,8 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) invFp = math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me)) invFi = math_inv33(constitutive_mech_Fi(ph)%data(1:3,1:3,me)) - invSubFp0 = math_inv33(crystallite_subFp0(1:3,1:3,co,ip,el)) - invSubFi0 = math_inv33(crystallite_subFi0(1:3,1:3,co,ip,el)) + invSubFp0 = math_inv33(constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me)) + invSubFi0 = math_inv33(constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me)) if (sum(abs(dLidS)) < tol_math_check) then dFidS = 0.0_pReal diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 158ed098e..11ced6f40 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -737,9 +737,9 @@ end subroutine mech_results !> @brief calculation of stress (P) with time integration based on a residuum in Lp and !> intermediate acceleration of the Newton-Raphson correction !-------------------------------------------------------------------------------------------------- -function integrateStress(F,Delta_t,co,ip,el) result(broken) +function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) - real(pReal), dimension(3,3), intent(in) :: F + real(pReal), dimension(3,3), intent(in) :: F,subFp0,subFi0 real(pReal), intent(in) :: Delta_t integer, intent(in):: el, & ! element index ip, & ! integration point index @@ -808,9 +808,9 @@ function integrateStress(F,Delta_t,co,ip,el) result(broken) Lpguess = crystallite_Lp(1:3,1:3,co,ip,el) ! take as first guess Liguess = constitutive_mech_Li(ph)%data(1:3,1:3,me) ! take as first guess - call math_invert33(invFp_current,devNull,error,crystallite_subFp0(1:3,1:3,co,ip,el)) + call math_invert33(invFp_current,devNull,error,subFp0) if (error) return ! error - call math_invert33(invFi_current,devNull,error,crystallite_subFi0(1:3,1:3,co,ip,el)) + call math_invert33(invFi_current,devNull,error,subFi0) if (error) return ! error A = matmul(F,invFp_current) ! intermediate tensor needed later to calculate dFe_dLp @@ -951,9 +951,10 @@ end function integrateStress !> @brief integrate stress, state with adaptive 1st order explicit Euler method !> using Fixed Point Iteration to adapt the stepsize !-------------------------------------------------------------------------------------------------- -function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) +function integrateStateFPI(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) result(broken) - real(pReal), intent(in),dimension(3,3) :: F_0,F + real(pReal), intent(in),dimension(3,3) :: F_0,F,subFp0,subFi0 + real(pReal), intent(in),dimension(:) :: subState0 real(pReal), intent(in) :: Delta_t integer, intent(in) :: & el, & !< element index in element loop @@ -982,7 +983,7 @@ function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) if(broken) return sizeDotState = plasticState(ph)%sizeDotState - plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%subState0(1:sizeDotState,me) & + plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotState (1:sizeDotState,me) * Delta_t dotState(1:sizeDotState,2) = 0.0_pReal @@ -991,7 +992,7 @@ function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) if(nIterationState > 1) dotState(1:sizeDotState,2) = dotState(1:sizeDotState,1) dotState(1:sizeDotState,1) = plasticState(ph)%dotState(:,me) - broken = integrateStress(F,Delta_t,co,ip,el) + broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) if(broken) exit iteration broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) @@ -1002,7 +1003,7 @@ function integrateStateFPI(F_0,F,Delta_t,co,ip,el) result(broken) plasticState(ph)%dotState(:,me) = plasticState(ph)%dotState(:,me) * zeta & + dotState(1:sizeDotState,1) * (1.0_pReal - zeta) r(1:sizeDotState) = plasticState(ph)%state (1:sizeDotState,me) & - - plasticState(ph)%subState0(1:sizeDotState,me) & + - subState0 & - plasticState(ph)%dotState (1:sizeDotState,me) * Delta_t plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%state(1:sizeDotState,me) & - r(1:sizeDotState) @@ -1042,9 +1043,10 @@ end function integrateStateFPI !-------------------------------------------------------------------------------------------------- !> @brief integrate state with 1st order explicit Euler method !-------------------------------------------------------------------------------------------------- -function integrateStateEuler(F_0,F,Delta_t,co,ip,el) result(broken) +function integrateStateEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) result(broken) - real(pReal), intent(in),dimension(3,3) :: F_0,F + real(pReal), intent(in),dimension(3,3) :: F_0,F,subFp0,subFi0 + real(pReal), intent(in),dimension(:) :: subState0 real(pReal), intent(in) :: Delta_t integer, intent(in) :: & el, & !< element index in element loop @@ -1066,14 +1068,14 @@ function integrateStateEuler(F_0,F,Delta_t,co,ip,el) result(broken) if(broken) return sizeDotState = plasticState(ph)%sizeDotState - plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%subState0(1:sizeDotState,me) & - + plasticState(ph)%dotState (1:sizeDotState,me) * Delta_t + plasticState(ph)%state(1:sizeDotState,me) = subState0 & + + plasticState(ph)%dotState(1:sizeDotState,me) * Delta_t broken = constitutive_deltaState(crystallite_S(1:3,1:3,co,ip,el), & constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) if(broken) return - broken = integrateStress(F,Delta_t,co,ip,el) + broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) end function integrateStateEuler @@ -1081,9 +1083,10 @@ end function integrateStateEuler !-------------------------------------------------------------------------------------------------- !> @brief integrate stress, state with 1st order Euler method with adaptive step size !-------------------------------------------------------------------------------------------------- -function integrateStateAdaptiveEuler(F_0,F,Delta_t,co,ip,el) result(broken) +function integrateStateAdaptiveEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) result(broken) - real(pReal), intent(in),dimension(3,3) :: F_0,F + real(pReal), intent(in),dimension(3,3) :: F_0,F,subFp0,subFi0 + real(pReal), intent(in),dimension(:) :: subState0 real(pReal), intent(in) :: Delta_t integer, intent(in) :: & el, & !< element index in element loop @@ -1108,14 +1111,14 @@ function integrateStateAdaptiveEuler(F_0,F,Delta_t,co,ip,el) result(broken) sizeDotState = plasticState(ph)%sizeDotState residuum_plastic(1:sizeDotState) = - plasticState(ph)%dotstate(1:sizeDotState,me) * 0.5_pReal * Delta_t - plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%subState0(1:sizeDotState,me) & + plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotstate(1:sizeDotState,me) * Delta_t broken = constitutive_deltaState(crystallite_S(1:3,1:3,co,ip,el), & constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) if(broken) return - broken = integrateStress(F,Delta_t,co,ip,el) + broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) if(broken) return broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) @@ -1131,9 +1134,10 @@ end function integrateStateAdaptiveEuler !--------------------------------------------------------------------------------------------------- !> @brief Integrate state (including stress integration) with the classic Runge Kutta method !--------------------------------------------------------------------------------------------------- -function integrateStateRK4(F_0,F,Delta_t,co,ip,el) result(broken) +function integrateStateRK4(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) result(broken) - real(pReal), intent(in),dimension(3,3) :: F_0,F + real(pReal), intent(in),dimension(3,3) :: F_0,F,subFp0,subFi0 + real(pReal), intent(in),dimension(:) :: subState0 real(pReal), intent(in) :: Delta_t integer, intent(in) :: co,ip,el logical :: broken @@ -1150,7 +1154,7 @@ function integrateStateRK4(F_0,F,Delta_t,co,ip,el) result(broken) B = [1.0_pReal/6.0_pReal, 1.0_pReal/3.0_pReal, 1.0_pReal/3.0_pReal, 1.0_pReal/6.0_pReal] - broken = integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C) + broken = integrateStateRK(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el,A,B,C) end function integrateStateRK4 @@ -1158,9 +1162,10 @@ end function integrateStateRK4 !--------------------------------------------------------------------------------------------------- !> @brief Integrate state (including stress integration) with the Cash-Carp method !--------------------------------------------------------------------------------------------------- -function integrateStateRKCK45(F_0,F,Delta_t,co,ip,el) result(broken) +function integrateStateRKCK45(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) result(broken) - real(pReal), intent(in),dimension(3,3) :: F_0,F + real(pReal), intent(in),dimension(3,3) :: F_0,F,subFp0,subFi0 + real(pReal), intent(in),dimension(:) :: subState0 real(pReal), intent(in) :: Delta_t integer, intent(in) :: co,ip,el logical :: broken @@ -1184,7 +1189,7 @@ function integrateStateRKCK45(F_0,F,Delta_t,co,ip,el) result(broken) 13525.0_pReal/55296.0_pReal, 277.0_pReal/14336.0_pReal, 1._pReal/4._pReal] - broken = integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) + broken = integrateStateRK(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el,A,B,C,DB) end function integrateStateRKCK45 @@ -1193,9 +1198,10 @@ end function integrateStateRKCK45 !> @brief Integrate state (including stress integration) with an explicit Runge-Kutta method or an !! embedded explicit Runge-Kutta method !-------------------------------------------------------------------------------------------------- -function integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) result(broken) +function integrateStateRK(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el,A,B,C,DB) result(broken) - real(pReal), intent(in),dimension(3,3) :: F_0,F + real(pReal), intent(in),dimension(3,3) :: F_0,F,subFp0,subFi0 + real(pReal), intent(in),dimension(:) :: subState0 real(pReal), intent(in) :: Delta_t real(pReal), dimension(:,:), intent(in) :: A real(pReal), dimension(:), intent(in) :: B, C @@ -1233,10 +1239,10 @@ function integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) result(broken) + A(n,stage) * plastic_RKdotState(1:sizeDotState,n) enddo - plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%subState0(1:sizeDotState,me) & + plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotState (1:sizeDotState,me) * Delta_t - broken = integrateStress(F_0 + (F - F_0) * Delta_t * C(stage),Delta_t * C(stage),co,ip,el) + broken = integrateStress(F_0 + (F - F_0) * Delta_t * C(stage),subFp0,subFi0,Delta_t * C(stage),co,ip,el) if(broken) exit broken = mech_collectDotState(Delta_t*C(stage),co,ip,el,ph,me) @@ -1248,7 +1254,7 @@ function integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) result(broken) plastic_RKdotState(1:sizeDotState,size(B)) = plasticState (ph)%dotState(:,me) plasticState(ph)%dotState(:,me) = matmul(plastic_RKdotState(1:sizeDotState,1:size(B)),B) - plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%subState0(1:sizeDotState,me) & + plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotState (1:sizeDotState,me) * Delta_t if(present(DB)) & @@ -1262,7 +1268,7 @@ function integrateStateRK(F_0,F,Delta_t,co,ip,el,A,B,C,DB) result(broken) constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) if(broken) return - broken = integrateStress(F,Delta_t,co,ip,el) + broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) end function integrateStateRK @@ -1487,33 +1493,40 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) formerSubStep integer :: & NiterationCrystallite, & ! number of iterations in crystallite loop - so, ph, me + so, ph, me, sizeDotState logical :: todo real(pReal) :: subFrac,subStep real(pReal), dimension(3,3) :: & - subLp0, & !< plastic velocity grad at start of crystallite inc - subLi0, & !< intermediate velocity grad at start of crystallite inc + subFp0, & + subFi0, & + subLp0, & + subLi0, & subF0, & subF + real(pReal), dimension(:), allocatable :: subState0 ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) + sizeDotState = plasticState(ph)%sizeDotState + subLi0 = constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) subLp0 = crystallite_partitionedLp0(1:3,1:3,co,ip,el) + subState0 = plasticState(ph)%partitionedState0(:,me) + - plasticState(ph)%subState0(:,me) = plasticState(ph)%partitionedState0(:,me) do so = 1, phase_Nsources(ph) sourceState(ph)%p(so)%subState0(:,me) = sourceState(ph)%p(so)%partitionedState0(:,me) enddo - crystallite_subFp0(1:3,1:3,co,ip,el) = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) - crystallite_subFi0(1:3,1:3,co,ip,el) = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) + subFp0 = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) + subFi0 = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) subF0 = crystallite_partitionedF0(1:3,1:3,co,ip,el) subFrac = 0.0_pReal subStep = 1.0_pReal/num%subStepSizeCryst todo = .true. converged_ = .false. ! pretend failed step of 1/subStepSizeCryst + crystallite_subdt(co,ip,el) = dt todo = .true. NiterationCrystallite = 0 cutbackLooping: do while (todo) @@ -1532,9 +1545,9 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) subF0 = subF subLp0 = crystallite_Lp (1:3,1:3,co,ip,el) subLi0 = constitutive_mech_Li(ph)%data(1:3,1:3,me) - crystallite_subFp0(1:3,1:3,co,ip,el) = constitutive_mech_Fp(ph)%data(1:3,1:3,me) - crystallite_subFi0(1:3,1:3,co,ip,el) = constitutive_mech_Fi(ph)%data(1:3,1:3,me) - plasticState(ph)%subState0(:,me) = plasticState(ph)%state(:,me) + subFp0 = constitutive_mech_Fp(ph)%data(1:3,1:3,me) + subFi0 = constitutive_mech_Fi(ph)%data(1:3,1:3,me) + subState0 = plasticState(ph)%state(:,me) do so = 1, phase_Nsources(ph) sourceState(ph)%p(so)%subState0(:,me) = sourceState(ph)%p(so)%state(:,me) enddo @@ -1543,14 +1556,14 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) ! cut back (reduced time and restore) else subStep = num%subStepSizeCryst * subStep - constitutive_mech_Fp(ph)%data(1:3,1:3,me) = crystallite_subFp0(1:3,1:3,co,ip,el) - constitutive_mech_Fi(ph)%data(1:3,1:3,me) = crystallite_subFi0(1:3,1:3,co,ip,el) - crystallite_S (1:3,1:3,co,ip,el) = crystallite_S0 (1:3,1:3,co,ip,el) - if (subStep < 1.0_pReal) then ! actual (not initial) cutback - crystallite_Lp (1:3,1:3,co,ip,el) = subLp0 - constitutive_mech_Li(ph)%data(1:3,1:3,me) = subLi0 + constitutive_mech_Fp(ph)%data(1:3,1:3,me) = subFp0 + constitutive_mech_Fi(ph)%data(1:3,1:3,me) = subFi0 + crystallite_S (1:3,1:3,co,ip,el) = crystallite_S0 (1:3,1:3,co,ip,el) + if (subStep < 1.0_pReal) then ! actual (not initial) cutback + crystallite_Lp (1:3,1:3,co,ip,el) = subLp0 + constitutive_mech_Li(ph)%data(1:3,1:3,me) = subLi0 endif - plasticState(ph)%state(:,me) = plasticState(ph)%subState0(:,me) + plasticState(ph)%state(:,me) = subState0 do so = 1, phase_Nsources(ph) sourceState(ph)%p(so)%state(:,me) = sourceState(ph)%p(so)%subState0(:,me) enddo @@ -1565,8 +1578,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) + subStep * (crystallite_F(1:3,1:3,co,ip,el) - crystallite_partitionedF0(1:3,1:3,co,ip,el)) crystallite_Fe(1:3,1:3,co,ip,el) = matmul(subF,math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) - crystallite_subdt(co,ip,el) = subStep * dt - converged_ = .not. integrateState(subF0,subF,subStep * dt,co,ip,el) + converged_ = .not. integrateState(subF0,subF,subFp0,subFi0,subState0(1:sizeDotState),subStep * dt,co,ip,el) converged_ = converged_ .and. .not. integrateSourceState(subStep * dt,co,ip,el) endif From 5f569b14121f49d421670c394dbaf2e5d3cfdae8 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 00:39:23 +0100 Subject: [PATCH 038/352] explicit arguments instead of global variables --- src/constitutive.f90 | 13 +++++-------- src/constitutive_mech.f90 | 1 - src/homogenization.f90 | 5 +++-- src/homogenization_mech.f90 | 12 +++++++----- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 808870059..fe09b3662 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -42,8 +42,7 @@ module constitutive KINEMATICS_SLIPPLANE_OPENING_ID, & KINEMATICS_THERMAL_EXPANSION_ID end enum - real(pReal), dimension(:,:,:), allocatable :: & - crystallite_subdt !< substepped time increment of each grain + type(rotation), dimension(:,:,:), allocatable :: & crystallite_orientation !< current orientation real(pReal), dimension(:,:,:,:,:), allocatable :: & @@ -874,7 +873,6 @@ subroutine crystallite_init crystallite_Fe,crystallite_Lp, & source = crystallite_F) - allocate(crystallite_subdt(cMax,iMax,eMax),source=0.0_pReal) allocate(crystallite_orientation(cMax,iMax,eMax)) @@ -1103,11 +1101,11 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) lhs_3333 = 0.0_pReal; rhs_3333 = 0.0_pReal do o=1,3; do p=1,3 lhs_3333(1:3,1:3,o,p) = lhs_3333(1:3,1:3,o,p) & - + crystallite_subdt(co,ip,el)*matmul(invSubFi0,dLidFi(1:3,1:3,o,p)) + + matmul(invSubFi0,dLidFi(1:3,1:3,o,p)) * dt lhs_3333(1:3,o,1:3,p) = lhs_3333(1:3,o,1:3,p) & + invFi*invFi(p,o) rhs_3333(1:3,1:3,o,p) = rhs_3333(1:3,1:3,o,p) & - - crystallite_subdt(co,ip,el)*matmul(invSubFi0,dLidS(1:3,1:3,o,p)) + - matmul(invSubFi0,dLidS(1:3,1:3,o,p)) * dt enddo; enddo call math_invert(temp_99,error,math_3333to99(lhs_3333)) if (error) then @@ -1136,7 +1134,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) temp_3333(1:3,1:3,p,o) = matmul(matmul(temp_33_2,dLpdS(1:3,1:3,p,o)), invFi) & + matmul(temp_33_3,dLidS(1:3,1:3,p,o)) enddo; enddo - lhs_3333 = crystallite_subdt(co,ip,el)*math_mul3333xx3333(dSdFe,temp_3333) & + lhs_3333 = math_mul3333xx3333(dSdFe,temp_3333) * dt & + math_mul3333xx3333(dSdFi,dFidS) call math_invert(temp_99,error,math_eye(9)+math_3333to99(lhs_3333)) @@ -1152,8 +1150,7 @@ function crystallite_stressTangent(co,ip,el) result(dPdF) ! calculate dFpinvdF temp_3333 = math_mul3333xx3333(dLpdS,dSdF) do o=1,3; do p=1,3 - dFpinvdF(1:3,1:3,p,o) = -crystallite_subdt(co,ip,el) & - * matmul(invSubFp0, matmul(temp_3333(1:3,1:3,p,o),invFi)) + dFpinvdF(1:3,1:3,p,o) = - matmul(invSubFp0, matmul(temp_3333(1:3,1:3,p,o),invFi)) * dt enddo; enddo !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 11ced6f40..7c819c480 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1526,7 +1526,6 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) todo = .true. converged_ = .false. ! pretend failed step of 1/subStepSizeCryst - crystallite_subdt(co,ip,el) = dt todo = .true. NiterationCrystallite = 0 cutbackLooping: do while (todo) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 52553b57b..d61fa57e8 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -63,7 +63,8 @@ module homogenization el !< element number end subroutine mech_partition - module subroutine mech_homogenize(ip,el) + module subroutine mech_homogenize(dt,ip,el) + real(pReal), intent(in) :: dt integer, intent(in) :: & ip, & !< integration point el !< element number @@ -257,7 +258,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE do co = 1, myNgrains call crystallite_orientations(co,ip,el) enddo - call mech_homogenize(ip,el) + call mech_homogenize(dt,ip,el) enddo IpLooping3 enddo elementLooping3 !$OMP END PARALLEL DO diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index 641e960fd..e3e9cfb3e 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -138,11 +138,13 @@ end subroutine mech_partition !-------------------------------------------------------------------------------------------------- !> @brief Average P and dPdF from the individual constituents. !-------------------------------------------------------------------------------------------------- -module subroutine mech_homogenize(ip,el) +module subroutine mech_homogenize(dt,ip,el) + real(pReal), intent(in) :: dt integer, intent(in) :: & ip, & !< integration point el !< element number + integer :: co,ce real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) @@ -152,11 +154,11 @@ module subroutine mech_homogenize(ip,el) case (HOMOGENIZATION_NONE_ID) chosenHomogenization homogenization_P(1:3,1:3,ce) = crystallite_P(1:3,1:3,1,ip,el) - homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = crystallite_stressTangent(1,ip,el) + homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = crystallite_stressTangent(dt,1,ip,el) case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = crystallite_stressTangent(co,ip,el) + dPdFs(:,:,:,:,co) = crystallite_stressTangent(dt,co,ip,el) enddo call mech_isostrain_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & @@ -167,7 +169,7 @@ module subroutine mech_homogenize(ip,el) case (HOMOGENIZATION_RGC_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = crystallite_stressTangent(co,ip,el) + dPdFs(:,:,:,:,co) = crystallite_stressTangent(dt,co,ip,el) enddo call mech_RGC_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & @@ -202,7 +204,7 @@ module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) if (homogenization_type(material_homogenizationAt(el)) == HOMOGENIZATION_RGC_ID) then do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = crystallite_stressTangent(co,ip,el) + dPdFs(:,:,:,:,co) = crystallite_stressTangent(subdt,co,ip,el) enddo doneAndHappy = & mech_RGC_updateState(crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & From 6bba7a509aa85f773c96703c21b258a9d1740192 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 00:44:42 +0100 Subject: [PATCH 039/352] polishing --- src/constitutive.f90 | 5 +++-- src/constitutive_mech.f90 | 19 ++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index fe09b3662..f3f731cc6 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -1049,13 +1049,14 @@ end subroutine constitutive_windForward !-------------------------------------------------------------------------------------------------- !> @brief Calculate tangent (dPdF). !-------------------------------------------------------------------------------------------------- -function crystallite_stressTangent(co,ip,el) result(dPdF) +function crystallite_stressTangent(dt,co,ip,el) result(dPdF) - real(pReal), dimension(3,3,3,3) :: dPdF + real(pReal), intent(in) :: dt integer, intent(in) :: & co, & !< counter in constituent loop ip, & !< counter in integration point loop el !< counter in element loop + real(pReal), dimension(3,3,3,3) :: dPdF integer :: & o, & diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 7c819c480..31f8d40cc 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1492,7 +1492,6 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) real(pReal) :: & formerSubStep integer :: & - NiterationCrystallite, & ! number of iterations in crystallite loop so, ph, me, sizeDotState logical :: todo real(pReal) :: subFrac,subStep @@ -1527,12 +1526,8 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) converged_ = .false. ! pretend failed step of 1/subStepSizeCryst todo = .true. - NiterationCrystallite = 0 cutbackLooping: do while (todo) - NiterationCrystallite = NiterationCrystallite + 1 -!-------------------------------------------------------------------------------------------------- -! wind forward if (converged_) then formerSubStep = subStep subFrac = subFrac + subStep @@ -1596,19 +1591,21 @@ module subroutine mech_restore(ip,el,includeL) el !< element number logical, intent(in) :: & includeL !< protect agains fake cutback + integer :: & - co, p, m !< constituent number + co, ph, me + do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - p = material_phaseAt(co,el) - m = material_phaseMemberAt(co,ip,el) + ph = material_phaseAt(co,el) + me = material_phaseMemberAt(co,ip,el) if (includeL) then crystallite_Lp(1:3,1:3,co,ip,el) = crystallite_partitionedLp0(1:3,1:3,co,ip,el) - constitutive_mech_Li(p)%data(1:3,1:3,m) = constitutive_mech_partitionedLi0(p)%data(1:3,1:3,m) + constitutive_mech_Li(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) endif ! maybe protecting everything from overwriting makes more sense - constitutive_mech_Fp(p)%data(1:3,1:3,m) = constitutive_mech_partitionedFp0(p)%data(1:3,1:3,m) - constitutive_mech_Fi(p)%data(1:3,1:3,m) = constitutive_mech_partitionedFi0(p)%data(1:3,1:3,m) + constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) + constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) crystallite_S (1:3,1:3,co,ip,el) = crystallite_partitionedS0 (1:3,1:3,co,ip,el) plasticState (material_phaseAt(co,el))%state( :,material_phasememberAt(co,ip,el)) = & From 1b85dbea80521ab7e632c900447f893f8b478d98 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 06:14:39 +0100 Subject: [PATCH 040/352] polishing --- src/constitutive.f90 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index f3f731cc6..5ed5bbdb9 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -1084,8 +1084,8 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) me = material_phaseMemberAt(co,ip,el) call constitutive_hooke_SandItsTangents(devNull,dSdFe,dSdFi, & - crystallite_Fe(1:3,1:3,co,ip,el), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) + crystallite_Fe(1:3,1:3,co,ip,el), & + constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) call constitutive_LiAndItsTangents(devNull,dLidS,dLidFi, & crystallite_S (1:3,1:3,co,ip,el), & constitutive_mech_Fi(ph)%data(1:3,1:3,me), & @@ -1120,8 +1120,8 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) endif call constitutive_plastic_LpAndItsTangents(devNull,dLpdS,dLpdFi, & - crystallite_S (1:3,1:3,co,ip,el), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) + crystallite_S (1:3,1:3,co,ip,el), & + constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) dLpdS = math_mul3333xx3333(dLpdFi,dFidS) + dLpdS !-------------------------------------------------------------------------------------------------- @@ -1166,10 +1166,8 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) enddo do o=1,3; do p=1,3 dPdF(1:3,1:3,p,o) = dPdF(1:3,1:3,p,o) & - + matmul(matmul(crystallite_F(1:3,1:3,co,ip,el), & - dFpinvdF(1:3,1:3,p,o)),temp_33_1) & - + matmul(matmul(temp_33_2,dSdF(1:3,1:3,p,o)), & - transpose(invFp)) & + + matmul(matmul(crystallite_F(1:3,1:3,co,ip,el),dFpinvdF(1:3,1:3,p,o)),temp_33_1) & + + matmul(matmul(temp_33_2,dSdF(1:3,1:3,p,o)),transpose(invFp)) & + matmul(temp_33_3,transpose(dFpinvdF(1:3,1:3,p,o))) enddo; enddo From 7992ef474e06673dd208613e75ef13ac87459022 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 07:20:37 +0100 Subject: [PATCH 041/352] preparing for non-global variables --- src/constitutive.f90 | 27 +++++++++++++++++++++++---- src/constitutive_thermal.f90 | 15 +++++++-------- src/thermal_conduction.f90 | 2 +- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 5ed5bbdb9..584bae3aa 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -235,15 +235,12 @@ module constitutive dPhiDot_dPhi end subroutine constitutive_damage_getRateAndItsTangents - module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, S, Lp, ip, el) + module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, ip, el) integer, intent(in) :: & ip, & !< integration point number el !< element number real(pReal), intent(in) :: & T - real(pReal), intent(in), dimension(:,:,:,:,:) :: & - S, & !< current 2nd Piola Kitchoff stress vector - Lp !< plastic velocity gradient real(pReal), intent(inout) :: & TDot, & dTDot_dT @@ -392,6 +389,8 @@ module constitutive crystallite_push33ToRef, & crystallite_restartWrite, & integrateSourceState, & + constitutive_mech_getLp, & + constitutive_mech_getS, & crystallite_restartRead, & constitutive_initializeRestorationPoints, & constitutive_windForward, & @@ -1427,4 +1426,24 @@ subroutine crystallite_restartRead end subroutine crystallite_restartRead +! getter for non-mech (e.g. thermal) +function constitutive_mech_getS(co,ip,el) result(S) + + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: S + + S = crystallite_S(1:3,1:3,co,ip,el) + +end function constitutive_mech_getS + +! getter for non-mech (e.g. thermal) +function constitutive_mech_getLp(co,ip,el) result(Lp) + + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: Lp + + Lp = crystallite_S(1:3,1:3,co,ip,el) + +end function constitutive_mech_getLp + end module constitutive diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index a7d5d3259..1e204a197 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -68,15 +68,13 @@ end subroutine thermal_init !---------------------------------------------------------------------------------------------- !< @brief calculates thermal dissipation rate !---------------------------------------------------------------------------------------------- -module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, S, Lp, ip, el) +module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, ip, el) + integer, intent(in) :: & ip, & !< integration point number el !< element number real(pReal), intent(in) :: & - T - real(pReal), intent(in), dimension(:,:,:,:,:) :: & - S, & !< current 2nd Piola Kirchhoff stress - Lp !< plastic velocity gradient + T !< plastic velocity gradient real(pReal), intent(inout) :: & TDot, & dTDot_dT @@ -84,6 +82,7 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, real(pReal) :: & my_Tdot, & my_dTdot_dT + real(pReal), dimension(3,3) :: Lp, S integer :: & phase, & homog, & @@ -101,10 +100,10 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, do source = 1, phase_Nsources(phase) select case(phase_source(source,phase)) case (SOURCE_thermal_dissipation_ID) + Lp = constitutive_mech_getLp(grain,ip,el) + S = constitutive_mech_getS(grain,ip,el) call source_thermal_dissipation_getRateAndItsTangent(my_Tdot, my_dTdot_dT, & - S(1:3,1:3,grain,ip,el), & - Lp(1:3,1:3,grain,ip,el), & - phase) + S, Lp, phase) case (SOURCE_thermal_externalheat_ID) call source_thermal_externalheat_getRateAndItsTangent(my_Tdot, my_dTdot_dT, & diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index d30e50677..09997162c 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -94,7 +94,7 @@ subroutine thermal_conduction_getSourceAndItsTangent(Tdot, dTdot_dT, T, ip, el) dTdot_dT = 0.0_pReal homog = material_homogenizationAt(el) - call constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, crystallite_S,crystallite_Lp ,ip, el) + call constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, ip, el) Tdot = Tdot/real(homogenization_Nconstituents(homog),pReal) dTdot_dT = dTdot_dT/real(homogenization_Nconstituents(homog),pReal) From 22575b15ffecca26af8f8fd9eaa0c87b3b767179 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 07:34:25 +0100 Subject: [PATCH 042/352] new (ph,me)-based data layout --- src/constitutive.f90 | 40 +++++++++++++++++++++------------------ src/constitutive_mech.f90 | 20 +++++++++++--------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 584bae3aa..9d756f535 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -48,13 +48,10 @@ module constitutive real(pReal), dimension(:,:,:,:,:), allocatable :: & crystallite_F0, & !< def grad at start of FE inc crystallite_Fe, & !< current "elastic" def grad (end of converged time step) - crystallite_Lp0, & !< plastic velocitiy grad at start of FE inc - crystallite_partitionedLp0, & !< plastic velocity grad at start of homog inc crystallite_S0, & !< 2nd Piola-Kirchhoff stress vector at start of FE inc crystallite_partitionedS0 !< 2nd Piola-Kirchhoff stress vector at start of homog inc real(pReal), dimension(:,:,:,:,:), allocatable, public :: & crystallite_P, & !< 1st Piola-Kirchhoff stress per grain - crystallite_Lp, & !< current plastic velocitiy grad (end of converged time step) crystallite_S, & !< current 2nd Piola-Kirchhoff stress vector (end of converged time step) crystallite_partitionedF0, & !< def grad at start of homog inc crystallite_F !< def grad to be reached at end of homog inc @@ -65,14 +62,17 @@ module constitutive type(tTensorContainer), dimension(:), allocatable :: & constitutive_mech_Fi, & - constitutive_mech_Fi0, & - constitutive_mech_partitionedFi0, & - constitutive_mech_Li, & - constitutive_mech_Li0, & - constitutive_mech_partitionedLi0, & constitutive_mech_Fp, & + constitutive_mech_Li, & + constitutive_mech_Lp, & + constitutive_mech_Fi0, & constitutive_mech_Fp0, & - constitutive_mech_partitionedFp0 + constitutive_mech_Li0, & + constitutive_mech_Lp0, & + constitutive_mech_partitionedFi0, & + constitutive_mech_partitionedFp0, & + constitutive_mech_partitionedLi0, & + constitutive_mech_partitionedLp0 type :: tNumerics @@ -790,7 +790,6 @@ subroutine constitutive_forward integer :: i, j crystallite_F0 = crystallite_F - crystallite_Lp0 = crystallite_Lp crystallite_S0 = crystallite_S call constitutive_mech_forward() @@ -864,12 +863,11 @@ subroutine crystallite_init allocate(crystallite_F(3,3,cMax,iMax,eMax),source=0.0_pReal) allocate(crystallite_S0, & - crystallite_F0,crystallite_Lp0, & + crystallite_F0, & crystallite_partitionedS0, & crystallite_partitionedF0,& - crystallite_partitionedLp0, & crystallite_S,crystallite_P, & - crystallite_Fe,crystallite_Lp, & + crystallite_Fe, & source = crystallite_F) allocate(crystallite_orientation(cMax,iMax,eMax)) @@ -917,6 +915,9 @@ subroutine crystallite_init allocate(constitutive_mech_Li(phases%length)) allocate(constitutive_mech_Li0(phases%length)) allocate(constitutive_mech_partitionedLi0(phases%length)) + allocate(constitutive_mech_partitionedLp0(phases%length)) + allocate(constitutive_mech_Lp0(phases%length)) + allocate(constitutive_mech_Lp(phases%length)) do ph = 1, phases%length Nconstituents = count(material_phaseAt == ph) * discretization_nIPs @@ -929,6 +930,9 @@ subroutine crystallite_init allocate(constitutive_mech_Li(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Li0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_partitionedLi0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_partitionedLp0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Lp0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Lp(ph)%data(3,3,Nconstituents)) do so = 1, phase_Nsources(ph) allocate(sourceState(ph)%p(so)%subState0,source=sourceState(ph)%p(so)%state0) ! ToDo: hack enddo @@ -1000,7 +1004,6 @@ subroutine constitutive_initializeRestorationPoints(ip,el) do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - crystallite_partitionedLp0(1:3,1:3,co,ip,el) = crystallite_Lp0(1:3,1:3,co,ip,el) crystallite_partitionedF0(1:3,1:3,co,ip,el) = crystallite_F0(1:3,1:3,co,ip,el) crystallite_partitionedS0(1:3,1:3,co,ip,el) = crystallite_S0(1:3,1:3,co,ip,el) @@ -1033,7 +1036,6 @@ subroutine constitutive_windForward(ip,el) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) crystallite_partitionedF0 (1:3,1:3,co,ip,el) = crystallite_F (1:3,1:3,co,ip,el) - crystallite_partitionedLp0(1:3,1:3,co,ip,el) = crystallite_Lp(1:3,1:3,co,ip,el) crystallite_partitionedS0 (1:3,1:3,co,ip,el) = crystallite_S (1:3,1:3,co,ip,el) call constitutive_mech_windForward(ph,me) @@ -1354,7 +1356,6 @@ subroutine crystallite_restartWrite fileHandle = HDF5_openFile(fileName,'a') call HDF5_write(fileHandle,crystallite_F,'F') - call HDF5_write(fileHandle,crystallite_Lp, 'L_p') call HDF5_write(fileHandle,crystallite_S, 'S') groupHandle = HDF5_addGroup(fileHandle,'phase') @@ -1365,6 +1366,8 @@ subroutine crystallite_restartWrite call HDF5_write(groupHandle,constitutive_mech_Fi(ph)%data,datasetName) write(datasetName,'(i0,a)') ph,'_L_i' call HDF5_write(groupHandle,constitutive_mech_Li(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_L_p' + call HDF5_write(groupHandle,constitutive_mech_Lp(ph)%data,datasetName) write(datasetName,'(i0,a)') ph,'_F_p' call HDF5_write(groupHandle,constitutive_mech_Fp(ph)%data,datasetName) enddo @@ -1398,7 +1401,6 @@ subroutine crystallite_restartRead fileHandle = HDF5_openFile(fileName) call HDF5_read(fileHandle,crystallite_F0, 'F') - call HDF5_read(fileHandle,crystallite_Lp0,'L_p') call HDF5_read(fileHandle,crystallite_S0, 'S') groupHandle = HDF5_openGroup(fileHandle,'phase') @@ -1409,6 +1411,8 @@ subroutine crystallite_restartRead call HDF5_read(groupHandle,constitutive_mech_Fi0(ph)%data,datasetName) write(datasetName,'(i0,a)') ph,'_L_i' call HDF5_read(groupHandle,constitutive_mech_Li0(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_L_p' + call HDF5_read(groupHandle,constitutive_mech_Lp0(ph)%data,datasetName) write(datasetName,'(i0,a)') ph,'_F_p' call HDF5_read(groupHandle,constitutive_mech_Fp0(ph)%data,datasetName) enddo @@ -1442,7 +1446,7 @@ function constitutive_mech_getLp(co,ip,el) result(Lp) integer, intent(in) :: co, ip, el real(pReal), dimension(3,3) :: Lp - Lp = crystallite_S(1:3,1:3,co,ip,el) + Lp = constitutive_mech_Lp(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) end function constitutive_mech_getLp diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 31f8d40cc..a6d1b76b6 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -805,7 +805,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - Lpguess = crystallite_Lp(1:3,1:3,co,ip,el) ! take as first guess + Lpguess = constitutive_mech_Lp(ph)%data(1:3,1:3,me) ! take as first guess Liguess = constitutive_mech_Li(ph)%data(1:3,1:3,me) ! take as first guess call math_invert33(invFp_current,devNull,error,subFp0) @@ -937,9 +937,9 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) crystallite_P (1:3,1:3,co,ip,el) = matmul(matmul(F,invFp_new),matmul(S,transpose(invFp_new))) crystallite_S (1:3,1:3,co,ip,el) = S - crystallite_Lp (1:3,1:3,co,ip,el) = Lpguess + constitutive_mech_Lp(ph)%data(1:3,1:3,me) = Lpguess constitutive_mech_Li(ph)%data(1:3,1:3,me) = Liguess - constitutive_mech_Fp(ph)%data(1:3,1:3,me) = Fp_new / math_det33(Fp_new)**(1.0_pReal/3.0_pReal) ! regularize + constitutive_mech_Fp(ph)%data(1:3,1:3,me) = Fp_new / math_det33(Fp_new)**(1.0_pReal/3.0_pReal) ! regularize constitutive_mech_Fi(ph)%data(1:3,1:3,me) = Fi_new crystallite_Fe (1:3,1:3,co,ip,el) = matmul(matmul(F,invFp_new),invFi_new) broken = .false. @@ -1307,8 +1307,7 @@ subroutine crystallite_results(group,ph) call results_writeDataset(group//'/mechanics/',constitutive_mech_Fi(ph)%data,output_constituent(ph)%label(ou),& 'inelastic deformation gradient','1') case('L_p') - selected_tensors = select_tensors(crystallite_Lp,ph) - call results_writeDataset(group//'/mechanics/',selected_tensors,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_Lp(ph)%data,output_constituent(ph)%label(ou),& 'plastic velocity gradient','1/s') case('L_i') call results_writeDataset(group//'/mechanics/',constitutive_mech_Li(ph)%data,output_constituent(ph)%label(ou),& @@ -1413,6 +1412,7 @@ module subroutine mech_initializeRestorationPoints(ph,me) constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) = constitutive_mech_Li0(ph)%data(1:3,1:3,me) + constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp0(ph)%data(1:3,1:3,me) plasticState(ph)%partitionedState0(:,me) = plasticState(ph)%state0(:,me) end subroutine mech_initializeRestorationPoints @@ -1429,6 +1429,7 @@ module subroutine constitutive_mech_windForward(ph,me) constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp(ph)%data(1:3,1:3,me) constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) = constitutive_mech_Li(ph)%data(1:3,1:3,me) + constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp(ph)%data(1:3,1:3,me) plasticState(ph)%partitionedState0(:,me) = plasticState(ph)%state(:,me) @@ -1449,6 +1450,7 @@ module subroutine constitutive_mech_forward() constitutive_mech_Fi0(ph) = constitutive_mech_Fi(ph) constitutive_mech_Fp0(ph) = constitutive_mech_Fp(ph) constitutive_mech_Li0(ph) = constitutive_mech_Li(ph) + constitutive_mech_Lp0(ph) = constitutive_mech_Lp(ph) enddo end subroutine constitutive_mech_forward @@ -1510,7 +1512,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) sizeDotState = plasticState(ph)%sizeDotState subLi0 = constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) - subLp0 = crystallite_partitionedLp0(1:3,1:3,co,ip,el) + subLp0 = constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) subState0 = plasticState(ph)%partitionedState0(:,me) @@ -1537,7 +1539,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) if (todo) then subF0 = subF - subLp0 = crystallite_Lp (1:3,1:3,co,ip,el) + subLp0 = constitutive_mech_Lp(ph)%data(1:3,1:3,me) subLi0 = constitutive_mech_Li(ph)%data(1:3,1:3,me) subFp0 = constitutive_mech_Fp(ph)%data(1:3,1:3,me) subFi0 = constitutive_mech_Fi(ph)%data(1:3,1:3,me) @@ -1554,7 +1556,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) constitutive_mech_Fi(ph)%data(1:3,1:3,me) = subFi0 crystallite_S (1:3,1:3,co,ip,el) = crystallite_S0 (1:3,1:3,co,ip,el) if (subStep < 1.0_pReal) then ! actual (not initial) cutback - crystallite_Lp (1:3,1:3,co,ip,el) = subLp0 + constitutive_mech_Lp(ph)%data(1:3,1:3,me) = subLp0 constitutive_mech_Li(ph)%data(1:3,1:3,me) = subLi0 endif plasticState(ph)%state(:,me) = subState0 @@ -1600,7 +1602,7 @@ module subroutine mech_restore(ip,el,includeL) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) if (includeL) then - crystallite_Lp(1:3,1:3,co,ip,el) = crystallite_partitionedLp0(1:3,1:3,co,ip,el) + constitutive_mech_Lp(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) constitutive_mech_Li(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) endif ! maybe protecting everything from overwriting makes more sense From 0d0a81a0165fd471c50e486b24cb90b529e7c0c5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 08:08:14 +0100 Subject: [PATCH 043/352] new structure --- src/constitutive.f90 | 18 ++++++++++-------- src/constitutive_mech.f90 | 9 ++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 9d756f535..4b87c72e3 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -47,7 +47,6 @@ module constitutive crystallite_orientation !< current orientation real(pReal), dimension(:,:,:,:,:), allocatable :: & crystallite_F0, & !< def grad at start of FE inc - crystallite_Fe, & !< current "elastic" def grad (end of converged time step) crystallite_S0, & !< 2nd Piola-Kirchhoff stress vector at start of FE inc crystallite_partitionedS0 !< 2nd Piola-Kirchhoff stress vector at start of homog inc real(pReal), dimension(:,:,:,:,:), allocatable, public :: & @@ -61,6 +60,7 @@ module constitutive end type type(tTensorContainer), dimension(:), allocatable :: & + constitutive_mech_Fe, & constitutive_mech_Fi, & constitutive_mech_Fp, & constitutive_mech_Li, & @@ -867,7 +867,6 @@ subroutine crystallite_init crystallite_partitionedS0, & crystallite_partitionedF0,& crystallite_S,crystallite_P, & - crystallite_Fe, & source = crystallite_F) allocate(crystallite_orientation(cMax,iMax,eMax)) @@ -906,6 +905,7 @@ subroutine crystallite_init phases => config_material%get('phase') + allocate(constitutive_mech_Fe(phases%length)) allocate(constitutive_mech_Fi(phases%length)) allocate(constitutive_mech_Fi0(phases%length)) allocate(constitutive_mech_partitionedFi0(phases%length)) @@ -922,6 +922,7 @@ subroutine crystallite_init Nconstituents = count(material_phaseAt == ph) * discretization_nIPs allocate(constitutive_mech_Fi(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Fe(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Fi0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_partitionedFi0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Fp(ph)%data(3,3,Nconstituents)) @@ -956,9 +957,9 @@ subroutine crystallite_init crystallite_F0(1:3,1:3,co,ip,el) = math_I3 - crystallite_Fe(1:3,1:3,co,ip,el) = math_inv33(matmul(constitutive_mech_Fi0(ph)%data(1:3,1:3,me), & - constitutive_mech_Fp0(ph)%data(1:3,1:3,me))) ! assuming that euler angles are given in internal strain free configuration - constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) + constitutive_mech_Fe(ph)%data(1:3,1:3,me) = math_inv33(matmul(constitutive_mech_Fi0(ph)%data(1:3,1:3,me), & + constitutive_mech_Fp0(ph)%data(1:3,1:3,me))) ! assuming that euler angles are given in internal strain free configuration + constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) @@ -1085,7 +1086,7 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) me = material_phaseMemberAt(co,ip,el) call constitutive_hooke_SandItsTangents(devNull,dSdFe,dSdFi, & - crystallite_Fe(1:3,1:3,co,ip,el), & + constitutive_mech_Fp(ph)%data(1:3,1:3,me), & constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) call constitutive_LiAndItsTangents(devNull,dLidS,dLidFi, & crystallite_S (1:3,1:3,co,ip,el), & @@ -1186,7 +1187,8 @@ subroutine crystallite_orientations(co,ip,el) el !< counter in element loop - call crystallite_orientation(co,ip,el)%fromMatrix(transpose(math_rotationalPart(crystallite_Fe(1:3,1:3,co,ip,el)))) + call crystallite_orientation(co,ip,el)%fromMatrix(transpose(math_rotationalPart(& + constitutive_mech_Fe(material_phaseAt(ip,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el))))) if (plasticState(material_phaseAt(1,el))%nonlocal) & call plastic_nonlocal_updateCompatibility(crystallite_orientation, & @@ -1289,7 +1291,7 @@ function integrateSourceState(dt,co,ip,el) result(broken) enddo if(converged_) then - broken = constitutive_damage_deltaState(crystallite_Fe(1:3,1:3,co,ip,el),co,ip,el,ph,me) + broken = constitutive_damage_deltaState(constitutive_mech_Fe(ph)%data(1:3,1:3,me),co,ip,el,ph,me) exit iteration endif diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index a6d1b76b6..06afe64fb 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -941,7 +941,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) constitutive_mech_Li(ph)%data(1:3,1:3,me) = Liguess constitutive_mech_Fp(ph)%data(1:3,1:3,me) = Fp_new / math_det33(Fp_new)**(1.0_pReal/3.0_pReal) ! regularize constitutive_mech_Fi(ph)%data(1:3,1:3,me) = Fi_new - crystallite_Fe (1:3,1:3,co,ip,el) = matmul(matmul(F,invFp_new),invFi_new) + constitutive_mech_Fe(ph)%data(1:3,1:3,me)= matmul(matmul(F,invFp_new),invFi_new) broken = .false. end function integrateStress @@ -1297,8 +1297,7 @@ subroutine crystallite_results(group,ph) call results_writeDataset(group//'/mechanics/',selected_tensors,output_constituent(ph)%label(ou),& 'deformation gradient','1') case('F_e') - selected_tensors = select_tensors(crystallite_Fe,ph) - call results_writeDataset(group//'/mechanics/',selected_tensors,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_Fe(ph)%data,output_constituent(ph)%label(ou),& 'elastic deformation gradient','1') case('F_p') call results_writeDataset(group//'/mechanics/',constitutive_mech_Fp(ph)%data,output_constituent(ph)%label(ou),& @@ -1572,8 +1571,8 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) if (todo) then subF = subF0 & + subStep * (crystallite_F(1:3,1:3,co,ip,el) - crystallite_partitionedF0(1:3,1:3,co,ip,el)) - crystallite_Fe(1:3,1:3,co,ip,el) = matmul(subF,math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & - constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) + constitutive_mech_Fe(ph)%data(1:3,1:3,me) = matmul(subF,math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & + constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) converged_ = .not. integrateState(subF0,subF,subFp0,subFi0,subState0(1:sizeDotState),subStep * dt,co,ip,el) converged_ = converged_ .and. .not. integrateSourceState(subStep * dt,co,ip,el) endif From e19ced830bc293ae81663eca778cc3e0606d1158 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 09:26:24 +0100 Subject: [PATCH 044/352] S and related quantities in new data layout --- src/constitutive.f90 | 62 +++++++++++++++++++++------------------ src/constitutive_mech.f90 | 43 +++++++++++++-------------- 2 files changed, 54 insertions(+), 51 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 4b87c72e3..37726ce2b 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -46,12 +46,9 @@ module constitutive type(rotation), dimension(:,:,:), allocatable :: & crystallite_orientation !< current orientation real(pReal), dimension(:,:,:,:,:), allocatable :: & - crystallite_F0, & !< def grad at start of FE inc - crystallite_S0, & !< 2nd Piola-Kirchhoff stress vector at start of FE inc - crystallite_partitionedS0 !< 2nd Piola-Kirchhoff stress vector at start of homog inc + crystallite_F0 !< def grad at start of FE inc real(pReal), dimension(:,:,:,:,:), allocatable, public :: & crystallite_P, & !< 1st Piola-Kirchhoff stress per grain - crystallite_S, & !< current 2nd Piola-Kirchhoff stress vector (end of converged time step) crystallite_partitionedF0, & !< def grad at start of homog inc crystallite_F !< def grad to be reached at end of homog inc @@ -60,19 +57,25 @@ module constitutive end type type(tTensorContainer), dimension(:), allocatable :: & + ! current value constitutive_mech_Fe, & constitutive_mech_Fi, & constitutive_mech_Fp, & constitutive_mech_Li, & constitutive_mech_Lp, & + constitutive_mech_S, & + ! converged value at end of last solver increment constitutive_mech_Fi0, & constitutive_mech_Fp0, & constitutive_mech_Li0, & constitutive_mech_Lp0, & + constitutive_mech_S0, & + ! converged value at end of last homogenization increment (RGC only) constitutive_mech_partitionedFi0, & constitutive_mech_partitionedFp0, & constitutive_mech_partitionedLi0, & - constitutive_mech_partitionedLp0 + constitutive_mech_partitionedLp0, & + constitutive_mech_partitionedS0 type :: tNumerics @@ -611,7 +614,7 @@ end subroutine constitutive_LiAndItsTangents !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the rate of change of microstructure !-------------------------------------------------------------------------------------------------- -function constitutive_damage_collectDotState(S, co, ip, el,ph,of) result(broken) +function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) integer, intent(in) :: & co, & !< component-ID of integration point @@ -619,8 +622,6 @@ function constitutive_damage_collectDotState(S, co, ip, el,ph,of) result(broken) el, & !< element ph, & of - real(pReal), intent(in), dimension(3,3) :: & - S !< 2nd Piola Kirchhoff stress (vector notation) integer :: & so !< counter in source loop logical :: broken @@ -633,7 +634,7 @@ function constitutive_damage_collectDotState(S, co, ip, el,ph,of) result(broken) sourceType: select case (phase_source(so,ph)) case (SOURCE_damage_anisoBrittle_ID) sourceType - call source_damage_anisoBrittle_dotState(S, co, ip, el) ! correct stress? + call source_damage_anisoBrittle_dotState(constitutive_mech_getS(co,ip,el), co, ip, el) ! correct stress? case (SOURCE_damage_isoDuctile_ID) sourceType call source_damage_isoDuctile_dotState(co, ip, el) @@ -790,7 +791,6 @@ subroutine constitutive_forward integer :: i, j crystallite_F0 = crystallite_F - crystallite_S0 = crystallite_S call constitutive_mech_forward() @@ -860,14 +860,12 @@ subroutine crystallite_init iMax = discretization_nIPs eMax = discretization_Nelems - allocate(crystallite_F(3,3,cMax,iMax,eMax),source=0.0_pReal) + allocate(crystallite_P(3,3,cMax,iMax,eMax),source=0.0_pReal) - allocate(crystallite_S0, & - crystallite_F0, & - crystallite_partitionedS0, & + allocate(crystallite_F0, & crystallite_partitionedF0,& - crystallite_S,crystallite_P, & - source = crystallite_F) + crystallite_F, & + source = crystallite_P) allocate(crystallite_orientation(cMax,iMax,eMax)) @@ -918,6 +916,9 @@ subroutine crystallite_init allocate(constitutive_mech_partitionedLp0(phases%length)) allocate(constitutive_mech_Lp0(phases%length)) allocate(constitutive_mech_Lp(phases%length)) + allocate(constitutive_mech_S(phases%length)) + allocate(constitutive_mech_S0(phases%length)) + allocate(constitutive_mech_partitionedS0(phases%length)) do ph = 1, phases%length Nconstituents = count(material_phaseAt == ph) * discretization_nIPs @@ -934,6 +935,9 @@ subroutine crystallite_init allocate(constitutive_mech_partitionedLp0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Lp0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Lp(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_S(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_S0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_partitionedS0(ph)%data(3,3,Nconstituents)) do so = 1, phase_Nsources(ph) allocate(sourceState(ph)%p(so)%subState0,source=sourceState(ph)%p(so)%state0) ! ToDo: hack enddo @@ -1006,7 +1010,6 @@ subroutine constitutive_initializeRestorationPoints(ip,el) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) crystallite_partitionedF0(1:3,1:3,co,ip,el) = crystallite_F0(1:3,1:3,co,ip,el) - crystallite_partitionedS0(1:3,1:3,co,ip,el) = crystallite_S0(1:3,1:3,co,ip,el) call mech_initializeRestorationPoints(ph,me) @@ -1037,7 +1040,6 @@ subroutine constitutive_windForward(ip,el) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) crystallite_partitionedF0 (1:3,1:3,co,ip,el) = crystallite_F (1:3,1:3,co,ip,el) - crystallite_partitionedS0 (1:3,1:3,co,ip,el) = crystallite_S (1:3,1:3,co,ip,el) call constitutive_mech_windForward(ph,me) do so = 1, phase_Nsources(material_phaseAt(co,el)) @@ -1086,10 +1088,10 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) me = material_phaseMemberAt(co,ip,el) call constitutive_hooke_SandItsTangents(devNull,dSdFe,dSdFi, & - constitutive_mech_Fp(ph)%data(1:3,1:3,me), & + constitutive_mech_Fe(ph)%data(1:3,1:3,me), & constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) call constitutive_LiAndItsTangents(devNull,dLidS,dLidFi, & - crystallite_S (1:3,1:3,co,ip,el), & + constitutive_mech_S(ph)%data(1:3,1:3,me), & constitutive_mech_Fi(ph)%data(1:3,1:3,me), & co,ip,el) @@ -1122,7 +1124,7 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) endif call constitutive_plastic_LpAndItsTangents(devNull,dLpdS,dLpdFi, & - crystallite_S (1:3,1:3,co,ip,el), & + constitutive_mech_S(ph)%data(1:3,1:3,me), & constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) dLpdS = math_mul3333xx3333(dLpdFi,dFidS) + dLpdS @@ -1158,9 +1160,9 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) !-------------------------------------------------------------------------------------------------- ! assemble dPdF - temp_33_1 = matmul(crystallite_S(1:3,1:3,co,ip,el),transpose(invFp)) + temp_33_1 = matmul(constitutive_mech_S(ph)%data(1:3,1:3,me),transpose(invFp)) temp_33_2 = matmul(crystallite_F(1:3,1:3,co,ip,el),invFp) - temp_33_3 = matmul(temp_33_2,crystallite_S(1:3,1:3,co,ip,el)) + temp_33_3 = matmul(temp_33_2,constitutive_mech_S(ph)%data(1:3,1:3,me)) dPdF = 0.0_pReal do p=1,3 @@ -1188,7 +1190,7 @@ subroutine crystallite_orientations(co,ip,el) call crystallite_orientation(co,ip,el)%fromMatrix(transpose(math_rotationalPart(& - constitutive_mech_Fe(material_phaseAt(ip,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el))))) + constitutive_mech_Fe(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el))))) if (plasticState(material_phaseAt(1,el))%nonlocal) & call plastic_nonlocal_updateCompatibility(crystallite_orientation, & @@ -1253,7 +1255,7 @@ function integrateSourceState(dt,co,ip,el) result(broken) converged_ = .true. broken = constitutive_thermal_collectDotState(ph,me) - broken = broken .or. constitutive_damage_collectDotState(crystallite_S(1:3,1:3,co,ip,el), co,ip,el,ph,me) + broken = broken .or. constitutive_damage_collectDotState(co,ip,el,ph,me) if(broken) return do so = 1, phase_Nsources(ph) @@ -1271,7 +1273,7 @@ function integrateSourceState(dt,co,ip,el) result(broken) enddo broken = constitutive_thermal_collectDotState(ph,me) - broken = broken .or. constitutive_damage_collectDotState(crystallite_S(1:3,1:3,co,ip,el), co,ip,el,ph,me) + broken = broken .or. constitutive_damage_collectDotState(co,ip,el,ph,me) if(broken) exit iteration do so = 1, phase_Nsources(ph) @@ -1358,7 +1360,6 @@ subroutine crystallite_restartWrite fileHandle = HDF5_openFile(fileName,'a') call HDF5_write(fileHandle,crystallite_F,'F') - call HDF5_write(fileHandle,crystallite_S, 'S') groupHandle = HDF5_addGroup(fileHandle,'phase') do ph = 1,size(material_name_phase) @@ -1372,6 +1373,8 @@ subroutine crystallite_restartWrite call HDF5_write(groupHandle,constitutive_mech_Lp(ph)%data,datasetName) write(datasetName,'(i0,a)') ph,'_F_p' call HDF5_write(groupHandle,constitutive_mech_Fp(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_S' + call HDF5_write(groupHandle,constitutive_mech_S(ph)%data,datasetName) enddo call HDF5_closeGroup(groupHandle) @@ -1403,7 +1406,6 @@ subroutine crystallite_restartRead fileHandle = HDF5_openFile(fileName) call HDF5_read(fileHandle,crystallite_F0, 'F') - call HDF5_read(fileHandle,crystallite_S0, 'S') groupHandle = HDF5_openGroup(fileHandle,'phase') do ph = 1,size(material_name_phase) @@ -1417,6 +1419,8 @@ subroutine crystallite_restartRead call HDF5_read(groupHandle,constitutive_mech_Lp0(ph)%data,datasetName) write(datasetName,'(i0,a)') ph,'_F_p' call HDF5_read(groupHandle,constitutive_mech_Fp0(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_S' + call HDF5_read(groupHandle,constitutive_mech_S0(ph)%data,datasetName) enddo call HDF5_closeGroup(groupHandle) @@ -1438,7 +1442,7 @@ function constitutive_mech_getS(co,ip,el) result(S) integer, intent(in) :: co, ip, el real(pReal), dimension(3,3) :: S - S = crystallite_S(1:3,1:3,co,ip,el) + S = constitutive_mech_S(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) end function constitutive_mech_getS diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 06afe64fb..f8f4c5254 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -609,7 +609,7 @@ function mech_collectDotState(subdt, co, ip, el,ph,of) result(broken) instance = phase_plasticityInstance(ph) Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,of)),& - constitutive_mech_Fi(ph)%data(1:3,1:3,of)),crystallite_S(1:3,1:3,co,ip,el)) + constitutive_mech_Fi(ph)%data(1:3,1:3,of)),constitutive_mech_S(ph)%data(1:3,1:3,of)) plasticityType: select case (phase_plasticity(ph)) @@ -642,7 +642,7 @@ end function mech_collectDotState !> @brief for constitutive models having an instantaneous change of state !> will return false if delta state is not needed/supported by the constitutive model !-------------------------------------------------------------------------------------------------- -function constitutive_deltaState(S, Fi, co, ip, el, ph, of) result(broken) +function constitutive_deltaState(co, ip, el, ph, of) result(broken) integer, intent(in) :: & co, & !< component-ID of integration point @@ -650,19 +650,19 @@ function constitutive_deltaState(S, Fi, co, ip, el, ph, of) result(broken) el, & !< element ph, & of - real(pReal), intent(in), dimension(3,3) :: & - S, & !< 2nd Piola Kirchhoff stress - Fi !< intermediate deformation gradient + logical :: & + broken + real(pReal), dimension(3,3) :: & Mp integer :: & instance, & myOffset, & mySize - logical :: & - broken + - Mp = matmul(matmul(transpose(Fi),Fi),S) + Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,of)),& + constitutive_mech_Fi(ph)%data(1:3,1:3,of)),constitutive_mech_S(ph)%data(1:3,1:3,of)) instance = phase_plasticityInstance(ph) plasticityType: select case (phase_plasticity(ph)) @@ -936,7 +936,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) if (error) return ! error crystallite_P (1:3,1:3,co,ip,el) = matmul(matmul(F,invFp_new),matmul(S,transpose(invFp_new))) - crystallite_S (1:3,1:3,co,ip,el) = S + constitutive_mech_S(ph)%data(1:3,1:3,me) = S constitutive_mech_Lp(ph)%data(1:3,1:3,me) = Lpguess constitutive_mech_Li(ph)%data(1:3,1:3,me) = Liguess constitutive_mech_Fp(ph)%data(1:3,1:3,me) = Fp_new / math_det33(Fp_new)**(1.0_pReal/3.0_pReal) ! regularize @@ -1008,8 +1008,7 @@ function integrateStateFPI(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) resul plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%state(1:sizeDotState,me) & - r(1:sizeDotState) if (converged(r(1:sizeDotState),plasticState(ph)%state(1:sizeDotState,me),plasticState(ph)%atol(1:sizeDotState))) then - broken = constitutive_deltaState(crystallite_S(1:3,1:3,co,ip,el), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) + broken = constitutive_deltaState(co,ip,el,ph,me) exit iteration endif @@ -1071,8 +1070,7 @@ function integrateStateEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) res plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotState(1:sizeDotState,me) * Delta_t - broken = constitutive_deltaState(crystallite_S(1:3,1:3,co,ip,el), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) + broken = constitutive_deltaState(co,ip,el,ph,me) if(broken) return broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) @@ -1114,8 +1112,7 @@ function integrateStateAdaptiveEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotstate(1:sizeDotState,me) * Delta_t - broken = constitutive_deltaState(crystallite_S(1:3,1:3,co,ip,el), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) + broken = constitutive_deltaState(co,ip,el,ph,me) if(broken) return broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) @@ -1264,8 +1261,7 @@ function integrateStateRK(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el,A,B,C,D if(broken) return - broken = constitutive_deltaState(crystallite_S(1:3,1:3,co,ip,el), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el,ph,me) + broken = constitutive_deltaState(co,ip,el,ph,me) if(broken) return broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) @@ -1316,8 +1312,7 @@ subroutine crystallite_results(group,ph) call results_writeDataset(group//'/mechanics/',selected_tensors,output_constituent(ph)%label(ou),& 'First Piola-Kirchhoff stress','Pa') case('S') - selected_tensors = select_tensors(crystallite_S,ph) - call results_writeDataset(group//'/mechanics/',selected_tensors,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_S(ph)%data,output_constituent(ph)%label(ou),& 'Second Piola-Kirchhoff stress','Pa') case('O') select case(lattice_structure(ph)) @@ -1412,6 +1407,8 @@ module subroutine mech_initializeRestorationPoints(ph,me) constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) = constitutive_mech_Li0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp0(ph)%data(1:3,1:3,me) + constitutive_mech_partitionedS0(ph)%data(1:3,1:3,me) = constitutive_mech_S0(ph)%data(1:3,1:3,me) + plasticState(ph)%partitionedState0(:,me) = plasticState(ph)%state0(:,me) end subroutine mech_initializeRestorationPoints @@ -1429,6 +1426,7 @@ module subroutine constitutive_mech_windForward(ph,me) constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) = constitutive_mech_Li(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp(ph)%data(1:3,1:3,me) + constitutive_mech_partitionedS0(ph)%data(1:3,1:3,me) = constitutive_mech_S(ph)%data(1:3,1:3,me) plasticState(ph)%partitionedState0(:,me) = plasticState(ph)%state(:,me) @@ -1445,11 +1443,12 @@ module subroutine constitutive_mech_forward() do ph = 1, size(plasticState) - plasticState(ph)%state0 = plasticState(ph)%state constitutive_mech_Fi0(ph) = constitutive_mech_Fi(ph) constitutive_mech_Fp0(ph) = constitutive_mech_Fp(ph) constitutive_mech_Li0(ph) = constitutive_mech_Li(ph) constitutive_mech_Lp0(ph) = constitutive_mech_Lp(ph) + constitutive_mech_S0(ph) = constitutive_mech_S(ph) + plasticState(ph)%state0 = plasticState(ph)%state enddo end subroutine constitutive_mech_forward @@ -1553,7 +1552,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) subStep = num%subStepSizeCryst * subStep constitutive_mech_Fp(ph)%data(1:3,1:3,me) = subFp0 constitutive_mech_Fi(ph)%data(1:3,1:3,me) = subFi0 - crystallite_S (1:3,1:3,co,ip,el) = crystallite_S0 (1:3,1:3,co,ip,el) + constitutive_mech_S(ph)%data(1:3,1:3,me) = constitutive_mech_S0(ph)%data(1:3,1:3,me) ! why no subS0 ? is S0 of any use? if (subStep < 1.0_pReal) then ! actual (not initial) cutback constitutive_mech_Lp(ph)%data(1:3,1:3,me) = subLp0 constitutive_mech_Li(ph)%data(1:3,1:3,me) = subLi0 @@ -1607,7 +1606,7 @@ module subroutine mech_restore(ip,el,includeL) constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) - crystallite_S (1:3,1:3,co,ip,el) = crystallite_partitionedS0 (1:3,1:3,co,ip,el) + constitutive_mech_S(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedS0(ph)%data(1:3,1:3,me) plasticState (material_phaseAt(co,el))%state( :,material_phasememberAt(co,ip,el)) = & plasticState (material_phaseAt(co,el))%partitionedState0(:,material_phasememberAt(co,ip,el)) From 120118695d37addac10811c83a814919a5e98bfb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 12:25:03 +0100 Subject: [PATCH 045/352] encapsulate data --- src/constitutive.f90 | 17 +++++++++++++++++ src/homogenization_mech.f90 | 21 ++++++++++++--------- src/homogenization_mech_RGC.f90 | 1 - 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 37726ce2b..de1b5017d 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -392,6 +392,7 @@ module constitutive crystallite_push33ToRef, & crystallite_restartWrite, & integrateSourceState, & + constitutive_mech_setF, & constitutive_mech_getLp, & constitutive_mech_getS, & crystallite_restartRead, & @@ -1442,18 +1443,34 @@ function constitutive_mech_getS(co,ip,el) result(S) integer, intent(in) :: co, ip, el real(pReal), dimension(3,3) :: S + S = constitutive_mech_S(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) end function constitutive_mech_getS + ! getter for non-mech (e.g. thermal) function constitutive_mech_getLp(co,ip,el) result(Lp) integer, intent(in) :: co, ip, el real(pReal), dimension(3,3) :: Lp + Lp = constitutive_mech_Lp(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) end function constitutive_mech_getLp + +! setter for homogenization +subroutine constitutive_mech_setF(F,co,ip,el) + + real(pReal), dimension(3,3), intent(in) :: F + integer, intent(in) :: co, ip, el + + + crystallite_F(1:3,1:3,co,ip,el) = F + !constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) = F + +end subroutine constitutive_mech_setF + end module constitutive diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index e3e9cfb3e..e5ad95449 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -112,26 +112,29 @@ module subroutine mech_partition(subF,ip,el) integer, intent(in) :: & ip, & !< integration point el !< element number + + integer :: co + real(pReal) :: F(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) + chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) case (HOMOGENIZATION_NONE_ID) chosenHomogenization - crystallite_F(1:3,1:3,1,ip,el) = subF + F(1:3,1:3,1) = subF case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization - call mech_isostrain_partitionDeformation(& - crystallite_F(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - subF) + call mech_isostrain_partitionDeformation(F,subF) case (HOMOGENIZATION_RGC_ID) chosenHomogenization - call mech_RGC_partitionDeformation(& - crystallite_F(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - subF,& - ip, & - el) + call mech_RGC_partitionDeformation(F,subF,ip,el) end select chosenHomogenization + do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) + call constitutive_mech_setF(F(1:3,1:3,co),co,ip,el) + enddo + + end subroutine mech_partition diff --git a/src/homogenization_mech_RGC.f90 b/src/homogenization_mech_RGC.f90 index 04ec73845..931540c2e 100644 --- a/src/homogenization_mech_RGC.f90 +++ b/src/homogenization_mech_RGC.f90 @@ -523,7 +523,6 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa integer, dimension (3) :: iGrain3,iGNghb3,nGDim real(pReal), dimension (3,3) :: gDef,nDef real(pReal), dimension (3) :: nVect,surfCorr - real(pReal), dimension (2) :: Gmoduli integer :: iGrain,iGNghb,iFace,i,j,k,l real(pReal) :: muGrain,muGNghb,nDefNorm real(pReal), parameter :: & From a5cdc8433f8ebb5dddfc2053a043ec0e61cf966b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 13:01:33 +0100 Subject: [PATCH 046/352] better readable --- src/homogenization.f90 | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index d61fa57e8..e31089177 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -169,10 +169,8 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE converged = .false. ! pretend failed step ... subStep = 1.0_pReal/num%subStepSizeHomog ! ... larger then the requested calculation - if (homogState(ho)%sizeState > 0) & - homogState(ho)%subState0(:,me) = homogState(ho)%State0(:,me) - if (damageState(ho)%sizeState > 0) & - damageState(ho)%subState0(:,me) = damageState(ho)%State0(:,me) + if (homogState(ho)%sizeState > 0) homogState(ho)%subState0(:,me) = homogState(ho)%State0(:,me) + if (damageState(ho)%sizeState > 0) damageState(ho)%subState0(:,me) = damageState(ho)%State0(:,me) cutBackLooping: do while (.not. terminallyIll .and. subStep > num%subStepMinHomog) @@ -185,10 +183,8 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE ! wind forward grain starting point call constitutive_windForward(ip,el) - if(homogState(ho)%sizeState > 0) & - homogState(ho)%subState0(:,me) = homogState(ho)%State(:,me) - if(damageState(ho)%sizeState > 0) & - damageState(ho)%subState0(:,me) = damageState(ho)%State(:,me) + if(homogState(ho)%sizeState > 0) homogState(ho)%subState0(:,me) = homogState(ho)%State(:,me) + if(damageState(ho)%sizeState > 0) damageState(ho)%subState0(:,me) = damageState(ho)%State(:,me) endif steppingNeeded elseif ( (myNgrains == 1 .and. subStep <= 1.0 ) .or. & ! single grain already tried internal subStepping in crystallite @@ -202,10 +198,8 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE call constitutive_restore(ip,el,subStep < 1.0_pReal) - if(homogState(ho)%sizeState > 0) & - homogState(ho)%State(:,me) = homogState(ho)%subState0(:,me) - if(damageState(ho)%sizeState > 0) & - damageState(ho)%State(:,me) = damageState(ho)%subState0(:,me) + if(homogState(ho)%sizeState > 0) homogState(ho)%State(:,me) = homogState(ho)%subState0(:,me) + if(damageState(ho)%sizeState > 0) damageState(ho)%State(:,me) = damageState(ho)%subState0(:,me) endif if (subStep > num%subStepMinHomog) doneAndHappy = [.false.,.true.] From 6ec120d0040ec60c81e46eacf349cd8117346700 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 14:54:58 +0100 Subject: [PATCH 047/352] simplified - no extra state - no extra argument at the cost of less output --- PRIVATE | 2 +- src/homogenization_mech.f90 | 6 ++---- src/homogenization_mech_RGC.f90 | 34 +++++---------------------------- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/PRIVATE b/PRIVATE index 45ef93dbf..591964dcf 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 45ef93dbfa3e0e6fa830914b3632e188c308a099 +Subproject commit 591964dcf8521d95f6cccbfe840d462c430e63d9 diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index e5ad95449..db3412b8f 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -52,12 +52,11 @@ submodule(homogenization) homogenization_mech end subroutine mech_RGC_averageStressAndItsTangent - module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHappy) + module function mech_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy) logical, dimension(2) :: doneAndHappy real(pReal), dimension(:,:,:), intent(in) :: & P,& !< partitioned stresses - F,& !< partitioned deformation gradients - F0 !< partitioned initial deformation gradients + F !< partitioned deformation gradients real(pReal), dimension(:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses real(pReal), dimension(3,3), intent(in) :: avgF !< average F real(pReal), intent(in) :: dt !< time increment @@ -212,7 +211,6 @@ module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) doneAndHappy = & mech_RGC_updateState(crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & crystallite_F(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - crystallite_partitionedF0(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el),& subF,& subdt, & dPdFs, & diff --git a/src/homogenization_mech_RGC.f90 b/src/homogenization_mech_RGC.f90 index 931540c2e..580bb0268 100644 --- a/src/homogenization_mech_RGC.f90 +++ b/src/homogenization_mech_RGC.f90 @@ -24,9 +24,6 @@ submodule(homogenization:homogenization_mech) homogenization_mech_RGC end type tParameters type :: tRGCstate - real(pReal), pointer, dimension(:) :: & - work, & - penaltyEnergy real(pReal), pointer, dimension(:,:) :: & relaxationVector end type tRGCstate @@ -170,8 +167,7 @@ module subroutine mech_RGC_init(num_homogMech) nIntFaceTot = 3*( (prm%N_constituents(1)-1)*prm%N_constituents(2)*prm%N_constituents(3) & + prm%N_constituents(1)*(prm%N_constituents(2)-1)*prm%N_constituents(3) & + prm%N_constituents(1)*prm%N_constituents(2)*(prm%N_constituents(3)-1)) - sizeState = nIntFaceTot & - + size(['avg constitutive work ','average penalty energy']) + sizeState = nIntFaceTot homogState(h)%sizeState = sizeState allocate(homogState(h)%state0 (sizeState,Nmaterialpoints), source=0.0_pReal) @@ -180,8 +176,6 @@ module subroutine mech_RGC_init(num_homogMech) stt%relaxationVector => homogState(h)%state(1:nIntFaceTot,:) st0%relaxationVector => homogState(h)%state0(1:nIntFaceTot,:) - stt%work => homogState(h)%state(nIntFaceTot+1,:) - stt%penaltyEnergy => homogState(h)%state(nIntFaceTot+2,:) allocate(dst%volumeDiscrepancy( Nmaterialpoints), source=0.0_pReal) allocate(dst%relaxationRate_avg( Nmaterialpoints), source=0.0_pReal) @@ -243,12 +237,11 @@ end subroutine mech_RGC_partitionDeformation !> @brief update the internal state of the homogenization scheme and tell whether "done" and ! "happy" with result !-------------------------------------------------------------------------------------------------- -module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHappy) +module function mech_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy) logical, dimension(2) :: doneAndHappy real(pReal), dimension(:,:,:), intent(in) :: & P,& !< partitioned stresses - F,& !< partitioned deformation gradients - F0 !< partitioned initial deformation gradients + F !< partitioned deformation gradients real(pReal), dimension(:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses real(pReal), dimension(3,3), intent(in) :: avgF !< average F real(pReal), intent(in) :: dt !< time increment @@ -287,8 +280,8 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa !-------------------------------------------------------------------------------------------------- ! allocate the size of the global relaxation arrays/jacobian matrices depending on the size of the cluster - allocate(resid(3*nIntFaceTot), source=0.0_pReal) - allocate(tract(nIntFaceTot,3), source=0.0_pReal) + allocate(resid(3*nIntFaceTot), source=0.0_pReal) + allocate(tract(nIntFaceTot,3), source=0.0_pReal) relax = stt%relaxationVector(:,of) drelax = stt%relaxationVector(:,of) - st0%relaxationVector(:,of) @@ -346,17 +339,6 @@ module function mech_RGC_updateState(P,F,F0,avgF,dt,dPdF,ip,el) result(doneAndHa if (residMax < num%rtol*stresMax .or. residMax < num%atol) then doneAndHappy = .true. -!-------------------------------------------------------------------------------------------------- -! compute/update the state for postResult, i.e., all energy densities computed by time-integration - do iGrain = 1,product(prm%N_constituents) - do i = 1,3;do j = 1,3 - stt%work(of) = stt%work(of) & - + P(i,j,iGrain)*(F(i,j,iGrain) - F0(i,j,iGrain))/real(nGrain,pReal) - stt%penaltyEnergy(of) = stt%penaltyEnergy(of) & - + R(i,j,iGrain)*(F(i,j,iGrain) - F0(i,j,iGrain))/real(nGrain,pReal) - enddo; enddo - enddo - dst%mismatch(1:3,of) = sum(NN,2)/real(nGrain,pReal) dst%relaxationRate_avg(of) = sum(abs(drelax))/dt/real(3*nIntFaceTot,pReal) dst%relaxationRate_max(of) = maxval(abs(drelax))/dt @@ -754,15 +736,9 @@ module subroutine mech_RGC_results(instance,group) associate(stt => state(instance), dst => dependentState(instance), prm => param(instance)) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) - case('W') - call results_writeDataset(group,stt%work,trim(prm%output(o)), & - 'work density','J/m³') case('M') call results_writeDataset(group,dst%mismatch,trim(prm%output(o)), & 'average mismatch tensor','1') - case('R') - call results_writeDataset(group,stt%penaltyEnergy,trim(prm%output(o)), & - 'mismatch penalty density','J/m³') case('Delta_V') call results_writeDataset(group,dst%volumeDiscrepancy,trim(prm%output(o)), & 'volume discrepancy','m³') From 9e18e1d10a036e068ae603d08d11655fbf406318 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 15:44:45 +0100 Subject: [PATCH 048/352] need to be initialized --- src/constitutive.f90 | 6 +++--- src/constitutive_mech.f90 | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index de1b5017d..9ff84186c 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -936,9 +936,9 @@ subroutine crystallite_init allocate(constitutive_mech_partitionedLp0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Lp0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Lp(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_S(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_S0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedS0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_S(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(constitutive_mech_S0(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(constitutive_mech_partitionedS0(ph)%data(3,3,Nconstituents),source=0.0_pReal) do so = 1, phase_Nsources(ph) allocate(sourceState(ph)%p(so)%subState0,source=sourceState(ph)%p(so)%state0) ! ToDo: hack enddo diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index f8f4c5254..1b79f6d6a 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -941,7 +941,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) constitutive_mech_Li(ph)%data(1:3,1:3,me) = Liguess constitutive_mech_Fp(ph)%data(1:3,1:3,me) = Fp_new / math_det33(Fp_new)**(1.0_pReal/3.0_pReal) ! regularize constitutive_mech_Fi(ph)%data(1:3,1:3,me) = Fi_new - constitutive_mech_Fe(ph)%data(1:3,1:3,me)= matmul(matmul(F,invFp_new),invFi_new) + constitutive_mech_Fe(ph)%data(1:3,1:3,me) = matmul(matmul(F,invFp_new),invFi_new) broken = .false. end function integrateStress From e34937a0d21851308bd158a8ab017a2710829a9c Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 18:27:24 +0100 Subject: [PATCH 049/352] avoiding public variables --- src/constitutive.f90 | 94 ++++++++++++++------------- src/constitutive_mech.f90 | 66 +++++++++---------- src/constitutive_plastic_nonlocal.f90 | 20 ++---- src/homogenization_mech.f90 | 4 +- src/thermal_conduction.f90 | 25 ++++--- 5 files changed, 107 insertions(+), 102 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 9ff84186c..59c3bf559 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -45,12 +45,8 @@ module constitutive type(rotation), dimension(:,:,:), allocatable :: & crystallite_orientation !< current orientation - real(pReal), dimension(:,:,:,:,:), allocatable :: & - crystallite_F0 !< def grad at start of FE inc real(pReal), dimension(:,:,:,:,:), allocatable, public :: & - crystallite_P, & !< 1st Piola-Kirchhoff stress per grain - crystallite_partitionedF0, & !< def grad at start of homog inc - crystallite_F !< def grad to be reached at end of homog inc + crystallite_P !< 1st Piola-Kirchhoff stress per grain type :: tTensorContainer real(pReal), dimension(:,:,:), allocatable :: data @@ -61,18 +57,21 @@ module constitutive constitutive_mech_Fe, & constitutive_mech_Fi, & constitutive_mech_Fp, & + constitutive_mech_F, & constitutive_mech_Li, & constitutive_mech_Lp, & constitutive_mech_S, & ! converged value at end of last solver increment constitutive_mech_Fi0, & constitutive_mech_Fp0, & + constitutive_mech_F0, & constitutive_mech_Li0, & constitutive_mech_Lp0, & constitutive_mech_S0, & ! converged value at end of last homogenization increment (RGC only) constitutive_mech_partitionedFi0, & constitutive_mech_partitionedFp0, & + constitutive_mech_partitionedF0, & constitutive_mech_partitionedLi0, & constitutive_mech_partitionedLp0, & constitutive_mech_partitionedS0 @@ -339,13 +338,11 @@ module constitutive end subroutine constitutive_plastic_LpAndItsTangents - module subroutine constitutive_plastic_dependentState(F, co, ip, el) + module subroutine constitutive_plastic_dependentState(co,ip,el) integer, intent(in) :: & co, & !< component-ID of integration point ip, & !< integration point el !< element - real(pReal), intent(in), dimension(3,3) :: & - F !< elastic deformation gradient end subroutine constitutive_plastic_dependentState @@ -394,6 +391,7 @@ module constitutive integrateSourceState, & constitutive_mech_setF, & constitutive_mech_getLp, & + constitutive_mech_getF, & constitutive_mech_getS, & crystallite_restartRead, & constitutive_initializeRestorationPoints, & @@ -789,15 +787,14 @@ end subroutine constitutive_restore !-------------------------------------------------------------------------------------------------- subroutine constitutive_forward - integer :: i, j - - crystallite_F0 = crystallite_F + integer :: ph, so + call constitutive_mech_forward() - do i = 1, size(sourceState) - do j = 1,phase_Nsources(i) - sourceState(i)%p(j)%state0 = sourceState(i)%p(j)%state + do ph = 1, size(sourceState) + do so = 1,phase_Nsources(ph) + sourceState(ph)%p(so)%state0 = sourceState(ph)%p(so)%state enddo; enddo end subroutine constitutive_forward @@ -862,12 +859,6 @@ subroutine crystallite_init eMax = discretization_Nelems allocate(crystallite_P(3,3,cMax,iMax,eMax),source=0.0_pReal) - - allocate(crystallite_F0, & - crystallite_partitionedF0,& - crystallite_F, & - source = crystallite_P) - allocate(crystallite_orientation(cMax,iMax,eMax)) @@ -911,6 +902,9 @@ subroutine crystallite_init allocate(constitutive_mech_Fp(phases%length)) allocate(constitutive_mech_Fp0(phases%length)) allocate(constitutive_mech_partitionedFp0(phases%length)) + allocate(constitutive_mech_F(phases%length)) + allocate(constitutive_mech_F0(phases%length)) + allocate(constitutive_mech_partitionedF0(phases%length)) allocate(constitutive_mech_Li(phases%length)) allocate(constitutive_mech_Li0(phases%length)) allocate(constitutive_mech_partitionedLi0(phases%length)) @@ -939,6 +933,9 @@ subroutine crystallite_init allocate(constitutive_mech_S(ph)%data(3,3,Nconstituents),source=0.0_pReal) allocate(constitutive_mech_S0(ph)%data(3,3,Nconstituents),source=0.0_pReal) allocate(constitutive_mech_partitionedS0(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(constitutive_mech_F(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_F0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_partitionedF0(ph)%data(3,3,Nconstituents)) do so = 1, phase_Nsources(ph) allocate(sourceState(ph)%p(so)%subState0,source=sourceState(ph)%p(so)%state0) ! ToDo: hack enddo @@ -955,28 +952,27 @@ subroutine crystallite_init ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) + constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = material_orientation0(co,ip,el)%asMatrix() ! Fp reflects initial orientation (see 10.1016/j.actamat.2006.01.005) constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) & - / math_det33(constitutive_mech_Fp0(ph)%data(1:3,1:3,me))**(1.0_pReal/3.0_pReal) + / math_det33(constitutive_mech_Fp0(ph)%data(1:3,1:3,me))**(1.0_pReal/3.0_pReal) constitutive_mech_Fi0(ph)%data(1:3,1:3,me) = math_I3 - - crystallite_F0(1:3,1:3,co,ip,el) = math_I3 - + constitutive_mech_F0(ph)%data(1:3,1:3,me) = math_I3 + constitutive_mech_Fe(ph)%data(1:3,1:3,me) = math_inv33(matmul(constitutive_mech_Fi0(ph)%data(1:3,1:3,me), & constitutive_mech_Fp0(ph)%data(1:3,1:3,me))) ! assuming that euler angles are given in internal strain free configuration constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) + constitutive_mech_F(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) + constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) enddo enddo; enddo !$OMP END PARALLEL DO - crystallite_partitionedF0 = crystallite_F0 - crystallite_F = crystallite_F0 - !$OMP PARALLEL DO PRIVATE(ph,me) do el = 1, size(material_phaseMemberAt,3) @@ -985,7 +981,7 @@ subroutine crystallite_init ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) call crystallite_orientations(co,ip,el) - call constitutive_plastic_dependentState(crystallite_partitionedF0(1:3,1:3,co,ip,el),co,ip,el) ! update dependent state variables to be consistent with basic states + call constitutive_plastic_dependentState(co,ip,el) ! update dependent state variables to be consistent with basic states enddo enddo enddo @@ -1010,13 +1006,11 @@ subroutine constitutive_initializeRestorationPoints(ip,el) do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - crystallite_partitionedF0(1:3,1:3,co,ip,el) = crystallite_F0(1:3,1:3,co,ip,el) call mech_initializeRestorationPoints(ph,me) do so = 1, phase_Nsources(material_phaseAt(co,el)) - sourceState(material_phaseAt(co,el))%p(so)%partitionedState0(:,material_phasememberAt(co,ip,el)) = & - sourceState(material_phaseAt(co,el))%p(so)%state0( :,material_phasememberAt(co,ip,el)) + sourceState(ph)%p(so)%partitionedState0(:,me) = sourceState(ph)%p(so)%state0(:,me) enddo enddo @@ -1040,7 +1034,6 @@ subroutine constitutive_windForward(ip,el) do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - crystallite_partitionedF0 (1:3,1:3,co,ip,el) = crystallite_F (1:3,1:3,co,ip,el) call constitutive_mech_windForward(ph,me) do so = 1, phase_Nsources(material_phaseAt(co,el)) @@ -1132,8 +1125,8 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) !-------------------------------------------------------------------------------------------------- ! calculate dSdF temp_33_1 = transpose(matmul(invFp,invFi)) - temp_33_2 = matmul(crystallite_F(1:3,1:3,co,ip,el),invSubFp0) - temp_33_3 = matmul(matmul(crystallite_F(1:3,1:3,co,ip,el),invFp), invSubFi0) + temp_33_2 = matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invSubFp0) + temp_33_3 = matmul(matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invFp), invSubFi0) do o=1,3; do p=1,3 rhs_3333(p,o,1:3,1:3) = matmul(dSdFe(p,o,1:3,1:3),temp_33_1) @@ -1162,7 +1155,7 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) !-------------------------------------------------------------------------------------------------- ! assemble dPdF temp_33_1 = matmul(constitutive_mech_S(ph)%data(1:3,1:3,me),transpose(invFp)) - temp_33_2 = matmul(crystallite_F(1:3,1:3,co,ip,el),invFp) + temp_33_2 = matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invFp) temp_33_3 = matmul(temp_33_2,constitutive_mech_S(ph)%data(1:3,1:3,me)) dPdF = 0.0_pReal @@ -1171,7 +1164,7 @@ function crystallite_stressTangent(dt,co,ip,el) result(dPdF) enddo do o=1,3; do p=1,3 dPdF(1:3,1:3,p,o) = dPdF(1:3,1:3,p,o) & - + matmul(matmul(crystallite_F(1:3,1:3,co,ip,el),dFpinvdF(1:3,1:3,p,o)),temp_33_1) & + + matmul(matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),dFpinvdF(1:3,1:3,p,o)),temp_33_1) & + matmul(matmul(temp_33_2,dSdF(1:3,1:3,p,o)),transpose(invFp)) & + matmul(temp_33_3,transpose(dFpinvdF(1:3,1:3,p,o))) enddo; enddo @@ -1207,17 +1200,17 @@ end subroutine crystallite_orientations function crystallite_push33ToRef(co,ip,el, tensor33) real(pReal), dimension(3,3), intent(in) :: tensor33 - real(pReal), dimension(3,3) :: T integer, intent(in):: & el, & ip, & co - real(pReal), dimension(3,3) :: crystallite_push33ToRef + + real(pReal), dimension(3,3) :: T T = matmul(material_orientation0(co,ip,el)%asMatrix(), & ! ToDo: initial orientation correct? - transpose(math_inv33(crystallite_F(1:3,1:3,co,ip,el)))) + transpose(math_inv33(constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el))))) crystallite_push33ToRef = matmul(transpose(T),matmul(tensor33,T)) end function crystallite_push33ToRef @@ -1360,8 +1353,6 @@ subroutine crystallite_restartWrite write(fileName,'(a,i0,a)') trim(getSolverJobName())//'_',worldrank,'.hdf5' fileHandle = HDF5_openFile(fileName,'a') - call HDF5_write(fileHandle,crystallite_F,'F') - groupHandle = HDF5_addGroup(fileHandle,'phase') do ph = 1,size(material_name_phase) write(datasetName,'(i0,a)') ph,'_omega' @@ -1376,6 +1367,8 @@ subroutine crystallite_restartWrite call HDF5_write(groupHandle,constitutive_mech_Fp(ph)%data,datasetName) write(datasetName,'(i0,a)') ph,'_S' call HDF5_write(groupHandle,constitutive_mech_S(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_F' + call HDF5_write(groupHandle,constitutive_mech_F(ph)%data,datasetName) enddo call HDF5_closeGroup(groupHandle) @@ -1406,8 +1399,6 @@ subroutine crystallite_restartRead write(fileName,'(a,i0,a)') trim(getSolverJobName())//'_',worldrank,'.hdf5' fileHandle = HDF5_openFile(fileName) - call HDF5_read(fileHandle,crystallite_F0, 'F') - groupHandle = HDF5_openGroup(fileHandle,'phase') do ph = 1,size(material_name_phase) write(datasetName,'(i0,a)') ph,'_omega' @@ -1422,6 +1413,8 @@ subroutine crystallite_restartRead call HDF5_read(groupHandle,constitutive_mech_Fp0(ph)%data,datasetName) write(datasetName,'(i0,a)') ph,'_S' call HDF5_read(groupHandle,constitutive_mech_S0(ph)%data,datasetName) + write(datasetName,'(i0,a)') ph,'_F' + call HDF5_read(groupHandle,constitutive_mech_F0(ph)%data,datasetName) enddo call HDF5_closeGroup(groupHandle) @@ -1461,6 +1454,18 @@ function constitutive_mech_getLp(co,ip,el) result(Lp) end function constitutive_mech_getLp +! getter for non-mech (e.g. thermal) +function constitutive_mech_getF(co,ip,el) result(F) + + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: F + + + F = constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + +end function constitutive_mech_getF + + ! setter for homogenization subroutine constitutive_mech_setF(F,co,ip,el) @@ -1468,8 +1473,7 @@ subroutine constitutive_mech_setF(F,co,ip,el) integer, intent(in) :: co, ip, el - crystallite_F(1:3,1:3,co,ip,el) = F - !constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) = F + constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) = F end subroutine constitutive_mech_setF diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 1b79f6d6a..1483e857c 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -184,12 +184,9 @@ submodule(constitutive) constitutive_mech of end subroutine plastic_disloTungsten_dotState - module subroutine plastic_nonlocal_dotState(Mp, F, Temperature,timestep, & - instance,of,ip,el) + module subroutine plastic_nonlocal_dotState(Mp,Temperature,timestep,instance,of,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress - real(pReal), dimension(3,3,homogenization_maxNconstituents,discretization_nIPs,discretization_Nelems), intent(in) :: & - F !< deformation gradient real(pReal), intent(in) :: & Temperature, & !< temperature timestep !< substepped crystallite time increment @@ -215,9 +212,7 @@ submodule(constitutive) constitutive_mech of end subroutine plastic_dislotungsten_dependentState - module subroutine plastic_nonlocal_dependentState(F, instance, of, ip, el) - real(pReal), dimension(3,3), intent(in) :: & - F !< deformation gradient + module subroutine plastic_nonlocal_dependentState(instance, of, ip, el) integer, intent(in) :: & instance, & of, & @@ -480,32 +475,35 @@ end subroutine constitutive_hooke_SandItsTangents !-------------------------------------------------------------------------------------------------- !> @brief calls microstructure function of the different plasticity constitutive models !-------------------------------------------------------------------------------------------------- -module subroutine constitutive_plastic_dependentState(F, co, ip, el) +module subroutine constitutive_plastic_dependentState(co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point ip, & !< integration point el !< element - real(pReal), intent(in), dimension(3,3) :: & - F !< deformation gradient integer :: & ho, & !< homogenization tme, & !< thermal member position - instance, of + instance, me + ho = material_homogenizationAt(el) tme = material_homogenizationMemberAt(ip,el) - of = material_phasememberAt(co,ip,el) + me = material_phasememberAt(co,ip,el) instance = phase_plasticityInstance(material_phaseAt(co,el)) plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) + case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_dependentState(temperature(ho)%p(tme),instance,of) + call plastic_dislotwin_dependentState(temperature(ho)%p(tme),instance,me) + case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_dislotungsten_dependentState(instance,of) + call plastic_dislotungsten_dependentState(instance,me) + case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_dependentState (F,instance,of,ip,el) + call plastic_nonlocal_dependentState(instance,me,ip,el) + end select plasticityType end subroutine constitutive_plastic_dependentState @@ -539,13 +537,13 @@ module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & ho, & !< homogenization tme !< thermal member position integer :: & - i, j, instance, of + i, j, instance, me ho = material_homogenizationAt(el) tme = material_homogenizationMemberAt(ip,el) Mp = matmul(matmul(transpose(Fi),Fi),S) - of = material_phasememberAt(co,ip,el) + me = material_phasememberAt(co,ip,el) instance = phase_plasticityInstance(material_phaseAt(co,el)) plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) @@ -555,22 +553,22 @@ module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & dLp_dMp = 0.0_pReal case (PLASTICITY_ISOTROPIC_ID) plasticityType - call plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + call plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType - call plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + call plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) case (PLASTICITY_KINEHARDENING_ID) plasticityType - call plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + call plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, temperature(ho)%p(tme),instance,of,ip,el) + call plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, temperature(ho)%p(tme),instance,me,ip,el) case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,temperature(ho)%p(tme),instance,of) + call plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,temperature(ho)%p(tme),instance,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,temperature(ho)%p(tme),instance,of) + call plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,temperature(ho)%p(tme),instance,me) end select plasticityType @@ -586,7 +584,7 @@ end subroutine constitutive_plastic_LpAndItsTangents !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the rate of change of microstructure !-------------------------------------------------------------------------------------------------- -function mech_collectDotState(subdt, co, ip, el,ph,of) result(broken) +function mech_collectDotState(subdt,co,ip,el,ph,of) result(broken) integer, intent(in) :: & co, & !< component-ID of integration point @@ -601,9 +599,9 @@ function mech_collectDotState(subdt, co, ip, el,ph,of) result(broken) integer :: & ho, & !< homogenization tme, & !< thermal member position - i, & !< counter in source loop instance logical :: broken + ho = material_homogenizationAt(el) tme = material_homogenizationMemberAt(ip,el) instance = phase_plasticityInstance(ph) @@ -629,8 +627,7 @@ function mech_collectDotState(subdt, co, ip, el,ph,of) result(broken) call plastic_disloTungsten_dotState(Mp,temperature(ho)%p(tme),instance,of) case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_dotState(Mp,crystallite_partitionedF0,temperature(ho)%p(tme),subdt, & - instance,of,ip,el) + call plastic_nonlocal_dotState(Mp,temperature(ho)%p(tme),subdt,instance,of,ip,el) end select plasticityType broken = any(IEEE_is_NaN(plasticState(ph)%dotState(:,of))) @@ -798,12 +795,13 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) jacoCounterLi ! counters to check for Jacobian update logical :: error,broken - broken = .true. - call constitutive_plastic_dependentState(crystallite_F(1:3,1:3,co,ip,el),co,ip,el) + broken = .true. ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) + + call constitutive_plastic_dependentState(co,ip,el) Lpguess = constitutive_mech_Lp(ph)%data(1:3,1:3,me) ! take as first guess Liguess = constitutive_mech_Li(ph)%data(1:3,1:3,me) ! take as first guess @@ -1289,8 +1287,7 @@ subroutine crystallite_results(group,ph) select case (output_constituent(ph)%label(ou)) case('F') - selected_tensors = select_tensors(crystallite_F,ph) - call results_writeDataset(group//'/mechanics/',selected_tensors,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_F(ph)%data,output_constituent(ph)%label(ou),& 'deformation gradient','1') case('F_e') call results_writeDataset(group//'/mechanics/',constitutive_mech_Fe(ph)%data,output_constituent(ph)%label(ou),& @@ -1405,6 +1402,7 @@ module subroutine mech_initializeRestorationPoints(ph,me) constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) + constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) = constitutive_mech_Li0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp0(ph)%data(1:3,1:3,me) constitutive_mech_partitionedS0(ph)%data(1:3,1:3,me) = constitutive_mech_S0(ph)%data(1:3,1:3,me) @@ -1424,6 +1422,7 @@ module subroutine constitutive_mech_windForward(ph,me) constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp(ph)%data(1:3,1:3,me) constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi(ph)%data(1:3,1:3,me) + constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) = constitutive_mech_F(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) = constitutive_mech_Li(ph)%data(1:3,1:3,me) constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp(ph)%data(1:3,1:3,me) constitutive_mech_partitionedS0(ph)%data(1:3,1:3,me) = constitutive_mech_S(ph)%data(1:3,1:3,me) @@ -1445,6 +1444,7 @@ module subroutine constitutive_mech_forward() do ph = 1, size(plasticState) constitutive_mech_Fi0(ph) = constitutive_mech_Fi(ph) constitutive_mech_Fp0(ph) = constitutive_mech_Fp(ph) + constitutive_mech_F0(ph) = constitutive_mech_F(ph) constitutive_mech_Li0(ph) = constitutive_mech_Li(ph) constitutive_mech_Lp0(ph) = constitutive_mech_Lp(ph) constitutive_mech_S0(ph) = constitutive_mech_S(ph) @@ -1519,7 +1519,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) enddo subFp0 = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) subFi0 = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) - subF0 = crystallite_partitionedF0(1:3,1:3,co,ip,el) + subF0 = constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) subFrac = 0.0_pReal subStep = 1.0_pReal/num%subStepSizeCryst todo = .true. @@ -1569,7 +1569,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) ! prepare for integration if (todo) then subF = subF0 & - + subStep * (crystallite_F(1:3,1:3,co,ip,el) - crystallite_partitionedF0(1:3,1:3,co,ip,el)) + + subStep * (constitutive_mech_F(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me)) constitutive_mech_Fe(ph)%data(1:3,1:3,me) = matmul(subF,math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) converged_ = .not. integrateState(subF0,subF,subFp0,subFi0,subState0(1:sizeDotState),subStep * dt,co,ip,el) diff --git a/src/constitutive_plastic_nonlocal.f90 b/src/constitutive_plastic_nonlocal.f90 index 0d7875291..2244eb7ad 100644 --- a/src/constitutive_plastic_nonlocal.f90 +++ b/src/constitutive_plastic_nonlocal.f90 @@ -552,10 +552,8 @@ end function plastic_nonlocal_init !-------------------------------------------------------------------------------------------------- !> @brief calculates quantities characterizing the microstructure !-------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_dependentState(F, instance, of, ip, el) +module subroutine plastic_nonlocal_dependentState(instance, of, ip, el) - real(pReal), dimension(3,3), intent(in) :: & - F integer, intent(in) :: & instance, & of, & @@ -647,7 +645,7 @@ module subroutine plastic_nonlocal_dependentState(F, instance, of, ip, el) ph = material_phaseAt(1,el) me = material_phaseMemberAt(1,ip,el) invFp = math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me)) - invFe = matmul(constitutive_mech_Fp(ph)%data(1:3,1:3,me),math_inv33(F)) + invFe = math_inv33(constitutive_mech_Fe(ph)%data(1:3,1:3,me)) rho_edg_delta = rho0(:,mob_edg_pos) - rho0(:,mob_edg_neg) rho_scr_delta = rho0(:,mob_scr_pos) - rho0(:,mob_scr_neg) @@ -976,13 +974,11 @@ end subroutine plastic_nonlocal_deltaState !--------------------------------------------------------------------------------------------------- !> @brief calculates the rate of change of microstructure !--------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_dotState(Mp, F, Temperature,timestep, & +module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & instance,of,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress - real(pReal), dimension(3,3,homogenization_maxNconstituents,discretization_nIPs,discretization_Nelems), intent(in) :: & - F !< Deformation gradient real(pReal), intent(in) :: & Temperature, & !< temperature timestep !< substepped crystallite time increment @@ -1149,7 +1145,7 @@ module subroutine plastic_nonlocal_dotState(Mp, F, Temperature,timestep, & - rhoDip(s,1) / timestep - rhoDotAthermalAnnihilation(s,9) & - rhoDotSingle2DipoleGlide(s,9)) ! make sure that we do not annihilate more dipoles than we have - rhoDot = rhoDotFlux(F,timestep, instance,of,ip,el) & + rhoDot = rhoDotFlux(timestep, instance,of,ip,el) & + rhoDotMultiplication & + rhoDotSingle2DipoleGlide & + rhoDotAthermalAnnihilation & @@ -1178,10 +1174,8 @@ end subroutine plastic_nonlocal_dotState !--------------------------------------------------------------------------------------------------- !> @brief calculates the rate of change of microstructure !--------------------------------------------------------------------------------------------------- -function rhoDotFlux(F,timestep, instance,of,ip,el) +function rhoDotFlux(timestep,instance,of,ip,el) - real(pReal), dimension(3,3,homogenization_maxNconstituents,discretization_nIPs,discretization_Nelems), intent(in) :: & - F !< Deformation gradient real(pReal), intent(in) :: & timestep !< substepped crystallite time increment integer, intent(in) :: & @@ -1293,7 +1287,7 @@ function rhoDotFlux(F,timestep, instance,of,ip,el) m(1:3,:,3) = -prm%slip_transverse m(1:3,:,4) = prm%slip_transverse - my_F = F(1:3,1:3,1,ip,el) + my_F = constitutive_mech_F(ph)%data(1:3,1:3,of) my_Fe = matmul(my_F, math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,of))) neighbors: do n = 1,nIPneighbors @@ -1311,7 +1305,7 @@ function rhoDotFlux(F,timestep, instance,of,ip,el) if (neighbor_n > 0) then ! if neighbor exists, average deformation gradient neighbor_instance = phase_plasticityInstance(material_phaseAt(1,neighbor_el)) - neighbor_F = F(1:3,1:3,1,neighbor_ip,neighbor_el) + neighbor_F = constitutive_mech_F(np)%data(1:3,1:3,no) neighbor_Fe = matmul(neighbor_F, math_inv33(constitutive_mech_Fp(np)%data(1:3,1:3,no))) Favg = 0.5_pReal * (my_F + neighbor_F) else ! if no neighbor, take my value as average diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index db3412b8f..4a9e1856f 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -202,15 +202,17 @@ module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) integer :: co real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) + real(pReal) :: Fs(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) if (homogenization_type(material_homogenizationAt(el)) == HOMOGENIZATION_RGC_ID) then do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) dPdFs(:,:,:,:,co) = crystallite_stressTangent(subdt,co,ip,el) + Fs(:,:,co) = constitutive_mech_getF(co,ip,el) enddo doneAndHappy = & mech_RGC_updateState(crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - crystallite_F(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & + Fs, & subF,& subdt, & dPdFs, & diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index 09997162c..f98d36d3b 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -112,14 +112,16 @@ function thermal_conduction_getConductivity(ip,el) el !< element number real(pReal), dimension(3,3) :: & thermal_conduction_getConductivity + integer :: & - grain + co thermal_conduction_getConductivity = 0.0_pReal - do grain = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) thermal_conduction_getConductivity = thermal_conduction_getConductivity + & - crystallite_push33ToRef(grain,ip,el,lattice_K(:,:,material_phaseAt(grain,el))) + crystallite_push33ToRef(co,ip,el,lattice_K(:,:,material_phaseAt(co,el))) enddo thermal_conduction_getConductivity = thermal_conduction_getConductivity & @@ -138,14 +140,16 @@ function thermal_conduction_getSpecificHeat(ip,el) el !< element number real(pReal) :: & thermal_conduction_getSpecificHeat + integer :: & - grain + co + thermal_conduction_getSpecificHeat = 0.0_pReal - do grain = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) thermal_conduction_getSpecificHeat = thermal_conduction_getSpecificHeat & - + lattice_c_p(material_phaseAt(grain,el)) + + lattice_c_p(material_phaseAt(co,el)) enddo thermal_conduction_getSpecificHeat = thermal_conduction_getSpecificHeat & @@ -164,15 +168,16 @@ function thermal_conduction_getMassDensity(ip,el) el !< element number real(pReal) :: & thermal_conduction_getMassDensity + integer :: & - grain + co + thermal_conduction_getMassDensity = 0.0_pReal - - do grain = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) thermal_conduction_getMassDensity = thermal_conduction_getMassDensity & - + lattice_rho(material_phaseAt(grain,el)) + + lattice_rho(material_phaseAt(co,el)) enddo thermal_conduction_getMassDensity = thermal_conduction_getMassDensity & From 8572ec836812cfebfed77055a1237846828efb87 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 18:45:11 +0100 Subject: [PATCH 050/352] preparing encapsulation --- src/constitutive.f90 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 59c3bf559..e39a0df2e 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -1466,6 +1466,22 @@ function constitutive_mech_getF(co,ip,el) result(F) end function constitutive_mech_getF +! getter for non-thermal (e.g. mech) +function constitutive_thermal_T(co,ip,el) result(T) + + integer, intent(in) :: co, ip, el + real(pReal) :: T + + integer :: ho, tme + + ho = material_homogenizationAt(el) + tme = material_homogenizationMemberAt(ip,el) + + T = temperature(ho)%p(tme) + +end function constitutive_thermal_T + + ! setter for homogenization subroutine constitutive_mech_setF(F,co,ip,el) From 39287ae61fcca9c84c2e6d5eba49cc79974124a5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 19:02:22 +0100 Subject: [PATCH 051/352] distribute responsibilities --- src/constitutive.f90 | 69 ----------------------------------- src/constitutive_mech.f90 | 76 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 70 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index e39a0df2e..261e9e304 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -830,7 +830,6 @@ end subroutine constitutive_results subroutine crystallite_init integer :: & - Nconstituents, & ph, & me, & co, & !< counter in integration point component loop @@ -861,7 +860,6 @@ subroutine crystallite_init allocate(crystallite_P(3,3,cMax,iMax,eMax),source=0.0_pReal) allocate(crystallite_orientation(cMax,iMax,eMax)) - num_crystallite => config_numerics%get('crystallite',defaultVal=emptyDict) num%subStepMinCryst = num_crystallite%get_asFloat ('subStepMin', defaultVal=1.0e-3_pReal) @@ -895,47 +893,7 @@ subroutine crystallite_init phases => config_material%get('phase') - allocate(constitutive_mech_Fe(phases%length)) - allocate(constitutive_mech_Fi(phases%length)) - allocate(constitutive_mech_Fi0(phases%length)) - allocate(constitutive_mech_partitionedFi0(phases%length)) - allocate(constitutive_mech_Fp(phases%length)) - allocate(constitutive_mech_Fp0(phases%length)) - allocate(constitutive_mech_partitionedFp0(phases%length)) - allocate(constitutive_mech_F(phases%length)) - allocate(constitutive_mech_F0(phases%length)) - allocate(constitutive_mech_partitionedF0(phases%length)) - allocate(constitutive_mech_Li(phases%length)) - allocate(constitutive_mech_Li0(phases%length)) - allocate(constitutive_mech_partitionedLi0(phases%length)) - allocate(constitutive_mech_partitionedLp0(phases%length)) - allocate(constitutive_mech_Lp0(phases%length)) - allocate(constitutive_mech_Lp(phases%length)) - allocate(constitutive_mech_S(phases%length)) - allocate(constitutive_mech_S0(phases%length)) - allocate(constitutive_mech_partitionedS0(phases%length)) do ph = 1, phases%length - Nconstituents = count(material_phaseAt == ph) * discretization_nIPs - - allocate(constitutive_mech_Fi(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Fe(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Fi0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedFi0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Fp(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Fp0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedFp0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Li(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Li0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedLi0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedLp0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Lp0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Lp(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_S(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(constitutive_mech_S0(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(constitutive_mech_partitionedS0(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(constitutive_mech_F(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_F0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedF0(ph)%data(3,3,Nconstituents)) do so = 1, phase_Nsources(ph) allocate(sourceState(ph)%p(so)%subState0,source=sourceState(ph)%p(so)%state0) ! ToDo: hack enddo @@ -946,33 +904,6 @@ subroutine crystallite_init print'(a42,1x,i10)', 'max # of constituents/integration point: ', cMax flush(IO_STDOUT) - !$OMP PARALLEL DO PRIVATE(ph,me) - do el = 1, size(material_phaseMemberAt,3); do ip = 1, size(material_phaseMemberAt,2) - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - - ph = material_phaseAt(co,el) - me = material_phaseMemberAt(co,ip,el) - - constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = material_orientation0(co,ip,el)%asMatrix() ! Fp reflects initial orientation (see 10.1016/j.actamat.2006.01.005) - constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) & - / math_det33(constitutive_mech_Fp0(ph)%data(1:3,1:3,me))**(1.0_pReal/3.0_pReal) - constitutive_mech_Fi0(ph)%data(1:3,1:3,me) = math_I3 - constitutive_mech_F0(ph)%data(1:3,1:3,me) = math_I3 - - constitutive_mech_Fe(ph)%data(1:3,1:3,me) = math_inv33(matmul(constitutive_mech_Fi0(ph)%data(1:3,1:3,me), & - constitutive_mech_Fp0(ph)%data(1:3,1:3,me))) ! assuming that euler angles are given in internal strain free configuration - constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) - constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) - constitutive_mech_F(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) - - constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) - - enddo - enddo; enddo - !$OMP END PARALLEL DO - !$OMP PARALLEL DO PRIVATE(ph,me) do el = 1, size(material_phaseMemberAt,3) diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 1483e857c..fa9a5eda6 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -297,8 +297,13 @@ contains module subroutine mech_init integer :: & + el, & + ip, & + co, & ph, & - stiffDegradationCtr + me, & + stiffDegradationCtr, & + Nconstituents class(tNode), pointer :: & num_crystallite, & phases, & @@ -317,7 +322,49 @@ module subroutine mech_init allocate(phase_NstiffnessDegradations(phases%length),source=0) allocate(output_constituent(phases%length)) + allocate(constitutive_mech_Fe(phases%length)) + allocate(constitutive_mech_Fi(phases%length)) + allocate(constitutive_mech_Fi0(phases%length)) + allocate(constitutive_mech_partitionedFi0(phases%length)) + allocate(constitutive_mech_Fp(phases%length)) + allocate(constitutive_mech_Fp0(phases%length)) + allocate(constitutive_mech_partitionedFp0(phases%length)) + allocate(constitutive_mech_F(phases%length)) + allocate(constitutive_mech_F0(phases%length)) + allocate(constitutive_mech_partitionedF0(phases%length)) + allocate(constitutive_mech_Li(phases%length)) + allocate(constitutive_mech_Li0(phases%length)) + allocate(constitutive_mech_partitionedLi0(phases%length)) + allocate(constitutive_mech_partitionedLp0(phases%length)) + allocate(constitutive_mech_Lp0(phases%length)) + allocate(constitutive_mech_Lp(phases%length)) + allocate(constitutive_mech_S(phases%length)) + allocate(constitutive_mech_S0(phases%length)) + allocate(constitutive_mech_partitionedS0(phases%length)) + do ph = 1, phases%length + Nconstituents = count(material_phaseAt == ph) * discretization_nIPs + + allocate(constitutive_mech_Fi(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Fe(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Fi0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_partitionedFi0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Fp(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Fp0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_partitionedFp0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Li(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Li0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_partitionedLi0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_partitionedLp0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Lp0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_Lp(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_S(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(constitutive_mech_S0(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(constitutive_mech_partitionedS0(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(constitutive_mech_F(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_F0(ph)%data(3,3,Nconstituents)) + allocate(constitutive_mech_partitionedF0(ph)%data(3,3,Nconstituents)) + phase => phases%get(ph) mech => phase%get('mechanics') #if defined(__GFORTRAN__) @@ -350,6 +397,33 @@ module subroutine mech_init enddo endif + !$OMP PARALLEL DO PRIVATE(ph,me) + do el = 1, size(material_phaseMemberAt,3); do ip = 1, size(material_phaseMemberAt,2) + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + + ph = material_phaseAt(co,el) + me = material_phaseMemberAt(co,ip,el) + + constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = material_orientation0(co,ip,el)%asMatrix() ! Fp reflects initial orientation (see 10.1016/j.actamat.2006.01.005) + constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) & + / math_det33(constitutive_mech_Fp0(ph)%data(1:3,1:3,me))**(1.0_pReal/3.0_pReal) + constitutive_mech_Fi0(ph)%data(1:3,1:3,me) = math_I3 + constitutive_mech_F0(ph)%data(1:3,1:3,me) = math_I3 + + constitutive_mech_Fe(ph)%data(1:3,1:3,me) = math_inv33(matmul(constitutive_mech_Fi0(ph)%data(1:3,1:3,me), & + constitutive_mech_Fp0(ph)%data(1:3,1:3,me))) ! assuming that euler angles are given in internal strain free configuration + constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) + constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) + constitutive_mech_F(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) + + constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) + constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) + constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) + + enddo + enddo; enddo + !$OMP END PARALLEL DO + ! initialize plasticity allocate(plasticState(phases%length)) From 6a6256dd34e847c89df9776dda9df6147ffc36be Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 29 Dec 2020 21:31:22 +0100 Subject: [PATCH 052/352] separate functionality --- src/CPFEM2.f90 | 28 +++++- src/constitutive.f90 | 173 +++++------------------------------- src/constitutive_mech.f90 | 127 ++++++++++++++++++++++++++ src/homogenization_mech.f90 | 8 +- 4 files changed, 179 insertions(+), 157 deletions(-) diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index 5a500875d..b1e03659b 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -74,9 +74,22 @@ end subroutine CPFEM_initAll !-------------------------------------------------------------------------------------------------- subroutine CPFEM_init + integer(HID_T) :: fileHandle + character(len=pStringLen) :: fileName + + print'(/,a)', ' <<<+- CPFEM init -+>>>'; flush(IO_STDOUT) - if (interface_restartInc > 0) call crystallite_restartRead + + 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) + + call constitutive_restartRead(fileHandle) + + call HDF5_closeFile(fileHandle) + endif end subroutine CPFEM_init @@ -85,8 +98,19 @@ end subroutine CPFEM_init !> @brief Write restart information. !-------------------------------------------------------------------------------------------------- subroutine CPFEM_restartWrite + + integer(HID_T) :: fileHandle + character(len=pStringLen) :: fileName + - call crystallite_restartWrite + 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') + + call constitutive_restartWrite(fileHandle) + + call HDF5_closeFile(fileHandle) end subroutine CPFEM_restartWrite diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 261e9e304..67e8b33c8 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -184,6 +184,15 @@ module constitutive includeL end subroutine mech_restore + module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) + real(pReal), intent(in) :: dt + integer, intent(in) :: & + co, & !< counter in constituent loop + ip, & !< counter in integration point loop + el !< counter in element loop + real(pReal), dimension(3,3,3,3) :: dPdF + end function constitutive_mech_dPdF + ! == cleaned:end =================================================================================== module function crystallite_stress(dt,co,ip,el) result(converged_) @@ -384,16 +393,16 @@ module constitutive converged, & crystallite_init, & crystallite_stress, & - crystallite_stressTangent, & + constitutive_mech_dPdF, & crystallite_orientations, & crystallite_push33ToRef, & - crystallite_restartWrite, & + constitutive_restartWrite, & + constitutive_restartRead, & integrateSourceState, & constitutive_mech_setF, & constitutive_mech_getLp, & constitutive_mech_getF, & constitutive_mech_getS, & - crystallite_restartRead, & constitutive_initializeRestorationPoints, & constitutive_windForward, & PLASTICITY_UNDEFINED_ID, & @@ -975,134 +984,6 @@ subroutine constitutive_windForward(ip,el) end subroutine constitutive_windForward -!-------------------------------------------------------------------------------------------------- -!> @brief Calculate tangent (dPdF). -!-------------------------------------------------------------------------------------------------- -function crystallite_stressTangent(dt,co,ip,el) result(dPdF) - - real(pReal), intent(in) :: dt - integer, intent(in) :: & - co, & !< counter in constituent loop - ip, & !< counter in integration point loop - el !< counter in element loop - real(pReal), dimension(3,3,3,3) :: dPdF - - integer :: & - o, & - p, ph, me - real(pReal), dimension(3,3) :: devNull, & - invSubFp0,invSubFi0,invFp,invFi, & - temp_33_1, temp_33_2, temp_33_3 - real(pReal), dimension(3,3,3,3) :: dSdFe, & - dSdF, & - dSdFi, & - dLidS, & ! tangent in lattice configuration - dLidFi, & - dLpdS, & - dLpdFi, & - dFidS, & - dFpinvdF, & - rhs_3333, & - lhs_3333, & - temp_3333 - real(pReal), dimension(9,9):: temp_99 - logical :: error - - - ph = material_phaseAt(co,el) - me = material_phaseMemberAt(co,ip,el) - - call constitutive_hooke_SandItsTangents(devNull,dSdFe,dSdFi, & - constitutive_mech_Fe(ph)%data(1:3,1:3,me), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) - call constitutive_LiAndItsTangents(devNull,dLidS,dLidFi, & - constitutive_mech_S(ph)%data(1:3,1:3,me), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me), & - co,ip,el) - - invFp = math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me)) - invFi = math_inv33(constitutive_mech_Fi(ph)%data(1:3,1:3,me)) - invSubFp0 = math_inv33(constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me)) - invSubFi0 = math_inv33(constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me)) - - if (sum(abs(dLidS)) < tol_math_check) then - dFidS = 0.0_pReal - else - lhs_3333 = 0.0_pReal; rhs_3333 = 0.0_pReal - do o=1,3; do p=1,3 - lhs_3333(1:3,1:3,o,p) = lhs_3333(1:3,1:3,o,p) & - + matmul(invSubFi0,dLidFi(1:3,1:3,o,p)) * dt - lhs_3333(1:3,o,1:3,p) = lhs_3333(1:3,o,1:3,p) & - + invFi*invFi(p,o) - rhs_3333(1:3,1:3,o,p) = rhs_3333(1:3,1:3,o,p) & - - matmul(invSubFi0,dLidS(1:3,1:3,o,p)) * dt - enddo; enddo - call math_invert(temp_99,error,math_3333to99(lhs_3333)) - if (error) then - call IO_warning(warning_ID=600,el=el,ip=ip,g=co, & - ext_msg='inversion error in analytic tangent calculation') - dFidS = 0.0_pReal - else - dFidS = math_mul3333xx3333(math_99to3333(temp_99),rhs_3333) - endif - dLidS = math_mul3333xx3333(dLidFi,dFidS) + dLidS - endif - - call constitutive_plastic_LpAndItsTangents(devNull,dLpdS,dLpdFi, & - constitutive_mech_S(ph)%data(1:3,1:3,me), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) - dLpdS = math_mul3333xx3333(dLpdFi,dFidS) + dLpdS - -!-------------------------------------------------------------------------------------------------- -! calculate dSdF - temp_33_1 = transpose(matmul(invFp,invFi)) - temp_33_2 = matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invSubFp0) - temp_33_3 = matmul(matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invFp), invSubFi0) - - do o=1,3; do p=1,3 - rhs_3333(p,o,1:3,1:3) = matmul(dSdFe(p,o,1:3,1:3),temp_33_1) - temp_3333(1:3,1:3,p,o) = matmul(matmul(temp_33_2,dLpdS(1:3,1:3,p,o)), invFi) & - + matmul(temp_33_3,dLidS(1:3,1:3,p,o)) - enddo; enddo - lhs_3333 = math_mul3333xx3333(dSdFe,temp_3333) * dt & - + math_mul3333xx3333(dSdFi,dFidS) - - call math_invert(temp_99,error,math_eye(9)+math_3333to99(lhs_3333)) - if (error) then - call IO_warning(warning_ID=600,el=el,ip=ip,g=co, & - ext_msg='inversion error in analytic tangent calculation') - dSdF = rhs_3333 - else - dSdF = math_mul3333xx3333(math_99to3333(temp_99),rhs_3333) - endif - -!-------------------------------------------------------------------------------------------------- -! calculate dFpinvdF - temp_3333 = math_mul3333xx3333(dLpdS,dSdF) - do o=1,3; do p=1,3 - dFpinvdF(1:3,1:3,p,o) = - matmul(invSubFp0, matmul(temp_3333(1:3,1:3,p,o),invFi)) * dt - enddo; enddo - -!-------------------------------------------------------------------------------------------------- -! assemble dPdF - temp_33_1 = matmul(constitutive_mech_S(ph)%data(1:3,1:3,me),transpose(invFp)) - temp_33_2 = matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invFp) - temp_33_3 = matmul(temp_33_2,constitutive_mech_S(ph)%data(1:3,1:3,me)) - - dPdF = 0.0_pReal - do p=1,3 - dPdF(p,1:3,p,1:3) = transpose(matmul(invFp,temp_33_1)) - enddo - do o=1,3; do p=1,3 - dPdF(1:3,1:3,p,o) = dPdF(1:3,1:3,p,o) & - + matmul(matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),dFpinvdF(1:3,1:3,p,o)),temp_33_1) & - + matmul(matmul(temp_33_2,dSdF(1:3,1:3,p,o)),transpose(invFp)) & - + matmul(temp_33_3,transpose(dFpinvdF(1:3,1:3,p,o))) - enddo; enddo - -end function crystallite_stressTangent - - !-------------------------------------------------------------------------------------------------- !> @brief calculates orientations !-------------------------------------------------------------------------------------------------- @@ -1273,16 +1154,12 @@ end function converged !> @brief Write current restart information (Field and constitutive data) to file. ! ToDo: Merge data into one file for MPI, move state to constitutive and homogenization, respectively !-------------------------------------------------------------------------------------------------- -subroutine crystallite_restartWrite +subroutine constitutive_restartWrite(fileHandle) + integer(HID_T), intent(in) :: fileHandle integer :: ph - integer(HID_T) :: fileHandle, groupHandle - character(len=pStringLen) :: fileName, datasetName - - 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') + integer(HID_T) :: groupHandle + character(len=pStringLen) :: datasetName groupHandle = HDF5_addGroup(fileHandle,'phase') do ph = 1,size(material_name_phase) @@ -1310,25 +1187,21 @@ subroutine crystallite_restartWrite enddo call HDF5_closeGroup(groupHandle) - call HDF5_closeFile(fileHandle) -end subroutine crystallite_restartWrite +end subroutine constitutive_restartWrite !-------------------------------------------------------------------------------------------------- !> @brief Read data for restart ! ToDo: Merge data into one file for MPI, move state to constitutive and homogenization, respectively !-------------------------------------------------------------------------------------------------- -subroutine crystallite_restartRead +subroutine constitutive_restartRead(fileHandle) + integer(HID_T), intent(in) :: fileHandle integer :: ph - integer(HID_T) :: fileHandle, groupHandle - character(len=pStringLen) :: fileName, datasetName + integer(HID_T) :: groupHandle + character(len=pStringLen) ::datasetName - print'(/,a,i0,a)', ' reading restart information of increment from file' - - write(fileName,'(a,i0,a)') trim(getSolverJobName())//'_',worldrank,'.hdf5' - fileHandle = HDF5_openFile(fileName) groupHandle = HDF5_openGroup(fileHandle,'phase') do ph = 1,size(material_name_phase) @@ -1356,9 +1229,7 @@ subroutine crystallite_restartRead enddo call HDF5_closeGroup(groupHandle) - call HDF5_closeFile(fileHandle) - -end subroutine crystallite_restartRead +end subroutine constitutive_restartRead ! getter for non-mech (e.g. thermal) diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index fa9a5eda6..6392fb0ee 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1688,5 +1688,132 @@ module subroutine mech_restore(ip,el,includeL) end subroutine mech_restore +!-------------------------------------------------------------------------------------------------- +!> @brief Calculate tangent (dPdF). +!-------------------------------------------------------------------------------------------------- +module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) + + real(pReal), intent(in) :: dt + integer, intent(in) :: & + co, & !< counter in constituent loop + ip, & !< counter in integration point loop + el !< counter in element loop + real(pReal), dimension(3,3,3,3) :: dPdF + + integer :: & + o, & + p, ph, me + real(pReal), dimension(3,3) :: devNull, & + invSubFp0,invSubFi0,invFp,invFi, & + temp_33_1, temp_33_2, temp_33_3 + real(pReal), dimension(3,3,3,3) :: dSdFe, & + dSdF, & + dSdFi, & + dLidS, & ! tangent in lattice configuration + dLidFi, & + dLpdS, & + dLpdFi, & + dFidS, & + dFpinvdF, & + rhs_3333, & + lhs_3333, & + temp_3333 + real(pReal), dimension(9,9):: temp_99 + logical :: error + + + ph = material_phaseAt(co,el) + me = material_phaseMemberAt(co,ip,el) + + call constitutive_hooke_SandItsTangents(devNull,dSdFe,dSdFi, & + constitutive_mech_Fe(ph)%data(1:3,1:3,me), & + constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) + call constitutive_LiAndItsTangents(devNull,dLidS,dLidFi, & + constitutive_mech_S(ph)%data(1:3,1:3,me), & + constitutive_mech_Fi(ph)%data(1:3,1:3,me), & + co,ip,el) + + invFp = math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me)) + invFi = math_inv33(constitutive_mech_Fi(ph)%data(1:3,1:3,me)) + invSubFp0 = math_inv33(constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me)) + invSubFi0 = math_inv33(constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me)) + + if (sum(abs(dLidS)) < tol_math_check) then + dFidS = 0.0_pReal + else + lhs_3333 = 0.0_pReal; rhs_3333 = 0.0_pReal + do o=1,3; do p=1,3 + lhs_3333(1:3,1:3,o,p) = lhs_3333(1:3,1:3,o,p) & + + matmul(invSubFi0,dLidFi(1:3,1:3,o,p)) * dt + lhs_3333(1:3,o,1:3,p) = lhs_3333(1:3,o,1:3,p) & + + invFi*invFi(p,o) + rhs_3333(1:3,1:3,o,p) = rhs_3333(1:3,1:3,o,p) & + - matmul(invSubFi0,dLidS(1:3,1:3,o,p)) * dt + enddo; enddo + call math_invert(temp_99,error,math_3333to99(lhs_3333)) + if (error) then + call IO_warning(warning_ID=600,el=el,ip=ip,g=co, & + ext_msg='inversion error in analytic tangent calculation') + dFidS = 0.0_pReal + else + dFidS = math_mul3333xx3333(math_99to3333(temp_99),rhs_3333) + endif + dLidS = math_mul3333xx3333(dLidFi,dFidS) + dLidS + endif + + call constitutive_plastic_LpAndItsTangents(devNull,dLpdS,dLpdFi, & + constitutive_mech_S(ph)%data(1:3,1:3,me), & + constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) + dLpdS = math_mul3333xx3333(dLpdFi,dFidS) + dLpdS + +!-------------------------------------------------------------------------------------------------- +! calculate dSdF + temp_33_1 = transpose(matmul(invFp,invFi)) + temp_33_2 = matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invSubFp0) + temp_33_3 = matmul(matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invFp), invSubFi0) + + do o=1,3; do p=1,3 + rhs_3333(p,o,1:3,1:3) = matmul(dSdFe(p,o,1:3,1:3),temp_33_1) + temp_3333(1:3,1:3,p,o) = matmul(matmul(temp_33_2,dLpdS(1:3,1:3,p,o)), invFi) & + + matmul(temp_33_3,dLidS(1:3,1:3,p,o)) + enddo; enddo + lhs_3333 = math_mul3333xx3333(dSdFe,temp_3333) * dt & + + math_mul3333xx3333(dSdFi,dFidS) + + call math_invert(temp_99,error,math_eye(9)+math_3333to99(lhs_3333)) + if (error) then + call IO_warning(warning_ID=600,el=el,ip=ip,g=co, & + ext_msg='inversion error in analytic tangent calculation') + dSdF = rhs_3333 + else + dSdF = math_mul3333xx3333(math_99to3333(temp_99),rhs_3333) + endif + +!-------------------------------------------------------------------------------------------------- +! calculate dFpinvdF + temp_3333 = math_mul3333xx3333(dLpdS,dSdF) + do o=1,3; do p=1,3 + dFpinvdF(1:3,1:3,p,o) = - matmul(invSubFp0, matmul(temp_3333(1:3,1:3,p,o),invFi)) * dt + enddo; enddo + +!-------------------------------------------------------------------------------------------------- +! assemble dPdF + temp_33_1 = matmul(constitutive_mech_S(ph)%data(1:3,1:3,me),transpose(invFp)) + temp_33_2 = matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invFp) + temp_33_3 = matmul(temp_33_2,constitutive_mech_S(ph)%data(1:3,1:3,me)) + + dPdF = 0.0_pReal + do p=1,3 + dPdF(p,1:3,p,1:3) = transpose(matmul(invFp,temp_33_1)) + enddo + do o=1,3; do p=1,3 + dPdF(1:3,1:3,p,o) = dPdF(1:3,1:3,p,o) & + + matmul(matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),dFpinvdF(1:3,1:3,p,o)),temp_33_1) & + + matmul(matmul(temp_33_2,dSdF(1:3,1:3,p,o)),transpose(invFp)) & + + matmul(temp_33_3,transpose(dFpinvdF(1:3,1:3,p,o))) + enddo; enddo + +end function constitutive_mech_dPdF + end submodule constitutive_mech diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index 4a9e1856f..1d0942f3e 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -156,11 +156,11 @@ module subroutine mech_homogenize(dt,ip,el) case (HOMOGENIZATION_NONE_ID) chosenHomogenization homogenization_P(1:3,1:3,ce) = crystallite_P(1:3,1:3,1,ip,el) - homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = crystallite_stressTangent(dt,1,ip,el) + homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = constitutive_mech_dPdF(dt,1,ip,el) case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = crystallite_stressTangent(dt,co,ip,el) + dPdFs(:,:,:,:,co) = constitutive_mech_dPdF(dt,co,ip,el) enddo call mech_isostrain_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & @@ -171,7 +171,7 @@ module subroutine mech_homogenize(dt,ip,el) case (HOMOGENIZATION_RGC_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = crystallite_stressTangent(dt,co,ip,el) + dPdFs(:,:,:,:,co) = constitutive_mech_dPdF(dt,co,ip,el) enddo call mech_RGC_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & @@ -207,7 +207,7 @@ module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) if (homogenization_type(material_homogenizationAt(el)) == HOMOGENIZATION_RGC_ID) then do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = crystallite_stressTangent(subdt,co,ip,el) + dPdFs(:,:,:,:,co) = constitutive_mech_dPdF(subdt,co,ip,el) Fs(:,:,co) = constitutive_mech_getF(co,ip,el) enddo doneAndHappy = & From 9ce932a082fc5e78f690ff2dd69da38e422a760d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 30 Dec 2020 00:14:48 +0100 Subject: [PATCH 053/352] distributing tasks --- src/CPFEM2.f90 | 10 ++-- src/constitutive.f90 | 103 ++++++++++++++++---------------------- src/constitutive_mech.f90 | 60 ++++++++++++++++------ src/homogenization.f90 | 60 +++++++++++++++++++++- 4 files changed, 152 insertions(+), 81 deletions(-) diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index b1e03659b..e696858cf 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -76,8 +76,8 @@ subroutine CPFEM_init integer(HID_T) :: fileHandle character(len=pStringLen) :: fileName - - + + print'(/,a)', ' <<<+- CPFEM init -+>>>'; flush(IO_STDOUT) @@ -86,6 +86,7 @@ subroutine CPFEM_init write(fileName,'(a,i0,a)') trim(getSolverJobName())//'_',worldrank,'.hdf5' fileHandle = HDF5_openFile(fileName) + call homogenization_restartRead(fileHandle) call constitutive_restartRead(fileHandle) call HDF5_closeFile(fileHandle) @@ -98,16 +99,17 @@ end subroutine CPFEM_init !> @brief Write restart information. !-------------------------------------------------------------------------------------------------- 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') + call homogenization_restartWrite(fileHandle) call constitutive_restartWrite(fileHandle) call HDF5_closeFile(fileHandle) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 67e8b33c8..5dd415a47 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -15,7 +15,6 @@ module constitutive use discretization use parallelization use HDF5_utilities - use DAMASK_interface use results implicit none @@ -161,10 +160,6 @@ module constitutive end subroutine damage_results - module subroutine mech_restart_read(fileHandle) - integer(HID_T), intent(in) :: fileHandle - end subroutine mech_restart_read - module subroutine mech_initializeRestorationPoints(ph,me) integer, intent(in) :: ph, me end subroutine mech_initializeRestorationPoints @@ -193,6 +188,16 @@ module constitutive real(pReal), dimension(3,3,3,3) :: dPdF end function constitutive_mech_dPdF + module subroutine mech_restartWrite(groupHandle,ph) + integer(HID_T), intent(in) :: groupHandle + integer, intent(in) :: ph + end subroutine mech_restartWrite + + module subroutine mech_restartRead(groupHandle,ph) + integer(HID_T), intent(in) :: groupHandle + integer, intent(in) :: ph + end subroutine mech_restartRead + ! == cleaned:end =================================================================================== module function crystallite_stress(dt,co,ip,el) result(converged_) @@ -798,7 +803,7 @@ subroutine constitutive_forward integer :: ph, so - + call constitutive_mech_forward() do ph = 1, size(sourceState) @@ -1017,7 +1022,7 @@ function crystallite_push33ToRef(co,ip,el, tensor33) ip, & co real(pReal), dimension(3,3) :: crystallite_push33ToRef - + real(pReal), dimension(3,3) :: T @@ -1152,82 +1157,58 @@ end function converged !-------------------------------------------------------------------------------------------------- !> @brief Write current restart information (Field and constitutive data) to file. -! ToDo: Merge data into one file for MPI, move state to constitutive and homogenization, respectively +! ToDo: Merge data into one file for MPI !-------------------------------------------------------------------------------------------------- subroutine constitutive_restartWrite(fileHandle) integer(HID_T), intent(in) :: fileHandle + + integer(HID_T), dimension(2) :: groupHandle integer :: ph - integer(HID_T) :: groupHandle - character(len=pStringLen) :: datasetName - groupHandle = HDF5_addGroup(fileHandle,'phase') - do ph = 1,size(material_name_phase) - write(datasetName,'(i0,a)') ph,'_omega' - call HDF5_write(groupHandle,plasticState(ph)%state,datasetName) - write(datasetName,'(i0,a)') ph,'_F_i' - call HDF5_write(groupHandle,constitutive_mech_Fi(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_L_i' - call HDF5_write(groupHandle,constitutive_mech_Li(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_L_p' - call HDF5_write(groupHandle,constitutive_mech_Lp(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_F_p' - call HDF5_write(groupHandle,constitutive_mech_Fp(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_S' - call HDF5_write(groupHandle,constitutive_mech_S(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_F' - call HDF5_write(groupHandle,constitutive_mech_F(ph)%data,datasetName) + + groupHandle(1) = HDF5_addGroup(fileHandle,'phase') + + do ph = 1, size(material_name_phase) + + groupHandle(2) = HDF5_addGroup(groupHandle(1),material_name_phase(ph)) + + call mech_restartWrite(groupHandle(2),ph) + + call HDF5_closeGroup(groupHandle(2)) + enddo - call HDF5_closeGroup(groupHandle) - - groupHandle = HDF5_addGroup(fileHandle,'homogenization') - do ph = 1, size(material_name_homogenization) - write(datasetName,'(i0,a)') ph,'_omega' - call HDF5_write(groupHandle,homogState(ph)%state,datasetName) - enddo - call HDF5_closeGroup(groupHandle) + call HDF5_closeGroup(groupHandle(1)) end subroutine constitutive_restartWrite !-------------------------------------------------------------------------------------------------- !> @brief Read data for restart -! ToDo: Merge data into one file for MPI, move state to constitutive and homogenization, respectively +! ToDo: Merge data into one file for MPI !-------------------------------------------------------------------------------------------------- subroutine constitutive_restartRead(fileHandle) integer(HID_T), intent(in) :: fileHandle + + integer(HID_T), dimension(2) :: groupHandle integer :: ph - integer(HID_T) :: groupHandle - character(len=pStringLen) ::datasetName - groupHandle = HDF5_openGroup(fileHandle,'phase') - do ph = 1,size(material_name_phase) - write(datasetName,'(i0,a)') ph,'_omega' - call HDF5_read(groupHandle,plasticState(ph)%state0,datasetName) - write(datasetName,'(i0,a)') ph,'_F_i' - call HDF5_read(groupHandle,constitutive_mech_Fi0(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_L_i' - call HDF5_read(groupHandle,constitutive_mech_Li0(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_L_p' - call HDF5_read(groupHandle,constitutive_mech_Lp0(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_F_p' - call HDF5_read(groupHandle,constitutive_mech_Fp0(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_S' - call HDF5_read(groupHandle,constitutive_mech_S0(ph)%data,datasetName) - write(datasetName,'(i0,a)') ph,'_F' - call HDF5_read(groupHandle,constitutive_mech_F0(ph)%data,datasetName) + groupHandle(1) = HDF5_openGroup(fileHandle,'phase') + + do ph = 1, size(material_name_phase) + + groupHandle(2) = HDF5_openGroup(groupHandle(1),material_name_phase(ph)) + + call mech_restartRead(groupHandle(2),ph) + + call HDF5_closeGroup(groupHandle(2)) + enddo - call HDF5_closeGroup(groupHandle) - groupHandle = HDF5_openGroup(fileHandle,'homogenization') - do ph = 1,size(material_name_homogenization) - write(datasetName,'(i0,a)') ph,'_omega' - call HDF5_read(groupHandle,homogState(ph)%state0,datasetName) - enddo - call HDF5_closeGroup(groupHandle) + call HDF5_closeGroup(groupHandle(1)) end subroutine constitutive_restartRead @@ -1273,7 +1254,7 @@ function constitutive_thermal_T(co,ip,el) result(T) integer, intent(in) :: co, ip, el real(pReal) :: T - + integer :: ho, tme ho = material_homogenizationAt(el) diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 6392fb0ee..cdf3d7ea5 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -364,7 +364,7 @@ module subroutine mech_init allocate(constitutive_mech_F(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_F0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_partitionedF0(ph)%data(3,3,Nconstituents)) - + phase => phases%get(ph) mech => phase%get('mechanics') #if defined(__GFORTRAN__) @@ -403,13 +403,13 @@ module subroutine mech_init ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - + constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = material_orientation0(co,ip,el)%asMatrix() ! Fp reflects initial orientation (see 10.1016/j.actamat.2006.01.005) constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) & / math_det33(constitutive_mech_Fp0(ph)%data(1:3,1:3,me))**(1.0_pReal/3.0_pReal) constitutive_mech_Fi0(ph)%data(1:3,1:3,me) = math_I3 constitutive_mech_F0(ph)%data(1:3,1:3,me) = math_I3 - + constitutive_mech_Fe(ph)%data(1:3,1:3,me) = math_inv33(matmul(constitutive_mech_Fi0(ph)%data(1:3,1:3,me), & constitutive_mech_Fp0(ph)%data(1:3,1:3,me))) ! assuming that euler angles are given in internal strain free configuration constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) @@ -568,16 +568,16 @@ module subroutine constitutive_plastic_dependentState(co, ip, el) instance = phase_plasticityInstance(material_phaseAt(co,el)) plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) - + case (PLASTICITY_DISLOTWIN_ID) plasticityType call plastic_dislotwin_dependentState(temperature(ho)%p(tme),instance,me) - + case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType call plastic_dislotungsten_dependentState(instance,me) - + case (PLASTICITY_NONLOCAL_ID) plasticityType call plastic_nonlocal_dependentState(instance,me,ip,el) - + end select plasticityType end subroutine constitutive_plastic_dependentState @@ -675,7 +675,7 @@ function mech_collectDotState(subdt,co,ip,el,ph,of) result(broken) tme, & !< thermal member position instance logical :: broken - + ho = material_homogenizationAt(el) tme = material_homogenizationMemberAt(ip,el) instance = phase_plasticityInstance(ph) @@ -723,14 +723,14 @@ function constitutive_deltaState(co, ip, el, ph, of) result(broken) of logical :: & broken - + real(pReal), dimension(3,3) :: & Mp integer :: & instance, & myOffset, & mySize - + Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,of)),& constitutive_mech_Fi(ph)%data(1:3,1:3,of)),constitutive_mech_S(ph)%data(1:3,1:3,of)) @@ -799,10 +799,6 @@ module subroutine mech_results(group,ph) end subroutine mech_results - module subroutine mech_restart_read(fileHandle) - integer(HID_T), intent(in) :: fileHandle - end subroutine mech_restart_read - !-------------------------------------------------------------------------------------------------- !> @brief calculation of stress (P) with time integration based on a residuum in Lp and @@ -874,7 +870,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - + call constitutive_plastic_dependentState(co,ip,el) Lpguess = constitutive_mech_Lp(ph)%data(1:3,1:3,me) ! take as first guess @@ -1815,5 +1811,39 @@ module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) end function constitutive_mech_dPdF + +module subroutine mech_restartWrite(groupHandle,ph) + + integer(HID_T), intent(in) :: groupHandle + integer, intent(in) :: ph + + + call HDF5_write(groupHandle,plasticState(ph)%state,'omega') + call HDF5_write(groupHandle,constitutive_mech_Fi(ph)%data,'F_i') + call HDF5_write(groupHandle,constitutive_mech_Li(ph)%data,'L_i') + call HDF5_write(groupHandle,constitutive_mech_Lp(ph)%data,'L_p') + call HDF5_write(groupHandle,constitutive_mech_Fp(ph)%data,'F_p') + call HDF5_write(groupHandle,constitutive_mech_S(ph)%data,'S') + call HDF5_write(groupHandle,constitutive_mech_F(ph)%data,'F') + +end subroutine mech_restartWrite + + +module subroutine mech_restartRead(groupHandle,ph) + + integer(HID_T), intent(in) :: groupHandle + integer, intent(in) :: ph + + + call HDF5_read(groupHandle,plasticState(ph)%state0,'omega') + call HDF5_read(groupHandle,constitutive_mech_Fi0(ph)%data,'F_i') + call HDF5_read(groupHandle,constitutive_mech_Li0(ph)%data,'L_i') + call HDF5_read(groupHandle,constitutive_mech_Lp0(ph)%data,'L_p') + call HDF5_read(groupHandle,constitutive_mech_Fp0(ph)%data,'F_p') + call HDF5_read(groupHandle,constitutive_mech_S0(ph)%data,'S') + call HDF5_read(groupHandle,constitutive_mech_F0(ph)%data,'F') + +end subroutine mech_restartRead + end submodule constitutive_mech diff --git a/src/homogenization.f90 b/src/homogenization.f90 index e31089177..686bb9885 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -16,6 +16,7 @@ module homogenization use thermal_conduction use damage_none use damage_nonlocal + use HDF5_utilities use results implicit none @@ -92,7 +93,9 @@ module homogenization homogenization_init, & materialpoint_stressAndItsTangent, & homogenization_forward, & - homogenization_results + homogenization_results, & + homogenization_restartRead, & + homogenization_restartWrite contains @@ -315,4 +318,59 @@ subroutine homogenization_forward end subroutine homogenization_forward + +!-------------------------------------------------------------------------------------------------- +!-------------------------------------------------------------------------------------------------- +subroutine homogenization_restartWrite(fileHandle) + + integer(HID_T), intent(in) :: fileHandle + + integer(HID_T), dimension(2) :: groupHandle + integer :: ho + + + groupHandle(1) = HDF5_addGroup(fileHandle,'homogenization') + + do ho = 1, size(material_name_homogenization) + + 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_closeGroup(groupHandle(2)) + + enddo + + call HDF5_closeGroup(groupHandle(1)) + +end subroutine homogenization_restartWrite + + +!-------------------------------------------------------------------------------------------------- +!-------------------------------------------------------------------------------------------------- +subroutine homogenization_restartRead(fileHandle) + + integer(HID_T), intent(in) :: fileHandle + + integer(HID_T), dimension(2) :: groupHandle + integer :: ho + + + groupHandle(1) = HDF5_openGroup(fileHandle,'homogenization') + + do ho = 1, size(material_name_homogenization) + + 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_closeGroup(groupHandle(2)) + + enddo + + call HDF5_closeGroup(groupHandle(1)) + +end subroutine homogenization_restartRead + + end module homogenization From 9d09721689bdeab5d72b742bbdc124be546f1541 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 30 Dec 2020 09:54:06 +0100 Subject: [PATCH 054/352] keep variables local --- src/constitutive.f90 | 127 ++++++++++------------------------- src/constitutive_mech.f90 | 84 +++++++++++++++++++++++ src/constitutive_thermal.f90 | 24 ++++++- 3 files changed, 140 insertions(+), 95 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 5dd415a47..29fca2b33 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -51,31 +51,6 @@ module constitutive real(pReal), dimension(:,:,:), allocatable :: data end type - type(tTensorContainer), dimension(:), allocatable :: & - ! current value - constitutive_mech_Fe, & - constitutive_mech_Fi, & - constitutive_mech_Fp, & - constitutive_mech_F, & - constitutive_mech_Li, & - constitutive_mech_Lp, & - constitutive_mech_S, & - ! converged value at end of last solver increment - constitutive_mech_Fi0, & - constitutive_mech_Fp0, & - constitutive_mech_F0, & - constitutive_mech_Li0, & - constitutive_mech_Lp0, & - constitutive_mech_S0, & - ! converged value at end of last homogenization increment (RGC only) - constitutive_mech_partitionedFi0, & - constitutive_mech_partitionedFp0, & - constitutive_mech_partitionedF0, & - constitutive_mech_partitionedLi0, & - constitutive_mech_partitionedLp0, & - constitutive_mech_partitionedS0 - - type :: tNumerics integer :: & iJacoLpresiduum, & !< frequency of Jacobian update of residuum in Lp @@ -198,6 +173,37 @@ module constitutive integer, intent(in) :: ph end subroutine mech_restartRead + + module function constitutive_mech_getS(co,ip,el) result(S) + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: S + end function constitutive_mech_getS + + module function constitutive_mech_getLp(co,ip,el) result(Lp) + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: Lp + end function constitutive_mech_getLp + + module function constitutive_mech_getF(co,ip,el) result(F) + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: F + end function constitutive_mech_getF + + module function constitutive_mech_getF_e(co,ip,el) result(F_e) + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: F_e + end function constitutive_mech_getF_e + + module function constitutive_thermal_T(co,ip,el) result(T) + integer, intent(in) :: co, ip, el + real(pReal) :: T + end function constitutive_thermal_T + + module subroutine constitutive_mech_setF(F,co,ip,el) + real(pReal), dimension(3,3), intent(in) :: F + integer, intent(in) :: co, ip, el + end subroutine constitutive_mech_setF + ! == cleaned:end =================================================================================== module function crystallite_stress(dt,co,ip,el) result(converged_) @@ -1001,7 +1007,7 @@ subroutine crystallite_orientations(co,ip,el) call crystallite_orientation(co,ip,el)%fromMatrix(transpose(math_rotationalPart(& - constitutive_mech_Fe(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el))))) + constitutive_mech_getF_e(co,ip,el)))) if (plasticState(material_phaseAt(1,el))%nonlocal) & call plastic_nonlocal_updateCompatibility(crystallite_orientation, & @@ -1026,8 +1032,8 @@ function crystallite_push33ToRef(co,ip,el, tensor33) real(pReal), dimension(3,3) :: T - T = matmul(material_orientation0(co,ip,el)%asMatrix(), & ! ToDo: initial orientation correct? - transpose(math_inv33(constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el))))) + T = matmul(material_orientation0(co,ip,el)%asMatrix(),transpose(math_inv33(constitutive_mech_getF(co,ip,el)))) ! ToDo: initial orientation correct? + crystallite_push33ToRef = matmul(transpose(T),matmul(tensor33,T)) end function crystallite_push33ToRef @@ -1104,7 +1110,7 @@ function integrateSourceState(dt,co,ip,el) result(broken) enddo if(converged_) then - broken = constitutive_damage_deltaState(constitutive_mech_Fe(ph)%data(1:3,1:3,me),co,ip,el,ph,me) + broken = constitutive_damage_deltaState(constitutive_mech_getF_e(co,ip,el),co,ip,el,ph,me) exit iteration endif @@ -1213,67 +1219,4 @@ subroutine constitutive_restartRead(fileHandle) end subroutine constitutive_restartRead -! getter for non-mech (e.g. thermal) -function constitutive_mech_getS(co,ip,el) result(S) - - integer, intent(in) :: co, ip, el - real(pReal), dimension(3,3) :: S - - - S = constitutive_mech_S(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) - -end function constitutive_mech_getS - - -! getter for non-mech (e.g. thermal) -function constitutive_mech_getLp(co,ip,el) result(Lp) - - integer, intent(in) :: co, ip, el - real(pReal), dimension(3,3) :: Lp - - - Lp = constitutive_mech_Lp(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) - -end function constitutive_mech_getLp - - -! getter for non-mech (e.g. thermal) -function constitutive_mech_getF(co,ip,el) result(F) - - integer, intent(in) :: co, ip, el - real(pReal), dimension(3,3) :: F - - - F = constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) - -end function constitutive_mech_getF - - -! getter for non-thermal (e.g. mech) -function constitutive_thermal_T(co,ip,el) result(T) - - integer, intent(in) :: co, ip, el - real(pReal) :: T - - integer :: ho, tme - - ho = material_homogenizationAt(el) - tme = material_homogenizationMemberAt(ip,el) - - T = temperature(ho)%p(tme) - -end function constitutive_thermal_T - - -! setter for homogenization -subroutine constitutive_mech_setF(F,co,ip,el) - - real(pReal), dimension(3,3), intent(in) :: F - integer, intent(in) :: co, ip, el - - - constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) = F - -end subroutine constitutive_mech_setF - end module constitutive diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index cdf3d7ea5..a1256a15d 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -15,6 +15,30 @@ submodule(constitutive) constitutive_mech integer(kind(SOURCE_undefined_ID)), dimension(:,:), allocatable :: & phase_stiffnessDegradation !< active stiffness degradation mechanisms of each phase + type(tTensorContainer), dimension(:), allocatable :: & + ! current value + constitutive_mech_Fe, & + constitutive_mech_Fi, & + constitutive_mech_Fp, & + constitutive_mech_F, & + constitutive_mech_Li, & + constitutive_mech_Lp, & + constitutive_mech_S, & + ! converged value at end of last solver increment + constitutive_mech_Fi0, & + constitutive_mech_Fp0, & + constitutive_mech_F0, & + constitutive_mech_Li0, & + constitutive_mech_Lp0, & + constitutive_mech_S0, & + ! converged value at end of last homogenization increment (RGC only) + constitutive_mech_partitionedFi0, & + constitutive_mech_partitionedFp0, & + constitutive_mech_partitionedF0, & + constitutive_mech_partitionedLi0, & + constitutive_mech_partitionedLp0, & + constitutive_mech_partitionedS0 + interface @@ -1845,5 +1869,65 @@ module subroutine mech_restartRead(groupHandle,ph) end subroutine mech_restartRead + +! getter for non-mech (e.g. thermal) +module function constitutive_mech_getS(co,ip,el) result(S) + + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: S + + + S = constitutive_mech_S(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + +end function constitutive_mech_getS + + +! getter for non-mech (e.g. thermal) +module function constitutive_mech_getLp(co,ip,el) result(Lp) + + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: Lp + + + Lp = constitutive_mech_Lp(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + +end function constitutive_mech_getLp + + +! getter for non-mech (e.g. thermal) +module function constitutive_mech_getF(co,ip,el) result(F) + + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: F + + + F = constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + +end function constitutive_mech_getF + + +! getter for non-mech (e.g. thermal) +module function constitutive_mech_getF_e(co,ip,el) result(F_e) + + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: F_e + + + F_e = constitutive_mech_Fe(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + +end function constitutive_mech_getF_e + + +! setter for homogenization +module subroutine constitutive_mech_setF(F,co,ip,el) + + real(pReal), dimension(3,3), intent(in) :: F + integer, intent(in) :: co, ip, el + + + constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) = F + +end subroutine constitutive_mech_setF + end submodule constitutive_mech diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 1e204a197..1a05b983f 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -9,7 +9,7 @@ submodule(constitutive) constitutive_thermal integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources end function source_thermal_dissipation_init - + module function source_thermal_externalheat_init(source_length) result(mySources) integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources @@ -55,8 +55,8 @@ module subroutine thermal_init if(maxval(phase_Nsources) /= 0) then where(source_thermal_dissipation_init (maxval(phase_Nsources))) phase_source = SOURCE_thermal_dissipation_ID where(source_thermal_externalheat_init(maxval(phase_Nsources))) phase_source = SOURCE_thermal_externalheat_ID - endif - + endif + !-------------------------------------------------------------------------------------------------- !initialize kinematic mechanisms if(maxval(phase_Nkinematics) /= 0) where(kinematics_thermal_expansion_init(maxval(phase_Nkinematics))) & @@ -121,4 +121,22 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, end subroutine constitutive_thermal_getRateAndItsTangents + + +! getter for non-thermal (e.g. mech) +module function constitutive_thermal_T(co,ip,el) result(T) + + integer, intent(in) :: co, ip, el + real(pReal) :: T + + integer :: ho, tme + + ho = material_homogenizationAt(el) + tme = material_homogenizationMemberAt(ip,el) + + T = temperature(ho)%p(tme) + +end function constitutive_thermal_T + + end submodule constitutive_thermal From dd23bec9aa9c1a3c32f2907c728a645bf1038858 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 30 Dec 2020 11:03:13 +0100 Subject: [PATCH 055/352] avoid global variables --- src/constitutive.f90 | 9 ++++-- src/constitutive_mech.f90 | 62 +++++++++++++++---------------------- src/homogenization_mech.f90 | 24 ++++++-------- 3 files changed, 41 insertions(+), 54 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 29fca2b33..667a23127 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -44,8 +44,6 @@ module constitutive type(rotation), dimension(:,:,:), allocatable :: & crystallite_orientation !< current orientation - real(pReal), dimension(:,:,:,:,:), allocatable, public :: & - crystallite_P !< 1st Piola-Kirchhoff stress per grain type :: tTensorContainer real(pReal), dimension(:,:,:), allocatable :: data @@ -194,6 +192,11 @@ module constitutive real(pReal), dimension(3,3) :: F_e end function constitutive_mech_getF_e + module function constitutive_mech_getP(co,ip,el) result(P) + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: P + end function constitutive_mech_getP + module function constitutive_thermal_T(co,ip,el) result(T) integer, intent(in) :: co, ip, el real(pReal) :: T @@ -411,6 +414,7 @@ module constitutive constitutive_restartRead, & integrateSourceState, & constitutive_mech_setF, & + constitutive_mech_getP, & constitutive_mech_getLp, & constitutive_mech_getF, & constitutive_mech_getS, & @@ -877,7 +881,6 @@ subroutine crystallite_init iMax = discretization_nIPs eMax = discretization_Nelems - allocate(crystallite_P(3,3,cMax,iMax,eMax),source=0.0_pReal) allocate(crystallite_orientation(cMax,iMax,eMax)) num_crystallite => config_numerics%get('crystallite',defaultVal=emptyDict) diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index a1256a15d..f5a5cd0a2 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -24,6 +24,7 @@ submodule(constitutive) constitutive_mech constitutive_mech_Li, & constitutive_mech_Lp, & constitutive_mech_S, & + constitutive_mech_P, & ! converged value at end of last solver increment constitutive_mech_Fi0, & constitutive_mech_Fp0, & @@ -363,6 +364,7 @@ module subroutine mech_init allocate(constitutive_mech_Lp0(phases%length)) allocate(constitutive_mech_Lp(phases%length)) allocate(constitutive_mech_S(phases%length)) + allocate(constitutive_mech_P(phases%length)) allocate(constitutive_mech_S0(phases%length)) allocate(constitutive_mech_partitionedS0(phases%length)) @@ -383,6 +385,7 @@ module subroutine mech_init allocate(constitutive_mech_Lp0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Lp(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_S(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(constitutive_mech_P(ph)%data(3,3,Nconstituents),source=0.0_pReal) allocate(constitutive_mech_S0(ph)%data(3,3,Nconstituents),source=0.0_pReal) allocate(constitutive_mech_partitionedS0(ph)%data(3,3,Nconstituents),source=0.0_pReal) allocate(constitutive_mech_F(ph)%data(3,3,Nconstituents)) @@ -1027,7 +1030,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) call math_invert33(Fp_new,devNull,error,invFp_new) if (error) return ! error - crystallite_P (1:3,1:3,co,ip,el) = matmul(matmul(F,invFp_new),matmul(S,transpose(invFp_new))) + constitutive_mech_P(ph)%data(1:3,1:3,me) = matmul(matmul(F,invFp_new),matmul(S,transpose(invFp_new))) constitutive_mech_S(ph)%data(1:3,1:3,me) = S constitutive_mech_Lp(ph)%data(1:3,1:3,me) = Lpguess constitutive_mech_Li(ph)%data(1:3,1:3,me) = Liguess @@ -1381,29 +1384,28 @@ subroutine crystallite_results(group,ph) select case (output_constituent(ph)%label(ou)) case('F') - call results_writeDataset(group//'/mechanics/',constitutive_mech_F(ph)%data,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_F(ph)%data,'F',& 'deformation gradient','1') case('F_e') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Fe(ph)%data,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_Fe(ph)%data,'F_e',& 'elastic deformation gradient','1') case('F_p') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Fp(ph)%data,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_Fp(ph)%data,'F_p', & 'plastic deformation gradient','1') case('F_i') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Fi(ph)%data,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_Fi(ph)%data,'F_i', & 'inelastic deformation gradient','1') case('L_p') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Lp(ph)%data,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_Lp(ph)%data,'L_p', & 'plastic velocity gradient','1/s') case('L_i') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Li(ph)%data,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_Li(ph)%data,'L_i', & 'inelastic velocity gradient','1/s') case('P') - selected_tensors = select_tensors(crystallite_P,ph) - call results_writeDataset(group//'/mechanics/',selected_tensors,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_P(ph)%data,'P', & 'First Piola-Kirchhoff stress','Pa') case('S') - call results_writeDataset(group//'/mechanics/',constitutive_mech_S(ph)%data,output_constituent(ph)%label(ou),& + call results_writeDataset(group//'/mechanics/',constitutive_mech_S(ph)%data,'S', & 'Second Piola-Kirchhoff stress','Pa') case('O') select case(lattice_structure(ph)) @@ -1430,33 +1432,6 @@ subroutine crystallite_results(group,ph) contains - !------------------------------------------------------------------------------------------------ - !> @brief select tensors for output - !------------------------------------------------------------------------------------------------ - function select_tensors(dataset,ph) - - integer, intent(in) :: ph - real(pReal), dimension(:,:,:,:,:), intent(in) :: dataset - real(pReal), allocatable, dimension(:,:,:) :: select_tensors - integer :: el,ip,co,j - - allocate(select_tensors(3,3,count(material_phaseAt==ph)*discretization_nIPs)) - - j=0 - do el = 1, size(material_phaseAt,2) - do ip = 1, discretization_nIPs - do co = 1, size(material_phaseAt,1) !ToDo: this needs to be changed for varying Ngrains - if (material_phaseAt(co,el) == ph) then - j = j + 1 - select_tensors(1:3,1:3,j) = dataset(1:3,1:3,co,ip,el) - endif - enddo - enddo - enddo - - end function select_tensors - - !-------------------------------------------------------------------------------------------------- !> @brief select rotations for output !-------------------------------------------------------------------------------------------------- @@ -1918,6 +1893,19 @@ module function constitutive_mech_getF_e(co,ip,el) result(F_e) end function constitutive_mech_getF_e + +! getter for non-mech (e.g. thermal) +module function constitutive_mech_getP(co,ip,el) result(P) + + integer, intent(in) :: co, ip, el + real(pReal), dimension(3,3) :: P + + + P = constitutive_mech_P(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + +end function constitutive_mech_getP + + ! setter for homogenization module subroutine constitutive_mech_setF(F,co,ip,el) diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index 1d0942f3e..783d08dd1 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -111,7 +111,7 @@ module subroutine mech_partition(subF,ip,el) integer, intent(in) :: & ip, & !< integration point el !< element number - + integer :: co real(pReal) :: F(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) @@ -149,35 +149,36 @@ module subroutine mech_homogenize(dt,ip,el) integer :: co,ce real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) + real(pReal) :: Ps(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) ce = (el-1)* discretization_nIPs + ip chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) case (HOMOGENIZATION_NONE_ID) chosenHomogenization - homogenization_P(1:3,1:3,ce) = crystallite_P(1:3,1:3,1,ip,el) + homogenization_P(1:3,1:3,ce) = constitutive_mech_getP(1,ip,el) homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = constitutive_mech_dPdF(dt,1,ip,el) case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) dPdFs(:,:,:,:,co) = constitutive_mech_dPdF(dt,co,ip,el) + Ps(:,:,co) = constitutive_mech_getP(co,ip,el) enddo call mech_isostrain_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& - crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - dPdFs, & + Ps,dPdFs, & homogenization_typeInstance(material_homogenizationAt(el))) case (HOMOGENIZATION_RGC_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) dPdFs(:,:,:,:,co) = constitutive_mech_dPdF(dt,co,ip,el) + Ps(:,:,co) = constitutive_mech_getP(co,ip,el) enddo call mech_RGC_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& - crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - dPdFs, & + Ps,dPdFs, & homogenization_typeInstance(material_homogenizationAt(el))) end select chosenHomogenization @@ -203,21 +204,16 @@ module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) integer :: co real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) real(pReal) :: Fs(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) + real(pReal) :: Ps(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) if (homogenization_type(material_homogenizationAt(el)) == HOMOGENIZATION_RGC_ID) then do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) dPdFs(:,:,:,:,co) = constitutive_mech_dPdF(subdt,co,ip,el) Fs(:,:,co) = constitutive_mech_getF(co,ip,el) + Ps(:,:,co) = constitutive_mech_getP(co,ip,el) enddo - doneAndHappy = & - mech_RGC_updateState(crystallite_P(1:3,1:3,1:homogenization_Nconstituents(material_homogenizationAt(el)),ip,el), & - Fs, & - subF,& - subdt, & - dPdFs, & - ip, & - el) + doneAndHappy = mech_RGC_updateState(Ps,Fs,subF,subdt,dPdFs,ip,el) else doneAndHappy = .true. endif From 0dac5f84ef15259016f66a4d0f1e9e7ce14d3dfb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 30 Dec 2020 12:00:47 +0100 Subject: [PATCH 056/352] dummy data layout --- src/constitutive.f90 | 7 +++++++ src/constitutive_thermal.f90 | 7 +++++++ src/homogenization.f90 | 5 +++++ src/homogenization_thermal.f90 | 37 ++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 src/homogenization_thermal.f90 diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 667a23127..36400fca7 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -202,11 +202,17 @@ module constitutive real(pReal) :: T end function constitutive_thermal_T + module subroutine constitutive_mech_setF(F,co,ip,el) real(pReal), dimension(3,3), intent(in) :: F integer, intent(in) :: co, ip, el end subroutine constitutive_mech_setF + module subroutine constitutive_thermal_setT(T,co,ip,el) + real(pReal), intent(in) :: T + integer, intent(in) :: co, ip, el + end subroutine constitutive_thermal_setT + ! == cleaned:end =================================================================================== module function crystallite_stress(dt,co,ip,el) result(converged_) @@ -414,6 +420,7 @@ module constitutive constitutive_restartRead, & integrateSourceState, & constitutive_mech_setF, & + constitutive_thermal_setT, & constitutive_mech_getP, & constitutive_mech_getLp, & constitutive_mech_getF, & diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 1a05b983f..01d517124 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -139,4 +139,11 @@ module function constitutive_thermal_T(co,ip,el) result(T) end function constitutive_thermal_T +! setter for homogenization +module subroutine constitutive_thermal_setT(T,co,ip,el) + real(pReal), intent(in) :: T + integer, intent(in) :: co, ip, el +end subroutine constitutive_thermal_setT + + end submodule constitutive_thermal diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 686bb9885..df7369096 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -27,6 +27,8 @@ module homogenization !-------------------------------------------------------------------------------------------------- ! General variables for the homogenization at a material point + real(pReal), dimension(:), allocatable, public :: & + homogenization_T real(pReal), dimension(:,:,:), allocatable, public :: & homogenization_F0, & !< def grad of IP at start of FE increment homogenization_F !< def grad of IP to be reached at end of FE increment @@ -56,6 +58,9 @@ module homogenization num_homog !< pointer to mechanical homogenization numerics data end subroutine mech_init + module subroutine thermal_init + end subroutine thermal_init + module subroutine mech_partition(subF,ip,el) real(pReal), intent(in), dimension(3,3) :: & subF diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 new file mode 100644 index 000000000..59e7357b6 --- /dev/null +++ b/src/homogenization_thermal.f90 @@ -0,0 +1,37 @@ +!-------------------------------------------------------------------------------------------------- +!> @author Martin Diehl, KU Leuven +!-------------------------------------------------------------------------------------------------- +submodule(homogenization) homogenization_thermal + + +contains + +!-------------------------------------------------------------------------------------------------- +!> @brief Allocate variables and set parameters. +!-------------------------------------------------------------------------------------------------- +module subroutine thermal_init() + + print'(/,a)', ' <<<+- homogenization_thermal init -+>>>' + + allocate(homogenization_T(discretization_nIPs*discretization_Nelems), source=0.0_pReal) + +end subroutine thermal_init + + +!-------------------------------------------------------------------------------------------------- +!> @brief Partition T onto the individual constituents. +!-------------------------------------------------------------------------------------------------- +module subroutine thermal_partition(T,ip,el) + + real(pReal), intent(in) :: T + integer, intent(in) :: & + ip, & !< integration point + el !< element number + + + call constitutive_thermal_setT(T,1,ip,el) + +end subroutine thermal_partition + + +end submodule homogenization_thermal From bc12ac44c3ccda8616ea255a2ab173b17f989cbc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 30 Dec 2020 12:34:00 +0100 Subject: [PATCH 057/352] basic functionality for thermal homogenization --- src/constitutive.f90 | 27 ++++++++++++----------- src/constitutive_mech.f90 | 7 +++--- src/constitutive_thermal.f90 | 42 +++++++++++++++++++++++++++--------- 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 36400fca7..e68d90de6 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -112,13 +112,15 @@ module constitutive interface ! == cleaned:begin ================================================================================= - module subroutine mech_init + module subroutine mech_init(phases) + class(tNode), pointer :: phases end subroutine mech_init module subroutine damage_init end subroutine damage_init - module subroutine thermal_init + module subroutine thermal_init(phases) + class(tNode), pointer :: phases end subroutine thermal_init @@ -197,10 +199,10 @@ module constitutive real(pReal), dimension(3,3) :: P end function constitutive_mech_getP - module function constitutive_thermal_T(co,ip,el) result(T) - integer, intent(in) :: co, ip, el + module function thermal_T(ph,me) result(T) + integer, intent(in) :: ph,me real(pReal) :: T - end function constitutive_thermal_T + end function thermal_T module subroutine constitutive_mech_setF(F,co,ip,el) @@ -463,6 +465,8 @@ subroutine constitutive_init phases + print'(/,a)', ' <<<+- constitutive init -+>>>'; flush(IO_STDOUT) + debug_constitutive => config_debug%get('constitutive', defaultVal=emptyList) debugConstitutive%basic = debug_constitutive%contains('basic') debugConstitutive%extensive = debug_constitutive%contains('extensive') @@ -471,15 +475,14 @@ subroutine constitutive_init debugConstitutive%ip = config_debug%get_asInt('integrationpoint',defaultVal = 1) debugConstitutive%grain = config_debug%get_asInt('grain',defaultVal = 1) -!-------------------------------------------------------------------------------------------------- -! initialize constitutive laws - print'(/,a)', ' <<<+- constitutive init -+>>>'; flush(IO_STDOUT) - call mech_init - call damage_init - call thermal_init - phases => config_material%get('phase') + + call mech_init(phases) + call damage_init + call thermal_init(phases) + + constitutive_source_maxSizeDotState = 0 PhaseLoop2:do ph = 1,phases%length !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index f5a5cd0a2..97bf7d853 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -319,7 +319,10 @@ contains !> @brief Initialize mechanical field related constitutive models !> @details Initialize elasticity, plasticity and stiffness degradation models. !-------------------------------------------------------------------------------------------------- -module subroutine mech_init +module subroutine mech_init(phases) + + class(tNode), pointer :: & + phases integer :: & el, & @@ -331,7 +334,6 @@ module subroutine mech_init Nconstituents class(tNode), pointer :: & num_crystallite, & - phases, & phase, & mech, & elastic, & @@ -341,7 +343,6 @@ module subroutine mech_init !------------------------------------------------------------------------------------------------- ! initialize elasticity (hooke) !ToDO: Maybe move to elastic submodule along with function homogenizedC? - phases => config_material%get('phase') allocate(phase_elasticity(phases%length), source = ELASTICITY_undefined_ID) allocate(phase_elasticityInstance(phases%length), source = 0) allocate(phase_NstiffnessDegradations(phases%length),source=0) diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 01d517124..bdcd0bc26 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -2,6 +2,12 @@ !> @brief internal microstructure state for all thermal sources and kinematics constitutive models !---------------------------------------------------------------------------------------------------- submodule(constitutive) constitutive_thermal + + type :: tDataContainer + real(pReal), dimension(:), allocatable :: T + end type tDataContainer + + type(tDataContainer), dimension(:), allocatable :: current interface @@ -49,8 +55,29 @@ contains !---------------------------------------------------------------------------------------------- !< @brief initializes thermal sources and kinematics mechanism !---------------------------------------------------------------------------------------------- -module subroutine thermal_init +module subroutine thermal_init(phases) + + class(tNode), pointer :: & + phases + + integer :: & + ph, & + Nconstituents + + print'(/,a)', ' <<<+- constitutive_mech init -+>>>' + + allocate(current(phases%length)) + + + do ph = 1, phases%length + + Nconstituents = count(material_phaseAt == ph) * discretization_nIPs + + allocate(current(ph)%T(Nconstituents)) + + enddo + ! initialize source mechanisms if(maxval(phase_Nsources) /= 0) then where(source_thermal_dissipation_init (maxval(phase_Nsources))) phase_source = SOURCE_thermal_dissipation_ID @@ -122,21 +149,16 @@ end subroutine constitutive_thermal_getRateAndItsTangents - ! getter for non-thermal (e.g. mech) -module function constitutive_thermal_T(co,ip,el) result(T) +module function thermal_T(ph,me) result(T) - integer, intent(in) :: co, ip, el + integer, intent(in) :: ph, me real(pReal) :: T - integer :: ho, tme - ho = material_homogenizationAt(el) - tme = material_homogenizationMemberAt(ip,el) + T = current(ph)%T(me) - T = temperature(ho)%p(tme) - -end function constitutive_thermal_T +end function thermal_T ! setter for homogenization From 8c6d759b557b8fed05b7b53c01ad7a28d349afba Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 30 Dec 2020 12:45:08 +0100 Subject: [PATCH 058/352] consistent naming --- src/constitutive.f90 | 31 +++++++++++++++---------------- src/constitutive_mech.f90 | 26 +++++++++++++------------- src/constitutive_thermal.f90 | 25 +++++++++++-------------- 3 files changed, 39 insertions(+), 43 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index e68d90de6..05653e3b4 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -174,25 +174,25 @@ module constitutive end subroutine mech_restartRead - module function constitutive_mech_getS(co,ip,el) result(S) - integer, intent(in) :: co, ip, el + module function mech_S(ph,me) result(S) + integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: S - end function constitutive_mech_getS + end function mech_S - module function constitutive_mech_getLp(co,ip,el) result(Lp) - integer, intent(in) :: co, ip, el - real(pReal), dimension(3,3) :: Lp - end function constitutive_mech_getLp + module function mech_L_p(ph,me) result(L_p) + integer, intent(in) :: ph,me + real(pReal), dimension(3,3) :: L_p + end function mech_L_p module function constitutive_mech_getF(co,ip,el) result(F) integer, intent(in) :: co, ip, el real(pReal), dimension(3,3) :: F end function constitutive_mech_getF - module function constitutive_mech_getF_e(co,ip,el) result(F_e) - integer, intent(in) :: co, ip, el + module function mech_F_e(ph,me) result(F_e) + integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: F_e - end function constitutive_mech_getF_e + end function mech_F_e module function constitutive_mech_getP(co,ip,el) result(P) integer, intent(in) :: co, ip, el @@ -421,12 +421,10 @@ module constitutive constitutive_restartWrite, & constitutive_restartRead, & integrateSourceState, & - constitutive_mech_setF, & constitutive_thermal_setT, & constitutive_mech_getP, & - constitutive_mech_getLp, & + constitutive_mech_setF, & constitutive_mech_getF, & - constitutive_mech_getS, & constitutive_initializeRestorationPoints, & constitutive_windForward, & PLASTICITY_UNDEFINED_ID, & @@ -667,7 +665,8 @@ function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) sourceType: select case (phase_source(so,ph)) case (SOURCE_damage_anisoBrittle_ID) sourceType - call source_damage_anisoBrittle_dotState(constitutive_mech_getS(co,ip,el), co, ip, el) ! correct stress? + call source_damage_anisoBrittle_dotState(mech_S(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el)),& + co, ip, el) ! correct stress? case (SOURCE_damage_isoDuctile_ID) sourceType call source_damage_isoDuctile_dotState(co, ip, el) @@ -1020,7 +1019,7 @@ subroutine crystallite_orientations(co,ip,el) call crystallite_orientation(co,ip,el)%fromMatrix(transpose(math_rotationalPart(& - constitutive_mech_getF_e(co,ip,el)))) + mech_F_e(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el))))) if (plasticState(material_phaseAt(1,el))%nonlocal) & call plastic_nonlocal_updateCompatibility(crystallite_orientation, & @@ -1123,7 +1122,7 @@ function integrateSourceState(dt,co,ip,el) result(broken) enddo if(converged_) then - broken = constitutive_damage_deltaState(constitutive_mech_getF_e(co,ip,el),co,ip,el,ph,me) + broken = constitutive_damage_deltaState(mech_F_e(ph,me),co,ip,el,ph,me) exit iteration endif diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 97bf7d853..f5be4863a 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1847,27 +1847,27 @@ end subroutine mech_restartRead ! getter for non-mech (e.g. thermal) -module function constitutive_mech_getS(co,ip,el) result(S) +module function mech_S(ph,me) result(S) - integer, intent(in) :: co, ip, el + integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: S - S = constitutive_mech_S(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + S = constitutive_mech_S(ph)%data(1:3,1:3,me) -end function constitutive_mech_getS +end function mech_S ! getter for non-mech (e.g. thermal) -module function constitutive_mech_getLp(co,ip,el) result(Lp) +module function mech_L_p(ph,me) result(L_p) - integer, intent(in) :: co, ip, el - real(pReal), dimension(3,3) :: Lp + integer, intent(in) :: ph,me + real(pReal), dimension(3,3) :: L_p - Lp = constitutive_mech_Lp(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + L_p = constitutive_mech_Lp(ph)%data(1:3,1:3,me) -end function constitutive_mech_getLp +end function mech_L_p ! getter for non-mech (e.g. thermal) @@ -1883,15 +1883,15 @@ end function constitutive_mech_getF ! getter for non-mech (e.g. thermal) -module function constitutive_mech_getF_e(co,ip,el) result(F_e) +module function mech_F_e(ph,me) result(F_e) - integer, intent(in) :: co, ip, el + integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: F_e - F_e = constitutive_mech_Fe(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + F_e = constitutive_mech_Fe(ph)%data(1:3,1:3,me) -end function constitutive_mech_getF_e +end function mech_F_e diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index bdcd0bc26..9e2807d42 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -109,32 +109,29 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, real(pReal) :: & my_Tdot, & my_dTdot_dT - real(pReal), dimension(3,3) :: Lp, S integer :: & - phase, & + ph, & homog, & instance, & - grain, & - source, & - constituent + me, & + so, & + co homog = material_homogenizationAt(el) instance = thermal_typeInstance(homog) - do grain = 1, homogenization_Nconstituents(homog) - phase = material_phaseAt(grain,el) - constituent = material_phasememberAt(grain,ip,el) - do source = 1, phase_Nsources(phase) - select case(phase_source(source,phase)) + do co = 1, homogenization_Nconstituents(homog) + ph = material_phaseAt(co,el) + me = material_phasememberAt(co,ip,el) + do so = 1, phase_Nsources(ph) + select case(phase_source(so,ph)) case (SOURCE_thermal_dissipation_ID) - Lp = constitutive_mech_getLp(grain,ip,el) - S = constitutive_mech_getS(grain,ip,el) call source_thermal_dissipation_getRateAndItsTangent(my_Tdot, my_dTdot_dT, & - S, Lp, phase) + mech_S(ph,me),mech_L_p(ph,me), ph) case (SOURCE_thermal_externalheat_ID) call source_thermal_externalheat_getRateAndItsTangent(my_Tdot, my_dTdot_dT, & - phase, constituent) + ph, me) case default my_Tdot = 0.0_pReal From f9f56a1755c6b64251d357c31047c98d34ce10cd Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 30 Dec 2020 13:57:37 +0100 Subject: [PATCH 059/352] documenting --- src/constitutive.f90 | 34 ---------------------------------- src/constitutive_mech.f90 | 24 +++++++++++++++++------- src/constitutive_thermal.f90 | 26 +++++++++++++++++--------- 3 files changed, 34 insertions(+), 50 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 05653e3b4..6348c18d6 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -352,23 +352,6 @@ module constitutive end subroutine source_damage_isoBrittle_deltaState - module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & - S, Fi, co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - real(pReal), intent(in), dimension(3,3) :: & - S, & !< 2nd Piola-Kirchhoff stress - Fi !< intermediate deformation gradient - real(pReal), intent(out), dimension(3,3) :: & - Lp !< plastic velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLp_dS, & - dLp_dFi !< derivative of Lp with respect to Fi - end subroutine constitutive_plastic_LpAndItsTangents - - module subroutine constitutive_plastic_dependentState(co,ip,el) integer, intent(in) :: & co, & !< component-ID of integration point @@ -376,23 +359,6 @@ module constitutive el !< element end subroutine constitutive_plastic_dependentState - - - module subroutine constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, Fe, Fi, co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - real(pReal), intent(in), dimension(3,3) :: & - Fe, & !< elastic deformation gradient - Fi !< intermediate deformation gradient - real(pReal), intent(out), dimension(3,3) :: & - S !< 2nd Piola-Kirchhoff stress tensor - real(pReal), intent(out), dimension(3,3,3,3) :: & - dS_dFe, & !< derivative of 2nd P-K stress with respect to elastic deformation gradient - dS_dFi !< derivative of 2nd P-K stress with respect to intermediate deformation gradient - end subroutine constitutive_hooke_SandItsTangents - end interface diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index f5be4863a..fedec379f 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -530,7 +530,7 @@ end function plastic_active !> @brief returns the 2nd Piola-Kirchhoff stress tensor and its tangent with respect to !> the elastic and intermediate deformation gradients using Hooke's law !-------------------------------------------------------------------------------------------------- -module subroutine constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & +subroutine constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & Fe, Fi, co, ip, el) integer, intent(in) :: & @@ -616,7 +616,7 @@ end subroutine constitutive_plastic_dependentState ! ToDo: Discuss whether it makes sense if crystallite handles the configuration conversion, i.e. ! Mp in, dLp_dMp out !-------------------------------------------------------------------------------------------------- -module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & +subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & S, Fi, co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point @@ -1846,7 +1846,9 @@ module subroutine mech_restartRead(groupHandle,ph) end subroutine mech_restartRead -! getter for non-mech (e.g. thermal) +!---------------------------------------------------------------------------------------------- +!< @brief Get first Piola-Kichhoff stress (for use by non-mech physics) +!---------------------------------------------------------------------------------------------- module function mech_S(ph,me) result(S) integer, intent(in) :: ph,me @@ -1858,7 +1860,9 @@ module function mech_S(ph,me) result(S) end function mech_S -! getter for non-mech (e.g. thermal) +!---------------------------------------------------------------------------------------------- +!< @brief Get plastic velocity gradient (for use by non-mech physics) +!---------------------------------------------------------------------------------------------- module function mech_L_p(ph,me) result(L_p) integer, intent(in) :: ph,me @@ -1870,7 +1874,9 @@ module function mech_L_p(ph,me) result(L_p) end function mech_L_p -! getter for non-mech (e.g. thermal) +!---------------------------------------------------------------------------------------------- +!< @brief Get deformation gradient (for use by homogenization) +!---------------------------------------------------------------------------------------------- module function constitutive_mech_getF(co,ip,el) result(F) integer, intent(in) :: co, ip, el @@ -1882,7 +1888,9 @@ module function constitutive_mech_getF(co,ip,el) result(F) end function constitutive_mech_getF -! getter for non-mech (e.g. thermal) +!---------------------------------------------------------------------------------------------- +!< @brief Get elastic deformation gradient (for use by non-mech physics) +!---------------------------------------------------------------------------------------------- module function mech_F_e(ph,me) result(F_e) integer, intent(in) :: ph,me @@ -1895,7 +1903,9 @@ end function mech_F_e -! getter for non-mech (e.g. thermal) +!---------------------------------------------------------------------------------------------- +!< @brief Get second Piola-Kichhoff stress (for use by homogenization) +!---------------------------------------------------------------------------------------------- module function constitutive_mech_getP(co,ip,el) result(P) integer, intent(in) :: co, ip, el diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 9e2807d42..f2b61fb26 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -2,11 +2,11 @@ !> @brief internal microstructure state for all thermal sources and kinematics constitutive models !---------------------------------------------------------------------------------------------------- submodule(constitutive) constitutive_thermal - + type :: tDataContainer real(pReal), dimension(:), allocatable :: T end type tDataContainer - + type(tDataContainer), dimension(:), allocatable :: current interface @@ -56,10 +56,10 @@ contains !< @brief initializes thermal sources and kinematics mechanism !---------------------------------------------------------------------------------------------- module subroutine thermal_init(phases) - + class(tNode), pointer :: & phases - + integer :: & ph, & Nconstituents @@ -71,13 +71,13 @@ module subroutine thermal_init(phases) do ph = 1, phases%length - + Nconstituents = count(material_phaseAt == ph) * discretization_nIPs allocate(current(ph)%T(Nconstituents)) enddo - + ! initialize source mechanisms if(maxval(phase_Nsources) /= 0) then where(source_thermal_dissipation_init (maxval(phase_Nsources))) phase_source = SOURCE_thermal_dissipation_ID @@ -145,8 +145,9 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, end subroutine constitutive_thermal_getRateAndItsTangents - -! getter for non-thermal (e.g. mech) +!---------------------------------------------------------------------------------------------- +!< @brief Get temperature (for use by non-thermal physics) +!---------------------------------------------------------------------------------------------- module function thermal_T(ph,me) result(T) integer, intent(in) :: ph, me @@ -158,10 +159,17 @@ module function thermal_T(ph,me) result(T) end function thermal_T -! setter for homogenization +!---------------------------------------------------------------------------------------------- +!< @brief Set temperature +!---------------------------------------------------------------------------------------------- module subroutine constitutive_thermal_setT(T,co,ip,el) + real(pReal), intent(in) :: T integer, intent(in) :: co, ip, el + + + current(material_phaseAt(co,el))%T(material_phaseMemberAt(co,ip,el)) = T + end subroutine constitutive_thermal_setT From a1facadf3fb9451dbc3402e2e8c18dd975019cab Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 30 Dec 2020 18:08:19 +0100 Subject: [PATCH 060/352] needed for MSC.Marc --- src/commercialFEM_fileList.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index d8ab6390d..371c85fd3 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -52,4 +52,5 @@ #include "homogenization_mech_none.f90" #include "homogenization_mech_isostrain.f90" #include "homogenization_mech_RGC.f90" +#include "homogenization_thermal.f90" #include "CPFEM.f90" From 92ec10b2518c488ec01e3246c373005c816ed74f Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 31 Dec 2020 07:46:26 +0100 Subject: [PATCH 061/352] consistent names --- src/homogenization_mech.f90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/homogenization_mech.f90 b/src/homogenization_mech.f90 index 783d08dd1..dd3e47c59 100644 --- a/src/homogenization_mech.f90 +++ b/src/homogenization_mech.f90 @@ -113,24 +113,24 @@ module subroutine mech_partition(subF,ip,el) el !< element number integer :: co - real(pReal) :: F(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) + real(pReal), dimension (3,3,homogenization_Nconstituents(material_homogenizationAt(el))) :: Fs chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) case (HOMOGENIZATION_NONE_ID) chosenHomogenization - F(1:3,1:3,1) = subF + Fs(1:3,1:3,1) = subF case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization - call mech_isostrain_partitionDeformation(F,subF) + call mech_isostrain_partitionDeformation(Fs,subF) case (HOMOGENIZATION_RGC_ID) chosenHomogenization - call mech_RGC_partitionDeformation(F,subF,ip,el) + call mech_RGC_partitionDeformation(Fs,subF,ip,el) end select chosenHomogenization do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - call constitutive_mech_setF(F(1:3,1:3,co),co,ip,el) + call constitutive_mech_setF(Fs(1:3,1:3,co),co,ip,el) enddo From ebc4f671c88d3b3d2a12eb73464622d6ac4f63e7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 31 Dec 2020 08:00:20 +0100 Subject: [PATCH 062/352] names follow structure --- src/commercialFEM_fileList.f90 | 4 ++-- ...l_dissipation.f90 => constitutive_thermal_dissipation.f90} | 4 ++-- ...externalheat.f90 => constitutive_thermal_externalheat.f90} | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/{source_thermal_dissipation.f90 => constitutive_thermal_dissipation.f90} (97%) rename src/{source_thermal_externalheat.f90 => constitutive_thermal_externalheat.f90} (98%) diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 371c85fd3..a27abec79 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -33,8 +33,8 @@ #include "constitutive_plastic_disloTungsten.f90" #include "constitutive_plastic_nonlocal.f90" #include "constitutive_thermal.f90" -#include "source_thermal_dissipation.f90" -#include "source_thermal_externalheat.f90" +#include "constitutive_thermal_dissipation.f90" +#include "constitutive_thermal_externalheat.f90" #include "kinematics_thermal_expansion.f90" #include "constitutive_damage.f90" #include "source_damage_isoBrittle.f90" diff --git a/src/source_thermal_dissipation.f90 b/src/constitutive_thermal_dissipation.f90 similarity index 97% rename from src/source_thermal_dissipation.f90 rename to src/constitutive_thermal_dissipation.f90 index f28567aa7..27653a9ef 100644 --- a/src/source_thermal_dissipation.f90 +++ b/src/constitutive_thermal_dissipation.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine for thermal source due to plastic dissipation !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_thermal) source_thermal_dissipation +submodule(constitutive:constitutive_thermal) source_dissipation integer, dimension(:), allocatable :: & source_thermal_dissipation_offset, & !< which source is my current thermal dissipation mechanism? @@ -96,4 +96,4 @@ module subroutine source_thermal_dissipation_getRateAndItsTangent(TDot, dTDot_dT end subroutine source_thermal_dissipation_getRateAndItsTangent -end submodule source_thermal_dissipation +end submodule source_dissipation diff --git a/src/source_thermal_externalheat.f90 b/src/constitutive_thermal_externalheat.f90 similarity index 98% rename from src/source_thermal_externalheat.f90 rename to src/constitutive_thermal_externalheat.f90 index 9ba4a051b..3ef96790e 100644 --- a/src/source_thermal_externalheat.f90 +++ b/src/constitutive_thermal_externalheat.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Michigan State University !> @brief material subroutine for variable heat source !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_thermal) source_thermal_externalheat +submodule(constitutive:constitutive_thermal) source_externalheat integer, dimension(:), allocatable :: & @@ -135,4 +135,4 @@ module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, dTDot_d end subroutine source_thermal_externalheat_getRateAndItsTangent -end submodule source_thermal_externalheat +end submodule source_externalheat From 228398e78709d9cbbbb9bf37af9a5aa40c20d3a5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 31 Dec 2020 09:10:59 +0100 Subject: [PATCH 063/352] config follows structure --- src/lattice.f90 | 83 ++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/src/lattice.f90 b/src/lattice.f90 index 6af135e4e..c9b6d99ef 100644 --- a/src/lattice.f90 +++ b/src/lattice.f90 @@ -453,12 +453,13 @@ contains !-------------------------------------------------------------------------------------------------- subroutine lattice_init - integer :: Nphases, p,i + integer :: Nphases, ph,i class(tNode), pointer :: & phases, & phase, & mech, & - elasticity + elasticity, & + thermal print'(/,a)', ' <<<+- lattice init -+>>>'; flush(IO_STDOUT) @@ -476,67 +477,71 @@ subroutine lattice_init lattice_mu, lattice_nu,& source=[(0.0_pReal,i=1,Nphases)]) - do p = 1, phases%length - phase => phases%get(p) + do ph = 1, phases%length + phase => phases%get(ph) mech => phase%get('mechanics') elasticity => mech%get('elasticity') - lattice_C66(1,1,p) = elasticity%get_asFloat('C_11') - lattice_C66(1,2,p) = elasticity%get_asFloat('C_12') + lattice_C66(1,1,ph) = elasticity%get_asFloat('C_11') + lattice_C66(1,2,ph) = elasticity%get_asFloat('C_12') - lattice_C66(1,3,p) = elasticity%get_asFloat('C_13',defaultVal=0.0_pReal) - lattice_C66(2,2,p) = elasticity%get_asFloat('C_22',defaultVal=0.0_pReal) - lattice_C66(2,3,p) = elasticity%get_asFloat('C_23',defaultVal=0.0_pReal) - lattice_C66(3,3,p) = elasticity%get_asFloat('C_33',defaultVal=0.0_pReal) - lattice_C66(4,4,p) = elasticity%get_asFloat('C_44',defaultVal=0.0_pReal) - lattice_C66(5,5,p) = elasticity%get_asFloat('C_55',defaultVal=0.0_pReal) - lattice_C66(6,6,p) = elasticity%get_asFloat('C_66',defaultVal=0.0_pReal) + lattice_C66(1,3,ph) = elasticity%get_asFloat('C_13',defaultVal=0.0_pReal) + lattice_C66(2,2,ph) = elasticity%get_asFloat('C_22',defaultVal=0.0_pReal) + lattice_C66(2,3,ph) = elasticity%get_asFloat('C_23',defaultVal=0.0_pReal) + lattice_C66(3,3,ph) = elasticity%get_asFloat('C_33',defaultVal=0.0_pReal) + lattice_C66(4,4,ph) = elasticity%get_asFloat('C_44',defaultVal=0.0_pReal) + lattice_C66(5,5,ph) = elasticity%get_asFloat('C_55',defaultVal=0.0_pReal) + lattice_C66(6,6,ph) = elasticity%get_asFloat('C_66',defaultVal=0.0_pReal) select case(phase%get_asString('lattice')) case('cF') - lattice_structure(p) = lattice_FCC_ID + lattice_structure(ph) = lattice_FCC_ID case('cI') - lattice_structure(p) = lattice_BCC_ID + lattice_structure(ph) = lattice_BCC_ID case('hP') - lattice_structure(p) = lattice_HEX_ID + lattice_structure(ph) = lattice_HEX_ID case('tI') - lattice_structure(p) = lattice_BCT_ID + lattice_structure(ph) = lattice_BCT_ID case('oP') - lattice_structure(p) = lattice_ORT_ID + lattice_structure(ph) = lattice_ORT_ID case('aP') - lattice_structure(p) = lattice_ISO_ID + lattice_structure(ph) = lattice_ISO_ID case default call IO_error(130,ext_msg='lattice_init: '//phase%get_asString('lattice')) end select - lattice_C66(1:6,1:6,p) = applyLatticeSymmetryC66(lattice_C66(1:6,1:6,p),phase%get_asString('lattice')) + lattice_C66(1:6,1:6,ph) = applyLatticeSymmetryC66(lattice_C66(1:6,1:6,ph),phase%get_asString('lattice')) - lattice_nu(p) = lattice_equivalent_nu(lattice_C66(1:6,1:6,p),'voigt') - lattice_mu(p) = lattice_equivalent_mu(lattice_C66(1:6,1:6,p),'voigt') + lattice_nu(ph) = lattice_equivalent_nu(lattice_C66(1:6,1:6,ph),'voigt') + lattice_mu(ph) = lattice_equivalent_mu(lattice_C66(1:6,1:6,ph),'voigt') - lattice_C66(1:6,1:6,p) = math_sym3333to66(math_Voigt66to3333(lattice_C66(1:6,1:6,p))) ! Literature data is in Voigt notation + lattice_C66(1:6,1:6,ph) = math_sym3333to66(math_Voigt66to3333(lattice_C66(1:6,1:6,ph))) ! Literature data is in Voigt notation do i = 1, 6 - if (abs(lattice_C66(i,i,p)) phase%get('thermal') + lattice_K(1,1,ph) = thermal%get_asFloat('K_11',defaultVal=0.0_pReal) + lattice_K(2,2,ph) = thermal%get_asFloat('K_22',defaultVal=0.0_pReal) + lattice_K(3,3,ph) = thermal%get_asFloat('K_33',defaultVal=0.0_pReal) + lattice_K(1:3,1:3,ph) = lattice_applyLatticeSymmetry33(lattice_K(1:3,1:3,ph), & + phase%get_asString('lattice')) + lattice_c_p(ph) = thermal%get_asFloat('c_p', defaultVal=0.0_pReal) + endif + + + lattice_D(1,1,ph) = phase%get_asFloat('D_11',defaultVal=0.0_pReal) + lattice_D(2,2,ph) = phase%get_asFloat('D_22',defaultVal=0.0_pReal) + lattice_D(3,3,ph) = phase%get_asFloat('D_33',defaultVal=0.0_pReal) + lattice_D(1:3,1:3,ph) = lattice_applyLatticeSymmetry33(lattice_D(1:3,1:3,ph), & phase%get_asString('lattice')) - lattice_c_p(p) = phase%get_asFloat('c_p', defaultVal=0.0_pReal) - lattice_rho(p) = phase%get_asFloat('rho', defaultVal=0.0_pReal) - - lattice_D(1,1,p) = phase%get_asFloat('D_11',defaultVal=0.0_pReal) - lattice_D(2,2,p) = phase%get_asFloat('D_22',defaultVal=0.0_pReal) - lattice_D(3,3,p) = phase%get_asFloat('D_33',defaultVal=0.0_pReal) - lattice_D(1:3,1:3,p) = lattice_applyLatticeSymmetry33(lattice_D(1:3,1:3,p), & - phase%get_asString('lattice')) - - lattice_M(p) = phase%get_asFloat('M',defaultVal=0.0_pReal) + lattice_M(ph) = phase%get_asFloat('M',defaultVal=0.0_pReal) ! SHOULD NOT BE PART OF LATTICE END call selfTest From a2d0a9e51152b302c50f670c4c77a39a30b81683 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 31 Dec 2020 09:54:13 +0100 Subject: [PATCH 064/352] WIP: separating states --- src/constitutive.f90 | 166 ++++++++++++++++++++++++++++++----- src/constitutive_mech.f90 | 11 ++- src/constitutive_thermal.f90 | 64 ++++++++++++++ 3 files changed, 215 insertions(+), 26 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 6348c18d6..a13904697 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -102,7 +102,7 @@ module constitutive type(tPlasticState), allocatable, dimension(:), public :: & plasticState type(tSourceState), allocatable, dimension(:), public :: & - sourceState + sourceState, thermalState integer, public, protected :: & @@ -139,21 +139,37 @@ module constitutive integer, intent(in) :: ph, me end subroutine mech_initializeRestorationPoints - module subroutine constitutive_mech_windForward(ph,me) + module subroutine thermal_initializeRestorationPoints(ph,me) integer, intent(in) :: ph, me - end subroutine constitutive_mech_windForward + end subroutine thermal_initializeRestorationPoints + + + module subroutine mech_windForward(ph,me) + integer, intent(in) :: ph, me + end subroutine mech_windForward + + module subroutine thermal_windForward(ph,me) + integer, intent(in) :: ph, me + end subroutine thermal_windForward + + + module subroutine mech_forward() + end subroutine mech_forward + + module subroutine thermal_forward() + end subroutine thermal_forward - module subroutine constitutive_mech_forward - end subroutine constitutive_mech_forward module subroutine mech_restore(ip,el,includeL) - integer, intent(in) :: & - ip, & - el - logical, intent(in) :: & - includeL + integer, intent(in) :: ip, el + logical, intent(in) :: includeL end subroutine mech_restore + module subroutine thermal_restore(ip,el) + integer, intent(in) :: ip, el + end subroutine thermal_restore + + module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) real(pReal), intent(in) :: dt integer, intent(in) :: & @@ -776,6 +792,7 @@ subroutine constitutive_restore(ip,el,includeL) enddo call mech_restore(ip,el,includeL) + call thermal_restore(ip,el) end subroutine constitutive_restore @@ -784,12 +801,13 @@ end subroutine constitutive_restore !> @brief Forward data after successful increment. ! ToDo: Any guessing for the current states possible? !-------------------------------------------------------------------------------------------------- -subroutine constitutive_forward +subroutine constitutive_forward() integer :: ph, so - call constitutive_mech_forward() + call mech_forward() + call thermal_forward() do ph = 1, size(sourceState) do so = 1,phase_Nsources(ph) @@ -802,7 +820,7 @@ end subroutine constitutive_forward !-------------------------------------------------------------------------------------------------- !> @brief writes constitutive results to HDF5 output file !-------------------------------------------------------------------------------------------------- -subroutine constitutive_results +subroutine constitutive_results() integer :: ph character(len=:), allocatable :: group @@ -826,7 +844,7 @@ end subroutine constitutive_results !-------------------------------------------------------------------------------------------------- !> @brief allocates and initialize per grain variables !-------------------------------------------------------------------------------------------------- -subroutine crystallite_init +subroutine crystallite_init() integer :: & ph, & @@ -937,10 +955,12 @@ subroutine constitutive_initializeRestorationPoints(ip,el) me = material_phaseMemberAt(co,ip,el) call mech_initializeRestorationPoints(ph,me) + call thermal_initializeRestorationPoints(ph,me) - do so = 1, phase_Nsources(material_phaseAt(co,el)) + do so = 1, size(sourceState(ph)%p) sourceState(ph)%p(so)%partitionedState0(:,me) = sourceState(ph)%p(so)%state0(:,me) enddo + enddo end subroutine constitutive_initializeRestorationPoints @@ -964,10 +984,13 @@ subroutine constitutive_windForward(ip,el) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - call constitutive_mech_windForward(ph,me) + call mech_windForward(ph,me) + call thermal_windForward(ph,me) + do so = 1, phase_Nsources(material_phaseAt(co,el)) sourceState(ph)%p(so)%partitionedState0(:,me) = sourceState(ph)%p(so)%state(:,me) enddo + enddo end subroutine constitutive_windForward @@ -1049,8 +1072,7 @@ function integrateSourceState(dt,co,ip,el) result(broken) me = material_phaseMemberAt(co,ip,el) converged_ = .true. - broken = constitutive_thermal_collectDotState(ph,me) - broken = broken .or. constitutive_damage_collectDotState(co,ip,el,ph,me) + broken = constitutive_damage_collectDotState(co,ip,el,ph,me) if(broken) return do so = 1, phase_Nsources(ph) @@ -1067,8 +1089,7 @@ function integrateSourceState(dt,co,ip,el) result(broken) source_dotState(1:size_so(so),1,so) = sourceState(ph)%p(so)%dotState(:,me) enddo - broken = constitutive_thermal_collectDotState(ph,me) - broken = broken .or. constitutive_damage_collectDotState(co,ip,el,ph,me) + broken = constitutive_damage_collectDotState(co,ip,el,ph,me) if(broken) exit iteration do so = 1, phase_Nsources(ph) @@ -1122,6 +1143,111 @@ function integrateSourceState(dt,co,ip,el) result(broken) end function integrateSourceState + +!-------------------------------------------------------------------------------------------------- +!> @brief integrate stress, state with adaptive 1st order explicit Euler method +!> using Fixed Point Iteration to adapt the stepsize +!-------------------------------------------------------------------------------------------------- +function integrateThermalState(dt,co,ip,el) result(broken) + + real(pReal), intent(in) :: dt + integer, intent(in) :: & + el, & !< element index in element loop + ip, & !< integration point index in ip loop + co !< grain index in grain loop + + integer :: & + NiterationState, & !< number of iterations in state loop + ph, & + me, & + so + integer, dimension(maxval(phase_Nsources)) :: & + size_so + real(pReal) :: & + zeta + real(pReal), dimension(constitutive_source_maxSizeDotState) :: & + r ! state residuum + real(pReal), dimension(constitutive_source_maxSizeDotState,2,maxval(phase_Nsources)) :: source_dotState + logical :: & + broken, converged_ + + + ph = material_phaseAt(co,el) + me = material_phaseMemberAt(co,ip,el) + + converged_ = .true. + broken = constitutive_thermal_collectDotState(ph,me) + if(broken) return + + do so = 1, phase_Nsources(ph) + size_so(so) = thermalState(ph)%p(so)%sizeDotState + thermalState(ph)%p(so)%state(1:size_so(so),me) = thermalState(ph)%p(so)%subState0(1:size_so(so),me) & + + thermalState(ph)%p(so)%dotState (1:size_so(so),me) * dt + source_dotState(1:size_so(so),2,so) = 0.0_pReal + enddo + + iteration: do NiterationState = 1, num%nState + + do so = 1, phase_Nsources(ph) + if(nIterationState > 1) source_dotState(1:size_so(so),2,so) = source_dotState(1:size_so(so),1,so) + source_dotState(1:size_so(so),1,so) = thermalState(ph)%p(so)%dotState(:,me) + enddo + + broken = constitutive_thermal_collectDotState(ph,me) + broken = broken .or. constitutive_damage_collectDotState(co,ip,el,ph,me) + if(broken) exit iteration + + do so = 1, phase_Nsources(ph) + zeta = damper(thermalState(ph)%p(so)%dotState(:,me), & + source_dotState(1:size_so(so),1,so),& + source_dotState(1:size_so(so),2,so)) + thermalState(ph)%p(so)%dotState(:,me) = thermalState(ph)%p(so)%dotState(:,me) * zeta & + + source_dotState(1:size_so(so),1,so)* (1.0_pReal - zeta) + r(1:size_so(so)) = thermalState(ph)%p(so)%state (1:size_so(so),me) & + - thermalState(ph)%p(so)%subState0(1:size_so(so),me) & + - thermalState(ph)%p(so)%dotState (1:size_so(so),me) * dt + thermalState(ph)%p(so)%state(1:size_so(so),me) = thermalState(ph)%p(so)%state(1:size_so(so),me) & + - r(1:size_so(so)) + converged_ = converged_ .and. converged(r(1:size_so(so)), & + thermalState(ph)%p(so)%state(1:size_so(so),me), & + thermalState(ph)%p(so)%atol(1:size_so(so))) + enddo + + if(converged_) then + broken = constitutive_damage_deltaState(mech_F_e(ph,me),co,ip,el,ph,me) + exit iteration + endif + + enddo iteration + + broken = broken .or. .not. converged_ + + + contains + + !-------------------------------------------------------------------------------------------------- + !> @brief calculate the damping for correction of state and dot state + !-------------------------------------------------------------------------------------------------- + real(pReal) pure function damper(current,previous,previous2) + + real(pReal), dimension(:), intent(in) ::& + current, previous, previous2 + + real(pReal) :: dot_prod12, dot_prod22 + + dot_prod12 = dot_product(current - previous, previous - previous2) + dot_prod22 = dot_product(previous - previous2, previous - previous2) + if ((dot_product(current,previous) < 0.0_pReal .or. dot_prod12 < 0.0_pReal) .and. dot_prod22 > 0.0_pReal) then + damper = 0.75_pReal + 0.25_pReal * tanh(2.0_pReal + 4.0_pReal * dot_prod12 / dot_prod22) + else + damper = 1.0_pReal + endif + + end function damper + +end function integrateThermalState + + !-------------------------------------------------------------------------------------------------- !> @brief determines whether a point is converged !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index fedec379f..67b6f9fbe 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1485,7 +1485,7 @@ end subroutine mech_initializeRestorationPoints !-------------------------------------------------------------------------------------------------- !> @brief Wind homog inc forward. !-------------------------------------------------------------------------------------------------- -module subroutine constitutive_mech_windForward(ph,me) +module subroutine mech_windForward(ph,me) integer, intent(in) :: ph, me @@ -1499,14 +1499,14 @@ module subroutine constitutive_mech_windForward(ph,me) plasticState(ph)%partitionedState0(:,me) = plasticState(ph)%state(:,me) -end subroutine constitutive_mech_windForward +end subroutine mech_windForward !-------------------------------------------------------------------------------------------------- !> @brief Forward data after successful increment. ! ToDo: Any guessing for the current states possible? !-------------------------------------------------------------------------------------------------- -module subroutine constitutive_mech_forward() +module subroutine mech_forward() integer :: ph @@ -1521,7 +1521,7 @@ module subroutine constitutive_mech_forward() plasticState(ph)%state0 = plasticState(ph)%state enddo -end subroutine constitutive_mech_forward +end subroutine mech_forward @@ -1678,8 +1678,7 @@ module subroutine mech_restore(ip,el,includeL) constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) constitutive_mech_S(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedS0(ph)%data(1:3,1:3,me) - plasticState (material_phaseAt(co,el))%state( :,material_phasememberAt(co,ip,el)) = & - plasticState (material_phaseAt(co,el))%partitionedState0(:,material_phasememberAt(co,ip,el)) + plasticState(ph)%state(:,me) = plasticState(ph)%partitionedState0(:,me) enddo end subroutine mech_restore diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index f2b61fb26..f1675f0a1 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -145,6 +145,70 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, end subroutine constitutive_thermal_getRateAndItsTangents + +module subroutine thermal_initializeRestorationPoints(ph,me) + + integer, intent(in) :: ph, me + + integer :: so + + + do so = 1, size(sourceState(ph)%p) + thermalState(ph)%p(so)%partitionedState0(:,me) = thermalState(ph)%p(so)%state0(:,me) + enddo + +end subroutine thermal_initializeRestorationPoints + + + +module subroutine thermal_windForward(ph,me) + + integer, intent(in) :: ph, me + + integer :: so + + + do so = 1, size(sourceState(ph)%p) + thermalState(ph)%p(so)%partitionedState0(:,me) = thermalState(ph)%p(so)%state(:,me) + enddo + +end subroutine thermal_windForward + + +module subroutine thermal_forward() + + integer :: ph, so + + + do ph = 1, size(thermalState) + do so = 1, size(sourceState(ph)%p) + thermalState(ph)%p(so)%state0 = thermalState(ph)%p(so)%state + enddo + enddo + +end subroutine thermal_forward + + +module subroutine thermal_restore(ip,el) + + integer, intent(in) :: ip, el + + integer :: co, ph, me, so + + + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + ph = material_phaseAt(co,el) + me = material_phaseMemberAt(co,ip,el) + + do so = 1, size(sourceState(ph)%p) + thermalState(ph)%p(so)%state(:,me) = thermalState(ph)%p(so)%partitionedState0(:,me) + enddo + + enddo + +end subroutine thermal_restore + + !---------------------------------------------------------------------------------------------- !< @brief Get temperature (for use by non-thermal physics) !---------------------------------------------------------------------------------------------- From 6fe1ff8e393ad0af27bd3634a7774a303f304e7c Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 3 Jan 2021 11:50:45 +0100 Subject: [PATCH 065/352] fixed test for rodrigues parametrization for angle close to 180deg, the sign of the axis does not matter --- python/damask/_rotation.py | 1 - python/tests/test_Rotation.py | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 780e81891..cec3854cc 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -1052,7 +1052,6 @@ class Rotation: @staticmethod def _om2ax(om): """Rotation matrix to axis angle pair.""" - #return Rotation._qu2ax(Rotation._om2qu(om)) # HOTFIX diag_delta = -_P*np.block([om[...,1,2:3]-om[...,2,1:2], om[...,2,0:1]-om[...,0,2:3], om[...,0,1:2]-om[...,1,0:1] diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index c60029046..f8f1a3da7 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -526,7 +526,7 @@ class TestRotation: o = backward(forward(m)) u = np.array([np.pi*2,np.pi,np.pi*2]) ok = np.allclose(m,o,atol=atol) - ok = ok or np.allclose(np.where(np.isclose(m,u),m-u,m),np.where(np.isclose(o,u),o-u,o),atol=atol) + ok |= np.allclose(np.where(np.isclose(m,u),m-u,m),np.where(np.isclose(o,u),o-u,o),atol=atol) if np.isclose(m[1],0.0,atol=atol) or np.isclose(m[1],np.pi,atol=atol): sum_phi = np.unwrap([m[0]+m[2],o[0]+o[2]]) ok |= np.isclose(sum_phi[0],sum_phi[1],atol=atol) @@ -550,19 +550,22 @@ class TestRotation: assert ok and np.isclose(np.linalg.norm(o[:3]),1.0) and o[3]<=np.pi+1.e-9, f'{m},{o},{rot.as_quaternion()}' @pytest.mark.parametrize('forward,backward',[(Rotation._ro2qu,Rotation._qu2ro), - #(Rotation._ro2om,Rotation._om2ro), - #(Rotation._ro2eu,Rotation._eu2ro), + (Rotation._ro2om,Rotation._om2ro), + (Rotation._ro2eu,Rotation._eu2ro), (Rotation._ro2ax,Rotation._ax2ro), (Rotation._ro2ho,Rotation._ho2ro), (Rotation._ro2cu,Rotation._cu2ro)]) def test_Rodrigues_internal(self,set_of_rotations,forward,backward): """Ensure invariance of conversion from Rodrigues-Frank vector and back.""" - cutoff = np.tan(np.pi*.5*(1.-1e-4)) + cutoff = np.tan(np.pi*.5*(1.-1e-5)) for rot in set_of_rotations: m = rot.as_Rodrigues_vector() o = backward(forward(m)) ok = np.allclose(np.clip(m,None,cutoff),np.clip(o,None,cutoff),atol=atol) - ok = ok or np.isclose(m[3],0.0,atol=atol) + ok |= np.isclose(m[3],0.0,atol=atol) + if m[3] > cutoff: + ok |= np.allclose(m[:3],-1*o[:3]) + assert ok and np.isclose(np.linalg.norm(o[:3]),1.0), f'{m},{o},{rot.as_quaternion()}' @pytest.mark.parametrize('forward,backward',[(Rotation._ho2qu,Rotation._qu2ho), @@ -592,7 +595,7 @@ class TestRotation: o = backward(forward(m)) ok = np.allclose(m,o,atol=atol) if np.count_nonzero(np.isclose(np.abs(o),np.pi**(2./3.)*.5)): - ok = ok or np.allclose(m*-1.,o,atol=atol) + ok |= np.allclose(m*-1.,o,atol=atol) assert ok and np.max(np.abs(o)) < np.pi**(2./3.) * 0.5 + 1.e-9, f'{m},{o},{rot.as_quaternion()}' @pytest.mark.parametrize('vectorized, single',[(Rotation._qu2om,qu2om), @@ -719,7 +722,7 @@ class TestRotation: o = Rotation.from_axis_angle(rot.as_axis_angle()).as_axis_angle() ok = np.allclose(m,o,atol=atol) if np.isclose(m[3],np.pi,atol=atol): - ok = ok or np.allclose(m*np.array([-1.,-1.,-1.,1.]),o,atol=atol) + ok |= np.allclose(m*np.array([-1.,-1.,-1.,1.]),o,atol=atol) assert ok and np.isclose(np.linalg.norm(o[:3]),1.0) \ and o[3]<=np.pi+1.e-9, f'{m},{o},{rot.as_quaternion()}' @@ -740,7 +743,7 @@ class TestRotation: m = rot.as_Rodrigues_vector() o = Rotation.from_homochoric(rot.as_homochoric()*P*-1,P).as_Rodrigues_vector() ok = np.allclose(np.clip(m,None,cutoff),np.clip(o,None,cutoff),atol=atol) - ok = ok or np.isclose(m[3],0.0,atol=atol) + ok |= np.isclose(m[3],0.0,atol=atol) assert ok and np.isclose(np.linalg.norm(o[:3]),1.0), f'{m},{o},{rot.as_quaternion()}' @pytest.mark.parametrize('P',[1,-1]) From 35ca1ffb0a9827fbcee58e46eeb4a936b5bac792 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 3 Jan 2021 12:03:40 +0100 Subject: [PATCH 066/352] consistent copy functionality --- python/damask/_config.py | 11 +++++++++++ python/damask/_configmaterial.py | 4 ++-- python/damask/_grid.py | 7 ++----- python/damask/_orientation.py | 2 +- python/damask/_rotation.py | 3 +-- python/damask/_table.py | 6 ++---- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/python/damask/_config.py b/python/damask/_config.py index 76955588f..91be5ebf1 100644 --- a/python/damask/_config.py +++ b/python/damask/_config.py @@ -1,3 +1,4 @@ +import copy from io import StringIO import abc @@ -35,6 +36,14 @@ class Config(dict): output.seek(0) return ''.join(output.readlines()) + + def __copy__(self): + """Create deep copy.""" + return copy.deepcopy(self) + + copy = __copy__ + + @classmethod def load(cls,fname): """ @@ -52,6 +61,7 @@ class Config(dict): fhandle = fname return cls(yaml.safe_load(fhandle)) + def save(self,fname,**kwargs): """ Save to yaml file. @@ -95,6 +105,7 @@ class Config(dict): """Check for completeness.""" pass + @property @abc.abstractmethod def is_valid(self): diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index b94e9897a..43a59eb1e 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -204,7 +204,7 @@ class ConfigMaterial(Config): Limit renaming to selected constituents. """ - dup = copy.deepcopy(self) + dup = self.copy() for i,m in enumerate(dup['material']): if ID and i not in ID: continue for c in m['constituents']: @@ -228,7 +228,7 @@ class ConfigMaterial(Config): Limit renaming to selected homogenization IDs. """ - dup = copy.deepcopy(self) + dup = self.copy() for i,m in enumerate(dup['material']): if ID and i not in ID: continue try: diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 8380bbc5b..76ce7ba64 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -57,13 +57,10 @@ class Grid: def __copy__(self): - """Copy grid.""" + """Create deep copy.""" return copy.deepcopy(self) - - def copy(self): - """Copy grid.""" - return self.__copy__() + copy = __copy__ def diff(self,other): diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 05301561f..4bd8a1e96 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -199,7 +199,7 @@ class Orientation(Rotation): def __copy__(self,**kwargs): - """Copy.""" + """Create deep copy.""" return self.__class__(rotation=kwargs['rotation'] if 'rotation' in kwargs else self.quaternion, lattice =kwargs['lattice'] if 'lattice' in kwargs else self.lattice if self.lattice is not None else self.family, diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index cec3854cc..492ca8d2d 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -78,9 +78,8 @@ class Rotation: ]) - # ToDo: Check difference __copy__ vs __deepcopy__ def __copy__(self,**kwargs): - """Copy.""" + """Create deep copy.""" return self.__class__(rotation=kwargs['rotation'] if 'rotation' in kwargs else self.quaternion) copy = __copy__ diff --git a/python/damask/_table.py b/python/damask/_table.py index e6e6c4eeb..78a8a276e 100644 --- a/python/damask/_table.py +++ b/python/damask/_table.py @@ -42,12 +42,10 @@ class Table: return len(self.data) def __copy__(self): - """Copy Table.""" + """Create deep copy.""" return copy.deepcopy(self) - def copy(self): - """Copy Table.""" - return self.__copy__() + copy = __copy__ def _label_discrete(self): From 9a278daa3f2b19a4389dd7cb173974f4ccf5eee0 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 3 Jan 2021 12:07:02 +0100 Subject: [PATCH 067/352] copy not needed YAML writer does not write out references anymore --- python/damask/_configmaterial.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 43a59eb1e..83ebdd5a5 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -1,5 +1,3 @@ -import copy - import numpy as np from . import Config @@ -289,7 +287,7 @@ class ConfigMaterial(Config): c = [{} for _ in range(length)] if constituents is None else \ [{'constituents':u} for u in ConfigMaterial._constituents(**constituents)] - if len(c) == 1: c = [copy.deepcopy(c[0]) for _ in range(length)] + 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') @@ -301,7 +299,7 @@ class ConfigMaterial(Config): else: for i in range(len(c)): c[i][k] = v - dup = copy.deepcopy(self) + dup = self.copy() dup['material'] = dup['material'] + c if 'material' in dup else c return dup From 5f1399acc37529e5b2bfa3d12be666823259f23b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 3 Jan 2021 12:09:21 +0100 Subject: [PATCH 068/352] consistent behavior with other classes python dictionary operates in-place, so wrappers for out-of-place behavior let it use like the other DAMASK classes --- python/damask/_config.py | 24 ++++++++++++++++++++++++ python/tests/test_Config.py | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/python/damask/_config.py b/python/damask/_config.py index 91be5ebf1..c7e937656 100644 --- a/python/damask/_config.py +++ b/python/damask/_config.py @@ -99,6 +99,30 @@ class Config(dict): fhandle.write(yaml.dump(self,Dumper=NiceDumper,**kwargs)) + def add(self,d): + """ + Add dictionary. + + d : dict + Dictionary to append. + """ + duplicate = self.copy() + duplicate.update(d) + return duplicate + + + def delete(self,key): + """ + Delete item. + + key : dict + Label of the key to remove. + """ + duplicate = self.copy() + del duplicate[key] + return duplicate + + @property @abc.abstractmethod def is_complete(self): diff --git a/python/tests/test_Config.py b/python/tests/test_Config.py index 67c419b3e..0319fb6de 100644 --- a/python/tests/test_Config.py +++ b/python/tests/test_Config.py @@ -22,6 +22,10 @@ class TestConfig: with open(tmp_path/'config.yaml') as f: assert Config.load(f) == config + def test_add_remove(self): + config = Config() + assert config.add({'hello':'world'}).delete('hello') == config + def test_repr(self,tmp_path): config = Config() config['A'] = 1 From 80b8693a66dcc99e038a5a2a429f3e5a6e984912 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 3 Jan 2021 12:10:39 +0100 Subject: [PATCH 069/352] avoid adding to existing data, i.e. when reading a file --- python/damask/_configmaterial.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 83ebdd5a5..6415ee4dc 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -11,11 +11,10 @@ class ConfigMaterial(Config): 'homogenization': {}, 'phase': {}} - def __init__(self,d={}): + def __init__(self,d=_defaults): """Initialize object with default dictionary keys.""" super().__init__(d) - for k,v in self._defaults.items(): - if k not in self: self[k] = v + def save(self,fname='material.yaml',**kwargs): """ From 98723cb0ed5155d83bf6e2605e35466d575e40bd Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 3 Jan 2021 15:50:15 +0100 Subject: [PATCH 070/352] need to handle special case of Re() = 0 ensuring that the real part is positive seems to be a good idea on first sight, but it would be easier to simply acknowledge that qu = -qu --- python/damask/_rotation.py | 4 +++- python/tests/test_Rotation.py | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 492ca8d2d..4b03e8f56 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -105,8 +105,10 @@ class Rotation: Rotation to check for equality. """ + ambiguous = np.isclose(self.quaternion[...,0],0) return np.prod(self.shape,dtype=int) == np.prod(other.shape,dtype=int) \ - and np.allclose(self.quaternion,other.quaternion) + and ( np.allclose(self.quaternion,other.quaternion) \ + or np.allclose(self.quaternion[ambiguous],-1*other.quaternion[ambiguous])) @property diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index f8f1a3da7..bc6614fb9 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -786,6 +786,12 @@ class TestRotation: def test_equal(self): assert Rotation.from_random(rng_seed=1) == Rotation.from_random(rng_seed=1) + def test_equal_ambiguous(self): + qu = np.random.rand(10,4) + qu[:,0] = 0. + qu/=np.linalg.norm(qu,axis=1,keepdims=True) + assert Rotation(qu) == Rotation(-qu) + def test_inversion(self): r = Rotation.from_random() assert r == ~~r From f48a4463535761071bafeab9639122163b564750 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 3 Jan 2021 15:54:41 +0100 Subject: [PATCH 071/352] compatible with scipy.spatial.transform.Rotation also introduced inplace variants and '/' as multiplicative inverse of '*' --- python/damask/_rotation.py | 85 ++++++++++++++++++++++++++++++++++- python/tests/test_Rotation.py | 39 ++++++++++++++++ 2 files changed, 122 insertions(+), 2 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 4b03e8f56..9fb83af7b 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -144,10 +144,91 @@ class Rotation: p = self.quaternion[...,1:]/np.linalg.norm(self.quaternion[...,1:],axis=-1,keepdims=True) return self.copy(rotation=Rotation(np.block([np.cos(pwr*phi),np.sin(pwr*phi)*p]))._standardize()) + def __ipow__(self,pwr): + """ + Raise quaternion to power (in-place). + + Equivalent to performing the rotation 'pwr' times. + + Parameters + ---------- + pwr : float + Power to raise quaternion to. + + """ + return self**pwr + def __mul__(self,other): - """Standard multiplication is not implemented.""" - raise NotImplementedError('Use "R@b", i.e. matmul, to apply rotation "R" to object "b"') + """ + Compose this rotation with other. + + Parameters + ---------- + other : damask.Rotation of shape(self.shape) + Rotation for comosition. + + """ + if isinstance(other,Rotation): + return self@other + else: + raise TypeError('Use "R@b", i.e. matmul, to apply rotation "R" to object "b"') + + def __imul__(self,other): + """ + Compose this rotation with other (in-place). + + Parameters + ---------- + other : damask.Rotation of shape(self.shape) + Rotation for comosition. + + """ + return self*other + + + def __truediv__(self,other): + """ + Compose this rotation with inverse of other. + + Parameters + ---------- + other : damask.Rotation of shape (self.shape) + Rotation to inverse composition. + + """ + if isinstance(other,Rotation): + return self@~other + else: + raise TypeError('Use "R@b", i.e. matmul, to apply rotation "R" to object "b"') + + def __itruediv__(self,other): + """ + Compose this rotation with inverse of other (in-place). + + Parameters + ---------- + other : damask.Rotation of shape (self.shape) + Rotation to inverse composition. + + """ + return self/other + + + def apply(self,other): + """ + Apply rotation to vector or second/forth order tensor field. + + Parameters + ---------- + other : numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) + Vector or tensor on which the rotation is apply + + """ + if isinstance(other,np.ndarray): + return self@other + else: + raise TypeError('Use "R1*R2" or "R1/R2", to compose rotations') def __matmul__(self,other): diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index bc6614fb9..5aed0bea2 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -974,6 +974,45 @@ class TestRotation: R_2 = Rotation.from_Euler_angles([360,0,0],degrees=True) assert np.allclose(R_1.misorientation(R_2).as_matrix(),np.eye(3)) + def test_composition(self): + a,b = (Rotation.from_random(),Rotation.from_random()) + c = a * b + a *= b + assert c == a + + def test_composition_invalid(self): + with pytest.raises(TypeError): + Rotation()*np.ones(3) + + def test_composition_inverse(self): + a,b = (Rotation.from_random(),Rotation.from_random()) + c = a / b + a /= b + assert c == a + + def test_composition_inverse_invalid(self): + with pytest.raises(TypeError): + Rotation()/np.ones(3) + + def test_power(self): + a = Rotation.from_random() + r = (np.random.rand()-.5)*4 + b = a**r + a **= r + assert a == b + + def test_invariant(self): + R = Rotation.from_random() + assert R/R == R*R**(-1) == Rotation() + + @pytest.mark.parametrize('vec',[np.ones(3),np.ones((3,3)), np.ones((3,3,3,3))]) + def test_apply(self,vec): + assert (Rotation().from_random().apply(vec)).all() + + def test_apply_invalid(self): + with pytest.raises(TypeError): + Rotation().apply(Rotation()) + @pytest.mark.parametrize('angle',[10,20,30,40,50,60,70,80,90,100,120]) def test_average(self,angle): R = Rotation.from_axis_angle([[0,0,1,10],[0,0,1,angle]],degrees=True) From b705be96833e4154f644a90922bcf4b8cd7561f6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 3 Jan 2021 19:27:56 +0100 Subject: [PATCH 072/352] don't mix space and tabstops --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 0587fff4c..c415745bc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ [submodule "PRIVATE"] - path = PRIVATE + path = PRIVATE url = ../PRIVATE.git branch = master - shallow = true + shallow = true From d8b4b7e0f596986f1d3aaeb72d757037a41af009 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 3 Jan 2021 21:49:01 +0100 Subject: [PATCH 073/352] != and == work componentwise --- python/damask/_orientation.py | 19 +++++++++++++++---- python/damask/_rotation.py | 27 ++++++++++++++++++++++----- python/tests/test_Orientation.py | 9 ++++++--- python/tests/test_Rotation.py | 18 +++++++++++++----- 4 files changed, 56 insertions(+), 17 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 4bd8a1e96..d5be5a751 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -225,10 +225,21 @@ class Orientation(Rotation): Orientation to check for equality. """ - return super().__eq__(other) \ - and self.family == other.family \ - and self.lattice == other.lattice \ - and self.parameters == other.parameters + matching_type = all([hasattr(other,attr) and getattr(self,attr) == getattr(other,attr) + for attr in ['family','lattice','parameters']]) + return np.logical_and(super().__eq__(other),matching_type) + + def __ne__(self,other): + """ + Not equal to other. + + Parameters + ---------- + other : Orientation + Orientation to check for equality. + + """ + return np.logical_not(self==other) def __matmul__(self,other): diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 9fb83af7b..50b7a3678 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -66,7 +66,7 @@ class Rotation: def __repr__(self): """Represent rotation as unit quaternion, rotation matrix, and Bunge-Euler angles.""" - if self == Rotation(): + if self.shape == () and self == Rotation(): return 'Rotation()' else: return f'Quaternions {self.shape}:\n'+str(self.quaternion) \ @@ -105,10 +105,27 @@ class Rotation: Rotation to check for equality. """ - ambiguous = np.isclose(self.quaternion[...,0],0) - return np.prod(self.shape,dtype=int) == np.prod(other.shape,dtype=int) \ - and ( np.allclose(self.quaternion,other.quaternion) \ - or np.allclose(self.quaternion[ambiguous],-1*other.quaternion[ambiguous])) + s = self.quaternion + o = other.quaternion + if self.shape == () == other.shape: + return np.allclose(s,o) or (np.isclose(s[0],0.0) and np.allclose(s,-1.0*o)) + else: + return np.all(np.isclose(s,o),-1) + np.all(np.isclose(s,-1.0*o),-1) * np.isclose(s[...,0],0.0) + + def __ne__(self,other): + """ + Not equal to other. + + Equality is determined taking limited floating point precision into + account. See numpy.allclose for details. + + Parameters + ---------- + other : Rotation + Rotation to check for equality. + + """ + return np.logical_not(self==other) @property diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 5ab0361a8..436b73c04 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -25,13 +25,16 @@ class TestOrientation: @pytest.mark.parametrize('shape',[None,5,(4,6)]) def test_equal(self,lattice,shape): R = Rotation.from_random(shape) - assert Orientation(R,lattice) == Orientation(R,lattice) + assert Orientation(R,lattice) == Orientation(R,lattice) if shape is None else \ + (Orientation(R,lattice) == Orientation(R,lattice)).all() + @pytest.mark.parametrize('lattice',Orientation.crystal_families) @pytest.mark.parametrize('shape',[None,5,(4,6)]) def test_unequal(self,lattice,shape): R = Rotation.from_random(shape) - assert not(Orientation(R,lattice) != Orientation(R,lattice)) + assert not ( Orientation(R,lattice) != Orientation(R,lattice) if shape is None else \ + (Orientation(R,lattice) != Orientation(R,lattice)).any()) @pytest.mark.parametrize('a,b',[ (dict(rotation=[1,0,0,0]), @@ -403,7 +406,7 @@ class TestOrientation: def test_relationship_vectorize(self,set_of_quaternions,lattice,model): r = Orientation(rotation=set_of_quaternions[:200].reshape((50,4,4)),lattice=lattice).related(model) for i in range(200): - assert r.reshape((-1,200))[:,i] == Orientation(set_of_quaternions[i],lattice).related(model) + assert (r.reshape((-1,200))[:,i] == Orientation(set_of_quaternions[i],lattice).related(model)).all() @pytest.mark.parametrize('model',['Bain','KS','GT','GT_prime','NW','Pitsch']) @pytest.mark.parametrize('lattice',['cF','cI']) diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 5aed0bea2..014efda99 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -783,14 +783,22 @@ class TestRotation: else: assert r.shape == shape - def test_equal(self): - assert Rotation.from_random(rng_seed=1) == Rotation.from_random(rng_seed=1) + @pytest.mark.parametrize('shape',[None,5,(4,6)]) + def test_equal(self,shape): + R = Rotation.from_random(shape,rng_seed=1) + assert R == R if shape is None else (R == R).all() + + @pytest.mark.parametrize('shape',[None,5,(4,6)]) + def test_unequal(self,shape): + R = Rotation.from_random(shape,rng_seed=1) + assert not (R != R if shape is None else (R != R).any()) + def test_equal_ambiguous(self): qu = np.random.rand(10,4) qu[:,0] = 0. qu/=np.linalg.norm(qu,axis=1,keepdims=True) - assert Rotation(qu) == Rotation(-qu) + assert (Rotation(qu) == Rotation(-qu)).all() def test_inversion(self): r = Rotation.from_random() @@ -807,7 +815,7 @@ class TestRotation: p = Rotation.from_random(shape=shape) s = r.append(p) print(f'append 2x {shape} --> {s.shape}') - assert s[0,...] == r[0,...] and s[-1,...] == p[-1,...] + assert np.logical_and(s[0,...] == r[0,...], s[-1,...] == p[-1,...]).all() @pytest.mark.parametrize('quat,standardized',[ ([-1,0,0,0],[1,0,0,0]), @@ -829,7 +837,7 @@ class TestRotation: @pytest.mark.parametrize('order',['C','F']) def test_flatten_reshape(self,shape,order): r = Rotation.from_random(shape=shape) - assert r == r.flatten(order).reshape(shape,order) + assert (r == r.flatten(order).reshape(shape,order)).all() @pytest.mark.parametrize('function',[Rotation.from_quaternion, Rotation.from_Euler_angles, From acbb564afc58eaf30524cedd535de028837ea3dd Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 4 Jan 2021 07:23:14 +0100 Subject: [PATCH 074/352] restored functionalitity for adding list. got accidently lost --- python/damask/_rotation.py | 12 ++++++++++-- python/tests/test_Rotation.py | 8 ++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 50b7a3678..b7be4f16d 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -303,8 +303,16 @@ class Rotation: def append(self,other): - """Extend rotation array along first dimension with other array.""" - return self.copy(rotation=np.vstack((self.quaternion,other.quaternion))) + """ + Extend rotation array along first dimension with other array(s). + + Parameters + ---------- + other : Rotation or list of Rotations. + + """ + return self.copy(rotation=np.vstack(tuple(map(lambda x:x.quaternion, + [self]+other if isinstance(other,list) else [self,other])))) def flatten(self,order = 'C'): diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 014efda99..3def59213 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -817,6 +817,14 @@ class TestRotation: print(f'append 2x {shape} --> {s.shape}') assert np.logical_and(s[0,...] == r[0,...], s[-1,...] == p[-1,...]).all() + @pytest.mark.parametrize('shape',[None,1,(1,),(4,2),(3,3,2)]) + def test_append_list(self,shape): + r = Rotation.from_random(shape=shape) + p = Rotation.from_random(shape=shape) + s = r.append([r,p]) + print(f'append 3x {shape} --> {s.shape}') + assert np.logical_and(s[0,...] == r[0,...], s[-1,...] == p[-1,...]).all() + @pytest.mark.parametrize('quat,standardized',[ ([-1,0,0,0],[1,0,0,0]), ([-0.5,-0.5,-0.5,-0.5],[0.5,0.5,0.5,0.5]), From 94cfe28128037cd06990a52ab0fd266ce3ed7b9b Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 6 Jan 2021 18:03:10 -0500 Subject: [PATCH 075/352] polishing help; Rotation.apply(Rotation) now acceptable. --- python/damask/_config.py | 2 +- python/damask/_rotation.py | 11 ++++------- python/tests/test_Rotation.py | 11 ++++------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/python/damask/_config.py b/python/damask/_config.py index c7e937656..9aa031ff0 100644 --- a/python/damask/_config.py +++ b/python/damask/_config.py @@ -115,7 +115,7 @@ class Config(dict): """ Delete item. - key : dict + key : str or scalar Label of the key to remove. """ duplicate = self.copy() diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index b7be4f16d..d68cea6d3 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -234,18 +234,15 @@ class Rotation: def apply(self,other): """ - Apply rotation to vector or second/forth order tensor field. + Apply rotation to vector, second or fourth order tensor, or rotation object. Parameters ---------- - other : numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) - Vector or tensor on which the rotation is apply + other : numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) or Rotation + Vector, tensor, or rotation object on which to apply the rotation. """ - if isinstance(other,np.ndarray): - return self@other - else: - raise TypeError('Use "R1*R2" or "R1/R2", to compose rotations') + return self@other def __matmul__(self,other): diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 3def59213..707bc0210 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -1021,13 +1021,10 @@ class TestRotation: R = Rotation.from_random() assert R/R == R*R**(-1) == Rotation() - @pytest.mark.parametrize('vec',[np.ones(3),np.ones((3,3)), np.ones((3,3,3,3))]) - def test_apply(self,vec): - assert (Rotation().from_random().apply(vec)).all() - - def test_apply_invalid(self): - with pytest.raises(TypeError): - Rotation().apply(Rotation()) + @pytest.mark.parametrize('item',[Rotation(),np.ones(3),np.ones((3,3)), np.ones((3,3,3,3))]) + def test_apply(self,item): + r = Rotation.from_random() + assert r.apply(item) == r@item if isinstance(item,Rotation) else (r.apply(item) == r@item).all() @pytest.mark.parametrize('angle',[10,20,30,40,50,60,70,80,90,100,120]) def test_average(self,angle): From 7ac8fa307818d14c8cc56473f0991ad45feae669 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Thu, 7 Jan 2021 16:37:28 +0100 Subject: [PATCH 076/352] updated PRIVATE --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 899f0ae9e..76f383c4e 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 899f0ae9e25ddad62530ec8a9381cf520aad083b +Subproject commit 76f383c4e57cb41b55de9aad4d9baf209a91633d From f0351e403a9b307ed7cba614db3a22df5dac8213 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 7 Jan 2021 11:01:15 -0500 Subject: [PATCH 077/352] removed duplicate test --- python/tests/test_Rotation.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 1067e8a87..707bc0210 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -825,14 +825,6 @@ class TestRotation: print(f'append 3x {shape} --> {s.shape}') assert np.logical_and(s[0,...] == r[0,...], s[-1,...] == p[-1,...]).all() - @pytest.mark.parametrize('shape',[None,1,(1,),(4,2),(3,3,2)]) - def test_append_list(self,shape): - r = Rotation.from_random(shape=shape) - p = Rotation.from_random(shape=shape) - s = r.append([r,p]) - print(f'append 3x {shape} --> {s.shape}') - assert s[0,...] == r[0,...] and s[-1,...] == p[-1,...] - @pytest.mark.parametrize('quat,standardized',[ ([-1,0,0,0],[1,0,0,0]), ([-0.5,-0.5,-0.5,-0.5],[0.5,0.5,0.5,0.5]), From 52aaf2fa5e73d205703925e9645cd5d4301bd943 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Thu, 7 Jan 2021 17:04:30 +0100 Subject: [PATCH 078/352] not needed --- src/mesh/discretization_mesh.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/discretization_mesh.f90 b/src/mesh/discretization_mesh.f90 index 67b061fa4..1320d2609 100644 --- a/src/mesh/discretization_mesh.f90 +++ b/src/mesh/discretization_mesh.f90 @@ -68,7 +68,7 @@ subroutine discretization_mesh_init(restart) integer, allocatable, dimension(:) :: chunkPos integer :: dimPlex, & mesh_Nnodes, & !< total number of nodes in mesh - j, l, k, & + j, l, & debug_element, debug_ip PetscSF :: sf DM :: globalMesh From 27f4e4ce2abb980028f38509e92127ca32196593 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 7 Jan 2021 22:15:18 +0100 Subject: [PATCH 079/352] separate state for thermal --- src/constitutive.f90 | 146 ++------------- src/constitutive_mech.f90 | 10 + src/constitutive_thermal.f90 | 212 ++++++++++++++++++++-- src/constitutive_thermal_dissipation.f90 | 2 +- src/constitutive_thermal_externalheat.f90 | 24 +-- src/homogenization.f90 | 12 +- src/homogenization_thermal.f90 | 4 +- src/thermal_conduction.f90 | 43 +++-- src/thermal_isothermal.f90 | 26 ++- 9 files changed, 299 insertions(+), 180 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index f9537a136..6a023022f 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -90,6 +90,7 @@ module constitutive phase_kinematics !< active kinematic mechanisms of each phase integer, dimension(:), allocatable, public :: & !< ToDo: should be protected (bug in Intel compiler) + thermal_Nsources, & phase_Nsources, & !< number of source mechanisms active in each phase phase_Nkinematics, & !< number of kinematic mechanisms active in each phase phase_NstiffnessDegradations, & !< number of stiffness degradation mechanisms active in each phase @@ -233,6 +234,16 @@ module constitutive ! == cleaned:end =================================================================================== + module function integrateThermalState(dt,co,ip,el) result(broken) + + real(pReal), intent(in) :: dt + integer, intent(in) :: & + el, & !< element index in element loop + ip, & !< integration point index in ip loop + co !< grain index in grain loop + logical :: broken + end function + module function crystallite_stress(dt,co,ip,el) result(converged_) real(pReal), intent(in) :: dt integer, intent(in) :: co, ip, el @@ -665,31 +676,6 @@ function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) end function constitutive_damage_collectDotState -!-------------------------------------------------------------------------------------------------- -!> @brief contains the constitutive equation for calculating the rate of change of microstructure -!-------------------------------------------------------------------------------------------------- -function constitutive_thermal_collectDotState(ph,me) result(broken) - - integer, intent(in) :: ph, me - logical :: broken - - integer :: i - - - broken = .false. - - SourceLoop: do i = 1, phase_Nsources(ph) - - if (phase_source(i,ph) == SOURCE_thermal_externalheat_ID) & - call source_thermal_externalheat_dotState(ph,me) - - broken = broken .or. any(IEEE_is_NaN(sourceState(ph)%p(i)%dotState(:,me))) - - enddo SourceLoop - -end function constitutive_thermal_collectDotState - - !-------------------------------------------------------------------------------------------------- !> @brief for constitutive models having an instantaneous change of state !> will return false if delta state is not needed/supported by the constitutive model @@ -856,7 +842,7 @@ subroutine crystallite_init() cMax, & !< maximum number of integration point components iMax, & !< maximum number of integration points eMax !< maximum number of elements - + class(tNode), pointer :: & num_crystallite, & @@ -914,6 +900,9 @@ subroutine crystallite_init() do so = 1, phase_Nsources(ph) allocate(sourceState(ph)%p(so)%subState0,source=sourceState(ph)%p(so)%state0) ! ToDo: hack enddo + do so = 1, thermal_Nsources(ph) + allocate(thermalState(ph)%p(so)%subState0,source=thermalState(ph)%p(so)%state0) ! ToDo: hack + enddo enddo print'(a42,1x,i10)', ' # of elements: ', eMax @@ -1144,111 +1133,6 @@ function integrateSourceState(dt,co,ip,el) result(broken) end function integrateSourceState - -!-------------------------------------------------------------------------------------------------- -!> @brief integrate stress, state with adaptive 1st order explicit Euler method -!> using Fixed Point Iteration to adapt the stepsize -!-------------------------------------------------------------------------------------------------- -function integrateThermalState(dt,co,ip,el) result(broken) - - real(pReal), intent(in) :: dt - integer, intent(in) :: & - el, & !< element index in element loop - ip, & !< integration point index in ip loop - co !< grain index in grain loop - - integer :: & - NiterationState, & !< number of iterations in state loop - ph, & - me, & - so - integer, dimension(maxval(phase_Nsources)) :: & - size_so - real(pReal) :: & - zeta - real(pReal), dimension(constitutive_source_maxSizeDotState) :: & - r ! state residuum - real(pReal), dimension(constitutive_source_maxSizeDotState,2,maxval(phase_Nsources)) :: source_dotState - logical :: & - broken, converged_ - - - ph = material_phaseAt(co,el) - me = material_phaseMemberAt(co,ip,el) - - converged_ = .true. - broken = constitutive_thermal_collectDotState(ph,me) - if(broken) return - - do so = 1, phase_Nsources(ph) - size_so(so) = thermalState(ph)%p(so)%sizeDotState - thermalState(ph)%p(so)%state(1:size_so(so),me) = thermalState(ph)%p(so)%subState0(1:size_so(so),me) & - + thermalState(ph)%p(so)%dotState (1:size_so(so),me) * dt - source_dotState(1:size_so(so),2,so) = 0.0_pReal - enddo - - iteration: do NiterationState = 1, num%nState - - do so = 1, phase_Nsources(ph) - if(nIterationState > 1) source_dotState(1:size_so(so),2,so) = source_dotState(1:size_so(so),1,so) - source_dotState(1:size_so(so),1,so) = thermalState(ph)%p(so)%dotState(:,me) - enddo - - broken = constitutive_thermal_collectDotState(ph,me) - broken = broken .or. constitutive_damage_collectDotState(co,ip,el,ph,me) - if(broken) exit iteration - - do so = 1, phase_Nsources(ph) - zeta = damper(thermalState(ph)%p(so)%dotState(:,me), & - source_dotState(1:size_so(so),1,so),& - source_dotState(1:size_so(so),2,so)) - thermalState(ph)%p(so)%dotState(:,me) = thermalState(ph)%p(so)%dotState(:,me) * zeta & - + source_dotState(1:size_so(so),1,so)* (1.0_pReal - zeta) - r(1:size_so(so)) = thermalState(ph)%p(so)%state (1:size_so(so),me) & - - thermalState(ph)%p(so)%subState0(1:size_so(so),me) & - - thermalState(ph)%p(so)%dotState (1:size_so(so),me) * dt - thermalState(ph)%p(so)%state(1:size_so(so),me) = thermalState(ph)%p(so)%state(1:size_so(so),me) & - - r(1:size_so(so)) - converged_ = converged_ .and. converged(r(1:size_so(so)), & - thermalState(ph)%p(so)%state(1:size_so(so),me), & - thermalState(ph)%p(so)%atol(1:size_so(so))) - enddo - - if(converged_) then - broken = constitutive_damage_deltaState(mech_F_e(ph,me),co,ip,el,ph,me) - exit iteration - endif - - enddo iteration - - broken = broken .or. .not. converged_ - - - contains - - !-------------------------------------------------------------------------------------------------- - !> @brief calculate the damping for correction of state and dot state - !-------------------------------------------------------------------------------------------------- - real(pReal) pure function damper(current,previous,previous2) - - real(pReal), dimension(:), intent(in) ::& - current, previous, previous2 - - real(pReal) :: dot_prod12, dot_prod22 - - dot_prod12 = dot_product(current - previous, previous - previous2) - dot_prod22 = dot_product(previous - previous2, previous - previous2) - if ((dot_product(current,previous) < 0.0_pReal .or. dot_prod12 < 0.0_pReal) .and. dot_prod22 > 0.0_pReal) then - damper = 0.75_pReal + 0.25_pReal * tanh(2.0_pReal + 4.0_pReal * dot_prod12 / dot_prod22) - else - damper = 1.0_pReal - endif - - end function damper - -end function integrateThermalState - - !-------------------------------------------------------------------------------------------------- !> @brief determines whether a point is converged !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index fccccf00c..9a065a829 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1588,6 +1588,9 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) do so = 1, phase_Nsources(ph) sourceState(ph)%p(so)%subState0(:,me) = sourceState(ph)%p(so)%partitionedState0(:,me) enddo + do so = 1, thermal_Nsources(ph) + thermalState(ph)%p(so)%subState0(:,me) = thermalState(ph)%p(so)%partitionedState0(:,me) + enddo subFp0 = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) subFi0 = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) subF0 = constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) @@ -1616,6 +1619,9 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) do so = 1, phase_Nsources(ph) sourceState(ph)%p(so)%subState0(:,me) = sourceState(ph)%p(so)%state(:,me) enddo + do so = 1, thermal_Nsources(ph) + thermalState(ph)%p(so)%subState0(:,me) = thermalState(ph)%p(so)%state(:,me) + enddo endif !-------------------------------------------------------------------------------------------------- ! cut back (reduced time and restore) @@ -1632,6 +1638,9 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) do so = 1, phase_Nsources(ph) sourceState(ph)%p(so)%state(:,me) = sourceState(ph)%p(so)%subState0(:,me) enddo + do so = 1, thermal_Nsources(ph) + thermalState(ph)%p(so)%state(:,me) = thermalState(ph)%p(so)%subState0(:,me) + enddo todo = subStep > num%subStepMinCryst ! still on track or already done (beyond repair) endif @@ -1645,6 +1654,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) converged_ = .not. integrateState(subF0,subF,subFp0,subFi0,subState0(1:sizeDotState),subStep * dt,co,ip,el) converged_ = converged_ .and. .not. integrateSourceState(subStep * dt,co,ip,el) + converged_ = converged_ .and. .not. integrateThermalState(subStep * dt,co,ip,el) endif enddo cutbackLooping diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index f1675f0a1..c86a286f9 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -6,9 +6,12 @@ submodule(constitutive) constitutive_thermal type :: tDataContainer real(pReal), dimension(:), allocatable :: T end type tDataContainer + integer(kind(SOURCE_undefined_ID)), dimension(:,:), allocatable :: & + thermal_source type(tDataContainer), dimension(:), allocatable :: current + integer :: thermal_source_maxSizeDotState interface module function source_thermal_dissipation_init(source_length) result(mySources) @@ -60,30 +63,55 @@ module subroutine thermal_init(phases) class(tNode), pointer :: & phases + class(tNode), pointer :: & + phase, thermal, sources + integer :: & - ph, & + ph, so, & Nconstituents - print'(/,a)', ' <<<+- constitutive_mech init -+>>>' + print'(/,a)', ' <<<+- constitutive_thermal init -+>>>' allocate(current(phases%length)) + allocate(thermalState (phases%length)) + allocate(thermal_Nsources(phases%length),source = 0) do ph = 1, phases%length Nconstituents = count(material_phaseAt == ph) * discretization_nIPs allocate(current(ph)%T(Nconstituents)) + phase => phases%get(ph) + if(phase%contains('thermal')) then + thermal => phase%get('thermal') + sources => thermal%get('source',defaultVal=emptyList) + thermal_Nsources(ph) = sources%length + endif + allocate(thermalstate(ph)%p(thermal_Nsources(ph))) enddo -! initialize source mechanisms - if(maxval(phase_Nsources) /= 0) then - where(source_thermal_dissipation_init (maxval(phase_Nsources))) phase_source = SOURCE_thermal_dissipation_ID - where(source_thermal_externalheat_init(maxval(phase_Nsources))) phase_source = SOURCE_thermal_externalheat_ID + allocate(thermal_source(maxval(thermal_Nsources),phases%length), source = SOURCE_undefined_ID) + + if(maxval(thermal_Nsources) /= 0) then + where(source_thermal_dissipation_init (maxval(thermal_Nsources))) thermal_source = SOURCE_thermal_dissipation_ID + where(source_thermal_externalheat_init(maxval(thermal_Nsources))) thermal_source = SOURCE_thermal_externalheat_ID endif + thermal_source_maxSizeDotState = 0 + PhaseLoop2:do ph = 1,phases%length + + do so = 1,thermal_Nsources(ph) + thermalState(ph)%p(so)%partitionedState0 = thermalState(ph)%p(so)%state0 + thermalState(ph)%p(so)%state = thermalState(ph)%p(so)%partitionedState0 + enddo + + thermal_source_maxSizeDotState = max(thermal_source_maxSizeDotState, & + maxval(thermalState(ph)%p%sizeDotState)) + enddo PhaseLoop2 + !-------------------------------------------------------------------------------------------------- !initialize kinematic mechanisms if(maxval(phase_Nkinematics) /= 0) where(kinematics_thermal_expansion_init(maxval(phase_Nkinematics))) & @@ -123,8 +151,8 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, do co = 1, homogenization_Nconstituents(homog) ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) - do so = 1, phase_Nsources(ph) - select case(phase_source(so,ph)) + do so = 1, thermal_Nsources(ph) + select case(thermal_source(so,ph)) case (SOURCE_thermal_dissipation_ID) call source_thermal_dissipation_getRateAndItsTangent(my_Tdot, my_dTdot_dT, & mech_S(ph,me),mech_L_p(ph,me), ph) @@ -145,6 +173,131 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, end subroutine constitutive_thermal_getRateAndItsTangents +!-------------------------------------------------------------------------------------------------- +!> @brief contains the constitutive equation for calculating the rate of change of microstructure +!-------------------------------------------------------------------------------------------------- +function constitutive_thermal_collectDotState(ph,me) result(broken) + + integer, intent(in) :: ph, me + logical :: broken + + integer :: i + + + broken = .false. + + SourceLoop: do i = 1, thermal_Nsources(ph) + + if (thermal_source(i,ph) == SOURCE_thermal_externalheat_ID) & + call source_thermal_externalheat_dotState(ph,me) + + broken = broken .or. any(IEEE_is_NaN(thermalState(ph)%p(i)%dotState(:,me))) + + enddo SourceLoop + +end function constitutive_thermal_collectDotState + + +!-------------------------------------------------------------------------------------------------- +!> @brief integrate stress, state with adaptive 1st order explicit Euler method +!> using Fixed Point Iteration to adapt the stepsize +!-------------------------------------------------------------------------------------------------- +module function integrateThermalState(dt,co,ip,el) result(broken) + + real(pReal), intent(in) :: dt + integer, intent(in) :: & + el, & !< element index in element loop + ip, & !< integration point index in ip loop + co !< grain index in grain loop + + integer :: & + NiterationState, & !< number of iterations in state loop + ph, & + me, & + so + integer, dimension(maxval(thermal_Nsources)) :: & + size_so + real(pReal) :: & + zeta + real(pReal), dimension(thermal_source_maxSizeDotState) :: & + r ! state residuum + real(pReal), dimension(thermal_source_maxSizeDotState,2,maxval(thermal_Nsources)) :: source_dotState + logical :: & + broken, converged_ + + + ph = material_phaseAt(co,el) + me = material_phaseMemberAt(co,ip,el) + + converged_ = .true. + broken = constitutive_thermal_collectDotState(ph,me) + if(broken) return + + do so = 1, thermal_Nsources(ph) + size_so(so) = thermalState(ph)%p(so)%sizeDotState + thermalState(ph)%p(so)%state(1:size_so(so),me) = thermalState(ph)%p(so)%subState0(1:size_so(so),me) & + + thermalState(ph)%p(so)%dotState (1:size_so(so),me) * dt + source_dotState(1:size_so(so),2,so) = 0.0_pReal + enddo + + iteration: do NiterationState = 1, num%nState + + do so = 1, thermal_Nsources(ph) + if(nIterationState > 1) source_dotState(1:size_so(so),2,so) = source_dotState(1:size_so(so),1,so) + source_dotState(1:size_so(so),1,so) = thermalState(ph)%p(so)%dotState(:,me) + enddo + + broken = constitutive_thermal_collectDotState(ph,me) + if(broken) exit iteration + + do so = 1, thermal_Nsources(ph) + zeta = damper(thermalState(ph)%p(so)%dotState(:,me), & + source_dotState(1:size_so(so),1,so),& + source_dotState(1:size_so(so),2,so)) + thermalState(ph)%p(so)%dotState(:,me) = thermalState(ph)%p(so)%dotState(:,me) * zeta & + + source_dotState(1:size_so(so),1,so)* (1.0_pReal - zeta) + r(1:size_so(so)) = thermalState(ph)%p(so)%state (1:size_so(so),me) & + - thermalState(ph)%p(so)%subState0(1:size_so(so),me) & + - thermalState(ph)%p(so)%dotState (1:size_so(so),me) * dt + thermalState(ph)%p(so)%state(1:size_so(so),me) = thermalState(ph)%p(so)%state(1:size_so(so),me) & + - r(1:size_so(so)) + converged_ = converged_ .and. converged(r(1:size_so(so)), & + thermalState(ph)%p(so)%state(1:size_so(so),me), & + thermalState(ph)%p(so)%atol(1:size_so(so))) + enddo + + if(converged_) exit iteration + + enddo iteration + + broken = broken .or. .not. converged_ + + + contains + + !-------------------------------------------------------------------------------------------------- + !> @brief calculate the damping for correction of state and dot state + !-------------------------------------------------------------------------------------------------- + real(pReal) pure function damper(current,previous,previous2) + + real(pReal), dimension(:), intent(in) ::& + current, previous, previous2 + + real(pReal) :: dot_prod12, dot_prod22 + + dot_prod12 = dot_product(current - previous, previous - previous2) + dot_prod22 = dot_product(previous - previous2, previous - previous2) + if ((dot_product(current,previous) < 0.0_pReal .or. dot_prod12 < 0.0_pReal) .and. dot_prod22 > 0.0_pReal) then + damper = 0.75_pReal + 0.25_pReal * tanh(2.0_pReal + 4.0_pReal * dot_prod12 / dot_prod22) + else + damper = 1.0_pReal + endif + + end function damper + +end function integrateThermalState + + module subroutine thermal_initializeRestorationPoints(ph,me) @@ -153,7 +306,7 @@ module subroutine thermal_initializeRestorationPoints(ph,me) integer :: so - do so = 1, size(sourceState(ph)%p) + do so = 1, size(thermalState(ph)%p) thermalState(ph)%p(so)%partitionedState0(:,me) = thermalState(ph)%p(so)%state0(:,me) enddo @@ -168,7 +321,7 @@ module subroutine thermal_windForward(ph,me) integer :: so - do so = 1, size(sourceState(ph)%p) + do so = 1, size(thermalState(ph)%p) thermalState(ph)%p(so)%partitionedState0(:,me) = thermalState(ph)%p(so)%state(:,me) enddo @@ -181,7 +334,7 @@ module subroutine thermal_forward() do ph = 1, size(thermalState) - do so = 1, size(sourceState(ph)%p) + do so = 1, size(thermalState(ph)%p) thermalState(ph)%p(so)%state0 = thermalState(ph)%p(so)%state enddo enddo @@ -200,7 +353,7 @@ module subroutine thermal_restore(ip,el) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - do so = 1, size(sourceState(ph)%p) + do so = 1, size(thermalState(ph)%p) thermalState(ph)%p(so)%state(:,me) = thermalState(ph)%p(so)%partitionedState0(:,me) enddo @@ -237,4 +390,39 @@ module subroutine constitutive_thermal_setT(T,co,ip,el) end subroutine constitutive_thermal_setT + +!-------------------------------------------------------------------------------------------------- +!> @brief checks if a source mechanism is active or not +!-------------------------------------------------------------------------------------------------- +function thermal_active(source_label,src_length) result(active_source) + + character(len=*), intent(in) :: source_label !< name of source mechanism + integer, intent(in) :: src_length !< max. number of sources in system + logical, dimension(:,:), allocatable :: active_source + + class(tNode), pointer :: & + phases, & + phase, & + sources, thermal, & + src + integer :: p,s + + phases => config_material%get('phase') + allocate(active_source(src_length,phases%length), source = .false. ) + do p = 1, phases%length + phase => phases%get(p) + if (phase%contains('thermal')) then + thermal => phase%get('thermal',defaultVal=emptyList) + sources => thermal%get('source',defaultVal=emptyList) + do s = 1, sources%length + src => sources%get(s) + if(src%get_asString('type') == source_label) active_source(s,p) = .true. + enddo + endif + enddo + + +end function thermal_active + + end submodule constitutive_thermal diff --git a/src/constitutive_thermal_dissipation.f90 b/src/constitutive_thermal_dissipation.f90 index 27653a9ef..44227536c 100644 --- a/src/constitutive_thermal_dissipation.f90 +++ b/src/constitutive_thermal_dissipation.f90 @@ -62,7 +62,7 @@ module function source_thermal_dissipation_init(source_length) result(mySources) src => sources%get(sourceOffset) prm%kappa = src%get_asFloat('kappa') Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(sourceState(p)%p(sourceOffset),Nconstituents,0,0,0) + call constitutive_allocateState(thermalState(p)%p(sourceOffset),Nconstituents,0,0,0) end associate endif diff --git a/src/constitutive_thermal_externalheat.f90 b/src/constitutive_thermal_externalheat.f90 index 3ef96790e..de1617efa 100644 --- a/src/constitutive_thermal_externalheat.f90 +++ b/src/constitutive_thermal_externalheat.f90 @@ -13,7 +13,7 @@ submodule(constitutive:constitutive_thermal) source_externalheat type :: tParameters !< container type for internal constitutive parameters real(pReal), dimension(:), allocatable :: & - t_n, & + t_n, & f_T integer :: & nIntervals @@ -31,19 +31,20 @@ contains !-------------------------------------------------------------------------------------------------- module function source_thermal_externalheat_init(source_length) result(mySources) - integer, intent(in) :: source_length + integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources class(tNode), pointer :: & phases, & phase, & - sources, & - src + sources, thermal, & + src integer :: Ninstances,sourceOffset,Nconstituents,p print'(/,a)', ' <<<+- source_thermal_externalHeat init -+>>>' - mySources = source_active('thermal_externalheat',source_length) + mySources = thermal_active('externalheat',source_length) + Ninstances = count(mySources) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -54,15 +55,16 @@ module function source_thermal_externalheat_init(source_length) result(mySources allocate(source_thermal_externalheat_instance(phases%length), source=0) do p = 1, phases%length - phase => phases%get(p) + phase => phases%get(p) if(any(mySources(:,p))) source_thermal_externalheat_instance(p) = count(mySources(:,1:p)) if(count(mySources(:,p)) == 0) cycle - sources => phase%get('source') + thermal => phase%get('thermal') + sources => thermal%get('source') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then source_thermal_externalheat_offset(p) = sourceOffset associate(prm => param(source_thermal_externalheat_instance(p))) - src => sources%get(sourceOffset) + src => sources%get(sourceOffset) prm%t_n = src%get_asFloats('t_n') prm%nIntervals = size(prm%t_n) - 1 @@ -70,7 +72,7 @@ module function source_thermal_externalheat_init(source_length) result(mySources prm%f_T = src%get_asFloats('f_T',requiredSize = size(prm%t_n)) Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(sourceState(p)%p(sourceOffset),Nconstituents,1,1,0) + call constitutive_allocateState(thermalState(p)%p(sourceOffset),Nconstituents,1,1,0) end associate endif @@ -95,7 +97,7 @@ module subroutine source_thermal_externalheat_dotState(phase, of) sourceOffset = source_thermal_externalheat_offset(phase) - sourceState(phase)%p(sourceOffset)%dotState(1,of) = 1.0_pReal ! state is current time + thermalState(phase)%p(sourceOffset)%dotState(1,of) = 1.0_pReal ! state is current time end subroutine source_thermal_externalheat_dotState @@ -121,7 +123,7 @@ module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, dTDot_d associate(prm => param(source_thermal_externalheat_instance(phase))) do interval = 1, prm%nIntervals ! scan through all rate segments - frac_time = (sourceState(phase)%p(sourceOffset)%state(1,of) - prm%t_n(interval)) & + frac_time = (thermalState(phase)%p(sourceOffset)%state(1,of) - prm%t_n(interval)) & / (prm%t_n(interval+1) - prm%t_n(interval)) ! fractional time within segment if ( (frac_time < 0.0_pReal .and. interval == 1) & .or. (frac_time >= 1.0_pReal .and. interval == prm%nIntervals) & diff --git a/src/homogenization.f90 b/src/homogenization.f90 index df7369096..8738ba6f1 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -69,6 +69,13 @@ module homogenization el !< element number end subroutine mech_partition + module subroutine thermal_partition(T,ip,el) + real(pReal), intent(in) :: T + integer, intent(in) :: & + ip, & !< integration point + el !< element number + end subroutine thermal_partition + module subroutine mech_homogenize(dt,ip,el) real(pReal), intent(in) :: dt integer, intent(in) :: & @@ -131,9 +138,10 @@ subroutine homogenization_init call mech_init(num_homog) + call thermal_init() - if (any(thermal_type == THERMAL_isothermal_ID)) call thermal_isothermal_init - if (any(thermal_type == THERMAL_conduction_ID)) call thermal_conduction_init + if (any(thermal_type == THERMAL_isothermal_ID)) call thermal_isothermal_init(homogenization_T) + if (any(thermal_type == THERMAL_conduction_ID)) call thermal_conduction_init(homogenization_T) if (any(damage_type == DAMAGE_none_ID)) call damage_none_init if (any(damage_type == DAMAGE_nonlocal_ID)) call damage_nonlocal_init diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index 59e7357b6..f181d97fa 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -11,9 +11,11 @@ contains !-------------------------------------------------------------------------------------------------- module subroutine thermal_init() + print'(/,a)', ' <<<+- homogenization_thermal init -+>>>' - allocate(homogenization_T(discretization_nIPs*discretization_Nelems), source=0.0_pReal) + allocate(homogenization_T(discretization_nIPs*discretization_Nelems)) + end subroutine thermal_init diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index f98d36d3b..0cd1678e0 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -10,6 +10,7 @@ module thermal_conduction use results use constitutive use YAML_types + use discretization implicit none private @@ -38,25 +39,28 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -subroutine thermal_conduction_init +subroutine thermal_conduction_init(T) - integer :: Ninstances,Nmaterialpoints,h + real(pReal), dimension(:), intent(inout) :: T + + integer :: Ninstances,Nmaterialpoints,ho,ip,el,ce class(tNode), pointer :: & material_homogenization, & homog, & homogThermal - + + print'(/,a)', ' <<<+- thermal_conduction init -+>>>'; flush(6) Ninstances = count(thermal_type == THERMAL_conduction_ID) allocate(param(Ninstances)) material_homogenization => config_material%get('homogenization') - do h = 1, size(material_name_homogenization) - if (thermal_type(h) /= THERMAL_conduction_ID) cycle - homog => material_homogenization%get(h) + do ho = 1, size(material_name_homogenization) + if (thermal_type(ho) /= THERMAL_conduction_ID) cycle + homog => material_homogenization%get(ho) homogThermal => homog%get('thermal') - associate(prm => param(thermal_typeInstance(h))) + associate(prm => param(thermal_typeInstance(ho))) #if defined (__GFORTRAN__) prm%output = output_asStrings(homogThermal) @@ -64,14 +68,23 @@ subroutine thermal_conduction_init prm%output = homogThermal%get_asStrings('output',defaultVal=emptyStringArray) #endif - Nmaterialpoints=count(material_homogenizationAt==h) + Nmaterialpoints=count(material_homogenizationAt==ho) - allocate (temperature (h)%p(Nmaterialpoints), source=thermal_initialT(h)) - allocate (temperatureRate(h)%p(Nmaterialpoints), source=0.0_pReal) + allocate (temperature (ho)%p(Nmaterialpoints), source=thermal_initialT(ho)) + allocate (temperatureRate(ho)%p(Nmaterialpoints), source=0.0_pReal) end associate enddo + ce = 0 + do el = 1, discretization_Nelems + do ip = 1, discretization_nIPs + ce = ce + 1 + ho = material_homogenizationAt(el) + if (thermal_type(ho) == THERMAL_conduction_ID) T(ce) = thermal_initialT(ho) + enddo + enddo + end subroutine thermal_conduction_init @@ -89,12 +102,12 @@ subroutine thermal_conduction_getSourceAndItsTangent(Tdot, dTdot_dT, T, ip, el) Tdot, dTdot_dT integer :: & homog - + Tdot = 0.0_pReal dTdot_dT = 0.0_pReal homog = material_homogenizationAt(el) - call constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, ip, el) + call constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, ip, el) Tdot = Tdot/real(homogenization_Nconstituents(homog),pReal) dTdot_dT = dTdot_dT/real(homogenization_Nconstituents(homog),pReal) @@ -112,13 +125,13 @@ function thermal_conduction_getConductivity(ip,el) el !< element number real(pReal), dimension(3,3) :: & thermal_conduction_getConductivity - + integer :: & co thermal_conduction_getConductivity = 0.0_pReal - + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) thermal_conduction_getConductivity = thermal_conduction_getConductivity + & crystallite_push33ToRef(co,ip,el,lattice_K(:,:,material_phaseAt(co,el))) @@ -168,7 +181,7 @@ function thermal_conduction_getMassDensity(ip,el) el !< element number real(pReal) :: & thermal_conduction_getMassDensity - + integer :: & co diff --git a/src/thermal_isothermal.f90 b/src/thermal_isothermal.f90 index 2a41ada49..09e35931e 100644 --- a/src/thermal_isothermal.f90 +++ b/src/thermal_isothermal.f90 @@ -6,6 +6,7 @@ module thermal_isothermal use prec use config use material + use discretization implicit none public @@ -15,22 +16,33 @@ contains !-------------------------------------------------------------------------------------------------- !> @brief allocates fields, reads information from material configuration file !-------------------------------------------------------------------------------------------------- -subroutine thermal_isothermal_init +subroutine thermal_isothermal_init(T) - integer :: h,Nmaterialpoints + real(pReal), dimension(:), intent(inout) :: T + + integer :: Ninstances,Nmaterialpoints,ho,ip,el,ce print'(/,a)', ' <<<+- thermal_isothermal init -+>>>'; flush(6) - do h = 1, size(material_name_homogenization) - if (thermal_type(h) /= THERMAL_isothermal_ID) cycle + do ho = 1, size(thermal_type) + if (thermal_type(ho) /= THERMAL_isothermal_ID) cycle - Nmaterialpoints = count(material_homogenizationAt == h) + Nmaterialpoints = count(material_homogenizationAt == ho) - allocate(temperature (h)%p(Nmaterialpoints),source=thermal_initialT(h)) - allocate(temperatureRate(h)%p(Nmaterialpoints),source = 0.0_pReal) + allocate(temperature (ho)%p(Nmaterialpoints),source=thermal_initialT(ho)) + allocate(temperatureRate(ho)%p(Nmaterialpoints),source = 0.0_pReal) enddo + ce = 0 + do el = 1, discretization_Nelems + do ip = 1, discretization_nIPs + ce = ce + 1 + ho = material_homogenizationAt(el) + if (thermal_type(ho) == THERMAL_isothermal_ID) T(ce) = thermal_initialT(ho) + enddo + enddo + end subroutine thermal_isothermal_init end module thermal_isothermal From 1df409376c884e1138dc3b2eeb0b7f9eee76481b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 7 Jan 2021 23:32:54 +0100 Subject: [PATCH 080/352] sourceState is now damage state --- src/constitutive.f90 | 283 ++---------------------------------- src/constitutive_damage.f90 | 193 ++++++++++++++++++++++++ src/constitutive_mech.f90 | 82 ++++++++++- 3 files changed, 286 insertions(+), 272 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 6a023022f..43d9b6b3f 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -235,14 +235,22 @@ module constitutive ! == cleaned:end =================================================================================== module function integrateThermalState(dt,co,ip,el) result(broken) - real(pReal), intent(in) :: dt integer, intent(in) :: & el, & !< element index in element loop ip, & !< integration point index in ip loop co !< grain index in grain loop logical :: broken - end function + end function integrateThermalState + + module function integrateDamageState(dt,co,ip,el) result(broken) + real(pReal), intent(in) :: dt + integer, intent(in) :: & + el, & !< element index in element loop + ip, & !< integration point index in ip loop + co !< grain index in grain loop + logical :: broken + end function integrateDamageState module function crystallite_stress(dt,co,ip,el) result(converged_) real(pReal), intent(in) :: dt @@ -395,7 +403,6 @@ module constitutive public :: & constitutive_init, & constitutive_homogenizedC, & - constitutive_LiAndItsTangents, & constitutive_damage_getRateAndItsTangents, & constitutive_thermal_getRateAndItsTangents, & constitutive_results, & @@ -413,7 +420,8 @@ module constitutive crystallite_push33ToRef, & constitutive_restartWrite, & constitutive_restartRead, & - integrateSourceState, & + integrateThermalState, & + integrateDamageState, & constitutive_thermal_setT, & constitutive_mech_getP, & constitutive_mech_setF, & @@ -555,173 +563,6 @@ function kinematics_active(kinematics_label,kinematics_length) result(active_ki end function kinematics_active -!-------------------------------------------------------------------------------------------------- -!> @brief contains the constitutive equation for calculating the velocity gradient -! ToDo: MD: S is Mi? -!-------------------------------------------------------------------------------------------------- -subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & - S, Fi, co, ip, el) - - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - real(pReal), intent(in), dimension(3,3) :: & - S !< 2nd Piola-Kirchhoff stress - real(pReal), intent(in), dimension(3,3) :: & - Fi !< intermediate deformation gradient - real(pReal), intent(out), dimension(3,3) :: & - Li !< intermediate velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLi_dS, & !< derivative of Li with respect to S - dLi_dFi - - real(pReal), dimension(3,3) :: & - my_Li, & !< intermediate velocity gradient - FiInv, & - temp_33 - real(pReal), dimension(3,3,3,3) :: & - my_dLi_dS - real(pReal) :: & - detFi - integer :: & - k, i, j, & - instance, of - - Li = 0.0_pReal - dLi_dS = 0.0_pReal - dLi_dFi = 0.0_pReal - - plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) - case (PLASTICITY_isotropic_ID) plasticityType - of = material_phasememberAt(co,ip,el) - instance = phase_plasticityInstance(material_phaseAt(co,el)) - call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,instance,of) - case default plasticityType - my_Li = 0.0_pReal - my_dLi_dS = 0.0_pReal - end select plasticityType - - Li = Li + my_Li - dLi_dS = dLi_dS + my_dLi_dS - - KinematicsLoop: do k = 1, phase_Nkinematics(material_phaseAt(co,el)) - kinematicsType: select case (phase_kinematics(k,material_phaseAt(co,el))) - case (KINEMATICS_cleavage_opening_ID) kinematicsType - call kinematics_cleavage_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) - case (KINEMATICS_slipplane_opening_ID) kinematicsType - call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) - case (KINEMATICS_thermal_expansion_ID) kinematicsType - call kinematics_thermal_expansion_LiAndItsTangent(my_Li, my_dLi_dS, co, ip, el) - case default kinematicsType - my_Li = 0.0_pReal - my_dLi_dS = 0.0_pReal - end select kinematicsType - Li = Li + my_Li - dLi_dS = dLi_dS + my_dLi_dS - enddo KinematicsLoop - - FiInv = math_inv33(Fi) - detFi = math_det33(Fi) - Li = matmul(matmul(Fi,Li),FiInv)*detFi !< push forward to intermediate configuration - temp_33 = matmul(FiInv,Li) - - do i = 1,3; do j = 1,3 - dLi_dS(1:3,1:3,i,j) = matmul(matmul(Fi,dLi_dS(1:3,1:3,i,j)),FiInv)*detFi - dLi_dFi(1:3,1:3,i,j) = dLi_dFi(1:3,1:3,i,j) + Li*FiInv(j,i) - dLi_dFi(1:3,i,1:3,j) = dLi_dFi(1:3,i,1:3,j) + math_I3*temp_33(j,i) + Li*FiInv(j,i) - enddo; enddo - -end subroutine constitutive_LiAndItsTangents - - -!-------------------------------------------------------------------------------------------------- -!> @brief contains the constitutive equation for calculating the rate of change of microstructure -!-------------------------------------------------------------------------------------------------- -function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) - - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el, & !< element - ph, & - of - integer :: & - so !< counter in source loop - logical :: broken - - - broken = .false. - - SourceLoop: do so = 1, phase_Nsources(ph) - - sourceType: select case (phase_source(so,ph)) - - case (SOURCE_damage_anisoBrittle_ID) sourceType - call source_damage_anisoBrittle_dotState(mech_S(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el)),& - co, ip, el) ! correct stress? - - case (SOURCE_damage_isoDuctile_ID) sourceType - call source_damage_isoDuctile_dotState(co, ip, el) - - case (SOURCE_damage_anisoDuctile_ID) sourceType - call source_damage_anisoDuctile_dotState(co, ip, el) - - end select sourceType - - broken = broken .or. any(IEEE_is_NaN(sourceState(ph)%p(so)%dotState(:,of))) - - enddo SourceLoop - -end function constitutive_damage_collectDotState - - -!-------------------------------------------------------------------------------------------------- -!> @brief for constitutive models having an instantaneous change of state -!> will return false if delta state is not needed/supported by the constitutive model -!-------------------------------------------------------------------------------------------------- -function constitutive_damage_deltaState(Fe, co, ip, el, ph, of) result(broken) - - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el, & !< element - ph, & - of - real(pReal), intent(in), dimension(3,3) :: & - Fe !< elastic deformation gradient - integer :: & - so, & - myOffset, & - mySize - logical :: & - broken - - - broken = .false. - - sourceLoop: do so = 1, phase_Nsources(ph) - - sourceType: select case (phase_source(so,ph)) - - case (SOURCE_damage_isoBrittle_ID) sourceType - call source_damage_isoBrittle_deltaState (constitutive_homogenizedC(co,ip,el), Fe, & - co, ip, el) - broken = any(IEEE_is_NaN(sourceState(ph)%p(so)%deltaState(:,of))) - if(.not. broken) then - myOffset = sourceState(ph)%p(so)%offsetDeltaState - mySize = sourceState(ph)%p(so)%sizeDeltaState - sourceState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) = & - sourceState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) + sourceState(ph)%p(so)%deltaState(1:mySize,of) - endif - - end select sourceType - - enddo SourceLoop - -end function constitutive_damage_deltaState - - !-------------------------------------------------------------------------------------------------- !> @brief Allocate the components of the state structure for a given phase !-------------------------------------------------------------------------------------------------- @@ -1030,107 +871,7 @@ function crystallite_push33ToRef(co,ip,el, tensor33) end function crystallite_push33ToRef -!-------------------------------------------------------------------------------------------------- -!> @brief integrate stress, state with adaptive 1st order explicit Euler method -!> using Fixed Point Iteration to adapt the stepsize -!-------------------------------------------------------------------------------------------------- -function integrateSourceState(dt,co,ip,el) result(broken) - real(pReal), intent(in) :: dt - integer, intent(in) :: & - el, & !< element index in element loop - ip, & !< integration point index in ip loop - co !< grain index in grain loop - - integer :: & - NiterationState, & !< number of iterations in state loop - ph, & - me, & - so - integer, dimension(maxval(phase_Nsources)) :: & - size_so - real(pReal) :: & - zeta - real(pReal), dimension(constitutive_source_maxSizeDotState) :: & - r ! state residuum - real(pReal), dimension(constitutive_source_maxSizeDotState,2,maxval(phase_Nsources)) :: source_dotState - logical :: & - broken, converged_ - - - ph = material_phaseAt(co,el) - me = material_phaseMemberAt(co,ip,el) - - converged_ = .true. - broken = constitutive_damage_collectDotState(co,ip,el,ph,me) - if(broken) return - - do so = 1, phase_Nsources(ph) - size_so(so) = sourceState(ph)%p(so)%sizeDotState - sourceState(ph)%p(so)%state(1:size_so(so),me) = sourceState(ph)%p(so)%subState0(1:size_so(so),me) & - + sourceState(ph)%p(so)%dotState (1:size_so(so),me) * dt - source_dotState(1:size_so(so),2,so) = 0.0_pReal - enddo - - iteration: do NiterationState = 1, num%nState - - do so = 1, phase_Nsources(ph) - if(nIterationState > 1) source_dotState(1:size_so(so),2,so) = source_dotState(1:size_so(so),1,so) - source_dotState(1:size_so(so),1,so) = sourceState(ph)%p(so)%dotState(:,me) - enddo - - broken = constitutive_damage_collectDotState(co,ip,el,ph,me) - if(broken) exit iteration - - do so = 1, phase_Nsources(ph) - zeta = damper(sourceState(ph)%p(so)%dotState(:,me), & - source_dotState(1:size_so(so),1,so),& - source_dotState(1:size_so(so),2,so)) - sourceState(ph)%p(so)%dotState(:,me) = sourceState(ph)%p(so)%dotState(:,me) * zeta & - + source_dotState(1:size_so(so),1,so)* (1.0_pReal - zeta) - r(1:size_so(so)) = sourceState(ph)%p(so)%state (1:size_so(so),me) & - - sourceState(ph)%p(so)%subState0(1:size_so(so),me) & - - sourceState(ph)%p(so)%dotState (1:size_so(so),me) * dt - sourceState(ph)%p(so)%state(1:size_so(so),me) = sourceState(ph)%p(so)%state(1:size_so(so),me) & - - r(1:size_so(so)) - converged_ = converged_ .and. converged(r(1:size_so(so)), & - sourceState(ph)%p(so)%state(1:size_so(so),me), & - sourceState(ph)%p(so)%atol(1:size_so(so))) - enddo - - if(converged_) then - broken = constitutive_damage_deltaState(mech_F_e(ph,me),co,ip,el,ph,me) - exit iteration - endif - - enddo iteration - - broken = broken .or. .not. converged_ - - - contains - - !-------------------------------------------------------------------------------------------------- - !> @brief calculate the damping for correction of state and dot state - !-------------------------------------------------------------------------------------------------- - real(pReal) pure function damper(current,previous,previous2) - - real(pReal), dimension(:), intent(in) ::& - current, previous, previous2 - - real(pReal) :: dot_prod12, dot_prod22 - - dot_prod12 = dot_product(current - previous, previous - previous2) - dot_prod22 = dot_product(previous - previous2, previous - previous2) - if ((dot_product(current,previous) < 0.0_pReal .or. dot_prod12 < 0.0_pReal) .and. dot_prod22 > 0.0_pReal) then - damper = 0.75_pReal + 0.25_pReal * tanh(2.0_pReal + 4.0_pReal * dot_prod12 / dot_prod22) - else - damper = 1.0_pReal - endif - - end function damper - -end function integrateSourceState !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index 3ce614666..be47d92b6 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -214,6 +214,111 @@ module subroutine constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi end subroutine constitutive_damage_getRateAndItsTangents + +!-------------------------------------------------------------------------------------------------- +!> @brief integrate stress, state with adaptive 1st order explicit Euler method +!> using Fixed Point Iteration to adapt the stepsize +!-------------------------------------------------------------------------------------------------- +module function integrateDamageState(dt,co,ip,el) result(broken) + + real(pReal), intent(in) :: dt + integer, intent(in) :: & + el, & !< element index in element loop + ip, & !< integration point index in ip loop + co !< grain index in grain loop + logical :: broken + + integer :: & + NiterationState, & !< number of iterations in state loop + ph, & + me, & + so + integer, dimension(maxval(phase_Nsources)) :: & + size_so + real(pReal) :: & + zeta + real(pReal), dimension(constitutive_source_maxSizeDotState) :: & + r ! state residuum + real(pReal), dimension(constitutive_source_maxSizeDotState,2,maxval(phase_Nsources)) :: source_dotState + logical :: & + converged_ + + + ph = material_phaseAt(co,el) + me = material_phaseMemberAt(co,ip,el) + + converged_ = .true. + broken = constitutive_damage_collectDotState(co,ip,el,ph,me) + if(broken) return + + do so = 1, phase_Nsources(ph) + size_so(so) = sourceState(ph)%p(so)%sizeDotState + sourceState(ph)%p(so)%state(1:size_so(so),me) = sourceState(ph)%p(so)%subState0(1:size_so(so),me) & + + sourceState(ph)%p(so)%dotState (1:size_so(so),me) * dt + source_dotState(1:size_so(so),2,so) = 0.0_pReal + enddo + + iteration: do NiterationState = 1, num%nState + + do so = 1, phase_Nsources(ph) + if(nIterationState > 1) source_dotState(1:size_so(so),2,so) = source_dotState(1:size_so(so),1,so) + source_dotState(1:size_so(so),1,so) = sourceState(ph)%p(so)%dotState(:,me) + enddo + + broken = constitutive_damage_collectDotState(co,ip,el,ph,me) + if(broken) exit iteration + + do so = 1, phase_Nsources(ph) + zeta = damper(sourceState(ph)%p(so)%dotState(:,me), & + source_dotState(1:size_so(so),1,so),& + source_dotState(1:size_so(so),2,so)) + sourceState(ph)%p(so)%dotState(:,me) = sourceState(ph)%p(so)%dotState(:,me) * zeta & + + source_dotState(1:size_so(so),1,so)* (1.0_pReal - zeta) + r(1:size_so(so)) = sourceState(ph)%p(so)%state (1:size_so(so),me) & + - sourceState(ph)%p(so)%subState0(1:size_so(so),me) & + - sourceState(ph)%p(so)%dotState (1:size_so(so),me) * dt + sourceState(ph)%p(so)%state(1:size_so(so),me) = sourceState(ph)%p(so)%state(1:size_so(so),me) & + - r(1:size_so(so)) + converged_ = converged_ .and. converged(r(1:size_so(so)), & + sourceState(ph)%p(so)%state(1:size_so(so),me), & + sourceState(ph)%p(so)%atol(1:size_so(so))) + enddo + + if(converged_) then + broken = constitutive_damage_deltaState(mech_F_e(ph,me),co,ip,el,ph,me) + exit iteration + endif + + enddo iteration + + broken = broken .or. .not. converged_ + + + contains + + !-------------------------------------------------------------------------------------------------- + !> @brief calculate the damping for correction of state and dot state + !-------------------------------------------------------------------------------------------------- + real(pReal) pure function damper(current,previous,previous2) + + real(pReal), dimension(:), intent(in) ::& + current, previous, previous2 + + real(pReal) :: dot_prod12, dot_prod22 + + dot_prod12 = dot_product(current - previous, previous - previous2) + dot_prod22 = dot_product(previous - previous2, previous - previous2) + if ((dot_product(current,previous) < 0.0_pReal .or. dot_prod12 < 0.0_pReal) .and. dot_prod22 > 0.0_pReal) then + damper = 0.75_pReal + 0.25_pReal * tanh(2.0_pReal + 4.0_pReal * dot_prod12 / dot_prod22) + else + damper = 1.0_pReal + endif + + end function damper + +end function integrateDamageState + + !---------------------------------------------------------------------------------------------- !< @brief writes damage sources results to HDF5 output file !---------------------------------------------------------------------------------------------- @@ -250,4 +355,92 @@ module subroutine damage_results(group,ph) end subroutine damage_results +!-------------------------------------------------------------------------------------------------- +!> @brief contains the constitutive equation for calculating the rate of change of microstructure +!-------------------------------------------------------------------------------------------------- +function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) + + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el, & !< element + ph, & + of + integer :: & + so !< counter in source loop + logical :: broken + + + broken = .false. + + SourceLoop: do so = 1, phase_Nsources(ph) + + sourceType: select case (phase_source(so,ph)) + + case (SOURCE_damage_anisoBrittle_ID) sourceType + call source_damage_anisoBrittle_dotState(mech_S(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el)),& + co, ip, el) ! correct stress? + + case (SOURCE_damage_isoDuctile_ID) sourceType + call source_damage_isoDuctile_dotState(co, ip, el) + + case (SOURCE_damage_anisoDuctile_ID) sourceType + call source_damage_anisoDuctile_dotState(co, ip, el) + + end select sourceType + + broken = broken .or. any(IEEE_is_NaN(sourceState(ph)%p(so)%dotState(:,of))) + + enddo SourceLoop + +end function constitutive_damage_collectDotState + + + +!-------------------------------------------------------------------------------------------------- +!> @brief for constitutive models having an instantaneous change of state +!> will return false if delta state is not needed/supported by the constitutive model +!-------------------------------------------------------------------------------------------------- +function constitutive_damage_deltaState(Fe, co, ip, el, ph, of) result(broken) + + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el, & !< element + ph, & + of + real(pReal), intent(in), dimension(3,3) :: & + Fe !< elastic deformation gradient + integer :: & + so, & + myOffset, & + mySize + logical :: & + broken + + + broken = .false. + + sourceLoop: do so = 1, phase_Nsources(ph) + + sourceType: select case (phase_source(so,ph)) + + case (SOURCE_damage_isoBrittle_ID) sourceType + call source_damage_isoBrittle_deltaState (constitutive_homogenizedC(co,ip,el), Fe, & + co, ip, el) + broken = any(IEEE_is_NaN(sourceState(ph)%p(so)%deltaState(:,of))) + if(.not. broken) then + myOffset = sourceState(ph)%p(so)%offsetDeltaState + mySize = sourceState(ph)%p(so)%sizeDeltaState + sourceState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) = & + sourceState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) + sourceState(ph)%p(so)%deltaState(1:mySize,of) + endif + + end select sourceType + + enddo SourceLoop + +end function constitutive_damage_deltaState + + end submodule constitutive_damage diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 9a065a829..7c403eeea 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1653,7 +1653,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) constitutive_mech_Fe(ph)%data(1:3,1:3,me) = matmul(subF,math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) converged_ = .not. integrateState(subF0,subF,subFp0,subFi0,subState0(1:sizeDotState),subStep * dt,co,ip,el) - converged_ = converged_ .and. .not. integrateSourceState(subStep * dt,co,ip,el) + converged_ = converged_ .and. .not. integrateDamageState(subStep * dt,co,ip,el) converged_ = converged_ .and. .not. integrateThermalState(subStep * dt,co,ip,el) endif @@ -1938,5 +1938,85 @@ module subroutine constitutive_mech_setF(F,co,ip,el) end subroutine constitutive_mech_setF + +!-------------------------------------------------------------------------------------------------- +!> @brief contains the constitutive equation for calculating the velocity gradient +! ToDo: MD: S is Mi? +!-------------------------------------------------------------------------------------------------- +subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & + S, Fi, co, ip, el) + + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + real(pReal), intent(in), dimension(3,3) :: & + S !< 2nd Piola-Kirchhoff stress + real(pReal), intent(in), dimension(3,3) :: & + Fi !< intermediate deformation gradient + real(pReal), intent(out), dimension(3,3) :: & + Li !< intermediate velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLi_dS, & !< derivative of Li with respect to S + dLi_dFi + + real(pReal), dimension(3,3) :: & + my_Li, & !< intermediate velocity gradient + FiInv, & + temp_33 + real(pReal), dimension(3,3,3,3) :: & + my_dLi_dS + real(pReal) :: & + detFi + integer :: & + k, i, j, & + instance, of + + Li = 0.0_pReal + dLi_dS = 0.0_pReal + dLi_dFi = 0.0_pReal + + plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) + case (PLASTICITY_isotropic_ID) plasticityType + of = material_phasememberAt(co,ip,el) + instance = phase_plasticityInstance(material_phaseAt(co,el)) + call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,instance,of) + case default plasticityType + my_Li = 0.0_pReal + my_dLi_dS = 0.0_pReal + end select plasticityType + + Li = Li + my_Li + dLi_dS = dLi_dS + my_dLi_dS + + KinematicsLoop: do k = 1, phase_Nkinematics(material_phaseAt(co,el)) + kinematicsType: select case (phase_kinematics(k,material_phaseAt(co,el))) + case (KINEMATICS_cleavage_opening_ID) kinematicsType + call kinematics_cleavage_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) + case (KINEMATICS_slipplane_opening_ID) kinematicsType + call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) + case (KINEMATICS_thermal_expansion_ID) kinematicsType + call kinematics_thermal_expansion_LiAndItsTangent(my_Li, my_dLi_dS, co, ip, el) + case default kinematicsType + my_Li = 0.0_pReal + my_dLi_dS = 0.0_pReal + end select kinematicsType + Li = Li + my_Li + dLi_dS = dLi_dS + my_dLi_dS + enddo KinematicsLoop + + FiInv = math_inv33(Fi) + detFi = math_det33(Fi) + Li = matmul(matmul(Fi,Li),FiInv)*detFi !< push forward to intermediate configuration + temp_33 = matmul(FiInv,Li) + + do i = 1,3; do j = 1,3 + dLi_dS(1:3,1:3,i,j) = matmul(matmul(Fi,dLi_dS(1:3,1:3,i,j)),FiInv)*detFi + dLi_dFi(1:3,1:3,i,j) = dLi_dFi(1:3,1:3,i,j) + Li*FiInv(j,i) + dLi_dFi(1:3,i,1:3,j) = dLi_dFi(1:3,i,1:3,j) + math_I3*temp_33(j,i) + Li*FiInv(j,i) + enddo; enddo + +end subroutine constitutive_LiAndItsTangents + end submodule constitutive_mech From 5efa6c997a2f31d163a892800fc18d065104ea99 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 7 Jan 2021 23:50:06 +0100 Subject: [PATCH 081/352] meaningful scope --- src/constitutive.f90 | 37 +---------------------------- src/constitutive_damage.f90 | 46 ++++++++++++++++++++++-------------- src/constitutive_mech.f90 | 20 +++++++++++++--- src/constitutive_thermal.f90 | 20 ++++++++++------ 4 files changed, 59 insertions(+), 64 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 43d9b6b3f..5f96e80e6 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -21,21 +21,6 @@ module constitutive private enum, bind(c); enumerator :: & - PLASTICITY_UNDEFINED_ID, & - PLASTICITY_NONE_ID, & - PLASTICITY_ISOTROPIC_ID, & - PLASTICITY_PHENOPOWERLAW_ID, & - PLASTICITY_KINEHARDENING_ID, & - PLASTICITY_DISLOTWIN_ID, & - PLASTICITY_DISLOTUNGSTEN_ID, & - PLASTICITY_NONLOCAL_ID, & - SOURCE_UNDEFINED_ID ,& - SOURCE_THERMAL_DISSIPATION_ID, & - SOURCE_THERMAL_EXTERNALHEAT_ID, & - SOURCE_DAMAGE_ISOBRITTLE_ID, & - SOURCE_DAMAGE_ISODUCTILE_ID, & - SOURCE_DAMAGE_ANISOBRITTLE_ID, & - SOURCE_DAMAGE_ANISODUCTILE_ID, & KINEMATICS_UNDEFINED_ID ,& KINEMATICS_CLEAVAGE_OPENING_ID, & KINEMATICS_SLIPPLANE_OPENING_ID, & @@ -81,12 +66,7 @@ module constitutive type(tDebugOptions) :: debugCrystallite - - integer(kind(PLASTICITY_undefined_ID)), dimension(:), allocatable, public :: & - phase_plasticity !< plasticity of each phase - - integer(kind(SOURCE_undefined_ID)), dimension(:,:), allocatable :: & - phase_source, & !< active sources mechanisms of each phase + integer(kind(KINEMATICS_UNDEFINED_ID)), dimension(:,:), allocatable :: & phase_kinematics !< active kinematic mechanisms of each phase integer, dimension(:), allocatable, public :: & !< ToDo: should be protected (bug in Intel compiler) @@ -428,21 +408,6 @@ module constitutive constitutive_mech_getF, & constitutive_initializeRestorationPoints, & constitutive_windForward, & - PLASTICITY_UNDEFINED_ID, & - PLASTICITY_NONE_ID, & - PLASTICITY_ISOTROPIC_ID, & - PLASTICITY_PHENOPOWERLAW_ID, & - PLASTICITY_KINEHARDENING_ID, & - PLASTICITY_DISLOTWIN_ID, & - PLASTICITY_DISLOTUNGSTEN_ID, & - PLASTICITY_NONLOCAL_ID, & - SOURCE_UNDEFINED_ID ,& - SOURCE_THERMAL_DISSIPATION_ID, & - SOURCE_THERMAL_EXTERNALHEAT_ID, & - SOURCE_DAMAGE_ISOBRITTLE_ID, & - SOURCE_DAMAGE_ISODUCTILE_ID, & - SOURCE_DAMAGE_ANISOBRITTLE_ID, & - SOURCE_DAMAGE_ANISODUCTILE_ID, & KINEMATICS_UNDEFINED_ID ,& KINEMATICS_CLEAVAGE_OPENING_ID, & KINEMATICS_SLIPPLANE_OPENING_ID, & diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index be47d92b6..ea00b5c94 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -2,6 +2,16 @@ !> @brief internal microstructure state for all damage sources and kinematics constitutive models !---------------------------------------------------------------------------------------------------- submodule(constitutive) constitutive_damage + enum, bind(c); enumerator :: & + DAMAGE_UNDEFINED_ID, & + DAMAGE_ISOBRITTLE_ID, & + DAMAGE_ISODUCTILE_ID, & + DAMAGE_ANISOBRITTLE_ID, & + DAMAGE_ANISODUCTILE_ID + end enum + + integer(kind(DAMAGE_UNDEFINED_ID)), dimension(:,:), allocatable :: & + phase_source !< active sources mechanisms of each phase interface @@ -129,14 +139,14 @@ module subroutine damage_init allocate(sourceState(ph)%p(phase_Nsources(ph))) enddo - allocate(phase_source(maxval(phase_Nsources),phases%length), source = SOURCE_undefined_ID) + allocate(phase_source(maxval(phase_Nsources),phases%length), source = DAMAGE_UNDEFINED_ID) ! initialize source mechanisms if(maxval(phase_Nsources) /= 0) then - where(source_damage_isoBrittle_init (maxval(phase_Nsources))) phase_source = SOURCE_damage_isoBrittle_ID - where(source_damage_isoDuctile_init (maxval(phase_Nsources))) phase_source = SOURCE_damage_isoDuctile_ID - where(source_damage_anisoBrittle_init (maxval(phase_Nsources))) phase_source = SOURCE_damage_anisoBrittle_ID - where(source_damage_anisoDuctile_init (maxval(phase_Nsources))) phase_source = SOURCE_damage_anisoDuctile_ID + where(source_damage_isoBrittle_init (maxval(phase_Nsources))) phase_source = DAMAGE_ISOBRITTLE_ID + where(source_damage_isoDuctile_init (maxval(phase_Nsources))) phase_source = DAMAGE_ISODUCTILE_ID + where(source_damage_anisoBrittle_init (maxval(phase_Nsources))) phase_source = DAMAGE_ANISOBRITTLE_ID + where(source_damage_anisoDuctile_init (maxval(phase_Nsources))) phase_source = DAMAGE_ANISODUCTILE_ID endif !-------------------------------------------------------------------------------------------------- @@ -189,16 +199,16 @@ module subroutine constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi constituent = material_phasememberAt(grain,ip,el) do source = 1, phase_Nsources(phase) select case(phase_source(source,phase)) - case (SOURCE_damage_isoBrittle_ID) + case (DAMAGE_ISOBRITTLE_ID) call source_damage_isobrittle_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - case (SOURCE_damage_isoDuctile_ID) + case (DAMAGE_ISODUCTILE_ID) call source_damage_isoductile_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - case (SOURCE_damage_anisoBrittle_ID) + case (DAMAGE_ANISOBRITTLE_ID) call source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - case (SOURCE_damage_anisoDuctile_ID) + case (DAMAGE_ANISODUCTILE_ID) call source_damage_anisoductile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) case default @@ -331,21 +341,21 @@ module subroutine damage_results(group,ph) sourceLoop: do so = 1, phase_Nsources(ph) - if (phase_source(so,ph) /= SOURCE_UNDEFINED_ID) & + if (phase_source(so,ph) /= DAMAGE_UNDEFINED_ID) & call results_closeGroup(results_addGroup(group//'sources/')) ! should be 'damage' sourceType: select case (phase_source(so,ph)) - case (SOURCE_damage_anisoBrittle_ID) sourceType + case (DAMAGE_ISOBRITTLE_ID) sourceType call source_damage_anisoBrittle_results(ph,group//'sources/') - case (SOURCE_damage_anisoDuctile_ID) sourceType + case (DAMAGE_ISODUCTILE_ID) sourceType call source_damage_anisoDuctile_results(ph,group//'sources/') - case (SOURCE_damage_isoBrittle_ID) sourceType + case (DAMAGE_ANISOBRITTLE_ID) sourceType call source_damage_isoBrittle_results(ph,group//'sources/') - case (SOURCE_damage_isoDuctile_ID) sourceType + case (DAMAGE_ANISODUCTILE_ID) sourceType call source_damage_isoDuctile_results(ph,group//'sources/') end select sourceType @@ -377,14 +387,14 @@ function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) sourceType: select case (phase_source(so,ph)) - case (SOURCE_damage_anisoBrittle_ID) sourceType + case (DAMAGE_ISOBRITTLE_ID) sourceType call source_damage_anisoBrittle_dotState(mech_S(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el)),& co, ip, el) ! correct stress? - case (SOURCE_damage_isoDuctile_ID) sourceType + case (DAMAGE_ISODUCTILE_ID) sourceType call source_damage_isoDuctile_dotState(co, ip, el) - case (SOURCE_damage_anisoDuctile_ID) sourceType + case (DAMAGE_ANISODUCTILE_ID) sourceType call source_damage_anisoDuctile_dotState(co, ip, el) end select sourceType @@ -425,7 +435,7 @@ function constitutive_damage_deltaState(Fe, co, ip, el, ph, of) result(broken) sourceType: select case (phase_source(so,ph)) - case (SOURCE_damage_isoBrittle_ID) sourceType + case (DAMAGE_ISOBRITTLE_ID) sourceType call source_damage_isoBrittle_deltaState (constitutive_homogenizedC(co,ip,el), Fe, & co, ip, el) broken = any(IEEE_is_NaN(sourceState(ph)%p(so)%deltaState(:,of))) diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 7c403eeea..9539d0b93 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -7,12 +7,20 @@ submodule(constitutive) constitutive_mech ELASTICITY_UNDEFINED_ID, & ELASTICITY_HOOKE_ID, & STIFFNESS_DEGRADATION_UNDEFINED_ID, & - STIFFNESS_DEGRADATION_DAMAGE_ID + STIFFNESS_DEGRADATION_DAMAGE_ID, & + PLASTICITY_UNDEFINED_ID, & + PLASTICITY_NONE_ID, & + PLASTICITY_ISOTROPIC_ID, & + PLASTICITY_PHENOPOWERLAW_ID, & + PLASTICITY_KINEHARDENING_ID, & + PLASTICITY_DISLOTWIN_ID, & + PLASTICITY_DISLOTUNGSTEN_ID, & + PLASTICITY_NONLOCAL_ID end enum - integer(kind(ELASTICITY_undefined_ID)), dimension(:), allocatable :: & + integer(kind(ELASTICITY_UNDEFINED_ID)), dimension(:), allocatable :: & phase_elasticity !< elasticity of each phase - integer(kind(SOURCE_undefined_ID)), dimension(:,:), allocatable :: & + integer(kind(STIFFNESS_DEGRADATION_UNDEFINED_ID)), dimension(:,:), allocatable :: & phase_stiffnessDegradation !< active stiffness degradation mechanisms of each phase type(tTensorContainer), dimension(:), allocatable :: & @@ -41,6 +49,12 @@ submodule(constitutive) constitutive_mech constitutive_mech_partitionedS0 + + + integer(kind(PLASTICITY_undefined_ID)), dimension(:), allocatable :: & + phase_plasticity !< plasticity of each phase + + interface module function plastic_none_init() result(myPlasticity) diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index c86a286f9..636d7e447 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -3,10 +3,16 @@ !---------------------------------------------------------------------------------------------------- submodule(constitutive) constitutive_thermal + enum, bind(c); enumerator :: & + THERMAL_UNDEFINED_ID ,& + THERMAL_DISSIPATION_ID, & + THERMAL_EXTERNALHEAT_ID + end enum + type :: tDataContainer real(pReal), dimension(:), allocatable :: T end type tDataContainer - integer(kind(SOURCE_undefined_ID)), dimension(:,:), allocatable :: & + integer(kind(THERMAL_UNDEFINED_ID)), dimension(:,:), allocatable :: & thermal_source type(tDataContainer), dimension(:), allocatable :: current @@ -93,11 +99,11 @@ module subroutine thermal_init(phases) allocate(thermalstate(ph)%p(thermal_Nsources(ph))) enddo - allocate(thermal_source(maxval(thermal_Nsources),phases%length), source = SOURCE_undefined_ID) + allocate(thermal_source(maxval(thermal_Nsources),phases%length), source = THERMAL_UNDEFINED_ID) if(maxval(thermal_Nsources) /= 0) then - where(source_thermal_dissipation_init (maxval(thermal_Nsources))) thermal_source = SOURCE_thermal_dissipation_ID - where(source_thermal_externalheat_init(maxval(thermal_Nsources))) thermal_source = SOURCE_thermal_externalheat_ID + where(source_thermal_dissipation_init (maxval(thermal_Nsources))) thermal_source = THERMAL_DISSIPATION_ID + where(source_thermal_externalheat_init(maxval(thermal_Nsources))) thermal_source = THERMAL_EXTERNALHEAT_ID endif thermal_source_maxSizeDotState = 0 @@ -153,11 +159,11 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, me = material_phasememberAt(co,ip,el) do so = 1, thermal_Nsources(ph) select case(thermal_source(so,ph)) - case (SOURCE_thermal_dissipation_ID) + case (THERMAL_DISSIPATION_ID) call source_thermal_dissipation_getRateAndItsTangent(my_Tdot, my_dTdot_dT, & mech_S(ph,me),mech_L_p(ph,me), ph) - case (SOURCE_thermal_externalheat_ID) + case (THERMAL_EXTERNALHEAT_ID) call source_thermal_externalheat_getRateAndItsTangent(my_Tdot, my_dTdot_dT, & ph, me) @@ -188,7 +194,7 @@ function constitutive_thermal_collectDotState(ph,me) result(broken) SourceLoop: do i = 1, thermal_Nsources(ph) - if (thermal_source(i,ph) == SOURCE_thermal_externalheat_ID) & + if (thermal_source(i,ph) == THERMAL_EXTERNALHEAT_ID) & call source_thermal_externalheat_dotState(ph,me) broken = broken .or. any(IEEE_is_NaN(thermalState(ph)%p(i)%dotState(:,me))) From 7239c0b226188ac102c54d1a5167ef1a8c6076a9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 8 Jan 2021 00:40:21 +0100 Subject: [PATCH 082/352] explicit Euler is ok (only state is current time) --- src/constitutive.f90 | 4 +- src/constitutive_thermal.f90 | 91 ++++++------------------------------ 2 files changed, 15 insertions(+), 80 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 5f96e80e6..9e9cfe423 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -214,8 +214,8 @@ module constitutive ! == cleaned:end =================================================================================== - module function integrateThermalState(dt,co,ip,el) result(broken) - real(pReal), intent(in) :: dt + module function integrateThermalState(Delta_t,co,ip,el) result(broken) + real(pReal), intent(in) :: Delta_t integer, intent(in) :: & el, & !< element index in element loop ip, & !< integration point index in ip loop diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 636d7e447..e6aa7c4cf 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -204,107 +204,42 @@ function constitutive_thermal_collectDotState(ph,me) result(broken) end function constitutive_thermal_collectDotState -!-------------------------------------------------------------------------------------------------- -!> @brief integrate stress, state with adaptive 1st order explicit Euler method -!> using Fixed Point Iteration to adapt the stepsize -!-------------------------------------------------------------------------------------------------- -module function integrateThermalState(dt,co,ip,el) result(broken) - real(pReal), intent(in) :: dt +!-------------------------------------------------------------------------------------------------- +!> @brief integrate state with 1st order explicit Euler method +!-------------------------------------------------------------------------------------------------- +function integrateThermalState(Delta_t,co,ip,el) result(broken) + + real(pReal), intent(in) :: Delta_t integer, intent(in) :: & el, & !< element index in element loop ip, & !< integration point index in ip loop co !< grain index in grain loop + logical :: & + broken integer :: & - NiterationState, & !< number of iterations in state loop ph, & me, & - so - integer, dimension(maxval(thermal_Nsources)) :: & - size_so - real(pReal) :: & - zeta - real(pReal), dimension(thermal_source_maxSizeDotState) :: & - r ! state residuum - real(pReal), dimension(thermal_source_maxSizeDotState,2,maxval(thermal_Nsources)) :: source_dotState - logical :: & - broken, converged_ + so, & + sizeDotState ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - converged_ = .true. broken = constitutive_thermal_collectDotState(ph,me) if(broken) return do so = 1, thermal_Nsources(ph) - size_so(so) = thermalState(ph)%p(so)%sizeDotState - thermalState(ph)%p(so)%state(1:size_so(so),me) = thermalState(ph)%p(so)%subState0(1:size_so(so),me) & - + thermalState(ph)%p(so)%dotState (1:size_so(so),me) * dt - source_dotState(1:size_so(so),2,so) = 0.0_pReal + sizeDotState = thermalState(ph)%p(so)%sizeDotState + thermalState(ph)%p(so)%state(1:sizeDotState,me) = thermalState(ph)%p(so)%subState0(1:sizeDotState,me) & + + thermalState(ph)%p(so)%dotState(1:sizeDotState,me) * Delta_t enddo - iteration: do NiterationState = 1, num%nState - - do so = 1, thermal_Nsources(ph) - if(nIterationState > 1) source_dotState(1:size_so(so),2,so) = source_dotState(1:size_so(so),1,so) - source_dotState(1:size_so(so),1,so) = thermalState(ph)%p(so)%dotState(:,me) - enddo - - broken = constitutive_thermal_collectDotState(ph,me) - if(broken) exit iteration - - do so = 1, thermal_Nsources(ph) - zeta = damper(thermalState(ph)%p(so)%dotState(:,me), & - source_dotState(1:size_so(so),1,so),& - source_dotState(1:size_so(so),2,so)) - thermalState(ph)%p(so)%dotState(:,me) = thermalState(ph)%p(so)%dotState(:,me) * zeta & - + source_dotState(1:size_so(so),1,so)* (1.0_pReal - zeta) - r(1:size_so(so)) = thermalState(ph)%p(so)%state (1:size_so(so),me) & - - thermalState(ph)%p(so)%subState0(1:size_so(so),me) & - - thermalState(ph)%p(so)%dotState (1:size_so(so),me) * dt - thermalState(ph)%p(so)%state(1:size_so(so),me) = thermalState(ph)%p(so)%state(1:size_so(so),me) & - - r(1:size_so(so)) - converged_ = converged_ .and. converged(r(1:size_so(so)), & - thermalState(ph)%p(so)%state(1:size_so(so),me), & - thermalState(ph)%p(so)%atol(1:size_so(so))) - enddo - - if(converged_) exit iteration - - enddo iteration - - broken = broken .or. .not. converged_ - - - contains - - !-------------------------------------------------------------------------------------------------- - !> @brief calculate the damping for correction of state and dot state - !-------------------------------------------------------------------------------------------------- - real(pReal) pure function damper(current,previous,previous2) - - real(pReal), dimension(:), intent(in) ::& - current, previous, previous2 - - real(pReal) :: dot_prod12, dot_prod22 - - dot_prod12 = dot_product(current - previous, previous - previous2) - dot_prod22 = dot_product(previous - previous2, previous - previous2) - if ((dot_product(current,previous) < 0.0_pReal .or. dot_prod12 < 0.0_pReal) .and. dot_prod22 > 0.0_pReal) then - damper = 0.75_pReal + 0.25_pReal * tanh(2.0_pReal + 4.0_pReal * dot_prod12 / dot_prod22) - else - damper = 1.0_pReal - endif - - end function damper - end function integrateThermalState - module subroutine thermal_initializeRestorationPoints(ph,me) integer, intent(in) :: ph, me From 88be08ae31f49fdd007843101c4491c04f96b69a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 8 Jan 2021 00:44:16 +0100 Subject: [PATCH 083/352] modified structure for thermal tests, fixed damage branching --- PRIVATE | 2 +- src/constitutive_damage.f90 | 22 +++++++++++----------- src/constitutive_thermal.f90 | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/PRIVATE b/PRIVATE index 591964dcf..7846c7112 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 591964dcf8521d95f6cccbfe840d462c430e63d9 +Subproject commit 7846c71126705cc5d41dd79f2d595f4864434068 diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index ea00b5c94..cc2b62002 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -347,17 +347,17 @@ module subroutine damage_results(group,ph) sourceType: select case (phase_source(so,ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType - call source_damage_anisoBrittle_results(ph,group//'sources/') - - case (DAMAGE_ISODUCTILE_ID) sourceType - call source_damage_anisoDuctile_results(ph,group//'sources/') - - case (DAMAGE_ANISOBRITTLE_ID) sourceType call source_damage_isoBrittle_results(ph,group//'sources/') - case (DAMAGE_ANISODUCTILE_ID) sourceType + case (DAMAGE_ISODUCTILE_ID) sourceType call source_damage_isoDuctile_results(ph,group//'sources/') + case (DAMAGE_ANISOBRITTLE_ID) sourceType + call source_damage_anisoBrittle_results(ph,group//'sources/') + + case (DAMAGE_ANISODUCTILE_ID) sourceType + call source_damage_anisoDuctile_results(ph,group//'sources/') + end select sourceType enddo SourceLoop @@ -387,16 +387,16 @@ function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) sourceType: select case (phase_source(so,ph)) - case (DAMAGE_ISOBRITTLE_ID) sourceType - call source_damage_anisoBrittle_dotState(mech_S(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el)),& - co, ip, el) ! correct stress? - case (DAMAGE_ISODUCTILE_ID) sourceType call source_damage_isoDuctile_dotState(co, ip, el) case (DAMAGE_ANISODUCTILE_ID) sourceType call source_damage_anisoDuctile_dotState(co, ip, el) + case (DAMAGE_ANISOBRITTLE_ID) sourceType + call source_damage_anisoBrittle_dotState(mech_S(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el)),& + co, ip, el) ! correct stress? + end select sourceType broken = broken .or. any(IEEE_is_NaN(sourceState(ph)%p(so)%dotState(:,of))) diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index e6aa7c4cf..5017904df 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -208,7 +208,7 @@ end function constitutive_thermal_collectDotState !-------------------------------------------------------------------------------------------------- !> @brief integrate state with 1st order explicit Euler method !-------------------------------------------------------------------------------------------------- -function integrateThermalState(Delta_t,co,ip,el) result(broken) +module function integrateThermalState(Delta_t,co,ip,el) result(broken) real(pReal), intent(in) :: Delta_t integer, intent(in) :: & From 65bd880fdf79394e2693a49e3c681c34574fc9ba Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 8 Jan 2021 07:10:38 +0100 Subject: [PATCH 084/352] clearerer names --- src/constitutive.f90 | 24 +++++++++--------- src/constitutive_damage.f90 | 40 +++++++++++++++--------------- src/constitutive_mech.f90 | 6 ++--- src/damage_none.f90 | 8 +++--- src/damage_nonlocal.f90 | 10 ++++---- src/homogenization.f90 | 8 +++--- src/material.f90 | 4 +-- src/source_damage_anisoBrittle.f90 | 16 ++++++------ src/source_damage_anisoDuctile.f90 | 12 ++++----- src/source_damage_isoBrittle.f90 | 24 +++++++++--------- src/source_damage_isoDuctile.f90 | 12 ++++----- 11 files changed, 82 insertions(+), 82 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 9e9cfe423..0d8e35ba3 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -83,7 +83,7 @@ module constitutive type(tPlasticState), allocatable, dimension(:), public :: & plasticState type(tSourceState), allocatable, dimension(:), public :: & - sourceState, thermalState + damageState, thermalState integer, public, protected :: & @@ -454,12 +454,12 @@ subroutine constitutive_init plasticState(ph)%partitionedState0 = plasticState(ph)%state0 plasticState(ph)%state = plasticState(ph)%partitionedState0 forall(so = 1:phase_Nsources(ph)) - sourceState(ph)%p(so)%partitionedState0 = sourceState(ph)%p(so)%state0 - sourceState(ph)%p(so)%state = sourceState(ph)%p(so)%partitionedState0 + damageState(ph)%p(so)%partitionedState0 = damageState(ph)%p(so)%state0 + damageState(ph)%p(so)%state = damageState(ph)%p(so)%partitionedState0 end forall constitutive_source_maxSizeDotState = max(constitutive_source_maxSizeDotState, & - maxval(sourceState(ph)%p%sizeDotState)) + maxval(damageState(ph)%p%sizeDotState)) enddo PhaseLoop2 constitutive_plasticity_maxSizeDotState = maxval(plasticState%sizeDotState) @@ -578,8 +578,8 @@ subroutine constitutive_restore(ip,el,includeL) do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) do so = 1, phase_Nsources(material_phaseAt(co,el)) - sourceState(material_phaseAt(co,el))%p(so)%state( :,material_phasememberAt(co,ip,el)) = & - sourceState(material_phaseAt(co,el))%p(so)%partitionedState0(:,material_phasememberAt(co,ip,el)) + damageState(material_phaseAt(co,el))%p(so)%state( :,material_phasememberAt(co,ip,el)) = & + damageState(material_phaseAt(co,el))%p(so)%partitionedState0(:,material_phasememberAt(co,ip,el)) enddo enddo @@ -601,9 +601,9 @@ subroutine constitutive_forward() call mech_forward() call thermal_forward() - do ph = 1, size(sourceState) + do ph = 1, size(damageState) do so = 1,phase_Nsources(ph) - sourceState(ph)%p(so)%state0 = sourceState(ph)%p(so)%state + damageState(ph)%p(so)%state0 = damageState(ph)%p(so)%state enddo; enddo end subroutine constitutive_forward @@ -704,7 +704,7 @@ subroutine crystallite_init() do ph = 1, phases%length do so = 1, phase_Nsources(ph) - allocate(sourceState(ph)%p(so)%subState0,source=sourceState(ph)%p(so)%state0) ! ToDo: hack + allocate(damageState(ph)%p(so)%subState0,source=damageState(ph)%p(so)%state0) ! ToDo: hack enddo do so = 1, thermal_Nsources(ph) allocate(thermalState(ph)%p(so)%subState0,source=thermalState(ph)%p(so)%state0) ! ToDo: hack @@ -753,8 +753,8 @@ subroutine constitutive_initializeRestorationPoints(ip,el) call mech_initializeRestorationPoints(ph,me) call thermal_initializeRestorationPoints(ph,me) - do so = 1, size(sourceState(ph)%p) - sourceState(ph)%p(so)%partitionedState0(:,me) = sourceState(ph)%p(so)%state0(:,me) + do so = 1, size(damageState(ph)%p) + damageState(ph)%p(so)%partitionedState0(:,me) = damageState(ph)%p(so)%state0(:,me) enddo enddo @@ -784,7 +784,7 @@ subroutine constitutive_windForward(ip,el) call thermal_windForward(ph,me) do so = 1, phase_Nsources(material_phaseAt(co,el)) - sourceState(ph)%p(so)%partitionedState0(:,me) = sourceState(ph)%p(so)%state(:,me) + damageState(ph)%p(so)%partitionedState0(:,me) = damageState(ph)%p(so)%state(:,me) enddo enddo diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index cc2b62002..85500e260 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -129,14 +129,14 @@ module subroutine damage_init phases => config_material%get('phase') - allocate(sourceState (phases%length)) + allocate(damageState (phases%length)) allocate(phase_Nsources(phases%length),source = 0) ! same for kinematics do ph = 1,phases%length phase => phases%get(ph) sources => phase%get('source',defaultVal=emptyList) phase_Nsources(ph) = sources%length - allocate(sourceState(ph)%p(phase_Nsources(ph))) + allocate(damageState(ph)%p(phase_Nsources(ph))) enddo allocate(phase_source(maxval(phase_Nsources),phases%length), source = DAMAGE_UNDEFINED_ID) @@ -262,9 +262,9 @@ module function integrateDamageState(dt,co,ip,el) result(broken) if(broken) return do so = 1, phase_Nsources(ph) - size_so(so) = sourceState(ph)%p(so)%sizeDotState - sourceState(ph)%p(so)%state(1:size_so(so),me) = sourceState(ph)%p(so)%subState0(1:size_so(so),me) & - + sourceState(ph)%p(so)%dotState (1:size_so(so),me) * dt + size_so(so) = damageState(ph)%p(so)%sizeDotState + damageState(ph)%p(so)%state(1:size_so(so),me) = damageState(ph)%p(so)%subState0(1:size_so(so),me) & + + damageState(ph)%p(so)%dotState (1:size_so(so),me) * dt source_dotState(1:size_so(so),2,so) = 0.0_pReal enddo @@ -272,26 +272,26 @@ module function integrateDamageState(dt,co,ip,el) result(broken) do so = 1, phase_Nsources(ph) if(nIterationState > 1) source_dotState(1:size_so(so),2,so) = source_dotState(1:size_so(so),1,so) - source_dotState(1:size_so(so),1,so) = sourceState(ph)%p(so)%dotState(:,me) + source_dotState(1:size_so(so),1,so) = damageState(ph)%p(so)%dotState(:,me) enddo broken = constitutive_damage_collectDotState(co,ip,el,ph,me) if(broken) exit iteration do so = 1, phase_Nsources(ph) - zeta = damper(sourceState(ph)%p(so)%dotState(:,me), & + zeta = damper(damageState(ph)%p(so)%dotState(:,me), & source_dotState(1:size_so(so),1,so),& source_dotState(1:size_so(so),2,so)) - sourceState(ph)%p(so)%dotState(:,me) = sourceState(ph)%p(so)%dotState(:,me) * zeta & + damageState(ph)%p(so)%dotState(:,me) = damageState(ph)%p(so)%dotState(:,me) * zeta & + source_dotState(1:size_so(so),1,so)* (1.0_pReal - zeta) - r(1:size_so(so)) = sourceState(ph)%p(so)%state (1:size_so(so),me) & - - sourceState(ph)%p(so)%subState0(1:size_so(so),me) & - - sourceState(ph)%p(so)%dotState (1:size_so(so),me) * dt - sourceState(ph)%p(so)%state(1:size_so(so),me) = sourceState(ph)%p(so)%state(1:size_so(so),me) & + r(1:size_so(so)) = damageState(ph)%p(so)%state (1:size_so(so),me) & + - damageState(ph)%p(so)%subState0(1:size_so(so),me) & + - damageState(ph)%p(so)%dotState (1:size_so(so),me) * dt + damageState(ph)%p(so)%state(1:size_so(so),me) = damageState(ph)%p(so)%state(1:size_so(so),me) & - r(1:size_so(so)) converged_ = converged_ .and. converged(r(1:size_so(so)), & - sourceState(ph)%p(so)%state(1:size_so(so),me), & - sourceState(ph)%p(so)%atol(1:size_so(so))) + damageState(ph)%p(so)%state(1:size_so(so),me), & + damageState(ph)%p(so)%atol(1:size_so(so))) enddo if(converged_) then @@ -399,7 +399,7 @@ function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) end select sourceType - broken = broken .or. any(IEEE_is_NaN(sourceState(ph)%p(so)%dotState(:,of))) + broken = broken .or. any(IEEE_is_NaN(damageState(ph)%p(so)%dotState(:,of))) enddo SourceLoop @@ -438,12 +438,12 @@ function constitutive_damage_deltaState(Fe, co, ip, el, ph, of) result(broken) case (DAMAGE_ISOBRITTLE_ID) sourceType call source_damage_isoBrittle_deltaState (constitutive_homogenizedC(co,ip,el), Fe, & co, ip, el) - broken = any(IEEE_is_NaN(sourceState(ph)%p(so)%deltaState(:,of))) + broken = any(IEEE_is_NaN(damageState(ph)%p(so)%deltaState(:,of))) if(.not. broken) then - myOffset = sourceState(ph)%p(so)%offsetDeltaState - mySize = sourceState(ph)%p(so)%sizeDeltaState - sourceState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) = & - sourceState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) + sourceState(ph)%p(so)%deltaState(1:mySize,of) + myOffset = damageState(ph)%p(so)%offsetDeltaState + mySize = damageState(ph)%p(so)%sizeDeltaState + damageState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) = & + damageState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) + damageState(ph)%p(so)%deltaState(1:mySize,of) endif end select sourceType diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 9539d0b93..8bc85354f 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1600,7 +1600,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) do so = 1, phase_Nsources(ph) - sourceState(ph)%p(so)%subState0(:,me) = sourceState(ph)%p(so)%partitionedState0(:,me) + damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%partitionedState0(:,me) enddo do so = 1, thermal_Nsources(ph) thermalState(ph)%p(so)%subState0(:,me) = thermalState(ph)%p(so)%partitionedState0(:,me) @@ -1631,7 +1631,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) subFi0 = constitutive_mech_Fi(ph)%data(1:3,1:3,me) subState0 = plasticState(ph)%state(:,me) do so = 1, phase_Nsources(ph) - sourceState(ph)%p(so)%subState0(:,me) = sourceState(ph)%p(so)%state(:,me) + damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%state(:,me) enddo do so = 1, thermal_Nsources(ph) thermalState(ph)%p(so)%subState0(:,me) = thermalState(ph)%p(so)%state(:,me) @@ -1650,7 +1650,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) endif plasticState(ph)%state(:,me) = subState0 do so = 1, phase_Nsources(ph) - sourceState(ph)%p(so)%state(:,me) = sourceState(ph)%p(so)%subState0(:,me) + damageState(ph)%p(so)%state(:,me) = damageState(ph)%p(so)%subState0(:,me) enddo do so = 1, thermal_Nsources(ph) thermalState(ph)%p(so)%state(:,me) = thermalState(ph)%p(so)%subState0(:,me) diff --git a/src/damage_none.f90 b/src/damage_none.f90 index 3f1144833..078d42af7 100644 --- a/src/damage_none.f90 +++ b/src/damage_none.f90 @@ -25,10 +25,10 @@ subroutine damage_none_init if (damage_type(h) /= DAMAGE_NONE_ID) cycle Nmaterialpoints = count(material_homogenizationAt == h) - damageState(h)%sizeState = 0 - allocate(damageState(h)%state0 (0,Nmaterialpoints)) - allocate(damageState(h)%subState0(0,Nmaterialpoints)) - allocate(damageState(h)%state (0,Nmaterialpoints)) + damageState_h(h)%sizeState = 0 + allocate(damageState_h(h)%state0 (0,Nmaterialpoints)) + allocate(damageState_h(h)%subState0(0,Nmaterialpoints)) + allocate(damageState_h(h)%state (0,Nmaterialpoints)) allocate (damage(h)%p(Nmaterialpoints), source=1.0_pReal) diff --git a/src/damage_nonlocal.f90 b/src/damage_nonlocal.f90 index 3db63cab2..4423c1e3a 100644 --- a/src/damage_nonlocal.f90 +++ b/src/damage_nonlocal.f90 @@ -76,12 +76,12 @@ subroutine damage_nonlocal_init #endif Nmaterialpoints = count(material_homogenizationAt == h) - damageState(h)%sizeState = 1 - allocate(damageState(h)%state0 (1,Nmaterialpoints), source=1.0_pReal) - allocate(damageState(h)%subState0(1,Nmaterialpoints), source=1.0_pReal) - allocate(damageState(h)%state (1,Nmaterialpoints), source=1.0_pReal) + damageState_h(h)%sizeState = 1 + allocate(damageState_h(h)%state0 (1,Nmaterialpoints), source=1.0_pReal) + allocate(damageState_h(h)%subState0(1,Nmaterialpoints), source=1.0_pReal) + allocate(damageState_h(h)%state (1,Nmaterialpoints), source=1.0_pReal) - damage(h)%p => damageState(h)%state(1,:) + damage(h)%p => damageState_h(h)%state(1,:) end associate enddo diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 8738ba6f1..9112562b9 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -186,7 +186,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE subStep = 1.0_pReal/num%subStepSizeHomog ! ... larger then the requested calculation if (homogState(ho)%sizeState > 0) homogState(ho)%subState0(:,me) = homogState(ho)%State0(:,me) - if (damageState(ho)%sizeState > 0) damageState(ho)%subState0(:,me) = damageState(ho)%State0(:,me) + if (damageState_h(ho)%sizeState > 0) damageState_h(ho)%subState0(:,me) = damageState_h(ho)%State0(:,me) cutBackLooping: do while (.not. terminallyIll .and. subStep > num%subStepMinHomog) @@ -200,7 +200,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE call constitutive_windForward(ip,el) if(homogState(ho)%sizeState > 0) homogState(ho)%subState0(:,me) = homogState(ho)%State(:,me) - if(damageState(ho)%sizeState > 0) damageState(ho)%subState0(:,me) = damageState(ho)%State(:,me) + if(damageState_h(ho)%sizeState > 0) damageState_h(ho)%subState0(:,me) = damageState_h(ho)%State(:,me) endif steppingNeeded elseif ( (myNgrains == 1 .and. subStep <= 1.0 ) .or. & ! single grain already tried internal subStepping in crystallite @@ -215,7 +215,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE call constitutive_restore(ip,el,subStep < 1.0_pReal) if(homogState(ho)%sizeState > 0) homogState(ho)%State(:,me) = homogState(ho)%subState0(:,me) - if(damageState(ho)%sizeState > 0) damageState(ho)%State(:,me) = damageState(ho)%subState0(:,me) + if(damageState_h(ho)%sizeState > 0) damageState_h(ho)%State(:,me) = damageState_h(ho)%subState0(:,me) endif if (subStep > num%subStepMinHomog) doneAndHappy = [.false.,.true.] @@ -326,7 +326,7 @@ subroutine homogenization_forward do ho = 1, size(material_name_homogenization) homogState (ho)%state0 = homogState (ho)%state - damageState(ho)%state0 = damageState(ho)%state + damageState_h(ho)%state0 = damageState_h(ho)%state enddo end subroutine homogenization_forward diff --git a/src/material.f90 b/src/material.f90 index 581182d22..16116ca91 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -61,7 +61,7 @@ module material type(tState), allocatable, dimension(:), public :: & homogState, & - damageState + damageState_h type(Rotation), dimension(:,:,:), allocatable, public, protected :: & material_orientation0 !< initial orientation of each grain,IP,element @@ -101,7 +101,7 @@ subroutine material_init(restart) allocate(homogState (size(material_name_homogenization))) - allocate(damageState (size(material_name_homogenization))) + allocate(damageState_h (size(material_name_homogenization))) allocate(temperature (size(material_name_homogenization))) allocate(damage (size(material_name_homogenization))) diff --git a/src/source_damage_anisoBrittle.f90 b/src/source_damage_anisoBrittle.f90 index 0f923ceba..7c00c6580 100644 --- a/src/source_damage_anisoBrittle.f90 +++ b/src/source_damage_anisoBrittle.f90 @@ -101,9 +101,9 @@ module function source_damage_anisoBrittle_init(source_length) result(mySources) if (any(prm%s_crit < 0.0_pReal)) extmsg = trim(extmsg)//' s_crit' Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(sourceState(p)%p(sourceOffset),Nconstituents,1,1,0) - sourceState(p)%p(sourceOffset)%atol = src%get_asFloat('anisobrittle_atol',defaultVal=1.0e-3_pReal) - if(any(sourceState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisobrittle_atol' + call constitutive_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) + damageState(p)%p(sourceOffset)%atol = src%get_asFloat('anisobrittle_atol',defaultVal=1.0e-3_pReal) + if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisobrittle_atol' end associate @@ -146,7 +146,7 @@ module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) damageOffset = material_homogenizationMemberAt(ip,el) associate(prm => param(source_damage_anisoBrittle_instance(phase))) - sourceState(phase)%p(sourceOffset)%dotState(1,constituent) = 0.0_pReal + damageState(phase)%p(sourceOffset)%dotState(1,constituent) = 0.0_pReal do i = 1, prm%sum_N_cl traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) @@ -154,8 +154,8 @@ module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) traction_crit = prm%g_crit(i)*damage(homog)%p(damageOffset)**2.0_pReal - sourceState(phase)%p(sourceOffset)%dotState(1,constituent) & - = sourceState(phase)%p(sourceOffset)%dotState(1,constituent) & + damageState(phase)%p(sourceOffset)%dotState(1,constituent) & + = damageState(phase)%p(sourceOffset)%dotState(1,constituent) & + prm%dot_o / prm%s_crit(i) & * ((max(0.0_pReal, abs(traction_d) - traction_crit)/traction_crit)**prm%q + & (max(0.0_pReal, abs(traction_t) - traction_crit)/traction_crit)**prm%q + & @@ -185,7 +185,7 @@ module subroutine source_damage_anisobrittle_getRateAndItsTangent(localphiDot, d sourceOffset = source_damage_anisoBrittle_offset(phase) - dLocalphiDot_dPhi = -sourceState(phase)%p(sourceOffset)%state(1,constituent) + dLocalphiDot_dPhi = -damageState(phase)%p(sourceOffset)%state(1,constituent) localphiDot = 1.0_pReal & + dLocalphiDot_dPhi*phi @@ -204,7 +204,7 @@ module subroutine source_damage_anisoBrittle_results(phase,group) integer :: o associate(prm => param(source_damage_anisoBrittle_instance(phase)), & - stt => sourceState(phase)%p(source_damage_anisoBrittle_offset(phase))%state) + stt => damageState(phase)%p(source_damage_anisoBrittle_offset(phase))%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('f_phi') diff --git a/src/source_damage_anisoDuctile.f90 b/src/source_damage_anisoDuctile.f90 index 6f71fc145..7ec06cb62 100644 --- a/src/source_damage_anisoDuctile.f90 +++ b/src/source_damage_anisoDuctile.f90 @@ -87,9 +87,9 @@ module function source_damage_anisoDuctile_init(source_length) result(mySources) if (any(prm%gamma_crit < 0.0_pReal)) extmsg = trim(extmsg)//' gamma_crit' Nconstituents=count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(sourceState(p)%p(sourceOffset),Nconstituents,1,1,0) - sourceState(p)%p(sourceOffset)%atol = src%get_asFloat('anisoDuctile_atol',defaultVal=1.0e-3_pReal) - if(any(sourceState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisoductile_atol' + call constitutive_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) + damageState(p)%p(sourceOffset)%atol = src%get_asFloat('anisoDuctile_atol',defaultVal=1.0e-3_pReal) + if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisoductile_atol' end associate @@ -128,7 +128,7 @@ module subroutine source_damage_anisoDuctile_dotState(co, ip, el) damageOffset = material_homogenizationMemberAt(ip,el) associate(prm => param(source_damage_anisoDuctile_instance(phase))) - sourceState(phase)%p(sourceOffset)%dotState(1,constituent) & + damageState(phase)%p(sourceOffset)%dotState(1,constituent) & = sum(plasticState(phase)%slipRate(:,constituent)/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit) end associate @@ -154,7 +154,7 @@ module subroutine source_damage_anisoDuctile_getRateAndItsTangent(localphiDot, d sourceOffset = source_damage_anisoDuctile_offset(phase) - dLocalphiDot_dPhi = -sourceState(phase)%p(sourceOffset)%state(1,constituent) + dLocalphiDot_dPhi = -damageState(phase)%p(sourceOffset)%state(1,constituent) localphiDot = 1.0_pReal & + dLocalphiDot_dPhi*phi @@ -173,7 +173,7 @@ module subroutine source_damage_anisoDuctile_results(phase,group) integer :: o associate(prm => param(source_damage_anisoDuctile_instance(phase)), & - stt => sourceState(phase)%p(source_damage_anisoDuctile_offset(phase))%state) + stt => damageState(phase)%p(source_damage_anisoDuctile_offset(phase))%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('f_phi') diff --git a/src/source_damage_isoBrittle.f90 b/src/source_damage_isoBrittle.f90 index 8c768b08d..1721b0201 100644 --- a/src/source_damage_isoBrittle.f90 +++ b/src/source_damage_isoBrittle.f90 @@ -74,9 +74,9 @@ module function source_damage_isoBrittle_init(source_length) result(mySources) if (prm%W_crit <= 0.0_pReal) extmsg = trim(extmsg)//' W_crit' Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(sourceState(p)%p(sourceOffset),Nconstituents,1,1,1) - sourceState(p)%p(sourceOffset)%atol = src%get_asFloat('isoBrittle_atol',defaultVal=1.0e-3_pReal) - if(any(sourceState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isobrittle_atol' + call constitutive_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,1) + damageState(p)%p(sourceOffset)%atol = src%get_asFloat('isoBrittle_atol',defaultVal=1.0e-3_pReal) + if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isobrittle_atol' end associate @@ -124,13 +124,13 @@ module subroutine source_damage_isoBrittle_deltaState(C, Fe, co, ip, el) strainenergy = 2.0_pReal*sum(strain*matmul(C,strain))/prm%W_crit ! ToDo: check strainenergy = 2.0_pReal*dot_product(strain,matmul(C,strain))/prm%W_crit - if (strainenergy > sourceState(phase)%p(sourceOffset)%subState0(1,constituent)) then - sourceState(phase)%p(sourceOffset)%deltaState(1,constituent) = & - strainenergy - sourceState(phase)%p(sourceOffset)%state(1,constituent) + if (strainenergy > damageState(phase)%p(sourceOffset)%subState0(1,constituent)) then + damageState(phase)%p(sourceOffset)%deltaState(1,constituent) = & + strainenergy - damageState(phase)%p(sourceOffset)%state(1,constituent) else - sourceState(phase)%p(sourceOffset)%deltaState(1,constituent) = & - sourceState(phase)%p(sourceOffset)%subState0(1,constituent) - & - sourceState(phase)%p(sourceOffset)%state(1,constituent) + damageState(phase)%p(sourceOffset)%deltaState(1,constituent) = & + damageState(phase)%p(sourceOffset)%subState0(1,constituent) - & + damageState(phase)%p(sourceOffset)%state(1,constituent) endif end associate @@ -158,8 +158,8 @@ module subroutine source_damage_isoBrittle_getRateAndItsTangent(localphiDot, dLo associate(prm => param(source_damage_isoBrittle_instance(phase))) localphiDot = 1.0_pReal & - - phi*sourceState(phase)%p(sourceOffset)%state(1,constituent) - dLocalphiDot_dPhi = - sourceState(phase)%p(sourceOffset)%state(1,constituent) + - phi*damageState(phase)%p(sourceOffset)%state(1,constituent) + dLocalphiDot_dPhi = - damageState(phase)%p(sourceOffset)%state(1,constituent) end associate end subroutine source_damage_isoBrittle_getRateAndItsTangent @@ -176,7 +176,7 @@ module subroutine source_damage_isoBrittle_results(phase,group) integer :: o associate(prm => param(source_damage_isoBrittle_instance(phase)), & - stt => sourceState(phase)%p(source_damage_isoBrittle_offset(phase))%state) + stt => damageState(phase)%p(source_damage_isoBrittle_offset(phase))%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('f_phi') diff --git a/src/source_damage_isoDuctile.f90 b/src/source_damage_isoDuctile.f90 index 86222bbf9..dd2910182 100644 --- a/src/source_damage_isoDuctile.f90 +++ b/src/source_damage_isoDuctile.f90 @@ -78,9 +78,9 @@ module function source_damage_isoDuctile_init(source_length) result(mySources) if (prm%gamma_crit <= 0.0_pReal) extmsg = trim(extmsg)//' gamma_crit' Nconstituents=count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(sourceState(p)%p(sourceOffset),Nconstituents,1,1,0) - sourceState(p)%p(sourceOffset)%atol = src%get_asFloat('isoDuctile_atol',defaultVal=1.0e-3_pReal) - if(any(sourceState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isoductile_atol' + call constitutive_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) + damageState(p)%p(sourceOffset)%atol = src%get_asFloat('isoDuctile_atol',defaultVal=1.0e-3_pReal) + if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isoductile_atol' end associate @@ -119,7 +119,7 @@ module subroutine source_damage_isoDuctile_dotState(co, ip, el) damageOffset = material_homogenizationMemberAt(ip,el) associate(prm => param(source_damage_isoDuctile_instance(phase))) - sourceState(phase)%p(sourceOffset)%dotState(1,constituent) = & + damageState(phase)%p(sourceOffset)%dotState(1,constituent) = & sum(plasticState(phase)%slipRate(:,constituent))/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit end associate @@ -145,7 +145,7 @@ module subroutine source_damage_isoDuctile_getRateAndItsTangent(localphiDot, dLo sourceOffset = source_damage_isoDuctile_offset(phase) - dLocalphiDot_dPhi = -sourceState(phase)%p(sourceOffset)%state(1,constituent) + dLocalphiDot_dPhi = -damageState(phase)%p(sourceOffset)%state(1,constituent) localphiDot = 1.0_pReal & + dLocalphiDot_dPhi*phi @@ -164,7 +164,7 @@ module subroutine source_damage_isoDuctile_results(phase,group) integer :: o associate(prm => param(source_damage_isoDuctile_instance(phase)), & - stt => sourceState(phase)%p(source_damage_isoDuctile_offset(phase))%state) + stt => damageState(phase)%p(source_damage_isoDuctile_offset(phase))%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('f_phi') From 6c62e186deccb414cec8681b298816e35e33df37 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 8 Jan 2021 07:37:51 +0100 Subject: [PATCH 085/352] separte functionality --- src/constitutive.f90 | 31 +---------------------- src/constitutive_damage.f90 | 31 +++++++++++++++++++++++ src/constitutive_thermal_dissipation.f90 | 20 ++++++++------- src/constitutive_thermal_externalheat.f90 | 3 +-- 4 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 0d8e35ba3..111e68fdf 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -369,7 +369,7 @@ module constitutive module subroutine constitutive_plastic_dependentState(co,ip,el) integer, intent(in) :: & - co, & !< component-ID of integration point + co, & !< component-ID of integration point ip, & !< integration point el !< element end subroutine constitutive_plastic_dependentState @@ -390,7 +390,6 @@ module constitutive constitutive_forward, & constitutive_restore, & plastic_nonlocal_updateCompatibility, & - source_active, & kinematics_active, & converged, & crystallite_init, & @@ -466,35 +465,7 @@ subroutine constitutive_init end subroutine constitutive_init -!-------------------------------------------------------------------------------------------------- -!> @brief checks if a source mechanism is active or not -!-------------------------------------------------------------------------------------------------- -function source_active(source_label,src_length) result(active_source) - character(len=*), intent(in) :: source_label !< name of source mechanism - integer, intent(in) :: src_length !< max. number of sources in system - logical, dimension(:,:), allocatable :: active_source - - class(tNode), pointer :: & - phases, & - phase, & - sources, & - src - integer :: p,s - - phases => config_material%get('phase') - allocate(active_source(src_length,phases%length), source = .false. ) - do p = 1, phases%length - phase => phases%get(p) - sources => phase%get('source',defaultVal=emptyList) - do s = 1, sources%length - src => sources%get(s) - if(src%get_asString('type') == source_label) active_source(s,p) = .true. - enddo - enddo - - -end function source_active !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index 85500e260..8c9104946 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -453,4 +453,35 @@ function constitutive_damage_deltaState(Fe, co, ip, el, ph, of) result(broken) end function constitutive_damage_deltaState +!-------------------------------------------------------------------------------------------------- +!> @brief checks if a source mechanism is active or not +!-------------------------------------------------------------------------------------------------- +function source_active(source_label,src_length) result(active_source) + + character(len=*), intent(in) :: source_label !< name of source mechanism + integer, intent(in) :: src_length !< max. number of sources in system + logical, dimension(:,:), allocatable :: active_source + + class(tNode), pointer :: & + phases, & + phase, & + sources, & + src + integer :: p,s + + phases => config_material%get('phase') + allocate(active_source(src_length,phases%length), source = .false. ) + do p = 1, phases%length + phase => phases%get(p) + sources => phase%get('source',defaultVal=emptyList) + do s = 1, sources%length + src => sources%get(s) + if(src%get_asString('type') == source_label) active_source(s,p) = .true. + enddo + enddo + + +end function source_active + + end submodule constitutive_damage diff --git a/src/constitutive_thermal_dissipation.f90 b/src/constitutive_thermal_dissipation.f90 index 44227536c..f15d1cfe9 100644 --- a/src/constitutive_thermal_dissipation.f90 +++ b/src/constitutive_thermal_dissipation.f90 @@ -27,19 +27,20 @@ contains !-------------------------------------------------------------------------------------------------- module function source_thermal_dissipation_init(source_length) result(mySources) - integer, intent(in) :: source_length + integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources class(tNode), pointer :: & phases, & phase, & - sources, & - src + sources, thermal, & + src integer :: Ninstances,sourceOffset,Nconstituents,p - print'(/,a)', ' <<<+- source_thermal_dissipation init -+>>>' + print'(/,a)', ' <<<+- thermal_externalheat init -+>>>' + + mySources = thermal_active('dissipation',source_length) - mySources = source_active('thermal_dissipation',source_length) Ninstances = count(mySources) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -50,16 +51,17 @@ module function source_thermal_dissipation_init(source_length) result(mySources) allocate(source_thermal_dissipation_instance(phases%length), source=0) do p = 1, phases%length - phase => phases%get(p) - if(count(mySources(:,p)) == 0) cycle + phase => phases%get(p) if(any(mySources(:,p))) source_thermal_dissipation_instance(p) = count(mySources(:,1:p)) - sources => phase%get('source') + if(count(mySources(:,p)) == 0) cycle + thermal => phase%get('thermal') + sources => thermal%get('source') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then source_thermal_dissipation_offset(p) = sourceOffset associate(prm => param(source_thermal_dissipation_instance(p))) + src => sources%get(sourceOffset) - src => sources%get(sourceOffset) prm%kappa = src%get_asFloat('kappa') Nconstituents = count(material_phaseAt==p) * discretization_nIPs call constitutive_allocateState(thermalState(p)%p(sourceOffset),Nconstituents,0,0,0) diff --git a/src/constitutive_thermal_externalheat.f90 b/src/constitutive_thermal_externalheat.f90 index de1617efa..2a3ec7362 100644 --- a/src/constitutive_thermal_externalheat.f90 +++ b/src/constitutive_thermal_externalheat.f90 @@ -41,7 +41,7 @@ module function source_thermal_externalheat_init(source_length) result(mySources src integer :: Ninstances,sourceOffset,Nconstituents,p - print'(/,a)', ' <<<+- source_thermal_externalHeat init -+>>>' + print'(/,a)', ' <<<+- thermal_externalheat init -+>>>' mySources = thermal_active('externalheat',source_length) @@ -74,7 +74,6 @@ module function source_thermal_externalheat_init(source_length) result(mySources Nconstituents = count(material_phaseAt==p) * discretization_nIPs call constitutive_allocateState(thermalState(p)%p(sourceOffset),Nconstituents,1,1,0) end associate - endif enddo enddo From d494c2d81e66ceb770d7e902f262ba337c3fd6d9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 8 Jan 2021 08:26:17 +0100 Subject: [PATCH 086/352] better to read --- src/constitutive.f90 | 3 +-- src/constitutive_thermal.f90 | 2 +- src/thermal_conduction.f90 | 5 +---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 111e68fdf..250f7f99e 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -305,6 +305,7 @@ module constitutive orientation !< crystal orientation end subroutine plastic_nonlocal_updateCompatibility + module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,of) real(pReal), dimension(3,3), intent(out) :: & Li !< inleastic velocity gradient @@ -466,8 +467,6 @@ end subroutine constitutive_init - - !-------------------------------------------------------------------------------------------------- !> @brief checks if a kinematic mechanism is active or not !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 5017904df..a716a0c55 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -136,7 +136,7 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, el !< element number real(pReal), intent(in) :: & T !< plastic velocity gradient - real(pReal), intent(inout) :: & + real(pReal), intent(out) :: & TDot, & dTDot_dT diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index 0cd1678e0..02649b1ad 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -103,10 +103,7 @@ subroutine thermal_conduction_getSourceAndItsTangent(Tdot, dTdot_dT, T, ip, el) integer :: & homog - Tdot = 0.0_pReal - dTdot_dT = 0.0_pReal - - homog = material_homogenizationAt(el) + homog = material_homogenizationAt(el) call constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, ip, el) Tdot = Tdot/real(homogenization_Nconstituents(homog),pReal) From 350466dd5f18aad38d11bb1cf49dd71591524d6f Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 8 Jan 2021 08:57:30 +0100 Subject: [PATCH 087/352] not needed --- src/DAMASK_marc.f90 | 3 ++- src/constitutive.f90 | 7 +++--- src/constitutive_thermal.f90 | 27 +++++++++-------------- src/constitutive_thermal_dissipation.f90 | 6 ++--- src/constitutive_thermal_externalheat.f90 | 6 ++--- src/grid/grid_thermal_spectral.f90 | 4 ++-- src/thermal_conduction.f90 | 10 ++++----- 7 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/DAMASK_marc.f90 b/src/DAMASK_marc.f90 index 0ad68445c..7c002e63c 100644 --- a/src/DAMASK_marc.f90 +++ b/src/DAMASK_marc.f90 @@ -364,7 +364,8 @@ subroutine flux(f,ts,n,time) real(pReal), dimension(2), intent(out) :: & f - call thermal_conduction_getSourceAndItsTangent(f(1), f(2), ts(3), n(3),mesh_FEM2DAMASK_elem(n(1))) + f(2) = 0.0_pReal + call thermal_conduction_getSourceAndItsTangent(f(1), ts(3), n(3),mesh_FEM2DAMASK_elem(n(1))) end subroutine flux diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 250f7f99e..0b58e524f 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -283,15 +283,14 @@ module constitutive dPhiDot_dPhi end subroutine constitutive_damage_getRateAndItsTangents - module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, ip, el) + module subroutine constitutive_thermal_getRateAndItsTangents(TDot, T,ip,el) integer, intent(in) :: & ip, & !< integration point number el !< element number real(pReal), intent(in) :: & T - real(pReal), intent(inout) :: & - TDot, & - dTDot_dT + real(pReal), intent(out) :: & + TDot end subroutine constitutive_thermal_getRateAndItsTangents diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index a716a0c55..721d6925c 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -36,7 +36,7 @@ submodule(constitutive) constitutive_thermal end function kinematics_thermal_expansion_init - module subroutine source_thermal_dissipation_getRateAndItsTangent(TDot, dTDot_dT, Tstar, Lp, phase) + module subroutine source_thermal_dissipation_getRateAndItsTangent(TDot, Tstar,Lp,phase) integer, intent(in) :: & phase !< phase ID of element real(pReal), intent(in), dimension(3,3) :: & @@ -44,17 +44,15 @@ submodule(constitutive) constitutive_thermal real(pReal), intent(in), dimension(3,3) :: & Lp !< plastic velocuty gradient for a given element real(pReal), intent(out) :: & - TDot, & - dTDot_dT + TDot end subroutine source_thermal_dissipation_getRateAndItsTangent - module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, dTDot_dT, phase, of) + module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, phase,of) integer, intent(in) :: & phase, & of real(pReal), intent(out) :: & - TDot, & - dTDot_dT + TDot end subroutine source_thermal_externalheat_getRateAndItsTangent end interface @@ -129,7 +127,7 @@ end subroutine thermal_init !---------------------------------------------------------------------------------------------- !< @brief calculates thermal dissipation rate !---------------------------------------------------------------------------------------------- -module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, ip, el) +module subroutine constitutive_thermal_getRateAndItsTangents(TDot, T, ip, el) integer, intent(in) :: & ip, & !< integration point number @@ -137,12 +135,10 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, real(pReal), intent(in) :: & T !< plastic velocity gradient real(pReal), intent(out) :: & - TDot, & - dTDot_dT + TDot real(pReal) :: & - my_Tdot, & - my_dTdot_dT + my_Tdot integer :: & ph, & homog, & @@ -154,25 +150,22 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, homog = material_homogenizationAt(el) instance = thermal_typeInstance(homog) + TDot = 0.0_pReal do co = 1, homogenization_Nconstituents(homog) ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) do so = 1, thermal_Nsources(ph) select case(thermal_source(so,ph)) case (THERMAL_DISSIPATION_ID) - call source_thermal_dissipation_getRateAndItsTangent(my_Tdot, my_dTdot_dT, & - mech_S(ph,me),mech_L_p(ph,me), ph) + call source_thermal_dissipation_getRateAndItsTangent(my_Tdot, mech_S(ph,me),mech_L_p(ph,me),ph) case (THERMAL_EXTERNALHEAT_ID) - call source_thermal_externalheat_getRateAndItsTangent(my_Tdot, my_dTdot_dT, & - ph, me) + call source_thermal_externalheat_getRateAndItsTangent(my_Tdot, ph,me) case default my_Tdot = 0.0_pReal - my_dTdot_dT = 0.0_pReal end select Tdot = Tdot + my_Tdot - dTdot_dT = dTdot_dT + my_dTdot_dT enddo enddo diff --git a/src/constitutive_thermal_dissipation.f90 b/src/constitutive_thermal_dissipation.f90 index f15d1cfe9..88b170f27 100644 --- a/src/constitutive_thermal_dissipation.f90 +++ b/src/constitutive_thermal_dissipation.f90 @@ -78,7 +78,7 @@ end function source_thermal_dissipation_init !-------------------------------------------------------------------------------------------------- !> @brief Ninstancess dissipation rate !-------------------------------------------------------------------------------------------------- -module subroutine source_thermal_dissipation_getRateAndItsTangent(TDot, dTDot_dT, Tstar, Lp, phase) +module subroutine source_thermal_dissipation_getRateAndItsTangent(TDot, Tstar, Lp, phase) integer, intent(in) :: & phase @@ -88,12 +88,10 @@ module subroutine source_thermal_dissipation_getRateAndItsTangent(TDot, dTDot_dT Lp real(pReal), intent(out) :: & - TDot, & - dTDot_dT + TDot associate(prm => param(source_thermal_dissipation_instance(phase))) TDot = prm%kappa*sum(abs(Tstar*Lp)) - dTDot_dT = 0.0_pReal end associate end subroutine source_thermal_dissipation_getRateAndItsTangent diff --git a/src/constitutive_thermal_externalheat.f90 b/src/constitutive_thermal_externalheat.f90 index 2a3ec7362..853f1e7dd 100644 --- a/src/constitutive_thermal_externalheat.f90 +++ b/src/constitutive_thermal_externalheat.f90 @@ -104,14 +104,13 @@ end subroutine source_thermal_externalheat_dotState !-------------------------------------------------------------------------------------------------- !> @brief returns local heat generation rate !-------------------------------------------------------------------------------------------------- -module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, dTDot_dT, phase, of) +module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, phase, of) integer, intent(in) :: & phase, & of real(pReal), intent(out) :: & - TDot, & - dTDot_dT + TDot integer :: & sourceOffset, interval @@ -131,7 +130,6 @@ module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, dTDot_d prm%f_T(interval+1) * frac_time ! interpolate heat rate between segment boundaries... ! ...or extrapolate if outside of bounds enddo - dTDot_dT = 0.0 end associate end subroutine source_thermal_externalheat_getRateAndItsTangent diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 259b45f33..aa3c38e4c 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -256,7 +256,7 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) PetscObject :: dummy PetscErrorCode :: ierr integer :: i, j, k, cell - real(pReal) :: Tdot, dTdot_dT + real(pReal) :: Tdot T_current = x_scal !-------------------------------------------------------------------------------------------------- @@ -278,7 +278,7 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) cell = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) cell = cell + 1 - call thermal_conduction_getSourceAndItsTangent(Tdot, dTdot_dT, T_current(i,j,k), 1, cell) + call thermal_conduction_getSourceAndItsTangent(Tdot, T_current(i,j,k), 1, cell) scalarField_real(i,j,k) = params%timeinc*(scalarField_real(i,j,k) + Tdot) & + thermal_conduction_getMassDensity (1,cell)* & thermal_conduction_getSpecificHeat(1,cell)*(T_lastInc(i,j,k) - & diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index 02649b1ad..4d6869d04 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -91,7 +91,7 @@ end subroutine thermal_conduction_init !-------------------------------------------------------------------------------------------------- !> @brief return heat generation rate !-------------------------------------------------------------------------------------------------- -subroutine thermal_conduction_getSourceAndItsTangent(Tdot, dTdot_dT, T, ip, el) +subroutine thermal_conduction_getSourceAndItsTangent(Tdot, T,ip,el) integer, intent(in) :: & ip, & !< integration point number @@ -99,15 +99,15 @@ subroutine thermal_conduction_getSourceAndItsTangent(Tdot, dTdot_dT, T, ip, el) real(pReal), intent(in) :: & T real(pReal), intent(out) :: & - Tdot, dTdot_dT - integer :: & + Tdot + + integer :: & homog homog = material_homogenizationAt(el) - call constitutive_thermal_getRateAndItsTangents(TDot, dTDot_dT, T, ip, el) + call constitutive_thermal_getRateAndItsTangents(TDot, T,ip,el) Tdot = Tdot/real(homogenization_Nconstituents(homog),pReal) - dTdot_dT = dTdot_dT/real(homogenization_Nconstituents(homog),pReal) end subroutine thermal_conduction_getSourceAndItsTangent From 0d291235b0242b6f751e71c0d1aa3a4a73429c66 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Fri, 8 Jan 2021 18:14:36 +0100 Subject: [PATCH 088/352] updated PRIVATE --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 76f383c4e..9282365fd 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 76f383c4e57cb41b55de9aad4d9baf209a91633d +Subproject commit 9282365fd54ccff1e8e57f4ea38967d733a4adc0 From fc7f919c231bb0b6e0973efcdecc8836ab496259 Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 8 Jan 2021 21:37:15 +0100 Subject: [PATCH 089/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-230-g0fc670d01 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 62c706093..f123674b3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-173-g584c7cc3a +v3.0.0-alpha2-230-g0fc670d01 From 209d59534aa865ab474d3544238e5d3966538ad0 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 9 Jan 2021 17:19:48 +0100 Subject: [PATCH 090/352] copy and paste error --- src/constitutive_thermal_dissipation.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constitutive_thermal_dissipation.f90 b/src/constitutive_thermal_dissipation.f90 index 88b170f27..9153915ca 100644 --- a/src/constitutive_thermal_dissipation.f90 +++ b/src/constitutive_thermal_dissipation.f90 @@ -37,7 +37,7 @@ module function source_thermal_dissipation_init(source_length) result(mySources) src integer :: Ninstances,sourceOffset,Nconstituents,p - print'(/,a)', ' <<<+- thermal_externalheat init -+>>>' + print'(/,a)', ' <<<+- thermal_dissipation init -+>>>' mySources = thermal_active('dissipation',source_length) From 2b91bad53ee63d9b8701244fa7c516d3084d0c80 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 10 Jan 2021 10:17:16 +0100 Subject: [PATCH 091/352] https://stackoverflow.com/questions/14950378 --- src/C_routines.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/C_routines.c b/src/C_routines.c index 4b07c0ee0..3d62a87c2 100644 --- a/src/C_routines.c +++ b/src/C_routines.c @@ -43,7 +43,7 @@ void gethostname_c(char hostname[], int *stat){ void getusername_c(char username[], int *stat){ - struct passwd *pw = getpwuid(geteuid()); + struct passwd *pw = getpwuid(getuid()); if(pw && strlen(pw->pw_name) <= STRLEN){ strncpy(username,pw->pw_name,STRLEN+1); *stat = 0; From b5bfb1dba9c88cb26c5d6040056d798d51556437 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 11 Jan 2021 16:13:59 +0100 Subject: [PATCH 092/352] tangent is not included anymore --- src/DAMASK_marc.f90 | 2 +- src/constitutive.f90 | 6 +++--- src/constitutive_thermal.f90 | 16 ++++++++-------- src/constitutive_thermal_dissipation.f90 | 4 ++-- src/constitutive_thermal_externalheat.f90 | 4 ++-- src/grid/grid_thermal_spectral.f90 | 2 +- src/thermal_conduction.f90 | 8 ++++---- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/DAMASK_marc.f90 b/src/DAMASK_marc.f90 index 7c002e63c..0f9d37ddb 100644 --- a/src/DAMASK_marc.f90 +++ b/src/DAMASK_marc.f90 @@ -365,7 +365,7 @@ subroutine flux(f,ts,n,time) f f(2) = 0.0_pReal - call thermal_conduction_getSourceAndItsTangent(f(1), ts(3), n(3),mesh_FEM2DAMASK_elem(n(1))) + call thermal_conduction_getSource(f(1), ts(3), n(3),mesh_FEM2DAMASK_elem(n(1))) end subroutine flux diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 0b58e524f..c6415a883 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -283,7 +283,7 @@ module constitutive dPhiDot_dPhi end subroutine constitutive_damage_getRateAndItsTangents - module subroutine constitutive_thermal_getRateAndItsTangents(TDot, T,ip,el) + module subroutine constitutive_thermal_getRate(TDot, T,ip,el) integer, intent(in) :: & ip, & !< integration point number el !< element number @@ -291,7 +291,7 @@ module constitutive T real(pReal), intent(out) :: & TDot - end subroutine constitutive_thermal_getRateAndItsTangents + end subroutine constitutive_thermal_getRate @@ -384,7 +384,7 @@ module constitutive constitutive_init, & constitutive_homogenizedC, & constitutive_damage_getRateAndItsTangents, & - constitutive_thermal_getRateAndItsTangents, & + constitutive_thermal_getRate, & constitutive_results, & constitutive_allocateState, & constitutive_forward, & diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 721d6925c..9787cb0e4 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -36,7 +36,7 @@ submodule(constitutive) constitutive_thermal end function kinematics_thermal_expansion_init - module subroutine source_thermal_dissipation_getRateAndItsTangent(TDot, Tstar,Lp,phase) + module subroutine thermal_dissipation_getRate(TDot, Tstar,Lp,phase) integer, intent(in) :: & phase !< phase ID of element real(pReal), intent(in), dimension(3,3) :: & @@ -45,15 +45,15 @@ submodule(constitutive) constitutive_thermal Lp !< plastic velocuty gradient for a given element real(pReal), intent(out) :: & TDot - end subroutine source_thermal_dissipation_getRateAndItsTangent + end subroutine thermal_dissipation_getRate - module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, phase,of) + module subroutine thermal_externalheat_getRate(TDot, phase,of) integer, intent(in) :: & phase, & of real(pReal), intent(out) :: & TDot - end subroutine source_thermal_externalheat_getRateAndItsTangent + end subroutine thermal_externalheat_getRate end interface @@ -127,7 +127,7 @@ end subroutine thermal_init !---------------------------------------------------------------------------------------------- !< @brief calculates thermal dissipation rate !---------------------------------------------------------------------------------------------- -module subroutine constitutive_thermal_getRateAndItsTangents(TDot, T, ip, el) +module subroutine constitutive_thermal_getRate(TDot, T, ip, el) integer, intent(in) :: & ip, & !< integration point number @@ -157,10 +157,10 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, T, ip, el) do so = 1, thermal_Nsources(ph) select case(thermal_source(so,ph)) case (THERMAL_DISSIPATION_ID) - call source_thermal_dissipation_getRateAndItsTangent(my_Tdot, mech_S(ph,me),mech_L_p(ph,me),ph) + call thermal_dissipation_getRate(my_Tdot, mech_S(ph,me),mech_L_p(ph,me),ph) case (THERMAL_EXTERNALHEAT_ID) - call source_thermal_externalheat_getRateAndItsTangent(my_Tdot, ph,me) + call thermal_externalheat_getRate(my_Tdot, ph,me) case default my_Tdot = 0.0_pReal @@ -169,7 +169,7 @@ module subroutine constitutive_thermal_getRateAndItsTangents(TDot, T, ip, el) enddo enddo -end subroutine constitutive_thermal_getRateAndItsTangents +end subroutine constitutive_thermal_getRate !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_thermal_dissipation.f90 b/src/constitutive_thermal_dissipation.f90 index 9153915ca..ae2d5735e 100644 --- a/src/constitutive_thermal_dissipation.f90 +++ b/src/constitutive_thermal_dissipation.f90 @@ -78,7 +78,7 @@ end function source_thermal_dissipation_init !-------------------------------------------------------------------------------------------------- !> @brief Ninstancess dissipation rate !-------------------------------------------------------------------------------------------------- -module subroutine source_thermal_dissipation_getRateAndItsTangent(TDot, Tstar, Lp, phase) +module subroutine thermal_dissipation_getRate(TDot, Tstar, Lp, phase) integer, intent(in) :: & phase @@ -94,6 +94,6 @@ module subroutine source_thermal_dissipation_getRateAndItsTangent(TDot, Tstar, L TDot = prm%kappa*sum(abs(Tstar*Lp)) end associate -end subroutine source_thermal_dissipation_getRateAndItsTangent +end subroutine thermal_dissipation_getRate end submodule source_dissipation diff --git a/src/constitutive_thermal_externalheat.f90 b/src/constitutive_thermal_externalheat.f90 index 853f1e7dd..2e8c02f8c 100644 --- a/src/constitutive_thermal_externalheat.f90 +++ b/src/constitutive_thermal_externalheat.f90 @@ -104,7 +104,7 @@ end subroutine source_thermal_externalheat_dotState !-------------------------------------------------------------------------------------------------- !> @brief returns local heat generation rate !-------------------------------------------------------------------------------------------------- -module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, phase, of) +module subroutine thermal_externalheat_getRate(TDot, phase, of) integer, intent(in) :: & phase, & @@ -132,6 +132,6 @@ module subroutine source_thermal_externalheat_getRateAndItsTangent(TDot, phase, enddo end associate -end subroutine source_thermal_externalheat_getRateAndItsTangent +end subroutine thermal_externalheat_getRate end submodule source_externalheat diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index aa3c38e4c..9d804ec56 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -278,7 +278,7 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) cell = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) cell = cell + 1 - call thermal_conduction_getSourceAndItsTangent(Tdot, T_current(i,j,k), 1, cell) + call thermal_conduction_getSource(Tdot, T_current(i,j,k), 1, cell) scalarField_real(i,j,k) = params%timeinc*(scalarField_real(i,j,k) + Tdot) & + thermal_conduction_getMassDensity (1,cell)* & thermal_conduction_getSpecificHeat(1,cell)*(T_lastInc(i,j,k) - & diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index 4d6869d04..79fe0d6cd 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -25,7 +25,7 @@ module thermal_conduction public :: & thermal_conduction_init, & - thermal_conduction_getSourceAndItsTangent, & + thermal_conduction_getSource, & thermal_conduction_getConductivity, & thermal_conduction_getSpecificHeat, & thermal_conduction_getMassDensity, & @@ -91,7 +91,7 @@ end subroutine thermal_conduction_init !-------------------------------------------------------------------------------------------------- !> @brief return heat generation rate !-------------------------------------------------------------------------------------------------- -subroutine thermal_conduction_getSourceAndItsTangent(Tdot, T,ip,el) +subroutine thermal_conduction_getSource(Tdot, T,ip,el) integer, intent(in) :: & ip, & !< integration point number @@ -105,11 +105,11 @@ subroutine thermal_conduction_getSourceAndItsTangent(Tdot, T,ip,el) homog homog = material_homogenizationAt(el) - call constitutive_thermal_getRateAndItsTangents(TDot, T,ip,el) + call constitutive_thermal_getRate(TDot, T,ip,el) Tdot = Tdot/real(homogenization_Nconstituents(homog),pReal) -end subroutine thermal_conduction_getSourceAndItsTangent +end subroutine thermal_conduction_getSource !-------------------------------------------------------------------------------------------------- From dc55aa002a05c48ded960260e933d3cfe05f961d Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 12 Jan 2021 14:13:26 +0100 Subject: [PATCH 093/352] updated test repo --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 9282365fd..f6fd3227e 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 9282365fd54ccff1e8e57f4ea38967d733a4adc0 +Subproject commit f6fd3227ec0f9c03fbf991bf7f8732b22ae96530 From 72c940a46d0f338bd54c554284388493be46f376 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 12 Jan 2021 17:02:13 +0100 Subject: [PATCH 094/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-255-g1e50fcc77 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f123674b3..7e44dd77b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-230-g0fc670d01 +v3.0.0-alpha2-255-g1e50fcc77 From 66af1f1818425d7c25375ccb1b28b981afb51d66 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 12 Jan 2021 23:33:27 +0100 Subject: [PATCH 095/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-258-g715504ee5 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7e44dd77b..364cb0e13 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-255-g1e50fcc77 +v3.0.0-alpha2-258-g715504ee5 From 2d6e6a2370230834521a2ecac4d892ce73dffeca Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 12 Jan 2021 18:56:40 -0500 Subject: [PATCH 096/352] Rotation composition uses "*"; application of Rotation to object uses "@"; "apply()" works on both --- python/damask/_orientation.py | 23 +++++----- python/damask/_rotation.py | 83 +++++++++++++++++++++-------------- python/tests/test_Rotation.py | 4 +- 3 files changed, 65 insertions(+), 45 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index d5be5a751..cf31f4089 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -242,24 +242,25 @@ class Orientation(Rotation): return np.logical_not(self==other) - def __matmul__(self,other): + def __mul__(self,other): """ - Rotation of vector, second or fourth order tensor, or rotation object. + Compose this orientation with other. Parameters ---------- - other : numpy.ndarray, Rotation, or Orientation - Vector, second or fourth order tensor, or rotation object that is rotated. + other : Rotation or Orientation + Object for composition. Returns ------- - other_rot : numpy.ndarray or Rotation - Rotated vector, second or fourth order tensor, or rotation object. + composition : Orientation + Compound rotation self*other, i.e. first other then self rotation. """ - return self.copy(rotation=Rotation.__matmul__(self,Rotation(other.quaternion))) \ - if isinstance(other,self.__class__) else \ - Rotation.__matmul__(self,other) + if isinstance(other,Orientation) or isinstance(other,Rotation): + return self.copy(rotation=Rotation.__mul__(self,Rotation(other.quaternion))) + else: + raise TypeError('Use "O@b", i.e. matmul, to apply Orientation "O" to object "b"') @classmethod @@ -440,7 +441,7 @@ class Orientation(Rotation): raise ValueError('Missing crystal symmetry') o = self.symmetry_operations.broadcast_to(self.symmetry_operations.shape+self.shape,mode='right') - return self.copy(rotation=o@Rotation(self.quaternion).broadcast_to(o.shape,mode='left')) + return self.copy(rotation=o*Rotation(self.quaternion).broadcast_to(o.shape,mode='left')) @property @@ -619,7 +620,7 @@ class Orientation(Rotation): o,lattice = self.relation_operations(model,return_lattice=True) target = Orientation(lattice=lattice) o = o.broadcast_to(o.shape+self.shape,mode='right') - return self.copy(rotation=o@Rotation(self.quaternion).broadcast_to(o.shape,mode='left'), + return self.copy(rotation=o*Rotation(self.quaternion).broadcast_to(o.shape,mode='left'), lattice=lattice, b = self.b if target.ratio['b'] is None else self.a*target.ratio['b'], c = self.c if target.ratio['c'] is None else self.a*target.ratio['c'], diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index ace2a3dba..b5b393971 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -35,6 +35,11 @@ class Rotation: - b = Q @ a - b = np.dot(Q.as_matrix(),a) + Compound rotations R1 (first) and R2 (second): + + - R = R2 * R1 + - R = Rotation.from_matrix(np.dot(R2.as_matrix(),R1.as_matrix()) + References ---------- D. Rowenhorst et al., Modelling and Simulation in Materials Science and Engineering 23:083501, 2015 @@ -96,8 +101,8 @@ class Rotation: """ Equal to other. - Equality is determined taking limited floating point precision into - account. See numpy.allclose for details. + Equality is determined taking limited floating point precision into account. + See numpy.allclose for details. Parameters ---------- @@ -182,14 +187,25 @@ class Rotation: Parameters ---------- - other : damask.Rotation of shape(self.shape) - Rotation for comosition. + other : Rotation of shape(self.shape) + Rotation for composition. + + Returns + ------- + composition : Rotation + Compound rotation self*other, i.e. first other then self rotation. """ if isinstance(other,Rotation): - return self@other + q_m = self.quaternion[...,0:1] + p_m = self.quaternion[...,1:] + q_o = other.quaternion[...,0:1] + p_o = other.quaternion[...,1:] + q = (q_m*q_o - np.einsum('...i,...i',p_m,p_o).reshape(self.shape+(1,))) + p = q_m*p_o + q_o*p_m + _P * np.cross(p_m,p_o) + return Rotation(np.block([q,p]))._standardize() else: - raise TypeError('Use "R@b", i.e. matmul, to apply rotation "R" to object "b"') + raise TypeError('Use "R@b", i.e. matmul, to apply rotation "R" to object "b"') def __imul__(self,other): """ @@ -197,8 +213,8 @@ class Rotation: Parameters ---------- - other : damask.Rotation of shape(self.shape) - Rotation for comosition. + other : Rotation of shape(self.shape) + Rotation for composition. """ return self*other @@ -213,11 +229,16 @@ class Rotation: other : damask.Rotation of shape (self.shape) Rotation to inverse composition. + Returns + ------- + composition : Rotation + Compound rotation self*(~other), i.e. first inverse of other then self rotation. + """ if isinstance(other,Rotation): - return self@~other + return self*~other else: - raise TypeError('Use "R@b", i.e. matmul, to apply rotation "R" to object "b"') + raise TypeError('Use "R@b", i.e. matmul, to apply rotation "R" to object "b"') def __itruediv__(self,other): """ @@ -225,7 +246,7 @@ class Rotation: Parameters ---------- - other : damask.Rotation of shape (self.shape) + other : Rotation of shape (self.shape) Rotation to inverse composition. """ @@ -234,41 +255,39 @@ class Rotation: def apply(self,other): """ - Apply rotation to vector, second or fourth order tensor, or rotation object. + Apply rotation to Rotation, vector, second order tensor, or fourth order tensor. Parameters ---------- - other : numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) or Rotation - Vector, tensor, or rotation object on which to apply the rotation. + other : Rotation or numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) + Rotation, vector, or tensor on which to apply the rotation. + + Returns + ------- + rotated : Rotation or numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) + Composed rotation or rotated vector/tensor, i.e. transformed to frame defined by rotation. """ - return self@other + return self*other if isinstance(other,Rotation) else self@other def __matmul__(self,other): """ - Rotation of vector, second or fourth order tensor, or rotation object. + Rotation of vector, second order tensor, or fourth order tensor. Parameters ---------- - other : numpy.ndarray or Rotation - Vector, second or fourth order tensor, or rotation object that is rotated. + other : numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) + Vector or tensor on which to apply the rotation. Returns ------- - other_rot : numpy.ndarray or Rotation - Rotated vector, second or fourth order tensor, or rotation object. + rotated : numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) + Rotated vector or tensor, i.e. transformed to frame defined by rotation. """ if isinstance(other,Rotation): - q_m = self.quaternion[...,0:1] - p_m = self.quaternion[...,1:] - q_o = other.quaternion[...,0:1] - p_o = other.quaternion[...,1:] - q = (q_m*q_o - np.einsum('...i,...i',p_m,p_o).reshape(self.shape+(1,))) - p = q_m*p_o + q_o*p_m + _P * np.cross(p_m,p_o) - return Rotation(np.block([q,p]))._standardize() - + raise TypeError('Use "R1*R2", i.e. multiplication, to compose rotations "R1" and "R2"') elif isinstance(other,np.ndarray): if self.shape + (3,) == other.shape: q_m = self.quaternion[...,0] @@ -392,7 +411,7 @@ class Rotation: Rotation to which the misorientation is computed. """ - return other@~self + return other*~self ################################################################################################ @@ -915,7 +934,7 @@ class Rotation: np.sqrt(1-u**2)*np.sin(Theta), u, omega]) - return Rotation.from_axis_angle(p) @ center + return Rotation.from_axis_angle(p) * center @staticmethod @@ -966,8 +985,8 @@ class Rotation: f[::2,:3] *= -1 # flip half the rotation axes to negative sense return R_align.broadcast_to(N) \ - @ Rotation.from_axis_angle(p,normalize=True) \ - @ Rotation.from_axis_angle(f) + * Rotation.from_axis_angle(p,normalize=True) \ + * Rotation.from_axis_angle(f) #################################################################################################### diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 707bc0210..ff4894632 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -956,7 +956,7 @@ class TestRotation: def test_rotate_inverse(self): R = Rotation.from_random() - assert np.allclose(np.eye(3),(~R@R).as_matrix()) + assert np.allclose(np.eye(3),(~R*R).as_matrix()) @pytest.mark.parametrize('data',[np.random.rand(3), np.random.rand(3,3), @@ -1024,7 +1024,7 @@ class TestRotation: @pytest.mark.parametrize('item',[Rotation(),np.ones(3),np.ones((3,3)), np.ones((3,3,3,3))]) def test_apply(self,item): r = Rotation.from_random() - assert r.apply(item) == r@item if isinstance(item,Rotation) else (r.apply(item) == r@item).all() + assert r.apply(item) == r*item if isinstance(item,Rotation) else (r.apply(item) == r@item).all() @pytest.mark.parametrize('angle',[10,20,30,40,50,60,70,80,90,100,120]) def test_average(self,angle): From f4247e0f3559370b56d894394b3c3cc84200ba62 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 13 Jan 2021 09:35:42 +0100 Subject: [PATCH 097/352] simpler (and scipy compatible) --- python/damask/_rotation.py | 26 +++++--------------------- python/tests/test_Rotation.py | 4 ++-- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index b5b393971..0c6824c35 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -253,24 +253,6 @@ class Rotation: return self/other - def apply(self,other): - """ - Apply rotation to Rotation, vector, second order tensor, or fourth order tensor. - - Parameters - ---------- - other : Rotation or numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) - Rotation, vector, or tensor on which to apply the rotation. - - Returns - ------- - rotated : Rotation or numpy.ndarray of shape (...,3), (...,3,3), or (...,3,3,3,3) - Composed rotation or rotated vector/tensor, i.e. transformed to frame defined by rotation. - - """ - return self*other if isinstance(other,Rotation) else self@other - - def __matmul__(self,other): """ Rotation of vector, second order tensor, or fourth order tensor. @@ -286,9 +268,7 @@ class Rotation: Rotated vector or tensor, i.e. transformed to frame defined by rotation. """ - if isinstance(other,Rotation): - raise TypeError('Use "R1*R2", i.e. multiplication, to compose rotations "R1" and "R2"') - elif isinstance(other,np.ndarray): + if isinstance(other,np.ndarray): if self.shape + (3,) == other.shape: q_m = self.quaternion[...,0] p_m = self.quaternion[...,1:] @@ -308,9 +288,13 @@ class Rotation: return np.einsum('...im,...jn,...ko,...lp,...mnop',R,R,R,R,other) else: raise ValueError('Can only rotate vectors, 2nd order tensors, and 4th order tensors') + elif isinstance(other,Rotation): + raise TypeError('Use "R1*R2", i.e. multiplication, to compose rotations "R1" and "R2"') else: raise TypeError(f'Cannot rotate {type(other)}') + apply = __matmul__ + def _standardize(self): """Standardize quaternion (ensure positive real hemisphere).""" diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index ff4894632..6bee44e7f 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -1021,10 +1021,10 @@ class TestRotation: R = Rotation.from_random() assert R/R == R*R**(-1) == Rotation() - @pytest.mark.parametrize('item',[Rotation(),np.ones(3),np.ones((3,3)), np.ones((3,3,3,3))]) + @pytest.mark.parametrize('item',[np.ones(3),np.ones((3,3)), np.ones((3,3,3,3))]) def test_apply(self,item): r = Rotation.from_random() - assert r.apply(item) == r*item if isinstance(item,Rotation) else (r.apply(item) == r@item).all() + assert (r.apply(item) == r@item).all() @pytest.mark.parametrize('angle',[10,20,30,40,50,60,70,80,90,100,120]) def test_average(self,angle): From 196902948f6612e48d14c6ecb567a550ca8ab9d4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 13 Jan 2021 09:50:58 +0100 Subject: [PATCH 098/352] simplified --- python/damask/_rotation.py | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 0c6824c35..441fb5b01 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -70,17 +70,9 @@ class Rotation: def __repr__(self): - """Represent rotation as unit quaternion, rotation matrix, and Bunge-Euler angles.""" - if self.shape == () and self == Rotation(): - return 'Rotation()' - else: - return f'Quaternions {self.shape}:\n'+str(self.quaternion) \ - if self.quaternion.shape != (4,) else \ - '\n'.join([ - 'Quaternion: (real={:.3f}, imag=<{:+.3f}, {:+.3f}, {:+.3f}>)'.format(*(self.quaternion)), - 'Matrix:\n{}'.format(np.round(self.as_matrix(),8)), - 'Bunge Eulers / deg: ({:3.2f}, {:3.2f}, {:3.2f})'.format(*self.as_Euler_angles(degrees=True)), - ]) + """Represent rotation as unit quaternion(s).""" + return f'Quaternion{" " if self.quaternion.shape == (4,) else "s of shape "+str(self.quaternion.shape)+chr(10)}'\ + + str(self.quaternion) def __copy__(self,**kwargs): @@ -150,35 +142,31 @@ class Rotation: return dup - def __pow__(self,pwr): + def __pow__(self,exp): """ - Raise quaternion to power. - - Equivalent to performing the rotation 'pwr' times. + Perform the rotation 'exp' times. Parameters ---------- - pwr : float - Power to raise quaternion to. + exp : float + Exponent. """ phi = np.arccos(self.quaternion[...,0:1]) p = self.quaternion[...,1:]/np.linalg.norm(self.quaternion[...,1:],axis=-1,keepdims=True) - return self.copy(rotation=Rotation(np.block([np.cos(pwr*phi),np.sin(pwr*phi)*p]))._standardize()) + return self.copy(rotation=Rotation(np.block([np.cos(exp*phi),np.sin(exp*phi)*p]))._standardize()) - def __ipow__(self,pwr): + def __ipow__(self,exp): """ - Raise quaternion to power (in-place). - - Equivalent to performing the rotation 'pwr' times. + Perform the rotation 'exp' times (in-place). Parameters ---------- - pwr : float - Power to raise quaternion to. + exp : float + Exponent. """ - return self**pwr + return self**exp def __mul__(self,other): From 4c35da8627cb14255be645d26e9161bf2816bbcd Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 13 Jan 2021 11:33:28 +0100 Subject: [PATCH 099/352] simplified --- python/damask/_grid.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 76ce7ba64..0edec05f9 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -763,24 +763,19 @@ 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 - Eulers = R.as_Euler_angles(degrees=True) - material_in = self.material.copy() - + material = self.material # These rotations are always applied in the reference coordinate system, i.e. (z,x,z) not (z,x',z'') # see https://www.cs.utexas.edu/~theshark/courses/cs354/lectures/cs354-14.pdf - for angle,axes in zip(Eulers[::-1], [(0,1),(1,2),(0,1)]): - material_out = ndimage.rotate(material_in,angle,axes,order=0, - prefilter=False,output=dtype,cval=fill) - if np.prod(material_in.shape) == np.prod(material_out.shape): - # avoid scipy interpolation errors for rotations close to multiples of 90° - material_in = np.rot90(material_in,k=np.rint(angle/90.).astype(int),axes=axes) - else: - material_in = material_out + for angle,axes in zip(R.as_Euler_angles(degrees=True)[::-1], [(0,1),(1,2),(0,1)]): + material_temp = ndimage.rotate(material,angle,axes,order=0,prefilter=False,output=dtype,cval=fill) + # avoid scipy interpolation errors for rotations close to multiples of 90° + material = material_temp if np.prod(material_temp.shape) != np.prod(material.shape) else \ + np.rot90(material,k=np.rint(angle/90.).astype(int),axes=axes) - origin = self.origin-(np.asarray(material_in.shape)-self.cells)*.5 * self.size/self.cells + origin = self.origin-(np.asarray(material.shape)-self.cells)*.5 * self.size/self.cells - return Grid(material = material_in, - size = self.size/self.cells*np.asarray(material_in.shape), + return Grid(material = material, + size = self.size/self.cells*np.asarray(material.shape), origin = origin, comments = self.comments+[util.execution_stamp('Grid','rotate')], ) From 4b0b28805435861ba6b4917fb90104cae22c667d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 13 Jan 2021 12:25:06 +0100 Subject: [PATCH 100/352] 2021! 10 years of DAMASK --- LICENSE | 2 +- PRIVATE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 3ffc3b9e3..4290d15bd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2011-20 Max-Planck-Institut für Eisenforschung GmbH +Copyright 2011-21 Max-Planck-Institut für Eisenforschung GmbH DAMASK is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/PRIVATE b/PRIVATE index 7846c7112..1d0c95c5c 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 7846c71126705cc5d41dd79f2d595f4864434068 +Subproject commit 1d0c95c5c1c0e7e6f57bdfc94b695e47a6ad6c60 From a7d998dd48896fc4cd2d9c1b41589bdc9186f331 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 13 Jan 2021 12:48:20 +0100 Subject: [PATCH 101/352] standard name --- env/CONFIG | 6 +++--- env/DAMASK.csh | 8 ++++---- env/DAMASK.sh | 6 +++--- env/DAMASK.zsh | 6 +++--- python/damask/_environment.py | 5 +---- python/damask/_grid.py | 14 +++++++------- python/damask/_result.py | 3 +-- src/parallelization.f90 | 20 ++++++++++---------- 8 files changed, 32 insertions(+), 36 deletions(-) diff --git a/env/CONFIG b/env/CONFIG index 52057526a..4407f4d2b 100644 --- a/env/CONFIG +++ b/env/CONFIG @@ -1,5 +1,5 @@ # "set"-syntax needed only for tcsh (but works with bash and zsh) -set DAMASK_NUM_THREADS = 4 +set OMP_NUM_THREADS = 4 -set MSC_ROOT = /opt/msc -set MSC_VERSION = 2020 +set MSC_ROOT = /opt/msc +set MSC_VERSION = 2020 diff --git a/env/DAMASK.csh b/env/DAMASK.csh index cc61449d2..58f2a150e 100644 --- a/env/DAMASK.csh +++ b/env/DAMASK.csh @@ -10,8 +10,8 @@ source $ENV_ROOT/CONFIG set path = ($DAMASK_ROOT/bin $path) set SOLVER=`which DAMASK_grid` -if ( "x$DAMASK_NUM_THREADS" == "x" ) then - set DAMASK_NUM_THREADS=1 +if ( "x$OMP_NUM_THREADS" == "x" ) then + set OMP_NUM_THREADS=1 endif # currently, there is no information that unlimited stack size causes problems @@ -38,13 +38,13 @@ if ( $?prompt ) then echo "MSC.Marc/Mentat $MSC_ROOT" endif echo - echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS" + echo "Multithreading OMP_NUM_THREADS=$OMP_NUM_THREADS" echo `limit datasize` echo `limit stacksize` echo endif -setenv DAMASK_NUM_THREADS $DAMASK_NUM_THREADS +setenv OMP_NUM_THREADS $OMP_NUM_THREADS if ( ! $?PYTHONPATH ) then setenv PYTHONPATH $DAMASK_ROOT/python else diff --git a/env/DAMASK.sh b/env/DAMASK.sh index 2151e842b..24a2c2de3 100644 --- a/env/DAMASK.sh +++ b/env/DAMASK.sh @@ -38,7 +38,7 @@ PATH=${DAMASK_ROOT}/bin:$PATH SOLVER=$(type -p DAMASK_grid || true 2>/dev/null) [ "x$SOLVER" == "x" ] && SOLVER=$(blink 'Not found!') -[ "x$DAMASK_NUM_THREADS" == "x" ] && DAMASK_NUM_THREADS=1 +[ "x$OMP_NUM_THREADS" == "x" ] && OMP_NUM_THREADS=1 # currently, there is no information that unlimited stack size causes problems # still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it @@ -66,7 +66,7 @@ if [ ! -z "$PS1" ]; then echo -n "MSC.Marc/Mentat " [ -d $MSC_ROOT ] && echo $MSC_ROOT || blink $MSC_ROOT echo - echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS" + echo "Multithreading OMP_NUM_THREADS=$OMP_NUM_THREADS" echo -n "heap size " [[ "$(ulimit -d)" == "unlimited" ]] \ && echo "unlimited" \ @@ -86,7 +86,7 @@ if [ ! -z "$PS1" ]; then echo fi -export DAMASK_NUM_THREADS +export OMP_NUM_THREADS export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH for var in BASE STAT SOLVER BRANCH; do diff --git a/env/DAMASK.zsh b/env/DAMASK.zsh index 377aa5304..e12a5248a 100644 --- a/env/DAMASK.zsh +++ b/env/DAMASK.zsh @@ -30,7 +30,7 @@ PATH=${DAMASK_ROOT}/bin:$PATH SOLVER=$(which DAMASK_grid || true 2>/dev/null) [[ "x$SOLVER" == "x" ]] && SOLVER=$(blink 'Not found!') -[[ "x$DAMASK_NUM_THREADS" == "x" ]] && DAMASK_NUM_THREADS=1 +[[ "x$OMP_NUM_THREADS" == "x" ]] && OMP_NUM_THREADS=1 # currently, there is no information that unlimited stack size causes problems # still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it @@ -60,7 +60,7 @@ if [ ! -z "$PS1" ]; then echo -n "MSC.Marc/Mentat " [ -d $MSC_ROOT ] && echo $MSC_ROOT || blink $MSC_ROOT echo - echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS" + echo "Multithreading OMP_NUM_THREADS=$OMP_NUM_THREADS" echo -n "heap size " [[ "$(ulimit -d)" == "unlimited" ]] \ && echo "unlimited" \ @@ -80,7 +80,7 @@ if [ ! -z "$PS1" ]; then echo fi -export DAMASK_NUM_THREADS +export OMP_NUM_THREADS export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH for var in SOLVER BRANCH; do diff --git a/python/damask/_environment.py b/python/damask/_environment.py index 7d93b83e0..30110e7ae 100644 --- a/python/damask/_environment.py +++ b/python/damask/_environment.py @@ -26,10 +26,7 @@ class Environment: @property def options(self): options = {} - for item in ['DAMASK_NUM_THREADS', - 'MSC_ROOT', - 'MSC_VERSION', - ]: + for item in ['MSC_ROOT', 'MSC_VERSION']: options[item] = os.environ[item] if item in os.environ else None return options diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 0edec05f9..2d3e59b37 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -1,7 +1,7 @@ import copy import multiprocessing as mp from functools import partial -from os import path +import os import warnings import numpy as np @@ -278,14 +278,14 @@ class Grid: """ root_dir ='DataContainers' f = h5py.File(fname, 'r') - g = path.join(root_dir,base_group,'_SIMPL_GEOMETRY') - cells = f[path.join(g,'DIMENSIONS')][()] - size = f[path.join(g,'SPACING')][()] * cells - origin = f[path.join(g,'ORIGIN')][()] + g = os.path.join(root_dir,base_group,'_SIMPL_GEOMETRY') + cells = f[os.path.join(g,'DIMENSIONS')][()] + size = f[os.path.join(g,'SPACING')][()] * cells + origin = f[os.path.join(g,'ORIGIN')][()] ma = np.arange(cells.prod(),dtype=int) \ if point_data is None else \ - np.reshape(f[path.join(root_dir,base_group,point_data,material)],cells.prod()) + np.reshape(f[os.path.join(root_dir,base_group,point_data,material)],cells.prod()) return Grid(ma.reshape(cells,order='F'),size,origin,util.execution_stamp('Grid','load_DREAM3D')) @@ -355,7 +355,7 @@ class Grid: seeds_p = seeds coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3) - pool = mp.Pool(processes = int(environment.options['DAMASK_NUM_THREADS'])) + pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',1))) result = pool.map_async(partial(Grid._find_closest_seed,seeds_p,weights_p), [coord for coord in coords]) pool.close() pool.join() diff --git a/python/damask/_result.py b/python/damask/_result.py index 5e37042e0..3f788f229 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1134,8 +1134,7 @@ class Result: """ chunk_size = 1024**2//8 - num_threads = damask.environment.options['DAMASK_NUM_THREADS'] - pool = mp.Pool(int(num_threads) if num_threads is not None else None) + pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',1))) lock = mp.Manager().Lock() groups = self.groups_with_datasets(datasets.values()) diff --git a/src/parallelization.f90 b/src/parallelization.f90 index 11a3574ec..edf56407b 100644 --- a/src/parallelization.f90 +++ b/src/parallelization.f90 @@ -32,7 +32,7 @@ contains subroutine parallelization_init integer :: err, typeSize -!$ integer :: got_env, DAMASK_NUM_THREADS, threadLevel +!$ integer :: got_env, OMP_NUM_THREADS, threadLevel !$ character(len=6) NumThreadsString #ifdef PETSc PetscErrorCode :: petsc_err @@ -87,19 +87,19 @@ call MPI_Comm_rank(PETSC_COMM_WORLD,worldrank,err) open(OUTPUT_UNIT,file='/dev/null',status='replace') ! close() alone will leave some temp files in cwd endif -!$ call get_environment_variable(name='DAMASK_NUM_THREADS',value=NumThreadsString,STATUS=got_env) +!$ call get_environment_variable(name='OMP_NUM_THREADS',value=NumThreadsString,STATUS=got_env) !$ if(got_env /= 0) then -!$ print*, 'Could not determine value of $DAMASK_NUM_THREADS' -!$ DAMASK_NUM_THREADS = 1_pI32 +!$ print*, 'Could not determine value of $OMP_NUM_THREADS' +!$ OMP_NUM_THREADS = 1_pI32 !$ else -!$ read(NumThreadsString,'(i6)') DAMASK_NUM_THREADS -!$ if (DAMASK_NUM_THREADS < 1_pI32) then -!$ print*, 'Invalid DAMASK_NUM_THREADS: '//trim(NumThreadsString) -!$ DAMASK_NUM_THREADS = 1_pI32 +!$ read(NumThreadsString,'(i6)') OMP_NUM_THREADS +!$ if (OMP_NUM_THREADS < 1_pI32) then +!$ print*, 'Invalid OMP_NUM_THREADS: '//trim(NumThreadsString) +!$ OMP_NUM_THREADS = 1_pI32 !$ endif !$ endif -!$ print'(a,i2)', ' DAMASK_NUM_THREADS: ',DAMASK_NUM_THREADS -!$ call omp_set_num_threads(DAMASK_NUM_THREADS) +!$ print'(a,i2)', ' OMP_NUM_THREADS: ',OMP_NUM_THREADS +!$ call omp_set_num_threads(OMP_NUM_THREADS) end subroutine parallelization_init From d76543f7590f8df2376de9f828b577f07f2acf54 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 13 Jan 2021 14:57:58 +0100 Subject: [PATCH 102/352] better name --- python/damask/_result.py | 98 ++++++++++++++++++------------------- python/tests/test_Result.py | 44 ++++++++--------- 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index 3f788f229..3d8368911 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -80,12 +80,12 @@ class Result: self.out_type_ho += f['/'.join([self.increments[0],'homogenization',m])].keys() self.out_type_ho = list(set(self.out_type_ho)) # make unique - self.selection = {'increments': self.increments, - 'phases': self.phases, - 'homogenizations': self.homogenizations, - 'out_type_ph': self.out_type_ph, - 'out_type_ho': self.out_type_ho - } + self.visible = {'increments': self.increments, + 'phases': self.phases, + 'homogenizations': self.homogenizations, + 'out_type_ph': self.out_type_ph, + 'out_type_ho': self.out_type_ho + } self.fname = Path(fname).absolute() @@ -94,23 +94,23 @@ class Result: def __repr__(self): """Show summary of file content.""" - all_selected_increments = self.selection['increments'] + visible_increments = self.visible['increments'] - self.pick('increments',all_selected_increments[0:1]) + self.view('increments',visible_increments[0:1]) first = self.list_data() - self.pick('increments',all_selected_increments[-1:]) - last = '' if len(all_selected_increments) < 2 else self.list_data() + self.view('increments',visible_increments[-1:]) + last = '' if len(visible_increments) < 2 else self.list_data() - self.pick('increments',all_selected_increments) + self.view('increments',visible_increments) - in_between = '' if len(all_selected_increments) < 3 else \ - ''.join([f'\n{inc}\n ...\n' for inc in all_selected_increments[1:-2]]) + in_between = '' if len(visible_increments) < 3 else \ + ''.join([f'\n{inc}\n ...\n' for inc in visible_increments[1:-2]]) return util.srepr(first + in_between + last) - def _manage_selection(self,action,what,datasets): + def _manage_view(self,action,what,datasets): """ Manages the visibility of the groups. @@ -119,7 +119,7 @@ class Result: action : str Select from 'set', 'add', and 'del'. what : str - Attribute to change (must be from self.selection). + Attribute to change (must be in self.visible). datasets : list of str or bool Name of datasets as list, supports ? and * wildcards. True is equivalent to [*], False is equivalent to [] @@ -156,18 +156,18 @@ class Result: choice.append(self.increments[idx+1]) valid = [e for e_ in [glob.fnmatch.filter(getattr(self,what),s) for s in choice] for e in e_] - existing = set(self.selection[what]) + existing = set(self.visible[what]) if action == 'set': - self.selection[what] = valid + self.visible[what] = valid elif action == 'add': add = existing.union(valid) add_sorted = sorted(add, key=natural_sort) - self.selection[what] = add_sorted + self.visible[what] = add_sorted elif action == 'del': diff = existing.difference(valid) diff_sorted = sorted(diff, key=natural_sort) - self.selection[what] = diff_sorted + self.visible[what] = diff_sorted def _get_attribute(self,path,attr): @@ -245,72 +245,72 @@ class Result: def iterate(self,what): """ - Iterate over selection items by setting each one selected. + Iterate over visible items and view them independently. Parameters ---------- what : str - Attribute to change (must be from self.selection). + Attribute to change (must be from self.visible). """ - datasets = self.selection[what] - last_selection = datasets.copy() + datasets = self.visible[what] + last_view = datasets.copy() for dataset in datasets: - if last_selection != self.selection[what]: - self._manage_selection('set',what,datasets) + if last_view != self.visible[what]: + self._manage_view('set',what,datasets) raise Exception - self._manage_selection('set',what,dataset) - last_selection = self.selection[what] + self._manage_view('set',what,dataset) + last_view = self.visible[what] yield dataset - self._manage_selection('set',what,datasets) + self._manage_view('set',what,datasets) - def pick(self,what,datasets): + def view(self,what,datasets): """ - Set selection. + Set view. Parameters ---------- what : str - attribute to change (must be from self.selection) + attribute to change (must be from self.visible) datasets : list of str or bool name of datasets as list, supports ? and * wildcards. True is equivalent to [*], False is equivalent to [] """ - self._manage_selection('set',what,datasets) + self._manage_view('set',what,datasets) - def pick_more(self,what,datasets): + def view_more(self,what,datasets): """ - Add to selection. + Add to view. Parameters ---------- what : str - attribute to change (must be from self.selection) + attribute to change (must be from self.visible) datasets : list of str or bool name of datasets as list, supports ? and * wildcards. True is equivalent to [*], False is equivalent to [] """ - self._manage_selection('add',what,datasets) + self._manage_view('add',what,datasets) - def pick_less(self,what,datasets): + def view_less(self,what,datasets): """ - Delete from selection. + Delete from view. Parameters ---------- what : str - attribute to change (must be from self.selection) + attribute to change (must be from self.visible) datasets : list of str or bool name of datasets as list, supports ? and * wildcards. True is equivalent to [*], False is equivalent to [] """ - self._manage_selection('del',what,datasets) + self._manage_view('del',what,datasets) def rename(self,name_old,name_new): @@ -1189,8 +1189,8 @@ class Result: """ Write XDMF file to directly visualize data in DADF5 file. - This works only for scalar, 3-vector and 3x3-tensor data. - Selection is not taken into account. + The view is not taken into account, i.e. the content of the + whole file will be included. """ if self.N_constituents != 1 or len(self.phases) != 1 or not self.structured: raise TypeError('XDMF output requires homogeneous grid') @@ -1319,10 +1319,10 @@ class Result: N_digits = int(np.floor(np.log10(max(1,int(self.increments[-1][3:])))))+1 - for inc in util.show_progress(self.iterate('increments'),len(self.selection['increments'])): + for inc in util.show_progress(self.iterate('increments'),len(self.visible['increments'])): - picked_backup_ho = self.selection['homogenizations'].copy() - self.pick('homogenizations',False) + viewed_backup_ho = self.visible['homogenizations'].copy() + self.view('homogenizations',False) for label in (labels if isinstance(labels,list) else [labels]): for o in self.iterate('out_type_ph'): for c in range(self.N_constituents): @@ -1342,10 +1342,10 @@ class Result: ph_name = re.compile(r'(?<=(phase\/))(.*?)(?=(mechanics))') # identify phase name dset_name = prefix+re.sub(ph_name,r'',paths[0].split('/',1)[1]) # remove phase name v.add(array,dset_name+f' / {self._get_attribute(paths[0],"Unit")}') - self.pick('homogenizations',picked_backup_ho) + self.view('homogenizations',viewed_backup_ho) - picked_backup_ph = self.selection['phases'].copy() - self.pick('phases',False) + viewed_backup_ph = self.visible['phases'].copy() + self.view('phases',False) for label in (labels if isinstance(labels,list) else [labels]): for _ in self.iterate('out_type_ho'): paths = self.get_dataset_location(label) @@ -1353,7 +1353,7 @@ class Result: continue array = self.read_dataset(paths) v.add(array,paths[0].split('/',1)[1]+f' / {self._get_attribute(paths[0],"Unit")}') - self.pick('phases',picked_backup_ph) + self.view('phases',viewed_backup_ph) u = self.read_dataset(self.get_dataset_location('u_n' if mode.lower() == 'cell' else 'u_p')) v.add(u,'u') diff --git a/python/tests/test_Result.py b/python/tests/test_Result.py index b8447b8b0..9973e7e7c 100644 --- a/python/tests/test_Result.py +++ b/python/tests/test_Result.py @@ -21,7 +21,7 @@ def default(tmp_path,ref_path): fname = '12grains6x7x8_tensionY.hdf5' shutil.copy(ref_path/fname,tmp_path) f = Result(tmp_path/fname) - f.pick('times',20.0) + f.view('times',20.0) return f @pytest.fixture @@ -43,56 +43,56 @@ class TestResult: print(default) - def test_pick_all(self,default): - default.pick('increments',True) + def test_view_all(self,default): + default.view('increments',True) a = default.get_dataset_location('F') - default.pick('increments','*') + default.view('increments','*') b = default.get_dataset_location('F') - default.pick('increments',default.incs_in_range(0,np.iinfo(int).max)) + default.view('increments',default.incs_in_range(0,np.iinfo(int).max)) c = default.get_dataset_location('F') - default.pick('times',True) + default.view('times',True) d = default.get_dataset_location('F') - default.pick('times','*') + default.view('times','*') e = default.get_dataset_location('F') - default.pick('times',default.times_in_range(0.0,np.inf)) + default.view('times',default.times_in_range(0.0,np.inf)) f = default.get_dataset_location('F') assert a == b == c == d == e ==f @pytest.mark.parametrize('what',['increments','times','phases']) # ToDo: discuss homogenizations - def test_pick_none(self,default,what): - default.pick(what,False) + def test_view_none(self,default,what): + default.view(what,False) a = default.get_dataset_location('F') - default.pick(what,[]) + default.view(what,[]) b = default.get_dataset_location('F') assert a == b == [] @pytest.mark.parametrize('what',['increments','times','phases']) # ToDo: discuss homogenizations - def test_pick_more(self,default,what): - default.pick(what,False) - default.pick_more(what,'*') + def test_view_more(self,default,what): + default.view(what,False) + default.view_more(what,'*') a = default.get_dataset_location('F') - default.pick(what,True) + default.view(what,True) b = default.get_dataset_location('F') assert a == b @pytest.mark.parametrize('what',['increments','times','phases']) # ToDo: discuss homogenizations - def test_pick_less(self,default,what): - default.pick(what,True) - default.pick_less(what,'*') + def test_view_less(self,default,what): + default.view(what,True) + default.view_less(what,'*') a = default.get_dataset_location('F') - default.pick(what,False) + default.view(what,False) b = default.get_dataset_location('F') assert a == b == [] - def test_pick_invalid(self,default): + def test_view_invalid(self,default): with pytest.raises(AttributeError): - default.pick('invalid',True) + default.view('invalid',True) def test_add_absolute(self,default): default.add_absolute('F_e') @@ -307,7 +307,7 @@ class TestResult: @pytest.mark.parametrize('overwrite',['off','on']) def test_add_overwrite(self,default,overwrite): - default.pick('times',default.times_in_range(0,np.inf)[-1]) + default.view('times',default.times_in_range(0,np.inf)[-1]) default.add_stress_Cauchy() loc = default.get_dataset_location('sigma') From 2cd5d96a904adafab7fb62219cb7fa391709edcc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 13 Jan 2021 18:42:59 +0100 Subject: [PATCH 103/352] not really used, not needed by normal users --- env/DAMASK.csh | 54 -------------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 env/DAMASK.csh diff --git a/env/DAMASK.csh b/env/DAMASK.csh deleted file mode 100644 index 58f2a150e..000000000 --- a/env/DAMASK.csh +++ /dev/null @@ -1,54 +0,0 @@ -# sets up an environment for DAMASK on tcsh -# usage: source DAMASK_env.csh - -set CALLED=($_) -set ENV_ROOT=`dirname $CALLED[2]` -set DAMASK_ROOT=`python3 -c "import os,sys; print(os.path.realpath(os.path.expanduser(sys.argv[1])))" $ENV_ROOT"/../"` - -source $ENV_ROOT/CONFIG - -set path = ($DAMASK_ROOT/bin $path) - -set SOLVER=`which DAMASK_grid` -if ( "x$OMP_NUM_THREADS" == "x" ) then - set OMP_NUM_THREADS=1 -endif - -# currently, there is no information that unlimited stack size causes problems -# still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it -# more info https://jblevins.org/log/segfault -# https://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap -# http://superuser.com/questions/220059/what-parameters-has-ulimit -limit stacksize unlimited # maximum stack size (kB) - -# disable output in case of scp -if ( $?prompt ) then - echo '' - echo Düsseldorf Advanced Materials Simulation Kit --- DAMASK - echo Max-Planck-Institut für Eisenforschung GmbH, Düsseldorf - echo https://damask.mpie.de - echo - echo Using environment with ... - echo "DAMASK $DAMASK_ROOT" - echo "Grid Solver $SOLVER" - if ( $?PETSC_DIR) then - echo "PETSc location $PETSC_DIR" - endif - if ( $?MSC_ROOT) then - echo "MSC.Marc/Mentat $MSC_ROOT" - endif - echo - echo "Multithreading OMP_NUM_THREADS=$OMP_NUM_THREADS" - echo `limit datasize` - echo `limit stacksize` - echo -endif - -setenv OMP_NUM_THREADS $OMP_NUM_THREADS -if ( ! $?PYTHONPATH ) then - setenv PYTHONPATH $DAMASK_ROOT/python -else - setenv PYTHONPATH $DAMASK_ROOT/python:$PYTHONPATH -endif -setenv MSC_ROOT -setenv MSC_VERSION From 37de561938cd7c4d048a5b1b3ad6b9cd8533766d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 13 Jan 2021 18:43:20 +0100 Subject: [PATCH 104/352] shell variables are more robust they will also work if Fortran and python code are installed in different locations. --- env/DAMASK.sh | 4 +++- env/DAMASK.zsh | 4 +++- .../mods_MarcMentat/apply_DAMASK_modifications.py | 2 +- python/damask/_environment.py | 8 +------- python/damask/_test.py | 2 +- python/damask/solver/_marc.py | 2 +- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/env/DAMASK.sh b/env/DAMASK.sh index 24a2c2de3..f8ccfc1e0 100644 --- a/env/DAMASK.sh +++ b/env/DAMASK.sh @@ -87,10 +87,12 @@ if [ ! -z "$PS1" ]; then fi export OMP_NUM_THREADS +export MSC_ROOT +export MSC_VERSION +export DAMASK_ROOT export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH for var in BASE STAT SOLVER BRANCH; do unset "${var}" done unset "ENV_ROOT" -unset "DAMASK_ROOT" diff --git a/env/DAMASK.zsh b/env/DAMASK.zsh index e12a5248a..2c74657fd 100644 --- a/env/DAMASK.zsh +++ b/env/DAMASK.zsh @@ -81,10 +81,12 @@ if [ ! -z "$PS1" ]; then fi export OMP_NUM_THREADS +export MSC_ROOT +export MSC_VERSION +export DAMASK_ROOT export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH for var in SOLVER BRANCH; do unset "${var}" done unset "ENV_ROOT" -unset "DAMASK_ROOT" diff --git a/installation/mods_MarcMentat/apply_DAMASK_modifications.py b/installation/mods_MarcMentat/apply_DAMASK_modifications.py index 407c33558..1b430ca75 100755 --- a/installation/mods_MarcMentat/apply_DAMASK_modifications.py +++ b/installation/mods_MarcMentat/apply_DAMASK_modifications.py @@ -11,7 +11,7 @@ msc_version = float(damask.environment.options['MSC_VERSION']) if int(msc_version) == msc_version: msc_version = int(msc_version) msc_root = Path(damask.environment.options['MSC_ROOT']) -damask_root = damask.environment.root_dir +damask_root = damask.environment.options['DAMASK_ROOT'] parser = argparse.ArgumentParser( description='Apply DAMASK modification to MSC.Marc/Mentat', diff --git a/python/damask/_environment.py b/python/damask/_environment.py index 30110e7ae..556229f63 100644 --- a/python/damask/_environment.py +++ b/python/damask/_environment.py @@ -26,13 +26,7 @@ class Environment: @property def options(self): options = {} - for item in ['MSC_ROOT', 'MSC_VERSION']: + for item in ['DAMASK_ROOT', 'MSC_ROOT', 'MSC_VERSION']: options[item] = os.environ[item] if item in os.environ else None return options - - - @property - def root_dir(self): - """Return DAMASK root path.""" - return Path(__file__).parents[2] diff --git a/python/damask/_test.py b/python/damask/_test.py index 000b76e0e..cea9b3a70 100644 --- a/python/damask/_test.py +++ b/python/damask/_test.py @@ -180,7 +180,7 @@ class Test: def fileInRoot(self,dir,file): """Path to a file in the root directory of DAMASK.""" - return str(damask.environment.root_dir/dir/file) + return str(damask.environment.options['DAMASK_ROOT']/dir/file) def fileInReference(self,file): diff --git a/python/damask/solver/_marc.py b/python/damask/solver/_marc.py index 5ddcf8898..c1dc3220d 100644 --- a/python/damask/solver/_marc.py +++ b/python/damask/solver/_marc.py @@ -54,7 +54,7 @@ class Marc: optimization = '', ): - usersub = environment.root_dir/'src/DAMASK_marc' + usersub = environment.options['DAMASK_ROOT']/'src/DAMASK_marc' usersub = usersub.parent/(usersub.name + ('.f90' if compile else '.marc')) if not usersub.is_file(): raise FileNotFoundError(f'subroutine ({"source" if compile else "binary"}) "{usersub}" not found') From c01fbe79bec51716ed92dfb3749a88fa0398c01f Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 13 Jan 2021 19:31:03 +0100 Subject: [PATCH 105/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-279-g8182c9c54 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 364cb0e13..6e2dff56f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-258-g715504ee5 +v3.0.0-alpha2-279-g8182c9c54 From c32b90417241e927a5522b4a5dfe4d9c8d1b9016 Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 14 Jan 2021 22:38:59 +0100 Subject: [PATCH 106/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-292-g589178668 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6e2dff56f..5a4014717 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-279-g8182c9c54 +v3.0.0-alpha2-292-g589178668 From 0f6094890a1a4230aaf3ab4f26057fa89fec9d6c Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 14 Jan 2021 21:12:29 +0100 Subject: [PATCH 107/352] simplified damask.environment does not offer any advantage over os.environ for variables. After 'root_dir' was removed, the whole module became obsolete --- PRIVATE | 2 +- .../apply_DAMASK_modifications.py | 16 ++++------ installation/symlink_Processing.py | 8 ++--- processing/post/DADF5_postResults.py | 8 ++--- python/damask/__init__.py | 3 -- python/damask/_environment.py | 32 ------------------- python/damask/_grid.py | 1 - python/damask/_test.py | 3 +- python/damask/_vtk.py | 20 ++++++++++-- python/damask/solver/_marc.py | 15 +++------ 10 files changed, 39 insertions(+), 69 deletions(-) delete mode 100644 python/damask/_environment.py diff --git a/PRIVATE b/PRIVATE index b1a31a79c..7c0795bce 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit b1a31a79cc90d458494068a96cfd3e9497aa330c +Subproject commit 7c0795bce79d0d9d223d7df5559ad6e63d6c2de0 diff --git a/installation/mods_MarcMentat/apply_DAMASK_modifications.py b/installation/mods_MarcMentat/apply_DAMASK_modifications.py index 1b430ca75..1cd93c47c 100755 --- a/installation/mods_MarcMentat/apply_DAMASK_modifications.py +++ b/installation/mods_MarcMentat/apply_DAMASK_modifications.py @@ -5,13 +5,9 @@ import glob import argparse from pathlib import Path -import damask - -msc_version = float(damask.environment.options['MSC_VERSION']) -if int(msc_version) == msc_version: - msc_version = int(msc_version) -msc_root = Path(damask.environment.options['MSC_ROOT']) -damask_root = damask.environment.options['DAMASK_ROOT'] +msc_version = os.environ['MSC_VERSION'] +msc_root = Path(os.environ['MSC_ROOT']) +damask_root = Path(os.environ['DAMASK_ROOT']) parser = argparse.ArgumentParser( description='Apply DAMASK modification to MSC.Marc/Mentat', @@ -24,7 +20,7 @@ def copy_and_replace(in_file,dst): with open(in_file) as f: content = f.read() content = content.replace('%INSTALLDIR%',str(msc_root)) - content = content.replace('%VERSION%',str(msc_version)) + content = content.replace('%VERSION%', msc_version) content = content.replace('%EDITOR%', parser.parse_args().editor) with open(dst/Path(in_file).name,'w') as f: f.write(content) @@ -53,8 +49,8 @@ for in_file in glob.glob(str(src/'job_run.ms')): print('compiling Mentat menu binaries...') -executable = str(msc_root/f'mentat{msc_version}/bin/mentat') -menu_file = str(msc_root/f'mentat{msc_version}/menus/linux64/main.msb') +executable = msc_root/f'mentat{msc_version}/bin/mentat' +menu_file = msc_root/f'mentat{msc_version}/menus/linux64/main.msb' os.system(f'xvfb-run {executable} -compile {menu_file}') diff --git a/installation/symlink_Processing.py b/installation/symlink_Processing.py index c9cf6e32a..ef2274028 100755 --- a/installation/symlink_Processing.py +++ b/installation/symlink_Processing.py @@ -3,11 +3,9 @@ # Makes postprocessing routines accessible from everywhere. import sys from pathlib import Path +import os -import damask - -env = damask.Environment() -bin_dir = env.root_dir/Path('bin') +bin_dir = Path(os.environ['DAMASK_ROOT'])/'bin' if not bin_dir.exists(): bin_dir.mkdir() @@ -15,7 +13,7 @@ if not bin_dir.exists(): sys.stdout.write('\nsymbolic linking...\n') for sub_dir in ['pre','post']: - the_dir = env.root_dir/Path('processing')/Path(sub_dir) + the_dir = Path(os.environ['DAMASK_ROOT'])/'processing'/sub_dir for the_file in the_dir.glob('*.py'): src = the_dir/the_file diff --git a/processing/post/DADF5_postResults.py b/processing/post/DADF5_postResults.py index a1b162e3d..81babcc57 100755 --- a/processing/post/DADF5_postResults.py +++ b/processing/post/DADF5_postResults.py @@ -41,15 +41,15 @@ for filename in options.filenames: table = damask.Table(np.ones(np.product(results.cells),dtype=int)*int(inc[3:]),{'inc':(1,)})\ .add('pos',coords.reshape(-1,3)) - results.pick('homogenizations',False) - results.pick('phases',True) + results.view('homogenizations',False) + results.view('phases',True) for label in options.con: x = results.get_dataset_location(label) if len(x) != 0: table = table.add(label,results.read_dataset(x,0,plain=True).reshape(results.cells.prod(),-1)) - results.pick('phases',False) - results.pick('homogenizations',True) + results.view('phases',False) + results.view('homogenizations',True) for label in options.mat: x = results.get_dataset_location(label) if len(x) != 0: diff --git a/python/damask/__init__.py b/python/damask/__init__.py index fa1af9f4f..e356d0bc4 100644 --- a/python/damask/__init__.py +++ b/python/damask/__init__.py @@ -16,8 +16,6 @@ with open(_Path(__file__).parent/_Path('VERSION')) as _f: __version__ = version # make classes directly accessible as damask.Class -from ._environment import Environment as _ # noqa -environment = _() from . import util # noqa from . import seeds # noqa from . import tensor # noqa @@ -38,7 +36,6 @@ from ._result import Result # noqa # deprecated -Environment = _ from ._asciitable import ASCIItable # noqa from ._test import Test # noqa from .util import extendableOption # noqa diff --git a/python/damask/_environment.py b/python/damask/_environment.py deleted file mode 100644 index 556229f63..000000000 --- a/python/damask/_environment.py +++ /dev/null @@ -1,32 +0,0 @@ -import os -from pathlib import Path - -class Environment: - - @property - def screen_size(self): - try: - import wx - _ = wx.App(False) # noqa - width, height = wx.GetDisplaySize() - except ImportError: - try: - import tkinter - tk = tkinter.Tk() - width = tk.winfo_screenwidth() - height = tk.winfo_screenheight() - tk.destroy() - except Exception as e: - width = 1024 - height = 768 - - return (width,height) - - - @property - def options(self): - options = {} - for item in ['DAMASK_ROOT', 'MSC_ROOT', 'MSC_VERSION']: - options[item] = os.environ[item] if item in os.environ else None - - return options diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 2d3e59b37..103538349 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -10,7 +10,6 @@ import h5py from scipy import ndimage, spatial from vtk.util.numpy_support import vtk_to_numpy as vtk_to_np -from . import environment from . import VTK from . import util from . import grid_filters diff --git a/python/damask/_test.py b/python/damask/_test.py index cea9b3a70..2f5dbde1f 100644 --- a/python/damask/_test.py +++ b/python/damask/_test.py @@ -5,6 +5,7 @@ import logging import logging.config from collections.abc import Iterable from optparse import OptionParser +from pathlib import Path import numpy as np @@ -180,7 +181,7 @@ class Test: def fileInRoot(self,dir,file): """Path to a file in the root directory of DAMASK.""" - return str(damask.environment.options['DAMASK_ROOT']/dir/file) + return str(Path(os.environ['DAMASK_ROOT'])/dir/file) def fileInReference(self,file): diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index 224412f7c..ad017ee1e 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -10,7 +10,6 @@ from vtk.util.numpy_support import numpy_to_vtkIdTypeArray as np_to_vtkIdTypeArr from vtk.util.numpy_support import vtk_to_numpy as vtk_to_np from . import util -from . import environment from . import Table @@ -348,6 +347,23 @@ class VTK: See http://compilatrix.com/article/vtk-1 for further ideas. """ + def screen_size(): + try: + import wx + _ = wx.App(False) # noqa + width, height = wx.GetDisplaySize() + except ImportError: + try: + import tkinter + tk = tkinter.Tk() + width = tk.winfo_screenwidth() + height = tk.winfo_screenheight() + tk.destroy() + except Exception as e: + width = 1024 + height = 768 + + return (width,height) mapper = vtk.vtkDataSetMapper() mapper.SetInputData(self.vtk_data) actor = vtk.vtkActor() @@ -361,7 +377,7 @@ class VTK: ren.AddActor(actor) ren.SetBackground(0.2,0.2,0.2) - window.SetSize(environment.screen_size[0],environment.screen_size[1]) + window.SetSize(screen_size[0],screen_size[1]) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(window) diff --git a/python/damask/solver/_marc.py b/python/damask/solver/_marc.py index c1dc3220d..d4aadb7ff 100644 --- a/python/damask/solver/_marc.py +++ b/python/damask/solver/_marc.py @@ -2,14 +2,13 @@ import subprocess import shlex import re import io +import os from pathlib import Path -from .. import environment - class Marc: """Wrapper to run DAMASK with MSCMarc.""" - def __init__(self,version=environment.options['MSC_VERSION']): + def __init__(self,version=os.environ['MSC_VERSION']): """ Create a Marc solver object. @@ -25,9 +24,7 @@ class Marc: @property def library_path(self): - path_MSC = environment.options['MSC_ROOT'] - path_lib = Path(f'{path_MSC}/mentat{self.version}/shlib/linux64') - + path_lib = Path(f'{os.environ["MSC_ROOT"]}/mentat{self.version}/shlib/linux64') if not path_lib.is_dir(): raise FileNotFoundError(f'library path "{path_lib}" not found') @@ -37,9 +34,7 @@ class Marc: @property def tools_path(self): - path_MSC = environment.options['MSC_ROOT'] - path_tools = Path(f'{path_MSC}/marc{self.version}/tools') - + path_tools = Path(f'{os.environ["MSC_ROOT"]}/marc{self.version}/tools') if not path_tools.is_dir(): raise FileNotFoundError(f'tools path "{path_tools}" not found') @@ -54,7 +49,7 @@ class Marc: optimization = '', ): - usersub = environment.options['DAMASK_ROOT']/'src/DAMASK_marc' + usersub = Path(os.environ['DAMASK_ROOT'])/'src/DAMASK_marc' usersub = usersub.parent/(usersub.name + ('.f90' if compile else '.marc')) if not usersub.is_file(): raise FileNotFoundError(f'subroutine ({"source" if compile else "binary"}) "{usersub}" not found') From d1eb650f541c508b4e87290a9b0059ed26be48e6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 15 Jan 2021 21:04:09 +0100 Subject: [PATCH 108/352] polished tests --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 7c0795bce..9e8011876 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 7c0795bce79d0d9d223d7df5559ad6e63d6c2de0 +Subproject commit 9e8011876b16896a18902737790eba8018e94f85 From c8be2b321c83ecf458dfb6b867bf50db3fbc25fb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 09:30:42 +0100 Subject: [PATCH 109/352] separat handling of thermal constitutive response --- src/constitutive.f90 | 31 ++++++---------- src/constitutive_mech.f90 | 7 ---- src/constitutive_thermal.f90 | 69 +++++++++++------------------------- src/homogenization.f90 | 37 +++++++++++++------ 4 files changed, 57 insertions(+), 87 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index c6415a883..2ec947f2b 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -120,19 +120,15 @@ module constitutive integer, intent(in) :: ph, me end subroutine mech_initializeRestorationPoints - module subroutine thermal_initializeRestorationPoints(ph,me) + module subroutine constitutive_thermal_initializeRestorationPoints(ph,me) integer, intent(in) :: ph, me - end subroutine thermal_initializeRestorationPoints + end subroutine constitutive_thermal_initializeRestorationPoints module subroutine mech_windForward(ph,me) integer, intent(in) :: ph, me end subroutine mech_windForward - module subroutine thermal_windForward(ph,me) - integer, intent(in) :: ph, me - end subroutine thermal_windForward - module subroutine mech_forward() end subroutine mech_forward @@ -146,10 +142,6 @@ module constitutive logical, intent(in) :: includeL end subroutine mech_restore - module subroutine thermal_restore(ip,el) - integer, intent(in) :: ip, el - end subroutine thermal_restore - module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) real(pReal), intent(in) :: dt @@ -214,14 +206,13 @@ module constitutive ! == cleaned:end =================================================================================== - module function integrateThermalState(Delta_t,co,ip,el) result(broken) + module function thermal_stress(Delta_t,ph,me) result(converged_) + real(pReal), intent(in) :: Delta_t - integer, intent(in) :: & - el, & !< element index in element loop - ip, & !< integration point index in ip loop - co !< grain index in grain loop - logical :: broken - end function integrateThermalState + integer, intent(in) :: ph, me + logical :: converged_ + + end function thermal_stress module function integrateDamageState(dt,co,ip,el) result(broken) real(pReal), intent(in) :: dt @@ -394,18 +385,19 @@ module constitutive converged, & crystallite_init, & crystallite_stress, & + thermal_stress, & constitutive_mech_dPdF, & crystallite_orientations, & crystallite_push33ToRef, & constitutive_restartWrite, & constitutive_restartRead, & - integrateThermalState, & integrateDamageState, & constitutive_thermal_setT, & constitutive_mech_getP, & constitutive_mech_setF, & constitutive_mech_getF, & constitutive_initializeRestorationPoints, & + constitutive_thermal_initializeRestorationPoints, & constitutive_windForward, & KINEMATICS_UNDEFINED_ID ,& KINEMATICS_CLEAVAGE_OPENING_ID, & @@ -553,7 +545,6 @@ subroutine constitutive_restore(ip,el,includeL) enddo call mech_restore(ip,el,includeL) - call thermal_restore(ip,el) end subroutine constitutive_restore @@ -720,7 +711,6 @@ subroutine constitutive_initializeRestorationPoints(ip,el) me = material_phaseMemberAt(co,ip,el) call mech_initializeRestorationPoints(ph,me) - call thermal_initializeRestorationPoints(ph,me) do so = 1, size(damageState(ph)%p) damageState(ph)%p(so)%partitionedState0(:,me) = damageState(ph)%p(so)%state0(:,me) @@ -750,7 +740,6 @@ subroutine constitutive_windForward(ip,el) me = material_phaseMemberAt(co,ip,el) call mech_windForward(ph,me) - call thermal_windForward(ph,me) do so = 1, phase_Nsources(material_phaseAt(co,el)) damageState(ph)%p(so)%partitionedState0(:,me) = damageState(ph)%p(so)%state(:,me) diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 8bc85354f..09aa797d8 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1633,9 +1633,6 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) do so = 1, phase_Nsources(ph) damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%state(:,me) enddo - do so = 1, thermal_Nsources(ph) - thermalState(ph)%p(so)%subState0(:,me) = thermalState(ph)%p(so)%state(:,me) - enddo endif !-------------------------------------------------------------------------------------------------- ! cut back (reduced time and restore) @@ -1652,9 +1649,6 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) do so = 1, phase_Nsources(ph) damageState(ph)%p(so)%state(:,me) = damageState(ph)%p(so)%subState0(:,me) enddo - do so = 1, thermal_Nsources(ph) - thermalState(ph)%p(so)%state(:,me) = thermalState(ph)%p(so)%subState0(:,me) - enddo todo = subStep > num%subStepMinCryst ! still on track or already done (beyond repair) endif @@ -1668,7 +1662,6 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) converged_ = .not. integrateState(subF0,subF,subFp0,subFi0,subState0(1:sizeDotState),subStep * dt,co,ip,el) converged_ = converged_ .and. .not. integrateDamageState(subStep * dt,co,ip,el) - converged_ = converged_ .and. .not. integrateThermalState(subStep * dt,co,ip,el) endif enddo cutbackLooping diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 9787cb0e4..cabd03c1e 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -86,7 +86,7 @@ module subroutine thermal_init(phases) Nconstituents = count(material_phaseAt == ph) * discretization_nIPs - allocate(current(ph)%T(Nconstituents)) + allocate(current(ph)%T(Nconstituents),source=300.0_pReal) phase => phases%get(ph) if(phase%contains('thermal')) then thermal => phase%get('thermal') @@ -197,30 +197,37 @@ function constitutive_thermal_collectDotState(ph,me) result(broken) end function constitutive_thermal_collectDotState +module function thermal_stress(Delta_t,ph,me) result(converged_) + + real(pReal), intent(in) :: Delta_t + integer, intent(in) :: ph, me + logical :: converged_ + + integer :: so + + + do so = 1, thermal_Nsources(ph) + thermalState(ph)%p(so)%state(:,me) = thermalState(ph)%p(so)%subState0(:,me) + enddo + converged_ = .not. integrateThermalState(Delta_t,ph,me) + +end function thermal_stress + !-------------------------------------------------------------------------------------------------- !> @brief integrate state with 1st order explicit Euler method !-------------------------------------------------------------------------------------------------- -module function integrateThermalState(Delta_t,co,ip,el) result(broken) +function integrateThermalState(Delta_t, ph,me) result(broken) real(pReal), intent(in) :: Delta_t - integer, intent(in) :: & - el, & !< element index in element loop - ip, & !< integration point index in ip loop - co !< grain index in grain loop + integer, intent(in) :: ph, me logical :: & broken integer :: & - ph, & - me, & so, & sizeDotState - - ph = material_phaseAt(co,el) - me = material_phaseMemberAt(co,ip,el) - broken = constitutive_thermal_collectDotState(ph,me) if(broken) return @@ -233,7 +240,7 @@ module function integrateThermalState(Delta_t,co,ip,el) result(broken) end function integrateThermalState -module subroutine thermal_initializeRestorationPoints(ph,me) +module subroutine constitutive_thermal_initializeRestorationPoints(ph,me) integer, intent(in) :: ph, me @@ -244,24 +251,10 @@ module subroutine thermal_initializeRestorationPoints(ph,me) thermalState(ph)%p(so)%partitionedState0(:,me) = thermalState(ph)%p(so)%state0(:,me) enddo -end subroutine thermal_initializeRestorationPoints +end subroutine constitutive_thermal_initializeRestorationPoints -module subroutine thermal_windForward(ph,me) - - integer, intent(in) :: ph, me - - integer :: so - - - do so = 1, size(thermalState(ph)%p) - thermalState(ph)%p(so)%partitionedState0(:,me) = thermalState(ph)%p(so)%state(:,me) - enddo - -end subroutine thermal_windForward - - module subroutine thermal_forward() integer :: ph, so @@ -276,26 +269,6 @@ module subroutine thermal_forward() end subroutine thermal_forward -module subroutine thermal_restore(ip,el) - - integer, intent(in) :: ip, el - - integer :: co, ph, me, so - - - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - ph = material_phaseAt(co,el) - me = material_phaseMemberAt(co,ip,el) - - do so = 1, size(thermalState(ph)%p) - thermalState(ph)%p(so)%state(:,me) = thermalState(ph)%p(so)%partitionedState0(:,me) - enddo - - enddo - -end subroutine thermal_restore - - !---------------------------------------------------------------------------------------------- !< @brief Get temperature (for use by non-thermal physics) !---------------------------------------------------------------------------------------------- diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 9112562b9..29d171062 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -161,7 +161,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE NiterationMPstate, & ip, & !< integration point number el, & !< element number - myNgrains, co, ce, ho, me + myNgrains, co, ce, ho, me, ph real(pReal) :: & subFrac, & subStep @@ -221,9 +221,8 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if (subStep > num%subStepMinHomog) doneAndHappy = [.false.,.true.] NiterationMPstate = 0 - convergenceLooping: do while (.not. terminallyIll & - .and. .not. doneAndHappy(1) & - .and. NiterationMPstate < num%nMPstate) + convergenceLooping: do while (.not. (terminallyIll .or. doneAndHappy(1)) & + .and. NiterationMPstate < num%nMPstate) NiterationMPstate = NiterationMPstate + 1 !-------------------------------------------------------------------------------------------------- @@ -231,10 +230,9 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if (.not. doneAndHappy(1)) then ce = (el-1)*discretization_nIPs + ip - call mech_partition(homogenization_F0(1:3,1:3,ce) & - + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce))& - *(subStep+subFrac), & - ip,el) + call mech_partition( homogenization_F0(1:3,1:3,ce) & + + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce))*(subStep+subFrac), & + ip,el) converged = .true. do co = 1, myNgrains converged = converged .and. crystallite_stress(dt*subStep,co,ip,el) @@ -260,12 +258,29 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE !$OMP END PARALLEL DO if (.not. terminallyIll ) then - !$OMP PARALLEL DO PRIVATE(ho,myNgrains) + !$OMP PARALLEL DO PRIVATE(ho,ph) + do el = FEsolving_execElem(1),FEsolving_execElem(2) + if (terminallyIll) continue + ho = material_homogenizationAt(el) + do ip = FEsolving_execIP(1),FEsolving_execIP(2) + do co = 1, homogenization_Nconstituents(ho) + ph = material_phaseAt(co,el) + call constitutive_thermal_initializeRestorationPoints(ph,material_phaseMemberAt(co,ip,el)) + if (.not. thermal_stress(dt,ph,material_phaseMemberAt(co,ip,el))) then + if (.not. terminallyIll) & ! so first signals terminally ill... + print*, ' Integration point ', ip,' at element ', el, ' terminally ill' + terminallyIll = .true. ! ...and kills all others + endif + enddo + enddo + enddo + !$OMP END PARALLEL DO + + !$OMP PARALLEL DO PRIVATE(ho) elementLooping3: do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) - myNgrains = homogenization_Nconstituents(ho) IpLooping3: do ip = FEsolving_execIP(1),FEsolving_execIP(2) - do co = 1, myNgrains + do co = 1, homogenization_Nconstituents(ho) call crystallite_orientations(co,ip,el) enddo call mech_homogenize(dt,ip,el) From 79364beadc1ad6030d52ca5a1fe1ce0d1eca25b8 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 10:10:30 +0100 Subject: [PATCH 110/352] partition temperature and use it further work required: - homogenization_T does not have the correct value - homogenization of rate needed --- src/constitutive_mech.f90 | 57 +++++++++++++++++---------------------- src/homogenization.f90 | 4 ++- 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 09aa797d8..50afe2e87 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -599,20 +599,18 @@ module subroutine constitutive_plastic_dependentState(co, ip, el) el !< element integer :: & - ho, & !< homogenization - tme, & !< thermal member position + ph, & instance, me - ho = material_homogenizationAt(el) - tme = material_homogenizationMemberAt(ip,el) - me = material_phasememberAt(co,ip,el) - instance = phase_plasticityInstance(material_phaseAt(co,el)) + ph = material_phaseAt(co,el) + me = material_phasememberAt(co,ip,el) + instance = phase_plasticityInstance(ph) plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_dependentState(temperature(ho)%p(tme),instance,me) + call plastic_dislotwin_dependentState(thermal_T(ph,me),instance,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType call plastic_dislotungsten_dependentState(instance,me) @@ -650,17 +648,13 @@ subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & real(pReal), dimension(3,3) :: & Mp !< Mandel stress work conjugate with Lp integer :: & - ho, & !< homogenization - tme !< thermal member position - integer :: & - i, j, instance, me + i, j, instance, me, ph - ho = material_homogenizationAt(el) - tme = material_homogenizationMemberAt(ip,el) Mp = matmul(matmul(transpose(Fi),Fi),S) me = material_phasememberAt(co,ip,el) - instance = phase_plasticityInstance(material_phaseAt(co,el)) + ph = material_phaseAt(co,el) + instance = phase_plasticityInstance(ph) plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) @@ -678,13 +672,13 @@ subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & call plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, temperature(ho)%p(tme),instance,me,ip,el) + call plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me,ip,el) case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,temperature(ho)%p(tme),instance,me) + call plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,temperature(ho)%p(tme),instance,me) + call plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) end select plasticityType @@ -700,52 +694,49 @@ end subroutine constitutive_plastic_LpAndItsTangents !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the rate of change of microstructure !-------------------------------------------------------------------------------------------------- -function mech_collectDotState(subdt,co,ip,el,ph,of) result(broken) +function mech_collectDotState(subdt,co,ip,el,ph,me) result(broken) integer, intent(in) :: & - co, & !< component-ID of integration point + co, & !< component-ID of integration point ip, & !< integration point el, & !< element ph, & - of + me real(pReal), intent(in) :: & subdt !< timestep real(pReal), dimension(3,3) :: & Mp integer :: & - ho, & !< homogenization - tme, & !< thermal member position instance logical :: broken - ho = material_homogenizationAt(el) - tme = material_homogenizationMemberAt(ip,el) + instance = phase_plasticityInstance(ph) - Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,of)),& - constitutive_mech_Fi(ph)%data(1:3,1:3,of)),constitutive_mech_S(ph)%data(1:3,1:3,of)) + Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,me)),& + constitutive_mech_Fi(ph)%data(1:3,1:3,me)),constitutive_mech_S(ph)%data(1:3,1:3,me)) plasticityType: select case (phase_plasticity(ph)) case (PLASTICITY_ISOTROPIC_ID) plasticityType - call plastic_isotropic_dotState(Mp,instance,of) + call plastic_isotropic_dotState(Mp,instance,me) case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType - call plastic_phenopowerlaw_dotState(Mp,instance,of) + call plastic_phenopowerlaw_dotState(Mp,instance,me) case (PLASTICITY_KINEHARDENING_ID) plasticityType - call plastic_kinehardening_dotState(Mp,instance,of) + call plastic_kinehardening_dotState(Mp,instance,me) case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_dotState(Mp,temperature(ho)%p(tme),instance,of) + call plastic_dislotwin_dotState(Mp,thermal_T(ph,me),instance,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_disloTungsten_dotState(Mp,temperature(ho)%p(tme),instance,of) + call plastic_disloTungsten_dotState(Mp,thermal_T(ph,me),instance,me) case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_dotState(Mp,temperature(ho)%p(tme),subdt,instance,of,ip,el) + call plastic_nonlocal_dotState(Mp,thermal_T(ph,me),subdt,instance,me,ip,el) end select plasticityType - broken = any(IEEE_is_NaN(plasticState(ph)%dotState(:,of))) + broken = any(IEEE_is_NaN(plasticState(ph)%dotState(:,me))) end function mech_collectDotState diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 29d171062..ba98e2af7 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -258,11 +258,13 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE !$OMP END PARALLEL DO if (.not. terminallyIll ) then - !$OMP PARALLEL DO PRIVATE(ho,ph) + !$OMP PARALLEL DO PRIVATE(ho,ph,ce) do el = FEsolving_execElem(1),FEsolving_execElem(2) if (terminallyIll) continue ho = material_homogenizationAt(el) do ip = FEsolving_execIP(1),FEsolving_execIP(2) + ce = (el-1)*discretization_nIPs + ip + call thermal_partition(homogenization_T(ce),ip,el) do co = 1, homogenization_Nconstituents(ho) ph = material_phaseAt(co,el) call constitutive_thermal_initializeRestorationPoints(ph,material_phaseMemberAt(co,ip,el)) From 7c159366d5414c83e62e95cc0939fbc6b89a98cb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 10:16:56 +0100 Subject: [PATCH 111/352] simplified --- src/homogenization.f90 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index ba98e2af7..7232608b3 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -170,8 +170,8 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE logical, dimension(2) :: & doneAndHappy - - !$OMP PARALLEL DO PRIVATE(ce,me,ho,myNgrains,NiterationMPstate,subFrac,converged,subStep,doneAndHappy) + !$OMP PARALLEL + !$OMP DO PRIVATE(ce,me,ho,myNgrains,NiterationMPstate,subFrac,converged,subStep,doneAndHappy) do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) myNgrains = homogenization_Nconstituents(ho) @@ -255,10 +255,10 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE enddo cutBackLooping enddo enddo - !$OMP END PARALLEL DO + !$OMP END DO if (.not. terminallyIll ) then - !$OMP PARALLEL DO PRIVATE(ho,ph,ce) + !$OMP DO PRIVATE(ho,ph,ce) do el = FEsolving_execElem(1),FEsolving_execElem(2) if (terminallyIll) continue ho = material_homogenizationAt(el) @@ -276,9 +276,9 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE enddo enddo enddo - !$OMP END PARALLEL DO + !$OMP END DO - !$OMP PARALLEL DO PRIVATE(ho) + !$OMP DO PRIVATE(ho) elementLooping3: do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) IpLooping3: do ip = FEsolving_execIP(1),FEsolving_execIP(2) @@ -288,10 +288,11 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE call mech_homogenize(dt,ip,el) enddo IpLooping3 enddo elementLooping3 - !$OMP END PARALLEL DO + !$OMP END DO else print'(/,a,/)', ' << HOMOG >> Material Point terminally ill' endif + !$OMP END PARALLEL end subroutine materialpoint_stressAndItsTangent From 9b698e78c180076bfc03bda0a4f95237d6a0f038 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 12:35:47 +0100 Subject: [PATCH 112/352] standard name --- src/grid/grid_thermal_spectral.f90 | 104 ++++++++++++++--------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 9d804ec56..c0a1b0f40 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -19,7 +19,7 @@ module grid_thermal_spectral use YAML_types use config use material - + implicit none private @@ -45,11 +45,11 @@ module grid_thermal_spectral T_stagInc !< field of staggered temperature !-------------------------------------------------------------------------------------------------- -! reference diffusion tensor, mobility etc. +! reference diffusion tensor, mobility etc. integer :: totalIter = 0 !< total iteration in current increment real(pReal), dimension(3,3) :: K_ref real(pReal) :: mu_ref - + public :: & grid_thermal_spectral_init, & grid_thermal_spectral_solution, & @@ -63,8 +63,8 @@ contains !-------------------------------------------------------------------------------------------------- subroutine grid_thermal_spectral_init - PetscInt, dimension(0:worldsize-1) :: localK - integer :: i, j, k, cell + PetscInt, dimension(0:worldsize-1) :: localK + integer :: i, j, k, ce DM :: thermal_grid PetscScalar, dimension(:,:,:), pointer :: x_scal PetscErrorCode :: ierr @@ -93,11 +93,11 @@ subroutine grid_thermal_spectral_init CHKERRQ(ierr) call PetscOptionsInsertString(PETSC_NULL_OPTIONS,num_grid%get_asString('petsc_options',defaultVal=''),ierr) CHKERRQ(ierr) - + !-------------------------------------------------------------------------------------------------- ! initialize solver specific parts of PETSc call SNESCreate(PETSC_COMM_WORLD,thermal_snes,ierr); CHKERRQ(ierr) - call SNESSetOptionsPrefix(thermal_snes,'thermal_',ierr);CHKERRQ(ierr) + call SNESSetOptionsPrefix(thermal_snes,'thermal_',ierr);CHKERRQ(ierr) localK = 0 localK(worldrank) = grid3 call MPI_Allreduce(MPI_IN_PLACE,localK,worldsize,MPI_INTEGER,MPI_SUM,PETSC_COMM_WORLD,ierr) @@ -115,23 +115,23 @@ subroutine grid_thermal_spectral_init call DMsetUp(thermal_grid,ierr); CHKERRQ(ierr) call DMCreateGlobalVector(thermal_grid,solution_vec,ierr); CHKERRQ(ierr) ! global solution vector (grid x 1, i.e. every def grad tensor) call DMDASNESSetFunctionLocal(thermal_grid,INSERT_VALUES,formResidual,PETSC_NULL_SNES,ierr) ! residual vector of same shape as solution vector - CHKERRQ(ierr) + CHKERRQ(ierr) call SNESSetFromOptions(thermal_snes,ierr); CHKERRQ(ierr) ! pull it all together with additional CLI arguments !-------------------------------------------------------------------------------------------------- -! init fields +! init fields call DMDAGetCorners(thermal_grid,xstart,ystart,zstart,xend,yend,zend,ierr) CHKERRQ(ierr) xend = xstart + xend - 1 yend = ystart + yend - 1 - zend = zstart + zend - 1 + zend = zstart + zend - 1 allocate(T_current(grid(1),grid(2),grid3), source=0.0_pReal) allocate(T_lastInc(grid(1),grid(2),grid3), source=0.0_pReal) allocate(T_stagInc(grid(1),grid(2),grid3), source=0.0_pReal) - cell = 0 + ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 - T_current(i,j,k) = temperature(material_homogenizationAt(cell))%p(material_homogenizationMemberAt(1,cell)) + ce = ce + 1 + T_current(i,j,k) = temperature(material_homogenizationAt(ce))%p(material_homogenizationMemberAt(1,ce)) T_lastInc(i,j,k) = T_current(i,j,k) T_stagInc(i,j,k) = T_current(i,j,k) enddo; enddo; enddo @@ -143,26 +143,26 @@ subroutine grid_thermal_spectral_init end subroutine grid_thermal_spectral_init - + !-------------------------------------------------------------------------------------------------- !> @brief solution for the spectral thermal scheme with internal iterations !-------------------------------------------------------------------------------------------------- function grid_thermal_spectral_solution(timeinc) result(solution) - + real(pReal), intent(in) :: & timeinc !< increment in time for current solution - integer :: i, j, k, cell + integer :: i, j, k, ce type(tSolutionState) :: solution PetscInt :: devNull PetscReal :: T_min, T_max, stagNorm, solnNorm - PetscErrorCode :: ierr + PetscErrorCode :: ierr SNESConvergedReason :: reason solution%converged =.false. - + !-------------------------------------------------------------------------------------------------- -! set module wide availabe data +! set module wide availabe data params%timeinc = timeinc call SNESSolve(thermal_snes,PETSC_NULL_VEC,solution_vec,ierr); CHKERRQ(ierr) @@ -183,13 +183,13 @@ function grid_thermal_spectral_solution(timeinc) result(solution) solution%stagConverged = stagNorm < max(num%eps_thermal_atol, num%eps_thermal_rtol*solnNorm) !-------------------------------------------------------------------------------------------------- -! updating thermal state - cell = 0 +! updating thermal state + ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 + ce = ce + 1 call thermal_conduction_putTemperatureAndItsRate(T_current(i,j,k), & (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & - 1,cell) + 1,ce) enddo; enddo; enddo call VecMin(solution_vec,devNull,T_min,ierr); CHKERRQ(ierr) @@ -198,7 +198,7 @@ function grid_thermal_spectral_solution(timeinc) result(solution) print'(/,a)', ' ... thermal conduction converged ..................................' print'(/,a,f8.4,2x,f8.4,2x,f8.4)', ' Minimum|Maximum|Delta Temperature / K = ', T_min, T_max, stagNorm print'(/,a)', ' ===========================================================================' - flush(IO_STDOUT) + flush(IO_STDOUT) end function grid_thermal_spectral_solution @@ -207,36 +207,36 @@ end function grid_thermal_spectral_solution !> @brief forwarding routine !-------------------------------------------------------------------------------------------------- subroutine grid_thermal_spectral_forward(cutBack) - + logical, intent(in) :: cutBack - integer :: i, j, k, cell + integer :: i, j, k, ce DM :: dm_local PetscScalar, dimension(:,:,:), pointer :: x_scal PetscErrorCode :: ierr - - if (cutBack) then + + if (cutBack) then T_current = T_lastInc T_stagInc = T_lastInc !-------------------------------------------------------------------------------------------------- -! reverting thermal field state - cell = 0 +! reverting thermal field state + ce = 0 call SNESGetDM(thermal_snes,dm_local,ierr); CHKERRQ(ierr) call DMDAVecGetArrayF90(dm_local,solution_vec,x_scal,ierr); CHKERRQ(ierr) !< get the data out of PETSc to work with x_scal(xstart:xend,ystart:yend,zstart:zend) = T_current call DMDAVecRestoreArrayF90(dm_local,solution_vec,x_scal,ierr); CHKERRQ(ierr) do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 + ce = ce + 1 call thermal_conduction_putTemperatureAndItsRate(T_current(i,j,k), & (T_current(i,j,k) - & T_lastInc(i,j,k))/params%timeinc, & - 1,cell) + 1,ce) enddo; enddo; enddo else T_lastInc = T_current call updateReference endif - + end subroutine grid_thermal_spectral_forward @@ -244,7 +244,7 @@ end subroutine grid_thermal_spectral_forward !> @brief forms the spectral thermal residual vector !-------------------------------------------------------------------------------------------------- subroutine formResidual(in,x_scal,f_scal,dummy,ierr) - + DMDALocalInfo, dimension(DMDA_LOCAL_INFO_SIZE) :: & in PetscScalar, dimension( & @@ -255,33 +255,33 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) f_scal PetscObject :: dummy PetscErrorCode :: ierr - integer :: i, j, k, cell + integer :: i, j, k, ce real(pReal) :: Tdot - T_current = x_scal + T_current = x_scal !-------------------------------------------------------------------------------------------------- ! evaluate polarization field scalarField_real = 0.0_pReal - scalarField_real(1:grid(1),1:grid(2),1:grid3) = T_current + scalarField_real(1:grid(1),1:grid(2),1:grid3) = T_current call utilities_FFTscalarForward call utilities_fourierScalarGradient !< calculate gradient of temperature field call utilities_FFTvectorBackward - cell = 0 + ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 - vectorField_real(1:3,i,j,k) = matmul(thermal_conduction_getConductivity(1,cell) - K_ref, & + ce = ce + 1 + vectorField_real(1:3,i,j,k) = matmul(thermal_conduction_getConductivity(1,ce) - K_ref, & vectorField_real(1:3,i,j,k)) enddo; enddo; enddo call utilities_FFTvectorForward call utilities_fourierVectorDivergence !< calculate temperature divergence in fourier field call utilities_FFTscalarBackward - cell = 0 + ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 - call thermal_conduction_getSource(Tdot, T_current(i,j,k), 1, cell) + ce = ce + 1 + call thermal_conduction_getSource(Tdot, T_current(i,j,k), 1, ce) scalarField_real(i,j,k) = params%timeinc*(scalarField_real(i,j,k) + Tdot) & - + thermal_conduction_getMassDensity (1,cell)* & - thermal_conduction_getSpecificHeat(1,cell)*(T_lastInc(i,j,k) - & + + thermal_conduction_getMassDensity (1,ce)* & + thermal_conduction_getSpecificHeat(1,ce)*(T_lastInc(i,j,k) - & T_current(i,j,k))& + mu_ref*T_current(i,j,k) enddo; enddo; enddo @@ -291,7 +291,7 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) call utilities_FFTscalarForward call utilities_fourierGreenConvolution(K_ref, mu_ref, params%timeinc) call utilities_FFTscalarBackward - + !-------------------------------------------------------------------------------------------------- ! constructing residual f_scal = T_current - scalarField_real(1:grid(1),1:grid(2),1:grid3) @@ -304,15 +304,15 @@ end subroutine formResidual !-------------------------------------------------------------------------------------------------- subroutine updateReference - integer :: i,j,k,cell,ierr - - cell = 0 + integer :: i,j,k,ce,ierr + + ce = 0 K_ref = 0.0_pReal mu_ref = 0.0_pReal do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 - K_ref = K_ref + thermal_conduction_getConductivity(1,cell) - mu_ref = mu_ref + thermal_conduction_getMassDensity(1,cell)* thermal_conduction_getSpecificHeat(1,cell) + ce = ce + 1 + K_ref = K_ref + thermal_conduction_getConductivity(1,ce) + mu_ref = mu_ref + thermal_conduction_getMassDensity(1,ce)* thermal_conduction_getSpecificHeat(1,ce) enddo; enddo; enddo K_ref = K_ref*wgt call MPI_Allreduce(MPI_IN_PLACE,K_ref,9,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD,ierr) From 6b452a73bb286ff7a6506bceabd10256aae5c9f6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 12:45:28 +0100 Subject: [PATCH 113/352] not needed --- src/constitutive.f90 | 4 +--- src/constitutive_thermal.f90 | 4 +--- src/grid/grid_thermal_spectral.f90 | 2 +- src/thermal_conduction.f90 | 6 ++---- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 2ec947f2b..6a73cc071 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -274,12 +274,10 @@ module constitutive dPhiDot_dPhi end subroutine constitutive_damage_getRateAndItsTangents - module subroutine constitutive_thermal_getRate(TDot, T,ip,el) + module subroutine constitutive_thermal_getRate(TDot, ip,el) integer, intent(in) :: & ip, & !< integration point number el !< element number - real(pReal), intent(in) :: & - T real(pReal), intent(out) :: & TDot end subroutine constitutive_thermal_getRate diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index cabd03c1e..8a18f030e 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -127,13 +127,11 @@ end subroutine thermal_init !---------------------------------------------------------------------------------------------- !< @brief calculates thermal dissipation rate !---------------------------------------------------------------------------------------------- -module subroutine constitutive_thermal_getRate(TDot, T, ip, el) +module subroutine constitutive_thermal_getRate(TDot, ip, el) integer, intent(in) :: & ip, & !< integration point number el !< element number - real(pReal), intent(in) :: & - T !< plastic velocity gradient real(pReal), intent(out) :: & TDot diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index c0a1b0f40..9ed0b24c1 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -278,7 +278,7 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) ce = ce + 1 - call thermal_conduction_getSource(Tdot, T_current(i,j,k), 1, ce) + call thermal_conduction_getSource(Tdot, 1,ce) scalarField_real(i,j,k) = params%timeinc*(scalarField_real(i,j,k) + Tdot) & + thermal_conduction_getMassDensity (1,ce)* & thermal_conduction_getSpecificHeat(1,ce)*(T_lastInc(i,j,k) - & diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index 79fe0d6cd..1711c5512 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -91,13 +91,11 @@ end subroutine thermal_conduction_init !-------------------------------------------------------------------------------------------------- !> @brief return heat generation rate !-------------------------------------------------------------------------------------------------- -subroutine thermal_conduction_getSource(Tdot, T,ip,el) +subroutine thermal_conduction_getSource(Tdot, ip,el) integer, intent(in) :: & ip, & !< integration point number el !< element number - real(pReal), intent(in) :: & - T real(pReal), intent(out) :: & Tdot @@ -105,7 +103,7 @@ subroutine thermal_conduction_getSource(Tdot, T,ip,el) homog homog = material_homogenizationAt(el) - call constitutive_thermal_getRate(TDot, T,ip,el) + call constitutive_thermal_getRate(TDot, ip,el) Tdot = Tdot/real(homogenization_Nconstituents(homog),pReal) From ca5409f0f166d805420022c88634500f78caeeb8 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 13:20:17 +0100 Subject: [PATCH 114/352] similar structure as for mechanics --- src/homogenization.f90 | 3 ++- src/homogenization_thermal.f90 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 7232608b3..76b93b163 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -28,7 +28,8 @@ module homogenization !-------------------------------------------------------------------------------------------------- ! General variables for the homogenization at a material point real(pReal), dimension(:), allocatable, public :: & - homogenization_T + homogenization_T, & + homogenization_dot_T real(pReal), dimension(:,:,:), allocatable, public :: & homogenization_F0, & !< def grad of IP at start of FE increment homogenization_F !< def grad of IP to be reached at end of FE increment diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index f181d97fa..4dbece13f 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -15,7 +15,7 @@ module subroutine thermal_init() print'(/,a)', ' <<<+- homogenization_thermal init -+>>>' allocate(homogenization_T(discretization_nIPs*discretization_Nelems)) - + allocate(homogenization_dot_T(discretization_nIPs*discretization_Nelems)) end subroutine thermal_init From e9a8badde8c9c4102a35f1c70ae7baed2ba2abb9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 14:38:12 +0100 Subject: [PATCH 115/352] mapping per cell --- src/material.f90 | 50 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/src/material.f90 b/src/material.f90 index 16116ca91..e165bd466 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -51,11 +51,15 @@ module material thermal_initialT !< initial temperature per each homogenization integer, dimension(:), allocatable, public, protected :: & ! (elem) - material_homogenizationAt !< homogenization ID of each element + material_homogenizationAt, & !< homogenization ID of each element + material_homogenizationAt2, & !< per cell + material_homogenizationMemberAt2 !< cell integer, dimension(:,:), allocatable, public, protected :: & ! (ip,elem) material_homogenizationMemberAt !< position of the element within its homogenization instance integer, dimension(:,:), allocatable, public, protected :: & ! (constituent,elem) - material_phaseAt !< phase ID of each element + material_phaseAt, & !< phase ID of each element + material_phaseAt2, & !< per constituent,cell + material_phaseMemberAt2 !< per constituent, cell integer, dimension(:,:,:), allocatable, public, protected :: & ! (constituent,IP,elem) material_phaseMemberAt !< position of the element within its phase instance @@ -215,8 +219,8 @@ subroutine material_parseMaterial real(pReal) :: & frac integer :: & - e, i, c, & - h + el, ip, co, & + h, ce materials => config_material%get('material') phases => config_material%get('phase') @@ -241,29 +245,41 @@ subroutine material_parseMaterial allocate(material_phaseAt(homogenization_maxNconstituents,discretization_Nelems),source=0) allocate(material_phaseMemberAt(homogenization_maxNconstituents,discretization_nIPs,discretization_Nelems),source=0) + + allocate(material_homogenizationAt2(discretization_nIPs*discretization_Nelems),source=0) + allocate(material_homogenizationMemberAt2(discretization_nIPs*discretization_Nelems),source=0) + allocate(material_phaseAt2(homogenization_maxNconstituents,discretization_nIPs*discretization_Nelems),source=0) + allocate(material_phaseMemberAt2(homogenization_maxNconstituents,discretization_nIPs*discretization_Nelems),source=0) + allocate(material_orientation0(homogenization_maxNconstituents,discretization_nIPs,discretization_Nelems)) - do e = 1, discretization_Nelems - material => materials%get(discretization_materialAt(e)) + do el = 1, discretization_Nelems + material => materials%get(discretization_materialAt(el)) constituents => material%get('constituents') - material_homogenizationAt(e) = homogenizations%getIndex(material%get_asString('homogenization')) - do i = 1, discretization_nIPs - counterHomogenization(material_homogenizationAt(e)) = counterHomogenization(material_homogenizationAt(e)) + 1 - material_homogenizationMemberAt(i,e) = counterHomogenization(material_homogenizationAt(e)) + material_homogenizationAt(el) = homogenizations%getIndex(material%get_asString('homogenization')) + do ip = 1, discretization_nIPs + ce = (el-1)*discretization_nIPs + ip + counterHomogenization(material_homogenizationAt(el)) = counterHomogenization(material_homogenizationAt(el)) + 1 + material_homogenizationMemberAt(ip,el) = counterHomogenization(material_homogenizationAt(el)) + material_homogenizationAt2(ce) = material_homogenizationAt(el) + material_homogenizationMemberAt2(ce) = material_homogenizationMemberAt(ip,el) enddo frac = 0.0_pReal - do c = 1, constituents%length - constituent => constituents%get(c) + do co = 1, constituents%length + constituent => constituents%get(co) frac = frac + constituent%get_asFloat('fraction') - material_phaseAt(c,e) = phases%getIndex(constituent%get_asString('phase')) - do i = 1, discretization_nIPs - counterPhase(material_phaseAt(c,e)) = counterPhase(material_phaseAt(c,e)) + 1 - material_phaseMemberAt(c,i,e) = counterPhase(material_phaseAt(c,e)) + material_phaseAt(co,el) = phases%getIndex(constituent%get_asString('phase')) + do ip = 1, discretization_nIPs + ce = (el-1)*discretization_nIPs + ip + counterPhase(material_phaseAt(co,el)) = counterPhase(material_phaseAt(co,el)) + 1 + material_phaseMemberAt(co,ip,el) = counterPhase(material_phaseAt(co,el)) - call material_orientation0(c,i,e)%fromQuaternion(constituent%get_asFloats('O',requiredSize=4)) ! should be done in crystallite + material_phaseAt2(co,ce) = material_phaseAt(co,el) + material_phaseMemberAt2(co,ce) = material_phaseMemberAt(co,ip,el) + call material_orientation0(co,ip,el)%fromQuaternion(constituent%get_asFloats('O',requiredSize=4)) ! should be done in crystallite enddo enddo From 833d25420bfde9a1f30a1f19965916d948f18c70 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 14:52:52 +0100 Subject: [PATCH 116/352] using new mapping discrimination of integration point and element makes only sense for the solver --- src/constitutive.f90 | 4 ++-- src/constitutive_thermal.f90 | 6 +++--- src/homogenization.f90 | 8 +++----- src/homogenization_thermal.f90 | 11 ++++++----- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 6a73cc071..29796cfbc 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -199,9 +199,9 @@ module constitutive integer, intent(in) :: co, ip, el end subroutine constitutive_mech_setF - module subroutine constitutive_thermal_setT(T,co,ip,el) + module subroutine constitutive_thermal_setT(T,co,ce) real(pReal), intent(in) :: T - integer, intent(in) :: co, ip, el + integer, intent(in) :: co, ce end subroutine constitutive_thermal_setT ! == cleaned:end =================================================================================== diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 8a18f030e..9007ef729 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -284,13 +284,13 @@ end function thermal_T !---------------------------------------------------------------------------------------------- !< @brief Set temperature !---------------------------------------------------------------------------------------------- -module subroutine constitutive_thermal_setT(T,co,ip,el) +module subroutine constitutive_thermal_setT(T,co,ce) real(pReal), intent(in) :: T - integer, intent(in) :: co, ip, el + integer, intent(in) :: ce, co - current(material_phaseAt(co,el))%T(material_phaseMemberAt(co,ip,el)) = T + current(material_phaseAt2(co,ce))%T(material_phaseMemberAt2(co,ce)) = T end subroutine constitutive_thermal_setT diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 76b93b163..7039febac 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -70,11 +70,9 @@ module homogenization el !< element number end subroutine mech_partition - module subroutine thermal_partition(T,ip,el) + module subroutine thermal_partition(T,ce) real(pReal), intent(in) :: T - integer, intent(in) :: & - ip, & !< integration point - el !< element number + integer, intent(in) :: ce end subroutine thermal_partition module subroutine mech_homogenize(dt,ip,el) @@ -265,7 +263,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE ho = material_homogenizationAt(el) do ip = FEsolving_execIP(1),FEsolving_execIP(2) ce = (el-1)*discretization_nIPs + ip - call thermal_partition(homogenization_T(ce),ip,el) + call thermal_partition(homogenization_T(ce),ce) do co = 1, homogenization_Nconstituents(ho) ph = material_phaseAt(co,el) call constitutive_thermal_initializeRestorationPoints(ph,material_phaseMemberAt(co,ip,el)) diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index 4dbece13f..5b67bcfbf 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -23,15 +23,16 @@ end subroutine thermal_init !-------------------------------------------------------------------------------------------------- !> @brief Partition T onto the individual constituents. !-------------------------------------------------------------------------------------------------- -module subroutine thermal_partition(T,ip,el) +module subroutine thermal_partition(T,ce) real(pReal), intent(in) :: T - integer, intent(in) :: & - ip, & !< integration point - el !< element number + integer, intent(in) :: ce + integer :: co - call constitutive_thermal_setT(T,1,ip,el) + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) + call constitutive_thermal_setT(T,co,ce) + enddo end subroutine thermal_partition From 9a7017484dfd14c22a5e0004f102cc75892c168a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 15:10:43 +0100 Subject: [PATCH 117/352] wrapper for homogenization of temperature rate --- src/homogenization.f90 | 5 +++++ src/homogenization_thermal.f90 | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 7039febac..a63487b6f 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -75,6 +75,10 @@ module homogenization integer, intent(in) :: ce end subroutine thermal_partition + module subroutine thermal_homogenize(ip,el) + integer, intent(in) :: ip,el + end subroutine thermal_homogenize + module subroutine mech_homogenize(dt,ip,el) real(pReal), intent(in) :: dt integer, intent(in) :: & @@ -272,6 +276,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE print*, ' Integration point ', ip,' at element ', el, ' terminally ill' terminallyIll = .true. ! ...and kills all others endif + call thermal_homogenize(ip,el) enddo enddo enddo diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index 5b67bcfbf..de91a98d6 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -21,7 +21,7 @@ end subroutine thermal_init !-------------------------------------------------------------------------------------------------- -!> @brief Partition T onto the individual constituents. +!> @brief Partition temperature onto the individual constituents. !-------------------------------------------------------------------------------------------------- module subroutine thermal_partition(T,ce) @@ -37,4 +37,16 @@ module subroutine thermal_partition(T,ce) end subroutine thermal_partition +!-------------------------------------------------------------------------------------------------- +!> @brief Homogenize temperature rates +!-------------------------------------------------------------------------------------------------- +module subroutine thermal_homogenize(ip,el) + + integer, intent(in) :: ip,el + + call constitutive_thermal_getRate(homogenization_dot_T((el-1)*discretization_nIPs+ip), ip,el) + +end subroutine thermal_homogenize + + end submodule homogenization_thermal From d2ae859b1c982bdeca73d3fdf75fa9c9e5e1c379 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 15:19:36 +0100 Subject: [PATCH 118/352] use new structure --- src/DAMASK_marc.f90 | 2 +- src/grid/grid_thermal_spectral.f90 | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DAMASK_marc.f90 b/src/DAMASK_marc.f90 index 0f9d37ddb..9464595b1 100644 --- a/src/DAMASK_marc.f90 +++ b/src/DAMASK_marc.f90 @@ -365,7 +365,7 @@ subroutine flux(f,ts,n,time) f f(2) = 0.0_pReal - call thermal_conduction_getSource(f(1), ts(3), n(3),mesh_FEM2DAMASK_elem(n(1))) + call thermal_conduction_getSource(f(1), n(3),mesh_FEM2DAMASK_elem(n(1))) end subroutine flux diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 9ed0b24c1..d164f11e7 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -16,6 +16,7 @@ module grid_thermal_spectral use spectral_utilities use discretization_grid use thermal_conduction + use homogenization use YAML_types use config use material @@ -190,6 +191,7 @@ function grid_thermal_spectral_solution(timeinc) result(solution) call thermal_conduction_putTemperatureAndItsRate(T_current(i,j,k), & (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & 1,ce) + homogenization_T(ce) = T_current(i,j,k) enddo; enddo; enddo call VecMin(solution_vec,devNull,T_min,ierr); CHKERRQ(ierr) @@ -231,6 +233,7 @@ subroutine grid_thermal_spectral_forward(cutBack) (T_current(i,j,k) - & T_lastInc(i,j,k))/params%timeinc, & 1,ce) + homogenization_T(ce) = T_current(i,j,k) enddo; enddo; enddo else T_lastInc = T_current From a2b5178b4535028e9aafd9c9f3cefe9954a33ea2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 21:56:19 +0100 Subject: [PATCH 119/352] polishing --- PRIVATE | 2 +- src/DAMASK_interface.f90 | 68 +++++++++++++++++++++++----------------- src/grid/DAMASK_grid.f90 | 4 +-- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/PRIVATE b/PRIVATE index b1a31a79c..047e5f361 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit b1a31a79cc90d458494068a96cfd3e9497aa330c +Subproject commit 047e5f3613e284a5ceb1f8b07119e8231bb94d4d diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index ffb8a0442..ab64dcf01 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -386,24 +386,14 @@ end function makeRelativePath subroutine catchSIGTERM(signal) bind(C) integer(C_INT), value :: signal + + + print'(a,i0)', ' received signal ',signal call interface_setSIGTERM(.true.) - print'(a,i0,a)', ' received signal ',signal, ', set SIGTERM=TRUE' - end subroutine catchSIGTERM -!-------------------------------------------------------------------------------------------------- -!> @brief Set global variable interface_SIGTERM. -!-------------------------------------------------------------------------------------------------- -subroutine interface_setSIGTERM(state) - - logical, intent(in) :: state - interface_SIGTERM = state - -end subroutine interface_setSIGTERM - - !-------------------------------------------------------------------------------------------------- !> @brief Set global variable interface_SIGUSR1 to .true. !> @details This function can be registered to catch signals send to the executable. @@ -411,24 +401,14 @@ end subroutine interface_setSIGTERM subroutine catchSIGUSR1(signal) bind(C) integer(C_INT), value :: signal + + + print'(a,i0)', ' received signal ',signal call interface_setSIGUSR1(.true.) - print'(a,i0,a)', ' received signal ',signal, ', set SIGUSR1=TRUE' - end subroutine catchSIGUSR1 -!-------------------------------------------------------------------------------------------------- -!> @brief Set global variable interface_SIGUSR. -!-------------------------------------------------------------------------------------------------- -subroutine interface_setSIGUSR1(state) - - logical, intent(in) :: state - interface_SIGUSR1 = state - -end subroutine interface_setSIGUSR1 - - !-------------------------------------------------------------------------------------------------- !> @brief Set global variable interface_SIGUSR2 to .true. !> @details This function can be registered to catch signals send to the executable. @@ -436,20 +416,52 @@ end subroutine interface_setSIGUSR1 subroutine catchSIGUSR2(signal) bind(C) integer(C_INT), value :: signal + + + print'(a,i0,a)', ' received signal ',signal call interface_setSIGUSR2(.true.) - print'(a,i0,a)', ' received signal ',signal, ', set SIGUSR2=TRUE' - end subroutine catchSIGUSR2 +!-------------------------------------------------------------------------------------------------- +!> @brief Set global variable interface_SIGTERM. +!-------------------------------------------------------------------------------------------------- +subroutine interface_setSIGTERM(state) + + logical, intent(in) :: state + + + interface_SIGTERM = state + print*, 'set SIGTERM to',state + +end subroutine interface_setSIGTERM + + +!-------------------------------------------------------------------------------------------------- +!> @brief Set global variable interface_SIGUSR. +!-------------------------------------------------------------------------------------------------- +subroutine interface_setSIGUSR1(state) + + logical, intent(in) :: state + + + interface_SIGUSR1 = state + print*, 'set SIGUSR1 to',state + +end subroutine interface_setSIGUSR1 + + !-------------------------------------------------------------------------------------------------- !> @brief Set global variable interface_SIGUSR2. !-------------------------------------------------------------------------------------------------- subroutine interface_setSIGUSR2(state) logical, intent(in) :: state + + interface_SIGUSR2 = state + print*, 'set SIGUSR2 to',state end subroutine interface_setSIGUSR2 diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 850ccf9e8..02d7b4cc3 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -453,19 +453,19 @@ program DAMASK_grid call MPI_Allreduce(interface_SIGUSR1,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) if (ierr /= 0) error stop 'MPI error' - call interface_setSIGUSR1(.false.) if (mod(inc,loadCases(l)%f_out) == 0 .or. signal) then print'(1/,a)', ' ... writing results to file ......................................' flush(IO_STDOUT) call CPFEM_results(totalIncsCounter,time) endif + if(signal) call interface_setSIGUSR1(.false.) call MPI_Allreduce(interface_SIGUSR2,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) if (ierr /= 0) error stop 'MPI error' - call interface_setSIGUSR2(.false.) if (mod(inc,loadCases(l)%f_restart) == 0 .or. signal) then call mech_restartWrite call CPFEM_restartWrite endif + if(signal) call interface_setSIGUSR2(.false.) call MPI_Allreduce(interface_SIGTERM,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) if (ierr /= 0) error stop 'MPI error' if (signal) exit loadCaseLooping From 04f5d8ce9a5948fa7276a2a928c6df490e06540d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 23:59:19 +0100 Subject: [PATCH 120/352] updated test still unclear why serial signal tests are problematic --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 047e5f361..a12312c47 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 047e5f3613e284a5ceb1f8b07119e8231bb94d4d +Subproject commit a12312c475159b6490709c5558f8363806b174be From 35f3a914622e08e606968974e3bf778f439e7426 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 18 Jan 2021 07:18:31 +0100 Subject: [PATCH 121/352] fine tuning test for signal handling --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index a12312c47..b82bf9fe6 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit a12312c475159b6490709c5558f8363806b174be +Subproject commit b82bf9fe6412165186a01d58f9c9652be4b55db4 From bcbf63b5fc752bad224bd0bea6a805fdb345f8c2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 18 Jan 2021 12:49:25 +0100 Subject: [PATCH 122/352] improved test --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index b82bf9fe6..99454fe2d 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit b82bf9fe6412165186a01d58f9c9652be4b55db4 +Subproject commit 99454fe2d3d0f2c3d0ec8c53b6cdd4a9504c1664 From 7a7c0c2dfb160cebef943e07729c36732072fb74 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 18 Jan 2021 15:18:27 +0100 Subject: [PATCH 123/352] polished PRIVATE --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 9e8011876..3ab1053b8 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 9e8011876b16896a18902737790eba8018e94f85 +Subproject commit 3ab1053b8c83248dc8654a22a3caea815c0813db From f2c233961b957fa2288f2b791b7fce8ac85b23d7 Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 18 Jan 2021 19:32:20 +0100 Subject: [PATCH 124/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-302-g5b9a2d7bf --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5a4014717..b8f3f3020 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-292-g589178668 +v3.0.0-alpha2-302-g5b9a2d7bf From c7f9c0dc301f330dc90e5af75382b11befc1d757 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 19 Jan 2021 00:49:09 +0100 Subject: [PATCH 125/352] again improving the tests for signal handling --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 17121848b..72661176e 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 17121848b9590fcc8ebbeb2d7c76794843ba2bdf +Subproject commit 72661176e9055cf6ec106bb61c50482c5bc78de8 From 494ed244a08c510e315856afd00078c5df68487e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 19 Jan 2021 10:14:34 +0100 Subject: [PATCH 126/352] consistent access via (ph)ase and phase(me)mber --- src/constitutive.f90 | 4 ++-- src/constitutive_damage.f90 | 3 ++- src/constitutive_mech.f90 | 31 ++++++++++---------------- src/constitutive_plastic_dislotwin.f90 | 27 ++++++++++------------ src/homogenization_mech_RGC.f90 | 5 ++++- 5 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 29796cfbc..1564e610b 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -229,8 +229,8 @@ module constitutive logical :: converged_ end function crystallite_stress - module function constitutive_homogenizedC(co,ip,el) result(C) - integer, intent(in) :: co, ip, el + module function constitutive_homogenizedC(ph,me) result(C) + integer, intent(in) :: ph, me real(pReal), dimension(6,6) :: C end function constitutive_homogenizedC diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index 8c9104946..4fa7a9627 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -436,7 +436,8 @@ function constitutive_damage_deltaState(Fe, co, ip, el, ph, of) result(broken) sourceType: select case (phase_source(so,ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType - call source_damage_isoBrittle_deltaState (constitutive_homogenizedC(co,ip,el), Fe, & + call source_damage_isoBrittle_deltaState (constitutive_homogenizedC(material_phaseAt(co,el), & + material_phaseMemberAt(co,ip,el)), Fe, & co, ip, el) broken = any(IEEE_is_NaN(damageState(ph)%p(so)%deltaState(:,of))) if(.not. broken) then diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 50afe2e87..cd1dedb61 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -307,13 +307,9 @@ submodule(constitutive) constitutive_mech character(len=*), intent(in) :: group end subroutine plastic_nonlocal_results - module function plastic_dislotwin_homogenizedC(co,ip,el) result(homogenizedC) - real(pReal), dimension(6,6) :: & - homogenizedC - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + module function plastic_dislotwin_homogenizedC(ph,me) result(homogenizedC) + real(pReal), dimension(6,6) :: homogenizedC + integer, intent(in) :: ph,me end function plastic_dislotwin_homogenizedC @@ -559,16 +555,16 @@ subroutine constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & real(pReal), intent(out), dimension(3,3,3,3) :: & dS_dFe, & !< derivative of 2nd P-K stress with respect to elastic deformation gradient dS_dFi !< derivative of 2nd P-K stress with respect to intermediate deformation gradient + real(pReal), dimension(3,3) :: E real(pReal), dimension(3,3,3,3) :: C integer :: & ho, & !< homogenization - d !< counter in degradation loop - integer :: & - i, j + d, & !< counter in degradation loop + i, j, ph, me ho = material_homogenizationAt(el) - C = math_66toSym3333(constitutive_homogenizedC(co,ip,el)) + C = math_66toSym3333(constitutive_homogenizedC(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el))) DegradationLoop: do d = 1, phase_NstiffnessDegradations(material_phaseAt(co,el)) degradationType: select case(phase_stiffnessDegradation(d,material_phaseAt(co,el))) @@ -1535,19 +1531,16 @@ end subroutine mech_forward !> @brief returns the homogenize elasticity matrix !> ToDo: homogenizedC66 would be more consistent !-------------------------------------------------------------------------------------------------- -module function constitutive_homogenizedC(co,ip,el) result(C) +module function constitutive_homogenizedC(ph,me) result(C) real(pReal), dimension(6,6) :: C - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + integer, intent(in) :: ph, me - plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) + plasticityType: select case (phase_plasticity(ph)) case (PLASTICITY_DISLOTWIN_ID) plasticityType - C = plastic_dislotwin_homogenizedC(co,ip,el) + C = plastic_dislotwin_homogenizedC(ph,me) case default plasticityType - C = lattice_C66(1:6,1:6,material_phaseAt(co,el)) + C = lattice_C66(1:6,1:6,ph) end select plasticityType end function constitutive_homogenizedC diff --git a/src/constitutive_plastic_dislotwin.f90 b/src/constitutive_plastic_dislotwin.f90 index 0474427fe..dea84f751 100644 --- a/src/constitutive_plastic_dislotwin.f90 +++ b/src/constitutive_plastic_dislotwin.f90 @@ -150,7 +150,7 @@ module function plastic_dislotwin_init() result(myPlasticity) Ninstances = count(myPlasticity) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return - + print*, 'Ma and Roters, Acta Materialia 52(12):3603–3612, 2004' print*, 'https://doi.org/10.1016/j.actamat.2004.04.012'//IO_EOL @@ -485,35 +485,32 @@ end function plastic_dislotwin_init !-------------------------------------------------------------------------------------------------- !> @brief Return the homogenized elasticity matrix. !-------------------------------------------------------------------------------------------------- -module function plastic_dislotwin_homogenizedC(co,ip,el) result(homogenizedC) +module function plastic_dislotwin_homogenizedC(ph,me) result(homogenizedC) + integer, intent(in) :: & + ph, me real(pReal), dimension(6,6) :: & homogenizedC - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - integer :: i, & - of + integer :: i real(pReal) :: f_unrotated - of = material_phasememberAt(co,ip,el) - associate(prm => param(phase_plasticityInstance(material_phaseAt(co,el))),& - stt => state(phase_plasticityInstance(material_phaseAT(co,el)))) + + associate(prm => param(phase_plasticityInstance(ph)),& + stt => state(phase_plasticityInstance(ph))) f_unrotated = 1.0_pReal & - - sum(stt%f_tw(1:prm%sum_N_tw,of)) & - - sum(stt%f_tr(1:prm%sum_N_tr,of)) + - sum(stt%f_tw(1:prm%sum_N_tw,me)) & + - sum(stt%f_tr(1:prm%sum_N_tr,me)) homogenizedC = f_unrotated * prm%C66 do i=1,prm%sum_N_tw homogenizedC = homogenizedC & - + stt%f_tw(i,of)*prm%C66_tw(1:6,1:6,i) + + stt%f_tw(i,me)*prm%C66_tw(1:6,1:6,i) enddo do i=1,prm%sum_N_tr homogenizedC = homogenizedC & - + stt%f_tr(i,of)*prm%C66_tr(1:6,1:6,i) + + stt%f_tr(i,me)*prm%C66_tr(1:6,1:6,i) enddo end associate diff --git a/src/homogenization_mech_RGC.f90 b/src/homogenization_mech_RGC.f90 index 580bb0268..24d14e059 100644 --- a/src/homogenization_mech_RGC.f90 +++ b/src/homogenization_mech_RGC.f90 @@ -656,8 +656,11 @@ module function mech_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy ip, & !< integration point number el !< element number + real(pReal), dimension(6,6) :: C - equivalentMu = lattice_equivalent_mu(constitutive_homogenizedC(grainID,ip,el),'voigt') + + C = constitutive_homogenizedC(material_phaseAt(grainID,el),material_phaseMemberAt(grainID,ip,el)) + equivalentMu = lattice_equivalent_mu(C,'voigt') end function equivalentMu From 261f32d7c9d2a912fae4d1add0b52e61389bbfd7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 19 Jan 2021 10:21:51 +0100 Subject: [PATCH 127/352] consistent names --- src/constitutive_damage.f90 | 16 +++++++--------- src/source_damage_isoBrittle.f90 | 32 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index 4fa7a9627..46f2a3057 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -411,14 +411,14 @@ end function constitutive_damage_collectDotState !> @brief for constitutive models having an instantaneous change of state !> will return false if delta state is not needed/supported by the constitutive model !-------------------------------------------------------------------------------------------------- -function constitutive_damage_deltaState(Fe, co, ip, el, ph, of) result(broken) +function constitutive_damage_deltaState(Fe, co, ip, el, ph, me) result(broken) integer, intent(in) :: & - co, & !< component-ID of integration point + co, & !< component-ID me integration point ip, & !< integration point el, & !< element ph, & - of + me real(pReal), intent(in), dimension(3,3) :: & Fe !< elastic deformation gradient integer :: & @@ -436,15 +436,13 @@ function constitutive_damage_deltaState(Fe, co, ip, el, ph, of) result(broken) sourceType: select case (phase_source(so,ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType - call source_damage_isoBrittle_deltaState (constitutive_homogenizedC(material_phaseAt(co,el), & - material_phaseMemberAt(co,ip,el)), Fe, & - co, ip, el) - broken = any(IEEE_is_NaN(damageState(ph)%p(so)%deltaState(:,of))) + call source_damage_isoBrittle_deltaState(constitutive_homogenizedC(ph,me), Fe, co, ip, el) + broken = any(IEEE_is_NaN(damageState(ph)%p(so)%deltaState(:,me))) if(.not. broken) then myOffset = damageState(ph)%p(so)%offsetDeltaState mySize = damageState(ph)%p(so)%sizeDeltaState - damageState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) = & - damageState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,of) + damageState(ph)%p(so)%deltaState(1:mySize,of) + damageState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,me) = & + damageState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,me) + damageState(ph)%p(so)%deltaState(1:mySize,me) endif end select sourceType diff --git a/src/source_damage_isoBrittle.f90 b/src/source_damage_isoBrittle.f90 index 1721b0201..b2da8411f 100644 --- a/src/source_damage_isoBrittle.f90 +++ b/src/source_damage_isoBrittle.f90 @@ -28,7 +28,7 @@ contains !-------------------------------------------------------------------------------------------------- module function source_damage_isoBrittle_init(source_length) result(mySources) - integer, intent(in) :: source_length + integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources class(tNode), pointer :: & @@ -52,7 +52,7 @@ module function source_damage_isoBrittle_init(source_length) result(mySources) allocate(source_damage_isoBrittle_instance(phases%length), source=0) do p = 1, phases%length - phase => phases%get(p) + phase => phases%get(p) if(any(mySources(:,p))) source_damage_isoBrittle_instance(p) = count(mySources(:,1:p)) if(count(mySources(:,p)) == 0) cycle sources => phase%get('source') @@ -60,7 +60,7 @@ module function source_damage_isoBrittle_init(source_length) result(mySources) if(mySources(sourceOffset,p)) then source_damage_isoBrittle_offset(p) = sourceOffset associate(prm => param(source_damage_isoBrittle_instance(p))) - src => sources%get(sourceOffset) + src => sources%get(sourceOffset) prm%W_crit = src%get_asFloat('W_crit') @@ -69,7 +69,7 @@ module function source_damage_isoBrittle_init(source_length) result(mySources) #else prm%output = src%get_asStrings('output',defaultVal=emptyStringArray) #endif - + ! sanity checks if (prm%W_crit <= 0.0_pReal) extmsg = trim(extmsg)//' W_crit' @@ -106,31 +106,31 @@ module subroutine source_damage_isoBrittle_deltaState(C, Fe, co, ip, el) C integer :: & - phase, & - constituent, & + ph, & + me, & sourceOffset real(pReal), dimension(6) :: & strain real(pReal) :: & strainenergy - phase = material_phaseAt(co,el) !< phase ID at co,ip,el - constituent = material_phasememberAt(co,ip,el) !< state array offset for phase ID at co,ip,el - sourceOffset = source_damage_isoBrittle_offset(phase) + ph = material_phaseAt(co,el) !< ph ID at co,ip,el + me = material_phasememberAt(co,ip,el) !< state array offset for ph ID at co,ip,el + sourceOffset = source_damage_isoBrittle_offset(ph) strain = 0.5_pReal*math_sym33to6(matmul(transpose(Fe),Fe)-math_I3) - associate(prm => param(source_damage_isoBrittle_instance(phase))) + associate(prm => param(source_damage_isoBrittle_instance(ph))) strainenergy = 2.0_pReal*sum(strain*matmul(C,strain))/prm%W_crit ! ToDo: check strainenergy = 2.0_pReal*dot_product(strain,matmul(C,strain))/prm%W_crit - if (strainenergy > damageState(phase)%p(sourceOffset)%subState0(1,constituent)) then - damageState(phase)%p(sourceOffset)%deltaState(1,constituent) = & - strainenergy - damageState(phase)%p(sourceOffset)%state(1,constituent) + if (strainenergy > damageState(ph)%p(sourceOffset)%subState0(1,me)) then + damageState(ph)%p(sourceOffset)%deltaState(1,me) = & + strainenergy - damageState(ph)%p(sourceOffset)%state(1,me) else - damageState(phase)%p(sourceOffset)%deltaState(1,constituent) = & - damageState(phase)%p(sourceOffset)%subState0(1,constituent) - & - damageState(phase)%p(sourceOffset)%state(1,constituent) + damageState(ph)%p(sourceOffset)%deltaState(1,me) = & + damageState(ph)%p(sourceOffset)%subState0(1,me) - & + damageState(ph)%p(sourceOffset)%state(1,me) endif end associate From 47724be32b4e85ea4c564da8e4b6435fe3534699 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 19 Jan 2021 10:25:52 +0100 Subject: [PATCH 128/352] simplified --- src/constitutive.f90 | 13 ------------- src/constitutive_damage.f90 | 17 +++++++++++------ src/source_damage_isoBrittle.f90 | 11 ++--------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 1564e610b..d54f55158 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -343,19 +343,6 @@ module constitutive dLi_dTstar !< derivative of Li with respect to Tstar (4th-order tensor defined to be zero) end subroutine kinematics_thermal_expansion_LiAndItsTangent - - module subroutine source_damage_isoBrittle_deltaState(C, Fe, co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - real(pReal), intent(in), dimension(3,3) :: & - Fe - real(pReal), intent(in), dimension(6,6) :: & - C - end subroutine source_damage_isoBrittle_deltaState - - module subroutine constitutive_plastic_dependentState(co,ip,el) integer, intent(in) :: & co, & !< component-ID of integration point diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index 46f2a3057..235fb8967 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -45,6 +45,14 @@ submodule(constitutive) constitutive_damage logical, dimension(:,:), allocatable :: myKinematics end function kinematics_slipplane_opening_init + module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph, me) + integer, intent(in) :: ph,me + real(pReal), intent(in), dimension(3,3) :: & + Fe + real(pReal), intent(in), dimension(6,6) :: & + C + end subroutine source_damage_isoBrittle_deltaState + module subroutine source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) integer, intent(in) :: & @@ -295,7 +303,7 @@ module function integrateDamageState(dt,co,ip,el) result(broken) enddo if(converged_) then - broken = constitutive_damage_deltaState(mech_F_e(ph,me),co,ip,el,ph,me) + broken = constitutive_damage_deltaState(mech_F_e(ph,me),ph,me) exit iteration endif @@ -411,12 +419,9 @@ end function constitutive_damage_collectDotState !> @brief for constitutive models having an instantaneous change of state !> will return false if delta state is not needed/supported by the constitutive model !-------------------------------------------------------------------------------------------------- -function constitutive_damage_deltaState(Fe, co, ip, el, ph, me) result(broken) +function constitutive_damage_deltaState(Fe, ph, me) result(broken) integer, intent(in) :: & - co, & !< component-ID me integration point - ip, & !< integration point - el, & !< element ph, & me real(pReal), intent(in), dimension(3,3) :: & @@ -436,7 +441,7 @@ function constitutive_damage_deltaState(Fe, co, ip, el, ph, me) result(broken) sourceType: select case (phase_source(so,ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType - call source_damage_isoBrittle_deltaState(constitutive_homogenizedC(ph,me), Fe, co, ip, el) + call source_damage_isoBrittle_deltaState(constitutive_homogenizedC(ph,me), Fe, ph,me) broken = any(IEEE_is_NaN(damageState(ph)%p(so)%deltaState(:,me))) if(.not. broken) then myOffset = damageState(ph)%p(so)%offsetDeltaState diff --git a/src/source_damage_isoBrittle.f90 b/src/source_damage_isoBrittle.f90 index b2da8411f..cff993e7f 100644 --- a/src/source_damage_isoBrittle.f90 +++ b/src/source_damage_isoBrittle.f90 @@ -94,28 +94,21 @@ end function source_damage_isoBrittle_init !-------------------------------------------------------------------------------------------------- !> @brief calculates derived quantities from state !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_isoBrittle_deltaState(C, Fe, co, ip, el) +module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph,me) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + integer, intent(in) :: ph,me real(pReal), intent(in), dimension(3,3) :: & Fe real(pReal), intent(in), dimension(6,6) :: & C integer :: & - ph, & - me, & sourceOffset real(pReal), dimension(6) :: & strain real(pReal) :: & strainenergy - ph = material_phaseAt(co,el) !< ph ID at co,ip,el - me = material_phasememberAt(co,ip,el) !< state array offset for ph ID at co,ip,el sourceOffset = source_damage_isoBrittle_offset(ph) strain = 0.5_pReal*math_sym33to6(matmul(transpose(Fe),Fe)-math_I3) From ff1dbfbb952a819c19a885689f52183cfb737c65 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 19 Jan 2021 10:30:10 +0100 Subject: [PATCH 129/352] only needed at lower level --- src/constitutive.f90 | 25 ------------------------- src/constitutive_damage.f90 | 24 ++++++++++++++++++++++++ src/constitutive_thermal.f90 | 7 +++++++ 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index d54f55158..7ecff0eef 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -234,34 +234,9 @@ module constitutive real(pReal), dimension(6,6) :: C end function constitutive_homogenizedC - module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - real(pReal), intent(in), dimension(3,3) :: & - S - end subroutine source_damage_anisoBrittle_dotState - module subroutine source_damage_anisoDuctile_dotState(co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - end subroutine source_damage_anisoDuctile_dotState - module subroutine source_damage_isoDuctile_dotState(co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - end subroutine source_damage_isoDuctile_dotState - module subroutine source_thermal_externalheat_dotState(phase, of) - integer, intent(in) :: & - phase, & - of - end subroutine source_thermal_externalheat_dotState module subroutine constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) integer, intent(in) :: & diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index 235fb8967..6565e1813 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -54,6 +54,30 @@ submodule(constitutive) constitutive_damage end subroutine source_damage_isoBrittle_deltaState + module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + real(pReal), intent(in), dimension(3,3) :: & + S + end subroutine source_damage_anisoBrittle_dotState + + module subroutine source_damage_anisoDuctile_dotState(co, ip, el) + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + end subroutine source_damage_anisoDuctile_dotState + + module subroutine source_damage_isoDuctile_dotState(co, ip, el) + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + end subroutine source_damage_isoDuctile_dotState + + module subroutine source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) integer, intent(in) :: & phase, & !< phase ID of element diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 9007ef729..511d44f8e 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -36,6 +36,13 @@ submodule(constitutive) constitutive_thermal end function kinematics_thermal_expansion_init + module subroutine source_thermal_externalheat_dotState(phase, of) + integer, intent(in) :: & + phase, & + of + end subroutine source_thermal_externalheat_dotState + + module subroutine thermal_dissipation_getRate(TDot, Tstar,Lp,phase) integer, intent(in) :: & phase !< phase ID of element From b1674b6835067341180c21407bec86d996ad0141 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 19 Jan 2021 10:32:56 +0100 Subject: [PATCH 130/352] consistent names --- src/constitutive_thermal.f90 | 12 ++++++------ src/constitutive_thermal_externalheat.f90 | 24 +++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 511d44f8e..2746ff889 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -36,10 +36,10 @@ submodule(constitutive) constitutive_thermal end function kinematics_thermal_expansion_init - module subroutine source_thermal_externalheat_dotState(phase, of) + module subroutine source_thermal_externalheat_dotState(ph, me) integer, intent(in) :: & - phase, & - of + ph, & + me end subroutine source_thermal_externalheat_dotState @@ -54,10 +54,10 @@ submodule(constitutive) constitutive_thermal TDot end subroutine thermal_dissipation_getRate - module subroutine thermal_externalheat_getRate(TDot, phase,of) + module subroutine thermal_externalheat_getRate(TDot, ph,me) integer, intent(in) :: & - phase, & - of + ph, & + me real(pReal), intent(out) :: & TDot end subroutine thermal_externalheat_getRate diff --git a/src/constitutive_thermal_externalheat.f90 b/src/constitutive_thermal_externalheat.f90 index 2e8c02f8c..16b2bdb65 100644 --- a/src/constitutive_thermal_externalheat.f90 +++ b/src/constitutive_thermal_externalheat.f90 @@ -85,18 +85,18 @@ end function source_thermal_externalheat_init !> @brief rate of change of state !> @details state only contains current time to linearly interpolate given heat powers !-------------------------------------------------------------------------------------------------- -module subroutine source_thermal_externalheat_dotState(phase, of) +module subroutine source_thermal_externalheat_dotState(ph, me) integer, intent(in) :: & - phase, & - of + ph, & + me integer :: & sourceOffset - sourceOffset = source_thermal_externalheat_offset(phase) + sourceOffset = source_thermal_externalheat_offset(ph) - thermalState(phase)%p(sourceOffset)%dotState(1,of) = 1.0_pReal ! state is current time + thermalState(ph)%p(sourceOffset)%dotState(1,me) = 1.0_pReal ! state is current time end subroutine source_thermal_externalheat_dotState @@ -104,11 +104,11 @@ end subroutine source_thermal_externalheat_dotState !-------------------------------------------------------------------------------------------------- !> @brief returns local heat generation rate !-------------------------------------------------------------------------------------------------- -module subroutine thermal_externalheat_getRate(TDot, phase, of) +module subroutine thermal_externalheat_getRate(TDot, ph, me) integer, intent(in) :: & - phase, & - of + ph, & + me real(pReal), intent(out) :: & TDot @@ -117,18 +117,18 @@ module subroutine thermal_externalheat_getRate(TDot, phase, of) real(pReal) :: & frac_time - sourceOffset = source_thermal_externalheat_offset(phase) + sourceOffset = source_thermal_externalheat_offset(ph) - associate(prm => param(source_thermal_externalheat_instance(phase))) + associate(prm => param(source_thermal_externalheat_instance(ph))) do interval = 1, prm%nIntervals ! scan through all rate segments - frac_time = (thermalState(phase)%p(sourceOffset)%state(1,of) - prm%t_n(interval)) & + frac_time = (thermalState(ph)%p(sourceOffset)%state(1,me) - prm%t_n(interval)) & / (prm%t_n(interval+1) - prm%t_n(interval)) ! fractional time within segment if ( (frac_time < 0.0_pReal .and. interval == 1) & .or. (frac_time >= 1.0_pReal .and. interval == prm%nIntervals) & .or. (frac_time >= 0.0_pReal .and. frac_time < 1.0_pReal) ) & TDot = prm%f_T(interval ) * (1.0_pReal - frac_time) + & prm%f_T(interval+1) * frac_time ! interpolate heat rate between segment boundaries... - ! ...or extrapolate if outside of bounds + ! ...or extrapolate if outside me bounds enddo end associate From 440790ca01a38db9029f2f966f799d115b6e8f37 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 19 Jan 2021 10:39:16 +0100 Subject: [PATCH 131/352] consistent names --- src/constitutive_damage.f90 | 11 ++++----- src/source_damage_anisoBrittle.f90 | 38 +++++++++++++++--------------- src/source_damage_anisoDuctile.f90 | 22 ++++++++--------- src/source_damage_isoDuctile.f90 | 24 +++++++++---------- 4 files changed, 47 insertions(+), 48 deletions(-) diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index 6565e1813..a8792d5e2 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -400,14 +400,14 @@ end subroutine damage_results !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the rate of change of microstructure !-------------------------------------------------------------------------------------------------- -function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) +function constitutive_damage_collectDotState(co,ip,el,ph,me) result(broken) integer, intent(in) :: & - co, & !< component-ID of integration point + co, & !< component-ID me integration point ip, & !< integration point el, & !< element ph, & - of + me integer :: & so !< counter in source loop logical :: broken @@ -426,12 +426,11 @@ function constitutive_damage_collectDotState(co,ip,el,ph,of) result(broken) call source_damage_anisoDuctile_dotState(co, ip, el) case (DAMAGE_ANISOBRITTLE_ID) sourceType - call source_damage_anisoBrittle_dotState(mech_S(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el)),& - co, ip, el) ! correct stress? + call source_damage_anisoBrittle_dotState(mech_S(ph,me),co, ip, el) ! correct stress? end select sourceType - broken = broken .or. any(IEEE_is_NaN(damageState(ph)%p(so)%dotState(:,of))) + broken = broken .or. any(IEEE_is_NaN(damageState(ph)%p(so)%dotState(:,me))) enddo SourceLoop diff --git a/src/source_damage_anisoBrittle.f90 b/src/source_damage_anisoBrittle.f90 index 7c00c6580..8da37c5d5 100644 --- a/src/source_damage_anisoBrittle.f90 +++ b/src/source_damage_anisoBrittle.f90 @@ -15,7 +15,7 @@ submodule (constitutive:constitutive_damage) source_damage_anisoBrittle dot_o, & !< opening rate of cleavage planes q !< damage rate sensitivity real(pReal), dimension(:), allocatable :: & - s_crit, & !< critical displacement + s_crit, & !< critical displacement g_crit !< critical load real(pReal), dimension(:,:,:,:), allocatable :: & cleavage_systems @@ -37,7 +37,7 @@ contains !-------------------------------------------------------------------------------------------------- module function source_damage_anisoBrittle_init(source_length) result(mySources) - integer, intent(in) :: source_length + integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources class(tNode), pointer :: & @@ -62,7 +62,7 @@ module function source_damage_anisoBrittle_init(source_length) result(mySources) allocate(source_damage_anisoBrittle_instance(phases%length), source=0) do p = 1, phases%length - phase => phases%get(p) + phase => phases%get(p) if(any(mySources(:,p))) source_damage_anisoBrittle_instance(p) = count(mySources(:,1:p)) if(count(mySources(:,p)) == 0) cycle sources => phase%get('source') @@ -70,20 +70,20 @@ module function source_damage_anisoBrittle_init(source_length) result(mySources) if(mySources(sourceOffset,p)) then source_damage_anisoBrittle_offset(p) = sourceOffset associate(prm => param(source_damage_anisoBrittle_instance(p))) - src => sources%get(sourceOffset) - + src => sources%get(sourceOffset) + N_cl = src%get_asInts('N_cl',defaultVal=emptyIntArray) prm%sum_N_cl = sum(abs(N_cl)) - + prm%q = src%get_asFloat('q') prm%dot_o = src%get_asFloat('dot_o') - + prm%s_crit = src%get_asFloats('s_crit', requiredSize=size(N_cl)) prm%g_crit = src%get_asFloats('g_crit', requiredSize=size(N_cl)) - + prm%cleavage_systems = lattice_SchmidMatrix_cleavage(N_cl,phase%get_asString('lattice'),& phase%get_asFloat('c/a',defaultVal=0.0_pReal)) - + ! expand: family => system prm%s_crit = math_expand(prm%s_crit,N_cl) prm%g_crit = math_expand(prm%g_crit,N_cl) @@ -93,7 +93,7 @@ module function source_damage_anisoBrittle_init(source_length) result(mySources) #else prm%output = src%get_asStrings('output',defaultVal=emptyStringArray) #endif - + ! sanity checks if (prm%q <= 0.0_pReal) extmsg = trim(extmsg)//' q' if (prm%dot_o <= 0.0_pReal) extmsg = trim(extmsg)//' dot_o' @@ -130,8 +130,8 @@ module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) S integer :: & - phase, & - constituent, & + ph, & + me, & sourceOffset, & damageOffset, & homog, & @@ -139,14 +139,14 @@ module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) real(pReal) :: & traction_d, traction_t, traction_n, traction_crit - phase = material_phaseAt(co,el) - constituent = material_phasememberAt(co,ip,el) - sourceOffset = source_damage_anisoBrittle_offset(phase) + ph = material_phaseAt(co,el) + me = material_phasememberAt(co,ip,el) + sourceOffset = source_damage_anisoBrittle_offset(ph) homog = material_homogenizationAt(el) damageOffset = material_homogenizationMemberAt(ip,el) - associate(prm => param(source_damage_anisoBrittle_instance(phase))) - damageState(phase)%p(sourceOffset)%dotState(1,constituent) = 0.0_pReal + associate(prm => param(source_damage_anisoBrittle_instance(ph))) + damageState(ph)%p(sourceOffset)%dotState(1,me) = 0.0_pReal do i = 1, prm%sum_N_cl traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) @@ -154,8 +154,8 @@ module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) traction_crit = prm%g_crit(i)*damage(homog)%p(damageOffset)**2.0_pReal - damageState(phase)%p(sourceOffset)%dotState(1,constituent) & - = damageState(phase)%p(sourceOffset)%dotState(1,constituent) & + damageState(ph)%p(sourceOffset)%dotState(1,me) & + = damageState(ph)%p(sourceOffset)%dotState(1,me) & + prm%dot_o / prm%s_crit(i) & * ((max(0.0_pReal, abs(traction_d) - traction_crit)/traction_crit)**prm%q + & (max(0.0_pReal, abs(traction_t) - traction_crit)/traction_crit)**prm%q + & diff --git a/src/source_damage_anisoDuctile.f90 b/src/source_damage_anisoDuctile.f90 index 7ec06cb62..b5e6fd17c 100644 --- a/src/source_damage_anisoDuctile.f90 +++ b/src/source_damage_anisoDuctile.f90 @@ -30,7 +30,7 @@ contains !-------------------------------------------------------------------------------------------------- module function source_damage_anisoDuctile_init(source_length) result(mySources) - integer, intent(in) :: source_length + integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources class(tNode), pointer :: & @@ -67,7 +67,7 @@ module function source_damage_anisoDuctile_init(source_length) result(mySources) if(mySources(sourceOffset,p)) then source_damage_anisoDuctile_offset(p) = sourceOffset associate(prm => param(source_damage_anisoDuctile_instance(p))) - src => sources%get(sourceOffset) + src => sources%get(sourceOffset) N_sl = pl%get_asInts('N_sl',defaultVal=emptyIntArray) prm%q = src%get_asFloat('q') @@ -81,7 +81,7 @@ module function source_damage_anisoDuctile_init(source_length) result(mySources) #else prm%output = src%get_asStrings('output',defaultVal=emptyStringArray) #endif - + ! sanity checks if (prm%q <= 0.0_pReal) extmsg = trim(extmsg)//' q' if (any(prm%gamma_crit < 0.0_pReal)) extmsg = trim(extmsg)//' gamma_crit' @@ -115,21 +115,21 @@ module subroutine source_damage_anisoDuctile_dotState(co, ip, el) el !< element integer :: & - phase, & - constituent, & + ph, & + me, & sourceOffset, & damageOffset, & homog - phase = material_phaseAt(co,el) - constituent = material_phasememberAt(co,ip,el) - sourceOffset = source_damage_anisoDuctile_offset(phase) + ph = material_phaseAt(co,el) + me = material_phasememberAt(co,ip,el) + sourceOffset = source_damage_anisoDuctile_offset(ph) homog = material_homogenizationAt(el) damageOffset = material_homogenizationMemberAt(ip,el) - associate(prm => param(source_damage_anisoDuctile_instance(phase))) - damageState(phase)%p(sourceOffset)%dotState(1,constituent) & - = sum(plasticState(phase)%slipRate(:,constituent)/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit) + associate(prm => param(source_damage_anisoDuctile_instance(ph))) + damageState(ph)%p(sourceOffset)%dotState(1,me) & + = sum(plasticState(ph)%slipRate(:,me)/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit) end associate end subroutine source_damage_anisoDuctile_dotState diff --git a/src/source_damage_isoDuctile.f90 b/src/source_damage_isoDuctile.f90 index dd2910182..3cebc474a 100644 --- a/src/source_damage_isoDuctile.f90 +++ b/src/source_damage_isoDuctile.f90 @@ -30,7 +30,7 @@ contains !-------------------------------------------------------------------------------------------------- module function source_damage_isoDuctile_init(source_length) result(mySources) - integer, intent(in) :: source_length + integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources class(tNode), pointer :: & @@ -54,7 +54,7 @@ module function source_damage_isoDuctile_init(source_length) result(mySources) allocate(source_damage_isoDuctile_instance(phases%length), source=0) do p = 1, phases%length - phase => phases%get(p) + phase => phases%get(p) if(count(mySources(:,p)) == 0) cycle if(any(mySources(:,p))) source_damage_isoDuctile_instance(p) = count(mySources(:,1:p)) sources => phase%get('source') @@ -62,7 +62,7 @@ module function source_damage_isoDuctile_init(source_length) result(mySources) if(mySources(sourceOffset,p)) then source_damage_isoDuctile_offset(p) = sourceOffset associate(prm => param(source_damage_isoDuctile_instance(p))) - src => sources%get(sourceOffset) + src => sources%get(sourceOffset) prm%q = src%get_asFloat('q') prm%gamma_crit = src%get_asFloat('gamma_crit') @@ -72,7 +72,7 @@ module function source_damage_isoDuctile_init(source_length) result(mySources) #else prm%output = src%get_asStrings('output',defaultVal=emptyStringArray) #endif - + ! sanity checks if (prm%q <= 0.0_pReal) extmsg = trim(extmsg)//' q' if (prm%gamma_crit <= 0.0_pReal) extmsg = trim(extmsg)//' gamma_crit' @@ -106,21 +106,21 @@ module subroutine source_damage_isoDuctile_dotState(co, ip, el) el !< element integer :: & - phase, & - constituent, & + ph, & + me, & sourceOffset, & damageOffset, & homog - phase = material_phaseAt(co,el) - constituent = material_phasememberAt(co,ip,el) - sourceOffset = source_damage_isoDuctile_offset(phase) + ph = material_phaseAt(co,el) + me = material_phasememberAt(co,ip,el) + sourceOffset = source_damage_isoDuctile_offset(ph) homog = material_homogenizationAt(el) damageOffset = material_homogenizationMemberAt(ip,el) - associate(prm => param(source_damage_isoDuctile_instance(phase))) - damageState(phase)%p(sourceOffset)%dotState(1,constituent) = & - sum(plasticState(phase)%slipRate(:,constituent))/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit + associate(prm => param(source_damage_isoDuctile_instance(ph))) + damageState(ph)%p(sourceOffset)%dotState(1,me) = & + sum(plasticState(ph)%slipRate(:,me))/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit end associate end subroutine source_damage_isoDuctile_dotState From 831bf92e6a24a5fecb2d1434e986ca89bb20473e Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 19 Jan 2021 15:14:41 +0100 Subject: [PATCH 132/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-314-g388e23348 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b8f3f3020..d2cad87cb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-302-g5b9a2d7bf +v3.0.0-alpha2-314-g388e23348 From 219529a4029ab92e82a8f43a02812128dd13a5fb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 20 Jan 2021 20:40:14 +0100 Subject: [PATCH 133/352] field variables --- src/homogenization.f90 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index a63487b6f..d576c5672 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -29,7 +29,9 @@ module homogenization ! General variables for the homogenization at a material point real(pReal), dimension(:), allocatable, public :: & homogenization_T, & - homogenization_dot_T + homogenization_dot_T, & + homogenization_phi, & + homogenization_dot_phi real(pReal), dimension(:,:,:), allocatable, public :: & homogenization_F0, & !< def grad of IP at start of FE increment homogenization_F !< def grad of IP to be reached at end of FE increment From 32bb0d8c6e5b4b223a8591133b0d2283b755dcd6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 20 Jan 2021 20:54:31 +0100 Subject: [PATCH 134/352] new variables for damage --- PRIVATE | 2 +- src/commercialFEM_fileList.f90 | 1 + src/constitutive.f90 | 12 ++++++ src/constitutive_damage.f90 | 42 ++++++++++++++++++- src/grid/grid_damage_spectral.f90 | 69 ++++++++++++++++--------------- src/homogenization.f90 | 11 ++++- src/homogenization_damage.f90 | 40 ++++++++++++++++++ 7 files changed, 141 insertions(+), 36 deletions(-) create mode 100644 src/homogenization_damage.f90 diff --git a/PRIVATE b/PRIVATE index 9e8011876..5fd23c60c 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 9e8011876b16896a18902737790eba8018e94f85 +Subproject commit 5fd23c60c721aada27bcd3a4ba96301753b7bd0d diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index e04936a3b..963871c7a 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -52,4 +52,5 @@ #include "homogenization_mech_isostrain.f90" #include "homogenization_mech_RGC.f90" #include "homogenization_thermal.f90" +#include "homogenization_damage.f90" #include "CPFEM.f90" diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 7ecff0eef..16f3d3b59 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -188,6 +188,11 @@ module constitutive real(pReal), dimension(3,3) :: P end function constitutive_mech_getP + module function constitutive_damage_get_phi(co,ip,el) result(phi) + integer, intent(in) :: co, ip, el + real(pReal) :: phi + end function constitutive_damage_get_phi + module function thermal_T(ph,me) result(T) integer, intent(in) :: ph,me real(pReal) :: T @@ -203,6 +208,11 @@ module constitutive real(pReal), intent(in) :: T integer, intent(in) :: co, ce end subroutine constitutive_thermal_setT + + module subroutine constitutive_damage_set_phi(phi,co,ce) + real(pReal), intent(in) :: phi + integer, intent(in) :: co, ce + end subroutine constitutive_damage_set_phi ! == cleaned:end =================================================================================== @@ -353,6 +363,8 @@ module constitutive constitutive_restartRead, & integrateDamageState, & constitutive_thermal_setT, & + constitutive_damage_set_phi, & + constitutive_damage_get_phi, & constitutive_mech_getP, & constitutive_mech_setF, & constitutive_mech_getF, & diff --git a/src/constitutive_damage.f90 b/src/constitutive_damage.f90 index a8792d5e2..07bfbeeca 100644 --- a/src/constitutive_damage.f90 +++ b/src/constitutive_damage.f90 @@ -10,9 +10,16 @@ submodule(constitutive) constitutive_damage DAMAGE_ANISODUCTILE_ID end enum + + type :: tDataContainer + real(pReal), dimension(:), allocatable :: phi, d_phi_d_dot_phi + end type tDataContainer + integer(kind(DAMAGE_UNDEFINED_ID)), dimension(:,:), allocatable :: & phase_source !< active sources mechanisms of each phase + type(tDataContainer), dimension(:), allocatable :: current + interface module function source_damage_anisoBrittle_init(source_length) result(mySources) @@ -152,7 +159,8 @@ contains module subroutine damage_init integer :: & - ph !< counter in phase loop + ph, & !< counter in phase loop + Nconstituents class(tNode), pointer :: & phases, & phase, & @@ -161,10 +169,18 @@ module subroutine damage_init phases => config_material%get('phase') + allocate(current(phases%length)) + allocate(damageState (phases%length)) allocate(phase_Nsources(phases%length),source = 0) ! same for kinematics do ph = 1,phases%length + + Nconstituents = count(material_phaseAt == ph) * discretization_nIPs + + allocate(current(ph)%phi(Nconstituents),source=1.0_pReal) + allocate(current(ph)%d_phi_d_dot_phi(Nconstituents),source=0.0_pReal) + phase => phases%get(ph) sources => phase%get('source',defaultVal=emptyList) phase_Nsources(ph) = sources%length @@ -511,4 +527,28 @@ function source_active(source_label,src_length) result(active_source) end function source_active +!---------------------------------------------------------------------------------------------- +!< @brief Set damage parameter +!---------------------------------------------------------------------------------------------- +module subroutine constitutive_damage_set_phi(phi,co,ce) + + real(pReal), intent(in) :: phi + integer, intent(in) :: ce, co + + + current(material_phaseAt2(co,ce))%phi(material_phaseMemberAt2(co,ce)) = phi + +end subroutine constitutive_damage_set_phi + + +module function constitutive_damage_get_phi(co,ip,el) result(phi) + + integer, intent(in) :: co, ip, el + real(pReal) :: phi + + phi = current(material_phaseAt(co,el))%phi(material_phaseMemberAt(co,ip,el)) + +end function constitutive_damage_get_phi + + end submodule constitutive_damage diff --git a/src/grid/grid_damage_spectral.f90 b/src/grid/grid_damage_spectral.f90 index 79437945b..a891f070d 100644 --- a/src/grid/grid_damage_spectral.f90 +++ b/src/grid/grid_damage_spectral.f90 @@ -17,8 +17,9 @@ module grid_damage_spectral use discretization_grid use damage_nonlocal use YAML_types + use homogenization use config - + implicit none private @@ -43,13 +44,13 @@ module grid_damage_spectral phi_current, & !< field of current damage phi_lastInc, & !< field of previous damage phi_stagInc !< field of staggered damage - + !-------------------------------------------------------------------------------------------------- -! reference diffusion tensor, mobility etc. +! reference diffusion tensor, mobility etc. integer :: totalIter = 0 !< total iteration in current increment real(pReal), dimension(3,3) :: K_ref real(pReal) :: mu_ref - + public :: & grid_damage_spectral_init, & grid_damage_spectral_solution, & @@ -62,8 +63,8 @@ contains ! ToDo: Restart not implemented !-------------------------------------------------------------------------------------------------- subroutine grid_damage_spectral_init - - PetscInt, dimension(0:worldsize-1) :: localK + + PetscInt, dimension(0:worldsize-1) :: localK DM :: damage_grid Vec :: uBound, lBound PetscErrorCode :: ierr @@ -72,22 +73,22 @@ subroutine grid_damage_spectral_init num_generic character(len=pStringLen) :: & snes_type - + print'(/,a)', ' <<<+- grid_spectral_damage init -+>>>' print*, 'Shanthraj et al., Handbook of Mechanics of Materials, 2019' print*, 'https://doi.org/10.1007/978-981-10-6855-3_80' - + !------------------------------------------------------------------------------------------------- ! read numerical parameters and do sanity checks num_grid => config_numerics%get('grid',defaultVal=emptyDict) num%itmax = num_grid%get_asInt ('itmax',defaultVal=250) num%eps_damage_atol = num_grid%get_asFloat ('eps_damage_atol',defaultVal=1.0e-2_pReal) num%eps_damage_rtol = num_grid%get_asFloat ('eps_damage_rtol',defaultVal=1.0e-6_pReal) - + num_generic => config_numerics%get('generic',defaultVal=emptyDict) num%residualStiffness = num_generic%get_asFloat('residualStiffness', defaultVal=1.0e-6_pReal) - + if (num%residualStiffness < 0.0_pReal) call IO_error(301,ext_msg='residualStiffness') if (num%itmax <= 1) call IO_error(301,ext_msg='itmax') if (num%eps_damage_atol <= 0.0_pReal) call IO_error(301,ext_msg='eps_damage_atol') @@ -104,7 +105,7 @@ subroutine grid_damage_spectral_init !-------------------------------------------------------------------------------------------------- ! initialize solver specific parts of PETSc call SNESCreate(PETSC_COMM_WORLD,damage_snes,ierr); CHKERRQ(ierr) - call SNESSetOptionsPrefix(damage_snes,'damage_',ierr);CHKERRQ(ierr) + call SNESSetOptionsPrefix(damage_snes,'damage_',ierr);CHKERRQ(ierr) localK = 0 localK(worldrank) = grid3 call MPI_Allreduce(MPI_IN_PLACE,localK,worldsize,MPI_INTEGER,MPI_SUM,PETSC_COMM_WORLD,ierr) @@ -122,7 +123,7 @@ subroutine grid_damage_spectral_init call DMsetUp(damage_grid,ierr); CHKERRQ(ierr) call DMCreateGlobalVector(damage_grid,solution_vec,ierr); CHKERRQ(ierr) ! global solution vector (grid x 1, i.e. every def grad tensor) call DMDASNESSetFunctionLocal(damage_grid,INSERT_VALUES,formResidual,PETSC_NULL_SNES,ierr) ! residual vector of same shape as solution vector - CHKERRQ(ierr) + CHKERRQ(ierr) call SNESSetFromOptions(damage_snes,ierr); CHKERRQ(ierr) ! pull it all together with additional CLI arguments call SNESGetType(damage_snes,snes_type,ierr); CHKERRQ(ierr) if (trim(snes_type) == 'vinewtonrsls' .or. & @@ -137,12 +138,12 @@ subroutine grid_damage_spectral_init endif !-------------------------------------------------------------------------------------------------- -! init fields +! init fields call DMDAGetCorners(damage_grid,xstart,ystart,zstart,xend,yend,zend,ierr) CHKERRQ(ierr) xend = xstart + xend - 1 yend = ystart + yend - 1 - zend = zstart + zend - 1 + zend = zstart + zend - 1 allocate(phi_current(grid(1),grid(2),grid3), source=1.0_pReal) allocate(phi_lastInc(grid(1),grid(2),grid3), source=1.0_pReal) allocate(phi_stagInc(grid(1),grid(2),grid3), source=1.0_pReal) @@ -157,26 +158,26 @@ end subroutine grid_damage_spectral_init !> @brief solution for the spectral damage scheme with internal iterations !-------------------------------------------------------------------------------------------------- function grid_damage_spectral_solution(timeinc) result(solution) - + real(pReal), intent(in) :: & timeinc !< increment in time for current solution integer :: i, j, k, cell type(tSolutionState) :: solution PetscInt :: devNull PetscReal :: phi_min, phi_max, stagNorm, solnNorm - + PetscErrorCode :: ierr SNESConvergedReason :: reason solution%converged =.false. - + !-------------------------------------------------------------------------------------------------- -! set module wide availabe data +! set module wide availabe data params%timeinc = timeinc - + call SNESSolve(damage_snes,PETSC_NULL_VEC,solution_vec,ierr); CHKERRQ(ierr) call SNESGetConvergedReason(damage_snes,reason,ierr); CHKERRQ(ierr) - + if (reason < 1) then solution%converged = .false. solution%iterationsNeeded = num%itmax @@ -192,20 +193,21 @@ function grid_damage_spectral_solution(timeinc) result(solution) solution%stagConverged = stagNorm < max(num%eps_damage_atol, num%eps_damage_rtol*solnNorm) !-------------------------------------------------------------------------------------------------- -! updating damage state +! updating damage state cell = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) cell = cell + 1 call damage_nonlocal_putNonLocalDamage(phi_current(i,j,k),1,cell) + homogenization_phi(cell) = phi_current(i,j,k) enddo; enddo; enddo - + call VecMin(solution_vec,devNull,phi_min,ierr); CHKERRQ(ierr) call VecMax(solution_vec,devNull,phi_max,ierr); CHKERRQ(ierr) if (solution%converged) & print'(/,a)', ' ... nonlocal damage converged .....................................' print'(/,a,f8.6,2x,f8.6,2x,e11.4)', ' Minimum|Maximum|Delta Damage = ', phi_min, phi_max, stagNorm print'(/,a)', ' ===========================================================================' - flush(IO_STDOUT) + flush(IO_STDOUT) end function grid_damage_spectral_solution @@ -214,31 +216,32 @@ end function grid_damage_spectral_solution !> @brief spectral damage forwarding routine !-------------------------------------------------------------------------------------------------- subroutine grid_damage_spectral_forward(cutBack) - + logical, intent(in) :: cutBack integer :: i, j, k, cell DM :: dm_local PetscScalar, dimension(:,:,:), pointer :: x_scal PetscErrorCode :: ierr - if (cutBack) then + if (cutBack) then phi_current = phi_lastInc phi_stagInc = phi_lastInc !-------------------------------------------------------------------------------------------------- -! reverting damage field state +! reverting damage field state cell = 0 call SNESGetDM(damage_snes,dm_local,ierr); CHKERRQ(ierr) call DMDAVecGetArrayF90(dm_local,solution_vec,x_scal,ierr); CHKERRQ(ierr) !< get the data out of PETSc to work with x_scal(xstart:xend,ystart:yend,zstart:zend) = phi_current call DMDAVecRestoreArrayF90(dm_local,solution_vec,x_scal,ierr); CHKERRQ(ierr) do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 + cell = cell + 1 call damage_nonlocal_putNonLocalDamage(phi_current(i,j,k),1,cell) + homogenization_phi(cell) = phi_current(i,j,k) enddo; enddo; enddo else phi_lastInc = phi_current call updateReference - endif + endif end subroutine grid_damage_spectral_forward @@ -247,7 +250,7 @@ end subroutine grid_damage_spectral_forward !> @brief forms the spectral damage residual vector !-------------------------------------------------------------------------------------------------- subroutine formResidual(in,x_scal,f_scal,dummy,ierr) - + DMDALocalInfo, dimension(DMDA_LOCAL_INFO_SIZE) :: & in PetscScalar, dimension( & @@ -261,11 +264,11 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) integer :: i, j, k, cell real(pReal) :: phiDot, dPhiDot_dPhi, mobility - phi_current = x_scal + phi_current = x_scal !-------------------------------------------------------------------------------------------------- ! evaluate polarization field scalarField_real = 0.0_pReal - scalarField_real(1:grid(1),1:grid(2),1:grid3) = phi_current + scalarField_real(1:grid(1),1:grid(2),1:grid3) = phi_current call utilities_FFTscalarForward call utilities_fourierScalarGradient !< calculate gradient of damage field call utilities_FFTvectorBackward @@ -297,7 +300,7 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) scalarField_real(1:grid(1),1:grid(2),1:grid3) = phi_lastInc where(scalarField_real(1:grid(1),1:grid(2),1:grid3) < num%residualStiffness) & scalarField_real(1:grid(1),1:grid(2),1:grid3) = num%residualStiffness - + !-------------------------------------------------------------------------------------------------- ! constructing residual f_scal = scalarField_real(1:grid(1),1:grid(2),1:grid3) - phi_current @@ -311,7 +314,7 @@ end subroutine formResidual subroutine updateReference integer :: i,j,k,cell,ierr - + cell = 0 K_ref = 0.0_pReal mu_ref = 0.0_pReal diff --git a/src/homogenization.f90 b/src/homogenization.f90 index d576c5672..ed9b7fead 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -64,6 +64,9 @@ module homogenization module subroutine thermal_init end subroutine thermal_init + module subroutine damage_init + end subroutine damage_init + module subroutine mech_partition(subF,ip,el) real(pReal), intent(in), dimension(3,3) :: & subF @@ -77,6 +80,11 @@ module homogenization integer, intent(in) :: ce end subroutine thermal_partition + module subroutine damage_partition(phi,ce) + real(pReal), intent(in) :: phi + integer, intent(in) :: ce + end subroutine damage_partition + module subroutine thermal_homogenize(ip,el) integer, intent(in) :: ip,el end subroutine thermal_homogenize @@ -120,7 +128,7 @@ contains !-------------------------------------------------------------------------------------------------- !> @brief module initialization !-------------------------------------------------------------------------------------------------- -subroutine homogenization_init +subroutine homogenization_init() class (tNode) , pointer :: & num_homog, & @@ -144,6 +152,7 @@ subroutine homogenization_init call mech_init(num_homog) call thermal_init() + call damage_init() if (any(thermal_type == THERMAL_isothermal_ID)) call thermal_isothermal_init(homogenization_T) if (any(thermal_type == THERMAL_conduction_ID)) call thermal_conduction_init(homogenization_T) diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 new file mode 100644 index 000000000..479318340 --- /dev/null +++ b/src/homogenization_damage.f90 @@ -0,0 +1,40 @@ +!-------------------------------------------------------------------------------------------------- +!> @author Martin Diehl, KU Leuven +!-------------------------------------------------------------------------------------------------- +submodule(homogenization) homogenization_damage + + +contains + +!-------------------------------------------------------------------------------------------------- +!> @brief Allocate variables and set parameters. +!-------------------------------------------------------------------------------------------------- +module subroutine damage_init() + + + print'(/,a)', ' <<<+- homogenization_damage init -+>>>' + + allocate(homogenization_phi(discretization_nIPs*discretization_Nelems)) + allocate(homogenization_dot_phi(discretization_nIPs*discretization_Nelems)) + +end subroutine damage_init + + +!-------------------------------------------------------------------------------------------------- +!> @brief Partition temperature onto the individual constituents. +!-------------------------------------------------------------------------------------------------- +module subroutine damage_partition(phi,ce) + + real(pReal), intent(in) :: phi + integer, intent(in) :: ce + + integer :: co + + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) + call constitutive_damage_set_phi(phi,co,ce) + enddo + +end subroutine damage_partition + + +end submodule homogenization_damage From 75024433aa7e1e13cad438e8c1c104a3787959cd Mon Sep 17 00:00:00 2001 From: Franz Roters Date: Fri, 22 Jan 2021 14:24:49 +0100 Subject: [PATCH 135/352] updated tests --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 72661176e..8b9836aaf 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 72661176e9055cf6ec106bb61c50482c5bc78de8 +Subproject commit 8b9836aaf5798727d96a316a2eb27df03bbd2d07 From c3ca61c3af533109890a87cd2a27897466909731 Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 22 Jan 2021 16:13:25 +0100 Subject: [PATCH 136/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-329-gda93031cb --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index d2cad87cb..5190c13c9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-314-g388e23348 +v3.0.0-alpha2-329-gda93031cb From 014378d49c6f10472d5cae65b8cdcdec80733cc3 Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 22 Jan 2021 18:21:50 +0100 Subject: [PATCH 137/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-339-g6fe8077b8 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index d2cad87cb..094d0eb7c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-314-g388e23348 +v3.0.0-alpha2-339-g6fe8077b8 From c729e7d53fcab996ad77dd3c3ff7756efc539059 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 09:39:40 +0100 Subject: [PATCH 138/352] cell-based indexing --- src/constitutive.f90 | 20 +++++++++----------- src/constitutive_mech.f90 | 12 +++++------- src/homogenization.f90 | 10 ++++------ 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 16f3d3b59..16278957a 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -137,8 +137,8 @@ module constitutive end subroutine thermal_forward - module subroutine mech_restore(ip,el,includeL) - integer, intent(in) :: ip, el + module subroutine mech_restore(ce,includeL) + integer, intent(in) :: ce logical, intent(in) :: includeL end subroutine mech_restore @@ -497,26 +497,24 @@ end subroutine constitutive_allocateState !-------------------------------------------------------------------------------------------------- !> @brief Restore data after homog cutback. !-------------------------------------------------------------------------------------------------- -subroutine constitutive_restore(ip,el,includeL) +subroutine constitutive_restore(ce,includeL) logical, intent(in) :: includeL - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce integer :: & co, & !< constituent number so - do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - do so = 1, phase_Nsources(material_phaseAt(co,el)) - damageState(material_phaseAt(co,el))%p(so)%state( :,material_phasememberAt(co,ip,el)) = & - damageState(material_phaseAt(co,el))%p(so)%partitionedState0(:,material_phasememberAt(co,ip,el)) + do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce)) + do so = 1, phase_Nsources(material_phaseAt2(co,ce)) + damageState(material_phaseAt2(co,ce))%p(so)%state( :,material_phasememberAt2(co,ce)) = & + damageState(material_phaseAt2(co,ce))%p(so)%partitionedState0(:,material_phasememberAt2(co,ce)) enddo enddo - call mech_restore(ip,el,includeL) + call mech_restore(ce,includeL) end subroutine constitutive_restore diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index cd1dedb61..d54367ad6 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1656,11 +1656,9 @@ end function crystallite_stress !-------------------------------------------------------------------------------------------------- !> @brief Restore data after homog cutback. !-------------------------------------------------------------------------------------------------- -module subroutine mech_restore(ip,el,includeL) +module subroutine mech_restore(ce,includeL) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce logical, intent(in) :: & includeL !< protect agains fake cutback @@ -1668,9 +1666,9 @@ module subroutine mech_restore(ip,el,includeL) co, ph, me - do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - ph = material_phaseAt(co,el) - me = material_phaseMemberAt(co,ip,el) + do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce)) + ph = material_phaseAt2(co,ce) + me = material_phaseMemberAt2(co,ce) if (includeL) then constitutive_mech_Lp(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) constitutive_mech_Li(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index ed9b7fead..627c7c36e 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -190,9 +190,9 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE ho = material_homogenizationAt(el) myNgrains = homogenization_Nconstituents(ho) do ip = FEsolving_execIP(1),FEsolving_execIP(2) - me = material_homogenizationMemberAt(ip,el) -!-------------------------------------------------------------------------------------------------- -! initialize restoration points + ce = (el-1)*discretization_nIPs + ip + me = material_homogenizationMemberAt2(ce) + call constitutive_initializeRestorationPoints(ip,el) subFrac = 0.0_pReal @@ -226,7 +226,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE else ! cutback makes sense subStep = num%subStepSizeHomog * subStep ! crystallite had severe trouble, so do a significant cutback - call constitutive_restore(ip,el,subStep < 1.0_pReal) + call constitutive_restore(ce,subStep < 1.0_pReal) if(homogState(ho)%sizeState > 0) homogState(ho)%State(:,me) = homogState(ho)%subState0(:,me) if(damageState_h(ho)%sizeState > 0) damageState_h(ho)%State(:,me) = damageState_h(ho)%subState0(:,me) @@ -243,7 +243,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE ! deformation partitioning if (.not. doneAndHappy(1)) then - ce = (el-1)*discretization_nIPs + ip call mech_partition( homogenization_F0(1:3,1:3,ce) & + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce))*(subStep+subFrac), & ip,el) @@ -255,7 +254,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if (.not. converged) then doneAndHappy = [.true.,.false.] else - ce = (el-1)*discretization_nIPs + ip doneAndHappy = mech_updateState(dt*subStep, & homogenization_F0(1:3,1:3,ce) & + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce)) & From 4f059910ab286413190791745dbcb757befb55d7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 10:39:32 +0100 Subject: [PATCH 139/352] fix broken statistics reporting in case of multi-physics --- src/grid/DAMASK_grid.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 02d7b4cc3..60c386c75 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -425,7 +425,7 @@ program DAMASK_grid guess = .true. ! start guessing after first converged (sub)inc if (worldrank == 0) then write(statUnit,*) totalIncsCounter, time, cutBackLevel, & - solres%converged, solres%iterationsNeeded + solres(1)%converged, solres(1)%iterationsNeeded flush(statUnit) endif elseif (cutBackLevel < maxCutBack) then ! further cutbacking tolerated? From fede1dcd09e80e0a61baeb1b82f832b753668174 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 11:16:17 +0100 Subject: [PATCH 140/352] dot_T is needed --- src/constitutive_thermal.f90 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 2746ff889..610b0b4a6 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -10,9 +10,9 @@ submodule(constitutive) constitutive_thermal end enum type :: tDataContainer - real(pReal), dimension(:), allocatable :: T + real(pReal), dimension(:), allocatable :: T, dot_T end type tDataContainer - integer(kind(THERMAL_UNDEFINED_ID)), dimension(:,:), allocatable :: & + integer(kind(THERMAL_UNDEFINED_ID)), dimension(:,:), allocatable :: & thermal_source type(tDataContainer), dimension(:), allocatable :: current @@ -94,6 +94,7 @@ module subroutine thermal_init(phases) Nconstituents = count(material_phaseAt == ph) * discretization_nIPs allocate(current(ph)%T(Nconstituents),source=300.0_pReal) + allocate(current(ph)%dot_T(Nconstituents),source=0.0_pReal) phase => phases%get(ph) if(phase%contains('thermal')) then thermal => phase%get('thermal') @@ -147,13 +148,11 @@ module subroutine constitutive_thermal_getRate(TDot, ip, el) integer :: & ph, & homog, & - instance, & me, & so, & co homog = material_homogenizationAt(el) - instance = thermal_typeInstance(homog) TDot = 0.0_pReal do co = 1, homogenization_Nconstituents(homog) From 983b59fe1efaf03395a5a0cf338fc9b340f3a341 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 11:19:10 +0100 Subject: [PATCH 141/352] simpler access pattern --- src/constitutive.f90 | 14 +++----------- src/constitutive_mech.f90 | 6 ++++-- src/kinematics_thermal_expansion.f90 | 20 +++++++------------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 16278957a..e05336cc2 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -245,9 +245,6 @@ module constitutive end function constitutive_homogenizedC - - - module subroutine constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) integer, intent(in) :: & ip, & !< integration point number @@ -317,11 +314,9 @@ module constitutive dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) end subroutine kinematics_slipplane_opening_LiAndItsTangent - module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, co, ip, el) - integer, intent(in) :: & - co, & !< grain number - ip, & !< integration point number - el !< element number + module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) + integer, intent(in) :: ph, me + !< element number real(pReal), intent(out), dimension(3,3) :: & Li !< thermal velocity gradient real(pReal), intent(out), dimension(3,3,3,3) :: & @@ -764,9 +759,6 @@ function crystallite_push33ToRef(co,ip,el, tensor33) end function crystallite_push33ToRef - - - !-------------------------------------------------------------------------------------------------- !> @brief determines whether a point is converged !-------------------------------------------------------------------------------------------------- diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index d54367ad6..fe07d2328 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1959,7 +1959,7 @@ subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & detFi integer :: & k, i, j, & - instance, of + instance, of, me, ph Li = 0.0_pReal dLi_dS = 0.0_pReal @@ -1985,7 +1985,9 @@ subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & case (KINEMATICS_slipplane_opening_ID) kinematicsType call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) case (KINEMATICS_thermal_expansion_ID) kinematicsType - call kinematics_thermal_expansion_LiAndItsTangent(my_Li, my_dLi_dS, co, ip, el) + me = material_phaseMemberAt(co,ip,el) + ph = material_phaseAt(co,el) + call kinematics_thermal_expansion_LiAndItsTangent(my_Li, my_dLi_dS, ph,me) case default kinematicsType my_Li = 0.0_pReal my_dLi_dS = 0.0_pReal diff --git a/src/kinematics_thermal_expansion.f90 b/src/kinematics_thermal_expansion.f90 index 6d4a39632..6e4fa8263 100644 --- a/src/kinematics_thermal_expansion.f90 +++ b/src/kinematics_thermal_expansion.f90 @@ -84,12 +84,9 @@ end function kinematics_thermal_expansion_init !-------------------------------------------------------------------------------------------------- !> @brief constitutive equation for calculating the velocity gradient !-------------------------------------------------------------------------------------------------- -module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, co, ip, el) +module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) - integer, intent(in) :: & - co, & !< grain number - ip, & !< integration point number - el !< element number + integer, intent(in) :: ph, me real(pReal), intent(out), dimension(3,3) :: & Li !< thermal velocity gradient real(pReal), intent(out), dimension(3,3,3,3) :: & @@ -98,16 +95,13 @@ module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, c integer :: & phase, & homog - real(pReal) :: & - T, TDot + real(pReal) :: T, dot_T - phase = material_phaseAt(co,el) - homog = material_homogenizationAt(el) - T = temperature(homog)%p(material_homogenizationMemberAt(ip,el)) - TDot = temperatureRate(homog)%p(material_homogenizationMemberAt(ip,el)) + T = current(ph)%T(me) + dot_T = current(ph)%dot_T(me) - associate(prm => param(kinematics_thermal_expansion_instance(phase))) - Li = TDot * ( & + associate(prm => param(kinematics_thermal_expansion_instance(ph))) + Li = dot_T * ( & prm%A(1:3,1:3,1)*(T - prm%T_ref)**0 & ! constant coefficient + prm%A(1:3,1:3,2)*(T - prm%T_ref)**1 & ! linear coefficient + prm%A(1:3,1:3,3)*(T - prm%T_ref)**2 & ! quadratic coefficient From 9f3fc6832531697307dc34eb5ac732b09a05a96a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 12:14:45 +0100 Subject: [PATCH 142/352] partitionedState not needed --- src/constitutive.f90 | 8 -------- src/constitutive_mech.f90 | 3 --- src/constitutive_thermal.f90 | 24 +++--------------------- src/homogenization.f90 | 1 - 4 files changed, 3 insertions(+), 33 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index e05336cc2..6cf7b5e46 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -120,10 +120,6 @@ module constitutive integer, intent(in) :: ph, me end subroutine mech_initializeRestorationPoints - module subroutine constitutive_thermal_initializeRestorationPoints(ph,me) - integer, intent(in) :: ph, me - end subroutine constitutive_thermal_initializeRestorationPoints - module subroutine mech_windForward(ph,me) integer, intent(in) :: ph, me @@ -364,7 +360,6 @@ module constitutive constitutive_mech_setF, & constitutive_mech_getF, & constitutive_initializeRestorationPoints, & - constitutive_thermal_initializeRestorationPoints, & constitutive_windForward, & KINEMATICS_UNDEFINED_ID ,& KINEMATICS_CLEAVAGE_OPENING_ID, & @@ -631,9 +626,6 @@ subroutine crystallite_init() do so = 1, phase_Nsources(ph) allocate(damageState(ph)%p(so)%subState0,source=damageState(ph)%p(so)%state0) ! ToDo: hack enddo - do so = 1, thermal_Nsources(ph) - allocate(thermalState(ph)%p(so)%subState0,source=thermalState(ph)%p(so)%state0) ! ToDo: hack - enddo enddo print'(a42,1x,i10)', ' # of elements: ', eMax diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index fe07d2328..56e03ac6f 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -1586,9 +1586,6 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) do so = 1, phase_Nsources(ph) damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%partitionedState0(:,me) enddo - do so = 1, thermal_Nsources(ph) - thermalState(ph)%p(so)%subState0(:,me) = thermalState(ph)%p(so)%partitionedState0(:,me) - enddo subFp0 = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) subFi0 = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) subF0 = constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 610b0b4a6..a82262e81 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -116,8 +116,8 @@ module subroutine thermal_init(phases) PhaseLoop2:do ph = 1,phases%length do so = 1,thermal_Nsources(ph) - thermalState(ph)%p(so)%partitionedState0 = thermalState(ph)%p(so)%state0 - thermalState(ph)%p(so)%state = thermalState(ph)%p(so)%partitionedState0 + deallocate(thermalState(ph)%p(so)%partitionedState0) + thermalState(ph)%p(so)%state = thermalState(ph)%p(so)%state0 enddo thermal_source_maxSizeDotState = max(thermal_source_maxSizeDotState, & @@ -210,9 +210,6 @@ module function thermal_stress(Delta_t,ph,me) result(converged_) integer :: so - do so = 1, thermal_Nsources(ph) - thermalState(ph)%p(so)%state(:,me) = thermalState(ph)%p(so)%subState0(:,me) - enddo converged_ = .not. integrateThermalState(Delta_t,ph,me) end function thermal_stress @@ -237,28 +234,13 @@ function integrateThermalState(Delta_t, ph,me) result(broken) do so = 1, thermal_Nsources(ph) sizeDotState = thermalState(ph)%p(so)%sizeDotState - thermalState(ph)%p(so)%state(1:sizeDotState,me) = thermalState(ph)%p(so)%subState0(1:sizeDotState,me) & + thermalState(ph)%p(so)%state(1:sizeDotState,me) = thermalState(ph)%p(so)%state0(1:sizeDotState,me) & + thermalState(ph)%p(so)%dotState(1:sizeDotState,me) * Delta_t enddo end function integrateThermalState -module subroutine constitutive_thermal_initializeRestorationPoints(ph,me) - - integer, intent(in) :: ph, me - - integer :: so - - - do so = 1, size(thermalState(ph)%p) - thermalState(ph)%p(so)%partitionedState0(:,me) = thermalState(ph)%p(so)%state0(:,me) - enddo - -end subroutine constitutive_thermal_initializeRestorationPoints - - - module subroutine thermal_forward() integer :: ph, so diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 627c7c36e..86caafef3 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -279,7 +279,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE call thermal_partition(homogenization_T(ce),ce) do co = 1, homogenization_Nconstituents(ho) ph = material_phaseAt(co,el) - call constitutive_thermal_initializeRestorationPoints(ph,material_phaseMemberAt(co,ip,el)) if (.not. thermal_stress(dt,ph,material_phaseMemberAt(co,ip,el))) then if (.not. terminallyIll) & ! so first signals terminally ill... print*, ' Integration point ', ip,' at element ', el, ' terminally ill' From a933fe57e70e27e5e596a1a6b0b7b1c3441e3f0c Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 12:15:18 +0100 Subject: [PATCH 143/352] data structures for storing T at the homogenization level similar to thermal_conduction, better than homogenization_T --- src/homogenization_thermal.f90 | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index de91a98d6..ce55d1573 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -4,6 +4,21 @@ submodule(homogenization) homogenization_thermal + type :: tDataContainer + real(pReal), dimension(:), allocatable :: T, dot_T + end type tDataContainer + + type(tDataContainer), dimension(:), allocatable :: current + + type :: tParameters + character(len=pStringLen), allocatable, dimension(:) :: & + output + end type tParameters + + type(tparameters), dimension(:), allocatable :: & + param + + contains !-------------------------------------------------------------------------------------------------- @@ -11,12 +26,41 @@ contains !-------------------------------------------------------------------------------------------------- module subroutine thermal_init() + class(tNode), pointer :: & + configHomogenizations, & + configHomogenization, & + configHomogenizationThermal + integer :: ho + print'(/,a)', ' <<<+- homogenization_thermal init -+>>>' + allocate(homogenization_T(discretization_nIPs*discretization_Nelems)) allocate(homogenization_dot_T(discretization_nIPs*discretization_Nelems)) + configHomogenizations => config_material%get('homogenization') + allocate(param(configHomogenizations%length)) + allocate(current(configHomogenizations%length)) + + do ho = 1, configHomogenizations%length + allocate(current(ho)%T(count(material_homogenizationAt2==ho)), source=thermal_initialT(ho)) + allocate(current(ho)%dot_T(count(material_homogenizationAt2==ho)), source=0.0_pReal) + configHomogenization => configHomogenizations%get(ho) + associate(prm => param(ho)) + if (configHomogenization%contains('thermal')) then + configHomogenizationThermal => configHomogenization%get('thermal') +#if defined (__GFORTRAN__) + prm%output = output_asStrings(configHomogenizationThermal) +#else + prm%output = configHomogenizationThermal%get_asStrings('output',defaultVal=emptyStringArray) +#endif + else + prm%output = emptyStringArray + endif + end associate + enddo + end subroutine thermal_init From e22d76be9e309d28a7024dc4526b57ff5d486da1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 13:26:01 +0100 Subject: [PATCH 144/352] using new structure for thermal --- src/constitutive.f90 | 12 ++-- src/constitutive_thermal.f90 | 7 ++- src/grid/grid_thermal_spectral.f90 | 12 +++- src/homogenization.f90 | 34 ++++++++++- src/homogenization_thermal.f90 | 95 +++++++++++++++++++++++++++++- src/thermal_conduction.f90 | 87 --------------------------- 6 files changed, 142 insertions(+), 105 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 6cf7b5e46..149d09a49 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -200,11 +200,11 @@ module constitutive integer, intent(in) :: co, ip, el end subroutine constitutive_mech_setF - module subroutine constitutive_thermal_setT(T,co,ce) - real(pReal), intent(in) :: T - integer, intent(in) :: co, ce - end subroutine constitutive_thermal_setT - + module subroutine constitutive_thermal_setField(T,dot_T, co,ce) + real(pReal), intent(in) :: T, dot_T + integer, intent(in) :: ce, co + end subroutine constitutive_thermal_setField + module subroutine constitutive_damage_set_phi(phi,co,ce) real(pReal), intent(in) :: phi integer, intent(in) :: co, ce @@ -353,7 +353,7 @@ module constitutive constitutive_restartWrite, & constitutive_restartRead, & integrateDamageState, & - constitutive_thermal_setT, & + constitutive_thermal_setField, & constitutive_damage_set_phi, & constitutive_damage_get_phi, & constitutive_mech_getP, & diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index a82262e81..57b8a3117 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -272,15 +272,16 @@ end function thermal_T !---------------------------------------------------------------------------------------------- !< @brief Set temperature !---------------------------------------------------------------------------------------------- -module subroutine constitutive_thermal_setT(T,co,ce) +module subroutine constitutive_thermal_setField(T,dot_T, co,ce) - real(pReal), intent(in) :: T + real(pReal), intent(in) :: T, dot_T integer, intent(in) :: ce, co current(material_phaseAt2(co,ce))%T(material_phaseMemberAt2(co,ce)) = T + current(material_phaseAt2(co,ce))%dot_T(material_phaseMemberAt2(co,ce)) = dot_T -end subroutine constitutive_thermal_setT +end subroutine constitutive_thermal_setField diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index d164f11e7..44d9e22b1 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -191,6 +191,9 @@ function grid_thermal_spectral_solution(timeinc) result(solution) call thermal_conduction_putTemperatureAndItsRate(T_current(i,j,k), & (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & 1,ce) + call homogenization_thermal_setField(T_current(i,j,k), & + (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & + ce) homogenization_T(ce) = T_current(i,j,k) enddo; enddo; enddo @@ -233,6 +236,9 @@ subroutine grid_thermal_spectral_forward(cutBack) (T_current(i,j,k) - & T_lastInc(i,j,k))/params%timeinc, & 1,ce) + call homogenization_thermal_setField(T_current(i,j,k), & + (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & + ce) homogenization_T(ce) = T_current(i,j,k) enddo; enddo; enddo else @@ -283,8 +289,8 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) ce = ce + 1 call thermal_conduction_getSource(Tdot, 1,ce) scalarField_real(i,j,k) = params%timeinc*(scalarField_real(i,j,k) + Tdot) & - + thermal_conduction_getMassDensity (1,ce)* & - thermal_conduction_getSpecificHeat(1,ce)*(T_lastInc(i,j,k) - & + + thermal_conduction_getMassDensity (ce)* & + thermal_conduction_getSpecificHeat(ce)*(T_lastInc(i,j,k) - & T_current(i,j,k))& + mu_ref*T_current(i,j,k) enddo; enddo; enddo @@ -315,7 +321,7 @@ subroutine updateReference do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) ce = ce + 1 K_ref = K_ref + thermal_conduction_getConductivity(1,ce) - mu_ref = mu_ref + thermal_conduction_getMassDensity(1,ce)* thermal_conduction_getSpecificHeat(1,ce) + mu_ref = mu_ref + thermal_conduction_getMassDensity(ce)* thermal_conduction_getSpecificHeat(ce) enddo; enddo; enddo K_ref = K_ref*wgt call MPI_Allreduce(MPI_IN_PLACE,K_ref,9,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD,ierr) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 86caafef3..f316d3969 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -75,8 +75,7 @@ module homogenization el !< element number end subroutine mech_partition - module subroutine thermal_partition(T,ce) - real(pReal), intent(in) :: T + module subroutine thermal_partition(ce) integer, intent(in) :: ce end subroutine thermal_partition @@ -112,11 +111,40 @@ module homogenization logical, dimension(2) :: doneAndHappy end function mech_updateState + + module function thermal_conduction_getConductivity(ip,el) result(K) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), dimension(3,3) :: K + + end function thermal_conduction_getConductivity + + module function thermal_conduction_getSpecificHeat(ce) result(c_P) + integer, intent(in) :: ce + real(pReal) :: c_P + end function thermal_conduction_getSpecificHeat + + module function thermal_conduction_getMassDensity(ce) result(rho) + integer, intent(in) :: ce + real(pReal) :: rho + end function thermal_conduction_getMassDensity + + module subroutine homogenization_thermal_setField(T,dot_T, ce) + integer, intent(in) :: ce + real(pReal), intent(in) :: T, dot_T + end subroutine homogenization_thermal_setField + end interface public :: & homogenization_init, & materialpoint_stressAndItsTangent, & + thermal_conduction_getSpecificHeat, & + thermal_conduction_getConductivity, & + thermal_conduction_getMassDensity, & + homogenization_thermal_setfield, & homogenization_forward, & homogenization_results, & homogenization_restartRead, & @@ -276,7 +304,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE ho = material_homogenizationAt(el) do ip = FEsolving_execIP(1),FEsolving_execIP(2) ce = (el-1)*discretization_nIPs + ip - call thermal_partition(homogenization_T(ce),ce) + call thermal_partition(ce) do co = 1, homogenization_Nconstituents(ho) ph = material_phaseAt(co,el) if (.not. thermal_stress(dt,ph,material_phaseMemberAt(co,ip,el))) then diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index ce55d1573..80137f13a 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -3,6 +3,7 @@ !-------------------------------------------------------------------------------------------------- submodule(homogenization) homogenization_thermal + use lattice type :: tDataContainer real(pReal), dimension(:), allocatable :: T, dot_T @@ -67,15 +68,18 @@ end subroutine thermal_init !-------------------------------------------------------------------------------------------------- !> @brief Partition temperature onto the individual constituents. !-------------------------------------------------------------------------------------------------- -module subroutine thermal_partition(T,ce) +module subroutine thermal_partition(ce) - real(pReal), intent(in) :: T integer, intent(in) :: ce + real(pReal) :: T, dot_T integer :: co + + T = current(material_homogenizationAt2(ce))%T(material_homogenizationMemberAt2(ce)) + dot_T = current(material_homogenizationAt2(ce))%dot_T(material_homogenizationMemberAt2(ce)) do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) - call constitutive_thermal_setT(T,co,ce) + call constitutive_thermal_setField(T,dot_T,co,ce) enddo end subroutine thermal_partition @@ -93,4 +97,89 @@ module subroutine thermal_homogenize(ip,el) end subroutine thermal_homogenize +!-------------------------------------------------------------------------------------------------- +!> @brief return homogenized thermal conductivity in reference configuration +!-------------------------------------------------------------------------------------------------- +module function thermal_conduction_getConductivity(ip,el) result(K) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), dimension(3,3) :: K + + integer :: & + co + + + K = 0.0_pReal + + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + K = K + crystallite_push33ToRef(co,ip,el,lattice_K(:,:,material_phaseAt(co,el))) + enddo + + K = K / real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) + +end function thermal_conduction_getConductivity + + +!-------------------------------------------------------------------------------------------------- +!> @brief returns homogenized specific heat capacity +!-------------------------------------------------------------------------------------------------- +module function thermal_conduction_getSpecificHeat(ce) result(c_P) + + integer, intent(in) :: ce + real(pReal) :: c_P + + integer :: co + + + c_P = 0.0_pReal + + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) + c_P = c_P + lattice_c_p(material_phaseAt2(co,ce)) + enddo + + c_P = c_P / real(homogenization_Nconstituents(material_homogenizationAt2(ce)),pReal) + +end function thermal_conduction_getSpecificHeat + + +!-------------------------------------------------------------------------------------------------- +!> @brief returns homogenized mass density +!-------------------------------------------------------------------------------------------------- +module function thermal_conduction_getMassDensity(ce) result(rho) + + integer, intent(in) :: ce + real(pReal) :: rho + + integer :: co + + + rho = 0.0_pReal + + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) + rho = rho + lattice_rho(material_phaseAt2(co,ce)) + enddo + + rho = rho / real(homogenization_Nconstituents(material_homogenizationAt2(ce)),pReal) + +end function thermal_conduction_getMassDensity + + + +!-------------------------------------------------------------------------------------------------- +!> @brief Set thermal field and its rate (T and dot_T) +!-------------------------------------------------------------------------------------------------- +module subroutine homogenization_thermal_setField(T,dot_T, ce) + + integer, intent(in) :: ce + real(pReal), intent(in) :: T, dot_T + + + current(material_homogenizationAt2(ce))%T(material_homogenizationMemberAt2(ce)) = T + current(material_homogenizationAt2(ce))%dot_T(material_homogenizationMemberAt2(ce)) = dot_T + + +end subroutine homogenization_thermal_setField + end submodule homogenization_thermal diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index 1711c5512..ccca75026 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -26,9 +26,6 @@ module thermal_conduction public :: & thermal_conduction_init, & thermal_conduction_getSource, & - thermal_conduction_getConductivity, & - thermal_conduction_getSpecificHeat, & - thermal_conduction_getMassDensity, & thermal_conduction_putTemperatureAndItsRate, & thermal_conduction_results @@ -110,90 +107,6 @@ subroutine thermal_conduction_getSource(Tdot, ip,el) end subroutine thermal_conduction_getSource -!-------------------------------------------------------------------------------------------------- -!> @brief return homogenized thermal conductivity in reference configuration -!-------------------------------------------------------------------------------------------------- -function thermal_conduction_getConductivity(ip,el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - real(pReal), dimension(3,3) :: & - thermal_conduction_getConductivity - - integer :: & - co - - - thermal_conduction_getConductivity = 0.0_pReal - - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - thermal_conduction_getConductivity = thermal_conduction_getConductivity + & - crystallite_push33ToRef(co,ip,el,lattice_K(:,:,material_phaseAt(co,el))) - enddo - - thermal_conduction_getConductivity = thermal_conduction_getConductivity & - / real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) - -end function thermal_conduction_getConductivity - - -!-------------------------------------------------------------------------------------------------- -!> @brief returns homogenized specific heat capacity -!-------------------------------------------------------------------------------------------------- -function thermal_conduction_getSpecificHeat(ip,el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - real(pReal) :: & - thermal_conduction_getSpecificHeat - - integer :: & - co - - - thermal_conduction_getSpecificHeat = 0.0_pReal - - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - thermal_conduction_getSpecificHeat = thermal_conduction_getSpecificHeat & - + lattice_c_p(material_phaseAt(co,el)) - enddo - - thermal_conduction_getSpecificHeat = thermal_conduction_getSpecificHeat & - / real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) - -end function thermal_conduction_getSpecificHeat - - -!-------------------------------------------------------------------------------------------------- -!> @brief returns homogenized mass density -!-------------------------------------------------------------------------------------------------- -function thermal_conduction_getMassDensity(ip,el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - real(pReal) :: & - thermal_conduction_getMassDensity - - integer :: & - co - - - thermal_conduction_getMassDensity = 0.0_pReal - - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - thermal_conduction_getMassDensity = thermal_conduction_getMassDensity & - + lattice_rho(material_phaseAt(co,el)) - enddo - - thermal_conduction_getMassDensity = thermal_conduction_getMassDensity & - / real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) - -end function thermal_conduction_getMassDensity - - !-------------------------------------------------------------------------------------------------- !> @brief updates thermal state with solution from heat conduction PDE !-------------------------------------------------------------------------------------------------- From c2ae2c919be1896d670b940ac2703a1c0f3c8490 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 15:19:57 +0100 Subject: [PATCH 145/352] use new structure --- src/grid/grid_thermal_spectral.f90 | 4 +--- src/homogenization.f90 | 13 +++++++++---- src/homogenization_thermal.f90 | 16 ++++++++++++---- src/thermal_conduction.f90 | 13 +------------ src/thermal_isothermal.f90 | 13 +------------ 5 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 44d9e22b1..4b80c1d72 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -132,7 +132,7 @@ subroutine grid_thermal_spectral_init ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) ce = ce + 1 - T_current(i,j,k) = temperature(material_homogenizationAt(ce))%p(material_homogenizationMemberAt(1,ce)) + T_current(i,j,k) = homogenization_thermal_T(ce) T_lastInc(i,j,k) = T_current(i,j,k) T_stagInc(i,j,k) = T_current(i,j,k) enddo; enddo; enddo @@ -194,7 +194,6 @@ function grid_thermal_spectral_solution(timeinc) result(solution) call homogenization_thermal_setField(T_current(i,j,k), & (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & ce) - homogenization_T(ce) = T_current(i,j,k) enddo; enddo; enddo call VecMin(solution_vec,devNull,T_min,ierr); CHKERRQ(ierr) @@ -239,7 +238,6 @@ subroutine grid_thermal_spectral_forward(cutBack) call homogenization_thermal_setField(T_current(i,j,k), & (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & ce) - homogenization_T(ce) = T_current(i,j,k) enddo; enddo; enddo else T_lastInc = T_current diff --git a/src/homogenization.f90 b/src/homogenization.f90 index f316d3969..51d339da9 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -28,8 +28,6 @@ module homogenization !-------------------------------------------------------------------------------------------------- ! General variables for the homogenization at a material point real(pReal), dimension(:), allocatable, public :: & - homogenization_T, & - homogenization_dot_T, & homogenization_phi, & homogenization_dot_phi real(pReal), dimension(:,:,:), allocatable, public :: & @@ -136,6 +134,12 @@ module homogenization real(pReal), intent(in) :: T, dot_T end subroutine homogenization_thermal_setField + + module function homogenization_thermal_T(ce) result(T) + integer, intent(in) :: ce + real(pReal) :: T + end function homogenization_thermal_T + end interface public :: & @@ -145,6 +149,7 @@ module homogenization thermal_conduction_getConductivity, & thermal_conduction_getMassDensity, & homogenization_thermal_setfield, & + homogenization_thermal_T, & homogenization_forward, & homogenization_results, & homogenization_restartRead, & @@ -182,8 +187,8 @@ subroutine homogenization_init() call thermal_init() call damage_init() - if (any(thermal_type == THERMAL_isothermal_ID)) call thermal_isothermal_init(homogenization_T) - if (any(thermal_type == THERMAL_conduction_ID)) call thermal_conduction_init(homogenization_T) + if (any(thermal_type == THERMAL_isothermal_ID)) call thermal_isothermal_init() + if (any(thermal_type == THERMAL_conduction_ID)) call thermal_conduction_init() if (any(damage_type == DAMAGE_none_ID)) call damage_none_init if (any(damage_type == DAMAGE_nonlocal_ID)) call damage_nonlocal_init diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index 80137f13a..b9cbccc66 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -37,9 +37,6 @@ module subroutine thermal_init() print'(/,a)', ' <<<+- homogenization_thermal init -+>>>' - allocate(homogenization_T(discretization_nIPs*discretization_Nelems)) - allocate(homogenization_dot_T(discretization_nIPs*discretization_Nelems)) - configHomogenizations => config_material%get('homogenization') allocate(param(configHomogenizations%length)) allocate(current(configHomogenizations%length)) @@ -92,7 +89,7 @@ module subroutine thermal_homogenize(ip,el) integer, intent(in) :: ip,el - call constitutive_thermal_getRate(homogenization_dot_T((el-1)*discretization_nIPs+ip), ip,el) + !call constitutive_thermal_getRate(homogenization_dot_T((el-1)*discretization_nIPs+ip), ip,el) end subroutine thermal_homogenize @@ -182,4 +179,15 @@ module subroutine homogenization_thermal_setField(T,dot_T, ce) end subroutine homogenization_thermal_setField + +module function homogenization_thermal_T(ce) result(T) + + integer, intent(in) :: ce + real(pReal) :: T + + T = current(material_homogenizationAt2(ce))%T(material_homogenizationMemberAt2(ce)) + +end function homogenization_thermal_T + + end submodule homogenization_thermal diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index ccca75026..84521afde 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -36,9 +36,7 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -subroutine thermal_conduction_init(T) - - real(pReal), dimension(:), intent(inout) :: T +subroutine thermal_conduction_init() integer :: Ninstances,Nmaterialpoints,ho,ip,el,ce class(tNode), pointer :: & @@ -73,15 +71,6 @@ subroutine thermal_conduction_init(T) end associate enddo - ce = 0 - do el = 1, discretization_Nelems - do ip = 1, discretization_nIPs - ce = ce + 1 - ho = material_homogenizationAt(el) - if (thermal_type(ho) == THERMAL_conduction_ID) T(ce) = thermal_initialT(ho) - enddo - enddo - end subroutine thermal_conduction_init diff --git a/src/thermal_isothermal.f90 b/src/thermal_isothermal.f90 index 09e35931e..e3dee2901 100644 --- a/src/thermal_isothermal.f90 +++ b/src/thermal_isothermal.f90 @@ -16,9 +16,7 @@ contains !-------------------------------------------------------------------------------------------------- !> @brief allocates fields, reads information from material configuration file !-------------------------------------------------------------------------------------------------- -subroutine thermal_isothermal_init(T) - - real(pReal), dimension(:), intent(inout) :: T +subroutine thermal_isothermal_init() integer :: Ninstances,Nmaterialpoints,ho,ip,el,ce @@ -34,15 +32,6 @@ subroutine thermal_isothermal_init(T) enddo - ce = 0 - do el = 1, discretization_Nelems - do ip = 1, discretization_nIPs - ce = ce + 1 - ho = material_homogenizationAt(el) - if (thermal_type(ho) == THERMAL_isothermal_ID) T(ce) = thermal_initialT(ho) - enddo - enddo - end subroutine thermal_isothermal_init end module thermal_isothermal From 599dc2a2c67a033b9ac220a59eeb5d5480fb163b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 16:34:51 +0100 Subject: [PATCH 146/352] base HDF5 output on new data --- src/homogenization.f90 | 4 +++ src/homogenization_thermal.f90 | 23 +++++++++++++++ src/thermal_conduction.f90 | 52 ++-------------------------------- 3 files changed, 30 insertions(+), 49 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 51d339da9..67c5ab001 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -134,6 +134,10 @@ module homogenization real(pReal), intent(in) :: T, dot_T end subroutine homogenization_thermal_setField + module subroutine thermal_conduction_results(ho,group) + integer, intent(in) :: ho + character(len=*), intent(in) :: group + end subroutine thermal_conduction_results module function homogenization_thermal_T(ce) result(T) integer, intent(in) :: ce diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index b9cbccc66..cfbd2136d 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -180,6 +180,29 @@ module subroutine homogenization_thermal_setField(T,dot_T, ce) end subroutine homogenization_thermal_setField + +!-------------------------------------------------------------------------------------------------- +!> @brief writes results to HDF5 output file +!-------------------------------------------------------------------------------------------------- +module subroutine thermal_conduction_results(ho,group) + + integer, intent(in) :: ho + character(len=*), intent(in) :: group + + integer :: o + + associate(prm => param(ho)) + outputsLoop: do o = 1,size(prm%output) + select case(trim(prm%output(o))) + case('T') + call results_writeDataset(group,current(ho)%T,'T','temperature','K') + end select + enddo outputsLoop + end associate + +end subroutine thermal_conduction_results + + module function homogenization_thermal_T(ce) result(T) integer, intent(in) :: ce diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 index 84521afde..613612113 100644 --- a/src/thermal_conduction.f90 +++ b/src/thermal_conduction.f90 @@ -15,19 +15,10 @@ module thermal_conduction implicit none private - type :: tParameters - character(len=pStringLen), allocatable, dimension(:) :: & - output - end type tParameters - - type(tparameters), dimension(:), allocatable :: & - param - public :: & thermal_conduction_init, & thermal_conduction_getSource, & - thermal_conduction_putTemperatureAndItsRate, & - thermal_conduction_results + thermal_conduction_putTemperatureAndItsRate contains @@ -38,37 +29,22 @@ contains !-------------------------------------------------------------------------------------------------- subroutine thermal_conduction_init() - integer :: Ninstances,Nmaterialpoints,ho,ip,el,ce + integer :: Nmaterialpoints,ho class(tNode), pointer :: & - material_homogenization, & - homog, & - homogThermal + material_homogenization print'(/,a)', ' <<<+- thermal_conduction init -+>>>'; flush(6) - Ninstances = count(thermal_type == THERMAL_conduction_ID) - allocate(param(Ninstances)) - material_homogenization => config_material%get('homogenization') do ho = 1, size(material_name_homogenization) if (thermal_type(ho) /= THERMAL_conduction_ID) cycle - homog => material_homogenization%get(ho) - homogThermal => homog%get('thermal') - associate(prm => param(thermal_typeInstance(ho))) - -#if defined (__GFORTRAN__) - prm%output = output_asStrings(homogThermal) -#else - prm%output = homogThermal%get_asStrings('output',defaultVal=emptyStringArray) -#endif Nmaterialpoints=count(material_homogenizationAt==ho) allocate (temperature (ho)%p(Nmaterialpoints), source=thermal_initialT(ho)) allocate (temperatureRate(ho)%p(Nmaterialpoints), source=0.0_pReal) - end associate enddo end subroutine thermal_conduction_init @@ -119,26 +95,4 @@ subroutine thermal_conduction_putTemperatureAndItsRate(T,Tdot,ip,el) end subroutine thermal_conduction_putTemperatureAndItsRate -!-------------------------------------------------------------------------------------------------- -!> @brief writes results to HDF5 output file -!-------------------------------------------------------------------------------------------------- -subroutine thermal_conduction_results(homog,group) - - integer, intent(in) :: homog - character(len=*), intent(in) :: group - - integer :: o - - associate(prm => param(damage_typeInstance(homog))) - outputsLoop: do o = 1,size(prm%output) - select case(trim(prm%output(o))) - case('T') - call results_writeDataset(group,temperature(homog)%p,'T',& - 'temperature','K') - end select - enddo outputsLoop - end associate - -end subroutine thermal_conduction_results - end module thermal_conduction From 26c7969837f27aa44a139912d127bfa6af81fd8b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 17:04:41 +0100 Subject: [PATCH 147/352] not needed anymore --- src/CPFEM.f90 | 8 +-- src/DAMASK_marc.f90 | 2 +- src/commercialFEM_fileList.f90 | 2 - src/grid/grid_thermal_spectral.f90 | 8 --- src/homogenization.f90 | 13 ++-- src/homogenization_thermal.f90 | 23 +++++++ src/material.f90 | 6 +- src/thermal_conduction.f90 | 98 ------------------------------ src/thermal_isothermal.f90 | 37 ----------- 9 files changed, 37 insertions(+), 160 deletions(-) delete mode 100644 src/thermal_conduction.f90 delete mode 100644 src/thermal_isothermal.f90 diff --git a/src/CPFEM.f90 b/src/CPFEM.f90 index 240688a8c..713aab5d7 100644 --- a/src/CPFEM.f90 +++ b/src/CPFEM.f90 @@ -180,10 +180,10 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature_inp, dt, elFE, ip, cauchyS if (iand(mode, CPFEM_AGERESULTS) /= 0_pInt) call CPFEM_forward chosenThermal1: select case (thermal_type(material_homogenizationAt(elCP))) - case (THERMAL_conduction_ID) chosenThermal1 - temperature(material_homogenizationAt(elCP))%p(material_homogenizationMemberAt(ip,elCP)) = & - temperature_inp - end select chosenThermal1 + !case (THERMAL_conduction_ID) chosenThermal1 + ! temperature(material_homogenizationAt(elCP))%p(material_homogenizationMemberAt(ip,elCP)) = & + ! temperature_inp + end select chosenThermal1 homogenization_F0(1:3,1:3,ma) = ffn homogenization_F(1:3,1:3,ma) = ffn1 diff --git a/src/DAMASK_marc.f90 b/src/DAMASK_marc.f90 index 9464595b1..360c911ff 100644 --- a/src/DAMASK_marc.f90 +++ b/src/DAMASK_marc.f90 @@ -351,7 +351,7 @@ end subroutine hypela2 !-------------------------------------------------------------------------------------------------- subroutine flux(f,ts,n,time) use prec - use thermal_conduction + use homogenization use discretization_marc implicit none diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 963871c7a..a20fb1cee 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -42,8 +42,6 @@ #include "source_damage_anisoDuctile.f90" #include "kinematics_cleavage_opening.f90" #include "kinematics_slipplane_opening.f90" -#include "thermal_isothermal.f90" -#include "thermal_conduction.f90" #include "damage_none.f90" #include "damage_nonlocal.f90" #include "homogenization.f90" diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 4b80c1d72..866914f5b 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -15,7 +15,6 @@ module grid_thermal_spectral use IO use spectral_utilities use discretization_grid - use thermal_conduction use homogenization use YAML_types use config @@ -188,9 +187,6 @@ function grid_thermal_spectral_solution(timeinc) result(solution) ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) ce = ce + 1 - call thermal_conduction_putTemperatureAndItsRate(T_current(i,j,k), & - (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & - 1,ce) call homogenization_thermal_setField(T_current(i,j,k), & (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & ce) @@ -231,10 +227,6 @@ subroutine grid_thermal_spectral_forward(cutBack) call DMDAVecRestoreArrayF90(dm_local,solution_vec,x_scal,ierr); CHKERRQ(ierr) do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) ce = ce + 1 - call thermal_conduction_putTemperatureAndItsRate(T_current(i,j,k), & - (T_current(i,j,k) - & - T_lastInc(i,j,k))/params%timeinc, & - 1,ce) call homogenization_thermal_setField(T_current(i,j,k), & (T_current(i,j,k)-T_lastInc(i,j,k))/params%timeinc, & ce) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 67c5ab001..64c2aade7 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -12,8 +12,6 @@ module homogenization use material use constitutive use discretization - use thermal_isothermal - use thermal_conduction use damage_none use damage_nonlocal use HDF5_utilities @@ -144,6 +142,13 @@ module homogenization real(pReal) :: T end function homogenization_thermal_T + module subroutine thermal_conduction_getSource(Tdot, ip,el) + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), intent(out) :: Tdot + end subroutine thermal_conduction_getSource + end interface public :: & @@ -152,6 +157,7 @@ module homogenization thermal_conduction_getSpecificHeat, & thermal_conduction_getConductivity, & thermal_conduction_getMassDensity, & + thermal_conduction_getSource, & homogenization_thermal_setfield, & homogenization_thermal_T, & homogenization_forward, & @@ -191,9 +197,6 @@ subroutine homogenization_init() call thermal_init() call damage_init() - if (any(thermal_type == THERMAL_isothermal_ID)) call thermal_isothermal_init() - if (any(thermal_type == THERMAL_conduction_ID)) call thermal_conduction_init() - if (any(damage_type == DAMAGE_none_ID)) call damage_none_init if (any(damage_type == DAMAGE_nonlocal_ID)) call damage_nonlocal_init diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index cfbd2136d..6a12730ac 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -213,4 +213,27 @@ module function homogenization_thermal_T(ce) result(T) end function homogenization_thermal_T + +!-------------------------------------------------------------------------------------------------- +!> @brief return heat generation rate +!-------------------------------------------------------------------------------------------------- +module subroutine thermal_conduction_getSource(Tdot, ip,el) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), intent(out) :: & + Tdot + + integer :: & + homog + + homog = material_homogenizationAt(el) + call constitutive_thermal_getRate(TDot, ip,el) + + Tdot = Tdot/real(homogenization_Nconstituents(homog),pReal) + +end subroutine thermal_conduction_getSource + + end submodule homogenization_thermal diff --git a/src/material.f90 b/src/material.f90 index e165bd466..5f0f86fe5 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -71,9 +71,7 @@ module material material_orientation0 !< initial orientation of each grain,IP,element type(group_float), allocatable, dimension(:), public :: & - temperature, & !< temperature field - damage, & !< damage field - temperatureRate !< temperature change rate field + damage !< damage field public :: & material_init, & @@ -107,9 +105,7 @@ subroutine material_init(restart) allocate(homogState (size(material_name_homogenization))) allocate(damageState_h (size(material_name_homogenization))) - allocate(temperature (size(material_name_homogenization))) allocate(damage (size(material_name_homogenization))) - allocate(temperatureRate (size(material_name_homogenization))) if (.not. restart) then diff --git a/src/thermal_conduction.f90 b/src/thermal_conduction.f90 deleted file mode 100644 index 613612113..000000000 --- a/src/thermal_conduction.f90 +++ /dev/null @@ -1,98 +0,0 @@ -!-------------------------------------------------------------------------------------------------- -!> @author Pratheek Shanthraj, Max-Planck-Institut für Eisenforschung GmbH -!> @brief material subroutine for temperature evolution from heat conduction -!-------------------------------------------------------------------------------------------------- -module thermal_conduction - use prec - use material - use config - use lattice - use results - use constitutive - use YAML_types - use discretization - - implicit none - private - - public :: & - thermal_conduction_init, & - thermal_conduction_getSource, & - thermal_conduction_putTemperatureAndItsRate - -contains - - -!-------------------------------------------------------------------------------------------------- -!> @brief module initialization -!> @details reads in material parameters, allocates arrays, and does sanity checks -!-------------------------------------------------------------------------------------------------- -subroutine thermal_conduction_init() - - integer :: Nmaterialpoints,ho - class(tNode), pointer :: & - material_homogenization - - - print'(/,a)', ' <<<+- thermal_conduction init -+>>>'; flush(6) - - material_homogenization => config_material%get('homogenization') - do ho = 1, size(material_name_homogenization) - if (thermal_type(ho) /= THERMAL_conduction_ID) cycle - - Nmaterialpoints=count(material_homogenizationAt==ho) - - allocate (temperature (ho)%p(Nmaterialpoints), source=thermal_initialT(ho)) - allocate (temperatureRate(ho)%p(Nmaterialpoints), source=0.0_pReal) - - enddo - -end subroutine thermal_conduction_init - - -!-------------------------------------------------------------------------------------------------- -!> @brief return heat generation rate -!-------------------------------------------------------------------------------------------------- -subroutine thermal_conduction_getSource(Tdot, ip,el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - real(pReal), intent(out) :: & - Tdot - - integer :: & - homog - - homog = material_homogenizationAt(el) - call constitutive_thermal_getRate(TDot, ip,el) - - Tdot = Tdot/real(homogenization_Nconstituents(homog),pReal) - -end subroutine thermal_conduction_getSource - - -!-------------------------------------------------------------------------------------------------- -!> @brief updates thermal state with solution from heat conduction PDE -!-------------------------------------------------------------------------------------------------- -subroutine thermal_conduction_putTemperatureAndItsRate(T,Tdot,ip,el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - real(pReal), intent(in) :: & - T, & - Tdot - integer :: & - homog, & - offset - - homog = material_homogenizationAt(el) - offset = material_homogenizationMemberAt(ip,el) - temperature (homog)%p(offset) = T - temperatureRate(homog)%p(offset) = Tdot - -end subroutine thermal_conduction_putTemperatureAndItsRate - - -end module thermal_conduction diff --git a/src/thermal_isothermal.f90 b/src/thermal_isothermal.f90 deleted file mode 100644 index e3dee2901..000000000 --- a/src/thermal_isothermal.f90 +++ /dev/null @@ -1,37 +0,0 @@ -!-------------------------------------------------------------------------------------------------- -!> @author Pratheek Shanthraj, Max-Planck-Institut für Eisenforschung GmbH -!> @brief material subroutine for isothermal temperature field -!-------------------------------------------------------------------------------------------------- -module thermal_isothermal - use prec - use config - use material - use discretization - - implicit none - public - -contains - -!-------------------------------------------------------------------------------------------------- -!> @brief allocates fields, reads information from material configuration file -!-------------------------------------------------------------------------------------------------- -subroutine thermal_isothermal_init() - - integer :: Ninstances,Nmaterialpoints,ho,ip,el,ce - - print'(/,a)', ' <<<+- thermal_isothermal init -+>>>'; flush(6) - - do ho = 1, size(thermal_type) - if (thermal_type(ho) /= THERMAL_isothermal_ID) cycle - - Nmaterialpoints = count(material_homogenizationAt == ho) - - allocate(temperature (ho)%p(Nmaterialpoints),source=thermal_initialT(ho)) - allocate(temperatureRate(ho)%p(Nmaterialpoints),source = 0.0_pReal) - - enddo - -end subroutine thermal_isothermal_init - -end module thermal_isothermal From b58465415b01ba44379bad7e7d2ee15bc1fc580e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 18:20:47 +0100 Subject: [PATCH 148/352] store damage parameter like temperature --- src/grid/grid_damage_spectral.f90 | 2 -- src/homogenization.f90 | 26 ++++++++++++---- src/homogenization_damage.f90 | 49 ++++++++++++++++++++++++++++--- 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/grid/grid_damage_spectral.f90 b/src/grid/grid_damage_spectral.f90 index a891f070d..dc78d9e44 100644 --- a/src/grid/grid_damage_spectral.f90 +++ b/src/grid/grid_damage_spectral.f90 @@ -198,7 +198,6 @@ function grid_damage_spectral_solution(timeinc) result(solution) do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) cell = cell + 1 call damage_nonlocal_putNonLocalDamage(phi_current(i,j,k),1,cell) - homogenization_phi(cell) = phi_current(i,j,k) enddo; enddo; enddo call VecMin(solution_vec,devNull,phi_min,ierr); CHKERRQ(ierr) @@ -236,7 +235,6 @@ subroutine grid_damage_spectral_forward(cutBack) do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) cell = cell + 1 call damage_nonlocal_putNonLocalDamage(phi_current(i,j,k),1,cell) - homogenization_phi(cell) = phi_current(i,j,k) enddo; enddo; enddo else phi_lastInc = phi_current diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 64c2aade7..048bf46df 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -25,9 +25,6 @@ module homogenization !-------------------------------------------------------------------------------------------------- ! General variables for the homogenization at a material point - real(pReal), dimension(:), allocatable, public :: & - homogenization_phi, & - homogenization_dot_phi real(pReal), dimension(:,:,:), allocatable, public :: & homogenization_F0, & !< def grad of IP at start of FE increment homogenization_F !< def grad of IP to be reached at end of FE increment @@ -75,8 +72,7 @@ module homogenization integer, intent(in) :: ce end subroutine thermal_partition - module subroutine damage_partition(phi,ce) - real(pReal), intent(in) :: phi + module subroutine damage_partition(ce) integer, intent(in) :: ce end subroutine damage_partition @@ -330,6 +326,26 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE enddo !$OMP END DO + !$OMP DO PRIVATE(ho,ph,ce) + do el = FEsolving_execElem(1),FEsolving_execElem(2) + if (terminallyIll) continue + ho = material_homogenizationAt(el) + do ip = FEsolving_execIP(1),FEsolving_execIP(2) + ce = (el-1)*discretization_nIPs + ip + call damage_partition(ce) + ! do co = 1, homogenization_Nconstituents(ho) + ! ph = material_phaseAt(co,el) + ! if (.not. thermal_stress(dt,ph,material_phaseMemberAt(co,ip,el))) then + ! if (.not. terminallyIll) & ! so first signals terminally ill... + ! print*, ' Integration point ', ip,' at element ', el, ' terminally ill' + ! terminallyIll = .true. ! ...and kills all others + ! endif + ! call thermal_homogenize(ip,el) + ! enddo + enddo + enddo + !$OMP END DO + !$OMP DO PRIVATE(ho) elementLooping3: do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index 479318340..ad029cce8 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -3,19 +3,58 @@ !-------------------------------------------------------------------------------------------------- submodule(homogenization) homogenization_damage + type :: tDataContainer + real(pReal), dimension(:), allocatable :: phi + end type tDataContainer + + type(tDataContainer), dimension(:), allocatable :: current + + type :: tParameters + character(len=pStringLen), allocatable, dimension(:) :: & + output + end type tParameters + + type(tparameters), dimension(:), allocatable :: & + param contains + !-------------------------------------------------------------------------------------------------- !> @brief Allocate variables and set parameters. !-------------------------------------------------------------------------------------------------- module subroutine damage_init() + class(tNode), pointer :: & + configHomogenizations, & + configHomogenization, & + configHomogenizationDamage + integer :: ho + print'(/,a)', ' <<<+- homogenization_damage init -+>>>' - allocate(homogenization_phi(discretization_nIPs*discretization_Nelems)) - allocate(homogenization_dot_phi(discretization_nIPs*discretization_Nelems)) + + configHomogenizations => config_material%get('homogenization') + allocate(param(configHomogenizations%length)) + allocate(current(configHomogenizations%length)) + + do ho = 1, configHomogenizations%length + allocate(current(ho)%phi(count(material_homogenizationAt2==ho)), source=1.0_pReal) + configHomogenization => configHomogenizations%get(ho) + associate(prm => param(ho)) + if (configHomogenization%contains('damage')) then + configHomogenizationDamage => configHomogenization%get('damage') +#if defined (__GFORTRAN__) + prm%output = output_asStrings(configHomogenizationDamage) +#else + prm%output = configHomogenizationDamage%get_asStrings('output',defaultVal=emptyStringArray) +#endif + else + prm%output = emptyStringArray + endif + end associate + enddo end subroutine damage_init @@ -23,13 +62,15 @@ end subroutine damage_init !-------------------------------------------------------------------------------------------------- !> @brief Partition temperature onto the individual constituents. !-------------------------------------------------------------------------------------------------- -module subroutine damage_partition(phi,ce) +module subroutine damage_partition(ce) - real(pReal), intent(in) :: phi + real(pReal) :: phi integer, intent(in) :: ce integer :: co + + phi = current(material_homogenizationAt2(ce))%phi(material_homogenizationMemberAt2(ce)) do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) call constitutive_damage_set_phi(phi,co,ce) enddo From 1f94a64ca6b1bee8396e7d347de27bc90cc16f88 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 18:47:19 +0100 Subject: [PATCH 149/352] part of homogenization --- src/damage_nonlocal.f90 | 28 ++-------------------------- src/homogenization.f90 | 10 ++++++++++ src/homogenization_damage.f90 | 26 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/damage_nonlocal.f90 b/src/damage_nonlocal.f90 index 4423c1e3a..1ae327833 100644 --- a/src/damage_nonlocal.f90 +++ b/src/damage_nonlocal.f90 @@ -23,7 +23,7 @@ module damage_nonlocal real(pReal) :: & charLength !< characteristic length scale for gradient problems end type tNumerics - + type(tparameters), dimension(:), allocatable :: & param type(tNumerics), private :: & @@ -33,7 +33,6 @@ module damage_nonlocal damage_nonlocal_init, & damage_nonlocal_getSourceAndItsTangent, & damage_nonlocal_getDiffusion, & - damage_nonlocal_getMobility, & damage_nonlocal_putNonLocalDamage, & damage_nonlocal_results @@ -104,7 +103,7 @@ subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ip, phiDot = 0.0_pReal dPhiDot_dPhi = 0.0_pReal - + call constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) phiDot = phiDot/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) dPhiDot_dPhi = dPhiDot_dPhi/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) @@ -139,29 +138,6 @@ function damage_nonlocal_getDiffusion(ip,el) end function damage_nonlocal_getDiffusion -!-------------------------------------------------------------------------------------------------- -!> @brief Returns homogenized nonlocal damage mobility -!-------------------------------------------------------------------------------------------------- -real(pReal) function damage_nonlocal_getMobility(ip,el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - integer :: & - co - - damage_nonlocal_getMobility = 0.0_pReal - - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - damage_nonlocal_getMobility = damage_nonlocal_getMobility + lattice_M(material_phaseAt(co,el)) - enddo - - damage_nonlocal_getMobility = damage_nonlocal_getMobility/& - real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) - -end function damage_nonlocal_getMobility - - !-------------------------------------------------------------------------------------------------- !> @brief updated nonlocal damage field with solution from damage phase field PDE !-------------------------------------------------------------------------------------------------- diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 048bf46df..816da4fa6 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -145,6 +145,15 @@ module homogenization real(pReal), intent(out) :: Tdot end subroutine thermal_conduction_getSource + module function damage_nonlocal_getMobility(ip,el) result(M) + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + integer :: & + co + real(pReal) :: M + end function damage_nonlocal_getMobility + end interface public :: & @@ -154,6 +163,7 @@ module homogenization thermal_conduction_getConductivity, & thermal_conduction_getMassDensity, & thermal_conduction_getSource, & + damage_nonlocal_getMobility, & homogenization_thermal_setfield, & homogenization_thermal_T, & homogenization_forward, & diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index ad029cce8..3a6758914 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -3,6 +3,8 @@ !-------------------------------------------------------------------------------------------------- submodule(homogenization) homogenization_damage + use lattice + type :: tDataContainer real(pReal), dimension(:), allocatable :: phi end type tDataContainer @@ -78,4 +80,28 @@ module subroutine damage_partition(ce) end subroutine damage_partition + +!-------------------------------------------------------------------------------------------------- +!> @brief Returns homogenized nonlocal damage mobility +!-------------------------------------------------------------------------------------------------- +module function damage_nonlocal_getMobility(ip,el) result(M) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + integer :: & + co + real(pReal) :: M + + M = 0.0_pReal + + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + M = M + lattice_M(material_phaseAt(co,el)) + enddo + + M = M/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) + +end function damage_nonlocal_getMobility + + end submodule homogenization_damage From 5a35c5ebc38ac6f2bf341ad12ffb3379d324b0a9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 Jan 2021 22:44:47 +0100 Subject: [PATCH 150/352] homogenization functionality --- src/damage_nonlocal.f90 | 24 ------------------------ src/homogenization.f90 | 11 +++++++++++ src/homogenization_damage.f90 | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/damage_nonlocal.f90 b/src/damage_nonlocal.f90 index 1ae327833..fe11b0db7 100644 --- a/src/damage_nonlocal.f90 +++ b/src/damage_nonlocal.f90 @@ -31,7 +31,6 @@ module damage_nonlocal public :: & damage_nonlocal_init, & - damage_nonlocal_getSourceAndItsTangent, & damage_nonlocal_getDiffusion, & damage_nonlocal_putNonLocalDamage, & damage_nonlocal_results @@ -88,29 +87,6 @@ subroutine damage_nonlocal_init end subroutine damage_nonlocal_init -!-------------------------------------------------------------------------------------------------- -!> @brief calculates homogenized damage driving forces -!-------------------------------------------------------------------------------------------------- -subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ip, el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - real(pReal), intent(in) :: & - phi - real(pReal) :: & - phiDot, dPhiDot_dPhi - - phiDot = 0.0_pReal - dPhiDot_dPhi = 0.0_pReal - - call constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) - phiDot = phiDot/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) - dPhiDot_dPhi = dPhiDot_dPhi/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) - -end subroutine damage_nonlocal_getSourceAndItsTangent - - !-------------------------------------------------------------------------------------------------- !> @brief returns homogenized non local damage diffusion tensor in reference configuration !-------------------------------------------------------------------------------------------------- diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 816da4fa6..64169382a 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -154,6 +154,16 @@ module homogenization real(pReal) :: M end function damage_nonlocal_getMobility +module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ip, el) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), intent(in) :: & + phi + real(pReal) :: & + phiDot, dPhiDot_dPhi +end subroutine damage_nonlocal_getSourceAndItsTangent end interface public :: & @@ -164,6 +174,7 @@ module homogenization thermal_conduction_getMassDensity, & thermal_conduction_getSource, & damage_nonlocal_getMobility, & + damage_nonlocal_getSourceAndItsTangent, & homogenization_thermal_setfield, & homogenization_thermal_T, & homogenization_forward, & diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index 3a6758914..630327e8d 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -104,4 +104,26 @@ module function damage_nonlocal_getMobility(ip,el) result(M) end function damage_nonlocal_getMobility +!-------------------------------------------------------------------------------------------------- +!> @brief calculates homogenized damage driving forces +!-------------------------------------------------------------------------------------------------- +module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ip, el) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), intent(in) :: & + phi + real(pReal) :: & + phiDot, dPhiDot_dPhi + + phiDot = 0.0_pReal + dPhiDot_dPhi = 0.0_pReal + + call constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) + phiDot = phiDot/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) + dPhiDot_dPhi = dPhiDot_dPhi/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) + +end subroutine damage_nonlocal_getSourceAndItsTangent + end submodule homogenization_damage From 2533e0616d6fd7dc1777869b61cbe6018f23d073 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 07:28:47 +0100 Subject: [PATCH 151/352] don't discriminate by number of constituents/grains --- src/homogenization.f90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 64169382a..17ead5d68 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -274,8 +274,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if(damageState_h(ho)%sizeState > 0) damageState_h(ho)%subState0(:,me) = damageState_h(ho)%State(:,me) endif steppingNeeded - elseif ( (myNgrains == 1 .and. subStep <= 1.0 ) .or. & ! single grain already tried internal subStepping in crystallite - num%subStepSizeHomog * subStep <= num%subStepMinHomog ) then ! would require too small subStep + elseif (subStep <= 1.0 ) then ! cutback makes no sense if (.not. terminallyIll) & ! so first signals terminally ill... print*, ' Integration point ', ip,' at element ', el, ' terminally ill' From 6cca9202ad309c63e9667f6c22d475f57263dd63 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 07:42:12 +0100 Subject: [PATCH 152/352] substepping seems to be inactive even in RGC test --- src/homogenization.f90 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 17ead5d68..abc5aa219 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -266,7 +266,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE subStep = min(1.0_pReal-subFrac,num%stepIncreaseHomog*subStep) ! introduce flexibility for step increase/acceleration steppingNeeded: if (subStep > num%subStepMinHomog) then - + error stop ! wind forward grain starting point call constitutive_windForward(ip,el) @@ -294,6 +294,8 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE convergenceLooping: do while (.not. (terminallyIll .or. doneAndHappy(1)) & .and. NiterationMPstate < num%nMPstate) NiterationMPstate = NiterationMPstate + 1 + if (subStep /= 1.0 .or. subFrac /= 0.0) error stop + !-------------------------------------------------------------------------------------------------- ! deformation partitioning From 2f5c988a8979eeb1aada043112e7cc59b72d9f78 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 13:34:06 +0100 Subject: [PATCH 153/352] removed dead code at least in the tests it was not used ... --- src/homogenization.f90 | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index abc5aa219..1886e87b6 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -265,15 +265,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE subFrac = subFrac + subStep subStep = min(1.0_pReal-subFrac,num%stepIncreaseHomog*subStep) ! introduce flexibility for step increase/acceleration - steppingNeeded: if (subStep > num%subStepMinHomog) then - error stop - ! wind forward grain starting point - call constitutive_windForward(ip,el) - - if(homogState(ho)%sizeState > 0) homogState(ho)%subState0(:,me) = homogState(ho)%State(:,me) - if(damageState_h(ho)%sizeState > 0) damageState_h(ho)%subState0(:,me) = damageState_h(ho)%State(:,me) - - endif steppingNeeded elseif (subStep <= 1.0 ) then ! cutback makes no sense if (.not. terminallyIll) & ! so first signals terminally ill... @@ -294,29 +285,21 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE convergenceLooping: do while (.not. (terminallyIll .or. doneAndHappy(1)) & .and. NiterationMPstate < num%nMPstate) NiterationMPstate = NiterationMPstate + 1 - if (subStep /= 1.0 .or. subFrac /= 0.0) error stop - !-------------------------------------------------------------------------------------------------- ! deformation partitioning if (.not. doneAndHappy(1)) then - call mech_partition( homogenization_F0(1:3,1:3,ce) & - + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce))*(subStep+subFrac), & - ip,el) + call mech_partition(homogenization_F(1:3,1:3,ce),ip,el) converged = .true. do co = 1, myNgrains - converged = converged .and. crystallite_stress(dt*subStep,co,ip,el) + converged = converged .and. crystallite_stress(dt,co,ip,el) enddo if (.not. converged) then doneAndHappy = [.true.,.false.] else - doneAndHappy = mech_updateState(dt*subStep, & - homogenization_F0(1:3,1:3,ce) & - + (homogenization_F(1:3,1:3,ce)-homogenization_F0(1:3,1:3,ce)) & - *(subStep+subFrac), & - ip,el) + doneAndHappy = mech_updateState(dt,homogenization_F(1:3,1:3,ce),ip,el) converged = all(doneAndHappy) endif endif From 5592f5aa34f96860c27e0fc26132854b8eeae028 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 13:49:29 +0100 Subject: [PATCH 154/352] simplified --- src/homogenization.f90 | 75 +++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 48 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 1886e87b6..977bd4078 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -242,7 +242,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE doneAndHappy !$OMP PARALLEL - !$OMP DO PRIVATE(ce,me,ho,myNgrains,NiterationMPstate,subFrac,converged,subStep,doneAndHappy) + !$OMP DO PRIVATE(ce,me,ho,myNgrains,NiterationMPstate,converged,doneAndHappy) do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) myNgrains = homogenization_Nconstituents(ho) @@ -252,60 +252,39 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE call constitutive_initializeRestorationPoints(ip,el) - subFrac = 0.0_pReal - converged = .false. ! pretend failed step ... - subStep = 1.0_pReal/num%subStepSizeHomog ! ... larger then the requested calculation + call constitutive_restore(ce,.false.) ! wrong name (is more a forward function) - if (homogState(ho)%sizeState > 0) homogState(ho)%subState0(:,me) = homogState(ho)%State0(:,me) - if (damageState_h(ho)%sizeState > 0) damageState_h(ho)%subState0(:,me) = damageState_h(ho)%State0(:,me) + if(homogState(ho)%sizeState > 0) homogState(ho)%State(:,me) = homogState(ho)%State0(:,me) + if(damageState_h(ho)%sizeState > 0) damageState_h(ho)%State(:,me) = damageState_h(ho)%State0(:,me) - cutBackLooping: do while (.not. terminallyIll .and. subStep > num%subStepMinHomog) + doneAndHappy = [.false.,.true.] - if (converged) then - subFrac = subFrac + subStep - subStep = min(1.0_pReal-subFrac,num%stepIncreaseHomog*subStep) ! introduce flexibility for step increase/acceleration + NiterationMPstate = 0 + convergenceLooping: do while (.not. (terminallyIll .or. doneAndHappy(1)) & + .and. NiterationMPstate < num%nMPstate) + NiterationMPstate = NiterationMPstate + 1 - elseif (subStep <= 1.0 ) then - ! cutback makes no sense - if (.not. terminallyIll) & ! so first signals terminally ill... - print*, ' Integration point ', ip,' at element ', el, ' terminally ill' - terminallyIll = .true. ! ...and kills all others - else ! cutback makes sense - subStep = num%subStepSizeHomog * subStep ! crystallite had severe trouble, so do a significant cutback - call constitutive_restore(ce,subStep < 1.0_pReal) + if (.not. doneAndHappy(1)) then + call mech_partition(homogenization_F(1:3,1:3,ce),ip,el) + converged = .true. + do co = 1, myNgrains + converged = converged .and. crystallite_stress(dt,co,ip,el) + enddo - if(homogState(ho)%sizeState > 0) homogState(ho)%State(:,me) = homogState(ho)%subState0(:,me) - if(damageState_h(ho)%sizeState > 0) damageState_h(ho)%State(:,me) = damageState_h(ho)%subState0(:,me) + if (.not. converged) then + doneAndHappy = [.true.,.false.] + else + doneAndHappy = mech_updateState(dt,homogenization_F(1:3,1:3,ce),ip,el) + converged = all(doneAndHappy) + endif endif - if (subStep > num%subStepMinHomog) doneAndHappy = [.false.,.true.] - - NiterationMPstate = 0 - convergenceLooping: do while (.not. (terminallyIll .or. doneAndHappy(1)) & - .and. NiterationMPstate < num%nMPstate) - NiterationMPstate = NiterationMPstate + 1 - -!-------------------------------------------------------------------------------------------------- -! deformation partitioning - - if (.not. doneAndHappy(1)) then - call mech_partition(homogenization_F(1:3,1:3,ce),ip,el) - converged = .true. - do co = 1, myNgrains - converged = converged .and. crystallite_stress(dt,co,ip,el) - enddo - - if (.not. converged) then - doneAndHappy = [.true.,.false.] - else - doneAndHappy = mech_updateState(dt,homogenization_F(1:3,1:3,ce),ip,el) - converged = all(doneAndHappy) - endif - endif - - enddo convergenceLooping - enddo cutBackLooping + enddo convergenceLooping + if (.not. converged) then + if (.not. terminallyIll) print*, ' Integration point ', ip,' at element ', el, ' terminally ill' + terminallyIll = .true. + endif enddo enddo !$OMP END DO @@ -337,7 +316,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE ho = material_homogenizationAt(el) do ip = FEsolving_execIP(1),FEsolving_execIP(2) ce = (el-1)*discretization_nIPs + ip - call damage_partition(ce) + ! call damage_partition(ce) ! do co = 1, homogenization_Nconstituents(ho) ! ph = material_phaseAt(co,el) ! if (.not. thermal_stress(dt,ph,material_phaseMemberAt(co,ip,el))) then From 6292094a6591e103b9c69fdee67d8fc738aa6fed Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 14:03:49 +0100 Subject: [PATCH 155/352] not needed partitionedState was only for RGC-triggered cutback. subState is for internal iteration, no need to store for all points --- src/constitutive.f90 | 45 ++----------- src/constitutive_mech.f90 | 93 +++++++-------------------- src/constitutive_thermal.f90 | 7 +- src/damage_none.f90 | 1 - src/damage_nonlocal.f90 | 1 - src/homogenization.f90 | 5 -- src/homogenization_mech_RGC.f90 | 1 - src/homogenization_mech_isostrain.f90 | 1 - src/homogenization_mech_none.f90 | 1 - src/prec.f90 | 1 - 10 files changed, 31 insertions(+), 125 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 149d09a49..630756ec4 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -115,12 +115,6 @@ module constitutive integer, intent(in) :: ph end subroutine damage_results - - module subroutine mech_initializeRestorationPoints(ph,me) - integer, intent(in) :: ph, me - end subroutine mech_initializeRestorationPoints - - module subroutine mech_windForward(ph,me) integer, intent(in) :: ph, me end subroutine mech_windForward @@ -359,7 +353,6 @@ module constitutive constitutive_mech_getP, & constitutive_mech_setF, & constitutive_mech_getF, & - constitutive_initializeRestorationPoints, & constitutive_windForward, & KINEMATICS_UNDEFINED_ID ,& KINEMATICS_CLEAVAGE_OPENING_ID, & @@ -404,11 +397,9 @@ subroutine constitutive_init PhaseLoop2:do ph = 1,phases%length !-------------------------------------------------------------------------------------------------- ! partition and initialize state - plasticState(ph)%partitionedState0 = plasticState(ph)%state0 - plasticState(ph)%state = plasticState(ph)%partitionedState0 + plasticState(ph)%state = plasticState(ph)%state0 forall(so = 1:phase_Nsources(ph)) - damageState(ph)%p(so)%partitionedState0 = damageState(ph)%p(so)%state0 - damageState(ph)%p(so)%state = damageState(ph)%p(so)%partitionedState0 + damageState(ph)%p(so)%state = damageState(ph)%p(so)%state0 end forall constitutive_source_maxSizeDotState = max(constitutive_source_maxSizeDotState, & @@ -473,7 +464,6 @@ subroutine constitutive_allocateState(state, & allocate(state%atol (sizeState), source=0.0_pReal) allocate(state%state0 (sizeState,Nconstituents), source=0.0_pReal) - allocate(state%partitionedState0(sizeState,Nconstituents), source=0.0_pReal) allocate(state%state (sizeState,Nconstituents), source=0.0_pReal) allocate(state%dotState (sizeDotState,Nconstituents), source=0.0_pReal) @@ -500,7 +490,7 @@ subroutine constitutive_restore(ce,includeL) do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce)) do so = 1, phase_Nsources(material_phaseAt2(co,ce)) damageState(material_phaseAt2(co,ce))%p(so)%state( :,material_phasememberAt2(co,ce)) = & - damageState(material_phaseAt2(co,ce))%p(so)%partitionedState0(:,material_phasememberAt2(co,ce)) + damageState(material_phaseAt2(co,ce))%p(so)%state0(:,material_phasememberAt2(co,ce)) enddo enddo @@ -651,33 +641,6 @@ subroutine crystallite_init() end subroutine crystallite_init -!-------------------------------------------------------------------------------------------------- -!> @brief Backup data for homog cutback. -!-------------------------------------------------------------------------------------------------- -subroutine constitutive_initializeRestorationPoints(ip,el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - integer :: & - co, & !< constituent number - so,ph, me - - do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - ph = material_phaseAt(co,el) - me = material_phaseMemberAt(co,ip,el) - - call mech_initializeRestorationPoints(ph,me) - - do so = 1, size(damageState(ph)%p) - damageState(ph)%p(so)%partitionedState0(:,me) = damageState(ph)%p(so)%state0(:,me) - enddo - - enddo - -end subroutine constitutive_initializeRestorationPoints - - !-------------------------------------------------------------------------------------------------- !> @brief Wind homog inc forward. !-------------------------------------------------------------------------------------------------- @@ -699,7 +662,7 @@ subroutine constitutive_windForward(ip,el) call mech_windForward(ph,me) do so = 1, phase_Nsources(material_phaseAt(co,el)) - damageState(ph)%p(so)%partitionedState0(:,me) = damageState(ph)%p(so)%state(:,me) + damageState(ph)%p(so)%state0(:,me) = damageState(ph)%p(so)%state(:,me) enddo enddo diff --git a/src/constitutive_mech.f90 b/src/constitutive_mech.f90 index 56e03ac6f..be933ef4f 100644 --- a/src/constitutive_mech.f90 +++ b/src/constitutive_mech.f90 @@ -39,16 +39,7 @@ submodule(constitutive) constitutive_mech constitutive_mech_F0, & constitutive_mech_Li0, & constitutive_mech_Lp0, & - constitutive_mech_S0, & - ! converged value at end of last homogenization increment (RGC only) - constitutive_mech_partitionedFi0, & - constitutive_mech_partitionedFp0, & - constitutive_mech_partitionedF0, & - constitutive_mech_partitionedLi0, & - constitutive_mech_partitionedLp0, & - constitutive_mech_partitionedS0 - - + constitutive_mech_S0 integer(kind(PLASTICITY_undefined_ID)), dimension(:), allocatable :: & @@ -361,23 +352,17 @@ module subroutine mech_init(phases) allocate(constitutive_mech_Fe(phases%length)) allocate(constitutive_mech_Fi(phases%length)) allocate(constitutive_mech_Fi0(phases%length)) - allocate(constitutive_mech_partitionedFi0(phases%length)) allocate(constitutive_mech_Fp(phases%length)) allocate(constitutive_mech_Fp0(phases%length)) - allocate(constitutive_mech_partitionedFp0(phases%length)) allocate(constitutive_mech_F(phases%length)) allocate(constitutive_mech_F0(phases%length)) - allocate(constitutive_mech_partitionedF0(phases%length)) allocate(constitutive_mech_Li(phases%length)) allocate(constitutive_mech_Li0(phases%length)) - allocate(constitutive_mech_partitionedLi0(phases%length)) - allocate(constitutive_mech_partitionedLp0(phases%length)) allocate(constitutive_mech_Lp0(phases%length)) allocate(constitutive_mech_Lp(phases%length)) allocate(constitutive_mech_S(phases%length)) allocate(constitutive_mech_P(phases%length)) allocate(constitutive_mech_S0(phases%length)) - allocate(constitutive_mech_partitionedS0(phases%length)) do ph = 1, phases%length Nconstituents = count(material_phaseAt == ph) * discretization_nIPs @@ -385,23 +370,17 @@ module subroutine mech_init(phases) allocate(constitutive_mech_Fi(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Fe(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Fi0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedFi0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Fp(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Fp0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedFp0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Li(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Li0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedLi0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedLp0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Lp0(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_Lp(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_S(ph)%data(3,3,Nconstituents),source=0.0_pReal) allocate(constitutive_mech_P(ph)%data(3,3,Nconstituents),source=0.0_pReal) allocate(constitutive_mech_S0(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(constitutive_mech_partitionedS0(ph)%data(3,3,Nconstituents),source=0.0_pReal) allocate(constitutive_mech_F(ph)%data(3,3,Nconstituents)) allocate(constitutive_mech_F0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_partitionedF0(ph)%data(3,3,Nconstituents)) phase => phases%get(ph) mech => phase%get('mechanics') @@ -454,10 +433,6 @@ module subroutine mech_init(phases) constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) constitutive_mech_F(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) - enddo enddo; enddo !$OMP END PARALLEL DO @@ -1464,26 +1439,6 @@ subroutine crystallite_results(group,ph) end subroutine crystallite_results -!-------------------------------------------------------------------------------------------------- -!> @brief Backup data for homog cutback. -!-------------------------------------------------------------------------------------------------- -module subroutine mech_initializeRestorationPoints(ph,me) - - integer, intent(in) :: ph, me - - - constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) = constitutive_mech_Li0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp0(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedS0(ph)%data(1:3,1:3,me) = constitutive_mech_S0(ph)%data(1:3,1:3,me) - - plasticState(ph)%partitionedState0(:,me) = plasticState(ph)%state0(:,me) - -end subroutine mech_initializeRestorationPoints - - !-------------------------------------------------------------------------------------------------- !> @brief Wind homog inc forward. !-------------------------------------------------------------------------------------------------- @@ -1492,14 +1447,14 @@ module subroutine mech_windForward(ph,me) integer, intent(in) :: ph, me - constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) = constitutive_mech_F(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) = constitutive_mech_Li(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedS0(ph)%data(1:3,1:3,me) = constitutive_mech_S(ph)%data(1:3,1:3,me) + constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp(ph)%data(1:3,1:3,me) + constitutive_mech_Fi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi(ph)%data(1:3,1:3,me) + constitutive_mech_F0(ph)%data(1:3,1:3,me) = constitutive_mech_F(ph)%data(1:3,1:3,me) + constitutive_mech_Li0(ph)%data(1:3,1:3,me) = constitutive_mech_Li(ph)%data(1:3,1:3,me) + constitutive_mech_Lp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp(ph)%data(1:3,1:3,me) + constitutive_mech_S0(ph)%data(1:3,1:3,me) = constitutive_mech_S(ph)%data(1:3,1:3,me) - plasticState(ph)%partitionedState0(:,me) = plasticState(ph)%state(:,me) + plasticState(ph)%State0(:,me) = plasticState(ph)%state(:,me) end subroutine mech_windForward @@ -1578,17 +1533,17 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) me = material_phaseMemberAt(co,ip,el) sizeDotState = plasticState(ph)%sizeDotState - subLi0 = constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) - subLp0 = constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) - subState0 = plasticState(ph)%partitionedState0(:,me) + subLi0 = constitutive_mech_Li0(ph)%data(1:3,1:3,me) + subLp0 = constitutive_mech_Lp0(ph)%data(1:3,1:3,me) + subState0 = plasticState(ph)%State0(:,me) do so = 1, phase_Nsources(ph) - damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%partitionedState0(:,me) + damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%state0(:,me) enddo - subFp0 = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) - subFi0 = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) - subF0 = constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me) + subFp0 = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) + subFi0 = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) + subF0 = constitutive_mech_F0(ph)%data(1:3,1:3,me) subFrac = 0.0_pReal subStep = 1.0_pReal/num%subStepSizeCryst todo = .true. @@ -1638,7 +1593,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) ! prepare for integration if (todo) then subF = subF0 & - + subStep * (constitutive_mech_F(ph)%data(1:3,1:3,me) - constitutive_mech_partitionedF0(ph)%data(1:3,1:3,me)) + + subStep * (constitutive_mech_F(ph)%data(1:3,1:3,me) - constitutive_mech_F0(ph)%data(1:3,1:3,me)) constitutive_mech_Fe(ph)%data(1:3,1:3,me) = matmul(subF,math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) converged_ = .not. integrateState(subF0,subF,subFp0,subFi0,subState0(1:sizeDotState),subStep * dt,co,ip,el) @@ -1667,15 +1622,15 @@ module subroutine mech_restore(ce,includeL) ph = material_phaseAt2(co,ce) me = material_phaseMemberAt2(co,ce) if (includeL) then - constitutive_mech_Lp(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedLp0(ph)%data(1:3,1:3,me) - constitutive_mech_Li(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedLi0(ph)%data(1:3,1:3,me) + constitutive_mech_Lp(ph)%data(1:3,1:3,me) = constitutive_mech_Lp0(ph)%data(1:3,1:3,me) + constitutive_mech_Li(ph)%data(1:3,1:3,me) = constitutive_mech_Li0(ph)%data(1:3,1:3,me) endif ! maybe protecting everything from overwriting makes more sense - constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me) - constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me) - constitutive_mech_S(ph)%data(1:3,1:3,me) = constitutive_mech_partitionedS0(ph)%data(1:3,1:3,me) + constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) + constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) + constitutive_mech_S(ph)%data(1:3,1:3,me) = constitutive_mech_S0(ph)%data(1:3,1:3,me) - plasticState(ph)%state(:,me) = plasticState(ph)%partitionedState0(:,me) + plasticState(ph)%state(:,me) = plasticState(ph)%State0(:,me) enddo end subroutine mech_restore @@ -1727,8 +1682,8 @@ module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) invFp = math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me)) invFi = math_inv33(constitutive_mech_Fi(ph)%data(1:3,1:3,me)) - invSubFp0 = math_inv33(constitutive_mech_partitionedFp0(ph)%data(1:3,1:3,me)) - invSubFi0 = math_inv33(constitutive_mech_partitionedFi0(ph)%data(1:3,1:3,me)) + invSubFp0 = math_inv33(constitutive_mech_Fp0(ph)%data(1:3,1:3,me)) + invSubFi0 = math_inv33(constitutive_mech_Fi0(ph)%data(1:3,1:3,me)) if (sum(abs(dLidS)) < tol_math_check) then dFidS = 0.0_pReal diff --git a/src/constitutive_thermal.f90 b/src/constitutive_thermal.f90 index 57b8a3117..831fd236d 100644 --- a/src/constitutive_thermal.f90 +++ b/src/constitutive_thermal.f90 @@ -116,12 +116,11 @@ module subroutine thermal_init(phases) PhaseLoop2:do ph = 1,phases%length do so = 1,thermal_Nsources(ph) - deallocate(thermalState(ph)%p(so)%partitionedState0) - thermalState(ph)%p(so)%state = thermalState(ph)%p(so)%state0 + thermalState(ph)%p(so)%state = thermalState(ph)%p(so)%state0 enddo - thermal_source_maxSizeDotState = max(thermal_source_maxSizeDotState, & - maxval(thermalState(ph)%p%sizeDotState)) + thermal_source_maxSizeDotState = max(thermal_source_maxSizeDotState, & + maxval(thermalState(ph)%p%sizeDotState)) enddo PhaseLoop2 !-------------------------------------------------------------------------------------------------- diff --git a/src/damage_none.f90 b/src/damage_none.f90 index 078d42af7..680110d55 100644 --- a/src/damage_none.f90 +++ b/src/damage_none.f90 @@ -27,7 +27,6 @@ subroutine damage_none_init Nmaterialpoints = count(material_homogenizationAt == h) damageState_h(h)%sizeState = 0 allocate(damageState_h(h)%state0 (0,Nmaterialpoints)) - allocate(damageState_h(h)%subState0(0,Nmaterialpoints)) allocate(damageState_h(h)%state (0,Nmaterialpoints)) allocate (damage(h)%p(Nmaterialpoints), source=1.0_pReal) diff --git a/src/damage_nonlocal.f90 b/src/damage_nonlocal.f90 index fe11b0db7..6e46d8799 100644 --- a/src/damage_nonlocal.f90 +++ b/src/damage_nonlocal.f90 @@ -76,7 +76,6 @@ subroutine damage_nonlocal_init Nmaterialpoints = count(material_homogenizationAt == h) damageState_h(h)%sizeState = 1 allocate(damageState_h(h)%state0 (1,Nmaterialpoints), source=1.0_pReal) - allocate(damageState_h(h)%subState0(1,Nmaterialpoints), source=1.0_pReal) allocate(damageState_h(h)%state (1,Nmaterialpoints), source=1.0_pReal) damage(h)%p => damageState_h(h)%state(1,:) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 977bd4078..5523f38ac 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -233,9 +233,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE ip, & !< integration point number el, & !< element number myNgrains, co, ce, ho, me, ph - real(pReal) :: & - subFrac, & - subStep logical :: & converged logical, dimension(2) :: & @@ -250,8 +247,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE ce = (el-1)*discretization_nIPs + ip me = material_homogenizationMemberAt2(ce) - call constitutive_initializeRestorationPoints(ip,el) - call constitutive_restore(ce,.false.) ! wrong name (is more a forward function) if(homogState(ho)%sizeState > 0) homogState(ho)%State(:,me) = homogState(ho)%State0(:,me) diff --git a/src/homogenization_mech_RGC.f90 b/src/homogenization_mech_RGC.f90 index 24d14e059..2c7a5a8cb 100644 --- a/src/homogenization_mech_RGC.f90 +++ b/src/homogenization_mech_RGC.f90 @@ -171,7 +171,6 @@ module subroutine mech_RGC_init(num_homogMech) homogState(h)%sizeState = sizeState allocate(homogState(h)%state0 (sizeState,Nmaterialpoints), source=0.0_pReal) - allocate(homogState(h)%subState0(sizeState,Nmaterialpoints), source=0.0_pReal) allocate(homogState(h)%state (sizeState,Nmaterialpoints), source=0.0_pReal) stt%relaxationVector => homogState(h)%state(1:nIntFaceTot,:) diff --git a/src/homogenization_mech_isostrain.f90 b/src/homogenization_mech_isostrain.f90 index a56104647..df8f5fc9d 100644 --- a/src/homogenization_mech_isostrain.f90 +++ b/src/homogenization_mech_isostrain.f90 @@ -64,7 +64,6 @@ module subroutine mech_isostrain_init Nmaterialpoints = count(material_homogenizationAt == h) homogState(h)%sizeState = 0 allocate(homogState(h)%state0 (0,Nmaterialpoints)) - allocate(homogState(h)%subState0(0,Nmaterialpoints)) allocate(homogState(h)%state (0,Nmaterialpoints)) end associate diff --git a/src/homogenization_mech_none.f90 b/src/homogenization_mech_none.f90 index d434d1ca0..767dbf557 100644 --- a/src/homogenization_mech_none.f90 +++ b/src/homogenization_mech_none.f90 @@ -32,7 +32,6 @@ module subroutine mech_none_init Nmaterialpoints = count(material_homogenizationAt == h) homogState(h)%sizeState = 0 allocate(homogState(h)%state0 (0,Nmaterialpoints)) - allocate(homogState(h)%subState0(0,Nmaterialpoints)) allocate(homogState(h)%state (0,Nmaterialpoints)) enddo diff --git a/src/prec.f90 b/src/prec.f90 index 4d73462c4..eabeecaf4 100644 --- a/src/prec.f90 +++ b/src/prec.f90 @@ -47,7 +47,6 @@ module prec dotState, & !< rate of state change deltaState !< increment of state change real(pReal), allocatable, dimension(:,:) :: & - partitionedState0, & subState0 end type From fdc48a7987757c2b5d9bde33827c8694949eae41 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 14:43:09 +0100 Subject: [PATCH 156/352] not used --- src/constitutive.f90 | 3 +-- src/homogenization.f90 | 11 ----------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/constitutive.f90 b/src/constitutive.f90 index 630756ec4..1412f5259 100644 --- a/src/constitutive.f90 +++ b/src/constitutive.f90 @@ -489,7 +489,7 @@ subroutine constitutive_restore(ce,includeL) do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce)) do so = 1, phase_Nsources(material_phaseAt2(co,ce)) - damageState(material_phaseAt2(co,ce))%p(so)%state( :,material_phasememberAt2(co,ce)) = & + damageState(material_phaseAt2(co,ce))%p(so)%state( :,material_phasememberAt2(co,ce)) = & damageState(material_phaseAt2(co,ce))%p(so)%state0(:,material_phasememberAt2(co,ce)) enddo enddo @@ -559,7 +559,6 @@ subroutine crystallite_init() iMax, & !< maximum number of integration points eMax !< maximum number of elements - class(tNode), pointer :: & num_crystallite, & debug_crystallite, & ! pointer to debug options for crystallite diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 5523f38ac..9d5ea5d4f 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -38,10 +38,6 @@ module homogenization type :: tNumerics integer :: & nMPstate !< materialpoint state loop limit - real(pReal) :: & - subStepMinHomog, & !< minimum (relative) size of sub-step allowed during cutback in homogenization - subStepSizeHomog, & !< size of first substep when cutback in homogenization - stepIncreaseHomog !< increase of next substep size when previous substep converged in homogenization end type tNumerics type(tNumerics) :: num @@ -200,14 +196,7 @@ subroutine homogenization_init() num_homogGeneric => num_homog%get('generic',defaultVal=emptyDict) num%nMPstate = num_homogGeneric%get_asInt ('nMPstate', defaultVal=10) - num%subStepMinHomog = num_homogGeneric%get_asFloat('subStepMin', defaultVal=1.0e-3_pReal) - num%subStepSizeHomog = num_homogGeneric%get_asFloat('subStepSize', defaultVal=0.25_pReal) - num%stepIncreaseHomog = num_homogGeneric%get_asFloat('stepIncrease', defaultVal=1.5_pReal) - if (num%nMPstate < 1) call IO_error(301,ext_msg='nMPstate') - if (num%subStepMinHomog <= 0.0_pReal) call IO_error(301,ext_msg='subStepMinHomog') - if (num%subStepSizeHomog <= 0.0_pReal) call IO_error(301,ext_msg='subStepSizeHomog') - if (num%stepIncreaseHomog <= 0.0_pReal) call IO_error(301,ext_msg='stepIncreaseHomog') call mech_init(num_homog) From 8b11af0d8477bf64e209dbcfbc5c286f872b175d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 15:13:17 +0100 Subject: [PATCH 157/352] more sensible location --- src/damage_nonlocal.f90 | 69 +---------------------------------- src/homogenization.f90 | 37 ++++++++++++++----- src/homogenization_damage.f90 | 44 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 76 deletions(-) diff --git a/src/damage_nonlocal.f90 b/src/damage_nonlocal.f90 index fe11b0db7..c4abaccea 100644 --- a/src/damage_nonlocal.f90 +++ b/src/damage_nonlocal.f90 @@ -14,26 +14,17 @@ module damage_nonlocal implicit none private - type :: tParameters - character(len=pStringLen), allocatable, dimension(:) :: & - output - end type tParameters - type, private :: tNumerics real(pReal) :: & charLength !< characteristic length scale for gradient problems end type tNumerics - type(tparameters), dimension(:), allocatable :: & - param type(tNumerics), private :: & num public :: & damage_nonlocal_init, & - damage_nonlocal_getDiffusion, & - damage_nonlocal_putNonLocalDamage, & - damage_nonlocal_results + damage_nonlocal_getDiffusion contains @@ -46,9 +37,7 @@ subroutine damage_nonlocal_init integer :: Ninstances,Nmaterialpoints,h class(tNode), pointer :: & num_generic, & - material_homogenization, & - homog, & - homogDamage + material_homogenization print'(/,a)', ' <<<+- damage_nonlocal init -+>>>'; flush(6) @@ -58,20 +47,10 @@ subroutine damage_nonlocal_init num%charLength = num_generic%get_asFloat('charLength',defaultVal=1.0_pReal) Ninstances = count(damage_type == DAMAGE_nonlocal_ID) - allocate(param(Ninstances)) material_homogenization => config_material%get('homogenization') do h = 1, material_homogenization%length if (damage_type(h) /= DAMAGE_NONLOCAL_ID) cycle - homog => material_homogenization%get(h) - homogDamage => homog%get('damage') - associate(prm => param(damage_typeInstance(h))) - -#if defined (__GFORTRAN__) - prm%output = output_asStrings(homogDamage) -#else - prm%output = homogDamage%get_asStrings('output',defaultVal=emptyStringArray) -#endif Nmaterialpoints = count(material_homogenizationAt == h) damageState_h(h)%sizeState = 1 @@ -81,7 +60,6 @@ subroutine damage_nonlocal_init damage(h)%p => damageState_h(h)%state(1,:) - end associate enddo end subroutine damage_nonlocal_init @@ -114,47 +92,4 @@ function damage_nonlocal_getDiffusion(ip,el) end function damage_nonlocal_getDiffusion -!-------------------------------------------------------------------------------------------------- -!> @brief updated nonlocal damage field with solution from damage phase field PDE -!-------------------------------------------------------------------------------------------------- -subroutine damage_nonlocal_putNonLocalDamage(phi,ip,el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - real(pReal), intent(in) :: & - phi - integer :: & - homog, & - offset - - homog = material_homogenizationAt(el) - offset = material_homogenizationMemberAt(ip,el) - damage(homog)%p(offset) = phi - -end subroutine damage_nonlocal_putNonLocalDamage - - -!-------------------------------------------------------------------------------------------------- -!> @brief writes results to HDF5 output file -!-------------------------------------------------------------------------------------------------- -subroutine damage_nonlocal_results(homog,group) - - integer, intent(in) :: homog - character(len=*), intent(in) :: group - - integer :: o - - associate(prm => param(damage_typeInstance(homog))) - outputsLoop: do o = 1,size(prm%output) - select case(prm%output(o)) - case ('phi') - call results_writeDataset(group,damage(homog)%p,prm%output(o),& - 'damage indicator','-') - end select - enddo outputsLoop - end associate - -end subroutine damage_nonlocal_results - end module damage_nonlocal diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 17ead5d68..9d517dd1f 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -154,16 +154,34 @@ module homogenization real(pReal) :: M end function damage_nonlocal_getMobility -module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ip, el) + module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ip, el) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - real(pReal), intent(in) :: & - phi - real(pReal) :: & - phiDot, dPhiDot_dPhi -end subroutine damage_nonlocal_getSourceAndItsTangent + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), intent(in) :: & + phi + real(pReal) :: & + phiDot, dPhiDot_dPhi + end subroutine damage_nonlocal_getSourceAndItsTangent + + + module subroutine damage_nonlocal_putNonLocalDamage(phi,ip,el) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), intent(in) :: & + phi + + end subroutine damage_nonlocal_putNonLocalDamage + + module subroutine damage_nonlocal_results(homog,group) + + integer, intent(in) :: homog + character(len=*), intent(in) :: group + + end subroutine damage_nonlocal_results end interface public :: & @@ -175,6 +193,7 @@ end subroutine damage_nonlocal_getSourceAndItsTangent thermal_conduction_getSource, & damage_nonlocal_getMobility, & damage_nonlocal_getSourceAndItsTangent, & + damage_nonlocal_putNonLocalDamage, & homogenization_thermal_setfield, & homogenization_thermal_T, & homogenization_forward, & diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index 630327e8d..3115e6a6f 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -126,4 +126,48 @@ module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, p end subroutine damage_nonlocal_getSourceAndItsTangent + +!-------------------------------------------------------------------------------------------------- +!> @brief updated nonlocal damage field with solution from damage phase field PDE +!-------------------------------------------------------------------------------------------------- +module subroutine damage_nonlocal_putNonLocalDamage(phi,ip,el) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), intent(in) :: & + phi + integer :: & + homog, & + offset + + homog = material_homogenizationAt(el) + offset = material_homogenizationMemberAt(ip,el) + damage(homog)%p(offset) = phi + +end subroutine damage_nonlocal_putNonLocalDamage + + +!-------------------------------------------------------------------------------------------------- +!> @brief writes results to HDF5 output file +!-------------------------------------------------------------------------------------------------- +module subroutine damage_nonlocal_results(homog,group) + + integer, intent(in) :: homog + character(len=*), intent(in) :: group + + integer :: o + + associate(prm => param(damage_typeInstance(homog))) + outputsLoop: do o = 1,size(prm%output) + select case(prm%output(o)) + case ('phi') + call results_writeDataset(group,damage(homog)%p,prm%output(o),& + 'damage indicator','-') + end select + enddo outputsLoop + end associate + +end subroutine damage_nonlocal_results + end submodule homogenization_damage From 546fcba93d0941751150eedf8b1f93a76c42acdc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 19:53:05 +0100 Subject: [PATCH 158/352] polishing --- src/prec.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prec.f90 b/src/prec.f90 index eabeecaf4..1a96c75a9 100644 --- a/src/prec.f90 +++ b/src/prec.f90 @@ -32,13 +32,13 @@ module prec real(pReal), dimension(:), pointer :: p end type group_float - ! http://stackoverflow.com/questions/3948210/can-i-have-a-pointer-to-an-item-in-an-allocatable-array type :: tState integer :: & sizeState = 0, & !< size of state sizeDotState = 0, & !< size of dot state, i.e. state(1:sizeDot) follows time evolution by dotState rates offsetDeltaState = 0, & !< index offset of delta state sizeDeltaState = 0 !< size of delta state, i.e. state(offset+1:offset+sizeDelta) follows time evolution by deltaState increments + ! http://stackoverflow.com/questions/3948210 real(pReal), pointer, dimension(:), contiguous :: & atol real(pReal), pointer, dimension(:,:), contiguous :: & ! a pointer is needed here because we might point to state/doState. However, they will never point to something, but are rather allocated and, hence, contiguous From 6db58dffb7c0205cf3a355e13a6c101043d44ebe Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 20:31:12 +0100 Subject: [PATCH 159/352] filenames reflect hierarchical structure --- src/commercialFEM_fileList.f90 | 50 +++++++++---------- ..._mech.f90 => homogenization_mechanics.f90} | 0 ...C.f90 => homogenization_mechanics_RGC.f90} | 0 ...=> homogenization_mechanics_isostrain.f90} | 0 ....f90 => homogenization_mechanics_none.f90} | 0 src/{constitutive.f90 => phase.f90} | 0 ...nstitutive_damage.f90 => phase_damage.f90} | 30 +---------- ...ttle.f90 => phase_damage_anisobrittle.f90} | 0 ...tile.f90 => phase_damage_anisoductile.f90} | 0 ...rittle.f90 => phase_damage_isobrittle.f90} | 0 ...uctile.f90 => phase_damage_isoductile.f90} | 0 ...stitutive_mech.f90 => phase_mechanics.f90} | 29 ++++++++++- ...e_mechanics_anelastic_cleavageopening.f90} | 12 ++--- ..._mechanics_anelastic_slipplaneopening.f90} | 10 ++-- ..._mechanics_anelastic_thermalexpansion.f90} | 0 ...phase_mechanics_plastic_dislotungsten.f90} | 0 ... => phase_mechanics_plastic_dislotwin.f90} | 0 ... => phase_mechanics_plastic_isotropic.f90} | 0 ...phase_mechanics_plastic_kinehardening.f90} | 0 ...e.f90 => phase_mechanics_plastic_none.f90} | 0 ...0 => phase_mechanics_plastic_nonlocal.f90} | 0 ...phase_mechanics_plastic_phenopowerlaw.f90} | 0 ...titutive_thermal.f90 => phase_thermal.f90} | 0 ...tion.f90 => phase_thermal_dissipation.f90} | 0 ...eat.f90 => phase_thermal_externalheat.f90} | 0 25 files changed, 65 insertions(+), 66 deletions(-) rename src/{homogenization_mech.f90 => homogenization_mechanics.f90} (100%) rename src/{homogenization_mech_RGC.f90 => homogenization_mechanics_RGC.f90} (100%) rename src/{homogenization_mech_isostrain.f90 => homogenization_mechanics_isostrain.f90} (100%) rename src/{homogenization_mech_none.f90 => homogenization_mechanics_none.f90} (100%) rename src/{constitutive.f90 => phase.f90} (100%) rename src/{constitutive_damage.f90 => phase_damage.f90} (94%) rename src/{source_damage_anisoBrittle.f90 => phase_damage_anisobrittle.f90} (100%) rename src/{source_damage_anisoDuctile.f90 => phase_damage_anisoductile.f90} (100%) rename src/{source_damage_isoBrittle.f90 => phase_damage_isobrittle.f90} (100%) rename src/{source_damage_isoDuctile.f90 => phase_damage_isoductile.f90} (100%) rename src/{constitutive_mech.f90 => phase_mechanics.f90} (98%) rename src/{kinematics_cleavage_opening.f90 => phase_mechanics_anelastic_cleavageopening.f90} (97%) rename src/{kinematics_slipplane_opening.f90 => phase_mechanics_anelastic_slipplaneopening.f90} (97%) rename src/{kinematics_thermal_expansion.f90 => phase_mechanics_anelastic_thermalexpansion.f90} (100%) rename src/{constitutive_plastic_disloTungsten.f90 => phase_mechanics_plastic_dislotungsten.f90} (100%) rename src/{constitutive_plastic_dislotwin.f90 => phase_mechanics_plastic_dislotwin.f90} (100%) rename src/{constitutive_plastic_isotropic.f90 => phase_mechanics_plastic_isotropic.f90} (100%) rename src/{constitutive_plastic_kinehardening.f90 => phase_mechanics_plastic_kinehardening.f90} (100%) rename src/{constitutive_plastic_none.f90 => phase_mechanics_plastic_none.f90} (100%) rename src/{constitutive_plastic_nonlocal.f90 => phase_mechanics_plastic_nonlocal.f90} (100%) rename src/{constitutive_plastic_phenopowerlaw.f90 => phase_mechanics_plastic_phenopowerlaw.f90} (100%) rename src/{constitutive_thermal.f90 => phase_thermal.f90} (100%) rename src/{constitutive_thermal_dissipation.f90 => phase_thermal_dissipation.f90} (100%) rename src/{constitutive_thermal_externalheat.f90 => phase_thermal_externalheat.f90} (100%) diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index a20fb1cee..42da97db7 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -17,38 +17,36 @@ #include "results.f90" #include "geometry_plastic_nonlocal.f90" #include "discretization.f90" -#ifdef Marc4DAMASK #include "marc/discretization_marc.f90" -#endif #include "material.f90" #include "lattice.f90" -#include "constitutive.f90" -#include "constitutive_mech.f90" -#include "constitutive_plastic_none.f90" -#include "constitutive_plastic_isotropic.f90" -#include "constitutive_plastic_phenopowerlaw.f90" -#include "constitutive_plastic_kinehardening.f90" -#include "constitutive_plastic_dislotwin.f90" -#include "constitutive_plastic_disloTungsten.f90" -#include "constitutive_plastic_nonlocal.f90" -#include "constitutive_thermal.f90" -#include "constitutive_thermal_dissipation.f90" -#include "constitutive_thermal_externalheat.f90" -#include "kinematics_thermal_expansion.f90" -#include "constitutive_damage.f90" -#include "source_damage_isoBrittle.f90" -#include "source_damage_isoDuctile.f90" -#include "source_damage_anisoBrittle.f90" -#include "source_damage_anisoDuctile.f90" -#include "kinematics_cleavage_opening.f90" -#include "kinematics_slipplane_opening.f90" +#include "phase.f90" +#include "phase_mechanics.f90" +#include "phase_mechanics_plastic_none.f90" +#include "phase_mechanics_plastic_isotropic.f90" +#include "phase_mechanics_plastic_phenopowerlaw.f90" +#include "phase_mechanics_plastic_kinehardening.f90" +#include "phase_mechanics_plastic_dislotwin.f90" +#include "phase_mechanics_plastic_disloTungsten.f90" +#include "phase_mechanics_plastic_nonlocal.f90" +#include "phase_mechancis_anelastic_thermalexpansion.f90" +#include "phase_mechanics_anelastic_cleavageopening.f90" +#include "phase_mechanics_anelastic_slipplaneopening.f90" +#include "phase_thermal.f90" +#include "phase_thermal_dissipation.f90" +#include "phase_thermal_externalheat.f90" +#include "phase_damage.f90" +#include "phase_damage_isobrittle.f90" +#include "phase_damage_isoductile.f90" +#include "phase_damage_anisobrittle.f90" +#include "phase_damage_anisoductile.f90" #include "damage_none.f90" #include "damage_nonlocal.f90" #include "homogenization.f90" -#include "homogenization_mech.f90" -#include "homogenization_mech_none.f90" -#include "homogenization_mech_isostrain.f90" -#include "homogenization_mech_RGC.f90" +#include "homogenization_mechanics.f90" +#include "homogenization_mechanics_none.f90" +#include "homogenization_mechanics_isostrain.f90" +#include "homogenization_mechanics_RGC.f90" #include "homogenization_thermal.f90" #include "homogenization_damage.f90" #include "CPFEM.f90" diff --git a/src/homogenization_mech.f90 b/src/homogenization_mechanics.f90 similarity index 100% rename from src/homogenization_mech.f90 rename to src/homogenization_mechanics.f90 diff --git a/src/homogenization_mech_RGC.f90 b/src/homogenization_mechanics_RGC.f90 similarity index 100% rename from src/homogenization_mech_RGC.f90 rename to src/homogenization_mechanics_RGC.f90 diff --git a/src/homogenization_mech_isostrain.f90 b/src/homogenization_mechanics_isostrain.f90 similarity index 100% rename from src/homogenization_mech_isostrain.f90 rename to src/homogenization_mechanics_isostrain.f90 diff --git a/src/homogenization_mech_none.f90 b/src/homogenization_mechanics_none.f90 similarity index 100% rename from src/homogenization_mech_none.f90 rename to src/homogenization_mechanics_none.f90 diff --git a/src/constitutive.f90 b/src/phase.f90 similarity index 100% rename from src/constitutive.f90 rename to src/phase.f90 diff --git a/src/constitutive_damage.f90 b/src/phase_damage.f90 similarity index 94% rename from src/constitutive_damage.f90 rename to src/phase_damage.f90 index 07bfbeeca..c1e555299 100644 --- a/src/constitutive_damage.f90 +++ b/src/phase_damage.f90 @@ -42,15 +42,6 @@ submodule(constitutive) constitutive_damage logical, dimension(:,:), allocatable :: mySources end function source_damage_isoDuctile_init - module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_cleavage_opening_init - - module function kinematics_slipplane_opening_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_slipplane_opening_init module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph, me) integer, intent(in) :: ph,me @@ -164,8 +155,7 @@ module subroutine damage_init class(tNode), pointer :: & phases, & phase, & - sources, & - kinematics + sources phases => config_material%get('phase') @@ -197,22 +187,6 @@ module subroutine damage_init where(source_damage_anisoDuctile_init (maxval(phase_Nsources))) phase_source = DAMAGE_ANISODUCTILE_ID endif -!-------------------------------------------------------------------------------------------------- -! initialize kinematic mechanisms - allocate(phase_Nkinematics(phases%length),source = 0) - do ph = 1,phases%length - phase => phases%get(ph) - kinematics => phase%get('kinematics',defaultVal=emptyList) - phase_Nkinematics(ph) = kinematics%length - enddo - - allocate(phase_kinematics(maxval(phase_Nkinematics),phases%length), source = KINEMATICS_undefined_ID) - - if(maxval(phase_Nkinematics) /= 0) then - where(kinematics_cleavage_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_cleavage_opening_ID - where(kinematics_slipplane_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_slipplane_opening_ID - endif - end subroutine damage_init @@ -542,7 +516,7 @@ end subroutine constitutive_damage_set_phi module function constitutive_damage_get_phi(co,ip,el) result(phi) - + integer, intent(in) :: co, ip, el real(pReal) :: phi diff --git a/src/source_damage_anisoBrittle.f90 b/src/phase_damage_anisobrittle.f90 similarity index 100% rename from src/source_damage_anisoBrittle.f90 rename to src/phase_damage_anisobrittle.f90 diff --git a/src/source_damage_anisoDuctile.f90 b/src/phase_damage_anisoductile.f90 similarity index 100% rename from src/source_damage_anisoDuctile.f90 rename to src/phase_damage_anisoductile.f90 diff --git a/src/source_damage_isoBrittle.f90 b/src/phase_damage_isobrittle.f90 similarity index 100% rename from src/source_damage_isoBrittle.f90 rename to src/phase_damage_isobrittle.f90 diff --git a/src/source_damage_isoDuctile.f90 b/src/phase_damage_isoductile.f90 similarity index 100% rename from src/source_damage_isoDuctile.f90 rename to src/phase_damage_isoductile.f90 diff --git a/src/constitutive_mech.f90 b/src/phase_mechanics.f90 similarity index 98% rename from src/constitutive_mech.f90 rename to src/phase_mechanics.f90 index be933ef4f..53986191b 100644 --- a/src/constitutive_mech.f90 +++ b/src/phase_mechanics.f90 @@ -268,6 +268,16 @@ submodule(constitutive) constitutive_mech el end subroutine plastic_nonlocal_deltaState + module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) + integer, intent(in) :: kinematics_length + logical, dimension(:,:), allocatable :: myKinematics + end function kinematics_cleavage_opening_init + + module function kinematics_slipplane_opening_init(kinematics_length) result(myKinematics) + integer, intent(in) :: kinematics_length + logical, dimension(:,:), allocatable :: myKinematics + end function kinematics_slipplane_opening_init + module subroutine plastic_isotropic_results(instance,group) integer, intent(in) :: instance character(len=*), intent(in) :: group @@ -338,7 +348,8 @@ module subroutine mech_init(phases) phase, & mech, & elastic, & - stiffDegradation + stiffDegradation, & + kinematics print'(/,a)', ' <<<+- constitutive_mech init -+>>>' @@ -481,6 +492,22 @@ module subroutine mech_init(phases) end select +!-------------------------------------------------------------------------------------------------- +! initialize kinematic mechanisms + allocate(phase_Nkinematics(phases%length),source = 0) + do ph = 1,phases%length + phase => phases%get(ph) + kinematics => phase%get('kinematics',defaultVal=emptyList) + phase_Nkinematics(ph) = kinematics%length + enddo + + allocate(phase_kinematics(maxval(phase_Nkinematics),phases%length), source = KINEMATICS_undefined_ID) + + if(maxval(phase_Nkinematics) /= 0) then + where(kinematics_cleavage_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_cleavage_opening_ID + where(kinematics_slipplane_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_slipplane_opening_ID + endif + end subroutine mech_init diff --git a/src/kinematics_cleavage_opening.f90 b/src/phase_mechanics_anelastic_cleavageopening.f90 similarity index 97% rename from src/kinematics_cleavage_opening.f90 rename to src/phase_mechanics_anelastic_cleavageopening.f90 index a29a290f8..01fbf0cb9 100644 --- a/src/kinematics_cleavage_opening.f90 +++ b/src/phase_mechanics_anelastic_cleavageopening.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating kinematics resulting from opening of cleavage planes !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_damage) kinematics_cleavage_opening +submodule(constitutive:constitutive_mech) kinematics_cleavage_opening integer, dimension(:), allocatable :: kinematics_cleavage_opening_instance @@ -31,8 +31,8 @@ contains !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) - - integer, intent(in) :: kinematics_length + + integer, intent(in) :: kinematics_length logical, dimension(:,:), allocatable :: myKinematics integer :: Ninstances,p,k @@ -42,8 +42,8 @@ module function kinematics_cleavage_opening_init(kinematics_length) result(myKin phases, & phase, & kinematics, & - kinematic_type - + kinematic_type + print'(/,a)', ' <<<+- kinematics_cleavage_opening init -+>>>' myKinematics = kinematics_active('cleavage_opening',kinematics_length) @@ -63,7 +63,7 @@ module function kinematics_cleavage_opening_init(kinematics_length) result(myKin do k = 1, kinematics%length if(myKinematics(k,p)) then associate(prm => param(kinematics_cleavage_opening_instance(p))) - kinematic_type => kinematics%get(k) + kinematic_type => kinematics%get(k) N_cl = kinematic_type%get_asInts('N_cl') prm%sum_N_cl = sum(abs(N_cl)) diff --git a/src/kinematics_slipplane_opening.f90 b/src/phase_mechanics_anelastic_slipplaneopening.f90 similarity index 97% rename from src/kinematics_slipplane_opening.f90 rename to src/phase_mechanics_anelastic_slipplaneopening.f90 index 84edab122..c15608dea 100644 --- a/src/kinematics_slipplane_opening.f90 +++ b/src/phase_mechanics_anelastic_slipplaneopening.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating kinematics resulting from opening of slip planes !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_damage) kinematics_slipplane_opening +submodule(constitutive:constitutive_mech) kinematics_slipplane_opening integer, dimension(:), allocatable :: kinematics_slipplane_opening_instance @@ -34,7 +34,7 @@ contains !-------------------------------------------------------------------------------------------------- module function kinematics_slipplane_opening_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length + integer, intent(in) :: kinematics_length logical, dimension(:,:), allocatable :: myKinematics integer :: Ninstances,p,i,k @@ -47,8 +47,8 @@ module function kinematics_slipplane_opening_init(kinematics_length) result(myKi mech, & pl, & kinematics, & - kinematic_type - + kinematic_type + print'(/,a)', ' <<<+- kinematics_slipplane init -+>>>' myKinematics = kinematics_active('slipplane_opening',kinematics_length) @@ -70,7 +70,7 @@ module function kinematics_slipplane_opening_init(kinematics_length) result(myKi do k = 1, kinematics%length if(myKinematics(k,p)) then associate(prm => param(kinematics_slipplane_opening_instance(p))) - kinematic_type => kinematics%get(k) + kinematic_type => kinematics%get(k) prm%dot_o = kinematic_type%get_asFloat('dot_o') prm%q = kinematic_type%get_asFloat('q') diff --git a/src/kinematics_thermal_expansion.f90 b/src/phase_mechanics_anelastic_thermalexpansion.f90 similarity index 100% rename from src/kinematics_thermal_expansion.f90 rename to src/phase_mechanics_anelastic_thermalexpansion.f90 diff --git a/src/constitutive_plastic_disloTungsten.f90 b/src/phase_mechanics_plastic_dislotungsten.f90 similarity index 100% rename from src/constitutive_plastic_disloTungsten.f90 rename to src/phase_mechanics_plastic_dislotungsten.f90 diff --git a/src/constitutive_plastic_dislotwin.f90 b/src/phase_mechanics_plastic_dislotwin.f90 similarity index 100% rename from src/constitutive_plastic_dislotwin.f90 rename to src/phase_mechanics_plastic_dislotwin.f90 diff --git a/src/constitutive_plastic_isotropic.f90 b/src/phase_mechanics_plastic_isotropic.f90 similarity index 100% rename from src/constitutive_plastic_isotropic.f90 rename to src/phase_mechanics_plastic_isotropic.f90 diff --git a/src/constitutive_plastic_kinehardening.f90 b/src/phase_mechanics_plastic_kinehardening.f90 similarity index 100% rename from src/constitutive_plastic_kinehardening.f90 rename to src/phase_mechanics_plastic_kinehardening.f90 diff --git a/src/constitutive_plastic_none.f90 b/src/phase_mechanics_plastic_none.f90 similarity index 100% rename from src/constitutive_plastic_none.f90 rename to src/phase_mechanics_plastic_none.f90 diff --git a/src/constitutive_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 similarity index 100% rename from src/constitutive_plastic_nonlocal.f90 rename to src/phase_mechanics_plastic_nonlocal.f90 diff --git a/src/constitutive_plastic_phenopowerlaw.f90 b/src/phase_mechanics_plastic_phenopowerlaw.f90 similarity index 100% rename from src/constitutive_plastic_phenopowerlaw.f90 rename to src/phase_mechanics_plastic_phenopowerlaw.f90 diff --git a/src/constitutive_thermal.f90 b/src/phase_thermal.f90 similarity index 100% rename from src/constitutive_thermal.f90 rename to src/phase_thermal.f90 diff --git a/src/constitutive_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 similarity index 100% rename from src/constitutive_thermal_dissipation.f90 rename to src/phase_thermal_dissipation.f90 diff --git a/src/constitutive_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 similarity index 100% rename from src/constitutive_thermal_externalheat.f90 rename to src/phase_thermal_externalheat.f90 From 88fb82abc87588beff060a7a798ce9dd72fcd0e5 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 26 Jan 2021 12:20:11 +0100 Subject: [PATCH 160/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-355-gbd9bb5c7c --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5190c13c9..62377fd35 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-329-gda93031cb +v3.0.0-alpha2-355-gbd9bb5c7c From 7a4ad53b8c12ad9f33cd3843b9a6a88b19766646 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 16:55:19 +0100 Subject: [PATCH 161/352] don't rely on compiler to remove dead loops --- src/homogenization.f90 | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 48919b46d..9b8c33c2e 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -313,25 +313,25 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE enddo !$OMP END DO - !$OMP DO PRIVATE(ho,ph,ce) - do el = FEsolving_execElem(1),FEsolving_execElem(2) - if (terminallyIll) continue - ho = material_homogenizationAt(el) - do ip = FEsolving_execIP(1),FEsolving_execIP(2) - ce = (el-1)*discretization_nIPs + ip - ! call damage_partition(ce) - ! do co = 1, homogenization_Nconstituents(ho) - ! ph = material_phaseAt(co,el) - ! if (.not. thermal_stress(dt,ph,material_phaseMemberAt(co,ip,el))) then - ! if (.not. terminallyIll) & ! so first signals terminally ill... - ! print*, ' Integration point ', ip,' at element ', el, ' terminally ill' - ! terminallyIll = .true. ! ...and kills all others - ! endif - ! call thermal_homogenize(ip,el) - ! enddo - enddo - enddo - !$OMP END DO +! !$OMP DO PRIVATE(ho,ph,ce) +! do el = FEsolving_execElem(1),FEsolving_execElem(2) +! if (terminallyIll) continue +! ho = material_homogenizationAt(el) +! do ip = FEsolving_execIP(1),FEsolving_execIP(2) +! ce = (el-1)*discretization_nIPs + ip +! call damage_partition(ce) +! do co = 1, homogenization_Nconstituents(ho) +! ph = material_phaseAt(co,el) +! if (.not. thermal_stress(dt,ph,material_phaseMemberAt(co,ip,el))) then +! if (.not. terminallyIll) & ! so first signals terminally ill... +! print*, ' Integration point ', ip,' at element ', el, ' terminally ill' +! terminallyIll = .true. ! ...and kills all others +! endif +! call thermal_homogenize(ip,el) +! enddo +! enddo +! enddo +! !$OMP END DO !$OMP DO PRIVATE(ho) elementLooping3: do el = FEsolving_execElem(1),FEsolving_execElem(2) From a51b32ccdf9cf2649f87702fc4065ba7a57e3ded Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 26 Jan 2021 20:18:04 +0100 Subject: [PATCH 162/352] only input --- src/HDF5_utilities.f90 | 84 +++++++++++++++++++++--------------------- src/results.f90 | 16 ++++---- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/HDF5_utilities.f90 b/src/HDF5_utilities.f90 index 88b8d960d..781089ad8 100644 --- a/src/HDF5_utilities.f90 +++ b/src/HDF5_utilities.f90 @@ -1086,9 +1086,9 @@ end subroutine HDF5_read_int7 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_real1(loc_id,dataset,datasetName,parallel) - real(pReal), intent(inout), dimension(:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + real(pReal), intent(in), dimension(:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1127,9 +1127,9 @@ end subroutine HDF5_write_real1 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_real2(loc_id,dataset,datasetName,parallel) - real(pReal), intent(inout), dimension(:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + real(pReal), intent(in), dimension(:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1168,9 +1168,9 @@ end subroutine HDF5_write_real2 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_real3(loc_id,dataset,datasetName,parallel) - real(pReal), intent(inout), dimension(:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + real(pReal), intent(in), dimension(:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1209,9 +1209,9 @@ end subroutine HDF5_write_real3 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_real4(loc_id,dataset,datasetName,parallel) - real(pReal), intent(inout), dimension(:,:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + real(pReal), intent(in), dimension(:,:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1251,9 +1251,9 @@ end subroutine HDF5_write_real4 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_real5(loc_id,dataset,datasetName,parallel) - real(pReal), intent(inout), dimension(:,:,:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + real(pReal), intent(in), dimension(:,:,:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1292,9 +1292,9 @@ end subroutine HDF5_write_real5 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_real6(loc_id,dataset,datasetName,parallel) - real(pReal), intent(inout), dimension(:,:,:,:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + real(pReal), intent(in), dimension(:,:,:,:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1333,9 +1333,9 @@ end subroutine HDF5_write_real6 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_real7(loc_id,dataset,datasetName,parallel) - real(pReal), intent(inout), dimension(:,:,:,:,:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + real(pReal), intent(in), dimension(:,:,:,:,:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1375,9 +1375,9 @@ end subroutine HDF5_write_real7 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_int1(loc_id,dataset,datasetName,parallel) - integer, intent(inout), dimension(:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + integer, intent(in), dimension(:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1416,9 +1416,9 @@ end subroutine HDF5_write_int1 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_int2(loc_id,dataset,datasetName,parallel) - integer, intent(inout), dimension(:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + integer, intent(in), dimension(:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1457,9 +1457,9 @@ end subroutine HDF5_write_int2 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_int3(loc_id,dataset,datasetName,parallel) - integer, intent(inout), dimension(:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + integer, intent(in), dimension(:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1498,9 +1498,9 @@ end subroutine HDF5_write_int3 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_int4(loc_id,dataset,datasetName,parallel) - integer, intent(inout), dimension(:,:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + integer, intent(in), dimension(:,:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1539,9 +1539,9 @@ end subroutine HDF5_write_int4 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_int5(loc_id,dataset,datasetName,parallel) - integer, intent(inout), dimension(:,:,:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + integer, intent(in), dimension(:,:,:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1580,9 +1580,9 @@ end subroutine HDF5_write_int5 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_int6(loc_id,dataset,datasetName,parallel) - integer, intent(inout), dimension(:,:,:,:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + integer, intent(in), dimension(:,:,:,:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes @@ -1621,9 +1621,9 @@ end subroutine HDF5_write_int6 !-------------------------------------------------------------------------------------------------- subroutine HDF5_write_int7(loc_id,dataset,datasetName,parallel) - integer, intent(inout), dimension(:,:,:,:,:,:,:) :: dataset !< data written to file - integer(HID_T), intent(in) :: loc_id !< file or group handle - character(len=*), intent(in) :: datasetName !< name of the dataset in the file + integer, intent(in), dimension(:,:,:,:,:,:,:) :: dataset !< data written to file + integer(HID_T), intent(in) :: loc_id !< file or group handle + character(len=*), intent(in) :: datasetName !< name of the dataset in the file logical, intent(in), optional :: parallel !< dataset is distributed over multiple processes diff --git a/src/results.f90 b/src/results.f90 index 6363e3efc..7cb518e83 100644 --- a/src/results.f90 +++ b/src/results.f90 @@ -283,7 +283,7 @@ subroutine results_writeScalarDataset_real(group,dataset,label,description,SIuni character(len=*), intent(in) :: label,group,description character(len=*), intent(in), optional :: SIunit - real(pReal), intent(inout), dimension(:) :: dataset + real(pReal), intent(in), dimension(:) :: dataset integer(HID_T) :: groupHandle @@ -314,7 +314,7 @@ subroutine results_writeVectorDataset_real(group,dataset,label,description,SIuni character(len=*), intent(in) :: label,group,description character(len=*), intent(in), optional :: SIunit - real(pReal), intent(inout), dimension(:,:) :: dataset + real(pReal), intent(in), dimension(:,:) :: dataset integer(HID_T) :: groupHandle @@ -397,9 +397,9 @@ end subroutine results_writeTensorDataset_real !-------------------------------------------------------------------------------------------------- subroutine results_writeVectorDataset_int(group,dataset,label,description,SIunit) - character(len=*), intent(in) :: label,group,description - character(len=*), intent(in), optional :: SIunit - integer, intent(inout), dimension(:,:) :: dataset + character(len=*), intent(in) :: label,group,description + character(len=*), intent(in), optional :: SIunit + integer, intent(in), dimension(:,:) :: dataset integer(HID_T) :: groupHandle @@ -429,9 +429,9 @@ end subroutine results_writeVectorDataset_int !-------------------------------------------------------------------------------------------------- subroutine results_writeTensorDataset_int(group,dataset,label,description,SIunit) - character(len=*), intent(in) :: label,group,description - character(len=*), intent(in), optional :: SIunit - integer, intent(inout), dimension(:,:,:) :: dataset + character(len=*), intent(in) :: label,group,description + character(len=*), intent(in), optional :: SIunit + integer, intent(in), dimension(:,:,:) :: dataset integer(HID_T) :: groupHandle From dff0434eb57344b05023351d0283220a685d5951 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 20:27:04 +0100 Subject: [PATCH 163/352] bugfix: correct file name and compilation order --- src/commercialFEM_fileList.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 42da97db7..257d6518d 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -27,12 +27,12 @@ #include "phase_mechanics_plastic_phenopowerlaw.f90" #include "phase_mechanics_plastic_kinehardening.f90" #include "phase_mechanics_plastic_dislotwin.f90" -#include "phase_mechanics_plastic_disloTungsten.f90" +#include "phase_mechanics_plastic_dislotungsten.f90" #include "phase_mechanics_plastic_nonlocal.f90" -#include "phase_mechancis_anelastic_thermalexpansion.f90" #include "phase_mechanics_anelastic_cleavageopening.f90" #include "phase_mechanics_anelastic_slipplaneopening.f90" #include "phase_thermal.f90" +#include "phase_mechanics_anelastic_thermalexpansion.f90" #include "phase_thermal_dissipation.f90" #include "phase_thermal_externalheat.f90" #include "phase_damage.f90" From 1d0d05855a857c631a2490a558e95c481d660db9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 25 Jan 2021 23:38:32 +0100 Subject: [PATCH 164/352] no need to prefix local functions --- src/phase_damage.f90 | 208 +++++++++++++++--------------- src/phase_damage_anisobrittle.f90 | 12 +- src/phase_damage_anisoductile.f90 | 12 +- src/phase_damage_isobrittle.f90 | 8 +- src/phase_damage_isoductile.f90 | 12 +- 5 files changed, 126 insertions(+), 126 deletions(-) diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index c1e555299..72be51be1 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -22,25 +22,25 @@ submodule(constitutive) constitutive_damage interface - module function source_damage_anisoBrittle_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources - end function source_damage_anisoBrittle_init + module function anisobrittle_init(source_length) result(mySources) + integer, intent(in) :: source_length + logical, dimension(:,:), allocatable :: mySources + end function anisobrittle_init - module function source_damage_anisoDuctile_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources - end function source_damage_anisoDuctile_init + module function anisoductile_init(source_length) result(mySources) + integer, intent(in) :: source_length + logical, dimension(:,:), allocatable :: mySources + end function anisoductile_init - module function source_damage_isoBrittle_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources - end function source_damage_isoBrittle_init + module function isobrittle_init(source_length) result(mySources) + integer, intent(in) :: source_length + logical, dimension(:,:), allocatable :: mySources + end function isobrittle_init - module function source_damage_isoDuctile_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources - end function source_damage_isoDuctile_init + module function isoductile_init(source_length) result(mySources) + integer, intent(in) :: source_length + logical, dimension(:,:), allocatable :: mySources + end function isoductile_init module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph, me) @@ -52,93 +52,93 @@ submodule(constitutive) constitutive_damage end subroutine source_damage_isoBrittle_deltaState - module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) + module subroutine anisobrittle_dotState(S, co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point ip, & !< integration point el !< element real(pReal), intent(in), dimension(3,3) :: & S - end subroutine source_damage_anisoBrittle_dotState + end subroutine anisobrittle_dotState - module subroutine source_damage_anisoDuctile_dotState(co, ip, el) + module subroutine anisoductile_dotState(co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point ip, & !< integration point el !< element - end subroutine source_damage_anisoDuctile_dotState + end subroutine anisoductile_dotState - module subroutine source_damage_isoDuctile_dotState(co, ip, el) + module subroutine isoductile_dotState(co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point ip, & !< integration point el !< element - end subroutine source_damage_isoDuctile_dotState + end subroutine isoductile_dotState - module subroutine source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - integer, intent(in) :: & - phase, & !< phase ID of element - constituent !< position of element within its phase instance - real(pReal), intent(in) :: & - phi !< damage parameter - real(pReal), intent(out) :: & - localphiDot, & - dLocalphiDot_dPhi - end subroutine source_damage_anisoBrittle_getRateAndItsTangent + module subroutine source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) + integer, intent(in) :: & + phase, & !< phase ID of element + constituent !< position of element within its phase instance + real(pReal), intent(in) :: & + phi !< damage parameter + real(pReal), intent(out) :: & + localphiDot, & + dLocalphiDot_dPhi + end subroutine source_damage_anisoBrittle_getRateAndItsTangent - module subroutine source_damage_anisoDuctile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - integer, intent(in) :: & - phase, & !< phase ID of element - constituent !< position of element within its phase instance - real(pReal), intent(in) :: & - phi !< damage parameter - real(pReal), intent(out) :: & - localphiDot, & - dLocalphiDot_dPhi - end subroutine source_damage_anisoDuctile_getRateAndItsTangent + module subroutine source_damage_anisoDuctile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) + integer, intent(in) :: & + phase, & !< phase ID of element + constituent !< position of element within its phase instance + real(pReal), intent(in) :: & + phi !< damage parameter + real(pReal), intent(out) :: & + localphiDot, & + dLocalphiDot_dPhi + end subroutine source_damage_anisoDuctile_getRateAndItsTangent - module subroutine source_damage_isoBrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - integer, intent(in) :: & - phase, & !< phase ID of element - constituent !< position of element within its phase instance - real(pReal), intent(in) :: & - phi !< damage parameter - real(pReal), intent(out) :: & - localphiDot, & - dLocalphiDot_dPhi - end subroutine source_damage_isoBrittle_getRateAndItsTangent + module subroutine source_damage_isoBrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) + integer, intent(in) :: & + phase, & !< phase ID of element + constituent !< position of element within its phase instance + real(pReal), intent(in) :: & + phi !< damage parameter + real(pReal), intent(out) :: & + localphiDot, & + dLocalphiDot_dPhi + end subroutine source_damage_isoBrittle_getRateAndItsTangent - module subroutine source_damage_isoDuctile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - integer, intent(in) :: & - phase, & !< phase ID of element - constituent !< position of element within its phase instance - real(pReal), intent(in) :: & - phi !< damage parameter - real(pReal), intent(out) :: & - localphiDot, & - dLocalphiDot_dPhi - end subroutine source_damage_isoDuctile_getRateAndItsTangent + module subroutine source_damage_isoDuctile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) + integer, intent(in) :: & + phase, & !< phase ID of element + constituent !< position of element within its phase instance + real(pReal), intent(in) :: & + phi !< damage parameter + real(pReal), intent(out) :: & + localphiDot, & + dLocalphiDot_dPhi + end subroutine source_damage_isoDuctile_getRateAndItsTangent - module subroutine source_damage_anisoBrittle_results(phase,group) - integer, intent(in) :: phase - character(len=*), intent(in) :: group - end subroutine source_damage_anisoBrittle_results + module subroutine anisobrittle_results(phase,group) + integer, intent(in) :: phase + character(len=*), intent(in) :: group + end subroutine anisobrittle_results - module subroutine source_damage_anisoDuctile_results(phase,group) - integer, intent(in) :: phase - character(len=*), intent(in) :: group - end subroutine source_damage_anisoDuctile_results + module subroutine anisoductile_results(phase,group) + integer, intent(in) :: phase + character(len=*), intent(in) :: group + end subroutine anisoductile_results - module subroutine source_damage_isoBrittle_results(phase,group) - integer, intent(in) :: phase - character(len=*), intent(in) :: group - end subroutine source_damage_isoBrittle_results + module subroutine isobrittle_results(phase,group) + integer, intent(in) :: phase + character(len=*), intent(in) :: group + end subroutine isobrittle_results - module subroutine source_damage_isoDuctile_results(phase,group) - integer, intent(in) :: phase - character(len=*), intent(in) :: group - end subroutine source_damage_isoDuctile_results + module subroutine isoductile_results(phase,group) + integer, intent(in) :: phase + character(len=*), intent(in) :: group + end subroutine isoductile_results end interface @@ -162,11 +162,11 @@ module subroutine damage_init allocate(current(phases%length)) allocate(damageState (phases%length)) - allocate(phase_Nsources(phases%length),source = 0) ! same for kinematics + allocate(phase_Nsources(phases%length),source = 0) do ph = 1,phases%length - Nconstituents = count(material_phaseAt == ph) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == ph) allocate(current(ph)%phi(Nconstituents),source=1.0_pReal) allocate(current(ph)%d_phi_d_dot_phi(Nconstituents),source=0.0_pReal) @@ -181,10 +181,10 @@ module subroutine damage_init ! initialize source mechanisms if(maxval(phase_Nsources) /= 0) then - where(source_damage_isoBrittle_init (maxval(phase_Nsources))) phase_source = DAMAGE_ISOBRITTLE_ID - where(source_damage_isoDuctile_init (maxval(phase_Nsources))) phase_source = DAMAGE_ISODUCTILE_ID - where(source_damage_anisoBrittle_init (maxval(phase_Nsources))) phase_source = DAMAGE_ANISOBRITTLE_ID - where(source_damage_anisoDuctile_init (maxval(phase_Nsources))) phase_source = DAMAGE_ANISODUCTILE_ID + where(isobrittle_init (maxval(phase_Nsources))) phase_source = DAMAGE_ISOBRITTLE_ID + where(isoductile_init (maxval(phase_Nsources))) phase_source = DAMAGE_ISODUCTILE_ID + where(anisobrittle_init (maxval(phase_Nsources))) phase_source = DAMAGE_ANISOBRITTLE_ID + where(anisoductile_init (maxval(phase_Nsources))) phase_source = DAMAGE_ANISODUCTILE_ID endif end subroutine damage_init @@ -208,30 +208,30 @@ module subroutine constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi localphiDot, & dLocalphiDot_dPhi integer :: & - phase, & - grain, & - source, & - constituent + ph, & + co, & + so, & + me phiDot = 0.0_pReal dPhiDot_dPhi = 0.0_pReal - do grain = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - phase = material_phaseAt(grain,el) - constituent = material_phasememberAt(grain,ip,el) - do source = 1, phase_Nsources(phase) - select case(phase_source(source,phase)) + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + ph = material_phaseAt(co,el) + me = material_phasememberAt(co,ip,el) + do so = 1, phase_Nsources(ph) + select case(phase_source(so,ph)) case (DAMAGE_ISOBRITTLE_ID) - call source_damage_isobrittle_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) + call source_damage_isobrittle_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, ph, me) case (DAMAGE_ISODUCTILE_ID) - call source_damage_isoductile_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) + call source_damage_isoductile_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, ph, me) case (DAMAGE_ANISOBRITTLE_ID) - call source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) + call source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) case (DAMAGE_ANISODUCTILE_ID) - call source_damage_anisoductile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) + call source_damage_anisoductile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) case default localphiDot = 0.0_pReal @@ -369,16 +369,16 @@ module subroutine damage_results(group,ph) sourceType: select case (phase_source(so,ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType - call source_damage_isoBrittle_results(ph,group//'sources/') + call isobrittle_results(ph,group//'sources/') case (DAMAGE_ISODUCTILE_ID) sourceType - call source_damage_isoDuctile_results(ph,group//'sources/') + call isoductile_results(ph,group//'sources/') case (DAMAGE_ANISOBRITTLE_ID) sourceType - call source_damage_anisoBrittle_results(ph,group//'sources/') + call anisobrittle_results(ph,group//'sources/') case (DAMAGE_ANISODUCTILE_ID) sourceType - call source_damage_anisoDuctile_results(ph,group//'sources/') + call anisoductile_results(ph,group//'sources/') end select sourceType @@ -410,13 +410,13 @@ function constitutive_damage_collectDotState(co,ip,el,ph,me) result(broken) sourceType: select case (phase_source(so,ph)) case (DAMAGE_ISODUCTILE_ID) sourceType - call source_damage_isoDuctile_dotState(co, ip, el) + call isoductile_dotState(co, ip, el) case (DAMAGE_ANISODUCTILE_ID) sourceType - call source_damage_anisoDuctile_dotState(co, ip, el) + call anisoductile_dotState(co, ip, el) case (DAMAGE_ANISOBRITTLE_ID) sourceType - call source_damage_anisoBrittle_dotState(mech_S(ph,me),co, ip, el) ! correct stress? + call anisobrittle_dotState(mech_S(ph,me),co, ip, el) ! correct stress? end select sourceType diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 8da37c5d5..095046c1c 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -35,7 +35,7 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function source_damage_anisoBrittle_init(source_length) result(mySources) +module function anisobrittle_init(source_length) result(mySources) integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources @@ -114,13 +114,13 @@ module function source_damage_anisoBrittle_init(source_length) result(mySources) enddo enddo -end function source_damage_anisoBrittle_init +end function anisobrittle_init !-------------------------------------------------------------------------------------------------- !> @brief calculates derived quantities from state !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) +module subroutine anisobrittle_dotState(S, co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point @@ -163,7 +163,7 @@ module subroutine source_damage_anisoBrittle_dotState(S, co, ip, el) enddo end associate -end subroutine source_damage_anisoBrittle_dotState +end subroutine anisobrittle_dotState !-------------------------------------------------------------------------------------------------- @@ -196,7 +196,7 @@ end subroutine source_damage_anisoBrittle_getRateAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief writes results to HDF5 output file !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_anisoBrittle_results(phase,group) +module subroutine anisobrittle_results(phase,group) integer, intent(in) :: phase character(len=*), intent(in) :: group @@ -213,6 +213,6 @@ module subroutine source_damage_anisoBrittle_results(phase,group) enddo outputsLoop end associate -end subroutine source_damage_anisoBrittle_results +end subroutine anisobrittle_results end submodule source_damage_anisoBrittle diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index b5e6fd17c..ea2b38645 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -28,7 +28,7 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function source_damage_anisoDuctile_init(source_length) result(mySources) +module function anisoductile_init(source_length) result(mySources) integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources @@ -101,13 +101,13 @@ module function source_damage_anisoDuctile_init(source_length) result(mySources) enddo -end function source_damage_anisoDuctile_init +end function anisoductile_init !-------------------------------------------------------------------------------------------------- !> @brief calculates derived quantities from state !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_anisoDuctile_dotState(co, ip, el) +module subroutine anisoductile_dotState(co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point @@ -132,7 +132,7 @@ module subroutine source_damage_anisoDuctile_dotState(co, ip, el) = sum(plasticState(ph)%slipRate(:,me)/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit) end associate -end subroutine source_damage_anisoDuctile_dotState +end subroutine anisoductile_dotState !-------------------------------------------------------------------------------------------------- @@ -165,7 +165,7 @@ end subroutine source_damage_anisoDuctile_getRateAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief writes results to HDF5 output file !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_anisoDuctile_results(phase,group) +module subroutine anisoductile_results(phase,group) integer, intent(in) :: phase character(len=*), intent(in) :: group @@ -182,6 +182,6 @@ module subroutine source_damage_anisoDuctile_results(phase,group) enddo outputsLoop end associate -end subroutine source_damage_anisoDuctile_results +end subroutine anisoductile_results end submodule source_damage_anisoDuctile diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index cff993e7f..0f192e2ae 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -26,7 +26,7 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function source_damage_isoBrittle_init(source_length) result(mySources) +module function isobrittle_init(source_length) result(mySources) integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources @@ -88,7 +88,7 @@ module function source_damage_isoBrittle_init(source_length) result(mySources) enddo -end function source_damage_isoBrittle_init +end function isobrittle_init !-------------------------------------------------------------------------------------------------- @@ -161,7 +161,7 @@ end subroutine source_damage_isoBrittle_getRateAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief writes results to HDF5 output file !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_isoBrittle_results(phase,group) +module subroutine isobrittle_results(phase,group) integer, intent(in) :: phase character(len=*), intent(in) :: group @@ -178,6 +178,6 @@ module subroutine source_damage_isoBrittle_results(phase,group) enddo outputsLoop end associate -end subroutine source_damage_isoBrittle_results +end subroutine isobrittle_results end submodule source_damage_isoBrittle diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index 3cebc474a..458b82e16 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -28,7 +28,7 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function source_damage_isoDuctile_init(source_length) result(mySources) +module function isoductile_init(source_length) result(mySources) integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources @@ -92,13 +92,13 @@ module function source_damage_isoDuctile_init(source_length) result(mySources) enddo -end function source_damage_isoDuctile_init +end function isoductile_init !-------------------------------------------------------------------------------------------------- !> @brief calculates derived quantities from state !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_isoDuctile_dotState(co, ip, el) +module subroutine isoductile_dotState(co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point @@ -123,7 +123,7 @@ module subroutine source_damage_isoDuctile_dotState(co, ip, el) sum(plasticState(ph)%slipRate(:,me))/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit end associate -end subroutine source_damage_isoDuctile_dotState +end subroutine isoductile_dotState !-------------------------------------------------------------------------------------------------- @@ -156,7 +156,7 @@ end subroutine source_damage_isoDuctile_getRateAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief writes results to HDF5 output file !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_isoDuctile_results(phase,group) +module subroutine isoductile_results(phase,group) integer, intent(in) :: phase character(len=*), intent(in) :: group @@ -173,6 +173,6 @@ module subroutine source_damage_isoDuctile_results(phase,group) enddo outputsLoop end associate -end subroutine source_damage_isoDuctile_results +end subroutine isoductile_results end submodule source_damage_isoDuctile From 4f467942ba0f471541dac1342f1c1cdd5acc9db6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 00:13:59 +0100 Subject: [PATCH 165/352] not used --- src/commercialFEM_fileList.f90 | 1 - src/future.f90 | 35 ---------------------------------- 2 files changed, 36 deletions(-) delete mode 100644 src/future.f90 diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 257d6518d..442eb48c1 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -7,7 +7,6 @@ #include "IO.f90" #include "YAML_types.f90" #include "YAML_parse.f90" -#include "future.f90" #include "config.f90" #include "LAPACK_interface.f90" #include "math.f90" diff --git a/src/future.f90 b/src/future.f90 deleted file mode 100644 index b7eb3fec9..000000000 --- a/src/future.f90 +++ /dev/null @@ -1,35 +0,0 @@ -!-------------------------------------------------------------------------------------------------- -!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH -!> @brief New fortran functions for compiler versions that do not support them -!-------------------------------------------------------------------------------------------------- -module future - use prec - - implicit none - public - -contains - -#if defined(__GFORTRAN__) && __GNUC__<9 || defined(__INTEL_COMPILER) && INTEL_COMPILER<1800 -!-------------------------------------------------------------------------------------------------- -!> @brief substitute for the findloc intrinsic (only for integer, dimension(:) at the moment) -!-------------------------------------------------------------------------------------------------- -function findloc(a,v) - - integer, intent(in), dimension(:) :: a - integer, intent(in) :: v - integer :: i,j - integer, allocatable, dimension(:) :: findloc - - allocate(findloc(count(a==v))) - j = 1 - do i = 1, size(a) - if (a(i)==v) then - findloc(j) = i - j = j + 1 - endif - enddo -end function findloc -#endif - -end module future From 912a21f5b6fe1098d1ca5be7eeb4ed1072ed0b9a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 01:11:32 +0100 Subject: [PATCH 166/352] modularizing --- src/phase_mechanics.f90 | 169 ++---------------- src/phase_mechanics_plastic.f90 | 162 +++++++++++++++++ src/phase_mechanics_plastic_dislotungsten.f90 | 4 +- src/phase_mechanics_plastic_dislotwin.f90 | 4 +- src/phase_mechanics_plastic_isotropic.f90 | 4 +- src/phase_mechanics_plastic_kinehardening.f90 | 4 +- src/phase_mechanics_plastic_none.f90 | 4 +- src/phase_mechanics_plastic_nonlocal.f90 | 4 +- src/phase_mechanics_plastic_phenopowerlaw.f90 | 4 +- 9 files changed, 192 insertions(+), 167 deletions(-) create mode 100644 src/phase_mechanics_plastic.f90 diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index 53986191b..fe0a95fbb 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -83,93 +83,6 @@ submodule(constitutive) constitutive_mech myPlasticity end function plastic_nonlocal_init - - module subroutine plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) - real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient - real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress - - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - integer, intent(in) :: & - instance, & - of - end subroutine plastic_isotropic_LpAndItsTangent - - pure module subroutine plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) - real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient - real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - integer, intent(in) :: & - instance, & - of - end subroutine plastic_phenopowerlaw_LpAndItsTangent - - pure module subroutine plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) - real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient - real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress - - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - integer, intent(in) :: & - instance, & - of - end subroutine plastic_kinehardening_LpAndItsTangent - - module subroutine plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) - real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient - real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress - - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - real(pReal), intent(in) :: & - T - integer, intent(in) :: & - instance, & - of - end subroutine plastic_dislotwin_LpAndItsTangent - - pure module subroutine plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) - real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient - real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress - - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - real(pReal), intent(in) :: & - T - integer, intent(in) :: & - instance, & - of - end subroutine plastic_dislotungsten_LpAndItsTangent - - module subroutine plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp, & - Mp,Temperature,instance,of,ip,el) - real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient - real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress - - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - real(pReal), intent(in) :: & - Temperature - integer, intent(in) :: & - instance, & - of, & - ip, & !< current integration point - el !< current element number - end subroutine plastic_nonlocal_LpAndItsTangent - module subroutine plastic_isotropic_dotState(Mp,instance,of) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress @@ -267,6 +180,22 @@ submodule(constitutive) constitutive_mech ip, & el end subroutine plastic_nonlocal_deltaState +module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & + S, Fi, co, ip, el) + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + real(pReal), intent(in), dimension(3,3) :: & + S, & !< 2nd Piola-Kirchhoff stress + Fi !< intermediate deformation gradient + real(pReal), intent(out), dimension(3,3) :: & + Lp !< plastic velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLp_dS, & + dLp_dFi !< derivative of Lp with respect to Fi + +end subroutine constitutive_plastic_LpAndItsTangents module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) integer, intent(in) :: kinematics_length @@ -621,72 +550,6 @@ module subroutine constitutive_plastic_dependentState(co, ip, el) end subroutine constitutive_plastic_dependentState -!-------------------------------------------------------------------------------------------------- -!> @brief contains the constitutive equation for calculating the velocity gradient -! ToDo: Discuss whether it makes sense if crystallite handles the configuration conversion, i.e. -! Mp in, dLp_dMp out -!-------------------------------------------------------------------------------------------------- -subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & - S, Fi, co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - real(pReal), intent(in), dimension(3,3) :: & - S, & !< 2nd Piola-Kirchhoff stress - Fi !< intermediate deformation gradient - real(pReal), intent(out), dimension(3,3) :: & - Lp !< plastic velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLp_dS, & - dLp_dFi !< derivative of Lp with respect to Fi - - real(pReal), dimension(3,3,3,3) :: & - dLp_dMp !< derivative of Lp with respect to Mandel stress - real(pReal), dimension(3,3) :: & - Mp !< Mandel stress work conjugate with Lp - integer :: & - i, j, instance, me, ph - - - Mp = matmul(matmul(transpose(Fi),Fi),S) - me = material_phasememberAt(co,ip,el) - ph = material_phaseAt(co,el) - instance = phase_plasticityInstance(ph) - - plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) - - case (PLASTICITY_NONE_ID) plasticityType - Lp = 0.0_pReal - dLp_dMp = 0.0_pReal - - case (PLASTICITY_ISOTROPIC_ID) plasticityType - call plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) - - case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType - call plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) - - case (PLASTICITY_KINEHARDENING_ID) plasticityType - call plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) - - case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me,ip,el) - - case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) - - case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) - - end select plasticityType - - do i=1,3; do j=1,3 - dLp_dFi(i,j,1:3,1:3) = matmul(matmul(Fi,S),transpose(dLp_dMp(i,j,1:3,1:3))) + & - matmul(matmul(Fi,dLp_dMp(i,j,1:3,1:3)),S) - dLp_dS(i,j,1:3,1:3) = matmul(matmul(transpose(Fi),Fi),dLp_dMp(i,j,1:3,1:3)) ! ToDo: @PS: why not: dLp_dMp:(FiT Fi) - enddo; enddo - -end subroutine constitutive_plastic_LpAndItsTangents !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 new file mode 100644 index 000000000..fdcc22027 --- /dev/null +++ b/src/phase_mechanics_plastic.f90 @@ -0,0 +1,162 @@ +submodule(constitutive:constitutive_mech) plastic + + interface + + module subroutine plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + real(pReal), dimension(3,3), intent(out) :: & + Lp !< plastic velocity gradient + real(pReal), dimension(3,3,3,3), intent(out) :: & + dLp_dMp !< derivative of Lp with respect to the Mandel stress + + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + integer, intent(in) :: & + instance, & + of + end subroutine plastic_isotropic_LpAndItsTangent + + pure module subroutine plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + real(pReal), dimension(3,3), intent(out) :: & + Lp !< plastic velocity gradient + real(pReal), dimension(3,3,3,3), intent(out) :: & + dLp_dMp !< derivative of Lp with respect to the Mandel stress + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + integer, intent(in) :: & + instance, & + of + end subroutine plastic_phenopowerlaw_LpAndItsTangent + + pure module subroutine plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + real(pReal), dimension(3,3), intent(out) :: & + Lp !< plastic velocity gradient + real(pReal), dimension(3,3,3,3), intent(out) :: & + dLp_dMp !< derivative of Lp with respect to the Mandel stress + + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + integer, intent(in) :: & + instance, & + of + end subroutine plastic_kinehardening_LpAndItsTangent + + module subroutine plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) + real(pReal), dimension(3,3), intent(out) :: & + Lp !< plastic velocity gradient + real(pReal), dimension(3,3,3,3), intent(out) :: & + dLp_dMp !< derivative of Lp with respect to the Mandel stress + + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + real(pReal), intent(in) :: & + T + integer, intent(in) :: & + instance, & + of + end subroutine plastic_dislotwin_LpAndItsTangent + + pure module subroutine plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) + real(pReal), dimension(3,3), intent(out) :: & + Lp !< plastic velocity gradient + real(pReal), dimension(3,3,3,3), intent(out) :: & + dLp_dMp !< derivative of Lp with respect to the Mandel stress + + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + real(pReal), intent(in) :: & + T + integer, intent(in) :: & + instance, & + of + end subroutine plastic_dislotungsten_LpAndItsTangent + + module subroutine plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp, & + Mp,Temperature,instance,of,ip,el) + real(pReal), dimension(3,3), intent(out) :: & + Lp !< plastic velocity gradient + real(pReal), dimension(3,3,3,3), intent(out) :: & + dLp_dMp !< derivative of Lp with respect to the Mandel stress + + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + real(pReal), intent(in) :: & + Temperature + integer, intent(in) :: & + instance, & + of, & + ip, & !< current integration point + el !< current element number + end subroutine plastic_nonlocal_LpAndItsTangent + + end interface + +contains + +!-------------------------------------------------------------------------------------------------- +!> @brief contains the constitutive equation for calculating the velocity gradient +! ToDo: Discuss whether it makes sense if crystallite handles the configuration conversion, i.e. +! Mp in, dLp_dMp out +!-------------------------------------------------------------------------------------------------- +module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & + S, Fi, co, ip, el) + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + real(pReal), intent(in), dimension(3,3) :: & + S, & !< 2nd Piola-Kirchhoff stress + Fi !< intermediate deformation gradient + real(pReal), intent(out), dimension(3,3) :: & + Lp !< plastic velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLp_dS, & + dLp_dFi !< derivative of Lp with respect to Fi + + real(pReal), dimension(3,3,3,3) :: & + dLp_dMp !< derivative of Lp with respect to Mandel stress + real(pReal), dimension(3,3) :: & + Mp !< Mandel stress work conjugate with Lp + integer :: & + i, j, instance, me, ph + + + Mp = matmul(matmul(transpose(Fi),Fi),S) + me = material_phasememberAt(co,ip,el) + ph = material_phaseAt(co,el) + instance = phase_plasticityInstance(ph) + + plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) + + case (PLASTICITY_NONE_ID) plasticityType + Lp = 0.0_pReal + dLp_dMp = 0.0_pReal + + case (PLASTICITY_ISOTROPIC_ID) plasticityType + call plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + + case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType + call plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + + case (PLASTICITY_KINEHARDENING_ID) plasticityType + call plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + + case (PLASTICITY_NONLOCAL_ID) plasticityType + call plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me,ip,el) + + case (PLASTICITY_DISLOTWIN_ID) plasticityType + call plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) + + case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType + call plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) + + end select plasticityType + + do i=1,3; do j=1,3 + dLp_dFi(i,j,1:3,1:3) = matmul(matmul(Fi,S),transpose(dLp_dMp(i,j,1:3,1:3))) + & + matmul(matmul(Fi,dLp_dMp(i,j,1:3,1:3)),S) + dLp_dS(i,j,1:3,1:3) = matmul(matmul(transpose(Fi),Fi),dLp_dMp(i,j,1:3,1:3)) ! ToDo: @PS: why not: dLp_dMp:(FiT Fi) + enddo; enddo + +end subroutine constitutive_plastic_LpAndItsTangents + +end submodule plastic diff --git a/src/phase_mechanics_plastic_dislotungsten.f90 b/src/phase_mechanics_plastic_dislotungsten.f90 index c39ae5c2b..8b258ab2a 100644 --- a/src/phase_mechanics_plastic_dislotungsten.f90 +++ b/src/phase_mechanics_plastic_dislotungsten.f90 @@ -5,7 +5,7 @@ !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH !> @brief crystal plasticity model for bcc metals, especially Tungsten !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_mech) plastic_dislotungsten +submodule(constitutive:plastic) dislotungsten real(pReal), parameter :: & kB = 1.38e-23_pReal !< Boltzmann constant in J/Kelvin @@ -547,4 +547,4 @@ pure subroutine kinetics(Mp,T,instance,of, & end subroutine kinetics -end submodule plastic_dislotungsten +end submodule dislotungsten diff --git a/src/phase_mechanics_plastic_dislotwin.f90 b/src/phase_mechanics_plastic_dislotwin.f90 index dea84f751..c2b19013e 100644 --- a/src/phase_mechanics_plastic_dislotwin.f90 +++ b/src/phase_mechanics_plastic_dislotwin.f90 @@ -7,7 +7,7 @@ !> @brief material subroutine incoprorating dislocation and twinning physics !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_mech) plastic_dislotwin +submodule(constitutive:plastic) dislotwin real(pReal), parameter :: & kB = 1.38e-23_pReal !< Boltzmann constant in J/Kelvin @@ -1088,4 +1088,4 @@ pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,instance,of,& end subroutine kinetics_trans -end submodule plastic_dislotwin +end submodule dislotwin diff --git a/src/phase_mechanics_plastic_isotropic.f90 b/src/phase_mechanics_plastic_isotropic.f90 index b7c5f67c1..eab9b67cc 100644 --- a/src/phase_mechanics_plastic_isotropic.f90 +++ b/src/phase_mechanics_plastic_isotropic.f90 @@ -7,7 +7,7 @@ !! resolving the stress on the slip systems. Will give the response of phenopowerlaw for an !! untextured polycrystal !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_mech) plastic_isotropic +submodule(constitutive:plastic) isotropic type :: tParameters real(pReal) :: & @@ -348,4 +348,4 @@ module subroutine plastic_isotropic_results(instance,group) end subroutine plastic_isotropic_results -end submodule plastic_isotropic +end submodule isotropic diff --git a/src/phase_mechanics_plastic_kinehardening.f90 b/src/phase_mechanics_plastic_kinehardening.f90 index 8454b28f8..4a92f6567 100644 --- a/src/phase_mechanics_plastic_kinehardening.f90 +++ b/src/phase_mechanics_plastic_kinehardening.f90 @@ -5,7 +5,7 @@ !> @brief Phenomenological crystal plasticity using a power law formulation for the shear rates !! and a Voce-type kinematic hardening rule !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_mech) plastic_kinehardening +submodule(constitutive:plastic) kinehardening type :: tParameters real(pReal) :: & @@ -474,4 +474,4 @@ pure subroutine kinetics(Mp,instance,of, & end subroutine kinetics -end submodule plastic_kinehardening +end submodule kinehardening diff --git a/src/phase_mechanics_plastic_none.f90 b/src/phase_mechanics_plastic_none.f90 index 27a01fb93..88fa6a5c2 100644 --- a/src/phase_mechanics_plastic_none.f90 +++ b/src/phase_mechanics_plastic_none.f90 @@ -4,7 +4,7 @@ !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH !> @brief Dummy plasticity for purely elastic material !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_mech) plastic_none +submodule(constitutive:plastic) none contains @@ -50,4 +50,4 @@ module function plastic_none_init() result(myPlasticity) end function plastic_none_init -end submodule plastic_none +end submodule none diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 index 2244eb7ad..648a6cbe4 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanics_plastic_nonlocal.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH !> @brief material subroutine for plasticity including dislocation flux !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_mech) plastic_nonlocal +submodule(constitutive:plastic) nonlocal use geometry_plastic_nonlocal, only: & nIPneighbors => geometry_plastic_nonlocal_nIPneighbors, & IPneighborhood => geometry_plastic_nonlocal_IPneighborhood, & @@ -1834,4 +1834,4 @@ pure function getRho0(instance,of,ip,el) end function getRho0 -end submodule plastic_nonlocal +end submodule nonlocal diff --git a/src/phase_mechanics_plastic_phenopowerlaw.f90 b/src/phase_mechanics_plastic_phenopowerlaw.f90 index 678acad27..39ceb1000 100644 --- a/src/phase_mechanics_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanics_plastic_phenopowerlaw.f90 @@ -4,7 +4,7 @@ !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH !> @brief phenomenological crystal plasticity formulation using a powerlaw fitting !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_mech) plastic_phenopowerlaw +submodule(constitutive:plastic) phenopowerlaw type :: tParameters real(pReal) :: & @@ -543,4 +543,4 @@ pure subroutine kinetics_twin(Mp,instance,of,& end subroutine kinetics_twin -end submodule plastic_phenopowerlaw +end submodule phenopowerlaw From 17ec5f378efff8c9a08ed6b6d4fac51bd65a4a2d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 01:20:45 +0100 Subject: [PATCH 167/352] short names --- src/homogenization_thermal.f90 | 4 ++-- src/phase_mechanics_anelastic_thermalexpansion.f90 | 4 ++-- src/phase_thermal.f90 | 4 ++-- src/phase_thermal_dissipation.f90 | 4 ++-- src/phase_thermal_externalheat.f90 | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index 6a12730ac..87ba8301a 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -1,7 +1,7 @@ !-------------------------------------------------------------------------------------------------- !> @author Martin Diehl, KU Leuven !-------------------------------------------------------------------------------------------------- -submodule(homogenization) homogenization_thermal +submodule(homogenization) thermal use lattice @@ -236,4 +236,4 @@ module subroutine thermal_conduction_getSource(Tdot, ip,el) end subroutine thermal_conduction_getSource -end submodule homogenization_thermal +end submodule thermal diff --git a/src/phase_mechanics_anelastic_thermalexpansion.f90 b/src/phase_mechanics_anelastic_thermalexpansion.f90 index 6e4fa8263..32bf30e75 100644 --- a/src/phase_mechanics_anelastic_thermalexpansion.f90 +++ b/src/phase_mechanics_anelastic_thermalexpansion.f90 @@ -3,7 +3,7 @@ !> @brief material subroutine incorporating kinematics resulting from thermal expansion !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_thermal) kinematics_thermal_expansion +submodule(constitutive:thermal) thermalexpansion integer, dimension(:), allocatable :: kinematics_thermal_expansion_instance @@ -116,4 +116,4 @@ module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, p end subroutine kinematics_thermal_expansion_LiAndItsTangent -end submodule kinematics_thermal_expansion +end submodule thermalexpansion diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 831fd236d..3a691111c 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -1,7 +1,7 @@ !---------------------------------------------------------------------------------------------------- !> @brief internal microstructure state for all thermal sources and kinematics constitutive models !---------------------------------------------------------------------------------------------------- -submodule(constitutive) constitutive_thermal +submodule(constitutive) thermal enum, bind(c); enumerator :: & THERMAL_UNDEFINED_ID ,& @@ -318,4 +318,4 @@ function thermal_active(source_label,src_length) result(active_source) end function thermal_active -end submodule constitutive_thermal +end submodule thermal diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index ae2d5735e..9519ba6ab 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine for thermal source due to plastic dissipation !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_thermal) source_dissipation +submodule(constitutive:thermal) dissipation integer, dimension(:), allocatable :: & source_thermal_dissipation_offset, & !< which source is my current thermal dissipation mechanism? @@ -96,4 +96,4 @@ module subroutine thermal_dissipation_getRate(TDot, Tstar, Lp, phase) end subroutine thermal_dissipation_getRate -end submodule source_dissipation +end submodule dissipation diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index 16b2bdb65..2d2e92bfa 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Michigan State University !> @brief material subroutine for variable heat source !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_thermal) source_externalheat +submodule(constitutive:thermal) externalheat integer, dimension(:), allocatable :: & @@ -134,4 +134,4 @@ module subroutine thermal_externalheat_getRate(TDot, ph, me) end subroutine thermal_externalheat_getRate -end submodule source_externalheat +end submodule externalheat From 4d52a25e7e412a0926a34a67b8d9d10e5cf22bd3 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 07:33:04 +0100 Subject: [PATCH 168/352] hierarchical naming --- src/phase_mechanics_plastic.f90 | 36 +++++++++---------- src/phase_mechanics_plastic_dislotungsten.f90 | 4 +-- src/phase_mechanics_plastic_dislotwin.f90 | 4 +-- src/phase_mechanics_plastic_isotropic.f90 | 4 +-- src/phase_mechanics_plastic_kinehardening.f90 | 4 +-- src/phase_mechanics_plastic_nonlocal.f90 | 4 +-- src/phase_mechanics_plastic_phenopowerlaw.f90 | 4 +-- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index fdcc22027..096621dfd 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -2,7 +2,7 @@ submodule(constitutive:constitutive_mech) plastic interface - module subroutine plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -13,9 +13,9 @@ submodule(constitutive:constitutive_mech) plastic integer, intent(in) :: & instance, & of - end subroutine plastic_isotropic_LpAndItsTangent + end subroutine isotropic_LpAndItsTangent - pure module subroutine plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -25,9 +25,9 @@ submodule(constitutive:constitutive_mech) plastic integer, intent(in) :: & instance, & of - end subroutine plastic_phenopowerlaw_LpAndItsTangent + end subroutine phenopowerlaw_LpAndItsTangent - pure module subroutine plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -38,9 +38,9 @@ submodule(constitutive:constitutive_mech) plastic integer, intent(in) :: & instance, & of - end subroutine plastic_kinehardening_LpAndItsTangent + end subroutine kinehardening_LpAndItsTangent - module subroutine plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) + module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -53,9 +53,9 @@ submodule(constitutive:constitutive_mech) plastic integer, intent(in) :: & instance, & of - end subroutine plastic_dislotwin_LpAndItsTangent + end subroutine dislotwin_LpAndItsTangent - pure module subroutine plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) + pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -68,9 +68,9 @@ submodule(constitutive:constitutive_mech) plastic integer, intent(in) :: & instance, & of - end subroutine plastic_dislotungsten_LpAndItsTangent + end subroutine dislotungsten_LpAndItsTangent - module subroutine plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp, & + module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & Mp,Temperature,instance,of,ip,el) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -86,7 +86,7 @@ submodule(constitutive:constitutive_mech) plastic of, & ip, & !< current integration point el !< current element number - end subroutine plastic_nonlocal_LpAndItsTangent + end subroutine nonlocal_LpAndItsTangent end interface @@ -132,22 +132,22 @@ module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & dLp_dMp = 0.0_pReal case (PLASTICITY_ISOTROPIC_ID) plasticityType - call plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + call isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType - call plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + call phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) case (PLASTICITY_KINEHARDENING_ID) plasticityType - call plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + call kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me,ip,el) + call nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me,ip,el) case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) + call dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) + call dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) end select plasticityType diff --git a/src/phase_mechanics_plastic_dislotungsten.f90 b/src/phase_mechanics_plastic_dislotungsten.f90 index 8b258ab2a..0f4b92af7 100644 --- a/src/phase_mechanics_plastic_dislotungsten.f90 +++ b/src/phase_mechanics_plastic_dislotungsten.f90 @@ -272,7 +272,7 @@ end function plastic_dislotungsten_init !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -pure module subroutine plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & +pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & Mp,T,instance,of) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -309,7 +309,7 @@ pure module subroutine plastic_dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & end associate -end subroutine plastic_dislotungsten_LpAndItsTangent +end subroutine dislotungsten_LpAndItsTangent !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic_dislotwin.f90 b/src/phase_mechanics_plastic_dislotwin.f90 index c2b19013e..7fb73f1c8 100644 --- a/src/phase_mechanics_plastic_dislotwin.f90 +++ b/src/phase_mechanics_plastic_dislotwin.f90 @@ -521,7 +521,7 @@ end function plastic_dislotwin_homogenizedC !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) +module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) real(pReal), dimension(3,3), intent(out) :: Lp real(pReal), dimension(3,3,3,3), intent(out) :: dLp_dMp @@ -628,7 +628,7 @@ module subroutine plastic_dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) end associate -end subroutine plastic_dislotwin_LpAndItsTangent +end subroutine dislotwin_LpAndItsTangent !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic_isotropic.f90 b/src/phase_mechanics_plastic_isotropic.f90 index eab9b67cc..9fb6bcae5 100644 --- a/src/phase_mechanics_plastic_isotropic.f90 +++ b/src/phase_mechanics_plastic_isotropic.f90 @@ -168,7 +168,7 @@ end function plastic_isotropic_init !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) +module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -222,7 +222,7 @@ module subroutine plastic_isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) end associate -end subroutine plastic_isotropic_LpAndItsTangent +end subroutine isotropic_LpAndItsTangent !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic_kinehardening.f90 b/src/phase_mechanics_plastic_kinehardening.f90 index 4a92f6567..69322e234 100644 --- a/src/phase_mechanics_plastic_kinehardening.f90 +++ b/src/phase_mechanics_plastic_kinehardening.f90 @@ -240,7 +240,7 @@ end function plastic_kinehardening_init !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -pure module subroutine plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) +pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -276,7 +276,7 @@ pure module subroutine plastic_kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,insta end associate -end subroutine plastic_kinehardening_LpAndItsTangent +end subroutine kinehardening_LpAndItsTangent !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 index 648a6cbe4..1d37907cf 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanics_plastic_nonlocal.f90 @@ -759,7 +759,7 @@ end subroutine plastic_nonlocal_dependentState !-------------------------------------------------------------------------------------------------- !> @brief calculates plastic velocity gradient and its tangent !-------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp, & +module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & Mp,Temperature,instance,of,ip,el) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -861,7 +861,7 @@ module subroutine plastic_nonlocal_LpAndItsTangent(Lp,dLp_dMp, & end associate -end subroutine plastic_nonlocal_LpAndItsTangent +end subroutine nonlocal_LpAndItsTangent !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic_phenopowerlaw.f90 b/src/phase_mechanics_plastic_phenopowerlaw.f90 index 39ceb1000..802bfa9b8 100644 --- a/src/phase_mechanics_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanics_plastic_phenopowerlaw.f90 @@ -285,7 +285,7 @@ end function plastic_phenopowerlaw_init !> @details asummes that deformation by dislocation glide affects twinned and untwinned volume ! equally (Taylor assumption). Twinning happens only in untwinned volume !-------------------------------------------------------------------------------------------------- -pure module subroutine plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) +pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -330,7 +330,7 @@ pure module subroutine plastic_phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,insta end associate -end subroutine plastic_phenopowerlaw_LpAndItsTangent +end subroutine phenopowerlaw_LpAndItsTangent !-------------------------------------------------------------------------------------------------- From 11046f708e8078cf4147cada034b6375aa2980a7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 07:54:24 +0100 Subject: [PATCH 169/352] simplified --- src/phase_mechanics_plastic_dislotungsten.f90 | 4 ++-- src/phase_mechanics_plastic_dislotwin.f90 | 2 +- src/phase_mechanics_plastic_isotropic.f90 | 2 +- src/phase_mechanics_plastic_kinehardening.f90 | 2 +- src/phase_mechanics_plastic_none.f90 | 2 +- src/phase_mechanics_plastic_nonlocal.f90 | 2 +- src/phase_mechanics_plastic_phenopowerlaw.f90 | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/phase_mechanics_plastic_dislotungsten.f90 b/src/phase_mechanics_plastic_dislotungsten.f90 index 0f4b92af7..08da6f1dc 100644 --- a/src/phase_mechanics_plastic_dislotungsten.f90 +++ b/src/phase_mechanics_plastic_dislotungsten.f90 @@ -103,7 +103,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) Ninstances = count(myPlasticity) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return - + print*, 'Cereceda et al., International Journal of Plasticity 78:242–256, 2016' print*, 'https://dx.doi.org/10.1016/j.ijplas.2015.09.002' @@ -222,7 +222,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt == p) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == p) sizeDotState = size(['rho_mob ','rho_dip ','gamma_sl']) * prm%sum_N_sl sizeState = sizeDotState diff --git a/src/phase_mechanics_plastic_dislotwin.f90 b/src/phase_mechanics_plastic_dislotwin.f90 index 7fb73f1c8..8c7ae78ba 100644 --- a/src/phase_mechanics_plastic_dislotwin.f90 +++ b/src/phase_mechanics_plastic_dislotwin.f90 @@ -408,7 +408,7 @@ module function plastic_dislotwin_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt == p) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == p) sizeDotState = size(['rho_mob ','rho_dip ','gamma_sl']) * prm%sum_N_sl & + size(['f_tw']) * prm%sum_N_tw & + size(['f_tr']) * prm%sum_N_tr diff --git a/src/phase_mechanics_plastic_isotropic.f90 b/src/phase_mechanics_plastic_isotropic.f90 index 9fb6bcae5..a2ef157d4 100644 --- a/src/phase_mechanics_plastic_isotropic.f90 +++ b/src/phase_mechanics_plastic_isotropic.f90 @@ -131,7 +131,7 @@ module function plastic_isotropic_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt == p) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == p) sizeDotState = size(['xi ','gamma']) sizeState = sizeDotState diff --git a/src/phase_mechanics_plastic_kinehardening.f90 b/src/phase_mechanics_plastic_kinehardening.f90 index 69322e234..1fb8588d8 100644 --- a/src/phase_mechanics_plastic_kinehardening.f90 +++ b/src/phase_mechanics_plastic_kinehardening.f90 @@ -175,7 +175,7 @@ module function plastic_kinehardening_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt == p) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == p) sizeDotState = size(['crss ','crss_back', 'accshear ']) * prm%sum_N_sl!ToDo: adjust names, ask Philip sizeDeltaState = size(['sense ', 'chi0 ', 'gamma0' ]) * prm%sum_N_sl !ToDo: adjust names sizeState = sizeDotState + sizeDeltaState diff --git a/src/phase_mechanics_plastic_none.f90 b/src/phase_mechanics_plastic_none.f90 index 88fa6a5c2..b09b4fc39 100644 --- a/src/phase_mechanics_plastic_none.f90 +++ b/src/phase_mechanics_plastic_none.f90 @@ -43,7 +43,7 @@ module function plastic_none_init() result(myPlasticity) do p = 1, phases%length phase => phases%get(p) if(.not. myPlasticity(p)) cycle - Nconstituents = count(material_phaseAt == p) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == p) call constitutive_allocateState(plasticState(p),Nconstituents,0,0,0) enddo diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 index 1d37907cf..c023e685e 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanics_plastic_nonlocal.f90 @@ -393,7 +393,7 @@ module function plastic_nonlocal_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt==p) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == p) sizeDotState = size([ 'rhoSglEdgePosMobile ','rhoSglEdgeNegMobile ', & 'rhoSglScrewPosMobile ','rhoSglScrewNegMobile ', & 'rhoSglEdgePosImmobile ','rhoSglEdgeNegImmobile ', & diff --git a/src/phase_mechanics_plastic_phenopowerlaw.f90 b/src/phase_mechanics_plastic_phenopowerlaw.f90 index 802bfa9b8..60951e7c4 100644 --- a/src/phase_mechanics_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanics_plastic_phenopowerlaw.f90 @@ -225,7 +225,7 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt == p) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == p) sizeDotState = size(['xi_sl ','gamma_sl']) * prm%sum_N_sl & + size(['xi_tw ','gamma_tw']) * prm%sum_N_tw sizeState = sizeDotState From 85dcd7af1655d59e6783a01fccac3ab62d3bf972 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 07:55:06 +0100 Subject: [PATCH 170/352] hierarchical naming --- src/phase_thermal.f90 | 73 +++++++++++++++--------------- src/phase_thermal_dissipation.f90 | 4 +- src/phase_thermal_externalheat.f90 | 8 ++-- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 3a691111c..c0a999bde 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -18,49 +18,50 @@ submodule(constitutive) thermal type(tDataContainer), dimension(:), allocatable :: current integer :: thermal_source_maxSizeDotState + + interface - module function source_thermal_dissipation_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources - end function source_thermal_dissipation_init + module function dissipation_init(source_length) result(mySources) + integer, intent(in) :: source_length + logical, dimension(:,:), allocatable :: mySources + end function dissipation_init - module function source_thermal_externalheat_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources - end function source_thermal_externalheat_init + module function externalheat_init(source_length) result(mySources) + integer, intent(in) :: source_length + logical, dimension(:,:), allocatable :: mySources + end function externalheat_init - module function kinematics_thermal_expansion_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_thermal_expansion_init + module function kinematics_thermal_expansion_init(kinematics_length) result(myKinematics) + integer, intent(in) :: kinematics_length + logical, dimension(:,:), allocatable :: myKinematics + end function kinematics_thermal_expansion_init - module subroutine source_thermal_externalheat_dotState(ph, me) + module subroutine externalheat_dotState(ph, me) integer, intent(in) :: & ph, & me - end subroutine source_thermal_externalheat_dotState + end subroutine externalheat_dotState + module subroutine thermal_dissipation_getRate(TDot, Tstar,Lp,phase) + integer, intent(in) :: & + phase !< phase ID of element + real(pReal), intent(in), dimension(3,3) :: & + Tstar !< 2nd Piola Kirchhoff stress tensor for a given element + real(pReal), intent(in), dimension(3,3) :: & + Lp !< plastic velocuty gradient for a given element + real(pReal), intent(out) :: & + TDot + end subroutine thermal_dissipation_getRate - module subroutine thermal_dissipation_getRate(TDot, Tstar,Lp,phase) - integer, intent(in) :: & - phase !< phase ID of element - real(pReal), intent(in), dimension(3,3) :: & - Tstar !< 2nd Piola Kirchhoff stress tensor for a given element - real(pReal), intent(in), dimension(3,3) :: & - Lp !< plastic velocuty gradient for a given element - real(pReal), intent(out) :: & - TDot - end subroutine thermal_dissipation_getRate - - module subroutine thermal_externalheat_getRate(TDot, ph,me) - integer, intent(in) :: & - ph, & - me - real(pReal), intent(out) :: & - TDot - end subroutine thermal_externalheat_getRate + module subroutine thermal_externalheat_getRate(TDot, ph,me) + integer, intent(in) :: & + ph, & + me + real(pReal), intent(out) :: & + TDot + end subroutine thermal_externalheat_getRate end interface @@ -91,7 +92,7 @@ module subroutine thermal_init(phases) do ph = 1, phases%length - Nconstituents = count(material_phaseAt == ph) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == ph) allocate(current(ph)%T(Nconstituents),source=300.0_pReal) allocate(current(ph)%dot_T(Nconstituents),source=0.0_pReal) @@ -108,8 +109,8 @@ module subroutine thermal_init(phases) allocate(thermal_source(maxval(thermal_Nsources),phases%length), source = THERMAL_UNDEFINED_ID) if(maxval(thermal_Nsources) /= 0) then - where(source_thermal_dissipation_init (maxval(thermal_Nsources))) thermal_source = THERMAL_DISSIPATION_ID - where(source_thermal_externalheat_init(maxval(thermal_Nsources))) thermal_source = THERMAL_EXTERNALHEAT_ID + where(dissipation_init (maxval(thermal_Nsources))) thermal_source = THERMAL_DISSIPATION_ID + where(externalheat_init(maxval(thermal_Nsources))) thermal_source = THERMAL_EXTERNALHEAT_ID endif thermal_source_maxSizeDotState = 0 @@ -191,7 +192,7 @@ function constitutive_thermal_collectDotState(ph,me) result(broken) SourceLoop: do i = 1, thermal_Nsources(ph) if (thermal_source(i,ph) == THERMAL_EXTERNALHEAT_ID) & - call source_thermal_externalheat_dotState(ph,me) + call externalheat_dotState(ph,me) broken = broken .or. any(IEEE_is_NaN(thermalState(ph)%p(i)%dotState(:,me))) diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index 9519ba6ab..3b4ddcfd1 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -25,7 +25,7 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function source_thermal_dissipation_init(source_length) result(mySources) +module function dissipation_init(source_length) result(mySources) integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources @@ -72,7 +72,7 @@ module function source_thermal_dissipation_init(source_length) result(mySources) enddo -end function source_thermal_dissipation_init +end function dissipation_init !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index 2d2e92bfa..054b91e01 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -29,7 +29,7 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function source_thermal_externalheat_init(source_length) result(mySources) +module function externalheat_init(source_length) result(mySources) integer, intent(in) :: source_length logical, dimension(:,:), allocatable :: mySources @@ -78,14 +78,14 @@ module function source_thermal_externalheat_init(source_length) result(mySources enddo enddo -end function source_thermal_externalheat_init +end function externalheat_init !-------------------------------------------------------------------------------------------------- !> @brief rate of change of state !> @details state only contains current time to linearly interpolate given heat powers !-------------------------------------------------------------------------------------------------- -module subroutine source_thermal_externalheat_dotState(ph, me) +module subroutine externalheat_dotState(ph, me) integer, intent(in) :: & ph, & @@ -98,7 +98,7 @@ module subroutine source_thermal_externalheat_dotState(ph, me) thermalState(ph)%p(sourceOffset)%dotState(1,me) = 1.0_pReal ! state is current time -end subroutine source_thermal_externalheat_dotState +end subroutine externalheat_dotState !-------------------------------------------------------------------------------------------------- From 5064e65a42b9f795d845d863af64ff58c5454dff Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 08:39:17 +0100 Subject: [PATCH 171/352] default name --- src/phase.f90 | 4 +- src/phase_mechanics.f90 | 91 ++++++------- src/phase_mechanics_plastic.f90 | 70 +++++----- src/phase_mechanics_plastic_dislotungsten.f90 | 62 ++++----- src/phase_mechanics_plastic_dislotwin.f90 | 124 +++++++++--------- src/phase_mechanics_plastic_isotropic.f90 | 47 +++---- src/phase_mechanics_plastic_kinehardening.f90 | 64 ++++----- src/phase_mechanics_plastic_nonlocal.f90 | 116 ++++++++-------- src/phase_mechanics_plastic_phenopowerlaw.f90 | 52 ++++---- 9 files changed, 305 insertions(+), 325 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index 1412f5259..e8cddfb25 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -266,7 +266,7 @@ module constitutive end subroutine plastic_nonlocal_updateCompatibility - module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,of) + module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) real(pReal), dimension(3,3), intent(out) :: & Li !< inleastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -275,7 +275,7 @@ module constitutive Mi !< Mandel stress integer, intent(in) :: & instance, & - of + me end subroutine plastic_isotropic_LiAndItsTangent module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, co, ip, el) diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index fe0a95fbb..edf2fb4ad 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -83,51 +83,51 @@ submodule(constitutive) constitutive_mech myPlasticity end function plastic_nonlocal_init - module subroutine plastic_isotropic_dotState(Mp,instance,of) + module subroutine plastic_isotropic_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me end subroutine plastic_isotropic_dotState - module subroutine plastic_phenopowerlaw_dotState(Mp,instance,of) + module subroutine plastic_phenopowerlaw_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me end subroutine plastic_phenopowerlaw_dotState - module subroutine plastic_kinehardening_dotState(Mp,instance,of) + module subroutine plastic_kinehardening_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me end subroutine plastic_kinehardening_dotState - module subroutine plastic_dislotwin_dotState(Mp,T,instance,of) + module subroutine plastic_dislotwin_dotState(Mp,T,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress real(pReal), intent(in) :: & T integer, intent(in) :: & instance, & - of + me end subroutine plastic_dislotwin_dotState - module subroutine plastic_disloTungsten_dotState(Mp,T,instance,of) + module subroutine plastic_disloTungsten_dotState(Mp,T,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress real(pReal), intent(in) :: & T integer, intent(in) :: & instance, & - of + me end subroutine plastic_disloTungsten_dotState - module subroutine plastic_nonlocal_dotState(Mp,Temperature,timestep,instance,of,ip,el) + module subroutine plastic_nonlocal_dotState(Mp,Temperature,timestep,instance,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress real(pReal), intent(in) :: & @@ -135,77 +135,78 @@ submodule(constitutive) constitutive_mech timestep !< substepped crystallite time increment integer, intent(in) :: & instance, & - of, & + me, & ip, & !< current integration point el !< current element number end subroutine plastic_nonlocal_dotState - module subroutine plastic_dislotwin_dependentState(T,instance,of) + module subroutine plastic_dislotwin_dependentState(T,instance,me) integer, intent(in) :: & instance, & - of + me real(pReal), intent(in) :: & T end subroutine plastic_dislotwin_dependentState - module subroutine plastic_dislotungsten_dependentState(instance,of) + module subroutine plastic_dislotungsten_dependentState(instance,me) integer, intent(in) :: & instance, & - of + me end subroutine plastic_dislotungsten_dependentState - module subroutine plastic_nonlocal_dependentState(instance, of, ip, el) + module subroutine plastic_nonlocal_dependentState(instance, me, ip, el) integer, intent(in) :: & instance, & - of, & + me, & ip, & !< current integration point el !< current element number end subroutine plastic_nonlocal_dependentState - module subroutine plastic_kinehardening_deltaState(Mp,instance,of) + module subroutine plastic_kinehardening_deltaState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me end subroutine plastic_kinehardening_deltaState - module subroutine plastic_nonlocal_deltaState(Mp,instance,of,ip,el) + module subroutine plastic_nonlocal_deltaState(Mp,instance,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp integer, intent(in) :: & instance, & - of, & + me, & ip, & el end subroutine plastic_nonlocal_deltaState -module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & - S, Fi, co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - real(pReal), intent(in), dimension(3,3) :: & - S, & !< 2nd Piola-Kirchhoff stress - Fi !< intermediate deformation gradient - real(pReal), intent(out), dimension(3,3) :: & - Lp !< plastic velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLp_dS, & - dLp_dFi !< derivative of Lp with respect to Fi -end subroutine constitutive_plastic_LpAndItsTangents + module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & + S, Fi, co, ip, el) + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + real(pReal), intent(in), dimension(3,3) :: & + S, & !< 2nd Piola-Kirchhoff stress + Fi !< intermediate deformation gradient + real(pReal), intent(out), dimension(3,3) :: & + Lp !< plastic velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLp_dS, & + dLp_dFi !< derivative of Lp with respect to Fi - module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_cleavage_opening_init + end subroutine constitutive_plastic_LpAndItsTangents - module function kinematics_slipplane_opening_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_slipplane_opening_init + module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) + integer, intent(in) :: kinematics_length + logical, dimension(:,:), allocatable :: myKinematics + end function kinematics_cleavage_opening_init + + module function kinematics_slipplane_opening_init(kinematics_length) result(myKinematics) + integer, intent(in) :: kinematics_length + logical, dimension(:,:), allocatable :: myKinematics + end function kinematics_slipplane_opening_init module subroutine plastic_isotropic_results(instance,group) integer, intent(in) :: instance diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index 096621dfd..ea04a18fd 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -1,81 +1,79 @@ submodule(constitutive:constitutive_mech) plastic interface - - module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) - real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient - real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress + module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + real(pReal), dimension(3,3), intent(out) :: & + Lp + real(pReal), dimension(3,3,3,3), intent(out) :: & + dLp_dMp real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress + Mp integer, intent(in) :: & instance, & - of + me end subroutine isotropic_LpAndItsTangent - pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient + Lp real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress + dLp_dMp real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress + Mp integer, intent(in) :: & instance, & - of + me end subroutine phenopowerlaw_LpAndItsTangent - pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient + Lp real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress - + dLp_dMp real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress + Mp integer, intent(in) :: & instance, & - of + me end subroutine kinehardening_LpAndItsTangent - module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) + module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient + Lp real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress + dLp_dMp real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress + Mp real(pReal), intent(in) :: & T integer, intent(in) :: & instance, & - of + me end subroutine dislotwin_LpAndItsTangent - pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) + pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient + Lp real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress + dLp_dMp real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress + Mp real(pReal), intent(in) :: & T integer, intent(in) :: & instance, & - of + me end subroutine dislotungsten_LpAndItsTangent module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & - Mp,Temperature,instance,of,ip,el) + Mp,Temperature,instance,me,ip,el) real(pReal), dimension(3,3), intent(out) :: & - Lp !< plastic velocity gradient + Lp real(pReal), dimension(3,3,3,3), intent(out) :: & - dLp_dMp !< derivative of Lp with respect to the Mandel stress + dLp_dMp real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress @@ -83,13 +81,13 @@ submodule(constitutive:constitutive_mech) plastic Temperature integer, intent(in) :: & instance, & - of, & + me, & ip, & !< current integration point el !< current element number end subroutine nonlocal_LpAndItsTangent end interface - + contains !-------------------------------------------------------------------------------------------------- @@ -110,7 +108,7 @@ module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & Lp !< plastic velocity gradient real(pReal), intent(out), dimension(3,3,3,3) :: & dLp_dS, & - dLp_dFi !< derivative of Lp with respect to Fi + dLp_dFi !< derivative me Lp with respect to Fi real(pReal), dimension(3,3,3,3) :: & dLp_dMp !< derivative of Lp with respect to Mandel stress @@ -158,5 +156,5 @@ module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & enddo; enddo end subroutine constitutive_plastic_LpAndItsTangents - + end submodule plastic diff --git a/src/phase_mechanics_plastic_dislotungsten.f90 b/src/phase_mechanics_plastic_dislotungsten.f90 index 08da6f1dc..c85a86b65 100644 --- a/src/phase_mechanics_plastic_dislotungsten.f90 +++ b/src/phase_mechanics_plastic_dislotungsten.f90 @@ -17,7 +17,7 @@ submodule(constitutive:plastic) dislotungsten D_0 = 1.0_pReal, & !< prefactor for self-diffusion coefficient Q_cl = 1.0_pReal !< activation energy for dislocation climb real(pReal), allocatable, dimension(:) :: & - b_sl, & !< magnitude of Burgers vector [m] + b_sl, & !< magnitude me Burgers vector [m] D_a, & i_sl, & !< Adj. parameter for distance between 2 forest dislocations f_at, & !< factor to calculate atomic volume @@ -273,7 +273,7 @@ end function plastic_dislotungsten_init !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & - Mp,T,instance,of) + Mp,T,instance,me) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -285,7 +285,7 @@ pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & T !< temperature integer, intent(in) :: & instance, & - of + me integer :: & i,k,l,m,n @@ -298,7 +298,7 @@ pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & associate(prm => param(instance)) - call kinetics(Mp,T,instance,of,dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg) + call kinetics(Mp,T,instance,me,dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg) do i = 1, prm%sum_N_sl Lp = Lp + (dot_gamma_pos(i)+dot_gamma_neg(i))*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -315,7 +315,7 @@ end subroutine dislotungsten_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotungsten_dotState(Mp,T,instance,of) +module subroutine plastic_dislotungsten_dotState(Mp,T,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress @@ -323,7 +323,7 @@ module subroutine plastic_dislotungsten_dotState(Mp,T,instance,of) T !< temperature integer, intent(in) :: & instance, & - of + me real(pReal) :: & VacancyDiffusion @@ -338,11 +338,11 @@ module subroutine plastic_dislotungsten_dotState(Mp,T,instance,of) associate(prm => param(instance), stt => state(instance),dot => dotState(instance), dst => dependentState(instance)) - call kinetics(Mp,T,instance,of,& + call kinetics(Mp,T,instance,me,& gdot_pos,gdot_neg, & tau_pos_out = tau_pos,tau_neg_out = tau_neg) - dot%gamma_sl(:,of) = (gdot_pos+gdot_neg) ! ToDo: needs to be abs + dot%gamma_sl(:,me) = (gdot_pos+gdot_neg) ! ToDo: needs to be abs VacancyDiffusion = prm%D_0*exp(-prm%Q_cl/(kB*T)) where(dEq0(tau_pos)) ! ToDo: use avg of pos and neg @@ -351,20 +351,20 @@ module subroutine plastic_dislotungsten_dotState(Mp,T,instance,of) else where dip_distance = math_clip(3.0_pReal*prm%mu*prm%b_sl/(16.0_pReal*PI*abs(tau_pos)), & prm%D_a, & ! lower limit - dst%Lambda_sl(:,of)) ! upper limit - dot_rho_dip_formation = merge(2.0_pReal*dip_distance* stt%rho_mob(:,of)*abs(dot%gamma_sl(:,of))/prm%b_sl, & ! ToDo: ignore region of spontaneous annihilation + dst%Lambda_sl(:,me)) ! upper limit + dot_rho_dip_formation = merge(2.0_pReal*dip_distance* stt%rho_mob(:,me)*abs(dot%gamma_sl(:,me))/prm%b_sl, & ! ToDo: ignore region of spontaneous annihilation 0.0_pReal, & prm%dipoleformation) v_cl = (3.0_pReal*prm%mu*VacancyDiffusion*prm%f_at/(2.0_pReal*pi*kB*T)) & * (1.0_pReal/(dip_distance+prm%D_a)) - dot_rho_dip_climb = (4.0_pReal*v_cl*stt%rho_dip(:,of))/(dip_distance-prm%D_a) ! ToDo: Discuss with Franz: Stress dependency? + dot_rho_dip_climb = (4.0_pReal*v_cl*stt%rho_dip(:,me))/(dip_distance-prm%D_a) ! ToDo: Discuss with Franz: Stress dependency? end where - dot%rho_mob(:,of) = abs(dot%gamma_sl(:,of))/(prm%b_sl*dst%Lambda_sl(:,of)) & ! multiplication + dot%rho_mob(:,me) = abs(dot%gamma_sl(:,me))/(prm%b_sl*dst%Lambda_sl(:,me)) & ! multiplication - dot_rho_dip_formation & - - (2.0_pReal*prm%D_a)/prm%b_sl*stt%rho_mob(:,of)*abs(dot%gamma_sl(:,of)) ! Spontaneous annihilation of 2 single edge dislocations - dot%rho_dip(:,of) = dot_rho_dip_formation & - - (2.0_pReal*prm%D_a)/prm%b_sl*stt%rho_dip(:,of)*abs(dot%gamma_sl(:,of)) & ! Spontaneous annihilation of a single edge dislocation with a dipole constituent + - (2.0_pReal*prm%D_a)/prm%b_sl*stt%rho_mob(:,me)*abs(dot%gamma_sl(:,me)) ! Spontaneous annihilation of 2 single edge dislocations + dot%rho_dip(:,me) = dot_rho_dip_formation & + - (2.0_pReal*prm%D_a)/prm%b_sl*stt%rho_dip(:,me)*abs(dot%gamma_sl(:,me)) & ! Spontaneous annihilation of a single edge dislocation with a dipole constituent - dot_rho_dip_climb end associate @@ -375,22 +375,22 @@ end subroutine plastic_dislotungsten_dotState !-------------------------------------------------------------------------------------------------- !> @brief Calculate derived quantities from state. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotungsten_dependentState(instance,of) +module subroutine plastic_dislotungsten_dependentState(instance,me) integer, intent(in) :: & instance, & - of + me real(pReal), dimension(param(instance)%sum_N_sl) :: & dislocationSpacing associate(prm => param(instance), stt => state(instance),dst => dependentState(instance)) - dislocationSpacing = sqrt(matmul(prm%forestProjection,stt%rho_mob(:,of)+stt%rho_dip(:,of))) - dst%threshold_stress(:,of) = prm%mu*prm%b_sl & - * sqrt(matmul(prm%h_sl_sl,stt%rho_mob(:,of)+stt%rho_dip(:,of))) + dislocationSpacing = sqrt(matmul(prm%forestProjection,stt%rho_mob(:,me)+stt%rho_dip(:,me))) + dst%threshold_stress(:,me) = prm%mu*prm%b_sl & + * sqrt(matmul(prm%h_sl_sl,stt%rho_mob(:,me)+stt%rho_dip(:,me))) - dst%Lambda_sl(:,of) = prm%D/(1.0_pReal+prm%D*dislocationSpacing/prm%i_sl) + dst%Lambda_sl(:,me) = prm%D/(1.0_pReal+prm%D*dislocationSpacing/prm%i_sl) end associate @@ -439,7 +439,7 @@ end subroutine plastic_dislotungsten_results ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics(Mp,T,instance,of, & +pure subroutine kinetics(Mp,T,instance,me, & dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg,tau_pos_out,tau_neg_out) real(pReal), dimension(3,3), intent(in) :: & @@ -448,7 +448,7 @@ pure subroutine kinetics(Mp,T,instance,of, & T !< temperature integer, intent(in) :: & instance, & - of + me real(pReal), intent(out), dimension(param(instance)%sum_N_sl) :: & dot_gamma_pos, & @@ -479,11 +479,11 @@ pure subroutine kinetics(Mp,T,instance,of, & if (present(tau_neg_out)) tau_neg_out = tau_neg associate(BoltzmannRatio => prm%Q_s/(kB*T), & - dot_gamma_0 => stt%rho_mob(:,of)*prm%b_sl*prm%v_0, & - effectiveLength => dst%Lambda_sl(:,of) - prm%w) + dot_gamma_0 => stt%rho_mob(:,me)*prm%b_sl*prm%v_0, & + effectiveLength => dst%Lambda_sl(:,me) - prm%w) - significantPositiveTau: where(abs(tau_pos)-dst%threshold_stress(:,of) > tol_math_check) - StressRatio = (abs(tau_pos)-dst%threshold_stress(:,of))/prm%tau_Peierls + significantPositiveTau: where(abs(tau_pos)-dst%threshold_stress(:,me) > tol_math_check) + StressRatio = (abs(tau_pos)-dst%threshold_stress(:,me))/prm%tau_Peierls StressRatio_p = StressRatio** prm%p StressRatio_pminus1 = StressRatio**(prm%p-1.0_pReal) needsGoodName = exp(-BoltzmannRatio*(1-StressRatio_p) ** prm%q) @@ -499,7 +499,7 @@ pure subroutine kinetics(Mp,T,instance,of, & end where significantPositiveTau if (present(ddot_gamma_dtau_pos)) then - significantPositiveTau2: where(abs(tau_pos)-dst%threshold_stress(:,of) > tol_math_check) + significantPositiveTau2: where(abs(tau_pos)-dst%threshold_stress(:,me) > tol_math_check) dtn = -1.0_pReal * t_n * BoltzmannRatio * prm%p * prm%q * (1.0_pReal-StressRatio_p)**(prm%q - 1.0_pReal) & * (StressRatio)**(prm%p - 1.0_pReal) / prm%tau_Peierls dtk = -1.0_pReal * t_k / tau_pos @@ -512,8 +512,8 @@ pure subroutine kinetics(Mp,T,instance,of, & end where significantPositiveTau2 endif - significantNegativeTau: where(abs(tau_neg)-dst%threshold_stress(:,of) > tol_math_check) - StressRatio = (abs(tau_neg)-dst%threshold_stress(:,of))/prm%tau_Peierls + significantNegativeTau: where(abs(tau_neg)-dst%threshold_stress(:,me) > tol_math_check) + StressRatio = (abs(tau_neg)-dst%threshold_stress(:,me))/prm%tau_Peierls StressRatio_p = StressRatio** prm%p StressRatio_pminus1 = StressRatio**(prm%p-1.0_pReal) needsGoodName = exp(-BoltzmannRatio*(1-StressRatio_p) ** prm%q) @@ -529,7 +529,7 @@ pure subroutine kinetics(Mp,T,instance,of, & end where significantNegativeTau if (present(ddot_gamma_dtau_neg)) then - significantNegativeTau2: where(abs(tau_neg)-dst%threshold_stress(:,of) > tol_math_check) + significantNegativeTau2: where(abs(tau_neg)-dst%threshold_stress(:,me) > tol_math_check) dtn = -1.0_pReal * t_n * BoltzmannRatio * prm%p * prm%q * (1.0_pReal-StressRatio_p)**(prm%q - 1.0_pReal) & * (StressRatio)**(prm%p - 1.0_pReal) / prm%tau_Peierls dtk = -1.0_pReal * t_k / tau_neg diff --git a/src/phase_mechanics_plastic_dislotwin.f90 b/src/phase_mechanics_plastic_dislotwin.f90 index 8c7ae78ba..55827ae51 100644 --- a/src/phase_mechanics_plastic_dislotwin.f90 +++ b/src/phase_mechanics_plastic_dislotwin.f90 @@ -521,12 +521,12 @@ end function plastic_dislotwin_homogenizedC !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) +module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) real(pReal), dimension(3,3), intent(out) :: Lp real(pReal), dimension(3,3,3,3), intent(out) :: dLp_dMp real(pReal), dimension(3,3), intent(in) :: Mp - integer, intent(in) :: instance,of + integer, intent(in) :: instance,me real(pReal), intent(in) :: T integer :: i,k,l,m,n @@ -567,13 +567,13 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) associate(prm => param(instance), stt => state(instance)) f_unrotated = 1.0_pReal & - - sum(stt%f_tw(1:prm%sum_N_tw,of)) & - - sum(stt%f_tr(1:prm%sum_N_tr,of)) + - sum(stt%f_tw(1:prm%sum_N_tw,me)) & + - sum(stt%f_tr(1:prm%sum_N_tr,me)) Lp = 0.0_pReal dLp_dMp = 0.0_pReal - call kinetics_slip(Mp,T,instance,of,dot_gamma_sl,ddot_gamma_dtau_slip) + call kinetics_slip(Mp,T,instance,me,dot_gamma_sl,ddot_gamma_dtau_slip) slipContribution: do i = 1, prm%sum_N_sl Lp = Lp + dot_gamma_sl(i)*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -581,7 +581,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) + ddot_gamma_dtau_slip(i) * prm%P_sl(k,l,i) * prm%P_sl(m,n,i) enddo slipContribution - call kinetics_twin(Mp,T,dot_gamma_sl,instance,of,dot_gamma_twin,ddot_gamma_dtau_twin) + call kinetics_twin(Mp,T,dot_gamma_sl,instance,me,dot_gamma_twin,ddot_gamma_dtau_twin) twinContibution: do i = 1, prm%sum_N_tw Lp = Lp + dot_gamma_twin(i)*prm%P_tw(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -589,7 +589,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,of) + ddot_gamma_dtau_twin(i)* prm%P_tw(k,l,i)*prm%P_tw(m,n,i) enddo twinContibution - call kinetics_trans(Mp,T,dot_gamma_sl,instance,of,dot_gamma_tr,ddot_gamma_dtau_trans) + call kinetics_trans(Mp,T,dot_gamma_sl,instance,me,dot_gamma_tr,ddot_gamma_dtau_trans) transContibution: do i = 1, prm%sum_N_tr Lp = Lp + dot_gamma_tr(i)*prm%P_tr(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -634,7 +634,7 @@ end subroutine dislotwin_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotwin_dotState(Mp,T,instance,of) +module subroutine plastic_dislotwin_dotState(Mp,T,instance,me) real(pReal), dimension(3,3), intent(in):: & Mp !< Mandel stress @@ -642,7 +642,7 @@ module subroutine plastic_dislotwin_dotState(Mp,T,instance,of) T !< temperature at integration point integer, intent(in) :: & instance, & - of + me integer :: i real(pReal) :: & @@ -667,11 +667,11 @@ module subroutine plastic_dislotwin_dotState(Mp,T,instance,of) dot => dotState(instance), dst => dependentState(instance)) f_unrotated = 1.0_pReal & - - sum(stt%f_tw(1:prm%sum_N_tw,of)) & - - sum(stt%f_tr(1:prm%sum_N_tr,of)) + - sum(stt%f_tw(1:prm%sum_N_tw,me)) & + - sum(stt%f_tr(1:prm%sum_N_tr,me)) - call kinetics_slip(Mp,T,instance,of,dot_gamma_sl) - dot%gamma_sl(:,of) = abs(dot_gamma_sl) + call kinetics_slip(Mp,T,instance,me,dot_gamma_sl) + dot%gamma_sl(:,me) = abs(dot_gamma_sl) rho_dip_distance_min = prm%D_a*prm%b_sl @@ -683,12 +683,12 @@ module subroutine plastic_dislotwin_dotState(Mp,T,instance,of) dot_rho_dip_climb(i) = 0.0_pReal else significantSlipStress rho_dip_distance = 3.0_pReal*prm%mu*prm%b_sl(i)/(16.0_pReal*PI*abs(tau)) - rho_dip_distance = math_clip(rho_dip_distance, right = dst%Lambda_sl(i,of)) + rho_dip_distance = math_clip(rho_dip_distance, right = dst%Lambda_sl(i,me)) rho_dip_distance = math_clip(rho_dip_distance, left = rho_dip_distance_min(i)) if (prm%dipoleFormation) then dot_rho_dip_formation(i) = 2.0_pReal*(rho_dip_distance-rho_dip_distance_min(i))/prm%b_sl(i) & - * stt%rho_mob(i,of)*abs(dot_gamma_sl(i)) + * stt%rho_mob(i,me)*abs(dot_gamma_sl(i)) else dot_rho_dip_formation(i) = 0.0_pReal endif @@ -707,25 +707,25 @@ module subroutine plastic_dislotwin_dotState(Mp,T,instance,of) v_cl = 2.0_pReal*prm%omega*b_d**2.0_pReal*exp(-prm%Q_cl/(kB*T)) & * (exp(abs(sigma_cl)*prm%b_sl(i)**3.0_pReal/(kB*T)) - 1.0_pReal) - dot_rho_dip_climb(i) = 4.0_pReal*v_cl*stt%rho_dip(i,of) & + dot_rho_dip_climb(i) = 4.0_pReal*v_cl*stt%rho_dip(i,me) & / (rho_dip_distance-rho_dip_distance_min(i)) endif endif significantSlipStress enddo slipState - dot%rho_mob(:,of) = abs(dot_gamma_sl)/(prm%b_sl*dst%Lambda_sl(:,of)) & + dot%rho_mob(:,me) = abs(dot_gamma_sl)/(prm%b_sl*dst%Lambda_sl(:,me)) & - dot_rho_dip_formation & - - 2.0_pReal*rho_dip_distance_min/prm%b_sl * stt%rho_mob(:,of)*abs(dot_gamma_sl) + - 2.0_pReal*rho_dip_distance_min/prm%b_sl * stt%rho_mob(:,me)*abs(dot_gamma_sl) - dot%rho_dip(:,of) = dot_rho_dip_formation & - - 2.0_pReal*rho_dip_distance_min/prm%b_sl * stt%rho_dip(:,of)*abs(dot_gamma_sl) & + dot%rho_dip(:,me) = dot_rho_dip_formation & + - 2.0_pReal*rho_dip_distance_min/prm%b_sl * stt%rho_dip(:,me)*abs(dot_gamma_sl) & - dot_rho_dip_climb - call kinetics_twin(Mp,T,dot_gamma_sl,instance,of,dot_gamma_twin) - dot%f_tw(:,of) = f_unrotated*dot_gamma_twin/prm%gamma_char + call kinetics_twin(Mp,T,dot_gamma_sl,instance,me,dot_gamma_twin) + dot%f_tw(:,me) = f_unrotated*dot_gamma_twin/prm%gamma_char - call kinetics_trans(Mp,T,dot_gamma_sl,instance,of,dot_gamma_tr) - dot%f_tr(:,of) = f_unrotated*dot_gamma_tr + call kinetics_trans(Mp,T,dot_gamma_sl,instance,me,dot_gamma_tr) + dot%f_tr(:,me) = f_unrotated*dot_gamma_tr end associate @@ -735,11 +735,11 @@ end subroutine plastic_dislotwin_dotState !-------------------------------------------------------------------------------------------------- !> @brief Calculate derived quantities from state. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotwin_dependentState(T,instance,of) +module subroutine plastic_dislotwin_dependentState(T,instance,me) integer, intent(in) :: & instance, & - of + me real(pReal), intent(in) :: & T @@ -763,18 +763,18 @@ module subroutine plastic_dislotwin_dependentState(T,instance,of) stt => state(instance),& dst => dependentState(instance)) - sumf_twin = sum(stt%f_tw(1:prm%sum_N_tw,of)) - sumf_trans = sum(stt%f_tr(1:prm%sum_N_tr,of)) + sumf_twin = sum(stt%f_tw(1:prm%sum_N_tw,me)) + sumf_trans = sum(stt%f_tr(1:prm%sum_N_tr,me)) Gamma = prm%Gamma_sf_0K + prm%dGamma_sf_dT * T !* rescaled volume fraction for topology - f_over_t_tw = stt%f_tw(1:prm%sum_N_tw,of)/prm%t_tw ! this is per system ... + f_over_t_tw = stt%f_tw(1:prm%sum_N_tw,me)/prm%t_tw ! this is per system ... f_over_t_tr = sumf_trans/prm%t_tr ! but this not ! ToDo ...Physically correct, but naming could be adjusted inv_lambda_sl_sl = sqrt(matmul(prm%forestProjection, & - stt%rho_mob(:,of)+stt%rho_dip(:,of)))/prm%i_sl + stt%rho_mob(:,me)+stt%rho_dip(:,me)))/prm%i_sl if (prm%sum_N_tw > 0 .and. prm%sum_N_sl > 0) & inv_lambda_sl_tw = matmul(prm%h_sl_tw,f_over_t_tw)/(1.0_pReal-sumf_twin) @@ -787,37 +787,37 @@ module subroutine plastic_dislotwin_dependentState(T,instance,of) inv_lambda_tr_tr = matmul(prm%h_tr_tr,f_over_t_tr)/(1.0_pReal-sumf_trans) if ((prm%sum_N_tw > 0) .or. (prm%sum_N_tr > 0)) then ! ToDo: better logic needed here - dst%Lambda_sl(:,of) = prm%D & + dst%Lambda_sl(:,me) = prm%D & / (1.0_pReal+prm%D*(inv_lambda_sl_sl + inv_lambda_sl_tw + inv_lambda_sl_tr)) else - dst%Lambda_sl(:,of) = prm%D & + dst%Lambda_sl(:,me) = prm%D & / (1.0_pReal+prm%D*inv_lambda_sl_sl) !!!!!! correct? endif - dst%Lambda_tw(:,of) = prm%i_tw*prm%D/(1.0_pReal+prm%D*inv_lambda_tw_tw) - dst%Lambda_tr(:,of) = prm%i_tr*prm%D/(1.0_pReal+prm%D*inv_lambda_tr_tr) + dst%Lambda_tw(:,me) = prm%i_tw*prm%D/(1.0_pReal+prm%D*inv_lambda_tw_tw) + dst%Lambda_tr(:,me) = prm%i_tr*prm%D/(1.0_pReal+prm%D*inv_lambda_tr_tr) !* threshold stress for dislocation motion - dst%tau_pass(:,of) = prm%mu*prm%b_sl* sqrt(matmul(prm%h_sl_sl,stt%rho_mob(:,of)+stt%rho_dip(:,of))) + dst%tau_pass(:,me) = prm%mu*prm%b_sl* sqrt(matmul(prm%h_sl_sl,stt%rho_mob(:,me)+stt%rho_dip(:,me))) !* threshold stress for growing twin/martensite if(prm%sum_N_tw == prm%sum_N_sl) & - dst%tau_hat_tw(:,of) = Gamma/(3.0_pReal*prm%b_tw) & + dst%tau_hat_tw(:,me) = Gamma/(3.0_pReal*prm%b_tw) & + 3.0_pReal*prm%b_tw*prm%mu/(prm%L_tw*prm%b_sl) ! slip Burgers here correct? if(prm%sum_N_tr == prm%sum_N_sl) & - dst%tau_hat_tr(:,of) = Gamma/(3.0_pReal*prm%b_tr) & + dst%tau_hat_tr(:,me) = Gamma/(3.0_pReal*prm%b_tr) & + 3.0_pReal*prm%b_tr*prm%mu/(prm%L_tr*prm%b_sl) & ! slip Burgers here correct? + prm%h*prm%delta_G/ (3.0_pReal*prm%b_tr) - dst%V_tw(:,of) = (PI/4.0_pReal)*prm%t_tw*dst%Lambda_tw(:,of)**2.0_pReal - dst%V_tr(:,of) = (PI/4.0_pReal)*prm%t_tr*dst%Lambda_tr(:,of)**2.0_pReal + dst%V_tw(:,me) = (PI/4.0_pReal)*prm%t_tw*dst%Lambda_tw(:,me)**2.0_pReal + dst%V_tr(:,me) = (PI/4.0_pReal)*prm%t_tr*dst%Lambda_tr(:,me)**2.0_pReal x0 = prm%mu*prm%b_tw**2.0_pReal/(Gamma*8.0_pReal*PI)*(2.0_pReal+prm%nu)/(1.0_pReal-prm%nu) ! ToDo: In the paper, this is the Burgers vector for slip and is the same for twin and trans - dst%tau_r_tw(:,of) = prm%mu*prm%b_tw/(2.0_pReal*PI)*(1.0_pReal/(x0+prm%x_c_tw)+cos(pi/3.0_pReal)/x0) + dst%tau_r_tw(:,me) = prm%mu*prm%b_tw/(2.0_pReal*PI)*(1.0_pReal/(x0+prm%x_c_tw)+cos(pi/3.0_pReal)/x0) x0 = prm%mu*prm%b_tr**2.0_pReal/(Gamma*8.0_pReal*PI)*(2.0_pReal+prm%nu)/(1.0_pReal-prm%nu) ! ToDo: In the paper, this is the Burgers vector for slip - dst%tau_r_tr(:,of) = prm%mu*prm%b_tr/(2.0_pReal*PI)*(1.0_pReal/(x0+prm%x_c_tr)+cos(pi/3.0_pReal)/x0) + dst%tau_r_tr(:,me) = prm%mu*prm%b_tr/(2.0_pReal*PI)*(1.0_pReal/(x0+prm%x_c_tr)+cos(pi/3.0_pReal)/x0) end associate @@ -882,7 +882,7 @@ end subroutine plastic_dislotwin_results ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_slip(Mp,T,instance,of, & +pure subroutine kinetics_slip(Mp,T,instance,me, & dot_gamma_sl,ddot_gamma_dtau_slip,tau_slip) real(pReal), dimension(3,3), intent(in) :: & @@ -891,7 +891,7 @@ pure subroutine kinetics_slip(Mp,T,instance,of, & T !< temperature integer, intent(in) :: & instance, & - of + me real(pReal), dimension(param(instance)%sum_N_sl), intent(out) :: & dot_gamma_sl @@ -920,7 +920,7 @@ pure subroutine kinetics_slip(Mp,T,instance,of, & tau(i) = math_tensordot(Mp,prm%P_sl(1:3,1:3,i)) enddo - tau_eff = abs(tau)-dst%tau_pass(:,of) + tau_eff = abs(tau)-dst%tau_pass(:,me) significantStress: where(tau_eff > tol_math_check) stressRatio = tau_eff/prm%tau_0 @@ -929,7 +929,7 @@ pure subroutine kinetics_slip(Mp,T,instance,of, & v_wait_inverse = prm%v_0**(-1.0_pReal) * exp(BoltzmannRatio*(1.0_pReal-StressRatio_p)** prm%q) v_run_inverse = prm%B/(tau_eff*prm%b_sl) - dot_gamma_sl = sign(stt%rho_mob(:,of)*prm%b_sl/(v_wait_inverse+v_run_inverse),tau) + dot_gamma_sl = sign(stt%rho_mob(:,me)*prm%b_sl/(v_wait_inverse+v_run_inverse),tau) dV_wait_inverse_dTau = -1.0_pReal * v_wait_inverse * prm%p * prm%q * BoltzmannRatio & * (stressRatio**(prm%p-1.0_pReal)) & @@ -938,7 +938,7 @@ pure subroutine kinetics_slip(Mp,T,instance,of, & dV_run_inverse_dTau = -1.0_pReal * v_run_inverse/tau_eff dV_dTau = -1.0_pReal * (dV_wait_inverse_dTau+dV_run_inverse_dTau) & / (v_wait_inverse+v_run_inverse)**2.0_pReal - ddot_gamma_dtau = dV_dTau*stt%rho_mob(:,of)*prm%b_sl + ddot_gamma_dtau = dV_dTau*stt%rho_mob(:,me)*prm%b_sl else where significantStress dot_gamma_sl = 0.0_pReal ddot_gamma_dtau = 0.0_pReal @@ -959,7 +959,7 @@ end subroutine kinetics_slip ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,instance,of,& +pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,instance,me,& dot_gamma_twin,ddot_gamma_dtau_twin) real(pReal), dimension(3,3), intent(in) :: & @@ -968,7 +968,7 @@ pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,instance,of,& T !< temperature integer, intent(in) :: & instance, & - of + me real(pReal), dimension(param(instance)%sum_N_sl), intent(in) :: & dot_gamma_sl @@ -992,11 +992,11 @@ pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,instance,of,& isFCC: if (prm%fccTwinTransNucleation) then s1=prm%fcc_twinNucleationSlipPair(1,i) s2=prm%fcc_twinNucleationSlipPair(2,i) - if (tau(i) < dst%tau_r_tw(i,of)) then ! ToDo: correct? - Ndot0=(abs(dot_gamma_sl(s1))*(stt%rho_mob(s2,of)+stt%rho_dip(s2,of))+& - abs(dot_gamma_sl(s2))*(stt%rho_mob(s1,of)+stt%rho_dip(s1,of)))/& ! ToDo: MD: it would be more consistent to use shearrates from state + if (tau(i) < dst%tau_r_tw(i,me)) then ! ToDo: correct? + Ndot0=(abs(dot_gamma_sl(s1))*(stt%rho_mob(s2,me)+stt%rho_dip(s2,me))+& + abs(dot_gamma_sl(s2))*(stt%rho_mob(s1,me)+stt%rho_dip(s1,me)))/& ! ToDo: MD: it would be more consistent to use shearrates from state (prm%L_tw*prm%b_sl(i))*& - (1.0_pReal-exp(-prm%V_cs/(kB*T)*(dst%tau_r_tw(i,of)-tau(i)))) ! P_ncs + (1.0_pReal-exp(-prm%V_cs/(kB*T)*(dst%tau_r_tw(i,me)-tau(i)))) ! P_ncs else Ndot0=0.0_pReal end if @@ -1006,8 +1006,8 @@ pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,instance,of,& enddo significantStress: where(tau > tol_math_check) - StressRatio_r = (dst%tau_hat_tw(:,of)/tau)**prm%r - dot_gamma_twin = prm%gamma_char * dst%V_tw(:,of) * Ndot0*exp(-StressRatio_r) + StressRatio_r = (dst%tau_hat_tw(:,me)/tau)**prm%r + dot_gamma_twin = prm%gamma_char * dst%V_tw(:,me) * Ndot0*exp(-StressRatio_r) ddot_gamma_dtau = (dot_gamma_twin*prm%r/tau)*StressRatio_r else where significantStress dot_gamma_twin = 0.0_pReal @@ -1028,7 +1028,7 @@ end subroutine kinetics_twin ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,instance,of,& +pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,instance,me,& dot_gamma_tr,ddot_gamma_dtau_trans) real(pReal), dimension(3,3), intent(in) :: & @@ -1037,7 +1037,7 @@ pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,instance,of,& T !< temperature integer, intent(in) :: & instance, & - of + me real(pReal), dimension(param(instance)%sum_N_sl), intent(in) :: & dot_gamma_sl @@ -1060,11 +1060,11 @@ pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,instance,of,& isFCC: if (prm%fccTwinTransNucleation) then s1=prm%fcc_twinNucleationSlipPair(1,i) s2=prm%fcc_twinNucleationSlipPair(2,i) - if (tau(i) < dst%tau_r_tr(i,of)) then ! ToDo: correct? - Ndot0=(abs(dot_gamma_sl(s1))*(stt%rho_mob(s2,of)+stt%rho_dip(s2,of))+& - abs(dot_gamma_sl(s2))*(stt%rho_mob(s1,of)+stt%rho_dip(s1,of)))/& ! ToDo: MD: it would be more consistent to use shearrates from state + if (tau(i) < dst%tau_r_tr(i,me)) then ! ToDo: correct? + Ndot0=(abs(dot_gamma_sl(s1))*(stt%rho_mob(s2,me)+stt%rho_dip(s2,me))+& + abs(dot_gamma_sl(s2))*(stt%rho_mob(s1,me)+stt%rho_dip(s1,me)))/& ! ToDo: MD: it would be more consistent to use shearrates from state (prm%L_tr*prm%b_sl(i))*& - (1.0_pReal-exp(-prm%V_cs/(kB*T)*(dst%tau_r_tr(i,of)-tau(i)))) ! P_ncs + (1.0_pReal-exp(-prm%V_cs/(kB*T)*(dst%tau_r_tr(i,me)-tau(i)))) ! P_ncs else Ndot0=0.0_pReal end if @@ -1074,8 +1074,8 @@ pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,instance,of,& enddo significantStress: where(tau > tol_math_check) - StressRatio_s = (dst%tau_hat_tr(:,of)/tau)**prm%s - dot_gamma_tr = dst%V_tr(:,of) * Ndot0*exp(-StressRatio_s) + StressRatio_s = (dst%tau_hat_tr(:,me)/tau)**prm%s + dot_gamma_tr = dst%V_tr(:,me) * Ndot0*exp(-StressRatio_s) ddot_gamma_dtau = (dot_gamma_tr*prm%s/tau)*StressRatio_s else where significantStress dot_gamma_tr = 0.0_pReal diff --git a/src/phase_mechanics_plastic_isotropic.f90 b/src/phase_mechanics_plastic_isotropic.f90 index a2ef157d4..7508f172c 100644 --- a/src/phase_mechanics_plastic_isotropic.f90 +++ b/src/phase_mechanics_plastic_isotropic.f90 @@ -168,7 +168,7 @@ end function plastic_isotropic_init !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) +module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -179,7 +179,7 @@ module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me real(pReal), dimension(3,3) :: & Mp_dev !< deviatoric part of the Mandel stress @@ -197,17 +197,9 @@ module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) norm_Mp_dev = sqrt(squarenorm_Mp_dev) if (norm_Mp_dev > 0.0_pReal) then - dot_gamma = prm%dot_gamma_0 * (sqrt(1.5_pReal) * norm_Mp_dev/(prm%M*stt%xi(of))) **prm%n + dot_gamma = prm%dot_gamma_0 * (sqrt(1.5_pReal) * norm_Mp_dev/(prm%M*stt%xi(me))) **prm%n Lp = dot_gamma/prm%M * Mp_dev/norm_Mp_dev -#ifdef DEBUG - if (debugConstitutive%extensive .and. (of == prm%of_debug .or. .not. debugConstitutive%selective)) then - print'(/,a,/,3(12x,3(f12.4,1x)/))', '<< CONST isotropic >> Tstar (dev) / MPa', & - transpose(Mp_dev)*1.0e-6_pReal - print'(/,a,/,f12.5)', '<< CONST isotropic >> norm Tstar / MPa', norm_Mp_dev*1.0e-6_pReal - print'(/,a,/,f12.5)', '<< CONST isotropic >> gdot', dot_gamma - end if -#endif forall (k=1:3,l=1:3,m=1:3,n=1:3) & dLp_dMp(k,l,m,n) = (prm%n-1.0_pReal) * Mp_dev(k,l)*Mp_dev(m,n) / squarenorm_Mp_dev forall (k=1:3,l=1:3) & @@ -228,7 +220,7 @@ end subroutine isotropic_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate inelastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,of) +module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) real(pReal), dimension(3,3), intent(out) :: & Li !< inleastic velocity gradient @@ -239,7 +231,7 @@ module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,of) Mi !< Mandel stress integer, intent(in) :: & instance, & - of + me real(pReal) :: & tr !< trace of spherical part of Mandel stress (= 3 x pressure) @@ -252,19 +244,10 @@ module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,of) if (prm%dilatation .and. abs(tr) > 0.0_pReal) then ! no stress or J2 plasticity --> Li and its derivative are zero Li = math_I3 & - * prm%dot_gamma_0/prm%M * (3.0_pReal*prm%M*stt%xi(of))**(-prm%n) & + * prm%dot_gamma_0/prm%M * (3.0_pReal*prm%M*stt%xi(me))**(-prm%n) & * tr * abs(tr)**(prm%n-1.0_pReal) -#ifdef DEBUG - if (debugConstitutive%extensive .and. (of == prm%of_debug .or. .not. debugConstitutive%selective)) then - print'(/,a,/,f12.5)', '<< CONST isotropic >> pressure / MPa', tr/3.0_pReal*1.0e-6_pReal - print'(/,a,/,f12.5)', '<< CONST isotropic >> gdot', prm%dot_gamma_0 * (3.0_pReal*prm%M*stt%xi(of))**(-prm%n) & - * tr * abs(tr)**(prm%n-1.0_pReal) - end if -#endif - - forall (k=1:3,l=1:3,m=1:3,n=1:3) & - dLi_dMi(k,l,m,n) = prm%n / tr * Li(k,l) * math_I3(m,n) + forall (k=1:3,l=1:3,m=1:3,n=1:3) dLi_dMi(k,l,m,n) = prm%n / tr * Li(k,l) * math_I3(m,n) else Li = 0.0_pReal @@ -279,13 +262,13 @@ module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,of) !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_isotropic_dotState(Mp,instance,of) +module subroutine plastic_isotropic_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me real(pReal) :: & dot_gamma, & !< strainrate @@ -300,7 +283,7 @@ module subroutine plastic_isotropic_dotState(Mp,instance,of) norm_Mp = sqrt(math_tensordot(math_deviatoric33(Mp),math_deviatoric33(Mp))) endif - dot_gamma = prm%dot_gamma_0 * (sqrt(1.5_pReal) * norm_Mp /(prm%M*stt%xi(of))) **prm%n + dot_gamma = prm%dot_gamma_0 * (sqrt(1.5_pReal) * norm_Mp /(prm%M*stt%xi(me))) **prm%n if (dot_gamma > 1e-12_pReal) then if (dEq0(prm%c_1)) then @@ -310,15 +293,15 @@ module subroutine plastic_isotropic_dotState(Mp,instance,of) + asinh( (dot_gamma / prm%c_1)**(1.0_pReal / prm%c_2))**(1.0_pReal / prm%c_3) & / prm%c_4 * (dot_gamma / prm%dot_gamma_0)**(1.0_pReal / prm%n) endif - dot%xi(of) = dot_gamma & + dot%xi(me) = dot_gamma & * ( prm%h_0 + prm%h_ln * log(dot_gamma) ) & - * abs( 1.0_pReal - stt%xi(of)/xi_inf_star )**prm%a & - * sign(1.0_pReal, 1.0_pReal - stt%xi(of)/xi_inf_star) + * abs( 1.0_pReal - stt%xi(me)/xi_inf_star )**prm%a & + * sign(1.0_pReal, 1.0_pReal - stt%xi(me)/xi_inf_star) else - dot%xi(of) = 0.0_pReal + dot%xi(me) = 0.0_pReal endif - dot%gamma(of) = dot_gamma ! ToDo: not really used + dot%gamma(me) = dot_gamma ! ToDo: not really used end associate diff --git a/src/phase_mechanics_plastic_kinehardening.f90 b/src/phase_mechanics_plastic_kinehardening.f90 index 1fb8588d8..ce6ea1935 100644 --- a/src/phase_mechanics_plastic_kinehardening.f90 +++ b/src/phase_mechanics_plastic_kinehardening.f90 @@ -240,7 +240,7 @@ end function plastic_kinehardening_init !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) +pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -251,7 +251,7 @@ pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me integer :: & i,k,l,m,n @@ -264,7 +264,7 @@ pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) associate(prm => param(instance)) - call kinetics(Mp,instance,of,gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) + call kinetics(Mp,instance,me,gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) do i = 1, prm%sum_N_sl Lp = Lp + (gdot_pos(i)+gdot_neg(i))*prm%P(1:3,1:3,i) @@ -282,13 +282,13 @@ end subroutine kinehardening_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_kinehardening_dotState(Mp,instance,of) +module subroutine plastic_kinehardening_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me real(pReal) :: & sumGamma @@ -298,22 +298,22 @@ module subroutine plastic_kinehardening_dotState(Mp,instance,of) associate(prm => param(instance), stt => state(instance), dot => dotState(instance)) - call kinetics(Mp,instance,of,gdot_pos,gdot_neg) - dot%accshear(:,of) = abs(gdot_pos+gdot_neg) - sumGamma = sum(stt%accshear(:,of)) + call kinetics(Mp,instance,me,gdot_pos,gdot_neg) + dot%accshear(:,me) = abs(gdot_pos+gdot_neg) + sumGamma = sum(stt%accshear(:,me)) - dot%crss(:,of) = matmul(prm%interaction_SlipSlip,dot%accshear(:,of)) & + dot%crss(:,me) = matmul(prm%interaction_SlipSlip,dot%accshear(:,me)) & * ( prm%h_inf_f & + (prm%h_0_f - prm%h_inf_f + prm%h_0_f*prm%h_inf_f*sumGamma/prm%xi_inf_f) & * exp(-sumGamma*prm%h_0_f/prm%xi_inf_f) & ) - dot%crss_back(:,of) = stt%sense(:,of)*dot%accshear(:,of) * & + dot%crss_back(:,me) = stt%sense(:,me)*dot%accshear(:,me) * & ( prm%h_inf_b + & (prm%h_0_b - prm%h_inf_b & - + prm%h_0_b*prm%h_inf_b/(prm%xi_inf_b+stt%chi0(:,of))*(stt%accshear(:,of)-stt%gamma0(:,of))& - ) *exp(-(stt%accshear(:,of)-stt%gamma0(:,of)) *prm%h_0_b/(prm%xi_inf_b+stt%chi0(:,of))) & + + prm%h_0_b*prm%h_inf_b/(prm%xi_inf_b+stt%chi0(:,me))*(stt%accshear(:,me)-stt%gamma0(:,me))& + ) *exp(-(stt%accshear(:,me)-stt%gamma0(:,me)) *prm%h_0_b/(prm%xi_inf_b+stt%chi0(:,me))) & ) end associate @@ -324,13 +324,13 @@ end subroutine plastic_kinehardening_dotState !-------------------------------------------------------------------------------------------------- !> @brief Calculate (instantaneous) incremental change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_kinehardening_deltaState(Mp,instance,of) +module subroutine plastic_kinehardening_deltaState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me real(pReal), dimension(param(instance)%sum_N_sl) :: & gdot_pos,gdot_neg, & @@ -338,29 +338,29 @@ module subroutine plastic_kinehardening_deltaState(Mp,instance,of) associate(prm => param(instance), stt => state(instance), dlt => deltaState(instance)) - call kinetics(Mp,instance,of,gdot_pos,gdot_neg) - sense = merge(state(instance)%sense(:,of), & ! keep existing... + call kinetics(Mp,instance,me,gdot_pos,gdot_neg) + sense = merge(state(instance)%sense(:,me), & ! keep existing... sign(1.0_pReal,gdot_pos+gdot_neg), & ! ...or have a defined dEq0(gdot_pos+gdot_neg,1e-10_pReal)) ! current sense of shear direction #ifdef DEBUG if (debugConstitutive%extensive & - .and. (of == prm%of_debug .or. .not. debugConstitutive%selective)) then + .and. (me == prm%of_debug .or. .not. debugConstitutive%selective)) then print*, '======= kinehardening delta state =======' - print*, sense,state(instance)%sense(:,of) + print*, sense,state(instance)%sense(:,me) endif #endif !-------------------------------------------------------------------------------------------------- -! switch in sense of shear? - where(dNeq(sense,stt%sense(:,of),0.1_pReal)) - dlt%sense (:,of) = sense - stt%sense(:,of) ! switch sense - dlt%chi0 (:,of) = abs(stt%crss_back(:,of)) - stt%chi0(:,of) ! remember current backstress magnitude - dlt%gamma0(:,of) = stt%accshear(:,of) - stt%gamma0(:,of) ! remember current accumulated shear +! switch in sense me shear? + where(dNeq(sense,stt%sense(:,me),0.1_pReal)) + dlt%sense (:,me) = sense - stt%sense(:,me) ! switch sense + dlt%chi0 (:,me) = abs(stt%crss_back(:,me)) - stt%chi0(:,me) ! remember current backstress magnitude + dlt%gamma0(:,me) = stt%accshear(:,me) - stt%gamma0(:,me) ! remember current accumulated shear else where - dlt%sense (:,of) = 0.0_pReal - dlt%chi0 (:,of) = 0.0_pReal - dlt%gamma0(:,of) = 0.0_pReal + dlt%sense (:,me) = 0.0_pReal + dlt%chi0 (:,me) = 0.0_pReal + dlt%gamma0(:,me) = 0.0_pReal end where end associate @@ -413,14 +413,14 @@ end subroutine plastic_kinehardening_results ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics(Mp,instance,of, & +pure subroutine kinetics(Mp,instance,me, & gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me real(pReal), intent(out), dimension(param(instance)%sum_N_sl) :: & gdot_pos, & @@ -437,21 +437,21 @@ pure subroutine kinetics(Mp,instance,of, & associate(prm => param(instance), stt => state(instance)) do i = 1, prm%sum_N_sl - tau_pos(i) = math_tensordot(Mp,prm%nonSchmid_pos(1:3,1:3,i)) - stt%crss_back(i,of) - tau_neg(i) = merge(math_tensordot(Mp,prm%nonSchmid_neg(1:3,1:3,i)) - stt%crss_back(i,of), & + tau_pos(i) = math_tensordot(Mp,prm%nonSchmid_pos(1:3,1:3,i)) - stt%crss_back(i,me) + tau_neg(i) = merge(math_tensordot(Mp,prm%nonSchmid_neg(1:3,1:3,i)) - stt%crss_back(i,me), & 0.0_pReal, prm%nonSchmidActive) enddo where(dNeq0(tau_pos)) gdot_pos = prm%dot_gamma_0 * merge(0.5_pReal,1.0_pReal, prm%nonSchmidActive) & ! 1/2 if non-Schmid active - * sign(abs(tau_pos/stt%crss(:,of))**prm%n, tau_pos) + * sign(abs(tau_pos/stt%crss(:,me))**prm%n, tau_pos) else where gdot_pos = 0.0_pReal end where where(dNeq0(tau_neg)) gdot_neg = prm%dot_gamma_0 * 0.5_pReal & ! only used if non-Schmid active, always 1/2 - * sign(abs(tau_neg/stt%crss(:,of))**prm%n, tau_neg) + * sign(abs(tau_neg/stt%crss(:,me))**prm%n, tau_neg) else where gdot_neg = 0.0_pReal end where diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 index c023e685e..4d952dfd4 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanics_plastic_nonlocal.f90 @@ -552,17 +552,16 @@ end function plastic_nonlocal_init !-------------------------------------------------------------------------------------------------- !> @brief calculates quantities characterizing the microstructure !-------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_dependentState(instance, of, ip, el) +module subroutine plastic_nonlocal_dependentState(instance, me, ip, el) integer, intent(in) :: & instance, & - of, & + me, & ip, & el integer :: & ph, & - me, & no, & !< neighbor offset neighbor_el, & ! element number of neighboring material point neighbor_ip, & ! integration point of neighboring material point @@ -612,9 +611,9 @@ module subroutine plastic_nonlocal_dependentState(instance, of, ip, el) associate(prm => param(instance),dst => microstructure(instance), stt => state(instance)) - rho = getRho(instance,of,ip,el) + rho = getRho(instance,me,ip,el) - stt%rho_forest(:,of) = matmul(prm%forestProjection_Edge, sum(abs(rho(:,edg)),2)) & + stt%rho_forest(:,me) = matmul(prm%forestProjection_Edge, sum(abs(rho(:,edg)),2)) & + matmul(prm%forestProjection_Screw,sum(abs(rho(:,scr)),2)) @@ -624,13 +623,13 @@ module subroutine plastic_nonlocal_dependentState(instance, of, ip, el) myInteractionMatrix = prm%h_sl_sl & * spread(( 1.0_pReal - prm%f_F & + prm%f_F & - * log(0.35_pReal * prm%b_sl * sqrt(max(stt%rho_forest(:,of),prm%rho_significant))) & + * log(0.35_pReal * prm%b_sl * sqrt(max(stt%rho_forest(:,me),prm%rho_significant))) & / log(0.35_pReal * prm%b_sl * 1e6_pReal))** 2.0_pReal,2,prm%sum_N_sl) else myInteractionMatrix = prm%h_sl_sl endif - dst%tau_pass(:,of) = prm%mu * prm%b_sl & + dst%tau_pass(:,me) = prm%mu * prm%b_sl & * sqrt(matmul(myInteractionMatrix,sum(abs(rho),2))) !*** calculate the dislocation stress of the neighboring excess dislocation densities @@ -640,10 +639,9 @@ module subroutine plastic_nonlocal_dependentState(instance, of, ip, el) ! ToDo: MD: this is most likely only correct for F_i = I !################################################################################################# - rho0 = getRho0(instance,of,ip,el) + rho0 = getRho0(instance,me,ip,el) if (.not. phase_localPlasticity(material_phaseAt(1,el)) .and. prm%shortRangeStressCorrection) then ph = material_phaseAt(1,el) - me = material_phaseMemberAt(1,ip,el) invFp = math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me)) invFe = math_inv33(constitutive_mech_Fe(ph)%data(1:3,1:3,me)) @@ -734,7 +732,7 @@ module subroutine plastic_nonlocal_dependentState(instance, of, ip, el) where(rhoTotal > 0.0_pReal) rhoExcessGradient_over_rho = rhoExcessGradient / rhoTotal ! ... gives the local stress correction when multiplied with a factor - dst%tau_back(s,of) = - prm%mu * prm%b_sl(s) / (2.0_pReal * PI) & + dst%tau_back(s,me) = - prm%mu * prm%b_sl(s) / (2.0_pReal * PI) & * ( rhoExcessGradient_over_rho(1) / (1.0_pReal - prm%nu) & + rhoExcessGradient_over_rho(2)) enddo @@ -745,9 +743,9 @@ module subroutine plastic_nonlocal_dependentState(instance, of, ip, el) .and. ((debugConstitutive%element == el .and. debugConstitutive%ip == ip)& .or. .not. debugConstitutive%selective)) then print'(/,a,i8,1x,i2,1x,i1,/)', '<< CONST >> nonlocal_microstructure at el ip ',el,ip - print'(a,/,12x,12(e10.3,1x))', '<< CONST >> rhoForest', stt%rho_forest(:,of) - print'(a,/,12x,12(f10.5,1x))', '<< CONST >> tauThreshold / MPa', dst%tau_pass(:,of)*1e-6 - print'(a,/,12x,12(f10.5,1x),/)', '<< CONST >> tauBack / MPa', dst%tau_back(:,of)*1e-6 + print'(a,/,12x,12(e10.3,1x))', '<< CONST >> rhoForest', stt%rho_forest(:,me) + print'(a,/,12x,12(f10.5,1x))', '<< CONST >> tauThreshold / MPa', dst%tau_pass(:,me)*1e-6 + print'(a,/,12x,12(f10.5,1x),/)', '<< CONST >> tauBack / MPa', dst%tau_back(:,me)*1e-6 endif #endif @@ -760,14 +758,14 @@ end subroutine plastic_nonlocal_dependentState !> @brief calculates plastic velocity gradient and its tangent !-------------------------------------------------------------------------------------------------- module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & - Mp,Temperature,instance,of,ip,el) + Mp,Temperature,instance,me,ip,el) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & dLp_dMp integer, intent(in) :: & instance, & - of, & + me, & ip, & !< current integration point el !< current element number real(pReal), intent(in) :: & @@ -801,7 +799,7 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & ns = prm%sum_N_sl !*** shortcut to state variables - rho = getRho(instance,of,ip,el) + rho = getRho(instance,me,ip,el) rhoSgl = rho(:,sgl) do s = 1,ns @@ -816,12 +814,12 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & tauNS(s,4) = math_tensordot(Mp, -prm%nonSchmid_pos(1:3,1:3,s)) endif enddo - tauNS = tauNS + spread(dst%tau_back(:,of),2,4) - tau = tau + dst%tau_back(:,of) + tauNS = tauNS + spread(dst%tau_back(:,me),2,4) + tau = tau + dst%tau_back(:,me) ! edges call kinetics(v(:,1), dv_dtau(:,1), dv_dtauNS(:,1), & - tau, tauNS(:,1), dst%tau_pass(:,of),1,Temperature, instance) + tau, tauNS(:,1), dst%tau_pass(:,me),1,Temperature, instance) v(:,2) = v(:,1) dv_dtau(:,2) = dv_dtau(:,1) dv_dtauNS(:,2) = dv_dtauNS(:,1) @@ -834,11 +832,11 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & else do t = 3,4 call kinetics(v(:,t), dv_dtau(:,t), dv_dtauNS(:,t), & - tau, tauNS(:,t), dst%tau_pass(:,of),2,Temperature, instance) + tau, tauNS(:,t), dst%tau_pass(:,me),2,Temperature, instance) enddo endif - stt%v(:,of) = pack(v,.true.) + stt%v(:,me) = pack(v,.true.) !*** Bauschinger effect forall (s = 1:ns, t = 5:8, rhoSgl(s,t) * v(s,t-4) < 0.0_pReal) & @@ -867,13 +865,13 @@ end subroutine nonlocal_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief (instantaneous) incremental change of microstructure !-------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_deltaState(Mp,instance,of,ip,el) +module subroutine plastic_nonlocal_deltaState(Mp,instance,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress integer, intent(in) :: & instance, & ! current instance of this plasticity - of, & !< offset + me, & !< offset ip, & el @@ -904,10 +902,10 @@ module subroutine plastic_nonlocal_deltaState(Mp,instance,of,ip,el) ns = prm%sum_N_sl !*** shortcut to state variables - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,instance),of) - forall (s = 1:ns, c = 1:2) dUpperOld(s,c) = plasticState(ph)%state(iD(s,c,instance),of) + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,instance),me) + forall (s = 1:ns, c = 1:2) dUpperOld(s,c) = plasticState(ph)%state(iD(s,c,instance),me) - rho = getRho(instance,of,ip,el) + rho = getRho(instance,me,ip,el) rhoDip = rho(:,dip) !**************************************************************************** @@ -928,7 +926,7 @@ module subroutine plastic_nonlocal_deltaState(Mp,instance,of,ip,el) !*** calculate limits for stable dipole height do s = 1,prm%sum_N_sl - tau(s) = math_tensordot(Mp, prm%Schmid(1:3,1:3,s)) +dst%tau_back(s,of) + tau(s) = math_tensordot(Mp, prm%Schmid(1:3,1:3,s)) +dst%tau_back(s,me) if (abs(tau(s)) < 1.0e-15_pReal) tau(s) = 1.0e-15_pReal enddo @@ -952,10 +950,10 @@ module subroutine plastic_nonlocal_deltaState(Mp,instance,of,ip,el) / (dUpperOld(s,c) - prm%minDipoleHeight(s,c)) forall (t=1:4) deltaRhoDipole2SingleStress(:,t) = -0.5_pReal * deltaRhoDipole2SingleStress(:,(t-1)/2+9) - forall (s = 1:ns, c = 1:2) plasticState(ph)%state(iD(s,c,instance),of) = dUpper(s,c) + forall (s = 1:ns, c = 1:2) plasticState(ph)%state(iD(s,c,instance),me) = dUpper(s,c) - plasticState(ph)%deltaState(:,of) = 0.0_pReal - del%rho(:,of) = reshape(deltaRhoRemobilization + deltaRhoDipole2SingleStress, [10*ns]) + plasticState(ph)%deltaState(:,me) = 0.0_pReal + del%rho(:,me) = reshape(deltaRhoRemobilization + deltaRhoDipole2SingleStress, [10*ns]) #ifdef DEBUG if (debugConstitutive%extensive & @@ -975,7 +973,7 @@ end subroutine plastic_nonlocal_deltaState !> @brief calculates the rate of change of microstructure !--------------------------------------------------------------------------------------------------- module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & - instance,of,ip,el) + instance,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress @@ -984,7 +982,7 @@ module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & timestep !< substepped crystallite time increment integer, intent(in) :: & instance, & - of, & + me, & ip, & !< current integration point el !< current element number @@ -1034,13 +1032,13 @@ module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & tau = 0.0_pReal gdot = 0.0_pReal - rho = getRho(instance,of,ip,el) + rho = getRho(instance,me,ip,el) rhoSgl = rho(:,sgl) rhoDip = rho(:,dip) - rho0 = getRho0(instance,of,ip,el) + rho0 = getRho0(instance,me,ip,el) my_rhoSgl0 = rho0(:,sgl) - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,instance),of) + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,instance),me) gdot = rhoSgl(:,1:4) * v * spread(prm%b_sl,2,4) #ifdef DEBUG @@ -1055,7 +1053,7 @@ module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & !**************************************************************************** !*** limits for stable dipole height do s = 1,ns - tau(s) = math_tensordot(Mp, prm%Schmid(1:3,1:3,s)) + dst%tau_back(s,of) + tau(s) = math_tensordot(Mp, prm%Schmid(1:3,1:3,s)) + dst%tau_back(s,me) if (abs(tau(s)) < 1.0e-15_pReal) tau(s) = 1.0e-15_pReal enddo @@ -1076,20 +1074,20 @@ module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & isBCC: if (lattice_structure(ph) == LATTICE_bcc_ID) then forall (s = 1:ns, sum(abs(v(s,1:4))) > 0.0_pReal) rhoDotMultiplication(s,1:2) = sum(abs(gdot(s,3:4))) / prm%b_sl(s) & ! assuming double-cross-slip of screws to be decisive for multiplication - * sqrt(stt%rho_forest(s,of)) / prm%i_sl(s) ! & ! mean free path + * sqrt(stt%rho_forest(s,me)) / prm%i_sl(s) ! & ! mean free path ! * 2.0_pReal * sum(abs(v(s,3:4))) / sum(abs(v(s,1:4))) ! ratio of screw to overall velocity determines edge generation rhoDotMultiplication(s,3:4) = sum(abs(gdot(s,3:4))) /prm%b_sl(s) & ! assuming double-cross-slip of screws to be decisive for multiplication - * sqrt(stt%rho_forest(s,of)) / prm%i_sl(s) ! & ! mean free path + * sqrt(stt%rho_forest(s,me)) / prm%i_sl(s) ! & ! mean free path ! * 2.0_pReal * sum(abs(v(s,1:2))) / sum(abs(v(s,1:4))) ! ratio of edge to overall velocity determines screw generation endforall else isBCC rhoDotMultiplication(:,1:4) = spread( & (sum(abs(gdot(:,1:2)),2) * prm%f_ed_mult + sum(abs(gdot(:,3:4)),2)) & - * sqrt(stt%rho_forest(:,of)) / prm%i_sl / prm%b_sl, 2, 4) + * sqrt(stt%rho_forest(:,me)) / prm%i_sl / prm%b_sl, 2, 4) endif isBCC - forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,instance),of) + forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,instance),me) !**************************************************************************** @@ -1132,10 +1130,10 @@ module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & if (lattice_structure(ph) == LATTICE_fcc_ID) & forall (s = 1:ns, prm%colinearSystem(s) > 0) & rhoDotAthermalAnnihilation(prm%colinearSystem(s),1:2) = - rhoDotAthermalAnnihilation(s,10) & - * 0.25_pReal * sqrt(stt%rho_forest(s,of)) * (dUpper(s,2) + dLower(s,2)) * prm%f_ed + * 0.25_pReal * sqrt(stt%rho_forest(s,me)) * (dUpper(s,2) + dLower(s,2)) * prm%f_ed - !*** thermally activated annihilation of edge dipoles by climb + !*** thermally activated annihilation me edge dipoles by climb rhoDotThermalAnnihilation = 0.0_pReal selfDiffusion = prm%D_0 * exp(-prm%Q_cl / (kB * Temperature)) vClimb = prm%V_at * selfDiffusion * prm%mu & @@ -1145,7 +1143,7 @@ module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & - rhoDip(s,1) / timestep - rhoDotAthermalAnnihilation(s,9) & - rhoDotSingle2DipoleGlide(s,9)) ! make sure that we do not annihilate more dipoles than we have - rhoDot = rhoDotFlux(timestep, instance,of,ip,el) & + rhoDot = rhoDotFlux(timestep, instance,me,ip,el) & + rhoDotMultiplication & + rhoDotSingle2DipoleGlide & + rhoDotAthermalAnnihilation & @@ -1162,8 +1160,8 @@ module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & #endif plasticState(ph)%dotState = IEEE_value(1.0_pReal,IEEE_quiet_NaN) else - dot%rho(:,of) = pack(rhoDot,.true.) - dot%gamma(:,of) = sum(gdot,2) + dot%rho(:,me) = pack(rhoDot,.true.) + dot%gamma(:,me) = sum(gdot,2) endif end associate @@ -1174,13 +1172,13 @@ end subroutine plastic_nonlocal_dotState !--------------------------------------------------------------------------------------------------- !> @brief calculates the rate of change of microstructure !--------------------------------------------------------------------------------------------------- -function rhoDotFlux(timestep,instance,of,ip,el) +function rhoDotFlux(timestep,instance,me,ip,el) real(pReal), intent(in) :: & timestep !< substepped crystallite time increment integer, intent(in) :: & instance, & - of, & + me, & ip, & !< current integration point el !< current element number @@ -1243,16 +1241,16 @@ function rhoDotFlux(timestep,instance,of,ip,el) gdot = 0.0_pReal - rho = getRho(instance,of,ip,el) + rho = getRho(instance,me,ip,el) rhoSgl = rho(:,sgl) - rho0 = getRho0(instance,of,ip,el) + rho0 = getRho0(instance,me,ip,el) my_rhoSgl0 = rho0(:,sgl) - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,instance),of) !ToDo: MD: I think we should use state0 here + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,instance),me) !ToDo: MD: I think we should use state0 here gdot = rhoSgl(:,1:4) * v * spread(prm%b_sl,2,4) - forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,instance),of) + forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,instance),me) !**************************************************************************** !*** calculate dislocation fluxes (only for nonlocal plasticity) @@ -1287,8 +1285,8 @@ function rhoDotFlux(timestep,instance,of,ip,el) m(1:3,:,3) = -prm%slip_transverse m(1:3,:,4) = prm%slip_transverse - my_F = constitutive_mech_F(ph)%data(1:3,1:3,of) - my_Fe = matmul(my_F, math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,of))) + my_F = constitutive_mech_F(ph)%data(1:3,1:3,me) + my_Fe = matmul(my_F, math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me))) neighbors: do n = 1,nIPneighbors @@ -1789,14 +1787,14 @@ end subroutine kinetics !> @brief returns copy of current dislocation densities from state !> @details raw values is rectified !-------------------------------------------------------------------------------------------------- -pure function getRho(instance,of,ip,el) +pure function getRho(instance,me,ip,el) - integer, intent(in) :: instance, of,ip,el + integer, intent(in) :: instance, me,ip,el real(pReal), dimension(param(instance)%sum_N_sl,10) :: getRho associate(prm => param(instance)) - getRho = reshape(state(instance)%rho(:,of),[prm%sum_N_sl,10]) + getRho = reshape(state(instance)%rho(:,me),[prm%sum_N_sl,10]) ! ensure positive densities (not for imm, they have a sign) getRho(:,mob) = max(getRho(:,mob),0.0_pReal) @@ -1814,14 +1812,14 @@ end function getRho !> @brief returns copy of current dislocation densities from state !> @details raw values is rectified !-------------------------------------------------------------------------------------------------- -pure function getRho0(instance,of,ip,el) +pure function getRho0(instance,me,ip,el) - integer, intent(in) :: instance, of,ip,el + integer, intent(in) :: instance, me,ip,el real(pReal), dimension(param(instance)%sum_N_sl,10) :: getRho0 associate(prm => param(instance)) - getRho0 = reshape(state0(instance)%rho(:,of),[prm%sum_N_sl,10]) + getRho0 = reshape(state0(instance)%rho(:,me),[prm%sum_N_sl,10]) ! ensure positive densities (not for imm, they have a sign) getRho0(:,mob) = max(getRho0(:,mob),0.0_pReal) diff --git a/src/phase_mechanics_plastic_phenopowerlaw.f90 b/src/phase_mechanics_plastic_phenopowerlaw.f90 index 60951e7c4..05cdf48ef 100644 --- a/src/phase_mechanics_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanics_plastic_phenopowerlaw.f90 @@ -285,7 +285,7 @@ end function plastic_phenopowerlaw_init !> @details asummes that deformation by dislocation glide affects twinned and untwinned volume ! equally (Taylor assumption). Twinning happens only in untwinned volume !-------------------------------------------------------------------------------------------------- -pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) +pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -296,7 +296,7 @@ pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me integer :: & i,k,l,m,n @@ -311,7 +311,7 @@ pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) associate(prm => param(instance)) - call kinetics_slip(Mp,instance,of,gdot_slip_pos,gdot_slip_neg,dgdot_dtauslip_pos,dgdot_dtauslip_neg) + call kinetics_slip(Mp,instance,me,gdot_slip_pos,gdot_slip_neg,dgdot_dtauslip_pos,dgdot_dtauslip_neg) slipSystems: do i = 1, prm%sum_N_sl Lp = Lp + (gdot_slip_pos(i)+gdot_slip_neg(i))*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -320,7 +320,7 @@ pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,of) + dgdot_dtauslip_neg(i) * prm%P_sl(k,l,i) * prm%nonSchmid_neg(m,n,i) enddo slipSystems - call kinetics_twin(Mp,instance,of,gdot_twin,dgdot_dtautwin) + call kinetics_twin(Mp,instance,me,gdot_twin,dgdot_dtautwin) twinSystems: do i = 1, prm%sum_N_tw Lp = Lp + gdot_twin(i)*prm%P_tw(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -336,13 +336,13 @@ end subroutine phenopowerlaw_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_phenopowerlaw_dotState(Mp,instance,of) +module subroutine plastic_phenopowerlaw_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me real(pReal) :: & c_SlipSlip,c_TwinSlip,c_TwinTwin, & @@ -354,8 +354,8 @@ module subroutine plastic_phenopowerlaw_dotState(Mp,instance,of) associate(prm => param(instance), stt => state(instance), dot => dotState(instance)) - sumGamma = sum(stt%gamma_slip(:,of)) - sumF = sum(stt%gamma_twin(:,of)/prm%gamma_tw_char) + sumGamma = sum(stt%gamma_slip(:,me)) + sumF = sum(stt%gamma_twin(:,me)/prm%gamma_tw_char) !-------------------------------------------------------------------------------------------------- ! system-independent (nonlinear) prefactors to M_Xx (X influenced by x) matrices @@ -367,23 +367,23 @@ module subroutine plastic_phenopowerlaw_dotState(Mp,instance,of) ! calculate left and right vectors left_SlipSlip = 1.0_pReal + prm%h_int xi_slip_sat_offset = prm%f_sl_sat_tw*sqrt(sumF) - right_SlipSlip = abs(1.0_pReal-stt%xi_slip(:,of) / (prm%xi_inf_sl+xi_slip_sat_offset)) **prm%a_sl & - * sign(1.0_pReal,1.0_pReal-stt%xi_slip(:,of) / (prm%xi_inf_sl+xi_slip_sat_offset)) + right_SlipSlip = abs(1.0_pReal-stt%xi_slip(:,me) / (prm%xi_inf_sl+xi_slip_sat_offset)) **prm%a_sl & + * sign(1.0_pReal,1.0_pReal-stt%xi_slip(:,me) / (prm%xi_inf_sl+xi_slip_sat_offset)) !-------------------------------------------------------------------------------------------------- ! shear rates - call kinetics_slip(Mp,instance,of,gdot_slip_pos,gdot_slip_neg) - dot%gamma_slip(:,of) = abs(gdot_slip_pos+gdot_slip_neg) - call kinetics_twin(Mp,instance,of,dot%gamma_twin(:,of)) + call kinetics_slip(Mp,instance,me,gdot_slip_pos,gdot_slip_neg) + dot%gamma_slip(:,me) = abs(gdot_slip_pos+gdot_slip_neg) + call kinetics_twin(Mp,instance,me,dot%gamma_twin(:,me)) !-------------------------------------------------------------------------------------------------- ! hardening - dot%xi_slip(:,of) = c_SlipSlip * left_SlipSlip * & - matmul(prm%h_sl_sl,dot%gamma_slip(:,of)*right_SlipSlip) & - + matmul(prm%h_sl_tw,dot%gamma_twin(:,of)) + dot%xi_slip(:,me) = c_SlipSlip * left_SlipSlip * & + matmul(prm%h_sl_sl,dot%gamma_slip(:,me)*right_SlipSlip) & + + matmul(prm%h_sl_tw,dot%gamma_twin(:,me)) - dot%xi_twin(:,of) = c_TwinSlip * matmul(prm%h_tw_sl,dot%gamma_slip(:,of)) & - + c_TwinTwin * matmul(prm%h_tw_tw,dot%gamma_twin(:,of)) + dot%xi_twin(:,me) = c_TwinSlip * matmul(prm%h_tw_sl,dot%gamma_slip(:,me)) & + + c_TwinTwin * matmul(prm%h_tw_tw,dot%gamma_twin(:,me)) end associate end subroutine plastic_phenopowerlaw_dotState @@ -431,14 +431,14 @@ end subroutine plastic_phenopowerlaw_results ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_slip(Mp,instance,of, & +pure subroutine kinetics_slip(Mp,instance,me, & gdot_slip_pos,gdot_slip_neg,dgdot_dtau_slip_pos,dgdot_dtau_slip_neg) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me real(pReal), intent(out), dimension(param(instance)%sum_N_sl) :: & gdot_slip_pos, & @@ -462,14 +462,14 @@ pure subroutine kinetics_slip(Mp,instance,of, & where(dNeq0(tau_slip_pos)) gdot_slip_pos = prm%dot_gamma_0_sl * merge(0.5_pReal,1.0_pReal, prm%nonSchmidActive) & ! 1/2 if non-Schmid active - * sign(abs(tau_slip_pos/stt%xi_slip(:,of))**prm%n_sl, tau_slip_pos) + * sign(abs(tau_slip_pos/stt%xi_slip(:,me))**prm%n_sl, tau_slip_pos) else where gdot_slip_pos = 0.0_pReal end where where(dNeq0(tau_slip_neg)) gdot_slip_neg = prm%dot_gamma_0_sl * 0.5_pReal & ! only used if non-Schmid active, always 1/2 - * sign(abs(tau_slip_neg/stt%xi_slip(:,of))**prm%n_sl, tau_slip_neg) + * sign(abs(tau_slip_neg/stt%xi_slip(:,me))**prm%n_sl, tau_slip_neg) else where gdot_slip_neg = 0.0_pReal end where @@ -500,14 +500,14 @@ end subroutine kinetics_slip ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_twin(Mp,instance,of,& +pure subroutine kinetics_twin(Mp,instance,me,& gdot_twin,dgdot_dtau_twin) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & - of + me real(pReal), dimension(param(instance)%sum_N_tw), intent(out) :: & gdot_twin @@ -525,8 +525,8 @@ pure subroutine kinetics_twin(Mp,instance,of,& enddo where(tau_twin > 0.0_pReal) - gdot_twin = (1.0_pReal-sum(stt%gamma_twin(:,of)/prm%gamma_tw_char)) & ! only twin in untwinned volume fraction - * prm%dot_gamma_0_tw*(abs(tau_twin)/stt%xi_twin(:,of))**prm%n_tw + gdot_twin = (1.0_pReal-sum(stt%gamma_twin(:,me)/prm%gamma_tw_char)) & ! only twin in untwinned volume fraction + * prm%dot_gamma_0_tw*(abs(tau_twin)/stt%xi_twin(:,me))**prm%n_tw else where gdot_twin = 0.0_pReal end where From 1f625e141e14cf2f60c977b798b6498e91883cfc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 11:41:19 +0100 Subject: [PATCH 172/352] hierarchical naming --- src/homogenization_mechanics.f90 | 4 ++-- src/homogenization_mechanics_RGC.f90 | 4 ++-- src/homogenization_mechanics_isostrain.f90 | 4 ++-- src/homogenization_mechanics_none.f90 | 4 ++-- src/phase_mechanics.f90 | 8 ++++---- src/phase_mechanics_plastic.f90 | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/homogenization_mechanics.f90 b/src/homogenization_mechanics.f90 index dd3e47c59..3d889e298 100644 --- a/src/homogenization_mechanics.f90 +++ b/src/homogenization_mechanics.f90 @@ -2,7 +2,7 @@ !> @author Martin Diehl, KU Leuven !> @brief Partition F and homogenize P/dPdF !-------------------------------------------------------------------------------------------------- -submodule(homogenization) homogenization_mech +submodule(homogenization) mechanics interface @@ -253,4 +253,4 @@ module subroutine mech_results(group_base,h) end subroutine mech_results -end submodule homogenization_mech +end submodule mechanics diff --git a/src/homogenization_mechanics_RGC.f90 b/src/homogenization_mechanics_RGC.f90 index 2c7a5a8cb..6f76fe788 100644 --- a/src/homogenization_mechanics_RGC.f90 +++ b/src/homogenization_mechanics_RGC.f90 @@ -6,7 +6,7 @@ !> @brief Relaxed grain cluster (RGC) homogenization scheme !> N_constituents is defined as p x q x r (cluster) !-------------------------------------------------------------------------------------------------- -submodule(homogenization:homogenization_mech) homogenization_mech_RGC +submodule(homogenization:mechanics) RGC use rotations use lattice @@ -947,4 +947,4 @@ pure function interface1to4(iFace1D, nGDim) end function interface1to4 -end submodule homogenization_mech_RGC +end submodule RGC diff --git a/src/homogenization_mechanics_isostrain.f90 b/src/homogenization_mechanics_isostrain.f90 index df8f5fc9d..699000cc8 100644 --- a/src/homogenization_mechanics_isostrain.f90 +++ b/src/homogenization_mechanics_isostrain.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH !> @brief Isostrain (full constraint Taylor assuption) homogenization scheme !-------------------------------------------------------------------------------------------------- -submodule(homogenization:homogenization_mech) homogenization_mech_isostrain +submodule(homogenization:mechanics) isostrain enum, bind(c); enumerator :: & parallel_ID, & @@ -114,4 +114,4 @@ module subroutine mech_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dP end subroutine mech_isostrain_averageStressAndItsTangent -end submodule homogenization_mech_isostrain +end submodule isostrain diff --git a/src/homogenization_mechanics_none.f90 b/src/homogenization_mechanics_none.f90 index 767dbf557..195e388f9 100644 --- a/src/homogenization_mechanics_none.f90 +++ b/src/homogenization_mechanics_none.f90 @@ -4,7 +4,7 @@ !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH !> @brief dummy homogenization homogenization scheme for 1 constituent per material point !-------------------------------------------------------------------------------------------------- -submodule(homogenization:homogenization_mech) homogenization_mech_none +submodule(homogenization:mechanics) none contains @@ -38,4 +38,4 @@ module subroutine mech_none_init end subroutine mech_none_init -end submodule homogenization_mech_none +end submodule none diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index edf2fb4ad..c880b5e17 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -181,7 +181,7 @@ submodule(constitutive) constitutive_mech el end subroutine plastic_nonlocal_deltaState - module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & + module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & S, Fi, co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point @@ -196,7 +196,7 @@ submodule(constitutive) constitutive_mech dLp_dS, & dLp_dFi !< derivative of Lp with respect to Fi - end subroutine constitutive_plastic_LpAndItsTangents + end subroutine plastic_LpAndItsTangents module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) integer, intent(in) :: kinematics_length @@ -806,7 +806,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) call constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & Fe, Fi_new, co, ip, el) - call constitutive_plastic_LpAndItsTangents(Lp_constitutive, dLp_dS, dLp_dFi, & + call plastic_LpAndItsTangents(Lp_constitutive, dLp_dS, dLp_dFi, & S, Fi_new, co, ip, el) !* update current residuum and check for convergence of loop @@ -1599,7 +1599,7 @@ module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) dLidS = math_mul3333xx3333(dLidFi,dFidS) + dLidS endif - call constitutive_plastic_LpAndItsTangents(devNull,dLpdS,dLpdFi, & + call plastic_LpAndItsTangents(devNull,dLpdS,dLpdFi, & constitutive_mech_S(ph)%data(1:3,1:3,me), & constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) dLpdS = math_mul3333xx3333(dLpdFi,dFidS) + dLpdS diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index ea04a18fd..542a79fcb 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -95,7 +95,7 @@ contains ! ToDo: Discuss whether it makes sense if crystallite handles the configuration conversion, i.e. ! Mp in, dLp_dMp out !-------------------------------------------------------------------------------------------------- -module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & +module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & S, Fi, co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point @@ -155,6 +155,6 @@ module subroutine constitutive_plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & dLp_dS(i,j,1:3,1:3) = matmul(matmul(transpose(Fi),Fi),dLp_dMp(i,j,1:3,1:3)) ! ToDo: @PS: why not: dLp_dMp:(FiT Fi) enddo; enddo -end subroutine constitutive_plastic_LpAndItsTangents +end subroutine plastic_LpAndItsTangents end submodule plastic From a2fe86a41004f67f68d8848a55490d15ffbecd8b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 11:45:39 +0100 Subject: [PATCH 173/352] structuring --- src/phase_mechanics.f90 | 240 +++----------------------------- src/phase_mechanics_plastic.f90 | 240 ++++++++++++++++++++++++++++++++ 2 files changed, 258 insertions(+), 222 deletions(-) diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index c880b5e17..cfc211cc0 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -83,103 +83,32 @@ submodule(constitutive) constitutive_mech myPlasticity end function plastic_nonlocal_init - module subroutine plastic_isotropic_dotState(Mp,instance,me) - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - integer, intent(in) :: & - instance, & - me - end subroutine plastic_isotropic_dotState + module function mech_collectDotState(subdt,co,ip,el,ph,me) result(broken) - module subroutine plastic_phenopowerlaw_dotState(Mp,instance,me) - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - integer, intent(in) :: & - instance, & - me - end subroutine plastic_phenopowerlaw_dotState - - module subroutine plastic_kinehardening_dotState(Mp,instance,me) - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - integer, intent(in) :: & - instance, & - me - end subroutine plastic_kinehardening_dotState - - module subroutine plastic_dislotwin_dotState(Mp,T,instance,me) - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - real(pReal), intent(in) :: & - T - integer, intent(in) :: & - instance, & - me - end subroutine plastic_dislotwin_dotState - - module subroutine plastic_disloTungsten_dotState(Mp,T,instance,me) - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - real(pReal), intent(in) :: & - T - integer, intent(in) :: & - instance, & - me - end subroutine plastic_disloTungsten_dotState - - module subroutine plastic_nonlocal_dotState(Mp,Temperature,timestep,instance,me,ip,el) - real(pReal), dimension(3,3), intent(in) :: & - Mp !< MandelStress - real(pReal), intent(in) :: & - Temperature, & !< temperature - timestep !< substepped crystallite time increment integer, intent(in) :: & - instance, & - me, & - ip, & !< current integration point - el !< current element number - end subroutine plastic_nonlocal_dotState - - - module subroutine plastic_dislotwin_dependentState(T,instance,me) - integer, intent(in) :: & - instance, & + co, & !< component-ID of integration point + ip, & !< integration point + el, & !< element + ph, & me - real(pReal), intent(in) :: & - T - end subroutine plastic_dislotwin_dependentState + real(pReal), intent(in) :: & + subdt !< timestep + logical :: broken + end function mech_collectDotState - module subroutine plastic_dislotungsten_dependentState(instance,me) - integer, intent(in) :: & - instance, & - me - end subroutine plastic_dislotungsten_dependentState + module function constitutive_deltaState(co, ip, el, ph, of) result(broken) - module subroutine plastic_nonlocal_dependentState(instance, me, ip, el) integer, intent(in) :: & - instance, & - me, & - ip, & !< current integration point - el !< current element number - end subroutine plastic_nonlocal_dependentState + co, & !< component-ID of integration point + ip, & !< integration point + el, & !< element + ph, & + of + logical :: & + broken - module subroutine plastic_kinehardening_deltaState(Mp,instance,me) - real(pReal), dimension(3,3), intent(in) :: & - Mp !< Mandel stress - integer, intent(in) :: & - instance, & - me - end subroutine plastic_kinehardening_deltaState + end function constitutive_deltaState - module subroutine plastic_nonlocal_deltaState(Mp,instance,me,ip,el) - real(pReal), dimension(3,3), intent(in) :: & - Mp - integer, intent(in) :: & - instance, & - me, & - ip, & - el - end subroutine plastic_nonlocal_deltaState module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & S, Fi, co, ip, el) @@ -516,149 +445,16 @@ subroutine constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & end subroutine constitutive_hooke_SandItsTangents -!-------------------------------------------------------------------------------------------------- -!> @brief calls microstructure function of the different plasticity constitutive models -!-------------------------------------------------------------------------------------------------- -module subroutine constitutive_plastic_dependentState(co, ip, el) - - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - - integer :: & - ph, & - instance, me - - - ph = material_phaseAt(co,el) - me = material_phasememberAt(co,ip,el) - instance = phase_plasticityInstance(ph) - - plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) - - case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_dependentState(thermal_T(ph,me),instance,me) - - case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_dislotungsten_dependentState(instance,me) - - case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_dependentState(instance,me,ip,el) - - end select plasticityType - -end subroutine constitutive_plastic_dependentState -!-------------------------------------------------------------------------------------------------- -!> @brief contains the constitutive equation for calculating the rate of change of microstructure -!-------------------------------------------------------------------------------------------------- -function mech_collectDotState(subdt,co,ip,el,ph,me) result(broken) - - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el, & !< element - ph, & - me - real(pReal), intent(in) :: & - subdt !< timestep - real(pReal), dimension(3,3) :: & - Mp - integer :: & - instance - logical :: broken - instance = phase_plasticityInstance(ph) - - Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,me)),& - constitutive_mech_Fi(ph)%data(1:3,1:3,me)),constitutive_mech_S(ph)%data(1:3,1:3,me)) - - plasticityType: select case (phase_plasticity(ph)) - - case (PLASTICITY_ISOTROPIC_ID) plasticityType - call plastic_isotropic_dotState(Mp,instance,me) - - case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType - call plastic_phenopowerlaw_dotState(Mp,instance,me) - - case (PLASTICITY_KINEHARDENING_ID) plasticityType - call plastic_kinehardening_dotState(Mp,instance,me) - - case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_dotState(Mp,thermal_T(ph,me),instance,me) - - case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_disloTungsten_dotState(Mp,thermal_T(ph,me),instance,me) - - case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_dotState(Mp,thermal_T(ph,me),subdt,instance,me,ip,el) - end select plasticityType - broken = any(IEEE_is_NaN(plasticState(ph)%dotState(:,me))) -end function mech_collectDotState -!-------------------------------------------------------------------------------------------------- -!> @brief for constitutive models having an instantaneous change of state -!> will return false if delta state is not needed/supported by the constitutive model -!-------------------------------------------------------------------------------------------------- -function constitutive_deltaState(co, ip, el, ph, of) result(broken) - - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el, & !< element - ph, & - of - logical :: & - broken - - real(pReal), dimension(3,3) :: & - Mp - integer :: & - instance, & - myOffset, & - mySize - - - Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,of)),& - constitutive_mech_Fi(ph)%data(1:3,1:3,of)),constitutive_mech_S(ph)%data(1:3,1:3,of)) - instance = phase_plasticityInstance(ph) - - plasticityType: select case (phase_plasticity(ph)) - - case (PLASTICITY_KINEHARDENING_ID) plasticityType - call plastic_kinehardening_deltaState(Mp,instance,of) - broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,of))) - - case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_deltaState(Mp,instance,of,ip,el) - broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,of))) - - case default - broken = .false. - - end select plasticityType - - if(.not. broken) then - select case(phase_plasticity(ph)) - case (PLASTICITY_NONLOCAL_ID,PLASTICITY_KINEHARDENING_ID) - - myOffset = plasticState(ph)%offsetDeltaState - mySize = plasticState(ph)%sizeDeltaState - plasticState(ph)%state(myOffset + 1:myOffset + mySize,of) = & - plasticState(ph)%state(myOffset + 1:myOffset + mySize,of) + plasticState(ph)%deltaState(1:mySize,of) - end select - endif - -end function constitutive_deltaState - module subroutine mech_results(group,ph) diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index 542a79fcb..ef8c356e5 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -86,6 +86,104 @@ submodule(constitutive:constitutive_mech) plastic el !< current element number end subroutine nonlocal_LpAndItsTangent + + module subroutine plastic_isotropic_dotState(Mp,instance,me) + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + integer, intent(in) :: & + instance, & + me + end subroutine plastic_isotropic_dotState + + module subroutine plastic_phenopowerlaw_dotState(Mp,instance,me) + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + integer, intent(in) :: & + instance, & + me + end subroutine plastic_phenopowerlaw_dotState + + module subroutine plastic_kinehardening_dotState(Mp,instance,me) + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + integer, intent(in) :: & + instance, & + me + end subroutine plastic_kinehardening_dotState + + module subroutine plastic_dislotwin_dotState(Mp,T,instance,me) + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + real(pReal), intent(in) :: & + T + integer, intent(in) :: & + instance, & + me + end subroutine plastic_dislotwin_dotState + + module subroutine plastic_disloTungsten_dotState(Mp,T,instance,me) + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + real(pReal), intent(in) :: & + T + integer, intent(in) :: & + instance, & + me + end subroutine plastic_disloTungsten_dotState + + module subroutine plastic_nonlocal_dotState(Mp,Temperature,timestep,instance,me,ip,el) + real(pReal), dimension(3,3), intent(in) :: & + Mp !< MandelStress + real(pReal), intent(in) :: & + Temperature, & !< temperature + timestep !< substepped crystallite time increment + integer, intent(in) :: & + instance, & + me, & + ip, & !< current integration point + el !< current element number + end subroutine plastic_nonlocal_dotState + + module subroutine plastic_dislotwin_dependentState(T,instance,me) + integer, intent(in) :: & + instance, & + me + real(pReal), intent(in) :: & + T + end subroutine plastic_dislotwin_dependentState + + module subroutine plastic_dislotungsten_dependentState(instance,me) + integer, intent(in) :: & + instance, & + me + end subroutine plastic_dislotungsten_dependentState + + module subroutine plastic_nonlocal_dependentState(instance, me, ip, el) + integer, intent(in) :: & + instance, & + me, & + ip, & !< current integration point + el !< current element number + end subroutine plastic_nonlocal_dependentState + + module subroutine plastic_kinehardening_deltaState(Mp,instance,me) + real(pReal), dimension(3,3), intent(in) :: & + Mp !< Mandel stress + integer, intent(in) :: & + instance, & + me + end subroutine plastic_kinehardening_deltaState + + module subroutine plastic_nonlocal_deltaState(Mp,instance,me,ip,el) + real(pReal), dimension(3,3), intent(in) :: & + Mp + integer, intent(in) :: & + instance, & + me, & + ip, & + el + end subroutine plastic_nonlocal_deltaState + end interface contains @@ -157,4 +255,146 @@ module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & end subroutine plastic_LpAndItsTangents + +!-------------------------------------------------------------------------------------------------- +!> @brief contains the constitutive equation for calculating the rate of change of microstructure +!-------------------------------------------------------------------------------------------------- +module function mech_collectDotState(subdt,co,ip,el,ph,me) result(broken) + + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el, & !< element + ph, & + me + real(pReal), intent(in) :: & + subdt !< timestep + real(pReal), dimension(3,3) :: & + Mp + integer :: & + instance + logical :: broken + + + instance = phase_plasticityInstance(ph) + + Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,me)),& + constitutive_mech_Fi(ph)%data(1:3,1:3,me)),constitutive_mech_S(ph)%data(1:3,1:3,me)) + + plasticityType: select case (phase_plasticity(ph)) + + case (PLASTICITY_ISOTROPIC_ID) plasticityType + call plastic_isotropic_dotState(Mp,instance,me) + + case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType + call plastic_phenopowerlaw_dotState(Mp,instance,me) + + case (PLASTICITY_KINEHARDENING_ID) plasticityType + call plastic_kinehardening_dotState(Mp,instance,me) + + case (PLASTICITY_DISLOTWIN_ID) plasticityType + call plastic_dislotwin_dotState(Mp,thermal_T(ph,me),instance,me) + + case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType + call plastic_disloTungsten_dotState(Mp,thermal_T(ph,me),instance,me) + + case (PLASTICITY_NONLOCAL_ID) plasticityType + call plastic_nonlocal_dotState(Mp,thermal_T(ph,me),subdt,instance,me,ip,el) + end select plasticityType + broken = any(IEEE_is_NaN(plasticState(ph)%dotState(:,me))) + + +end function mech_collectDotState + + +!-------------------------------------------------------------------------------------------------- +!> @brief calls microstructure function of the different plasticity constitutive models +!-------------------------------------------------------------------------------------------------- +module subroutine constitutive_plastic_dependentState(co, ip, el) + + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + + integer :: & + ph, & + instance, me + + + ph = material_phaseAt(co,el) + me = material_phasememberAt(co,ip,el) + instance = phase_plasticityInstance(ph) + + plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) + + case (PLASTICITY_DISLOTWIN_ID) plasticityType + call plastic_dislotwin_dependentState(thermal_T(ph,me),instance,me) + + case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType + call plastic_dislotungsten_dependentState(instance,me) + + case (PLASTICITY_NONLOCAL_ID) plasticityType + call plastic_nonlocal_dependentState(instance,me,ip,el) + + end select plasticityType + +end subroutine constitutive_plastic_dependentState + + +!-------------------------------------------------------------------------------------------------- +!> @brief for constitutive models having an instantaneous change of state +!> will return false if delta state is not needed/supported by the constitutive model +!-------------------------------------------------------------------------------------------------- +module function constitutive_deltaState(co, ip, el, ph, of) result(broken) + + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el, & !< element + ph, & + of + logical :: & + broken + + real(pReal), dimension(3,3) :: & + Mp + integer :: & + instance, & + myOffset, & + mySize + + + Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,of)),& + constitutive_mech_Fi(ph)%data(1:3,1:3,of)),constitutive_mech_S(ph)%data(1:3,1:3,of)) + instance = phase_plasticityInstance(ph) + + plasticityType: select case (phase_plasticity(ph)) + + case (PLASTICITY_KINEHARDENING_ID) plasticityType + call plastic_kinehardening_deltaState(Mp,instance,of) + broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,of))) + + case (PLASTICITY_NONLOCAL_ID) plasticityType + call plastic_nonlocal_deltaState(Mp,instance,of,ip,el) + broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,of))) + + case default + broken = .false. + + end select plasticityType + + if(.not. broken) then + select case(phase_plasticity(ph)) + case (PLASTICITY_NONLOCAL_ID,PLASTICITY_KINEHARDENING_ID) + + myOffset = plasticState(ph)%offsetDeltaState + mySize = plasticState(ph)%sizeDeltaState + plasticState(ph)%state(myOffset + 1:myOffset + mySize,of) = & + plasticState(ph)%state(myOffset + 1:myOffset + mySize,of) + plasticState(ph)%deltaState(1:mySize,of) + end select + endif + +end function constitutive_deltaState + end submodule plastic From e0e927d1915fe8554c7ca9dcd21b0d708821ef83 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 12:17:00 +0100 Subject: [PATCH 174/352] names reflect hierarchy --- src/phase.f90 | 6 +- src/phase_mechanics.f90 | 43 +++++-------- src/phase_mechanics_plastic.f90 | 60 +++++++++---------- src/phase_mechanics_plastic_dislotungsten.f90 | 8 +-- src/phase_mechanics_plastic_dislotwin.f90 | 8 +-- src/phase_mechanics_plastic_isotropic.f90 | 4 +- src/phase_mechanics_plastic_nonlocal.f90 | 8 +-- src/phase_mechanics_plastic_phenopowerlaw.f90 | 4 +- 8 files changed, 65 insertions(+), 76 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index e8cddfb25..65fb7a859 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -313,12 +313,12 @@ module constitutive dLi_dTstar !< derivative of Li with respect to Tstar (4th-order tensor defined to be zero) end subroutine kinematics_thermal_expansion_LiAndItsTangent - module subroutine constitutive_plastic_dependentState(co,ip,el) + module subroutine plastic_dependentState(co,ip,el) integer, intent(in) :: & co, & !< component-ID of integration point ip, & !< integration point el !< element - end subroutine constitutive_plastic_dependentState + end subroutine plastic_dependentState end interface @@ -630,7 +630,7 @@ subroutine crystallite_init() ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) call crystallite_orientations(co,ip,el) - call constitutive_plastic_dependentState(co,ip,el) ! update dependent state variables to be consistent with basic states + call plastic_dependentState(co,ip,el) ! update dependent state variables to be consistent with basic states enddo enddo enddo diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index cfc211cc0..e37712e40 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -83,7 +83,7 @@ submodule(constitutive) constitutive_mech myPlasticity end function plastic_nonlocal_init - module function mech_collectDotState(subdt,co,ip,el,ph,me) result(broken) + module function plastic_dotState(subdt,co,ip,el,ph,me) result(broken) integer, intent(in) :: & co, & !< component-ID of integration point @@ -94,9 +94,9 @@ submodule(constitutive) constitutive_mech real(pReal), intent(in) :: & subdt !< timestep logical :: broken - end function mech_collectDotState + end function plastic_dotState - module function constitutive_deltaState(co, ip, el, ph, of) result(broken) + module function plastic_deltaState(co, ip, el, ph, of) result(broken) integer, intent(in) :: & co, & !< component-ID of integration point @@ -107,7 +107,7 @@ submodule(constitutive) constitutive_mech logical :: & broken - end function constitutive_deltaState + end function plastic_deltaState module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & @@ -445,17 +445,6 @@ subroutine constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & end subroutine constitutive_hooke_SandItsTangents - - - - - - - - - - - module subroutine mech_results(group,ph) character(len=*), intent(in) :: group @@ -562,7 +551,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - call constitutive_plastic_dependentState(co,ip,el) + call plastic_dependentState(co,ip,el) Lpguess = constitutive_mech_Lp(ph)%data(1:3,1:3,me) ! take as first guess Liguess = constitutive_mech_Li(ph)%data(1:3,1:3,me) ! take as first guess @@ -738,7 +727,7 @@ function integrateStateFPI(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) resul ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) + broken = plastic_dotState(Delta_t, co,ip,el,ph,me) if(broken) return sizeDotState = plasticState(ph)%sizeDotState @@ -754,7 +743,7 @@ function integrateStateFPI(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) resul broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) if(broken) exit iteration - broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) + broken = plastic_dotState(Delta_t, co,ip,el,ph,me) if(broken) exit iteration zeta = damper(plasticState(ph)%dotState(:,me),dotState(1:sizeDotState,1),& @@ -767,7 +756,7 @@ function integrateStateFPI(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) resul plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%state(1:sizeDotState,me) & - r(1:sizeDotState) if (converged(r(1:sizeDotState),plasticState(ph)%state(1:sizeDotState,me),plasticState(ph)%atol(1:sizeDotState))) then - broken = constitutive_deltaState(co,ip,el,ph,me) + broken = plastic_deltaState(co,ip,el,ph,me) exit iteration endif @@ -823,14 +812,14 @@ function integrateStateEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) res ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) + broken = plastic_dotState(Delta_t, co,ip,el,ph,me) if(broken) return sizeDotState = plasticState(ph)%sizeDotState plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotState(1:sizeDotState,me) * Delta_t - broken = constitutive_deltaState(co,ip,el,ph,me) + broken = plastic_deltaState(co,ip,el,ph,me) if(broken) return broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) @@ -863,7 +852,7 @@ function integrateStateAdaptiveEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) + broken = plastic_dotState(Delta_t, co,ip,el,ph,me) if(broken) return sizeDotState = plasticState(ph)%sizeDotState @@ -872,13 +861,13 @@ function integrateStateAdaptiveEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotstate(1:sizeDotState,me) * Delta_t - broken = constitutive_deltaState(co,ip,el,ph,me) + broken = plastic_deltaState(co,ip,el,ph,me) if(broken) return broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) if(broken) return - broken = mech_collectDotState(Delta_t, co,ip,el,ph,me) + broken = plastic_dotState(Delta_t, co,ip,el,ph,me) if(broken) return broken = .not. converged(residuum_plastic(1:sizeDotState) + 0.5_pReal * plasticState(ph)%dotState(:,me) * Delta_t, & @@ -981,7 +970,7 @@ function integrateStateRK(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el,A,B,C,D ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - broken = mech_collectDotState(Delta_t,co,ip,el,ph,me) + broken = plastic_dotState(Delta_t,co,ip,el,ph,me) if(broken) return sizeDotState = plasticState(ph)%sizeDotState @@ -1002,7 +991,7 @@ function integrateStateRK(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el,A,B,C,D broken = integrateStress(F_0 + (F - F_0) * Delta_t * C(stage),subFp0,subFi0,Delta_t * C(stage),co,ip,el) if(broken) exit - broken = mech_collectDotState(Delta_t*C(stage),co,ip,el,ph,me) + broken = plastic_dotState(Delta_t*C(stage),co,ip,el,ph,me) if(broken) exit enddo @@ -1021,7 +1010,7 @@ function integrateStateRK(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el,A,B,C,D if(broken) return - broken = constitutive_deltaState(co,ip,el,ph,me) + broken = plastic_deltaState(co,ip,el,ph,me) if(broken) return broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index ef8c356e5..a8ebe9ea2 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -87,21 +87,21 @@ submodule(constitutive:constitutive_mech) plastic end subroutine nonlocal_LpAndItsTangent - module subroutine plastic_isotropic_dotState(Mp,instance,me) + module subroutine isotropic_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & me - end subroutine plastic_isotropic_dotState + end subroutine isotropic_dotState - module subroutine plastic_phenopowerlaw_dotState(Mp,instance,me) + module subroutine phenopowerlaw_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & instance, & me - end subroutine plastic_phenopowerlaw_dotState + end subroutine phenopowerlaw_dotState module subroutine plastic_kinehardening_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & @@ -111,7 +111,7 @@ submodule(constitutive:constitutive_mech) plastic me end subroutine plastic_kinehardening_dotState - module subroutine plastic_dislotwin_dotState(Mp,T,instance,me) + module subroutine dislotwin_dotState(Mp,T,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress real(pReal), intent(in) :: & @@ -119,9 +119,9 @@ submodule(constitutive:constitutive_mech) plastic integer, intent(in) :: & instance, & me - end subroutine plastic_dislotwin_dotState + end subroutine dislotwin_dotState - module subroutine plastic_disloTungsten_dotState(Mp,T,instance,me) + module subroutine dislotungsten_dotState(Mp,T,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress real(pReal), intent(in) :: & @@ -129,9 +129,9 @@ submodule(constitutive:constitutive_mech) plastic integer, intent(in) :: & instance, & me - end subroutine plastic_disloTungsten_dotState + end subroutine dislotungsten_dotState - module subroutine plastic_nonlocal_dotState(Mp,Temperature,timestep,instance,me,ip,el) + module subroutine nonlocal_dotState(Mp,Temperature,timestep,instance,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress real(pReal), intent(in) :: & @@ -142,29 +142,29 @@ submodule(constitutive:constitutive_mech) plastic me, & ip, & !< current integration point el !< current element number - end subroutine plastic_nonlocal_dotState + end subroutine nonlocal_dotState - module subroutine plastic_dislotwin_dependentState(T,instance,me) + module subroutine dislotwin_dependentState(T,instance,me) integer, intent(in) :: & instance, & me real(pReal), intent(in) :: & T - end subroutine plastic_dislotwin_dependentState + end subroutine dislotwin_dependentState - module subroutine plastic_dislotungsten_dependentState(instance,me) + module subroutine dislotungsten_dependentState(instance,me) integer, intent(in) :: & instance, & me - end subroutine plastic_dislotungsten_dependentState + end subroutine dislotungsten_dependentState - module subroutine plastic_nonlocal_dependentState(instance, me, ip, el) + module subroutine nonlocal_dependentState(instance, me, ip, el) integer, intent(in) :: & instance, & me, & ip, & !< current integration point el !< current element number - end subroutine plastic_nonlocal_dependentState + end subroutine nonlocal_dependentState module subroutine plastic_kinehardening_deltaState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & @@ -259,7 +259,7 @@ end subroutine plastic_LpAndItsTangents !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the rate of change of microstructure !-------------------------------------------------------------------------------------------------- -module function mech_collectDotState(subdt,co,ip,el,ph,me) result(broken) +module function plastic_dotState(subdt,co,ip,el,ph,me) result(broken) integer, intent(in) :: & co, & !< component-ID of integration point @@ -284,33 +284,33 @@ module function mech_collectDotState(subdt,co,ip,el,ph,me) result(broken) plasticityType: select case (phase_plasticity(ph)) case (PLASTICITY_ISOTROPIC_ID) plasticityType - call plastic_isotropic_dotState(Mp,instance,me) + call isotropic_dotState(Mp,instance,me) case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType - call plastic_phenopowerlaw_dotState(Mp,instance,me) + call phenopowerlaw_dotState(Mp,instance,me) case (PLASTICITY_KINEHARDENING_ID) plasticityType call plastic_kinehardening_dotState(Mp,instance,me) case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_dotState(Mp,thermal_T(ph,me),instance,me) + call dislotwin_dotState(Mp,thermal_T(ph,me),instance,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_disloTungsten_dotState(Mp,thermal_T(ph,me),instance,me) + call dislotungsten_dotState(Mp,thermal_T(ph,me),instance,me) case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_dotState(Mp,thermal_T(ph,me),subdt,instance,me,ip,el) + call nonlocal_dotState(Mp,thermal_T(ph,me),subdt,instance,me,ip,el) end select plasticityType broken = any(IEEE_is_NaN(plasticState(ph)%dotState(:,me))) -end function mech_collectDotState +end function plastic_dotState !-------------------------------------------------------------------------------------------------- !> @brief calls microstructure function of the different plasticity constitutive models !-------------------------------------------------------------------------------------------------- -module subroutine constitutive_plastic_dependentState(co, ip, el) +module subroutine plastic_dependentState(co, ip, el) integer, intent(in) :: & co, & !< component-ID of integration point @@ -329,24 +329,24 @@ module subroutine constitutive_plastic_dependentState(co, ip, el) plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) case (PLASTICITY_DISLOTWIN_ID) plasticityType - call plastic_dislotwin_dependentState(thermal_T(ph,me),instance,me) + call dislotwin_dependentState(thermal_T(ph,me),instance,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call plastic_dislotungsten_dependentState(instance,me) + call dislotungsten_dependentState(instance,me) case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_dependentState(instance,me,ip,el) + call nonlocal_dependentState(instance,me,ip,el) end select plasticityType -end subroutine constitutive_plastic_dependentState +end subroutine plastic_dependentState !-------------------------------------------------------------------------------------------------- !> @brief for constitutive models having an instantaneous change of state !> will return false if delta state is not needed/supported by the constitutive model !-------------------------------------------------------------------------------------------------- -module function constitutive_deltaState(co, ip, el, ph, of) result(broken) +module function plastic_deltaState(co, ip, el, ph, of) result(broken) integer, intent(in) :: & co, & !< component-ID of integration point @@ -395,6 +395,6 @@ module function constitutive_deltaState(co, ip, el, ph, of) result(broken) end select endif -end function constitutive_deltaState +end function plastic_deltaState end submodule plastic diff --git a/src/phase_mechanics_plastic_dislotungsten.f90 b/src/phase_mechanics_plastic_dislotungsten.f90 index c85a86b65..33379aae2 100644 --- a/src/phase_mechanics_plastic_dislotungsten.f90 +++ b/src/phase_mechanics_plastic_dislotungsten.f90 @@ -315,7 +315,7 @@ end subroutine dislotungsten_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotungsten_dotState(Mp,T,instance,me) +module subroutine dislotungsten_dotState(Mp,T,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress @@ -369,13 +369,13 @@ module subroutine plastic_dislotungsten_dotState(Mp,T,instance,me) end associate -end subroutine plastic_dislotungsten_dotState +end subroutine dislotungsten_dotState !-------------------------------------------------------------------------------------------------- !> @brief Calculate derived quantities from state. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotungsten_dependentState(instance,me) +module subroutine dislotungsten_dependentState(instance,me) integer, intent(in) :: & instance, & @@ -394,7 +394,7 @@ module subroutine plastic_dislotungsten_dependentState(instance,me) end associate -end subroutine plastic_dislotungsten_dependentState +end subroutine dislotungsten_dependentState !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic_dislotwin.f90 b/src/phase_mechanics_plastic_dislotwin.f90 index 55827ae51..db15e73b0 100644 --- a/src/phase_mechanics_plastic_dislotwin.f90 +++ b/src/phase_mechanics_plastic_dislotwin.f90 @@ -634,7 +634,7 @@ end subroutine dislotwin_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotwin_dotState(Mp,T,instance,me) +module subroutine dislotwin_dotState(Mp,T,instance,me) real(pReal), dimension(3,3), intent(in):: & Mp !< Mandel stress @@ -729,13 +729,13 @@ module subroutine plastic_dislotwin_dotState(Mp,T,instance,me) end associate -end subroutine plastic_dislotwin_dotState +end subroutine dislotwin_dotState !-------------------------------------------------------------------------------------------------- !> @brief Calculate derived quantities from state. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotwin_dependentState(T,instance,me) +module subroutine dislotwin_dependentState(T,instance,me) integer, intent(in) :: & instance, & @@ -821,7 +821,7 @@ module subroutine plastic_dislotwin_dependentState(T,instance,me) end associate -end subroutine plastic_dislotwin_dependentState +end subroutine dislotwin_dependentState !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic_isotropic.f90 b/src/phase_mechanics_plastic_isotropic.f90 index 7508f172c..b79c14607 100644 --- a/src/phase_mechanics_plastic_isotropic.f90 +++ b/src/phase_mechanics_plastic_isotropic.f90 @@ -262,7 +262,7 @@ module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_isotropic_dotState(Mp,instance,me) +module subroutine isotropic_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress @@ -305,7 +305,7 @@ module subroutine plastic_isotropic_dotState(Mp,instance,me) end associate -end subroutine plastic_isotropic_dotState +end subroutine isotropic_dotState !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 index 4d952dfd4..4b44ee019 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanics_plastic_nonlocal.f90 @@ -552,7 +552,7 @@ end function plastic_nonlocal_init !-------------------------------------------------------------------------------------------------- !> @brief calculates quantities characterizing the microstructure !-------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_dependentState(instance, me, ip, el) +module subroutine nonlocal_dependentState(instance, me, ip, el) integer, intent(in) :: & instance, & @@ -751,7 +751,7 @@ module subroutine plastic_nonlocal_dependentState(instance, me, ip, el) end associate -end subroutine plastic_nonlocal_dependentState +end subroutine nonlocal_dependentState !-------------------------------------------------------------------------------------------------- @@ -972,7 +972,7 @@ end subroutine plastic_nonlocal_deltaState !--------------------------------------------------------------------------------------------------- !> @brief calculates the rate of change of microstructure !--------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & +module subroutine nonlocal_dotState(Mp, Temperature,timestep, & instance,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & @@ -1166,7 +1166,7 @@ module subroutine plastic_nonlocal_dotState(Mp, Temperature,timestep, & end associate -end subroutine plastic_nonlocal_dotState +end subroutine nonlocal_dotState !--------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics_plastic_phenopowerlaw.f90 b/src/phase_mechanics_plastic_phenopowerlaw.f90 index 05cdf48ef..a0318d266 100644 --- a/src/phase_mechanics_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanics_plastic_phenopowerlaw.f90 @@ -336,7 +336,7 @@ end subroutine phenopowerlaw_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_phenopowerlaw_dotState(Mp,instance,me) +module subroutine phenopowerlaw_dotState(Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress @@ -386,7 +386,7 @@ module subroutine plastic_phenopowerlaw_dotState(Mp,instance,me) + c_TwinTwin * matmul(prm%h_tw_tw,dot%gamma_twin(:,me)) end associate -end subroutine plastic_phenopowerlaw_dotState +end subroutine phenopowerlaw_dotState !-------------------------------------------------------------------------------------------------- From 79ec2c5a9d68b07b00029e4c7ee4a3488af85f59 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 20:36:28 +0100 Subject: [PATCH 175/352] better matching name --- src/commercialFEM_fileList.f90 | 6 +++--- ...=> phase_mechanics_eigendeformation_cleavageopening.f90} | 0 ...> phase_mechanics_eigendeformation_slipplaneopening.f90} | 0 ...> phase_mechanics_eigendeformation_thermalexpansion.f90} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename src/{phase_mechanics_anelastic_cleavageopening.f90 => phase_mechanics_eigendeformation_cleavageopening.f90} (100%) rename src/{phase_mechanics_anelastic_slipplaneopening.f90 => phase_mechanics_eigendeformation_slipplaneopening.f90} (100%) rename src/{phase_mechanics_anelastic_thermalexpansion.f90 => phase_mechanics_eigendeformation_thermalexpansion.f90} (100%) diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 442eb48c1..3e11923ed 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -28,10 +28,10 @@ #include "phase_mechanics_plastic_dislotwin.f90" #include "phase_mechanics_plastic_dislotungsten.f90" #include "phase_mechanics_plastic_nonlocal.f90" -#include "phase_mechanics_anelastic_cleavageopening.f90" -#include "phase_mechanics_anelastic_slipplaneopening.f90" +#include "phase_mechanics_eigendeformation_cleavageopening.f90" +#include "phase_mechanics_eigendeformation_slipplaneopening.f90" #include "phase_thermal.f90" -#include "phase_mechanics_anelastic_thermalexpansion.f90" +#include "phase_mechanics_eigendeformation_thermalexpansion.f90" #include "phase_thermal_dissipation.f90" #include "phase_thermal_externalheat.f90" #include "phase_damage.f90" diff --git a/src/phase_mechanics_anelastic_cleavageopening.f90 b/src/phase_mechanics_eigendeformation_cleavageopening.f90 similarity index 100% rename from src/phase_mechanics_anelastic_cleavageopening.f90 rename to src/phase_mechanics_eigendeformation_cleavageopening.f90 diff --git a/src/phase_mechanics_anelastic_slipplaneopening.f90 b/src/phase_mechanics_eigendeformation_slipplaneopening.f90 similarity index 100% rename from src/phase_mechanics_anelastic_slipplaneopening.f90 rename to src/phase_mechanics_eigendeformation_slipplaneopening.f90 diff --git a/src/phase_mechanics_anelastic_thermalexpansion.f90 b/src/phase_mechanics_eigendeformation_thermalexpansion.f90 similarity index 100% rename from src/phase_mechanics_anelastic_thermalexpansion.f90 rename to src/phase_mechanics_eigendeformation_thermalexpansion.f90 From 2497a5fb4af9879a19dbc2b70d8f2a7a46b94e84 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 20:43:30 +0100 Subject: [PATCH 176/352] systematic naming --- src/commercialFEM_fileList.f90 | 2 ++ src/phase_mechanics.f90 | 4 ++-- src/phase_mechanics_eigendeformation.f90 | 2 ++ src/phase_mechanics_eigendeformation_cleavageopening.f90 | 4 ++-- src/phase_mechanics_eigendeformation_slipplaneopening.f90 | 4 ++-- src/phase_mechanics_plastic.f90 | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 src/phase_mechanics_eigendeformation.f90 diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 3e11923ed..311129d61 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -21,6 +21,7 @@ #include "lattice.f90" #include "phase.f90" #include "phase_mechanics.f90" +#include "phase_mechanics_plastic.f90" #include "phase_mechanics_plastic_none.f90" #include "phase_mechanics_plastic_isotropic.f90" #include "phase_mechanics_plastic_phenopowerlaw.f90" @@ -28,6 +29,7 @@ #include "phase_mechanics_plastic_dislotwin.f90" #include "phase_mechanics_plastic_dislotungsten.f90" #include "phase_mechanics_plastic_nonlocal.f90" +#include "phase_mechanics_eigendeformation.f90" #include "phase_mechanics_eigendeformation_cleavageopening.f90" #include "phase_mechanics_eigendeformation_slipplaneopening.f90" #include "phase_thermal.f90" diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index e37712e40..1d9248dd6 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -1,7 +1,7 @@ !---------------------------------------------------------------------------------------------------- !> @brief internal microstructure state for all plasticity constitutive models !---------------------------------------------------------------------------------------------------- -submodule(constitutive) constitutive_mech +submodule(constitutive) mechanics enum, bind(c); enumerator :: & ELASTICITY_UNDEFINED_ID, & @@ -1637,5 +1637,5 @@ subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & end subroutine constitutive_LiAndItsTangents -end submodule constitutive_mech +end submodule mechanics diff --git a/src/phase_mechanics_eigendeformation.f90 b/src/phase_mechanics_eigendeformation.f90 new file mode 100644 index 000000000..ddae8ec06 --- /dev/null +++ b/src/phase_mechanics_eigendeformation.f90 @@ -0,0 +1,2 @@ +submodule(constitutive:mechanics) eigendeformation +end submodule eigendeformation diff --git a/src/phase_mechanics_eigendeformation_cleavageopening.f90 b/src/phase_mechanics_eigendeformation_cleavageopening.f90 index 01fbf0cb9..b0ea2be87 100644 --- a/src/phase_mechanics_eigendeformation_cleavageopening.f90 +++ b/src/phase_mechanics_eigendeformation_cleavageopening.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating kinematics resulting from opening of cleavage planes !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_mech) kinematics_cleavage_opening +submodule(constitutive:eigendeformation) cleavageopening integer, dimension(:), allocatable :: kinematics_cleavage_opening_instance @@ -162,4 +162,4 @@ module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, end subroutine kinematics_cleavage_opening_LiAndItsTangent -end submodule kinematics_cleavage_opening +end submodule cleavageopening diff --git a/src/phase_mechanics_eigendeformation_slipplaneopening.f90 b/src/phase_mechanics_eigendeformation_slipplaneopening.f90 index c15608dea..1cab5e731 100644 --- a/src/phase_mechanics_eigendeformation_slipplaneopening.f90 +++ b/src/phase_mechanics_eigendeformation_slipplaneopening.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating kinematics resulting from opening of slip planes !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_mech) kinematics_slipplane_opening +submodule(constitutive:eigendeformation) slipplaneopening integer, dimension(:), allocatable :: kinematics_slipplane_opening_instance @@ -193,4 +193,4 @@ module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S end subroutine kinematics_slipplane_opening_LiAndItsTangent -end submodule kinematics_slipplane_opening +end submodule slipplaneopening diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index a8ebe9ea2..271c73391 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -1,4 +1,4 @@ -submodule(constitutive:constitutive_mech) plastic +submodule(constitutive:mechanics) plastic interface From 74a7be160718e74d4c1e95be4e46f5d20722f40e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 20:52:48 +0100 Subject: [PATCH 177/352] [skip sc] more systematic naming module name 'damagee' gets extra e for the moment to avoid conflict with global variable 'damage' --- src/CPFEM.f90 | 2 +- src/CPFEM2.f90 | 2 +- src/commercialFEM_fileList.f90 | 8 +++---- src/damage_nonlocal.f90 | 2 +- src/homogenization.f90 | 2 +- src/phase.f90 | 24 +++++++++++++++---- src/phase_damage.f90 | 4 ++-- src/phase_damage_anisobrittle.f90 | 4 ++-- src/phase_damage_anisoductile.f90 | 4 ++-- src/phase_damage_isobrittle.f90 | 4 ++-- src/phase_damage_isoductile.f90 | 4 ++-- src/phase_mechanics.f90 | 4 ++-- src/phase_mechanics_eigendeformation.f90 | 2 +- ...anics_eigendeformation_cleavageopening.f90 | 2 +- ...nics_eigendeformation_slipplaneopening.f90 | 2 +- ...nics_eigendeformation_thermalexpansion.f90 | 12 +++++----- src/phase_mechanics_plastic.f90 | 2 +- src/phase_mechanics_plastic_dislotungsten.f90 | 2 +- src/phase_mechanics_plastic_dislotwin.f90 | 2 +- src/phase_mechanics_plastic_isotropic.f90 | 2 +- src/phase_mechanics_plastic_kinehardening.f90 | 2 +- src/phase_mechanics_plastic_none.f90 | 2 +- src/phase_mechanics_plastic_nonlocal.f90 | 2 +- src/phase_mechanics_plastic_phenopowerlaw.f90 | 2 +- src/phase_thermal.f90 | 2 +- src/phase_thermal_dissipation.f90 | 2 +- src/phase_thermal_externalheat.f90 | 2 +- 27 files changed, 59 insertions(+), 45 deletions(-) diff --git a/src/CPFEM.f90 b/src/CPFEM.f90 index 713aab5d7..8a12bef76 100644 --- a/src/CPFEM.f90 +++ b/src/CPFEM.f90 @@ -19,7 +19,7 @@ module CPFEM use HDF5_utilities use results use lattice - use constitutive + use phase implicit none private diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index e696858cf..2b32a0cbb 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -19,7 +19,7 @@ module CPFEM2 use discretization use HDF5_utilities use homogenization - use constitutive + use phase #if defined(Mesh) use FEM_quadrature use discretization_mesh diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 311129d61..d145d3965 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -32,15 +32,15 @@ #include "phase_mechanics_eigendeformation.f90" #include "phase_mechanics_eigendeformation_cleavageopening.f90" #include "phase_mechanics_eigendeformation_slipplaneopening.f90" -#include "phase_thermal.f90" -#include "phase_mechanics_eigendeformation_thermalexpansion.f90" -#include "phase_thermal_dissipation.f90" -#include "phase_thermal_externalheat.f90" #include "phase_damage.f90" #include "phase_damage_isobrittle.f90" #include "phase_damage_isoductile.f90" #include "phase_damage_anisobrittle.f90" #include "phase_damage_anisoductile.f90" +#include "phase_thermal.f90" +#include "phase_mechanics_eigendeformation_thermalexpansion.f90" +#include "phase_thermal_dissipation.f90" +#include "phase_thermal_externalheat.f90" #include "damage_none.f90" #include "damage_nonlocal.f90" #include "homogenization.f90" diff --git a/src/damage_nonlocal.f90 b/src/damage_nonlocal.f90 index f566ebbeb..807231889 100644 --- a/src/damage_nonlocal.f90 +++ b/src/damage_nonlocal.f90 @@ -8,7 +8,7 @@ module damage_nonlocal use config use YAML_types use lattice - use constitutive + use phase use results implicit none diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 9b8c33c2e..4738b3ad8 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -10,7 +10,7 @@ module homogenization use config use math use material - use constitutive + use phase use discretization use damage_none use damage_nonlocal diff --git a/src/phase.f90 b/src/phase.f90 index 65fb7a859..849c5d8c6 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -3,7 +3,7 @@ !> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH !> @brief elasticity, plasticity, damage & thermal internal microstructure state !-------------------------------------------------------------------------------------------------- -module constitutive +module phase use prec use math use rotations @@ -16,7 +16,6 @@ module constitutive use parallelization use HDF5_utilities use results - implicit none private @@ -304,14 +303,14 @@ module constitutive dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) end subroutine kinematics_slipplane_opening_LiAndItsTangent - module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) + module subroutine thermalexpansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) integer, intent(in) :: ph, me !< element number real(pReal), intent(out), dimension(3,3) :: & Li !< thermal velocity gradient real(pReal), intent(out), dimension(3,3,3,3) :: & dLi_dTstar !< derivative of Li with respect to Tstar (4th-order tensor defined to be zero) - end subroutine kinematics_thermal_expansion_LiAndItsTangent + end subroutine thermalexpansion_LiAndItsTangent module subroutine plastic_dependentState(co,ip,el) integer, intent(in) :: & @@ -325,6 +324,21 @@ module constitutive type(tDebugOptions) :: debugConstitutive +#if __INTEL_COMPILER >= 1900 + public :: & + prec, & + math, & + rotations, & + IO, & + config, & + material, & + results, & + lattice, & + discretization, & + parallelization, & + HDF5_utilities, & + results +#endif public :: & constitutive_init, & @@ -788,4 +802,4 @@ subroutine constitutive_restartRead(fileHandle) end subroutine constitutive_restartRead -end module constitutive +end module phase diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 72be51be1..6c1a0b8d0 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -1,7 +1,7 @@ !---------------------------------------------------------------------------------------------------- !> @brief internal microstructure state for all damage sources and kinematics constitutive models !---------------------------------------------------------------------------------------------------- -submodule(constitutive) constitutive_damage +submodule(phase) damagee enum, bind(c); enumerator :: & DAMAGE_UNDEFINED_ID, & DAMAGE_ISOBRITTLE_ID, & @@ -525,4 +525,4 @@ module function constitutive_damage_get_phi(co,ip,el) result(phi) end function constitutive_damage_get_phi -end submodule constitutive_damage +end submodule damagee diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 095046c1c..f78a0ec99 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating anisotropic brittle damage source mechanism !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule (constitutive:constitutive_damage) source_damage_anisoBrittle +submodule (phase:damagee) anisobrittle integer, dimension(:), allocatable :: & source_damage_anisoBrittle_offset, & !< which source is my current source mechanism? @@ -215,4 +215,4 @@ module subroutine anisobrittle_results(phase,group) end subroutine anisobrittle_results -end submodule source_damage_anisoBrittle +end submodule anisobrittle diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index ea2b38645..f5e8d3795 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating anisotropic ductile damage source mechanism !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_damage) source_damage_anisoDuctile +submodule(phase:damagee) anisoductile integer, dimension(:), allocatable :: & source_damage_anisoDuctile_offset, & !< which source is my current damage mechanism? @@ -184,4 +184,4 @@ module subroutine anisoductile_results(phase,group) end subroutine anisoductile_results -end submodule source_damage_anisoDuctile +end submodule anisoductile diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 0f192e2ae..5a01a425d 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incoprorating isotropic brittle damage source mechanism !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:constitutive_damage) source_damage_isoBrittle +submodule(phase:damagee) isobrittle integer, dimension(:), allocatable :: & source_damage_isoBrittle_offset, & @@ -180,4 +180,4 @@ module subroutine isobrittle_results(phase,group) end subroutine isobrittle_results -end submodule source_damage_isoBrittle +end submodule isobrittle diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index 458b82e16..fe5ca93ed 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating isotropic ductile damage source mechanism !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule (constitutive:constitutive_damage) source_damage_isoDuctile +submodule(phase:damagee) isoductile integer, dimension(:), allocatable :: & source_damage_isoDuctile_offset, & !< which source is my current damage mechanism? @@ -175,4 +175,4 @@ module subroutine isoductile_results(phase,group) end subroutine isoductile_results -end submodule source_damage_isoDuctile +end submodule isoductile diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index 1d9248dd6..3bca63886 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -1,7 +1,7 @@ !---------------------------------------------------------------------------------------------------- !> @brief internal microstructure state for all plasticity constitutive models !---------------------------------------------------------------------------------------------------- -submodule(constitutive) mechanics +submodule(phase) mechanics enum, bind(c); enumerator :: & ELASTICITY_UNDEFINED_ID, & @@ -1615,7 +1615,7 @@ subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & case (KINEMATICS_thermal_expansion_ID) kinematicsType me = material_phaseMemberAt(co,ip,el) ph = material_phaseAt(co,el) - call kinematics_thermal_expansion_LiAndItsTangent(my_Li, my_dLi_dS, ph,me) + call thermalexpansion_LiAndItsTangent(my_Li, my_dLi_dS, ph,me) case default kinematicsType my_Li = 0.0_pReal my_dLi_dS = 0.0_pReal diff --git a/src/phase_mechanics_eigendeformation.f90 b/src/phase_mechanics_eigendeformation.f90 index ddae8ec06..9a86945dd 100644 --- a/src/phase_mechanics_eigendeformation.f90 +++ b/src/phase_mechanics_eigendeformation.f90 @@ -1,2 +1,2 @@ -submodule(constitutive:mechanics) eigendeformation +submodule(phase:mechanics) eigendeformation end submodule eigendeformation diff --git a/src/phase_mechanics_eigendeformation_cleavageopening.f90 b/src/phase_mechanics_eigendeformation_cleavageopening.f90 index b0ea2be87..185aee520 100644 --- a/src/phase_mechanics_eigendeformation_cleavageopening.f90 +++ b/src/phase_mechanics_eigendeformation_cleavageopening.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating kinematics resulting from opening of cleavage planes !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:eigendeformation) cleavageopening +submodule(phase:eigendeformation) cleavageopening integer, dimension(:), allocatable :: kinematics_cleavage_opening_instance diff --git a/src/phase_mechanics_eigendeformation_slipplaneopening.f90 b/src/phase_mechanics_eigendeformation_slipplaneopening.f90 index 1cab5e731..8b8b1dd29 100644 --- a/src/phase_mechanics_eigendeformation_slipplaneopening.f90 +++ b/src/phase_mechanics_eigendeformation_slipplaneopening.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating kinematics resulting from opening of slip planes !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:eigendeformation) slipplaneopening +submodule(phase:eigendeformation) slipplaneopening integer, dimension(:), allocatable :: kinematics_slipplane_opening_instance diff --git a/src/phase_mechanics_eigendeformation_thermalexpansion.f90 b/src/phase_mechanics_eigendeformation_thermalexpansion.f90 index 32bf30e75..5380330f2 100644 --- a/src/phase_mechanics_eigendeformation_thermalexpansion.f90 +++ b/src/phase_mechanics_eigendeformation_thermalexpansion.f90 @@ -3,7 +3,10 @@ !> @brief material subroutine incorporating kinematics resulting from thermal expansion !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:thermal) thermalexpansion +submodule(phase:thermal) thermalexpansion + use prec + use YAML_types + use config integer, dimension(:), allocatable :: kinematics_thermal_expansion_instance @@ -84,7 +87,7 @@ end function kinematics_thermal_expansion_init !-------------------------------------------------------------------------------------------------- !> @brief constitutive equation for calculating the velocity gradient !-------------------------------------------------------------------------------------------------- -module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) +module subroutine thermalexpansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) integer, intent(in) :: ph, me real(pReal), intent(out), dimension(3,3) :: & @@ -92,9 +95,6 @@ module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, p real(pReal), intent(out), dimension(3,3,3,3) :: & dLi_dTstar !< derivative of Li with respect to Tstar (4th-order tensor defined to be zero) - integer :: & - phase, & - homog real(pReal) :: T, dot_T T = current(ph)%T(me) @@ -114,6 +114,6 @@ module subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, p end associate dLi_dTstar = 0.0_pReal -end subroutine kinematics_thermal_expansion_LiAndItsTangent +end subroutine thermalexpansion_LiAndItsTangent end submodule thermalexpansion diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index 271c73391..035b03171 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -1,4 +1,4 @@ -submodule(constitutive:mechanics) plastic +submodule(phase:mechanics) plastic interface diff --git a/src/phase_mechanics_plastic_dislotungsten.f90 b/src/phase_mechanics_plastic_dislotungsten.f90 index 33379aae2..c57669edb 100644 --- a/src/phase_mechanics_plastic_dislotungsten.f90 +++ b/src/phase_mechanics_plastic_dislotungsten.f90 @@ -5,7 +5,7 @@ !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH !> @brief crystal plasticity model for bcc metals, especially Tungsten !-------------------------------------------------------------------------------------------------- -submodule(constitutive:plastic) dislotungsten +submodule(phase:plastic) dislotungsten real(pReal), parameter :: & kB = 1.38e-23_pReal !< Boltzmann constant in J/Kelvin diff --git a/src/phase_mechanics_plastic_dislotwin.f90 b/src/phase_mechanics_plastic_dislotwin.f90 index db15e73b0..4889b7698 100644 --- a/src/phase_mechanics_plastic_dislotwin.f90 +++ b/src/phase_mechanics_plastic_dislotwin.f90 @@ -7,7 +7,7 @@ !> @brief material subroutine incoprorating dislocation and twinning physics !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:plastic) dislotwin +submodule(phase:plastic) dislotwin real(pReal), parameter :: & kB = 1.38e-23_pReal !< Boltzmann constant in J/Kelvin diff --git a/src/phase_mechanics_plastic_isotropic.f90 b/src/phase_mechanics_plastic_isotropic.f90 index b79c14607..080a56cfd 100644 --- a/src/phase_mechanics_plastic_isotropic.f90 +++ b/src/phase_mechanics_plastic_isotropic.f90 @@ -7,7 +7,7 @@ !! resolving the stress on the slip systems. Will give the response of phenopowerlaw for an !! untextured polycrystal !-------------------------------------------------------------------------------------------------- -submodule(constitutive:plastic) isotropic +submodule(phase:plastic) isotropic type :: tParameters real(pReal) :: & diff --git a/src/phase_mechanics_plastic_kinehardening.f90 b/src/phase_mechanics_plastic_kinehardening.f90 index ce6ea1935..de80a646d 100644 --- a/src/phase_mechanics_plastic_kinehardening.f90 +++ b/src/phase_mechanics_plastic_kinehardening.f90 @@ -5,7 +5,7 @@ !> @brief Phenomenological crystal plasticity using a power law formulation for the shear rates !! and a Voce-type kinematic hardening rule !-------------------------------------------------------------------------------------------------- -submodule(constitutive:plastic) kinehardening +submodule(phase:plastic) kinehardening type :: tParameters real(pReal) :: & diff --git a/src/phase_mechanics_plastic_none.f90 b/src/phase_mechanics_plastic_none.f90 index b09b4fc39..5c79c1b1e 100644 --- a/src/phase_mechanics_plastic_none.f90 +++ b/src/phase_mechanics_plastic_none.f90 @@ -4,7 +4,7 @@ !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH !> @brief Dummy plasticity for purely elastic material !-------------------------------------------------------------------------------------------------- -submodule(constitutive:plastic) none +submodule(phase:plastic) none contains diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 index 4b44ee019..884bc6bc0 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanics_plastic_nonlocal.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH !> @brief material subroutine for plasticity including dislocation flux !-------------------------------------------------------------------------------------------------- -submodule(constitutive:plastic) nonlocal +submodule(phase:plastic) nonlocal use geometry_plastic_nonlocal, only: & nIPneighbors => geometry_plastic_nonlocal_nIPneighbors, & IPneighborhood => geometry_plastic_nonlocal_IPneighborhood, & diff --git a/src/phase_mechanics_plastic_phenopowerlaw.f90 b/src/phase_mechanics_plastic_phenopowerlaw.f90 index a0318d266..a9538aeec 100644 --- a/src/phase_mechanics_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanics_plastic_phenopowerlaw.f90 @@ -4,7 +4,7 @@ !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH !> @brief phenomenological crystal plasticity formulation using a powerlaw fitting !-------------------------------------------------------------------------------------------------- -submodule(constitutive:plastic) phenopowerlaw +submodule(phase:plastic) phenopowerlaw type :: tParameters real(pReal) :: & diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index c0a999bde..5a7c7bc62 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -1,7 +1,7 @@ !---------------------------------------------------------------------------------------------------- !> @brief internal microstructure state for all thermal sources and kinematics constitutive models !---------------------------------------------------------------------------------------------------- -submodule(constitutive) thermal +submodule(phase) thermal enum, bind(c); enumerator :: & THERMAL_UNDEFINED_ID ,& diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index 3b4ddcfd1..ab2a13c64 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine for thermal source due to plastic dissipation !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(constitutive:thermal) dissipation +submodule(phase:thermal) dissipation integer, dimension(:), allocatable :: & source_thermal_dissipation_offset, & !< which source is my current thermal dissipation mechanism? diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index 054b91e01..5707efb11 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Michigan State University !> @brief material subroutine for variable heat source !-------------------------------------------------------------------------------------------------- -submodule(constitutive:thermal) externalheat +submodule(phase:thermal) externalheat integer, dimension(:), allocatable :: & From 9cb057b1c0f47e9dea4311bb96745f82d08a1407 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 26 Jan 2021 21:54:59 +0100 Subject: [PATCH 178/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-370-ga0a700914 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 62377fd35..2500cc420 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-355-gbd9bb5c7c +v3.0.0-alpha2-370-ga0a700914 From 6130d8740d76ff1673c214545cf5bf40d0fcb3f6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 22:29:55 +0100 Subject: [PATCH 179/352] [skip sc] small polishing to make ifort happy old ifort on magit1 still has issues --- src/phase.f90 | 9 ++------- src/phase_mechanics.f90 | 1 - ...phase_mechanics_eigendeformation_thermalexpansion.f90 | 4 ---- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index 849c5d8c6..8b2532b79 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -15,7 +15,6 @@ module phase use discretization use parallelization use HDF5_utilities - use results implicit none private @@ -335,9 +334,7 @@ module phase results, & lattice, & discretization, & - parallelization, & - HDF5_utilities, & - results + HDF5_utilities #endif public :: & @@ -576,9 +573,7 @@ subroutine crystallite_init() class(tNode), pointer :: & num_crystallite, & debug_crystallite, & ! pointer to debug options for crystallite - phases, & - phase, & - mech + phases print'(/,a)', ' <<<+- crystallite init -+>>>' diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index 3bca63886..91d455279 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -1027,7 +1027,6 @@ subroutine crystallite_results(group,ph) integer, intent(in) :: ph integer :: ou - real(pReal), allocatable, dimension(:,:,:) :: selected_tensors real(pReal), allocatable, dimension(:,:) :: selected_rotations character(len=:), allocatable :: structureLabel diff --git a/src/phase_mechanics_eigendeformation_thermalexpansion.f90 b/src/phase_mechanics_eigendeformation_thermalexpansion.f90 index 5380330f2..b9483977a 100644 --- a/src/phase_mechanics_eigendeformation_thermalexpansion.f90 +++ b/src/phase_mechanics_eigendeformation_thermalexpansion.f90 @@ -4,9 +4,6 @@ !> @details to be done !-------------------------------------------------------------------------------------------------- submodule(phase:thermal) thermalexpansion - use prec - use YAML_types - use config integer, dimension(:), allocatable :: kinematics_thermal_expansion_instance @@ -19,7 +16,6 @@ submodule(phase:thermal) thermalexpansion type(tParameters), dimension(:), allocatable :: param - contains From 9292bc91ea56790b8377308f2f0aa4b2e057deaf Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 22:41:41 +0100 Subject: [PATCH 180/352] [skip sc] default access for phase: (ph,me) --- src/commercialFEM_fileList.f90 | 8 +- src/phase_mechanics_plastic.f90 | 81 +++++++++---------- src/phase_mechanics_plastic_dislotungsten.f90 | 21 ++--- src/phase_mechanics_plastic_dislotwin.f90 | 38 ++++----- src/phase_mechanics_plastic_isotropic.f90 | 13 +-- src/phase_mechanics_plastic_kinehardening.f90 | 21 ++--- src/phase_mechanics_plastic_nonlocal.f90 | 54 ++++++------- src/phase_mechanics_plastic_phenopowerlaw.f90 | 27 ++++--- 8 files changed, 131 insertions(+), 132 deletions(-) diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index d145d3965..621a091d8 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -32,15 +32,15 @@ #include "phase_mechanics_eigendeformation.f90" #include "phase_mechanics_eigendeformation_cleavageopening.f90" #include "phase_mechanics_eigendeformation_slipplaneopening.f90" +#include "phase_thermal.f90" +#include "phase_thermal_dissipation.f90" +#include "phase_thermal_externalheat.f90" +#include "phase_mechanics_eigendeformation_thermalexpansion.f90" #include "phase_damage.f90" #include "phase_damage_isobrittle.f90" #include "phase_damage_isoductile.f90" #include "phase_damage_anisobrittle.f90" #include "phase_damage_anisoductile.f90" -#include "phase_thermal.f90" -#include "phase_mechanics_eigendeformation_thermalexpansion.f90" -#include "phase_thermal_dissipation.f90" -#include "phase_thermal_externalheat.f90" #include "damage_none.f90" #include "damage_nonlocal.f90" #include "homogenization.f90" diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index 035b03171..f6c010485 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -2,7 +2,7 @@ submodule(phase:mechanics) plastic interface - module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -10,11 +10,11 @@ submodule(phase:mechanics) plastic real(pReal), dimension(3,3), intent(in) :: & Mp integer, intent(in) :: & - instance, & + ph, & me end subroutine isotropic_LpAndItsTangent - pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -22,11 +22,11 @@ submodule(phase:mechanics) plastic real(pReal), dimension(3,3), intent(in) :: & Mp integer, intent(in) :: & - instance, & + ph, & me end subroutine phenopowerlaw_LpAndItsTangent - pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -34,11 +34,11 @@ submodule(phase:mechanics) plastic real(pReal), dimension(3,3), intent(in) :: & Mp integer, intent(in) :: & - instance, & + ph, & me end subroutine kinehardening_LpAndItsTangent - module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) + module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -49,11 +49,11 @@ submodule(phase:mechanics) plastic real(pReal), intent(in) :: & T integer, intent(in) :: & - instance, & + ph, & me end subroutine dislotwin_LpAndItsTangent - pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) + pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -64,12 +64,12 @@ submodule(phase:mechanics) plastic real(pReal), intent(in) :: & T integer, intent(in) :: & - instance, & + ph, & me end subroutine dislotungsten_LpAndItsTangent module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & - Mp,Temperature,instance,me,ip,el) + Mp,Temperature,ph,me,ip,el) real(pReal), dimension(3,3), intent(out) :: & Lp real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -80,71 +80,71 @@ submodule(phase:mechanics) plastic real(pReal), intent(in) :: & Temperature integer, intent(in) :: & - instance, & + ph, & me, & ip, & !< current integration point el !< current element number end subroutine nonlocal_LpAndItsTangent - module subroutine isotropic_dotState(Mp,instance,me) + module subroutine isotropic_dotState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me end subroutine isotropic_dotState - module subroutine phenopowerlaw_dotState(Mp,instance,me) + module subroutine phenopowerlaw_dotState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me end subroutine phenopowerlaw_dotState - module subroutine plastic_kinehardening_dotState(Mp,instance,me) + module subroutine plastic_kinehardening_dotState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me end subroutine plastic_kinehardening_dotState - module subroutine dislotwin_dotState(Mp,T,instance,me) + module subroutine dislotwin_dotState(Mp,T,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress real(pReal), intent(in) :: & T integer, intent(in) :: & - instance, & + ph, & me end subroutine dislotwin_dotState - module subroutine dislotungsten_dotState(Mp,T,instance,me) + module subroutine dislotungsten_dotState(Mp,T,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress real(pReal), intent(in) :: & T integer, intent(in) :: & - instance, & + ph, & me end subroutine dislotungsten_dotState - module subroutine nonlocal_dotState(Mp,Temperature,timestep,instance,me,ip,el) + module subroutine nonlocal_dotState(Mp,Temperature,timestep,ph,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress real(pReal), intent(in) :: & Temperature, & !< temperature timestep !< substepped crystallite time increment integer, intent(in) :: & - instance, & + ph, & me, & ip, & !< current integration point el !< current element number end subroutine nonlocal_dotState - module subroutine dislotwin_dependentState(T,instance,me) + module subroutine dislotwin_dependentState(T,instance,me) integer, intent(in) :: & instance, & me @@ -213,13 +213,12 @@ module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & real(pReal), dimension(3,3) :: & Mp !< Mandel stress work conjugate with Lp integer :: & - i, j, instance, me, ph + i, j, me, ph Mp = matmul(matmul(transpose(Fi),Fi),S) me = material_phasememberAt(co,ip,el) ph = material_phaseAt(co,el) - instance = phase_plasticityInstance(ph) plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) @@ -228,22 +227,22 @@ module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & dLp_dMp = 0.0_pReal case (PLASTICITY_ISOTROPIC_ID) plasticityType - call isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + call isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType - call phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + call phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) case (PLASTICITY_KINEHARDENING_ID) plasticityType - call kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + call kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) case (PLASTICITY_NONLOCAL_ID) plasticityType - call nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me,ip,el) + call nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),ph,me,ip,el) case (PLASTICITY_DISLOTWIN_ID) plasticityType - call dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) + call dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),ph,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),instance,me) + call dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),ph,me) end select plasticityType @@ -271,35 +270,31 @@ module function plastic_dotState(subdt,co,ip,el,ph,me) result(broken) subdt !< timestep real(pReal), dimension(3,3) :: & Mp - integer :: & - instance logical :: broken - instance = phase_plasticityInstance(ph) - Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,me)),& constitutive_mech_Fi(ph)%data(1:3,1:3,me)),constitutive_mech_S(ph)%data(1:3,1:3,me)) plasticityType: select case (phase_plasticity(ph)) case (PLASTICITY_ISOTROPIC_ID) plasticityType - call isotropic_dotState(Mp,instance,me) + call isotropic_dotState(Mp,ph,me) case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType - call phenopowerlaw_dotState(Mp,instance,me) + call phenopowerlaw_dotState(Mp,ph,me) case (PLASTICITY_KINEHARDENING_ID) plasticityType - call plastic_kinehardening_dotState(Mp,instance,me) + call plastic_kinehardening_dotState(Mp,ph,me) case (PLASTICITY_DISLOTWIN_ID) plasticityType - call dislotwin_dotState(Mp,thermal_T(ph,me),instance,me) + call dislotwin_dotState(Mp,thermal_T(ph,me),ph,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType - call dislotungsten_dotState(Mp,thermal_T(ph,me),instance,me) + call dislotungsten_dotState(Mp,thermal_T(ph,me),ph,me) case (PLASTICITY_NONLOCAL_ID) plasticityType - call nonlocal_dotState(Mp,thermal_T(ph,me),subdt,instance,me,ip,el) + call nonlocal_dotState(Mp,thermal_T(ph,me),subdt,ph,me,ip,el) end select plasticityType broken = any(IEEE_is_NaN(plasticState(ph)%dotState(:,me))) diff --git a/src/phase_mechanics_plastic_dislotungsten.f90 b/src/phase_mechanics_plastic_dislotungsten.f90 index c57669edb..ee0dfa9da 100644 --- a/src/phase_mechanics_plastic_dislotungsten.f90 +++ b/src/phase_mechanics_plastic_dislotungsten.f90 @@ -273,7 +273,7 @@ end function plastic_dislotungsten_init !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & - Mp,T,instance,me) + Mp,T,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -284,21 +284,21 @@ pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & real(pReal), intent(in) :: & T !< temperature integer, intent(in) :: & - instance, & + ph, & me integer :: & i,k,l,m,n - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & dot_gamma_pos,dot_gamma_neg, & ddot_gamma_dtau_pos,ddot_gamma_dtau_neg Lp = 0.0_pReal dLp_dMp = 0.0_pReal - associate(prm => param(instance)) + associate(prm => param(phase_plasticityInstance(ph))) - call kinetics(Mp,T,instance,me,dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg) + call kinetics(Mp,T,phase_plasticityInstance(ph),me,dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg) do i = 1, prm%sum_N_sl Lp = Lp + (dot_gamma_pos(i)+dot_gamma_neg(i))*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -315,19 +315,19 @@ end subroutine dislotungsten_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine dislotungsten_dotState(Mp,T,instance,me) +module subroutine dislotungsten_dotState(Mp,T,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress real(pReal), intent(in) :: & T !< temperature integer, intent(in) :: & - instance, & + ph, & me real(pReal) :: & VacancyDiffusion - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & gdot_pos, gdot_neg,& tau_pos,& tau_neg, & @@ -336,9 +336,10 @@ module subroutine dislotungsten_dotState(Mp,T,instance,me) dot_rho_dip_climb, & dip_distance - associate(prm => param(instance), stt => state(instance),dot => dotState(instance), dst => dependentState(instance)) + associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)),& + dot => dotState(phase_plasticityInstance(ph)), dst => dependentState(phase_plasticityInstance(ph))) - call kinetics(Mp,T,instance,me,& + call kinetics(Mp,T,phase_plasticityInstance(ph),me,& gdot_pos,gdot_neg, & tau_pos_out = tau_pos,tau_neg_out = tau_neg) diff --git a/src/phase_mechanics_plastic_dislotwin.f90 b/src/phase_mechanics_plastic_dislotwin.f90 index 4889b7698..1ad1957ec 100644 --- a/src/phase_mechanics_plastic_dislotwin.f90 +++ b/src/phase_mechanics_plastic_dislotwin.f90 @@ -521,12 +521,12 @@ end function plastic_dislotwin_homogenizedC !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) +module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) real(pReal), dimension(3,3), intent(out) :: Lp real(pReal), dimension(3,3,3,3), intent(out) :: dLp_dMp real(pReal), dimension(3,3), intent(in) :: Mp - integer, intent(in) :: instance,me + integer, intent(in) :: ph,me real(pReal), intent(in) :: T integer :: i,k,l,m,n @@ -535,11 +535,11 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) BoltzmannRatio, & ddot_gamma_dtau, & tau - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & dot_gamma_sl,ddot_gamma_dtau_slip - real(pReal), dimension(param(instance)%sum_N_tw) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tw) :: & dot_gamma_twin,ddot_gamma_dtau_twin - real(pReal), dimension(param(instance)%sum_N_tr) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tr) :: & dot_gamma_tr,ddot_gamma_dtau_trans real(pReal):: dot_gamma_sb real(pReal), dimension(3,3) :: eigVectors, P_sb @@ -564,7 +564,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) 0, 1, 1 & ],pReal),[ 3,6]) - associate(prm => param(instance), stt => state(instance)) + associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph))) f_unrotated = 1.0_pReal & - sum(stt%f_tw(1:prm%sum_N_tw,me)) & @@ -573,7 +573,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) Lp = 0.0_pReal dLp_dMp = 0.0_pReal - call kinetics_slip(Mp,T,instance,me,dot_gamma_sl,ddot_gamma_dtau_slip) + call kinetics_slip(Mp,T,phase_plasticityInstance(ph),me,dot_gamma_sl,ddot_gamma_dtau_slip) slipContribution: do i = 1, prm%sum_N_sl Lp = Lp + dot_gamma_sl(i)*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -581,7 +581,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) + ddot_gamma_dtau_slip(i) * prm%P_sl(k,l,i) * prm%P_sl(m,n,i) enddo slipContribution - call kinetics_twin(Mp,T,dot_gamma_sl,instance,me,dot_gamma_twin,ddot_gamma_dtau_twin) + call kinetics_twin(Mp,T,dot_gamma_sl,phase_plasticityInstance(ph),me,dot_gamma_twin,ddot_gamma_dtau_twin) twinContibution: do i = 1, prm%sum_N_tw Lp = Lp + dot_gamma_twin(i)*prm%P_tw(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -589,7 +589,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,instance,me) + ddot_gamma_dtau_twin(i)* prm%P_tw(k,l,i)*prm%P_tw(m,n,i) enddo twinContibution - call kinetics_trans(Mp,T,dot_gamma_sl,instance,me,dot_gamma_tr,ddot_gamma_dtau_trans) + call kinetics_trans(Mp,T,dot_gamma_sl,phase_plasticityInstance(ph),me,dot_gamma_tr,ddot_gamma_dtau_trans) transContibution: do i = 1, prm%sum_N_tr Lp = Lp + dot_gamma_tr(i)*prm%P_tr(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -634,14 +634,14 @@ end subroutine dislotwin_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine dislotwin_dotState(Mp,T,instance,me) +module subroutine dislotwin_dotState(Mp,T,ph,me) real(pReal), dimension(3,3), intent(in):: & Mp !< Mandel stress real(pReal), intent(in) :: & T !< temperature at integration point integer, intent(in) :: & - instance, & + ph, & me integer :: i @@ -653,24 +653,24 @@ module subroutine dislotwin_dotState(Mp,T,instance,me) tau, & sigma_cl, & !< climb stress b_d !< ratio of Burgers vector to stacking fault width - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & dot_rho_dip_formation, & dot_rho_dip_climb, & rho_dip_distance_min, & dot_gamma_sl - real(pReal), dimension(param(instance)%sum_N_tw) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tw) :: & dot_gamma_twin - real(pReal), dimension(param(instance)%sum_N_tr) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tr) :: & dot_gamma_tr - associate(prm => param(instance), stt => state(instance), & - dot => dotState(instance), dst => dependentState(instance)) + associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)), & + dot => dotState(phase_plasticityInstance(ph)), dst => dependentState(phase_plasticityInstance(ph))) f_unrotated = 1.0_pReal & - sum(stt%f_tw(1:prm%sum_N_tw,me)) & - sum(stt%f_tr(1:prm%sum_N_tr,me)) - call kinetics_slip(Mp,T,instance,me,dot_gamma_sl) + call kinetics_slip(Mp,T,phase_plasticityInstance(ph),me,dot_gamma_sl) dot%gamma_sl(:,me) = abs(dot_gamma_sl) rho_dip_distance_min = prm%D_a*prm%b_sl @@ -721,10 +721,10 @@ module subroutine dislotwin_dotState(Mp,T,instance,me) - 2.0_pReal*rho_dip_distance_min/prm%b_sl * stt%rho_dip(:,me)*abs(dot_gamma_sl) & - dot_rho_dip_climb - call kinetics_twin(Mp,T,dot_gamma_sl,instance,me,dot_gamma_twin) + call kinetics_twin(Mp,T,dot_gamma_sl,phase_plasticityInstance(ph),me,dot_gamma_twin) dot%f_tw(:,me) = f_unrotated*dot_gamma_twin/prm%gamma_char - call kinetics_trans(Mp,T,dot_gamma_sl,instance,me,dot_gamma_tr) + call kinetics_trans(Mp,T,dot_gamma_sl,phase_plasticityInstance(ph),me,dot_gamma_tr) dot%f_tr(:,me) = f_unrotated*dot_gamma_tr end associate diff --git a/src/phase_mechanics_plastic_isotropic.f90 b/src/phase_mechanics_plastic_isotropic.f90 index 080a56cfd..e7b72fcd2 100644 --- a/src/phase_mechanics_plastic_isotropic.f90 +++ b/src/phase_mechanics_plastic_isotropic.f90 @@ -168,7 +168,7 @@ end function plastic_isotropic_init !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) +module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -178,7 +178,7 @@ module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me real(pReal), dimension(3,3) :: & @@ -190,7 +190,7 @@ module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) integer :: & k, l, m, n - associate(prm => param(instance), stt => state(instance)) + associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph))) Mp_dev = math_deviatoric33(Mp) squarenorm_Mp_dev = math_tensordot(Mp_dev,Mp_dev) @@ -262,12 +262,12 @@ module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine isotropic_dotState(Mp,instance,me) +module subroutine isotropic_dotState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me real(pReal) :: & @@ -275,7 +275,8 @@ module subroutine isotropic_dotState(Mp,instance,me) xi_inf_star, & !< saturation xi norm_Mp !< norm of the (deviatoric) Mandel stress - associate(prm => param(instance), stt => state(instance), dot => dotState(instance)) + associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)), & + dot => dotState(phase_plasticityInstance(ph))) if (prm%dilatation) then norm_Mp = sqrt(math_tensordot(Mp,Mp)) diff --git a/src/phase_mechanics_plastic_kinehardening.f90 b/src/phase_mechanics_plastic_kinehardening.f90 index de80a646d..034e5fd32 100644 --- a/src/phase_mechanics_plastic_kinehardening.f90 +++ b/src/phase_mechanics_plastic_kinehardening.f90 @@ -240,7 +240,7 @@ end function plastic_kinehardening_init !-------------------------------------------------------------------------------------------------- !> @brief Calculate plastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) +pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -250,21 +250,21 @@ pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me integer :: & i,k,l,m,n - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & gdot_pos,gdot_neg, & dgdot_dtau_pos,dgdot_dtau_neg Lp = 0.0_pReal dLp_dMp = 0.0_pReal - associate(prm => param(instance)) + associate(prm => param(phase_plasticityInstance(ph))) - call kinetics(Mp,instance,me,gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) + call kinetics(Mp,phase_plasticityInstance(ph),me,gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) do i = 1, prm%sum_N_sl Lp = Lp + (gdot_pos(i)+gdot_neg(i))*prm%P(1:3,1:3,i) @@ -282,23 +282,24 @@ end subroutine kinehardening_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_kinehardening_dotState(Mp,instance,me) +module subroutine plastic_kinehardening_dotState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me real(pReal) :: & sumGamma - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & gdot_pos,gdot_neg - associate(prm => param(instance), stt => state(instance), dot => dotState(instance)) + associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)),& + dot => dotState(phase_plasticityInstance(ph))) - call kinetics(Mp,instance,me,gdot_pos,gdot_neg) + call kinetics(Mp,phase_plasticityInstance(ph),me,gdot_pos,gdot_neg) dot%accshear(:,me) = abs(gdot_pos+gdot_neg) sumGamma = sum(stt%accshear(:,me)) diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 index 884bc6bc0..d0ed01cf0 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanics_plastic_nonlocal.f90 @@ -758,13 +758,13 @@ end subroutine nonlocal_dependentState !> @brief calculates plastic velocity gradient and its tangent !-------------------------------------------------------------------------------------------------- module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & - Mp,Temperature,instance,me,ip,el) + Mp,Temperature,ph,me,ip,el) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & dLp_dMp integer, intent(in) :: & - instance, & + ph, & me, & ip, & !< current integration point el !< current element number @@ -782,24 +782,25 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & l, & t, & !< dislocation type s !< index of my current slip system - real(pReal), dimension(param(instance)%sum_N_sl,8) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,8) :: & rhoSgl !< single dislocation densities (including blocked) - real(pReal), dimension(param(instance)%sum_N_sl,10) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,10) :: & rho - real(pReal), dimension(param(instance)%sum_N_sl,4) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,4) :: & v, & !< velocity tauNS, & !< resolved shear stress including non Schmid and backstress terms dv_dtau, & !< velocity derivative with respect to the shear stress dv_dtauNS !< velocity derivative with respect to the shear stress - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & tau, & !< resolved shear stress including backstress terms gdotTotal !< shear rate - associate(prm => param(instance),dst=>microstructure(instance),stt=>state(instance)) + associate(prm => param(phase_plasticityInstance(ph)),dst=>microstructure(phase_plasticityInstance(ph)),& + stt=>state(phase_plasticityInstance(ph))) ns = prm%sum_N_sl !*** shortcut to state variables - rho = getRho(instance,me,ip,el) + rho = getRho(phase_plasticityInstance(ph),me,ip,el) rhoSgl = rho(:,sgl) do s = 1,ns @@ -819,7 +820,7 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & ! edges call kinetics(v(:,1), dv_dtau(:,1), dv_dtauNS(:,1), & - tau, tauNS(:,1), dst%tau_pass(:,me),1,Temperature, instance) + tau, tauNS(:,1), dst%tau_pass(:,me),1,Temperature, phase_plasticityInstance(ph)) v(:,2) = v(:,1) dv_dtau(:,2) = dv_dtau(:,1) dv_dtauNS(:,2) = dv_dtauNS(:,1) @@ -832,7 +833,7 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & else do t = 3,4 call kinetics(v(:,t), dv_dtau(:,t), dv_dtauNS(:,t), & - tau, tauNS(:,t), dst%tau_pass(:,me),2,Temperature, instance) + tau, tauNS(:,t), dst%tau_pass(:,me),2,Temperature, phase_plasticityInstance(ph)) enddo endif @@ -973,7 +974,7 @@ end subroutine plastic_nonlocal_deltaState !> @brief calculates the rate of change of microstructure !--------------------------------------------------------------------------------------------------- module subroutine nonlocal_dotState(Mp, Temperature,timestep, & - instance,me,ip,el) + ph,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress @@ -981,7 +982,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & Temperature, & !< temperature timestep !< substepped crystallite time increment integer, intent(in) :: & - instance, & + ph, & me, & ip, & !< current integration point el !< current element number @@ -992,7 +993,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & c, & !< character of dislocation t, & !< type of dislocation s !< index of my current slip system - real(pReal), dimension(param(instance)%sum_N_sl,10) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,10) :: & rho, & rho0, & !< dislocation density at beginning of time step rhoDot, & !< density evolution @@ -1000,45 +1001,44 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & rhoDotSingle2DipoleGlide, & !< density evolution by dipole formation (by glide) rhoDotAthermalAnnihilation, & !< density evolution by athermal annihilation rhoDotThermalAnnihilation !< density evolution by thermal annihilation - real(pReal), dimension(param(instance)%sum_N_sl,8) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,8) :: & rhoSgl, & !< current single dislocation densities (positive/negative screw and edge without dipoles) my_rhoSgl0 !< single dislocation densities of central ip (positive/negative screw and edge without dipoles) - real(pReal), dimension(param(instance)%sum_N_sl,4) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,4) :: & v, & !< current dislocation glide velocity v0, & gdot !< shear rates - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & tau, & !< current resolved shear stress vClimb !< climb velocity of edge dipoles - real(pReal), dimension(param(instance)%sum_N_sl,2) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,2) :: & rhoDip, & !< current dipole dislocation densities (screw and edge dipoles) dLower, & !< minimum stable dipole distance for edges and screws dUpper !< current maximum stable dipole distance for edges and screws real(pReal) :: & selfDiffusion !< self diffusion - ph = material_phaseAt(1,el) if (timestep <= 0.0_pReal) then plasticState(ph)%dotState = 0.0_pReal return endif - associate(prm => param(instance), & - dst => microstructure(instance), & - dot => dotState(instance), & - stt => state(instance)) + associate(prm => param(phase_plasticityInstance(ph)), & + dst => microstructure(phase_plasticityInstance(ph)), & + dot => dotState(phase_plasticityInstance(ph)), & + stt => state(phase_plasticityInstance(ph))) ns = prm%sum_N_sl tau = 0.0_pReal gdot = 0.0_pReal - rho = getRho(instance,me,ip,el) + rho = getRho(phase_plasticityInstance(ph),me,ip,el) rhoSgl = rho(:,sgl) rhoDip = rho(:,dip) - rho0 = getRho0(instance,me,ip,el) + rho0 = getRho0(phase_plasticityInstance(ph),me,ip,el) my_rhoSgl0 = rho0(:,sgl) - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,instance),me) + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,phase_plasticityInstance(ph)),me) gdot = rhoSgl(:,1:4) * v * spread(prm%b_sl,2,4) #ifdef DEBUG @@ -1087,7 +1087,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & * sqrt(stt%rho_forest(:,me)) / prm%i_sl / prm%b_sl, 2, 4) endif isBCC - forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,instance),me) + forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,phase_plasticityInstance(ph)),me) !**************************************************************************** @@ -1143,7 +1143,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & - rhoDip(s,1) / timestep - rhoDotAthermalAnnihilation(s,9) & - rhoDotSingle2DipoleGlide(s,9)) ! make sure that we do not annihilate more dipoles than we have - rhoDot = rhoDotFlux(timestep, instance,me,ip,el) & + rhoDot = rhoDotFlux(timestep, phase_plasticityInstance(ph),me,ip,el) & + rhoDotMultiplication & + rhoDotSingle2DipoleGlide & + rhoDotAthermalAnnihilation & diff --git a/src/phase_mechanics_plastic_phenopowerlaw.f90 b/src/phase_mechanics_plastic_phenopowerlaw.f90 index a9538aeec..1d91a97fb 100644 --- a/src/phase_mechanics_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanics_plastic_phenopowerlaw.f90 @@ -285,7 +285,7 @@ end function plastic_phenopowerlaw_init !> @details asummes that deformation by dislocation glide affects twinned and untwinned volume ! equally (Taylor assumption). Twinning happens only in untwinned volume !-------------------------------------------------------------------------------------------------- -pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) +pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient @@ -295,23 +295,23 @@ pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me integer :: & i,k,l,m,n - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & gdot_slip_pos,gdot_slip_neg, & dgdot_dtauslip_pos,dgdot_dtauslip_neg - real(pReal), dimension(param(instance)%sum_N_tw) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tw) :: & gdot_twin,dgdot_dtautwin Lp = 0.0_pReal dLp_dMp = 0.0_pReal - associate(prm => param(instance)) + associate(prm => param(phase_plasticityInstance(ph))) - call kinetics_slip(Mp,instance,me,gdot_slip_pos,gdot_slip_neg,dgdot_dtauslip_pos,dgdot_dtauslip_neg) + call kinetics_slip(Mp,phase_plasticityInstance(ph),me,gdot_slip_pos,gdot_slip_neg,dgdot_dtauslip_pos,dgdot_dtauslip_neg) slipSystems: do i = 1, prm%sum_N_sl Lp = Lp + (gdot_slip_pos(i)+gdot_slip_neg(i))*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -320,7 +320,7 @@ pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,instance,me) + dgdot_dtauslip_neg(i) * prm%P_sl(k,l,i) * prm%nonSchmid_neg(m,n,i) enddo slipSystems - call kinetics_twin(Mp,instance,me,gdot_twin,dgdot_dtautwin) + call kinetics_twin(Mp,phase_plasticityInstance(ph),me,gdot_twin,dgdot_dtautwin) twinSystems: do i = 1, prm%sum_N_tw Lp = Lp + gdot_twin(i)*prm%P_tw(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -336,23 +336,24 @@ end subroutine phenopowerlaw_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate the rate of change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine phenopowerlaw_dotState(Mp,instance,me) +module subroutine phenopowerlaw_dotState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me real(pReal) :: & c_SlipSlip,c_TwinSlip,c_TwinTwin, & xi_slip_sat_offset,& sumGamma,sumF - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & left_SlipSlip,right_SlipSlip, & gdot_slip_pos,gdot_slip_neg - associate(prm => param(instance), stt => state(instance), dot => dotState(instance)) + associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)), & + dot => dotState(phase_plasticityInstance(ph))) sumGamma = sum(stt%gamma_slip(:,me)) sumF = sum(stt%gamma_twin(:,me)/prm%gamma_tw_char) @@ -372,9 +373,9 @@ module subroutine phenopowerlaw_dotState(Mp,instance,me) !-------------------------------------------------------------------------------------------------- ! shear rates - call kinetics_slip(Mp,instance,me,gdot_slip_pos,gdot_slip_neg) + call kinetics_slip(Mp,phase_plasticityInstance(ph),me,gdot_slip_pos,gdot_slip_neg) dot%gamma_slip(:,me) = abs(gdot_slip_pos+gdot_slip_neg) - call kinetics_twin(Mp,instance,me,dot%gamma_twin(:,me)) + call kinetics_twin(Mp,phase_plasticityInstance(ph),me,dot%gamma_twin(:,me)) !-------------------------------------------------------------------------------------------------- ! hardening From 69f6de0e4f524fd1b49ebaf7e9902db823705aad Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 23:44:11 +0100 Subject: [PATCH 181/352] consistent access pattern and naming --- src/homogenization_thermal.f90 | 16 ++++++---- src/phase.f90 | 6 ++-- src/phase_thermal.f90 | 30 ++++++------------- src/phase_thermal_dissipation.f90 | 47 +++++++++++------------------- src/phase_thermal_externalheat.f90 | 24 +++++++-------- 5 files changed, 51 insertions(+), 72 deletions(-) diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index 87ba8301a..dc5182dbf 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -225,13 +225,19 @@ module subroutine thermal_conduction_getSource(Tdot, ip,el) real(pReal), intent(out) :: & Tdot - integer :: & - homog + integer :: co, ho,ph,me + real(pReal) :: dot_T_temp - homog = material_homogenizationAt(el) - call constitutive_thermal_getRate(TDot, ip,el) + ho = material_homogenizationAt(el) + Tdot = 0.0_pReal + do co = 1, homogenization_Nconstituents(ho) + ph = material_phaseAt(co,el) + me = material_phasememberAt(co,ip,el) + call constitutive_thermal_getRate(dot_T_temp, ph,me) + Tdot = Tdot + dot_T_temp + enddo - Tdot = Tdot/real(homogenization_Nconstituents(homog),pReal) + Tdot = Tdot/real(homogenization_Nconstituents(ho),pReal) end subroutine thermal_conduction_getSource diff --git a/src/phase.f90 b/src/phase.f90 index 8b2532b79..f37efd043 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -244,10 +244,8 @@ module phase dPhiDot_dPhi end subroutine constitutive_damage_getRateAndItsTangents - module subroutine constitutive_thermal_getRate(TDot, ip,el) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + module subroutine constitutive_thermal_getRate(TDot, ph,me) + integer, intent(in) :: ph, me real(pReal), intent(out) :: & TDot end subroutine constitutive_thermal_getRate diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 5a7c7bc62..592ce04d0 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -44,13 +44,10 @@ submodule(phase) thermal me end subroutine externalheat_dotState - module subroutine thermal_dissipation_getRate(TDot, Tstar,Lp,phase) + module subroutine thermal_dissipation_getRate(TDot, ph,me) integer, intent(in) :: & - phase !< phase ID of element - real(pReal), intent(in), dimension(3,3) :: & - Tstar !< 2nd Piola Kirchhoff stress tensor for a given element - real(pReal), intent(in), dimension(3,3) :: & - Lp !< plastic velocuty gradient for a given element + ph, & + me real(pReal), intent(out) :: & TDot end subroutine thermal_dissipation_getRate @@ -135,33 +132,24 @@ end subroutine thermal_init !---------------------------------------------------------------------------------------------- !< @brief calculates thermal dissipation rate !---------------------------------------------------------------------------------------------- -module subroutine constitutive_thermal_getRate(TDot, ip, el) +module subroutine constitutive_thermal_getRate(TDot, ph,me) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ph, me real(pReal), intent(out) :: & TDot real(pReal) :: & my_Tdot integer :: & - ph, & - homog, & - me, & - so, & - co + so - homog = material_homogenizationAt(el) TDot = 0.0_pReal - do co = 1, homogenization_Nconstituents(homog) - ph = material_phaseAt(co,el) - me = material_phasememberAt(co,ip,el) + do so = 1, thermal_Nsources(ph) select case(thermal_source(so,ph)) case (THERMAL_DISSIPATION_ID) - call thermal_dissipation_getRate(my_Tdot, mech_S(ph,me),mech_L_p(ph,me),ph) + call thermal_dissipation_getRate(my_Tdot, ph,me) case (THERMAL_EXTERNALHEAT_ID) call thermal_externalheat_getRate(my_Tdot, ph,me) @@ -171,7 +159,7 @@ module subroutine constitutive_thermal_getRate(TDot, ip, el) end select Tdot = Tdot + my_Tdot enddo - enddo + end subroutine constitutive_thermal_getRate diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index ab2a13c64..9055910ac 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -6,10 +6,6 @@ !-------------------------------------------------------------------------------------------------- submodule(phase:thermal) dissipation - integer, dimension(:), allocatable :: & - source_thermal_dissipation_offset, & !< which source is my current thermal dissipation mechanism? - source_thermal_dissipation_instance !< instance of thermal dissipation source mechanism - type :: tParameters !< container type for internal constitutive parameters real(pReal) :: & kappa !< TAYLOR-QUINNEY factor @@ -35,7 +31,7 @@ module function dissipation_init(source_length) result(mySources) phase, & sources, thermal, & src - integer :: Ninstances,sourceOffset,Nconstituents,p + integer :: Ninstances,so,Nconstituents,ph print'(/,a)', ' <<<+- thermal_dissipation init -+>>>' @@ -46,25 +42,21 @@ module function dissipation_init(source_length) result(mySources) if(Ninstances == 0) return phases => config_material%get('phase') - allocate(param(Ninstances)) - allocate(source_thermal_dissipation_offset (phases%length), source=0) - allocate(source_thermal_dissipation_instance(phases%length), source=0) + allocate(param(phases%length)) - do p = 1, phases%length - phase => phases%get(p) - if(any(mySources(:,p))) source_thermal_dissipation_instance(p) = count(mySources(:,1:p)) - if(count(mySources(:,p)) == 0) cycle + do ph = 1, phases%length + phase => phases%get(ph) + if(count(mySources(:,ph)) == 0) cycle !ToDo: error if > 1 thermal => phase%get('thermal') sources => thermal%get('source') - do sourceOffset = 1, sources%length - if(mySources(sourceOffset,p)) then - source_thermal_dissipation_offset(p) = sourceOffset - associate(prm => param(source_thermal_dissipation_instance(p))) - src => sources%get(sourceOffset) + do so = 1, sources%length + if(mySources(so,ph)) then + associate(prm => param(ph)) + src => sources%get(so) - prm%kappa = src%get_asFloat('kappa') - Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(thermalState(p)%p(sourceOffset),Nconstituents,0,0,0) + prm%kappa = src%get_asFloat('kappa') + Nconstituents = count(material_phaseAt2 == ph) + call constitutive_allocateState(thermalState(ph)%p(so),Nconstituents,0,0,0) end associate endif @@ -78,20 +70,15 @@ end function dissipation_init !-------------------------------------------------------------------------------------------------- !> @brief Ninstancess dissipation rate !-------------------------------------------------------------------------------------------------- -module subroutine thermal_dissipation_getRate(TDot, Tstar, Lp, phase) - - integer, intent(in) :: & - phase - real(pReal), intent(in), dimension(3,3) :: & - Tstar - real(pReal), intent(in), dimension(3,3) :: & - Lp +module subroutine thermal_dissipation_getRate(TDot, ph,me) + integer, intent(in) :: ph, me real(pReal), intent(out) :: & TDot - associate(prm => param(source_thermal_dissipation_instance(phase))) - TDot = prm%kappa*sum(abs(Tstar*Lp)) + + associate(prm => param(ph)) + TDot = prm%kappa*sum(abs(mech_S(ph,me)*mech_L_p(ph,me))) end associate end subroutine thermal_dissipation_getRate diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index 5707efb11..d612794e6 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -39,7 +39,7 @@ module function externalheat_init(source_length) result(mySources) phase, & sources, thermal, & src - integer :: Ninstances,sourceOffset,Nconstituents,p + integer :: Ninstances,so,Nconstituents,p print'(/,a)', ' <<<+- thermal_externalheat init -+>>>' @@ -60,11 +60,11 @@ module function externalheat_init(source_length) result(mySources) if(count(mySources(:,p)) == 0) cycle thermal => phase%get('thermal') sources => thermal%get('source') - do sourceOffset = 1, sources%length - if(mySources(sourceOffset,p)) then - source_thermal_externalheat_offset(p) = sourceOffset + do so = 1, sources%length + if(mySources(so,p)) then + source_thermal_externalheat_offset(p) = so associate(prm => param(source_thermal_externalheat_instance(p))) - src => sources%get(sourceOffset) + src => sources%get(so) prm%t_n = src%get_asFloats('t_n') prm%nIntervals = size(prm%t_n) - 1 @@ -72,7 +72,7 @@ module function externalheat_init(source_length) result(mySources) prm%f_T = src%get_asFloats('f_T',requiredSize = size(prm%t_n)) Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(thermalState(p)%p(sourceOffset),Nconstituents,1,1,0) + call constitutive_allocateState(thermalState(p)%p(so),Nconstituents,1,1,0) end associate endif enddo @@ -92,11 +92,11 @@ module subroutine externalheat_dotState(ph, me) me integer :: & - sourceOffset + so - sourceOffset = source_thermal_externalheat_offset(ph) + so = source_thermal_externalheat_offset(ph) - thermalState(ph)%p(sourceOffset)%dotState(1,me) = 1.0_pReal ! state is current time + thermalState(ph)%p(so)%dotState(1,me) = 1.0_pReal ! state is current time end subroutine externalheat_dotState @@ -113,15 +113,15 @@ module subroutine thermal_externalheat_getRate(TDot, ph, me) TDot integer :: & - sourceOffset, interval + so, interval real(pReal) :: & frac_time - sourceOffset = source_thermal_externalheat_offset(ph) + so = source_thermal_externalheat_offset(ph) associate(prm => param(source_thermal_externalheat_instance(ph))) do interval = 1, prm%nIntervals ! scan through all rate segments - frac_time = (thermalState(ph)%p(sourceOffset)%state(1,me) - prm%t_n(interval)) & + frac_time = (thermalState(ph)%p(so)%state(1,me) - prm%t_n(interval)) & / (prm%t_n(interval+1) - prm%t_n(interval)) ! fractional time within segment if ( (frac_time < 0.0_pReal .and. interval == 1) & .or. (frac_time >= 1.0_pReal .and. interval == prm%nIntervals) & From 1da1018d86f9b8e8e3e6c64b35e1483e1840ba8e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 23:56:20 +0100 Subject: [PATCH 182/352] polishing --- src/phase_thermal.f90 | 30 +++++++-------- src/phase_thermal_dissipation.f90 | 4 +- src/phase_thermal_externalheat.f90 | 59 ++++++++++++++---------------- 3 files changed, 45 insertions(+), 48 deletions(-) diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 592ce04d0..96ac291ae 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -44,21 +44,21 @@ submodule(phase) thermal me end subroutine externalheat_dotState - module subroutine thermal_dissipation_getRate(TDot, ph,me) + module subroutine dissipation_getRate(TDot, ph,me) integer, intent(in) :: & ph, & me real(pReal), intent(out) :: & TDot - end subroutine thermal_dissipation_getRate + end subroutine dissipation_getRate - module subroutine thermal_externalheat_getRate(TDot, ph,me) + module subroutine externalheat_getRate(TDot, ph,me) integer, intent(in) :: & ph, & me real(pReal), intent(out) :: & TDot - end subroutine thermal_externalheat_getRate + end subroutine externalheat_getRate end interface @@ -146,19 +146,19 @@ module subroutine constitutive_thermal_getRate(TDot, ph,me) TDot = 0.0_pReal - do so = 1, thermal_Nsources(ph) - select case(thermal_source(so,ph)) - case (THERMAL_DISSIPATION_ID) - call thermal_dissipation_getRate(my_Tdot, ph,me) + do so = 1, thermal_Nsources(ph) + select case(thermal_source(so,ph)) + case (THERMAL_DISSIPATION_ID) + call dissipation_getRate(my_Tdot, ph,me) - case (THERMAL_EXTERNALHEAT_ID) - call thermal_externalheat_getRate(my_Tdot, ph,me) + case (THERMAL_EXTERNALHEAT_ID) + call externalheat_getRate(my_Tdot, ph,me) - case default - my_Tdot = 0.0_pReal - end select - Tdot = Tdot + my_Tdot - enddo + case default + my_Tdot = 0.0_pReal + end select + Tdot = Tdot + my_Tdot + enddo end subroutine constitutive_thermal_getRate diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index 9055910ac..2ac444f4a 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -70,7 +70,7 @@ end function dissipation_init !-------------------------------------------------------------------------------------------------- !> @brief Ninstancess dissipation rate !-------------------------------------------------------------------------------------------------- -module subroutine thermal_dissipation_getRate(TDot, ph,me) +module subroutine dissipation_getRate(TDot, ph,me) integer, intent(in) :: ph, me real(pReal), intent(out) :: & @@ -81,6 +81,6 @@ module subroutine thermal_dissipation_getRate(TDot, ph,me) TDot = prm%kappa*sum(abs(mech_S(ph,me)*mech_L_p(ph,me))) end associate -end subroutine thermal_dissipation_getRate +end subroutine dissipation_getRate end submodule dissipation diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index d612794e6..60a4c3964 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -8,8 +8,7 @@ submodule(phase:thermal) externalheat integer, dimension(:), allocatable :: & - source_thermal_externalheat_offset, & !< which source is my current thermal dissipation mechanism? - source_thermal_externalheat_instance !< instance of thermal dissipation source mechanism + source_thermal_externalheat_offset !< which source is my current thermal dissipation mechanism? type :: tParameters !< container type for internal constitutive parameters real(pReal), dimension(:), allocatable :: & @@ -39,7 +38,7 @@ module function externalheat_init(source_length) result(mySources) phase, & sources, thermal, & src - integer :: Ninstances,so,Nconstituents,p + integer :: Ninstances,so,Nconstituents,ph print'(/,a)', ' <<<+- thermal_externalheat init -+>>>' @@ -50,29 +49,27 @@ module function externalheat_init(source_length) result(mySources) if(Ninstances == 0) return phases => config_material%get('phase') - allocate(param(Ninstances)) + allocate(param(phases%length)) allocate(source_thermal_externalheat_offset (phases%length), source=0) - allocate(source_thermal_externalheat_instance(phases%length), source=0) - do p = 1, phases%length - phase => phases%get(p) - if(any(mySources(:,p))) source_thermal_externalheat_instance(p) = count(mySources(:,1:p)) - if(count(mySources(:,p)) == 0) cycle + do ph = 1, phases%length + phase => phases%get(ph) + if(count(mySources(:,ph)) == 0) cycle thermal => phase%get('thermal') sources => thermal%get('source') do so = 1, sources%length - if(mySources(so,p)) then - source_thermal_externalheat_offset(p) = so - associate(prm => param(source_thermal_externalheat_instance(p))) - src => sources%get(so) + if(mySources(so,ph)) then + source_thermal_externalheat_offset(ph) = so + associate(prm => param(ph)) + src => sources%get(so) - prm%t_n = src%get_asFloats('t_n') - prm%nIntervals = size(prm%t_n) - 1 + prm%t_n = src%get_asFloats('t_n') + prm%nIntervals = size(prm%t_n) - 1 - prm%f_T = src%get_asFloats('f_T',requiredSize = size(prm%t_n)) + prm%f_T = src%get_asFloats('f_T',requiredSize = size(prm%t_n)) - Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(thermalState(p)%p(so),Nconstituents,1,1,0) + Nconstituents = count(material_phaseAt2 == ph) + call constitutive_allocateState(thermalState(ph)%p(so),Nconstituents,1,1,0) end associate endif enddo @@ -104,7 +101,7 @@ end subroutine externalheat_dotState !-------------------------------------------------------------------------------------------------- !> @brief returns local heat generation rate !-------------------------------------------------------------------------------------------------- -module subroutine thermal_externalheat_getRate(TDot, ph, me) +module subroutine externalheat_getRate(TDot, ph, me) integer, intent(in) :: & ph, & @@ -119,19 +116,19 @@ module subroutine thermal_externalheat_getRate(TDot, ph, me) so = source_thermal_externalheat_offset(ph) - associate(prm => param(source_thermal_externalheat_instance(ph))) - do interval = 1, prm%nIntervals ! scan through all rate segments - frac_time = (thermalState(ph)%p(so)%state(1,me) - prm%t_n(interval)) & - / (prm%t_n(interval+1) - prm%t_n(interval)) ! fractional time within segment - if ( (frac_time < 0.0_pReal .and. interval == 1) & - .or. (frac_time >= 1.0_pReal .and. interval == prm%nIntervals) & - .or. (frac_time >= 0.0_pReal .and. frac_time < 1.0_pReal) ) & - TDot = prm%f_T(interval ) * (1.0_pReal - frac_time) + & - prm%f_T(interval+1) * frac_time ! interpolate heat rate between segment boundaries... - ! ...or extrapolate if outside me bounds - enddo + associate(prm => param(ph)) + do interval = 1, prm%nIntervals ! scan through all rate segments + frac_time = (thermalState(ph)%p(so)%state(1,me) - prm%t_n(interval)) & + / (prm%t_n(interval+1) - prm%t_n(interval)) ! fractional time within segment + if ( (frac_time < 0.0_pReal .and. interval == 1) & + .or. (frac_time >= 1.0_pReal .and. interval == prm%nIntervals) & + .or. (frac_time >= 0.0_pReal .and. frac_time < 1.0_pReal) ) & + TDot = prm%f_T(interval ) * (1.0_pReal - frac_time) + & + prm%f_T(interval+1) * frac_time ! interpolate heat rate between segment boundaries... + ! ...or extrapolate if outside me bounds + enddo end associate -end subroutine thermal_externalheat_getRate +end subroutine externalheat_getRate end submodule externalheat From e6a9ea6ddedf670f22fd6e3009341e4c3755a79b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 27 Jan 2021 00:06:41 +0100 Subject: [PATCH 183/352] should be part of eigendeformation submodule --- src/commercialFEM_fileList.f90 | 2 +- src/phase.f90 | 5 ++++ src/phase_mechanics.f90 | 6 ++++ ...nics_eigendeformation_thermalexpansion.f90 | 28 +++++++++---------- src/phase_thermal.f90 | 24 ++++++++++------ 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 621a091d8..6480f7382 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -32,10 +32,10 @@ #include "phase_mechanics_eigendeformation.f90" #include "phase_mechanics_eigendeformation_cleavageopening.f90" #include "phase_mechanics_eigendeformation_slipplaneopening.f90" +#include "phase_mechanics_eigendeformation_thermalexpansion.f90" #include "phase_thermal.f90" #include "phase_thermal_dissipation.f90" #include "phase_thermal_externalheat.f90" -#include "phase_mechanics_eigendeformation_thermalexpansion.f90" #include "phase_damage.f90" #include "phase_damage_isobrittle.f90" #include "phase_damage_isoductile.f90" diff --git a/src/phase.f90 b/src/phase.f90 index f37efd043..d532e4596 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -186,6 +186,11 @@ module phase real(pReal) :: T end function thermal_T + module function thermal_dot_T(ph,me) result(dot_T) + integer, intent(in) :: ph,me + real(pReal) :: dot_T + end function thermal_dot_T + module subroutine constitutive_mech_setF(F,co,ip,el) real(pReal), dimension(3,3), intent(in) :: F diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index 91d455279..2b2144b97 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -137,6 +137,11 @@ submodule(phase) mechanics logical, dimension(:,:), allocatable :: myKinematics end function kinematics_slipplane_opening_init + module function kinematics_thermal_expansion_init(kinematics_length) result(myKinematics) + integer, intent(in) :: kinematics_length + logical, dimension(:,:), allocatable :: myKinematics + end function kinematics_thermal_expansion_init + module subroutine plastic_isotropic_results(instance,group) integer, intent(in) :: instance character(len=*), intent(in) :: group @@ -365,6 +370,7 @@ module subroutine mech_init(phases) if(maxval(phase_Nkinematics) /= 0) then where(kinematics_cleavage_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_cleavage_opening_ID where(kinematics_slipplane_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_slipplane_opening_ID + where(kinematics_thermal_expansion_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_thermal_expansion_ID endif end subroutine mech_init diff --git a/src/phase_mechanics_eigendeformation_thermalexpansion.f90 b/src/phase_mechanics_eigendeformation_thermalexpansion.f90 index b9483977a..7a6a7daa3 100644 --- a/src/phase_mechanics_eigendeformation_thermalexpansion.f90 +++ b/src/phase_mechanics_eigendeformation_thermalexpansion.f90 @@ -3,7 +3,7 @@ !> @brief material subroutine incorporating kinematics resulting from thermal expansion !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(phase:thermal) thermalexpansion +submodule(phase:eigendeformation) thermalexpansion integer, dimension(:), allocatable :: kinematics_thermal_expansion_instance @@ -93,21 +93,21 @@ module subroutine thermalexpansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) real(pReal) :: T, dot_T - T = current(ph)%T(me) - dot_T = current(ph)%dot_T(me) + T = thermal_T(ph,me) + dot_T = thermal_dot_T(ph,me) associate(prm => param(kinematics_thermal_expansion_instance(ph))) - Li = dot_T * ( & - prm%A(1:3,1:3,1)*(T - prm%T_ref)**0 & ! constant coefficient - + prm%A(1:3,1:3,2)*(T - prm%T_ref)**1 & ! linear coefficient - + prm%A(1:3,1:3,3)*(T - prm%T_ref)**2 & ! quadratic coefficient - ) / & - (1.0_pReal & - + prm%A(1:3,1:3,1)*(T - prm%T_ref)**1 / 1. & - + prm%A(1:3,1:3,2)*(T - prm%T_ref)**2 / 2. & - + prm%A(1:3,1:3,3)*(T - prm%T_ref)**3 / 3. & - ) - end associate + Li = dot_T * ( & + prm%A(1:3,1:3,1)*(T - prm%T_ref)**0 & ! constant coefficient + + prm%A(1:3,1:3,2)*(T - prm%T_ref)**1 & ! linear coefficient + + prm%A(1:3,1:3,3)*(T - prm%T_ref)**2 & ! quadratic coefficient + ) / & + (1.0_pReal & + + prm%A(1:3,1:3,1)*(T - prm%T_ref)**1 / 1. & + + prm%A(1:3,1:3,2)*(T - prm%T_ref)**2 / 2. & + + prm%A(1:3,1:3,3)*(T - prm%T_ref)**3 / 3. & + ) + end associate dLi_dTstar = 0.0_pReal end subroutine thermalexpansion_LiAndItsTangent diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 96ac291ae..621bb4f4a 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -32,10 +32,7 @@ submodule(phase) thermal logical, dimension(:,:), allocatable :: mySources end function externalheat_init - module function kinematics_thermal_expansion_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_thermal_expansion_init + module subroutine externalheat_dotState(ph, me) @@ -121,11 +118,6 @@ module subroutine thermal_init(phases) maxval(thermalState(ph)%p%sizeDotState)) enddo PhaseLoop2 -!-------------------------------------------------------------------------------------------------- -!initialize kinematic mechanisms - if(maxval(phase_Nkinematics) /= 0) where(kinematics_thermal_expansion_init(maxval(phase_Nkinematics))) & - phase_kinematics = KINEMATICS_thermal_expansion_ID - end subroutine thermal_init @@ -257,6 +249,20 @@ module function thermal_T(ph,me) result(T) end function thermal_T +!---------------------------------------------------------------------------------------------- +!< @brief Get rate of temperature (for use by non-thermal physics) +!---------------------------------------------------------------------------------------------- +module function thermal_dot_T(ph,me) result(dot_T) + + integer, intent(in) :: ph, me + real(pReal) :: dot_T + + + dot_T = current(ph)%dot_T(me) + +end function thermal_dot_T + + !---------------------------------------------------------------------------------------------- !< @brief Set temperature !---------------------------------------------------------------------------------------------- From 6c99f1a2343350f15d9c26adfd24c2e48d87154d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 27 Jan 2021 00:32:44 +0100 Subject: [PATCH 184/352] separating according to physics --- src/phase_mechanics.f90 | 72 +++--------------------- src/phase_mechanics_eigendeformation.f90 | 55 ++++++++++++++++++ src/phase_mechanics_plastic.f90 | 47 ++++++++++++++++ 3 files changed, 109 insertions(+), 65 deletions(-) diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index 2b2144b97..fd8b9331b 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -48,40 +48,16 @@ submodule(phase) mechanics interface - module function plastic_none_init() result(myPlasticity) - logical, dimension(:), allocatable :: & - myPlasticity - end function plastic_none_init + module subroutine eigendeformation_init(phases) + class(tNode), pointer :: phases + end subroutine eigendeformation_init - module function plastic_isotropic_init() result(myPlasticity) - logical, dimension(:), allocatable :: & - myPlasticity - end function plastic_isotropic_init + module subroutine plastic_init - module function plastic_phenopowerlaw_init() result(myPlasticity) - logical, dimension(:), allocatable :: & - myPlasticity - end function plastic_phenopowerlaw_init - module function plastic_kinehardening_init() result(myPlasticity) - logical, dimension(:), allocatable :: & - myPlasticity - end function plastic_kinehardening_init + end subroutine plastic_init - module function plastic_dislotwin_init() result(myPlasticity) - logical, dimension(:), allocatable :: & - myPlasticity - end function plastic_dislotwin_init - module function plastic_dislotungsten_init() result(myPlasticity) - logical, dimension(:), allocatable :: & - myPlasticity - end function plastic_dislotungsten_init - - module function plastic_nonlocal_init() result(myPlasticity) - logical, dimension(:), allocatable :: & - myPlasticity - end function plastic_nonlocal_init module function plastic_dotState(subdt,co,ip,el,ph,me) result(broken) @@ -124,23 +100,8 @@ submodule(phase) mechanics real(pReal), intent(out), dimension(3,3,3,3) :: & dLp_dS, & dLp_dFi !< derivative of Lp with respect to Fi - end subroutine plastic_LpAndItsTangents - module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_cleavage_opening_init - - module function kinematics_slipplane_opening_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_slipplane_opening_init - - module function kinematics_thermal_expansion_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_thermal_expansion_init module subroutine plastic_isotropic_results(instance,group) integer, intent(in) :: instance @@ -319,13 +280,7 @@ module subroutine mech_init(phases) allocate(phase_plasticityInstance(phases%length),source = 0) allocate(phase_localPlasticity(phases%length), source=.true.) - where(plastic_none_init()) phase_plasticity = PLASTICITY_NONE_ID - where(plastic_isotropic_init()) phase_plasticity = PLASTICITY_ISOTROPIC_ID - where(plastic_phenopowerlaw_init()) phase_plasticity = PLASTICITY_PHENOPOWERLAW_ID - where(plastic_kinehardening_init()) phase_plasticity = PLASTICITY_KINEHARDENING_ID - where(plastic_dislotwin_init()) phase_plasticity = PLASTICITY_DISLOTWIN_ID - where(plastic_dislotungsten_init()) phase_plasticity = PLASTICITY_DISLOTUNGSTEN_ID - where(plastic_nonlocal_init()) phase_plasticity = PLASTICITY_NONLOCAL_ID + call plastic_init() do ph = 1, phases%length phase_elasticityInstance(ph) = count(phase_elasticity(1:ph) == phase_elasticity(ph)) @@ -356,22 +311,9 @@ module subroutine mech_init(phases) end select -!-------------------------------------------------------------------------------------------------- -! initialize kinematic mechanisms - allocate(phase_Nkinematics(phases%length),source = 0) - do ph = 1,phases%length - phase => phases%get(ph) - kinematics => phase%get('kinematics',defaultVal=emptyList) - phase_Nkinematics(ph) = kinematics%length - enddo - allocate(phase_kinematics(maxval(phase_Nkinematics),phases%length), source = KINEMATICS_undefined_ID) + call eigendeformation_init(phases) - if(maxval(phase_Nkinematics) /= 0) then - where(kinematics_cleavage_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_cleavage_opening_ID - where(kinematics_slipplane_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_slipplane_opening_ID - where(kinematics_thermal_expansion_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_thermal_expansion_ID - endif end subroutine mech_init diff --git a/src/phase_mechanics_eigendeformation.f90 b/src/phase_mechanics_eigendeformation.f90 index 9a86945dd..98bc8481f 100644 --- a/src/phase_mechanics_eigendeformation.f90 +++ b/src/phase_mechanics_eigendeformation.f90 @@ -1,2 +1,57 @@ submodule(phase:mechanics) eigendeformation + + interface + module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) + integer, intent(in) :: kinematics_length + logical, dimension(:,:), allocatable :: myKinematics + end function kinematics_cleavage_opening_init + + module function kinematics_slipplane_opening_init(kinematics_length) result(myKinematics) + integer, intent(in) :: kinematics_length + logical, dimension(:,:), allocatable :: myKinematics + end function kinematics_slipplane_opening_init + + module function kinematics_thermal_expansion_init(kinematics_length) result(myKinematics) + integer, intent(in) :: kinematics_length + logical, dimension(:,:), allocatable :: myKinematics + end function kinematics_thermal_expansion_init + end interface + + +contains + + +module subroutine eigendeformation_init(phases) + + class(tNode), pointer :: & + phases + + integer :: & + ph + class(tNode), pointer :: & + phase, & + kinematics + + print'(/,a)', ' <<<+- phase_mechanics_eigendeformation init -+>>>' + +!-------------------------------------------------------------------------------------------------- +! initialize kinematic mechanisms + allocate(phase_Nkinematics(phases%length),source = 0) + do ph = 1,phases%length + phase => phases%get(ph) + kinematics => phase%get('kinematics',defaultVal=emptyList) + phase_Nkinematics(ph) = kinematics%length + enddo + + allocate(phase_kinematics(maxval(phase_Nkinematics),phases%length), source = KINEMATICS_undefined_ID) + + if(maxval(phase_Nkinematics) /= 0) then + where(kinematics_cleavage_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_cleavage_opening_ID + where(kinematics_slipplane_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_slipplane_opening_ID + where(kinematics_thermal_expansion_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_thermal_expansion_ID + endif + +end subroutine eigendeformation_init + + end submodule eigendeformation diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index f6c010485..9b8334c99 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -2,6 +2,41 @@ submodule(phase:mechanics) plastic interface + module function plastic_none_init() result(myPlasticity) + logical, dimension(:), allocatable :: & + myPlasticity + end function plastic_none_init + + module function plastic_isotropic_init() result(myPlasticity) + logical, dimension(:), allocatable :: & + myPlasticity + end function plastic_isotropic_init + + module function plastic_phenopowerlaw_init() result(myPlasticity) + logical, dimension(:), allocatable :: & + myPlasticity + end function plastic_phenopowerlaw_init + + module function plastic_kinehardening_init() result(myPlasticity) + logical, dimension(:), allocatable :: & + myPlasticity + end function plastic_kinehardening_init + + module function plastic_dislotwin_init() result(myPlasticity) + logical, dimension(:), allocatable :: & + myPlasticity + end function plastic_dislotwin_init + + module function plastic_dislotungsten_init() result(myPlasticity) + logical, dimension(:), allocatable :: & + myPlasticity + end function plastic_dislotungsten_init + + module function plastic_nonlocal_init() result(myPlasticity) + logical, dimension(:), allocatable :: & + myPlasticity + end function plastic_nonlocal_init + module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp @@ -188,6 +223,18 @@ submodule(phase:mechanics) plastic contains +module subroutine plastic_init + + where(plastic_none_init()) phase_plasticity = PLASTICITY_NONE_ID + where(plastic_isotropic_init()) phase_plasticity = PLASTICITY_ISOTROPIC_ID + where(plastic_phenopowerlaw_init()) phase_plasticity = PLASTICITY_PHENOPOWERLAW_ID + where(plastic_kinehardening_init()) phase_plasticity = PLASTICITY_KINEHARDENING_ID + where(plastic_dislotwin_init()) phase_plasticity = PLASTICITY_DISLOTWIN_ID + where(plastic_dislotungsten_init()) phase_plasticity = PLASTICITY_DISLOTUNGSTEN_ID + where(plastic_nonlocal_init()) phase_plasticity = PLASTICITY_NONLOCAL_ID + +end subroutine plastic_init + !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the velocity gradient ! ToDo: Discuss whether it makes sense if crystallite handles the configuration conversion, i.e. From 4f4adf7d6896584e6e4b39b63ee9bbb8dece0a0d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 27 Jan 2021 07:10:53 +0100 Subject: [PATCH 185/352] sorting according to physics --- src/homogenization.f90 | 2 - src/phase.f90 | 84 +------------ src/phase_mechanics.f90 | 141 +++++---------------- src/phase_mechanics_eigendeformation.f90 | 150 +++++++++++++++++++++++ src/phase_mechanics_plastic.f90 | 27 ++++ src/phase_mechanics_plastic_nonlocal.f90 | 1 - src/phase_thermal.f90 | 2 - 7 files changed, 209 insertions(+), 198 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 4738b3ad8..2255e83b0 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -145,8 +145,6 @@ module homogenization integer, intent(in) :: & ip, & !< integration point number el !< element number - integer :: & - co real(pReal) :: M end function damage_nonlocal_getMobility diff --git a/src/phase.f90 b/src/phase.f90 index d532e4596..c3696eda7 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -15,6 +15,7 @@ module phase use discretization use parallelization use HDF5_utilities + implicit none private @@ -255,8 +256,6 @@ module phase TDot end subroutine constitutive_thermal_getRate - - module subroutine plastic_nonlocal_updateCompatibility(orientation,instance,i,e) integer, intent(in) :: & instance, & @@ -266,54 +265,6 @@ module phase orientation !< crystal orientation end subroutine plastic_nonlocal_updateCompatibility - - module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) - real(pReal), dimension(3,3), intent(out) :: & - Li !< inleastic velocity gradient - real(pReal), dimension(3,3,3,3), intent(out) :: & - dLi_dMi !< derivative of Li with respect to Mandel stress - real(pReal), dimension(3,3), intent(in) :: & - Mi !< Mandel stress - integer, intent(in) :: & - instance, & - me - end subroutine plastic_isotropic_LiAndItsTangent - - module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, co, ip, el) - integer, intent(in) :: & - co, & !< grain number - ip, & !< integration point number - el !< element number - real(pReal), intent(in), dimension(3,3) :: & - S - real(pReal), intent(out), dimension(3,3) :: & - Ld !< damage velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) - end subroutine kinematics_cleavage_opening_LiAndItsTangent - - module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S, co, ip, el) - integer, intent(in) :: & - co, & !< grain number - ip, & !< integration point number - el !< element number - real(pReal), intent(in), dimension(3,3) :: & - S - real(pReal), intent(out), dimension(3,3) :: & - Ld !< damage velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) - end subroutine kinematics_slipplane_opening_LiAndItsTangent - - module subroutine thermalexpansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) - integer, intent(in) :: ph, me - !< element number - real(pReal), intent(out), dimension(3,3) :: & - Li !< thermal velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLi_dTstar !< derivative of Li with respect to Tstar (4th-order tensor defined to be zero) - end subroutine thermalexpansion_LiAndItsTangent - module subroutine plastic_dependentState(co,ip,el) integer, intent(in) :: & co, & !< component-ID of integration point @@ -350,7 +301,6 @@ module phase constitutive_forward, & constitutive_restore, & plastic_nonlocal_updateCompatibility, & - kinematics_active, & converged, & crystallite_init, & crystallite_stress, & @@ -424,38 +374,6 @@ subroutine constitutive_init end subroutine constitutive_init - -!-------------------------------------------------------------------------------------------------- -!> @brief checks if a kinematic mechanism is active or not -!-------------------------------------------------------------------------------------------------- -function kinematics_active(kinematics_label,kinematics_length) result(active_kinematics) - - character(len=*), intent(in) :: kinematics_label !< name of kinematic mechanism - integer, intent(in) :: kinematics_length !< max. number of kinematics in system - logical, dimension(:,:), allocatable :: active_kinematics - - class(tNode), pointer :: & - phases, & - phase, & - kinematics, & - kinematics_type - integer :: p,k - - phases => config_material%get('phase') - allocate(active_kinematics(kinematics_length,phases%length), source = .false. ) - do p = 1, phases%length - phase => phases%get(p) - kinematics => phase%get('kinematics',defaultVal=emptyList) - do k = 1, kinematics%length - kinematics_type => kinematics%get(k) - if(kinematics_type%get_asString('type') == kinematics_label) active_kinematics(k,p) = .true. - enddo - enddo - - -end function kinematics_active - - !-------------------------------------------------------------------------------------------------- !> @brief Allocate the components of the state structure for a given phase !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index fd8b9331b..dab9ddc88 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -57,7 +57,17 @@ submodule(phase) mechanics end subroutine plastic_init - + module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) + real(pReal), dimension(3,3), intent(out) :: & + Li !< inleastic velocity gradient + real(pReal), dimension(3,3,3,3), intent(out) :: & + dLi_dMi !< derivative of Li with respect to Mandel stress + real(pReal), dimension(3,3), intent(in) :: & + Mi !< Mandel stress + integer, intent(in) :: & + instance, & + me + end subroutine plastic_isotropic_LiAndItsTangent module function plastic_dotState(subdt,co,ip,el,ph,me) result(broken) @@ -85,6 +95,25 @@ submodule(phase) mechanics end function plastic_deltaState + module subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & + S, Fi, co, ip, el) + + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + real(pReal), intent(in), dimension(3,3) :: & + S !< 2nd Piola-Kirchhoff stress + real(pReal), intent(in), dimension(3,3) :: & + Fi !< intermediate deformation gradient + real(pReal), intent(out), dimension(3,3) :: & + Li !< intermediate velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLi_dS, & !< derivative of Li with respect to S + dLi_dFi + + end subroutine constitutive_LiAndItsTangents + module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & S, Fi, co, ip, el) @@ -173,8 +202,7 @@ module subroutine mech_init(phases) phase, & mech, & elastic, & - stiffDegradation, & - kinematics + stiffDegradation print'(/,a)', ' <<<+- constitutive_mech init -+>>>' @@ -318,31 +346,7 @@ module subroutine mech_init(phases) end subroutine mech_init -!-------------------------------------------------------------------------------------------------- -!> @brief checks if a plastic module is active or not -!-------------------------------------------------------------------------------------------------- -function plastic_active(plastic_label) result(active_plastic) - character(len=*), intent(in) :: plastic_label !< type of plasticity model - logical, dimension(:), allocatable :: active_plastic - - class(tNode), pointer :: & - phases, & - phase, & - mech, & - pl - integer :: ph - - phases => config_material%get('phase') - allocate(active_plastic(phases%length), source = .false. ) - do ph = 1, phases%length - phase => phases%get(ph) - mech => phase%get('mechanics') - pl => mech%get('plasticity') - if(pl%get_asString('type') == plastic_label) active_plastic(ph) = .true. - enddo - -end function plastic_active !-------------------------------------------------------------------------------------------------- @@ -486,7 +490,6 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) ierr, & ! error indicator for LAPACK o, & p, & - m, & ph, & me, & jacoCounterLp, & @@ -1503,86 +1506,4 @@ module subroutine constitutive_mech_setF(F,co,ip,el) end subroutine constitutive_mech_setF -!-------------------------------------------------------------------------------------------------- -!> @brief contains the constitutive equation for calculating the velocity gradient -! ToDo: MD: S is Mi? -!-------------------------------------------------------------------------------------------------- -subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & - S, Fi, co, ip, el) - - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - real(pReal), intent(in), dimension(3,3) :: & - S !< 2nd Piola-Kirchhoff stress - real(pReal), intent(in), dimension(3,3) :: & - Fi !< intermediate deformation gradient - real(pReal), intent(out), dimension(3,3) :: & - Li !< intermediate velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLi_dS, & !< derivative of Li with respect to S - dLi_dFi - - real(pReal), dimension(3,3) :: & - my_Li, & !< intermediate velocity gradient - FiInv, & - temp_33 - real(pReal), dimension(3,3,3,3) :: & - my_dLi_dS - real(pReal) :: & - detFi - integer :: & - k, i, j, & - instance, of, me, ph - - Li = 0.0_pReal - dLi_dS = 0.0_pReal - dLi_dFi = 0.0_pReal - - plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) - case (PLASTICITY_isotropic_ID) plasticityType - of = material_phasememberAt(co,ip,el) - instance = phase_plasticityInstance(material_phaseAt(co,el)) - call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,instance,of) - case default plasticityType - my_Li = 0.0_pReal - my_dLi_dS = 0.0_pReal - end select plasticityType - - Li = Li + my_Li - dLi_dS = dLi_dS + my_dLi_dS - - KinematicsLoop: do k = 1, phase_Nkinematics(material_phaseAt(co,el)) - kinematicsType: select case (phase_kinematics(k,material_phaseAt(co,el))) - case (KINEMATICS_cleavage_opening_ID) kinematicsType - call kinematics_cleavage_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) - case (KINEMATICS_slipplane_opening_ID) kinematicsType - call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) - case (KINEMATICS_thermal_expansion_ID) kinematicsType - me = material_phaseMemberAt(co,ip,el) - ph = material_phaseAt(co,el) - call thermalexpansion_LiAndItsTangent(my_Li, my_dLi_dS, ph,me) - case default kinematicsType - my_Li = 0.0_pReal - my_dLi_dS = 0.0_pReal - end select kinematicsType - Li = Li + my_Li - dLi_dS = dLi_dS + my_dLi_dS - enddo KinematicsLoop - - FiInv = math_inv33(Fi) - detFi = math_det33(Fi) - Li = matmul(matmul(Fi,Li),FiInv)*detFi !< push forward to intermediate configuration - temp_33 = matmul(FiInv,Li) - - do i = 1,3; do j = 1,3 - dLi_dS(1:3,1:3,i,j) = matmul(matmul(Fi,dLi_dS(1:3,1:3,i,j)),FiInv)*detFi - dLi_dFi(1:3,1:3,i,j) = dLi_dFi(1:3,1:3,i,j) + Li*FiInv(j,i) - dLi_dFi(1:3,i,1:3,j) = dLi_dFi(1:3,i,1:3,j) + math_I3*temp_33(j,i) + Li*FiInv(j,i) - enddo; enddo - -end subroutine constitutive_LiAndItsTangents - end submodule mechanics - diff --git a/src/phase_mechanics_eigendeformation.f90 b/src/phase_mechanics_eigendeformation.f90 index 98bc8481f..d1f581d5a 100644 --- a/src/phase_mechanics_eigendeformation.f90 +++ b/src/phase_mechanics_eigendeformation.f90 @@ -15,6 +15,42 @@ submodule(phase:mechanics) eigendeformation integer, intent(in) :: kinematics_length logical, dimension(:,:), allocatable :: myKinematics end function kinematics_thermal_expansion_init + + module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, co, ip, el) + integer, intent(in) :: & + co, & !< grain number + ip, & !< integration point number + el !< element number + real(pReal), intent(in), dimension(3,3) :: & + S + real(pReal), intent(out), dimension(3,3) :: & + Ld !< damage velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) + end subroutine kinematics_cleavage_opening_LiAndItsTangent + + module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S, co, ip, el) + integer, intent(in) :: & + co, & !< grain number + ip, & !< integration point number + el !< element number + real(pReal), intent(in), dimension(3,3) :: & + S + real(pReal), intent(out), dimension(3,3) :: & + Ld !< damage velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) + end subroutine kinematics_slipplane_opening_LiAndItsTangent + + module subroutine thermalexpansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) + integer, intent(in) :: ph, me + !< element number + real(pReal), intent(out), dimension(3,3) :: & + Li !< thermal velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLi_dTstar !< derivative of Li with respect to Tstar (4th-order tensor defined to be zero) + end subroutine thermalexpansion_LiAndItsTangent + end interface @@ -54,4 +90,118 @@ module subroutine eigendeformation_init(phases) end subroutine eigendeformation_init + +!-------------------------------------------------------------------------------------------------- +!> @brief checks if a kinematic mechanism is active or not +!-------------------------------------------------------------------------------------------------- +function kinematics_active(kinematics_label,kinematics_length) result(active_kinematics) + + character(len=*), intent(in) :: kinematics_label !< name of kinematic mechanism + integer, intent(in) :: kinematics_length !< max. number of kinematics in system + logical, dimension(:,:), allocatable :: active_kinematics + + class(tNode), pointer :: & + phases, & + phase, & + kinematics, & + kinematics_type + integer :: p,k + + phases => config_material%get('phase') + allocate(active_kinematics(kinematics_length,phases%length), source = .false. ) + do p = 1, phases%length + phase => phases%get(p) + kinematics => phase%get('kinematics',defaultVal=emptyList) + do k = 1, kinematics%length + kinematics_type => kinematics%get(k) + if(kinematics_type%get_asString('type') == kinematics_label) active_kinematics(k,p) = .true. + enddo + enddo + + +end function kinematics_active + + +!-------------------------------------------------------------------------------------------------- +!> @brief contains the constitutive equation for calculating the velocity gradient +! ToDo: MD: S is Mi? +!-------------------------------------------------------------------------------------------------- +module subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & + S, Fi, co, ip, el) + + integer, intent(in) :: & + co, & !< component-ID of integration point + ip, & !< integration point + el !< element + real(pReal), intent(in), dimension(3,3) :: & + S !< 2nd Piola-Kirchhoff stress + real(pReal), intent(in), dimension(3,3) :: & + Fi !< intermediate deformation gradient + real(pReal), intent(out), dimension(3,3) :: & + Li !< intermediate velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLi_dS, & !< derivative of Li with respect to S + dLi_dFi + + real(pReal), dimension(3,3) :: & + my_Li, & !< intermediate velocity gradient + FiInv, & + temp_33 + real(pReal), dimension(3,3,3,3) :: & + my_dLi_dS + real(pReal) :: & + detFi + integer :: & + k, i, j, & + instance, of, me, ph + + Li = 0.0_pReal + dLi_dS = 0.0_pReal + dLi_dFi = 0.0_pReal + + plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) + case (PLASTICITY_isotropic_ID) plasticityType + of = material_phasememberAt(co,ip,el) + instance = phase_plasticityInstance(material_phaseAt(co,el)) + call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,instance,of) + case default plasticityType + my_Li = 0.0_pReal + my_dLi_dS = 0.0_pReal + end select plasticityType + + Li = Li + my_Li + dLi_dS = dLi_dS + my_dLi_dS + + KinematicsLoop: do k = 1, phase_Nkinematics(material_phaseAt(co,el)) + kinematicsType: select case (phase_kinematics(k,material_phaseAt(co,el))) + case (KINEMATICS_cleavage_opening_ID) kinematicsType + call kinematics_cleavage_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) + case (KINEMATICS_slipplane_opening_ID) kinematicsType + call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) + case (KINEMATICS_thermal_expansion_ID) kinematicsType + me = material_phaseMemberAt(co,ip,el) + ph = material_phaseAt(co,el) + call thermalexpansion_LiAndItsTangent(my_Li, my_dLi_dS, ph,me) + case default kinematicsType + my_Li = 0.0_pReal + my_dLi_dS = 0.0_pReal + end select kinematicsType + Li = Li + my_Li + dLi_dS = dLi_dS + my_dLi_dS + enddo KinematicsLoop + + FiInv = math_inv33(Fi) + detFi = math_det33(Fi) + Li = matmul(matmul(Fi,Li),FiInv)*detFi !< push forward to intermediate configuration + temp_33 = matmul(FiInv,Li) + + do i = 1,3; do j = 1,3 + dLi_dS(1:3,1:3,i,j) = matmul(matmul(Fi,dLi_dS(1:3,1:3,i,j)),FiInv)*detFi + dLi_dFi(1:3,1:3,i,j) = dLi_dFi(1:3,1:3,i,j) + Li*FiInv(j,i) + dLi_dFi(1:3,i,1:3,j) = dLi_dFi(1:3,i,1:3,j) + math_I3*temp_33(j,i) + Li*FiInv(j,i) + enddo; enddo + +end subroutine constitutive_LiAndItsTangents + + end submodule eigendeformation diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index 9b8334c99..b03683061 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -439,4 +439,31 @@ module function plastic_deltaState(co, ip, el, ph, of) result(broken) end function plastic_deltaState + +!-------------------------------------------------------------------------------------------------- +!> @brief checks if a plastic module is active or not +!-------------------------------------------------------------------------------------------------- +function plastic_active(plastic_label) result(active_plastic) + + character(len=*), intent(in) :: plastic_label !< type of plasticity model + logical, dimension(:), allocatable :: active_plastic + + class(tNode), pointer :: & + phases, & + phase, & + mech, & + pl + integer :: ph + + phases => config_material%get('phase') + allocate(active_plastic(phases%length), source = .false. ) + do ph = 1, phases%length + phase => phases%get(ph) + mech => phase%get('mechanics') + pl => mech%get('plasticity') + if(pl%get_asString('type') == plastic_label) active_plastic(ph) = .true. + enddo + +end function plastic_active + end submodule plastic diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 index d0ed01cf0..2f566c515 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanics_plastic_nonlocal.f90 @@ -988,7 +988,6 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & el !< current element number integer :: & - ph, & ns, & !< short notation for the total number of active slip systems c, & !< character of dislocation t, & !< type of dislocation diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 621bb4f4a..04c35a311 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -187,8 +187,6 @@ module function thermal_stress(Delta_t,ph,me) result(converged_) integer, intent(in) :: ph, me logical :: converged_ - integer :: so - converged_ = .not. integrateThermalState(Delta_t,ph,me) From 52d7d374017eb0eca27772258cf00110d7c53f18 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 27 Jan 2021 08:45:54 +0100 Subject: [PATCH 186/352] cleaning --- src/phase.f90 | 18 +----------------- src/phase_mechanics.f90 | 19 +++++++++---------- src/phase_mechanics_plastic.f90 | 22 +++++++++++----------- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index c3696eda7..af7f577af 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -19,13 +19,6 @@ module phase implicit none private - enum, bind(c); enumerator :: & - KINEMATICS_UNDEFINED_ID ,& - KINEMATICS_CLEAVAGE_OPENING_ID, & - KINEMATICS_SLIPPLANE_OPENING_ID, & - KINEMATICS_THERMAL_EXPANSION_ID - end enum - type(rotation), dimension(:,:,:), allocatable :: & crystallite_orientation !< current orientation @@ -64,10 +57,6 @@ module phase type(tDebugOptions) :: debugCrystallite - - integer(kind(KINEMATICS_UNDEFINED_ID)), dimension(:,:), allocatable :: & - phase_kinematics !< active kinematic mechanisms of each phase - integer, dimension(:), allocatable, public :: & !< ToDo: should be protected (bug in Intel compiler) thermal_Nsources, & phase_Nsources, & !< number of source mechanisms active in each phase @@ -317,15 +306,10 @@ module phase constitutive_mech_getP, & constitutive_mech_setF, & constitutive_mech_getF, & - constitutive_windForward, & - KINEMATICS_UNDEFINED_ID ,& - KINEMATICS_CLEAVAGE_OPENING_ID, & - KINEMATICS_SLIPPLANE_OPENING_ID, & - KINEMATICS_THERMAL_EXPANSION_ID + constitutive_windForward contains - !-------------------------------------------------------------------------------------------------- !> @brief Initialze constitutive models for individual physics !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index dab9ddc88..0408f91d0 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -15,9 +15,15 @@ submodule(phase) mechanics PLASTICITY_KINEHARDENING_ID, & PLASTICITY_DISLOTWIN_ID, & PLASTICITY_DISLOTUNGSTEN_ID, & - PLASTICITY_NONLOCAL_ID + PLASTICITY_NONLOCAL_ID, & + KINEMATICS_UNDEFINED_ID, & + KINEMATICS_CLEAVAGE_OPENING_ID, & + KINEMATICS_SLIPPLANE_OPENING_ID, & + KINEMATICS_THERMAL_EXPANSION_ID end enum + integer(kind(KINEMATICS_UNDEFINED_ID)), dimension(:,:), allocatable :: & + phase_kinematics integer(kind(ELASTICITY_UNDEFINED_ID)), dimension(:), allocatable :: & phase_elasticity !< elasticity of each phase integer(kind(STIFFNESS_DEGRADATION_UNDEFINED_ID)), dimension(:,:), allocatable :: & @@ -53,8 +59,6 @@ submodule(phase) mechanics end subroutine eigendeformation_init module subroutine plastic_init - - end subroutine plastic_init module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) @@ -82,17 +86,15 @@ submodule(phase) mechanics logical :: broken end function plastic_dotState - module function plastic_deltaState(co, ip, el, ph, of) result(broken) - + module function plastic_deltaState(co, ip, el, ph, me) result(broken) integer, intent(in) :: & co, & !< component-ID of integration point ip, & !< integration point el, & !< element ph, & - of + me logical :: & broken - end function plastic_deltaState module subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & @@ -346,9 +348,6 @@ module subroutine mech_init(phases) end subroutine mech_init - - - !-------------------------------------------------------------------------------------------------- !> @brief returns the 2nd Piola-Kirchhoff stress tensor and its tangent with respect to !> the elastic and intermediate deformation gradients using Hooke's law diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index b03683061..95bcbb650 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -388,14 +388,14 @@ end subroutine plastic_dependentState !> @brief for constitutive models having an instantaneous change of state !> will return false if delta state is not needed/supported by the constitutive model !-------------------------------------------------------------------------------------------------- -module function plastic_deltaState(co, ip, el, ph, of) result(broken) +module function plastic_deltaState(co, ip, el, ph, me) result(broken) integer, intent(in) :: & - co, & !< component-ID of integration point + co, & !< component-ID of integration point ip, & !< integration point el, & !< element ph, & - of + me logical :: & broken @@ -407,19 +407,19 @@ module function plastic_deltaState(co, ip, el, ph, of) result(broken) mySize - Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,of)),& - constitutive_mech_Fi(ph)%data(1:3,1:3,of)),constitutive_mech_S(ph)%data(1:3,1:3,of)) + Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,me)),& + constitutive_mech_Fi(ph)%data(1:3,1:3,me)),constitutive_mech_S(ph)%data(1:3,1:3,me)) instance = phase_plasticityInstance(ph) plasticityType: select case (phase_plasticity(ph)) case (PLASTICITY_KINEHARDENING_ID) plasticityType - call plastic_kinehardening_deltaState(Mp,instance,of) - broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,of))) + call plastic_kinehardening_deltaState(Mp,instance,me) + broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,me))) case (PLASTICITY_NONLOCAL_ID) plasticityType - call plastic_nonlocal_deltaState(Mp,instance,of,ip,el) - broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,of))) + call plastic_nonlocal_deltaState(Mp,instance,me,ip,el) + broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,me))) case default broken = .false. @@ -432,8 +432,8 @@ module function plastic_deltaState(co, ip, el, ph, of) result(broken) myOffset = plasticState(ph)%offsetDeltaState mySize = plasticState(ph)%sizeDeltaState - plasticState(ph)%state(myOffset + 1:myOffset + mySize,of) = & - plasticState(ph)%state(myOffset + 1:myOffset + mySize,of) + plasticState(ph)%deltaState(1:mySize,of) + plasticState(ph)%state(myOffset + 1:myOffset + mySize,me) = & + plasticState(ph)%state(myOffset + 1:myOffset + mySize,me) + plasticState(ph)%deltaState(1:mySize,me) end select endif From 8ec385140cc6205fbe8d5ab645af16995762f278 Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 27 Jan 2021 09:49:46 +0100 Subject: [PATCH 187/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-373-g81682494e --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2500cc420..bf5540b87 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-370-ga0a700914 +v3.0.0-alpha2-373-g81682494e From 0d3b9b9f2a83c9e5439fd17f90f6b92599438cf9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 27 Jan 2021 10:44:03 +0100 Subject: [PATCH 188/352] correct reporting --- src/homogenization_damage.f90 | 4 ++-- src/homogenization_mechanics.f90 | 2 +- src/homogenization_mechanics_RGC.f90 | 2 +- src/homogenization_mechanics_isostrain.f90 | 2 +- src/homogenization_mechanics_none.f90 | 2 +- src/homogenization_thermal.f90 | 4 +++- src/phase.f90 | 2 +- src/phase_damage.f90 | 3 +++ src/phase_damage_anisobrittle.f90 | 2 +- src/phase_damage_anisoductile.f90 | 2 +- src/phase_damage_isobrittle.f90 | 2 +- src/phase_damage_isoductile.f90 | 2 +- src/phase_mechanics.f90 | 2 +- src/phase_mechanics_eigendeformation.f90 | 2 +- src/phase_mechanics_eigendeformation_cleavageopening.f90 | 2 +- src/phase_mechanics_eigendeformation_slipplaneopening.f90 | 2 +- src/phase_mechanics_eigendeformation_thermalexpansion.f90 | 2 +- src/phase_mechanics_plastic.f90 | 3 +++ src/phase_mechanics_plastic_dislotungsten.f90 | 2 +- src/phase_mechanics_plastic_dislotwin.f90 | 2 +- src/phase_mechanics_plastic_isotropic.f90 | 2 +- src/phase_mechanics_plastic_kinehardening.f90 | 2 +- src/phase_mechanics_plastic_none.f90 | 2 +- src/phase_mechanics_plastic_nonlocal.f90 | 2 +- src/phase_mechanics_plastic_phenopowerlaw.f90 | 2 +- src/phase_thermal.f90 | 2 +- src/phase_thermal_dissipation.f90 | 2 +- src/phase_thermal_externalheat.f90 | 2 +- 28 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index 3115e6a6f..ba021a0e0 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -34,8 +34,8 @@ module subroutine damage_init() integer :: ho - print'(/,a)', ' <<<+- homogenization_damage init -+>>>' - + print'(/,a)', ' <<<+- homogenization:damage init -+>>>' + print'(/,a)', ' <<<+- homogenization:damage:isodamage init -+>>>' configHomogenizations => config_material%get('homogenization') allocate(param(configHomogenizations%length)) diff --git a/src/homogenization_mechanics.f90 b/src/homogenization_mechanics.f90 index 3d889e298..4eae859ee 100644 --- a/src/homogenization_mechanics.f90 +++ b/src/homogenization_mechanics.f90 @@ -86,7 +86,7 @@ module subroutine mech_init(num_homog) class(tNode), pointer :: & num_homogMech - print'(/,a)', ' <<<+- homogenization_mech init -+>>>' + print'(/,a)', ' <<<+- homogenization:mechanics init -+>>>' allocate(homogenization_dPdF(3,3,3,3,discretization_nIPs*discretization_Nelems), source=0.0_pReal) homogenization_F0 = spread(math_I3,3,discretization_nIPs*discretization_Nelems) ! initialize to identity diff --git a/src/homogenization_mechanics_RGC.f90 b/src/homogenization_mechanics_RGC.f90 index 6f76fe788..89a84314b 100644 --- a/src/homogenization_mechanics_RGC.f90 +++ b/src/homogenization_mechanics_RGC.f90 @@ -88,7 +88,7 @@ module subroutine mech_RGC_init(num_homogMech) homog, & homogMech - print'(/,a)', ' <<<+- homogenization_mech_rgc init -+>>>' + print'(/,a)', ' <<<+- homogenization:mechanics:RGC init -+>>>' Ninstances = count(homogenization_type == HOMOGENIZATION_RGC_ID) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) diff --git a/src/homogenization_mechanics_isostrain.f90 b/src/homogenization_mechanics_isostrain.f90 index 699000cc8..9634b2a38 100644 --- a/src/homogenization_mechanics_isostrain.f90 +++ b/src/homogenization_mechanics_isostrain.f90 @@ -37,7 +37,7 @@ module subroutine mech_isostrain_init homog, & homogMech - print'(/,a)', ' <<<+- homogenization_mech_isostrain init -+>>>' + print'(/,a)', ' <<<+- homogenization:mechanics:isostrain init -+>>>' Ninstances = count(homogenization_type == HOMOGENIZATION_ISOSTRAIN_ID) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) diff --git a/src/homogenization_mechanics_none.f90 b/src/homogenization_mechanics_none.f90 index 195e388f9..ebe2ea8f1 100644 --- a/src/homogenization_mechanics_none.f90 +++ b/src/homogenization_mechanics_none.f90 @@ -18,7 +18,7 @@ module subroutine mech_none_init h, & Nmaterialpoints - print'(/,a)', ' <<<+- homogenization_mech_none init -+>>>' + print'(/,a)', ' <<<+- homogenization:mechanics:none init -+>>>' Ninstances = count(homogenization_type == HOMOGENIZATION_NONE_ID) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index dc5182dbf..b7170e6ec 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -34,7 +34,9 @@ module subroutine thermal_init() integer :: ho - print'(/,a)', ' <<<+- homogenization_thermal init -+>>>' + print'(/,a)', ' <<<+- homogenization:thermal init -+>>>' + print'(/,a)', ' <<<+- homogenization:thermal:isotemperature init -+>>>' + configHomogenizations => config_material%get('homogenization') diff --git a/src/phase.f90 b/src/phase.f90 index af7f577af..dd14e0831 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -323,7 +323,7 @@ subroutine constitutive_init phases - print'(/,a)', ' <<<+- constitutive init -+>>>'; flush(IO_STDOUT) + print'(/,a)', ' <<<+- phase init -+>>>'; flush(IO_STDOUT) debug_constitutive => config_debug%get('constitutive', defaultVal=emptyList) debugConstitutive%basic = debug_constitutive%contains('basic') diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 6c1a0b8d0..014347c1a 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -157,6 +157,9 @@ module subroutine damage_init phase, & sources + + print'(/,a)', ' <<<+- phase:damage init -+>>>' + phases => config_material%get('phase') allocate(current(phases%length)) diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index f78a0ec99..2ae5ca951 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -49,7 +49,7 @@ module function anisobrittle_init(source_length) result(mySources) integer, dimension(:), allocatable :: N_cl character(len=pStringLen) :: extmsg = '' - print'(/,a)', ' <<<+- source_damage_anisoBrittle init -+>>>' + print'(/,a)', ' <<<+- phase:damage:anisobrittle init -+>>>' mySources = source_active('damage_anisoBrittle',source_length) Ninstances = count(mySources) diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index f5e8d3795..8d5904e6b 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -44,7 +44,7 @@ module function anisoductile_init(source_length) result(mySources) integer, dimension(:), allocatable :: N_sl character(len=pStringLen) :: extmsg = '' - print'(/,a)', ' <<<+- source_damage_anisoDuctile init -+>>>' + print'(/,a)', ' <<<+- phase:damage:anisoductile init -+>>>' mySources = source_active('damage_anisoDuctile',source_length) Ninstances = count(mySources) diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 5a01a425d..091377171 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -39,7 +39,7 @@ module function isobrittle_init(source_length) result(mySources) integer :: Ninstances,sourceOffset,Nconstituents,p character(len=pStringLen) :: extmsg = '' - print'(/,a)', ' <<<+- source_damage_isoBrittle init -+>>>' + print'(/,a)', ' <<<+- phase:damage:isobrittle init -+>>>' mySources = source_active('damage_isoBrittle',source_length) Ninstances = count(mySources) diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index fe5ca93ed..6f0a2d0fb 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -41,7 +41,7 @@ module function isoductile_init(source_length) result(mySources) integer :: Ninstances,sourceOffset,Nconstituents,p character(len=pStringLen) :: extmsg = '' - print'(/,a)', ' <<<+- source_damage_isoDuctile init -+>>>' + print'(/,a)', ' <<<+- phase:damage:isoductile init -+>>>' mySources = source_active('damage_isoDuctile',source_length) Ninstances = count(mySources) diff --git a/src/phase_mechanics.f90 b/src/phase_mechanics.f90 index 0408f91d0..a84c1a385 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanics.f90 @@ -206,7 +206,7 @@ module subroutine mech_init(phases) elastic, & stiffDegradation - print'(/,a)', ' <<<+- constitutive_mech init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics init -+>>>' !------------------------------------------------------------------------------------------------- ! initialize elasticity (hooke) !ToDO: Maybe move to elastic submodule along with function homogenizedC? diff --git a/src/phase_mechanics_eigendeformation.f90 b/src/phase_mechanics_eigendeformation.f90 index d1f581d5a..45cfd82d3 100644 --- a/src/phase_mechanics_eigendeformation.f90 +++ b/src/phase_mechanics_eigendeformation.f90 @@ -68,7 +68,7 @@ module subroutine eigendeformation_init(phases) phase, & kinematics - print'(/,a)', ' <<<+- phase_mechanics_eigendeformation init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:eigendeformation init -+>>>' !-------------------------------------------------------------------------------------------------- ! initialize kinematic mechanisms diff --git a/src/phase_mechanics_eigendeformation_cleavageopening.f90 b/src/phase_mechanics_eigendeformation_cleavageopening.f90 index 185aee520..59be7837a 100644 --- a/src/phase_mechanics_eigendeformation_cleavageopening.f90 +++ b/src/phase_mechanics_eigendeformation_cleavageopening.f90 @@ -44,7 +44,7 @@ module function kinematics_cleavage_opening_init(kinematics_length) result(myKin kinematics, & kinematic_type - print'(/,a)', ' <<<+- kinematics_cleavage_opening init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:cleavageopening init -+>>>' myKinematics = kinematics_active('cleavage_opening',kinematics_length) Ninstances = count(myKinematics) diff --git a/src/phase_mechanics_eigendeformation_slipplaneopening.f90 b/src/phase_mechanics_eigendeformation_slipplaneopening.f90 index 8b8b1dd29..a144d39a6 100644 --- a/src/phase_mechanics_eigendeformation_slipplaneopening.f90 +++ b/src/phase_mechanics_eigendeformation_slipplaneopening.f90 @@ -49,7 +49,7 @@ module function kinematics_slipplane_opening_init(kinematics_length) result(myKi kinematics, & kinematic_type - print'(/,a)', ' <<<+- kinematics_slipplane init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:slipplaneopening init -+>>>' myKinematics = kinematics_active('slipplane_opening',kinematics_length) Ninstances = count(myKinematics) diff --git a/src/phase_mechanics_eigendeformation_thermalexpansion.f90 b/src/phase_mechanics_eigendeformation_thermalexpansion.f90 index 7a6a7daa3..6630f0eb7 100644 --- a/src/phase_mechanics_eigendeformation_thermalexpansion.f90 +++ b/src/phase_mechanics_eigendeformation_thermalexpansion.f90 @@ -36,7 +36,7 @@ module function kinematics_thermal_expansion_init(kinematics_length) result(myKi kinematics, & kinematic_type - print'(/,a)', ' <<<+- kinematics_thermal_expansion init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:thermalexpansion init -+>>>' myKinematics = kinematics_active('thermal_expansion',kinematics_length) Ninstances = count(myKinematics) diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanics_plastic.f90 index 95bcbb650..fff1fbdcf 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanics_plastic.f90 @@ -225,6 +225,9 @@ contains module subroutine plastic_init + + print'(/,a)', ' <<<+- phase:mechanics:plastic init -+>>>' + where(plastic_none_init()) phase_plasticity = PLASTICITY_NONE_ID where(plastic_isotropic_init()) phase_plasticity = PLASTICITY_ISOTROPIC_ID where(plastic_phenopowerlaw_init()) phase_plasticity = PLASTICITY_PHENOPOWERLAW_ID diff --git a/src/phase_mechanics_plastic_dislotungsten.f90 b/src/phase_mechanics_plastic_dislotungsten.f90 index ee0dfa9da..a47132c63 100644 --- a/src/phase_mechanics_plastic_dislotungsten.f90 +++ b/src/phase_mechanics_plastic_dislotungsten.f90 @@ -97,7 +97,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- plastic_dislotungsten init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:plastic:dislotungsten init -+>>>' myPlasticity = plastic_active('dislotungsten') Ninstances = count(myPlasticity) diff --git a/src/phase_mechanics_plastic_dislotwin.f90 b/src/phase_mechanics_plastic_dislotwin.f90 index 1ad1957ec..9f7464323 100644 --- a/src/phase_mechanics_plastic_dislotwin.f90 +++ b/src/phase_mechanics_plastic_dislotwin.f90 @@ -144,7 +144,7 @@ module function plastic_dislotwin_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- plastic_dislotwin init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:plastic:dislotwin init -+>>>' myPlasticity = plastic_active('dislotwin') Ninstances = count(myPlasticity) diff --git a/src/phase_mechanics_plastic_isotropic.f90 b/src/phase_mechanics_plastic_isotropic.f90 index e7b72fcd2..6789e74b4 100644 --- a/src/phase_mechanics_plastic_isotropic.f90 +++ b/src/phase_mechanics_plastic_isotropic.f90 @@ -68,7 +68,7 @@ module function plastic_isotropic_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- plastic_isotropic init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:plastic:isotropic init -+>>>' myPlasticity = plastic_active('isotropic') Ninstances = count(myPlasticity) diff --git a/src/phase_mechanics_plastic_kinehardening.f90 b/src/phase_mechanics_plastic_kinehardening.f90 index 034e5fd32..919302bc1 100644 --- a/src/phase_mechanics_plastic_kinehardening.f90 +++ b/src/phase_mechanics_plastic_kinehardening.f90 @@ -80,7 +80,7 @@ module function plastic_kinehardening_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- plastic_kinehardening init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:plastic:kinehardening init -+>>>' myPlasticity = plastic_active('kinehardening') Ninstances = count(myPlasticity) diff --git a/src/phase_mechanics_plastic_none.f90 b/src/phase_mechanics_plastic_none.f90 index 5c79c1b1e..b8d1678eb 100644 --- a/src/phase_mechanics_plastic_none.f90 +++ b/src/phase_mechanics_plastic_none.f90 @@ -25,7 +25,7 @@ module function plastic_none_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- plastic_none init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:plastic:none init -+>>>' phases => config_material%get('phase') allocate(myPlasticity(phases%length), source = .false.) diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanics_plastic_nonlocal.f90 index 2f566c515..693ffcf93 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanics_plastic_nonlocal.f90 @@ -187,7 +187,7 @@ module function plastic_nonlocal_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- plastic_nonlocal init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:plastic:nonlocal init -+>>>' myPlasticity = plastic_active('nonlocal') Ninstances = count(myPlasticity) diff --git a/src/phase_mechanics_plastic_phenopowerlaw.f90 b/src/phase_mechanics_plastic_phenopowerlaw.f90 index 1d91a97fb..ea2f53100 100644 --- a/src/phase_mechanics_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanics_plastic_phenopowerlaw.f90 @@ -89,7 +89,7 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- plastic_phenopowerlaw init -+>>>' + print'(/,a)', ' <<<+- phase:mechanics:plastic:phenopowerlaw init -+>>>' myPlasticity = plastic_active('phenopowerlaw') Ninstances = count(myPlasticity) diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 04c35a311..d5d52b010 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -77,7 +77,7 @@ module subroutine thermal_init(phases) Nconstituents - print'(/,a)', ' <<<+- constitutive_thermal init -+>>>' + print'(/,a)', ' <<<+- phase:thermal init -+>>>' allocate(current(phases%length)) diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index 2ac444f4a..7a043308d 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -33,7 +33,7 @@ module function dissipation_init(source_length) result(mySources) src integer :: Ninstances,so,Nconstituents,ph - print'(/,a)', ' <<<+- thermal_dissipation init -+>>>' + print'(/,a)', ' <<<+- phase:thermal:dissipation init -+>>>' mySources = thermal_active('dissipation',source_length) diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index 60a4c3964..ddae6763b 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -40,7 +40,7 @@ module function externalheat_init(source_length) result(mySources) src integer :: Ninstances,so,Nconstituents,ph - print'(/,a)', ' <<<+- thermal_externalheat init -+>>>' + print'(/,a)', ' <<<+- phase:thermal:externalheat init -+>>>' mySources = thermal_active('externalheat',source_length) From 072e15faa772e7237d58b5b3f8e59d2592c2d6a1 Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 28 Jan 2021 19:00:36 +0100 Subject: [PATCH 189/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-401-g85cfa0bab --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index bf5540b87..de297f225 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-373-g81682494e +v3.0.0-alpha2-401-g85cfa0bab From cc18abb42d7b8b60e599a2cfe9588c533f6af30f Mon Sep 17 00:00:00 2001 From: "f.basile" Date: Tue, 2 Feb 2021 09:03:41 +0100 Subject: [PATCH 190/352] write marc displacements of nodes and IPs in HDF5 file --- PRIVATE | 2 +- src/CPFEM.f90 | 1 - src/DAMASK_marc.f90 | 46 +++--- src/element.f90 | 2 +- src/marc/discretization_marc.f90 | 263 ++++++++++++++++--------------- src/parallelization.f90 | 20 +-- 6 files changed, 167 insertions(+), 167 deletions(-) diff --git a/PRIVATE b/PRIVATE index 8b9836aaf..4b5636231 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 8b9836aaf5798727d96a316a2eb27df03bbd2d07 +Subproject commit 4b563623162f033b11d9d0ac95fc421de279f690 diff --git a/src/CPFEM.f90 b/src/CPFEM.f90 index 8a12bef76..e441339cb 100644 --- a/src/CPFEM.f90 +++ b/src/CPFEM.f90 @@ -72,7 +72,6 @@ contains !-------------------------------------------------------------------------------------------------- subroutine CPFEM_initAll - call parallelization_init call DAMASK_interface_init call prec_init call IO_init diff --git a/src/DAMASK_marc.f90 b/src/DAMASK_marc.f90 index 360c911ff..7abb0e746 100644 --- a/src/DAMASK_marc.f90 +++ b/src/DAMASK_marc.f90 @@ -7,20 +7,6 @@ !> @author Christoph Kords, Max-Planck-Institut für Eisenforschung GmbH !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH !> @brief Interfaces DAMASK with MSC.Marc -!> @details Usage: -!> @details - choose material as hypela2 -!> @details - set statevariable 2 to index of homogenization -!> @details - set statevariable 3 to index of microstructure -!> @details - use nonsymmetric option for solver (e.g. direct profile or multifrontal sparse, the latter seems to be faster!) -!> @details - in case of ddm (domain decomposition) a SYMMETRIC solver has to be used, i.e uncheck "non-symmetric" -!> @details Marc subroutines used: -!> @details - hypela2 -!> @details - uedinc -!> @details - flux -!> @details - quit -!> @details Marc common blocks included: -!> @details - concom: lovl, inc -!> @details - creeps: timinc !-------------------------------------------------------------------------------------------------- #define QUOTE(x) #x #define PASTE(x,y) x ## y @@ -65,14 +51,8 @@ subroutine DAMASK_interface_init print'(/,a)', ' Version: '//DAMASKVERSION - ! https://github.com/jeffhammond/HPCInfo/blob/master/docs/Preprocessor-Macros.md -#if __INTEL_COMPILER >= 1800 - print'(/,a)', ' Compiled with: '//compiler_version() - print'(a)', ' Compiler options: '//compiler_options() -#else - print'(/,a,i4.4,a,i8.8)', ' Compiled with Intel fortran version :', __INTEL_COMPILER,& - ', build date :', __INTEL_COMPILER_BUILD_DATE -#endif + print'(/,a)', ' Compiled with: '//compiler_version() + print'(a)', ' Compiler options: '//compiler_options() print'(/,a)', ' Compiled on: '//__DATE__//' at '//__TIME__ @@ -239,7 +219,7 @@ subroutine hypela2(d,g,e,de,s,t,dt,ngens,m,nn,kcus,matus,ndi,nshear,disp, & real(pReal), dimension(6) :: stress real(pReal), dimension(6,6) :: ddsdde integer :: computationMode, i, cp_en, node, CPnodeID - integer(4) :: defaultNumThreadsInt !< default value set by Marc + integer(pI32) :: defaultNumThreadsInt !< default value set by Marc integer(pInt), save :: & theInc = -1_pInt, & !< needs description @@ -250,13 +230,13 @@ subroutine hypela2(d,g,e,de,s,t,dt,ngens,m,nn,kcus,matus,ndi,nshear,disp, & logical, save :: & lastIncConverged = .false., & !< needs description outdatedByNewInc = .false., & !< needs description - CPFEM_init_done = .false., & !< remember whether init has been done already + CPFEM_init_done = .false., & !< remember whether init has been done already debug_basic = .true. class(tNode), pointer :: & debug_Marc ! pointer to Marc debug options if(debug_basic) then - print'(a,/,i8,i8,i2)', ' MSC.MARC information on shape of element(2), IP:', m, nn + print'(a,/,i8,i8,i2)', ' MSC.Marc information on shape of element(2), IP:', m, nn print'(a,2(i1))', ' Jacobian: ', ngens,ngens print'(a,i1)', ' Direct stress: ', ndi print'(a,i1)', ' Shear stress: ', nshear @@ -271,7 +251,7 @@ subroutine hypela2(d,g,e,de,s,t,dt,ngens,m,nn,kcus,matus,ndi,nshear,disp, & endif defaultNumThreadsInt = omp_get_num_threads() ! remember number of threads set by Marc - call omp_set_num_threads(1) ! no openMP + call omp_set_num_threads(1_pI32) ! no openMP if (.not. CPFEM_init_done) then CPFEM_init_done = .true. @@ -379,14 +359,28 @@ subroutine flux(f,ts,n,time) subroutine uedinc(inc,incsub) use prec use CPFEM + use discretization_marc implicit none integer, intent(in) :: inc, incsub + integer :: n, nqncomp, nqdatatype integer, save :: inc_written + real(pReal), allocatable, dimension(:,:) :: d_n #include QUOTE(PASTE(./marc/include/creeps,Marc4DAMASK)) ! creeps is needed for timinc (time increment) + if (inc > inc_written) then + allocate(d_n(3,size(mesh_FEM2DAMASK_node))) + do n = 1, size(d_n,2) + if (mesh_FEM2DAMASK_node(n) /= -1) then + call nodvar(1,n,d_n(1:3,mesh_FEM2DAMASK_node(n)),nqncomp,nqdatatype) + if(nqncomp == 2) d_n(3,mesh_FEM2DAMASK_node(n)) = 0.0_pReal + endif + enddo + + call discretization_marc_UpdateNodeAndIpCoords(d_n) call CPFEM_results(inc,cptim) + inc_written = inc endif diff --git a/src/element.f90 b/src/element.f90 index 722a7fd96..5b7af36bd 100644 --- a/src/element.f90 +++ b/src/element.f90 @@ -686,7 +686,7 @@ module element 1, 5,11, 7, 8,12,15,14, & 5, 2, 6,11,12, 9,13,15, & 7,11, 6, 3,14,15,13,10, & - 8,12,15, 4, 4, 9,13,10 & + 8,12,15,14, 4, 9,13,10 & #if !defined(__GFORTRAN__) ],shape(CELL6)) #else diff --git a/src/marc/discretization_marc.f90 b/src/marc/discretization_marc.f90 index 675e57bd3..d92623215 100644 --- a/src/marc/discretization_marc.f90 +++ b/src/marc/discretization_marc.f90 @@ -20,6 +20,14 @@ module discretization_marc implicit none private + real(pReal), public, protected :: & + mesh_unitlength !< physical length of one unit in mesh MD: needs systematic_name + + integer, dimension(:), allocatable, public, protected :: & + mesh_FEM2DAMASK_elem, & !< DAMASK element ID for Marc element ID MD: Needs systematic name + mesh_FEM2DAMASK_node !< DAMASK node ID for Marc node ID MD: needs systematic_name + + type tCellNodeDefinition integer, dimension(:,:), allocatable :: parents integer, dimension(:,:), allocatable :: weights @@ -27,15 +35,12 @@ module discretization_marc type(tCellNodeDefinition), dimension(:), allocatable :: cellNodeDefinition - real(pReal), public, protected :: & - mesh_unitlength !< physical length of one unit in mesh - - integer, dimension(:), allocatable, public :: & - mesh_FEM2DAMASK_elem, & !< DAMASK element ID for Marc element ID - mesh_FEM2DAMASK_node !< DAMASK node ID for Marc node ID + integer, dimension(:,:,:), allocatable :: & + connectivity_cell !< cell connectivity for each element,ip/cell public :: & - discretization_marc_init + discretization_marc_init, & + discretization_marc_UpdateNodeAndIpCoords contains @@ -45,25 +50,22 @@ contains !-------------------------------------------------------------------------------------------------- subroutine discretization_marc_init - real(pReal), dimension(:,:), allocatable :: & + real(pReal), dimension(:,:), allocatable :: & node0_elem, & !< node x,y,z coordinates (initially!) node0_cell type(tElement) :: elem - integer, dimension(:), allocatable :: & + integer, dimension(:), allocatable :: & materialAt integer:: & - Nnodes, & !< total number of nodes in the mesh Nelems, & !< total number of elements in the mesh debug_e, debug_i - real(pReal), dimension(:,:), allocatable :: & + real(pReal), dimension(:,:), allocatable :: & IP_reshaped - integer,dimension(:,:,:), allocatable :: & - connectivity_cell !< cell connectivity for each element,ip/cell - integer, dimension(:,:), allocatable :: & + integer, dimension(:,:), allocatable :: & connectivity_elem - real(pReal), dimension(:,:,:,:),allocatable :: & + real(pReal), dimension(:,:,:,:), allocatable :: & unscaledNormals class(tNode), pointer :: & @@ -90,18 +92,14 @@ subroutine discretization_marc_init allocate(cellNodeDefinition(elem%nNodes-1)) allocate(connectivity_cell(elem%NcellNodesPerCell,elem%nIPs,nElems)) + call buildCells(connectivity_cell,cellNodeDefinition,& elem,connectivity_elem) - allocate(node0_cell(3,maxval(connectivity_cell))) - call buildCellNodes(node0_cell,& - cellNodeDefinition,node0_elem) - allocate(IP_reshaped(3,elem%nIPs*nElems),source=0.0_pReal) - call buildIPcoordinates(IP_reshaped,reshape(connectivity_cell,[elem%NcellNodesPerCell,& - elem%nIPs*nElems]),node0_cell) + node0_cell = buildCellNodes(node0_elem) + + IP_reshaped = buildIPcoordinates(node0_cell) - call discretization_init(materialAt,& - IP_reshaped,& - node0_cell) + call discretization_init(materialAt, IP_reshaped, node0_cell) call writeGeometry(elem,connectivity_elem,& reshape(connectivity_cell,[elem%NcellNodesPerCell,elem%nIPs*nElems]),& @@ -109,55 +107,65 @@ subroutine discretization_marc_init !-------------------------------------------------------------------------------------------------- ! geometry information required by the nonlocal CP model - call geometry_plastic_nonlocal_setIPvolume(IPvolume(elem,node0_cell,connectivity_cell)) - unscaledNormals = IPareaNormal(elem,nElems,connectivity_cell,node0_cell) + call geometry_plastic_nonlocal_setIPvolume(IPvolume(elem,node0_cell)) + unscaledNormals = IPareaNormal(elem,nElems,node0_cell) call geometry_plastic_nonlocal_setIParea(norm2(unscaledNormals,1)) call geometry_plastic_nonlocal_setIPareaNormal(unscaledNormals/spread(norm2(unscaledNormals,1),1,3)) - call geometry_plastic_nonlocal_setIPneighborhood(IPneighborhood(elem,connectivity_cell)) + call geometry_plastic_nonlocal_setIPneighborhood(IPneighborhood(elem)) call geometry_plastic_nonlocal_results end subroutine discretization_marc_init +!-------------------------------------------------------------------------------------------------- +!> @brief Calculate and set current nodal and IP positions (including cell nodes) +!-------------------------------------------------------------------------------------------------- +subroutine discretization_marc_UpdateNodeAndIpCoords(d_n) + + real(pReal), dimension(:,:), intent(in) :: d_n + + real(pReal), dimension(:,:), allocatable :: node_cell + + + node_cell = buildCellNodes(discretization_NodeCoords0(1:3,1:maxval(mesh_FEM2DAMASK_node)) + d_n) + + call discretization_setNodeCoords(node_cell) + call discretization_setIPcoords(buildIPcoordinates(node_cell)) + +end subroutine discretization_marc_UpdateNodeAndIpCoords + + !-------------------------------------------------------------------------------------------------- !> @brief Write all information needed for the DADF5 geometry !-------------------------------------------------------------------------------------------------- subroutine writeGeometry(elem, & - connectivity_elem,connectivity_cell, & + connectivity_elem,connectivity_cell_reshaped, & coordinates_nodes,coordinates_points) type(tElement), intent(in) :: & elem integer, dimension(:,:), intent(in) :: & connectivity_elem, & - connectivity_cell + connectivity_cell_reshaped real(pReal), dimension(:,:), intent(in) :: & coordinates_nodes, & coordinates_points - integer, dimension(:,:), allocatable :: & - connectivity_temp - real(pReal), dimension(:,:), allocatable :: & - coordinates_temp call results_openJobFile call results_closeGroup(results_addGroup('geometry')) - connectivity_temp = connectivity_elem - call results_writeDataset('geometry',connectivity_temp,'T_e',& + call results_writeDataset('geometry',connectivity_elem,'T_e',& 'connectivity of the elements','-') - connectivity_temp = connectivity_cell - call results_writeDataset('geometry',connectivity_temp,'T_c', & + call results_writeDataset('geometry',connectivity_cell_reshaped,'T_c', & 'connectivity of the cells','-') call results_addAttribute('VTK_TYPE',elem%vtkType,'geometry/T_c') - coordinates_temp = coordinates_nodes - call results_writeDataset('geometry',coordinates_temp,'x_n', & + call results_writeDataset('geometry',coordinates_nodes,'x_n', & 'initial coordinates of the nodes','m') - coordinates_temp = coordinates_points - call results_writeDataset('geometry',coordinates_temp,'x_p', & + call results_writeDataset('geometry',coordinates_points,'x_p', & 'initial coordinates of the materialpoints (cell centers)','m') call results_closeJobFile @@ -186,13 +194,13 @@ subroutine inputRead(elem,node0_elem,connectivity_elem,materialAt) nElems integer, dimension(:), allocatable :: & matNumber !< material numbers for hypoelastic material - character(len=pStringLen), dimension(:), allocatable :: inputFile !< file content, separated per lines - character(len=pStringLen), dimension(:), allocatable :: & + inputFile, & !< file content, separated per lines nameElemSet integer, dimension(:,:), allocatable :: & mapElemSet !< list of elements in elementSet + inputFile = IO_readlines(trim(getSolverJobName())//trim(InputFileExtension)) call inputRead_fileFormat(fileFormatVersion, & inputFile) @@ -588,20 +596,20 @@ subroutine inputRead_elemType(elem, & mapElemtype = 1 ! Two-dimensional Plane Strain Triangle case ( '125') ! 155, 128 (need test) mapElemtype = 2 ! Two-dimensional Plane Strain triangle (155: cubic shape function, 125/128: second order isoparametric) - !case ( '11') ! need test - ! mapElemtype = 3 ! Arbitrary Quadrilateral Plane-strain + case ( '11') + mapElemtype = 3 ! Arbitrary Quadrilateral Plane-strain case ( '27') mapElemtype = 4 ! Plane Strain, Eight-node Distorted Quadrilateral case ( '54') mapElemtype = 5 ! Plane Strain, Eight-node Distorted Quadrilateral with reduced integration - !case ( '134') ! need test - ! mapElemtype = 6 ! Three-dimensional Four-node Tetrahedron + case ( '134') + mapElemtype = 6 ! Three-dimensional Four-node Tetrahedron !case ( '157') ! need test ! mapElemtype = 7 ! Three-dimensional, Low-order, Tetrahedron, Herrmann Formulations - !case ( '127') ! need test - ! mapElemtype = 8 ! Three-dimensional Ten-node Tetrahedron - !case ( '136') ! need test - ! mapElemtype = 9 ! Three-dimensional Arbitrarily Distorted Pentahedral + case ( '127') + mapElemtype = 8 ! Three-dimensional Ten-node Tetrahedron + case ( '136') + mapElemtype = 9 ! Three-dimensional Arbitrarily Distorted Pentahedral case ( '117') ! 123 (need test) mapElemtype = 10 ! Three-dimensional Arbitrarily Distorted linear hexahedral with reduced integration case ( '7') @@ -727,11 +735,11 @@ end subroutine inputRead_material !-------------------------------------------------------------------------------------------------- !> @brief Calculates cell node coordinates from element node coordinates !-------------------------------------------------------------------------------------------------- -pure subroutine buildCells(connectivity_cell,cellNodeDefinition, & +pure subroutine buildCells(connectivity,definition, & elem,connectivity_elem) - type(tCellNodeDefinition), dimension(:), intent(out) :: cellNodeDefinition ! definition of cell nodes for increasing number of parents - integer, dimension(:,:,:),intent(out) :: connectivity_cell + type(tCellNodeDefinition), dimension(:), intent(out) :: definition ! definition of cell nodes for increasing number of parents + integer, dimension(:,:,:),intent(out) :: connectivity type(tElement), intent(in) :: elem ! element definition integer, dimension(:,:), intent(in) :: connectivity_elem ! connectivity of the elements @@ -745,7 +753,7 @@ pure subroutine buildCells(connectivity_cell,cellNodeDefinition, & !--------------------------------------------------------------------------------------------------- ! initialize global connectivity to negative local connectivity - connectivity_cell = -spread(elem%cell,3,Nelem) ! local cell node ID + connectivity = -spread(elem%cell,3,Nelem) ! local cell node ID !--------------------------------------------------------------------------------------------------- ! set connectivity of cell nodes that coincide with FE nodes (defined by 1 parent node) @@ -753,9 +761,7 @@ pure subroutine buildCells(connectivity_cell,cellNodeDefinition, & do e = 1, Nelem do c = 1, elem%NcellNodes realNode: if (count(elem%cellNodeParentNodeWeights(:,c) /= 0) == 1) then - where(connectivity_cell(:,:,e) == -c) - connectivity_cell(:,:,e) = connectivity_elem(c,e) - end where + where(connectivity(:,:,e) == -c) connectivity(:,:,e) = connectivity_elem(c,e) endif realNode enddo enddo @@ -821,8 +827,8 @@ pure subroutine buildCells(connectivity_cell,cellNodeDefinition, & enddo i = uniqueRows(candidates_global(1:2*nParentNodes,:)) - allocate(cellNodeDefinition(nParentNodes-1)%parents(i,nParentNodes)) - allocate(cellNodeDefinition(nParentNodes-1)%weights(i,nParentNodes)) + allocate(definition(nParentNodes-1)%parents(i,nParentNodes)) + allocate(definition(nParentNodes-1)%weights(i,nParentNodes)) i = 1 n = 1 @@ -836,15 +842,15 @@ pure subroutine buildCells(connectivity_cell,cellNodeDefinition, & do while (n+j<= size(candidates_local)*Nelem) if (any(candidates_global(1:2*nParentNodes,n+j)/=candidates_global(1:2*nParentNodes,n))) exit - where (connectivity_cell(:,:,candidates_global(nParentNodes*2+1,n+j)) == -candidates_global(nParentNodes*2+2,n+j)) ! still locally defined - connectivity_cell(:,:,candidates_global(nParentNodes*2+1,n+j)) = nCellNode + 1 ! gets current new cell node id + where (connectivity(:,:,candidates_global(nParentNodes*2+1,n+j)) == -candidates_global(nParentNodes*2+2,n+j)) ! still locally defined + connectivity(:,:,candidates_global(nParentNodes*2+1,n+j)) = nCellNode + 1 ! gets current new cell node id end where j = j+1 enddo nCellNode = nCellNode + 1 - cellNodeDefinition(nParentNodes-1)%parents(i,:) = parentsAndWeights(:,1) - cellNodeDefinition(nParentNodes-1)%weights(i,:) = parentsAndWeights(:,2) + definition(nParentNodes-1)%parents(i,:) = parentsAndWeights(:,1) + definition(nParentNodes-1)%weights(i,:) = parentsAndWeights(:,2) i = i + 1 n = n+j enddo @@ -884,55 +890,62 @@ end subroutine buildCells !-------------------------------------------------------------------------------------------------- !> @brief Calculates cell node coordinates from element node coordinates !-------------------------------------------------------------------------------------------------- -pure subroutine buildCellNodes(node_cell, & - definition,node_elem) +pure function buildCellNodes(node_elem) - real(pReal), dimension(:,:), intent(out) :: node_cell !< cell node coordinates - type(tCellNodeDefinition), dimension(:), intent(in) :: definition !< cell node definition (weights and parents) real(pReal), dimension(:,:), intent(in) :: node_elem !< element nodes + real(pReal), dimension(:,:), allocatable :: buildCellNodes !< cell node coordinates integer :: i, j, k, n - n = size(node_elem,2) - node_cell(:,1:n) = node_elem !< initial nodes coincide with element nodes - do i = 1, size(cellNodeDefinition,1) + allocate(buildCellNodes(3,maxval(connectivity_cell))) + n = size(node_elem,2) + buildCellNodes(:,1:n) = node_elem !< initial nodes coincide with element nodes + + do i = 1, size(cellNodeDefinition) do j = 1, size(cellNodeDefinition(i)%parents,1) n = n+1 - node_cell(:,n) = 0.0_pReal + buildCellNodes(:,n) = 0.0_pReal do k = 1, size(cellNodeDefinition(i)%parents,2) - node_cell(:,n) = node_cell(:,n) & - + node_cell(:,definition(i)%parents(j,k)) * real(definition(i)%weights(j,k),pReal) + buildCellNodes(:,n) = buildCellNodes(:,n) & + + buildCellNodes(:,cellNodeDefinition(i)%parents(j,k)) & + * real(cellNodeDefinition(i)%weights(j,k),pReal) enddo - node_cell(:,n) = node_cell(:,n)/real(sum(definition(i)%weights(j,:)),pReal) + buildCellNodes(:,n) = buildCellNodes(:,n)/real(sum(cellNodeDefinition(i)%weights(j,:)),pReal) enddo enddo -end subroutine buildCellNodes +end function buildCellNodes !-------------------------------------------------------------------------------------------------- !> @brief Calculates IP coordinates as center of cell !-------------------------------------------------------------------------------------------------- -pure subroutine buildIPcoordinates(IPcoordinates, & - connectivity_cell,node_cell) +pure function buildIPcoordinates(node_cell) - real(pReal), dimension(:,:), intent(out):: IPcoordinates !< cell-center/IP coordinates - integer, dimension(:,:), intent(in) :: connectivity_cell !< connectivity for each cell - real(pReal), dimension(:,:), intent(in) :: node_cell !< cell node coordinates + real(pReal), dimension(:,:), intent(in) :: node_cell !< cell node coordinates + real(pReal), dimension(:,:), allocatable :: buildIPcoordinates !< cell-center/IP coordinates - integer :: i, n + integer, dimension(:,:), allocatable :: connectivity_cell_reshaped + integer :: i, n, NcellNodesPerCell,Ncells - do i = 1, size(connectivity_cell,2) - IPcoordinates(:,i) = 0.0_pReal - do n = 1, size(connectivity_cell,1) - IPcoordinates(:,i) = IPcoordinates(:,i) & - + node_cell(:,connectivity_cell(n,i)) + + NcellNodesPerCell = size(connectivity_cell,1) + Ncells = size(connectivity_cell,2)*size(connectivity_cell,3) + connectivity_cell_reshaped = reshape(connectivity_cell,[NcellNodesPerCell,Ncells]) + + allocate(buildIPcoordinates(3,Ncells)) + + do i = 1, size(connectivity_cell_reshaped,2) + buildIPcoordinates(:,i) = 0.0_pReal + do n = 1, size(connectivity_cell_reshaped,1) + buildIPcoordinates(:,i) = buildIPcoordinates(:,i) & + + node_cell(:,connectivity_cell_reshaped(n,i)) enddo - IPcoordinates(:,i) = IPcoordinates(:,i)/real(size(connectivity_cell,1),pReal) + buildIPcoordinates(:,i) = buildIPcoordinates(:,i)/real(size(connectivity_cell_reshaped,1),pReal) enddo -end subroutine buildIPcoordinates +end function buildIPcoordinates !--------------------------------------------------------------------------------------------------- @@ -940,50 +953,50 @@ end subroutine buildIPcoordinates !> @details The IP volume is calculated differently depending on the cell type. !> 2D cells assume an element depth of 1.0 !--------------------------------------------------------------------------------------------------- -pure function IPvolume(elem,node,connectivity) +pure function IPvolume(elem,node) type(tElement), intent(in) :: elem real(pReal), dimension(:,:), intent(in) :: node - integer, dimension(:,:,:), intent(in) :: connectivity - real(pReal), dimension(elem%nIPs,size(connectivity,3)) :: IPvolume + real(pReal), dimension(elem%nIPs,size(connectivity_cell,3)) :: IPvolume real(pReal), dimension(3) :: x0,x1,x2,x3,x4,x5,x6,x7 integer :: e,i - do e = 1,size(connectivity,3) + + do e = 1,size(connectivity_cell,3) do i = 1,elem%nIPs select case (elem%cellType) case (1) ! 2D 3node - IPvolume(i,e) = math_areaTriangle(node(1:3,connectivity(1,i,e)), & - node(1:3,connectivity(2,i,e)), & - node(1:3,connectivity(3,i,e))) + IPvolume(i,e) = math_areaTriangle(node(1:3,connectivity_cell(1,i,e)), & + node(1:3,connectivity_cell(2,i,e)), & + node(1:3,connectivity_cell(3,i,e))) case (2) ! 2D 4node - IPvolume(i,e) = math_areaTriangle(node(1:3,connectivity(1,i,e)), & ! assume planar shape, division in two triangles suffices - node(1:3,connectivity(2,i,e)), & - node(1:3,connectivity(3,i,e))) & - + math_areaTriangle(node(1:3,connectivity(3,i,e)), & - node(1:3,connectivity(4,i,e)), & - node(1:3,connectivity(1,i,e))) + IPvolume(i,e) = math_areaTriangle(node(1:3,connectivity_cell(1,i,e)), & ! assume planar shape, division in two triangles suffices + node(1:3,connectivity_cell(2,i,e)), & + node(1:3,connectivity_cell(3,i,e))) & + + math_areaTriangle(node(1:3,connectivity_cell(3,i,e)), & + node(1:3,connectivity_cell(4,i,e)), & + node(1:3,connectivity_cell(1,i,e))) case (3) ! 3D 4node - IPvolume(i,e) = math_volTetrahedron(node(1:3,connectivity(1,i,e)), & - node(1:3,connectivity(2,i,e)), & - node(1:3,connectivity(3,i,e)), & - node(1:3,connectivity(4,i,e))) + IPvolume(i,e) = math_volTetrahedron(node(1:3,connectivity_cell(1,i,e)), & + node(1:3,connectivity_cell(2,i,e)), & + node(1:3,connectivity_cell(3,i,e)), & + node(1:3,connectivity_cell(4,i,e))) case (4) ! 3D 8node ! J. Grandy, Efficient Calculation of Volume of Hexahedral Cells ! Lawrence Livermore National Laboratory ! https://www.osti.gov/servlets/purl/632793 - x0 = node(1:3,connectivity(1,i,e)) - x1 = node(1:3,connectivity(2,i,e)) - x2 = node(1:3,connectivity(4,i,e)) - x3 = node(1:3,connectivity(3,i,e)) - x4 = node(1:3,connectivity(5,i,e)) - x5 = node(1:3,connectivity(6,i,e)) - x6 = node(1:3,connectivity(8,i,e)) - x7 = node(1:3,connectivity(7,i,e)) + x0 = node(1:3,connectivity_cell(1,i,e)) + x1 = node(1:3,connectivity_cell(2,i,e)) + x2 = node(1:3,connectivity_cell(4,i,e)) + x3 = node(1:3,connectivity_cell(3,i,e)) + x4 = node(1:3,connectivity_cell(5,i,e)) + x5 = node(1:3,connectivity_cell(6,i,e)) + x6 = node(1:3,connectivity_cell(8,i,e)) + x7 = node(1:3,connectivity_cell(7,i,e)) IPvolume(i,e) = dot_product((x7-x1)+(x6-x0),math_cross((x7-x2), (x3-x0))) & + dot_product((x6-x0), math_cross((x7-x2)+(x5-x0),(x7-x4))) & + dot_product((x7-x1), math_cross((x5-x0), (x7-x4)+(x3-x0))) @@ -998,11 +1011,10 @@ end function IPvolume !-------------------------------------------------------------------------------------------------- !> @brief calculation of IP interface areas !-------------------------------------------------------------------------------------------------- -pure function IPareaNormal(elem,nElem,connectivity,node) +pure function IPareaNormal(elem,nElem,node) type(tElement), intent(in) :: elem integer, intent(in) :: nElem - integer, dimension(:,:,:), intent(in) :: connectivity real(pReal), dimension(:,:), intent(in) :: node real(pReal), dimension(3,elem%nIPneighbors,elem%nIPs,nElem) :: ipAreaNormal @@ -1015,7 +1027,7 @@ pure function IPareaNormal(elem,nElem,connectivity,node) do e = 1,nElem do i = 1,elem%nIPs do f = 1,elem%nIPneighbors - nodePos = node(1:3,connectivity(elem%cellface(1:m,f),i,e)) + nodePos = node(1:3,connectivity_cell(elem%cellface(1:m,f),i,e)) select case (elem%cellType) case (1,2) ! 2D 3 or 4 node @@ -1046,23 +1058,22 @@ end function IPareaNormal !-------------------------------------------------------------------------------------------------- !> @brief IP neighborhood !-------------------------------------------------------------------------------------------------- -function IPneighborhood(elem,connectivity) +function IPneighborhood(elem) type(tElement), intent(in) :: elem ! definition of the element in use - integer, dimension(:,:,:), intent(in) :: connectivity ! cell connectivity integer, dimension(3,size(elem%cellFace,2), & - size(connectivity,2),size(connectivity,3)) :: IPneighborhood ! neighboring IPs as [element ID, IP ID, face ID] + size(connectivity_cell,2),size(connectivity_cell,3)) :: IPneighborhood ! neighboring IPs as [element ID, IP ID, face ID] integer, dimension(size(elem%cellFace,1)+3,& - size(elem%cellFace,2)*size(connectivity,2)*size(connectivity,3)) :: face - integer, dimension(size(connectivity,1)) :: myConnectivity - integer, dimension(size(elem%cellFace,1)) :: face_unordered + size(elem%cellFace,2)*size(connectivity_cell,2)*size(connectivity_cell,3)) :: face + integer, dimension(size(connectivity_cell,1)) :: myConnectivity + integer, dimension(size(elem%cellFace,1)) :: face_unordered integer :: e,i,f,n,c,s c = 0 - do e = 1, size(connectivity,3) - do i = 1, size(connectivity,2) - myConnectivity = connectivity(:,i,e) + do e = 1, size(connectivity_cell,3) + do i = 1, size(connectivity_cell,2) + myConnectivity = connectivity_cell(:,i,e) do f = 1, size(elem%cellFace,2) c = c + 1 face_unordered = myConnectivity(elem%cellFace(:,f)) diff --git a/src/parallelization.f90 b/src/parallelization.f90 index edf56407b..8413ba825 100644 --- a/src/parallelization.f90 +++ b/src/parallelization.f90 @@ -9,9 +9,8 @@ module parallelization #ifdef PETSc #include use petscsys -#endif !$ use OMP_LIB - +#endif use prec implicit none @@ -21,6 +20,7 @@ module parallelization worldrank = 0, & !< MPI worldrank (/=0 for MPI simulations only) worldsize = 1 !< MPI worldsize (/=1 for MPI simulations only) +#ifdef PETSc public :: & parallelization_init @@ -32,16 +32,12 @@ contains subroutine parallelization_init integer :: err, typeSize -!$ integer :: got_env, OMP_NUM_THREADS, threadLevel +!$ integer :: got_env, threadLevel +!$ integer(pI32) :: OMP_NUM_THREADS !$ character(len=6) NumThreadsString -#ifdef PETSc + + PetscErrorCode :: petsc_err - -#else - print'(/,a)', ' <<<+- parallelization init -+>>>'; flush(OUTPUT_UNIT) -#endif - -#ifdef PETSc #ifdef _OPENMP ! If openMP is enabled, check if the MPI libary supports it and initialize accordingly. ! Otherwise, the first call to PETSc will do the initialization. @@ -64,7 +60,7 @@ subroutine parallelization_init #endif CHKERRQ(petsc_err) -call MPI_Comm_rank(PETSC_COMM_WORLD,worldrank,err) + call MPI_Comm_rank(PETSC_COMM_WORLD,worldrank,err) if (err /= 0) error stop 'Could not determine worldrank' if (worldrank == 0) print'(/,a)', ' <<<+- parallelization init -+>>>' @@ -80,7 +76,6 @@ call MPI_Comm_rank(PETSC_COMM_WORLD,worldrank,err) call MPI_Type_size(MPI_DOUBLE,typeSize,err) if (err /= 0) error stop 'Could not determine MPI real size' if (typeSize*8 /= storage_size(0.0_pReal)) error stop 'Mismatch between MPI and DAMASK real' -#endif if (worldrank /= 0) then close(OUTPUT_UNIT) ! disable output @@ -102,5 +97,6 @@ call MPI_Comm_rank(PETSC_COMM_WORLD,worldrank,err) !$ call omp_set_num_threads(OMP_NUM_THREADS) end subroutine parallelization_init +#endif end module parallelization From f69d1029e679c6aa97ff6c41717d901ded955b23 Mon Sep 17 00:00:00 2001 From: "f.basile" Date: Tue, 2 Feb 2021 10:18:06 +0100 Subject: [PATCH 191/352] updated tests for marc write displacements --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 4b5636231..dcafb91d1 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 4b563623162f033b11d9d0ac95fc421de279f690 +Subproject commit dcafb91d1fadb2b112021677698ff118cfaebf36 From 051e3ed0ae572ddcaa66dff7cad65ce79cb2b381 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 2 Feb 2021 09:48:14 +0100 Subject: [PATCH 192/352] not needed anymore --- python/damask/_test.py | 129 ----------------------------------------- 1 file changed, 129 deletions(-) diff --git a/python/damask/_test.py b/python/damask/_test.py index 2f5dbde1f..f8fb24cca 100644 --- a/python/damask/_test.py +++ b/python/damask/_test.py @@ -283,40 +283,6 @@ class Test: return out,error - - def compare_Array(self,File1,File2): - - import numpy as np - logging.info('\n '.join(['comparing',File1,File2])) - table = damask.Table.load(File1) - len1 = len(table.comments)+2 - table = damask.Table.load(File2) - len2 = len(table.comments)+2 - - refArray = np.nan_to_num(np.genfromtxt(File1,missing_values='n/a',skip_header = len1,autostrip=True)) - curArray = np.nan_to_num(np.genfromtxt(File2,missing_values='n/a',skip_header = len2,autostrip=True)) - - if len(curArray) == len(refArray): - refArrayNonZero = refArray[refArray.nonzero()] - curArray = curArray[refArray.nonzero()] - max_err = np. max(abs(refArrayNonZero[curArray.nonzero()]/curArray[curArray.nonzero()]-1.)) - max_loc = np.argmax(abs(refArrayNonZero[curArray.nonzero()]/curArray[curArray.nonzero()]-1.)) - refArrayNonZero = refArrayNonZero[curArray.nonzero()] - curArray = curArray[curArray.nonzero()] - print(f' ********\n * maximum relative error {max_err} between {refArrayNonZero[max_loc]} and {curArray[max_loc]}\n ********') - return max_err - else: - raise Exception(f'mismatch in array sizes ({len(refArray)} and {len(curArray)}) to compare') - - - def compare_ArrayRefCur(self,ref,cur=''): - - if cur == '': cur = ref - refName = self.fileInReference(ref) - curName = self.fileInCurrent(cur) - return self.compare_Array(refName,curName) - - def compare_Table(self,headings0,file0, headings1,file1, normHeadings='',normType=None, @@ -469,101 +435,6 @@ class Test: return (mean < meanTol) & (std < stdTol) - def compare_Tables(self, - files = [None,None], # list of file names - columns = [None], # list of list of column labels (per file) - rtol = 1e-5, - atol = 1e-8, - debug = False): - """Compare multiple tables with np.allclose.""" - if not (isinstance(files, Iterable) and not isinstance(files, str)): # check whether list of files is requested - files = [str(files)] - - if len(files) < 2: return True # single table is always close to itself... - - tables = [damask.Table.load(filename) for filename in files] - - columns += [columns[0]]*(len(files)-len(columns)) # extend to same length as files - columns = columns[:len(files)] # truncate to same length as files - - for i,column in enumerate(columns): - if column is None: columns[i] = list(tables[i].shapes.keys()) # if no column is given, use all - - logging.info('comparing ASCIItables') - for i in range(len(columns)): - columns[i] = columns[0] if not columns[i] else \ - ([columns[i]] if not (isinstance(columns[i], Iterable) and not isinstance(columns[i], str)) else \ - columns[i] - ) - logging.info(files[i]+': '+','.join(columns[i])) - - dimensions = [np.prod(tables[0].shapes[c]) for c in columns[0]] # width of each requested column - maximum = np.zeros_like(columns[0],dtype=float) # one magnitude per column entry - data = [] # list of feature table extracted from each file (ASCII table) - - for i,(table,labels) in enumerate(zip(tables,columns)): - if np.any(dimensions != [np.prod(table.shapes[c]) for c in labels]): # check data object consistency - logging.critical(f'Table {files[i]} differs in data layout.') - return False - data.append(np.hstack(list(table.get(label) for label in labels)).astype(np.float)) # store - - for j,label in enumerate(labels): # iterate over object labels - maximum[j] = np.maximum( - maximum[j], - np.amax(np.linalg.norm(table.get(label), - axis=1)) - ) # find maximum Euclidean norm across rows - - maximum = np.where(maximum > 0.0, maximum, 1.0) # avoid div by zero for zero columns - maximum = np.repeat(maximum,dimensions) # spread maximum over columns of each object - - for i in range(len(data)): - data[i] /= maximum # normalize each table - logging.info(f'shape of data {i}: {data[i].shape}') - - if debug: - violators = np.absolute(data[0]-data[1]) > atol + rtol*np.absolute(data[1]) - logging.info(f'shape of violators: {violators.shape}') - for j,culprits in enumerate(violators): - goodguys = np.logical_not(culprits) - if culprits.any(): - logging.info(f'{j} has {np.sum(culprits)}') - logging.info(f'deviation: {np.absolute(data[0][j]-data[1][j])[culprits]}') - logging.info(f'data : {np.absolute(data[1][j])[culprits]}') - logging.info(f'deviation: {np.absolute(data[0][j]-data[1][j])[goodguys]}') - logging.info(f'data : {np.absolute(data[1][j])[goodguys]}') - - allclose = True # start optimistic - for i in range(1,len(data)): - allclose &= np.allclose(data[i-1],data[i],rtol,atol) # accumulate "pessimism" - - return allclose - - - def compare_TableRefCur(self,headingsRef,ref,headingsCur='',cur='', - normHeadings='',normType=None, - absoluteTolerance=False,perLine=False,skipLines=[]): - - return self.compare_Table(headingsRef, - self.fileInReference(ref), - headingsRef if headingsCur == '' else headingsCur, - self.fileInCurrent(ref if cur == '' else cur), - normHeadings,normType, - absoluteTolerance,perLine,skipLines) - - - def compare_TableCurCur(self,headingsCur0,Cur0,Cur1, - headingsCur1='', - normHeadings='',normType=None, - absoluteTolerance=False,perLine=False,skipLines=[]): - - return self.compare_Table(headingsCur0, - self.fileInCurrent(Cur0), - headingsCur0 if headingsCur1 == '' else headingsCur1, - self.fileInCurrent(Cur1), - normHeadings,normType,absoluteTolerance,perLine,skipLines) - - def report_Success(self,culprit): ret = culprit From ee40884916121355dcfcdbb26c343211ba1d8687 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 2 Feb 2021 12:26:16 +0100 Subject: [PATCH 193/352] only use pytest-based tests --- .gitlab-ci.yml | 12 ++---------- PRIVATE | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca1b2959a..5aef9c54c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,7 +95,7 @@ checkout: - release ################################################################################################### -Pytest_python: +pytest_python: stage: python script: - cd $DAMASKROOT/python @@ -252,7 +252,7 @@ setup_mesh: - release ################################################################################################### -Pytest_grid: +pytest_fortran: stage: grid script: - module load $IntelCompiler $MPI_Intel $PETSc_Intel @@ -287,14 +287,6 @@ J2_plasticBehavior: - master - release -Marc_elementLib: - stage: marc - script: - - module load $IntelMarc $HDF5Marc $MSC - - Marc_elementLib/test.py - except: - - master - - release ################################################################################################### SpectralRuntime: diff --git a/PRIVATE b/PRIVATE index dcafb91d1..f7297868d 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit dcafb91d1fadb2b112021677698ff118cfaebf36 +Subproject commit f7297868d932edbadef170c584ac5349f2c0a6d5 From 47f52b9095701e7f1d64baa126321dda6ac57188 Mon Sep 17 00:00:00 2001 From: "f.basile" Date: Tue, 2 Feb 2021 17:12:03 +0100 Subject: [PATCH 194/352] elements and nodes do not need to start at 1 necessarily --- PRIVATE | 2 +- src/DAMASK_marc.f90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PRIVATE b/PRIVATE index f7297868d..f3cd8f4c4 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit f7297868d932edbadef170c584ac5349f2c0a6d5 +Subproject commit f3cd8f4c4b2d154e179d9bb5f396a77535f88556 diff --git a/src/DAMASK_marc.f90 b/src/DAMASK_marc.f90 index 7abb0e746..8537992e8 100644 --- a/src/DAMASK_marc.f90 +++ b/src/DAMASK_marc.f90 @@ -370,8 +370,8 @@ subroutine uedinc(inc,incsub) if (inc > inc_written) then - allocate(d_n(3,size(mesh_FEM2DAMASK_node))) - do n = 1, size(d_n,2) + allocate(d_n(3,count(mesh_FEM2DAMASK_node /= -1))) + do n = lbound(mesh_FEM2DAMASK_node,1), ubound(mesh_FEM2DAMASK_node,1) if (mesh_FEM2DAMASK_node(n) /= -1) then call nodvar(1,n,d_n(1:3,mesh_FEM2DAMASK_node(n)),nqncomp,nqdatatype) if(nqncomp == 2) d_n(3,mesh_FEM2DAMASK_node(n)) = 0.0_pReal From 2c1f23d983c509be507fa2fac7ccd1bfc3ed558b Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 3 Feb 2021 18:36:33 +0100 Subject: [PATCH 195/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-407-g47f52b909 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index de297f225..b7d460b2d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-401-g85cfa0bab +v3.0.0-alpha2-407-g47f52b909 From 14ce127dc405fee3a0c66d6adf805614ebd8e947 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Thu, 4 Feb 2021 13:46:01 +0100 Subject: [PATCH 196/352] fraction --> v --- PRIVATE | 2 +- .../SpectralMethod/Polycrystal/material.yaml | 40 +++++++++---------- python/damask/_configmaterial.py | 14 +++---- .../reference/ConfigMaterial/material.yaml | 10 ++--- python/tests/test_ConfigMaterial.py | 2 +- src/material.f90 | 2 +- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/PRIVATE b/PRIVATE index f3cd8f4c4..3f915ee49 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit f3cd8f4c4b2d154e179d9bb5f396a77535f88556 +Subproject commit 3f915ee49eb7e5e26d4b9b5e5712de9e05e64d83 diff --git a/examples/SpectralMethod/Polycrystal/material.yaml b/examples/SpectralMethod/Polycrystal/material.yaml index b560a919d..e54eec436 100644 --- a/examples/SpectralMethod/Polycrystal/material.yaml +++ b/examples/SpectralMethod/Polycrystal/material.yaml @@ -8,102 +8,102 @@ material: - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [1.0, 0.0, 0.0, 0.0] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.7936696712125002, -0.28765777461664166, -0.3436487135089419, 0.4113964260949434] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.3986143167493579, -0.7014883552495493, 0.2154871765709027, 0.5500781677772945] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.28645844315788244, -0.022571491243423537, -0.467933059311115, -0.8357456192708106] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.33012772942625784, -0.6781865350268957, 0.6494525351030648, 0.09638521992649676] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.43596817439583935, -0.5982537129781701, 0.046599032277502436, 0.6707106499919265] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.169734823419553, -0.699615227367322, -0.6059581215838098, -0.33844257746495854] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.9698864809294915, 0.1729052643205874, -0.15948307917616958, 0.06315956884687175] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.46205660912967883, 0.3105054068891252, -0.617849551030653, 0.555294529545738] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.4512443497461787, -0.7636045534540555, -0.04739348426715133, -0.45939142396805815] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.2161856212656443, -0.6581450184826598, -0.5498086209601588, 0.4667112513346289] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.8753220715350803, -0.4561599367657419, -0.13298279533852678, -0.08969369719975541] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.11908260752431069, 0.18266024809834172, -0.7144822594012615, -0.664807992845101] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.751104669484278, 0.5585633382623958, -0.34579336397009175, 0.06538900566860861] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.08740438971703973, 0.8991264096610437, -0.4156704205935976, 0.10559485570696363] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.5584325870096193, 0.6016408353068798, -0.14280340445801173, 0.5529814994483859] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.4052725440888093, 0.25253073423599154, 0.5693263597910454, -0.669215876471182] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.7570164606888676, 0.15265448024694664, -0.5998021466848317, 0.20942796551297105] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.6987659297138081, -0.132172211261028, -0.19693254724422338, 0.6748883269678543] - homogenization: SX constituents: - phase: Aluminum - fraction: 1.0 + v: 1.0 O: [0.7729330445886478, 0.21682179052722322, -0.5207379472917645, 0.2905078484066341] phase: diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 6415ee4dc..d3ed972e3 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -74,12 +74,12 @@ class ConfigMaterial(Config): material: - constituents: - O: [0.19, 0.8, 0.24, -0.51] - fraction: 1.0 + v: 1.0 phase: Aluminum homogenization: SX - constituents: - O: [0.8, 0.19, 0.24, -0.51] - fraction: 1.0 + v: 1.0 phase: Steel homogenization: SX homogenization: {} @@ -172,7 +172,7 @@ class ConfigMaterial(Config): if 'constituents' in v: f = 0.0 for c in v['constituents']: - f+= float(c['fraction']) + f+= float(c['v']) if 'O' in c: try: Rotation.from_quaternion(c['O']) @@ -257,17 +257,17 @@ class ConfigMaterial(Config): material: - constituents: - O: [0.577764, -0.146299, -0.617669, 0.513010] - fraction: 1.0 + v: 1.0 phase: Aluminum homogenization: SX - constituents: - O: [0.184176, 0.340305, 0.737247, 0.553840] - fraction: 1.0 + v: 1.0 phase: Steel homogenization: SX - constituents: - O: [0.0886257, -0.144848, 0.615674, -0.769487] - fraction: 1.0 + v: 1.0 phase: Aluminum homogenization: SX homogenization: {} @@ -312,7 +312,7 @@ class ConfigMaterial(Config): if hasattr(v,'__len__') and not isinstance(v,str): N_material = len(v) if N == 1: - m = [[{'fraction':1.0}] for _ in range(N_material)] + 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: diff --git a/python/tests/reference/ConfigMaterial/material.yaml b/python/tests/reference/ConfigMaterial/material.yaml index fbba6a631..1da30535a 100644 --- a/python/tests/reference/ConfigMaterial/material.yaml +++ b/python/tests/reference/ConfigMaterial/material.yaml @@ -8,25 +8,25 @@ homogenization: material: - constituents: - - fraction: 1.0 + - v: 1.0 O: [1.0, 0.0, 0.0, 0.0] phase: Aluminum homogenization: SX - constituents: - - fraction: 1.0 + - v: 1.0 O: [0.7936696712125002, -0.28765777461664166, -0.3436487135089419, 0.4113964260949434] phase: Aluminum homogenization: SX - constituents: - - fraction: 1.0 + - v: 1.0 O: [0.3986143167493579, -0.7014883552495493, 0.2154871765709027, 0.5500781677772945] phase: Aluminum homogenization: SX - constituents: - - fraction: 0.5 + - v: 0.5 O: [0.28645844315788244, -0.022571491243423537, -0.467933059311115, -0.8357456192708106] phase: Aluminum - - fraction: 0.5 + - v: 0.5 O: [0.3986143167493579, -0.7014883552495493, 0.2154871765709027, 0.5500781677772945] phase: Steel homogenization: Taylor diff --git a/python/tests/test_ConfigMaterial.py b/python/tests/test_ConfigMaterial.py index 45dc3b97f..4ad0d31ca 100644 --- a/python/tests/test_ConfigMaterial.py +++ b/python/tests/test_ConfigMaterial.py @@ -42,7 +42,7 @@ class TestConfigMaterial: def test_invalid_fraction(self,ref_path): material_config = ConfigMaterial.load(ref_path/'material.yaml') - material_config['material'][0]['constituents'][0]['fraction']=.9 + material_config['material'][0]['constituents'][0]['v']=.9 assert not material_config.is_valid @pytest.mark.parametrize('item',['homogenization','phase','material']) diff --git a/src/material.f90 b/src/material.f90 index 5f0f86fe5..3a4c910d9 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -265,7 +265,7 @@ subroutine material_parseMaterial frac = 0.0_pReal do co = 1, constituents%length constituent => constituents%get(co) - frac = frac + constituent%get_asFloat('fraction') + frac = frac + constituent%get_asFloat('v') material_phaseAt(co,el) = phases%getIndex(constituent%get_asString('phase')) do ip = 1, discretization_nIPs From cab5a5cec7f98fd95a5997cb247451912ea9a951 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Thu, 4 Feb 2021 15:37:40 +0100 Subject: [PATCH 197/352] homogenization 'none' name misleading. --- PRIVATE | 2 +- examples/SpectralMethod/Polycrystal/material.yaml | 2 +- python/tests/reference/ConfigMaterial/material.yaml | 2 +- src/material.f90 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PRIVATE b/PRIVATE index 3f915ee49..18dea4a43 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 3f915ee49eb7e5e26d4b9b5e5712de9e05e64d83 +Subproject commit 18dea4a43c94b04e4c5cc3d193298ef796de7d18 diff --git a/examples/SpectralMethod/Polycrystal/material.yaml b/examples/SpectralMethod/Polycrystal/material.yaml index e54eec436..09176d531 100644 --- a/examples/SpectralMethod/Polycrystal/material.yaml +++ b/examples/SpectralMethod/Polycrystal/material.yaml @@ -2,7 +2,7 @@ homogenization: SX: N_constituents: 1 - mechanics: {type: none} + mechanics: {type: pass} material: - homogenization: SX diff --git a/python/tests/reference/ConfigMaterial/material.yaml b/python/tests/reference/ConfigMaterial/material.yaml index 1da30535a..48ebd98e3 100644 --- a/python/tests/reference/ConfigMaterial/material.yaml +++ b/python/tests/reference/ConfigMaterial/material.yaml @@ -1,7 +1,7 @@ homogenization: SX: N_constituents: 1 - mechanics: {type: none} + mechanics: {type: pass} Taylor: N_constituents: 2 mechanics: {type: isostrain} diff --git a/src/material.f90 b/src/material.f90 index 3a4c910d9..ccc6898be 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -147,7 +147,7 @@ subroutine material_parseHomogenization homog => material_homogenization%get(h) homogMech => homog%get('mechanics') select case (homogMech%get_asString('type')) - case('none') + case('pass') homogenization_type(h) = HOMOGENIZATION_NONE_ID case('isostrain') homogenization_type(h) = HOMOGENIZATION_ISOSTRAIN_ID From 2e173b4b7b91a8f0867687ad4076204b3f470098 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Thu, 4 Feb 2021 19:17:32 +0100 Subject: [PATCH 198/352] 'estimate_rate' better describes what we want to do than 'drop_guessing' true by default --- PRIVATE | 2 +- src/grid/DAMASK_grid.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PRIVATE b/PRIVATE index 18dea4a43..2b3f72505 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 18dea4a43c94b04e4c5cc3d193298ef796de7d18 +Subproject commit 2b3f72505785d717860ab0012da8bc21c7fb61ed diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 60c386c75..a9ec6e594 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -227,7 +227,7 @@ program DAMASK_grid loadCases(l)%f_out = step_discretization%get_asInt ('f_out', defaultVal=1) loadCases(l)%f_restart = step_discretization%get_asInt ('f_restart', defaultVal=huge(0)) - loadCases(l)%drop_guessing = (load_step%get_asBool('drop_guessing',defaultVal=.false.) .or. & + loadCases(l)%drop_guessing = (.not. load_step%get_asBool('estimate_rate',defaultVal=.true.) .or. & !ToDO: SR: simplify logic later,change name merge(.false.,.true.,l > 1)) reportAndCheck: if (worldrank == 0) then From a1a7a339d483fbf72e7532c5e99013024b9f242d Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Fri, 5 Feb 2021 01:31:41 +0100 Subject: [PATCH 199/352] specify solver,initial and boundary conditions in load file --- PRIVATE | 2 +- .../SpectralMethod/Polycrystal/shearXY.yaml | 21 +++++++--- .../SpectralMethod/Polycrystal/shearZX.yaml | 20 ++++++--- .../SpectralMethod/Polycrystal/tensionX.yaml | 42 +++++++++++-------- src/grid/DAMASK_grid.f90 | 9 ++-- 5 files changed, 60 insertions(+), 34 deletions(-) diff --git a/PRIVATE b/PRIVATE index 2b3f72505..1c2dd13c9 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 2b3f72505785d717860ab0012da8bc21c7fb61ed +Subproject commit 1c2dd13c9aea21d341e579fe66e4bef5c48ce07e diff --git a/examples/SpectralMethod/Polycrystal/shearXY.yaml b/examples/SpectralMethod/Polycrystal/shearXY.yaml index 559bdfe56..fe746e7ac 100644 --- a/examples/SpectralMethod/Polycrystal/shearXY.yaml +++ b/examples/SpectralMethod/Polycrystal/shearXY.yaml @@ -1,9 +1,18 @@ -step: - - mechanics: - dot_F: [0, 0, 0, - 1e-3, 0, 0, - 0, 0, 0] +--- + +solver: + mechanical: spectral_basic + +initial_conditions: + T: 300 #in Kelvin + +loadstep: + - boundary_conditions: + mechanical: + dot_F: [0, 0, 0, + 1e-3, 0, 0, + 0, 0, 0] discretization: t: 60 N: 120 - f_out: 20 + f_out: 20 diff --git a/examples/SpectralMethod/Polycrystal/shearZX.yaml b/examples/SpectralMethod/Polycrystal/shearZX.yaml index df7b887e5..5d977b4ba 100644 --- a/examples/SpectralMethod/Polycrystal/shearZX.yaml +++ b/examples/SpectralMethod/Polycrystal/shearZX.yaml @@ -1,10 +1,18 @@ --- -step: - - mechanics: - dot_F: [0, 0, 1e-3, - 0, 0, 0, - 0, 0, 0] + +solver: + mechanical: spectral_basic + +initial_conditions: + T: 300 #in Kelvin + +loadstep: + - boundary_conditions: + mechanical: + dot_F: [0, 0, 1e-3, + 0, 0, 0, + 0, 0, 0] discretization: t: 60 N: 120 - f_out: 20 + f_out: 20 diff --git a/examples/SpectralMethod/Polycrystal/tensionX.yaml b/examples/SpectralMethod/Polycrystal/tensionX.yaml index 2f1d11f91..0809fd53d 100644 --- a/examples/SpectralMethod/Polycrystal/tensionX.yaml +++ b/examples/SpectralMethod/Polycrystal/tensionX.yaml @@ -1,25 +1,33 @@ --- -step: - - mechanics: - dot_F: [1.0e-3, 0, 0, - 0, x, 0, - 0, 0, x] - P: [x, x, x, - x, 0, x, - x, x, 0] +solver: + mechanical: spectral_basic + +initial_conditions: + T: 300 #in Kelvin + +loadstep: + - boundary_conditions: + mechanical: + dot_F: [1.0e-3, 0, 0, + 0, x, 0, + 0, 0, x] + P: [x, x, x, + x, 0, x, + x, x, 0] discretization: t: 10 N: 40 - f_out: 4 - - mechanics: - dot_F: [1.0e-3, 0, 0, - 0, x, 0, - 0, 0, x] - P: [x, x, x, - x, 0, x, - x, x, 0] + f_out: 4 + - boundary_conditions: + mechanical: + dot_F: [1.0e-3, 0, 0, + 0, x, 0, + 0, 0, x] + P: [x, x, x, + x, 0, x, + x, x, 0] discretization: t: 60 N: 60 - f_out: 4 + f_out: 4 diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index a9ec6e594..d49f6f023 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -102,6 +102,7 @@ program DAMASK_grid config_load, & load_steps, & load_step, & + step_bc, & step_mech, & step_discretization, & step_deformation, & @@ -168,7 +169,7 @@ program DAMASK_grid ! reading information from load case file and to sanity checks config_load => YAML_parse_file(trim(interface_loadFile)) - load_steps => config_load%get('step') + load_steps => config_load%get('loadstep') allocate(loadCases(load_steps%length)) ! array of load cases do l = 1, load_steps%length @@ -186,8 +187,8 @@ program DAMASK_grid endif damageActive load_step => load_steps%get(l) - - step_mech => load_step%get('mechanics') + step_bc => load_step%get('boundary_conditions') + step_mech => step_bc%get('mechanical') loadCases(l)%stress%myType='' readMech: do m = 1, step_mech%length select case (step_mech%getKey(m)) @@ -224,9 +225,9 @@ 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_out = step_discretization%get_asInt ('f_out', defaultVal=1) loadCases(l)%f_restart = step_discretization%get_asInt ('f_restart', defaultVal=huge(0)) + loadCases(l)%f_out = load_step%get_asInt('f_out', defaultVal=1) loadCases(l)%drop_guessing = (.not. load_step%get_asBool('estimate_rate',defaultVal=.true.) .or. & !ToDO: SR: simplify logic later,change name merge(.false.,.true.,l > 1)) From ba2e8b3c636a9a89450e26d34b5e0b7248f51054 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Fri, 5 Feb 2021 11:57:18 +0100 Subject: [PATCH 200/352] variable name follows label --- src/grid/DAMASK_grid.f90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index d49f6f023..2c9f11285 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -36,7 +36,7 @@ program DAMASK_grid integer :: N, & !< number of increments f_out, & !< frequency of result writes f_restart !< frequency of restart writes - logical :: drop_guessing !< do not follow trajectory of former loadcase + logical :: estimate_rate !< do not follow trajectory of former loadcase integer(kind(FIELD_UNDEFINED_ID)), allocatable :: ID(:) end type tLoadCase @@ -228,13 +228,13 @@ program DAMASK_grid loadCases(l)%f_restart = step_discretization%get_asInt ('f_restart', defaultVal=huge(0)) loadCases(l)%f_out = load_step%get_asInt('f_out', defaultVal=1) - loadCases(l)%drop_guessing = (.not. load_step%get_asBool('estimate_rate',defaultVal=.true.) .or. & !ToDO: SR: simplify logic later,change name - merge(.false.,.true.,l > 1)) + loadCases(l)%estimate_rate = (load_step%get_asBool('estimate_rate',defaultVal=.true.) .and. & + merge(.true.,.false.,l > 1)) reportAndCheck: if (worldrank == 0) then write (loadcase_string, '(i0)' ) l print'(/,a,i0)', ' load case: ', l - print*, ' drop_guessing:', loadCases(l)%drop_guessing + print*, ' estimate_rate:', loadCases(l)%estimate_rate if (loadCases(l)%deformation%myType == 'L') then do j = 1, 3 if (any(loadCases(l)%deformation%mask(j,1:3) .eqv. .true.) .and. & @@ -334,7 +334,7 @@ program DAMASK_grid loadCaseLooping: do l = 1, size(loadCases) time0 = time ! load case start time - guess = .not. loadCases(l)%drop_guessing ! change of load case? homogeneous guess for the first inc + guess = loadCases(l)%estimate_rate ! change of load case? homogeneous guess for the first inc incLooping: do inc = 1, loadCases(l)%N totalIncsCounter = totalIncsCounter + 1 From 8048d69a975c9e3b8dbba78f1843c68c344168b9 Mon Sep 17 00:00:00 2001 From: Franz Roters Date: Fri, 5 Feb 2021 16:59:28 +0100 Subject: [PATCH 201/352] [skip ci] logic inverted --- src/grid/DAMASK_grid.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 2c9f11285..7e649ff38 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -36,7 +36,7 @@ program DAMASK_grid integer :: N, & !< number of increments f_out, & !< frequency of result writes f_restart !< frequency of restart writes - logical :: estimate_rate !< do not follow trajectory of former loadcase + logical :: estimate_rate !< follow trajectory of former loadcase integer(kind(FIELD_UNDEFINED_ID)), allocatable :: ID(:) end type tLoadCase From 09c2d7f3f32b81daa6866e6cbca9779115770d13 Mon Sep 17 00:00:00 2001 From: Franz Roters Date: Fri, 5 Feb 2021 17:12:00 +0100 Subject: [PATCH 202/352] updated tests --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 1c2dd13c9..d90babadf 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 1c2dd13c9aea21d341e579fe66e4bef5c48ce07e +Subproject commit d90babadfb0a33afa1b793044cc4efd4d7430731 From d5c98bbf62f246e551a0346832a57bd04e023f20 Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 5 Feb 2021 18:46:17 +0100 Subject: [PATCH 203/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-415-g09c2d7f3f --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b7d460b2d..b91ec55e4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-407-g47f52b909 +v3.0.0-alpha2-415-g09c2d7f3f From 869307c5ecda89b712267de5103b8c2af16cf220 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 7 Feb 2021 15:05:38 +0100 Subject: [PATCH 204/352] temperature not needed for pure mechanics would also require to define thermal homogenization --- PRIVATE | 2 +- examples/SpectralMethod/Polycrystal/shearXY.yaml | 3 --- examples/SpectralMethod/Polycrystal/shearZX.yaml | 3 --- examples/SpectralMethod/Polycrystal/tensionX.yaml | 3 --- python/damask/_configmaterial.py | 14 +++++++------- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/PRIVATE b/PRIVATE index d90babadf..91a4329a6 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit d90babadfb0a33afa1b793044cc4efd4d7430731 +Subproject commit 91a4329a6fe073fc2ef17e5c2c8e2f796e3b897b diff --git a/examples/SpectralMethod/Polycrystal/shearXY.yaml b/examples/SpectralMethod/Polycrystal/shearXY.yaml index fe746e7ac..58471e8f1 100644 --- a/examples/SpectralMethod/Polycrystal/shearXY.yaml +++ b/examples/SpectralMethod/Polycrystal/shearXY.yaml @@ -3,9 +3,6 @@ solver: mechanical: spectral_basic -initial_conditions: - T: 300 #in Kelvin - loadstep: - boundary_conditions: mechanical: diff --git a/examples/SpectralMethod/Polycrystal/shearZX.yaml b/examples/SpectralMethod/Polycrystal/shearZX.yaml index 5d977b4ba..a32fafb85 100644 --- a/examples/SpectralMethod/Polycrystal/shearZX.yaml +++ b/examples/SpectralMethod/Polycrystal/shearZX.yaml @@ -3,9 +3,6 @@ solver: mechanical: spectral_basic -initial_conditions: - T: 300 #in Kelvin - loadstep: - boundary_conditions: mechanical: diff --git a/examples/SpectralMethod/Polycrystal/tensionX.yaml b/examples/SpectralMethod/Polycrystal/tensionX.yaml index 0809fd53d..870755d58 100644 --- a/examples/SpectralMethod/Polycrystal/tensionX.yaml +++ b/examples/SpectralMethod/Polycrystal/tensionX.yaml @@ -3,9 +3,6 @@ solver: mechanical: spectral_basic -initial_conditions: - T: 300 #in Kelvin - loadstep: - boundary_conditions: mechanical: diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index d3ed972e3..0adc494b8 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -168,11 +168,11 @@ class ConfigMaterial(Config): ok = False if 'material' in self: - for i,v in enumerate(self['material']): - if 'constituents' in v: - f = 0.0 - for c in v['constituents']: - f+= float(c['v']) + for i,m in enumerate(self['material']): + if 'constituents' in m: + v = 0.0 + for c in m['constituents']: + v+= float(c['v']) if 'O' in c: try: Rotation.from_quaternion(c['O']) @@ -180,8 +180,8 @@ class ConfigMaterial(Config): o = c['O'] print(f"Invalid orientation: '{o}' in material '{i}'") ok = False - if not np.isclose(f,1.0): - print(f"Invalid total fraction '{f}' in material '{i}'") + if not np.isclose(v,1.0): + print(f"Invalid total fraction (v) '{v}' in material '{i}'") ok = False return ok From 4bcbcb34d00790844d4c00a1b86e1df284af825e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 9 Feb 2021 23:34:51 +0100 Subject: [PATCH 205/352] ensures that at least one orientation in the FZ is found --- python/damask/_orientation.py | 24 ++++++++++++------------ python/tests/test_Orientation.py | 11 +++++++++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index cf31f4089..184315111 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -481,26 +481,26 @@ class Orientation(Rotation): if self.family is None: raise ValueError('Missing crystal symmetry') - rho_abs = np.abs(self.as_Rodrigues_vector(compact=True)) + rho_abs = np.abs(self.as_Rodrigues_vector(compact=True))*(1.-1.e-9) with np.errstate(invalid='ignore'): # using '*'/prod for 'and' if self.family == 'cubic': return (np.prod(np.sqrt(2)-1. >= rho_abs,axis=-1) * - (1. >= np.sum(rho_abs,axis=-1))).astype(np.bool) + (1. >= np.sum(rho_abs,axis=-1))).astype(bool) elif self.family == 'hexagonal': return (np.prod(1. >= rho_abs,axis=-1) * (2. >= np.sqrt(3)*rho_abs[...,0] + rho_abs[...,1]) * (2. >= np.sqrt(3)*rho_abs[...,1] + rho_abs[...,0]) * - (2. >= np.sqrt(3) + rho_abs[...,2])).astype(np.bool) + (2. >= np.sqrt(3) + rho_abs[...,2])).astype(bool) elif self.family == 'tetragonal': return (np.prod(1. >= rho_abs[...,:2],axis=-1) * (np.sqrt(2) >= rho_abs[...,0] + rho_abs[...,1]) * - (np.sqrt(2) >= rho_abs[...,2] + 1.)).astype(np.bool) + (np.sqrt(2) >= rho_abs[...,2] + 1.)).astype(bool) elif self.family == 'orthorhombic': - return (np.prod(1. >= rho_abs,axis=-1)).astype(np.bool) + return (np.prod(1. >= rho_abs,axis=-1)).astype(bool) elif self.family == 'monoclinic': - return (1. >= rho_abs[...,1]).astype(np.bool) + return (1. >= rho_abs[...,1]).astype(bool) else: return np.all(np.isfinite(rho_abs),axis=-1) @@ -524,28 +524,28 @@ class Orientation(Rotation): if self.family is None: raise ValueError('Missing crystal symmetry') - rho = self.as_Rodrigues_vector(compact=True) + rho = self.as_Rodrigues_vector(compact=True)*(1.0-1.0e-9) with np.errstate(invalid='ignore'): if self.family == 'cubic': return ((rho[...,0] >= rho[...,1]) & (rho[...,1] >= rho[...,2]) & - (rho[...,2] >= 0)).astype(np.bool) + (rho[...,2] >= 0)).astype(bool) elif self.family == 'hexagonal': return ((rho[...,0] >= rho[...,1]*np.sqrt(3)) & (rho[...,1] >= 0) & - (rho[...,2] >= 0)).astype(np.bool) + (rho[...,2] >= 0)).astype(bool) elif self.family == 'tetragonal': return ((rho[...,0] >= rho[...,1]) & (rho[...,1] >= 0) & - (rho[...,2] >= 0)).astype(np.bool) + (rho[...,2] >= 0)).astype(bool) elif self.family == 'orthorhombic': return ((rho[...,0] >= 0) & (rho[...,1] >= 0) & - (rho[...,2] >= 0)).astype(np.bool) + (rho[...,2] >= 0)).astype(bool) elif self.family == 'monoclinic': return ((rho[...,1] >= 0) & - (rho[...,2] >= 0)).astype(np.bool) + (rho[...,2] >= 0)).astype(bool) else: return np.ones_like(rho[...,0],dtype=bool) diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 436b73c04..4d1f958e2 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -7,6 +7,7 @@ from damask import Orientation from damask import Table from damask import lattice from damask import util +from damask import grid_filters @pytest.fixture @@ -220,6 +221,16 @@ class TestOrientation: o = Orientation.from_random(lattice=lattice,shape=shape) for r, theO in zip(o.reduced.flatten(),o.flatten()): assert r == theO.reduced + + @pytest.mark.parametrize('lattice',Orientation.crystal_families) + def test_reduced_corner_cases(self,lattice): + # test whether there is always a sym-eq rotation that falls into the FZ + N = np.random.randint(10,40) + size = np.ones(3)*np.pi**(2./3.) + grid = grid_filters.coordinates0_node([N+1,N+1,N+1],size,-size*.5) + evenly_distributed = Orientation.from_cubochoric(c=grid[:-2,:-2,:-2],lattice=lattice) + assert evenly_distributed.shape == evenly_distributed.reduced.shape + @pytest.mark.parametrize('lattice',Orientation.crystal_families) @pytest.mark.parametrize('shape',[(1),(2,3),(4,3,2)]) From 5b8e1996273572de5c36e8d1fcaec22ac89a6820 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 9 Feb 2021 23:09:41 +0100 Subject: [PATCH 206/352] avoid errors related to CRLF (windows) file endings --- src/IO.f90 | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index fd87907aa..33ab7ee97 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -65,8 +65,8 @@ end subroutine IO_init function IO_readlines(fileName) result(fileContent) character(len=*), intent(in) :: fileName - character(len=pStringLen), dimension(:), allocatable :: fileContent !< file content, separated per lines + character(len=pStringLen) :: line character(len=:), allocatable :: rawData integer :: & @@ -75,6 +75,7 @@ function IO_readlines(fileName) result(fileContent) l logical :: warned + rawData = IO_read(fileName) !-------------------------------------------------------------------------------------------------- @@ -112,17 +113,20 @@ end function IO_readlines !-------------------------------------------------------------------------------------------------- !> @brief Read whole file. -!> @details ensures that the string ends with a new line (expected UNIX behavior) +!> @details ensures that the string ends with a new line (expected UNIX behavior) and rejects +! windows (CRLF) line endings !-------------------------------------------------------------------------------------------------- function IO_read(fileName) result(fileContent) character(len=*), intent(in) :: fileName character(len=:), allocatable :: fileContent + integer :: & fileLength, & fileUnit, & myStat + inquire(file = fileName, size=fileLength) open(newunit=fileUnit, file=fileName, access='stream',& status='old', position='rewind', action='read',iostat=myStat) @@ -137,6 +141,8 @@ function IO_read(fileName) result(fileContent) if(myStat /= 0) call IO_error(102,ext_msg=trim(fileName)) close(fileUnit) + if(scan(fileContent,achar(13)) /= 0) call IO_error(115) + if(fileContent(fileLength:fileLength) /= IO_EOL) fileContent = fileContent//IO_EOL ! ensure EOL@EOF end function IO_read @@ -151,6 +157,7 @@ logical pure function IO_isBlank(string) integer :: posNonBlank + posNonBlank = verify(string,IO_WHITESPACE) IO_isBlank = posNonBlank == 0 .or. posNonBlank == scan(string,IO_COMMENT) @@ -170,6 +177,7 @@ pure function IO_stringPos(string) integer :: left, right + allocate(IO_stringPos(1), source=0) right = 0 @@ -249,6 +257,7 @@ pure function IO_lc(string) integer :: i,n + do i=1,len(string) n = index(UPPER,string(i:i)) if(n/=0) then @@ -271,6 +280,7 @@ function IO_rmComment(line) character(len=:), allocatable :: IO_rmComment integer :: split + split = index(line,IO_COMMENT) if (split == 0) then @@ -292,6 +302,7 @@ integer function IO_stringAsInt(string) integer :: readStatus character(len=*), parameter :: VALIDCHARS = '0123456789+- ' + valid: if (verify(string,VALIDCHARS) == 0) then read(string,*,iostat=readStatus) IO_stringAsInt if (readStatus /= 0) call IO_error(111,ext_msg=string) @@ -313,6 +324,7 @@ real(pReal) function IO_stringAsFloat(string) integer :: readStatus character(len=*), parameter :: VALIDCHARS = '0123456789eE.+- ' + valid: if (verify(string,VALIDCHARS) == 0) then read(string,*,iostat=readStatus) IO_stringAsFloat if (readStatus /= 0) call IO_error(112,ext_msg=string) @@ -331,6 +343,7 @@ logical function IO_stringAsBool(string) character(len=*), intent(in) :: string !< string for conversion to int value + if (trim(adjustl(string)) == 'True' .or. trim(adjustl(string)) == 'true') then IO_stringAsBool = .true. elseif (trim(adjustl(string)) == 'False' .or. trim(adjustl(string)) == 'false') then @@ -356,6 +369,7 @@ subroutine IO_error(error_ID,el,ip,g,instance,ext_msg) character(len=:), allocatable :: msg character(len=pStringLen) :: formatString + select case (error_ID) !-------------------------------------------------------------------------------------------------- @@ -382,6 +396,9 @@ subroutine IO_error(error_ID,el,ip,g,instance,ext_msg) msg = 'invalid character for logical:' case (114) msg = 'cannot decode base64 string:' + case (115) + msg = 'found CR. Windows file endings (CRLF) are not supported.' + !-------------------------------------------------------------------------------------------------- ! lattice error messages From ef45e856a15cb1f265b08f5c8934a8fc28ad6489 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 10 Feb 2021 09:07:42 +0100 Subject: [PATCH 207/352] don't scan the whole file in case of proper line endings might lead to strange behavior if people randomly distribute CRs in their file. But that actually deserves to get strange behavior + Test --- PRIVATE | 2 +- src/IO.f90 | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/PRIVATE b/PRIVATE index d90babadf..5d27d879a 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit d90babadfb0a33afa1b793044cc4efd4d7430731 +Subproject commit 5d27d879abaeb1542e3f9f3065172be740af2899 diff --git a/src/IO.f90 b/src/IO.f90 index 33ab7ee97..36b774191 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -124,7 +124,9 @@ function IO_read(fileName) result(fileContent) integer :: & fileLength, & fileUnit, & - myStat + myStat, & + firstEOL + character, parameter :: CR = achar(13) inquire(file = fileName, size=fileLength) @@ -141,10 +143,12 @@ function IO_read(fileName) result(fileContent) if(myStat /= 0) call IO_error(102,ext_msg=trim(fileName)) close(fileUnit) - if(scan(fileContent,achar(13)) /= 0) call IO_error(115) if(fileContent(fileLength:fileLength) /= IO_EOL) fileContent = fileContent//IO_EOL ! ensure EOL@EOF + firstEOL = index(fileContent,IO_EOL) + if(scan(fileContent(firstEOL:firstEOL),CR) /= 0) call IO_error(115) + end function IO_read From 6895ef6b18b2cc3b3c26d0ab09c81e0115016b21 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 10 Feb 2021 10:03:35 +0100 Subject: [PATCH 208/352] always write LF line endings small pitfall: I windows users use a filehandle that results from a call to open() without the newline option, they get still CRLF line endings --- python/damask/_colormap.py | 16 ++++++++-------- python/damask/_config.py | 2 +- python/damask/_result.py | 2 +- python/damask/_table.py | 2 +- python/damask/solver/_marc.py | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index 5a22f049b..8af14e081 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -238,7 +238,7 @@ class Colormap(mpl.colors.ListedColormap): fhandle = None else: try: - fhandle = open(fname,'w') + fhandle = open(fname,'w',newline='\n') except TypeError: fhandle = fname @@ -254,7 +254,7 @@ class Colormap(mpl.colors.ListedColormap): 'RGBPoints':colors }] - with open(self.name.replace(' ','_')+'.json', 'w') if fhandle is None else fhandle as f: + with open(self.name.replace(' ','_')+'.json','w',newline='\n') if fhandle is None else fhandle as f: json.dump(out, f,indent=4) @@ -273,14 +273,14 @@ class Colormap(mpl.colors.ListedColormap): fhandle = None else: try: - fhandle = open(fname,'w') + fhandle = open(fname,'w',newline='\n') except TypeError: fhandle = fname labels = {'RGBA':4} if self.colors.shape[1] == 4 else {'RGB': 3} t = Table(self.colors,labels,f'Creator: {util.execution_stamp("Colormap")}') - with open(self.name.replace(' ','_')+'.txt', 'w') if fhandle is None else fhandle as f: + with open(self.name.replace(' ','_')+'.txt','w',newline='\n') if fhandle is None else fhandle as f: t.save(f) @@ -299,7 +299,7 @@ class Colormap(mpl.colors.ListedColormap): fhandle = None else: try: - fhandle = open(fname,'w') + fhandle = open(fname,'w',newline='\n') except TypeError: fhandle = fname # ToDo: test in GOM @@ -308,7 +308,7 @@ class Colormap(mpl.colors.ListedColormap): + f'30 NO_UNIT 1 1 64 64 64 255 1 0 0 0 0 0 0 3 0 {len(self.colors)}' \ + ' '.join([f' 0 {c[0]} {c[1]} {c[2]} 255 1' for c in reversed((self.colors*255).astype(int))]) \ + '\n' - with open(self.name.replace(' ','_')+'.legend', 'w') if fhandle is None else fhandle as f: + with open(self.name.replace(' ','_')+'.legend','w',newline='\n') if fhandle is None else fhandle as f: f.write(GOM_str) @@ -327,14 +327,14 @@ class Colormap(mpl.colors.ListedColormap): fhandle = None else: try: - fhandle = open(fname,'w') + fhandle = open(fname,'w',newline='\n') except TypeError: fhandle = fname # ToDo: test in gmsh gmsh_str = 'View.ColorTable = {\n' \ +'\n'.join([f'{c[0]},{c[1]},{c[2]},' for c in self.colors[:,:3]*255]) \ +'\n}\n' - with open(self.name.replace(' ','_')+'.msh', 'w') if fhandle is None else fhandle as f: + with open(self.name.replace(' ','_')+'.msh','w',newline='\n') if fhandle is None else fhandle as f: f.write(gmsh_str) diff --git a/python/damask/_config.py b/python/damask/_config.py index 9aa031ff0..edf3a5676 100644 --- a/python/damask/_config.py +++ b/python/damask/_config.py @@ -75,7 +75,7 @@ class Config(dict): """ try: - fhandle = open(fname,'w') + fhandle = open(fname,'w',newline='\n') except TypeError: fhandle = fname diff --git a/python/damask/_result.py b/python/damask/_result.py index 3d8368911..6f2494299 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1287,7 +1287,7 @@ class Result: np.prod(shape))} data_items[-1].text=f'{os.path.split(self.fname)[1]}:{name}' - with open(self.fname.with_suffix('.xdmf').name,'w') as f: + with open(self.fname.with_suffix('.xdmf').name,'w',newline='\n') as f: f.write(xml.dom.minidom.parseString(ET.tostring(xdmf).decode()).toprettyxml()) diff --git a/python/damask/_table.py b/python/damask/_table.py index 78a8a276e..e9acb371d 100644 --- a/python/damask/_table.py +++ b/python/damask/_table.py @@ -380,7 +380,7 @@ class Table: [f'# {comment}' for comment in self.comments] try: - fhandle = open(fname,'w') + fhandle = open(fname,'w',newline='\n') except TypeError: fhandle = fname diff --git a/python/damask/solver/_marc.py b/python/damask/solver/_marc.py index d4aadb7ff..f6c81da9f 100644 --- a/python/damask/solver/_marc.py +++ b/python/damask/solver/_marc.py @@ -66,7 +66,7 @@ class Marc: if logfile is not None: try: - f = open(logfile,'w+') + f = open(logfile,'w+',newline='\n') except TypeError: f = logfile else: From 4e31862f0ff9cae6c89687bdad26ff660dd216d4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 10 Feb 2021 18:35:13 +0100 Subject: [PATCH 209/352] avoid repetition --- python/damask/_colormap.py | 75 ++++++++++++++++++-------------------- python/damask/_table.py | 2 +- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index 8af14e081..7e8860dae 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -223,25 +223,46 @@ class Colormap(mpl.colors.ListedColormap): return Colormap(np.array(rev.colors),rev.name[:-4] if rev.name.endswith('_r_r') else rev.name) - def save_paraview(self,fname=None): + def _get_file_handle(self,fname,extension): """ - Save as JSON file for use in Paraview. + Provide file handle. Parameters ---------- - fname : file, str, or pathlib.Path, optional. - Filename to store results. If not given, the filename will - consist of the name of the colormap and extension '.json'. + fname : file, str, pathlib.Path, or None + Filename or filehandle, will be name of the colormap+extension if None. + + extension: str + Extension of the filename. + + Returns + ------- + f + File handle """ if fname is None: - fhandle = None + fhandle = open(self.name.replace(' ','_')+'.'+extension,'w',newline='\n') else: try: fhandle = open(fname,'w',newline='\n') except TypeError: fhandle = fname + return fhandle + + + def save_paraview(self,fname=None): + """ + Save as JSON file for use in Paraview. + + Parameters + ---------- + fname : file, str, or pathlib.Path, optional + Filename to store results. If not given, the filename will + consist of the name of the colormap and extension '.json'. + + """ colors = [] for i,c in enumerate(np.round(self.colors,6).tolist()): colors+=[i]+c @@ -254,8 +275,7 @@ class Colormap(mpl.colors.ListedColormap): 'RGBPoints':colors }] - with open(self.name.replace(' ','_')+'.json','w',newline='\n') if fhandle is None else fhandle as f: - json.dump(out, f,indent=4) + json.dump(out,self._get_file_handle(fname,'json'),indent=4) def save_ASCII(self,fname=None): @@ -264,24 +284,14 @@ class Colormap(mpl.colors.ListedColormap): Parameters ---------- - fname : file, str, or pathlib.Path, optional. + fname : file, str, or pathlib.Path, optional Filename to store results. If not given, the filename will consist of the name of the colormap and extension '.txt'. """ - if fname is None: - fhandle = None - else: - try: - fhandle = open(fname,'w',newline='\n') - except TypeError: - fhandle = fname - labels = {'RGBA':4} if self.colors.shape[1] == 4 else {'RGB': 3} t = Table(self.colors,labels,f'Creator: {util.execution_stamp("Colormap")}') - - with open(self.name.replace(' ','_')+'.txt','w',newline='\n') if fhandle is None else fhandle as f: - t.save(f) + t.save(self._get_file_handle(fname,'txt')) def save_GOM(self,fname=None): @@ -290,26 +300,19 @@ class Colormap(mpl.colors.ListedColormap): Parameters ---------- - fname : file, str, or pathlib.Path, optional. + fname : file, str, or pathlib.Path, optional Filename to store results. If not given, the filename will consist of the name of the colormap and extension '.legend'. """ - if fname is None: - fhandle = None - else: - try: - fhandle = open(fname,'w',newline='\n') - except TypeError: - fhandle = fname # ToDo: test in GOM GOM_str = '1 1 {name} 9 {name} '.format(name=self.name.replace(" ","_")) \ + '0 1 0 3 0 0 -1 9 \\ 0 0 0 255 255 255 0 0 255 ' \ + f'30 NO_UNIT 1 1 64 64 64 255 1 0 0 0 0 0 0 3 0 {len(self.colors)}' \ + ' '.join([f' 0 {c[0]} {c[1]} {c[2]} 255 1' for c in reversed((self.colors*255).astype(int))]) \ + '\n' - with open(self.name.replace(' ','_')+'.legend','w',newline='\n') if fhandle is None else fhandle as f: - f.write(GOM_str) + + self._get_file_handle(fname,'legend').write(GOM_str) def save_gmsh(self,fname=None): @@ -318,24 +321,16 @@ class Colormap(mpl.colors.ListedColormap): Parameters ---------- - fname : file, str, or pathlib.Path, optional. + fname : file, str, or pathlib.Path, optional Filename to store results. If not given, the filename will consist of the name of the colormap and extension '.msh'. """ - if fname is None: - fhandle = None - else: - try: - fhandle = open(fname,'w',newline='\n') - except TypeError: - fhandle = fname # ToDo: test in gmsh gmsh_str = 'View.ColorTable = {\n' \ +'\n'.join([f'{c[0]},{c[1]},{c[2]},' for c in self.colors[:,:3]*255]) \ +'\n}\n' - with open(self.name.replace(' ','_')+'.msh','w',newline='\n') if fhandle is None else fhandle as f: - f.write(gmsh_str) + self._get_file_handle(fname,'msh').write(gmsh_str) @staticmethod diff --git a/python/damask/_table.py b/python/damask/_table.py index e9acb371d..68d6f94bf 100644 --- a/python/damask/_table.py +++ b/python/damask/_table.py @@ -26,7 +26,7 @@ class Table: comments_ = [comments] if isinstance(comments,str) else comments self.comments = [] if comments_ is None else [c for c in comments_] self.data = pd.DataFrame(data=data) - self.shapes = { k:(v,) if isinstance(v,(np.int,int)) else v for k,v in shapes.items() } + self.shapes = { k:(v,) if isinstance(v,(np.int64,np.int32,int)) else v for k,v in shapes.items() } self._label_uniform() def __repr__(self): From 992b4a7e6dab945b6d5dc3bb848e7ab310ffa0ab Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 11 Feb 2021 11:42:33 +0100 Subject: [PATCH 210/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-421-ge96352b0e --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b91ec55e4..a1f129287 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-415-g09c2d7f3f +v3.0.0-alpha2-421-ge96352b0e From e855083964794f44aa0793597c945091b5b34ff2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 8 Feb 2021 23:21:53 +0100 Subject: [PATCH 211/352] systematic names --- src/CPFEM.f90 | 6 +- src/CPFEM2.f90 | 10 +- src/commercialFEM_fileList.f90 | 34 +- src/grid/DAMASK_grid.f90 | 66 +-- src/grid/grid_mech_FEM.f90 | 135 +++--- src/grid/grid_mech_spectral_basic.f90 | 40 +- src/grid/grid_mech_spectral_polarisation.f90 | 40 +- src/homogenization.f90 | 32 +- src/homogenization_damage.f90 | 4 +- ...nics.f90 => homogenization_mechanical.f90} | 94 ++--- ....f90 => homogenization_mechanical_RGC.f90} | 24 +- ...> homogenization_mechanical_isostrain.f90} | 14 +- ...f90 => homogenization_mechanical_pass.f90} | 8 +- src/homogenization_thermal.f90 | 6 +- src/mesh/DAMASK_mesh.f90 | 8 +- src/mesh/FEM_utilities.f90 | 12 +- src/mesh/mesh_mech_FEM.f90 | 110 ++--- src/phase.f90 | 180 ++++---- src/phase_damage.f90 | 34 +- src/phase_damage_anisobrittle.f90 | 2 +- src/phase_damage_anisoductile.f90 | 2 +- src/phase_damage_isobrittle.f90 | 2 +- src/phase_damage_isoductile.f90 | 2 +- ...ase_mechanics.f90 => phase_mechanical.f90} | 384 +++++++++--------- ...rmation.f90 => phase_mechanical_eigen.f90} | 14 +- ...hase_mechanical_eigen_cleavageopening.f90} | 0 ...ase_mechanical_eigen_slipplaneopening.f90} | 0 ...ase_mechanical_eigen_thermalexpansion.f90} | 0 ...astic.f90 => phase_mechanical_plastic.f90} | 64 +-- ...hase_mechanical_plastic_dislotungsten.f90} | 16 +- ...=> phase_mechanical_plastic_dislotwin.f90} | 36 +- ...=> phase_mechanical_plastic_isotropic.f90} | 8 +- ...hase_mechanical_plastic_kinehardening.f90} | 16 +- ....f90 => phase_mechanical_plastic_none.f90} | 2 +- ... => phase_mechanical_plastic_nonlocal.f90} | 64 +-- ...hase_mechanical_plastic_phenopowerlaw.f90} | 22 +- src/phase_thermal.f90 | 14 +- src/phase_thermal_dissipation.f90 | 4 +- src/phase_thermal_externalheat.f90 | 2 +- 39 files changed, 769 insertions(+), 742 deletions(-) rename src/{homogenization_mechanics.f90 => homogenization_mechanical.f90} (79%) rename src/{homogenization_mechanics_RGC.f90 => homogenization_mechanical_RGC.f90} (98%) rename src/{homogenization_mechanics_isostrain.f90 => homogenization_mechanical_isostrain.f90} (91%) rename src/{homogenization_mechanics_none.f90 => homogenization_mechanical_pass.f90} (87%) rename src/{phase_mechanics.f90 => phase_mechanical.f90} (82%) rename src/{phase_mechanics_eigendeformation.f90 => phase_mechanical_eigen.f90} (96%) rename src/{phase_mechanics_eigendeformation_cleavageopening.f90 => phase_mechanical_eigen_cleavageopening.f90} (100%) rename src/{phase_mechanics_eigendeformation_slipplaneopening.f90 => phase_mechanical_eigen_slipplaneopening.f90} (100%) rename src/{phase_mechanics_eigendeformation_thermalexpansion.f90 => phase_mechanical_eigen_thermalexpansion.f90} (100%) rename src/{phase_mechanics_plastic.f90 => phase_mechanical_plastic.f90} (91%) rename src/{phase_mechanics_plastic_dislotungsten.f90 => phase_mechanical_plastic_dislotungsten.f90} (97%) rename src/{phase_mechanics_plastic_dislotwin.f90 => phase_mechanical_plastic_dislotwin.f90} (97%) rename src/{phase_mechanics_plastic_isotropic.f90 => phase_mechanical_plastic_isotropic.f90} (97%) rename src/{phase_mechanics_plastic_kinehardening.f90 => phase_mechanical_plastic_kinehardening.f90} (97%) rename src/{phase_mechanics_plastic_none.f90 => phase_mechanical_plastic_none.f90} (96%) rename src/{phase_mechanics_plastic_nonlocal.f90 => phase_mechanical_plastic_nonlocal.f90} (97%) rename src/{phase_mechanics_plastic_phenopowerlaw.f90 => phase_mechanical_plastic_phenopowerlaw.f90} (96%) diff --git a/src/CPFEM.f90 b/src/CPFEM.f90 index e441339cb..f0e510433 100644 --- a/src/CPFEM.f90 +++ b/src/CPFEM.f90 @@ -85,7 +85,7 @@ subroutine CPFEM_initAll call discretization_marc_init call lattice_init call material_init(.false.) - call constitutive_init + call phase_init call homogenization_init call crystallite_init call CPFEM_init @@ -257,7 +257,7 @@ end subroutine CPFEM_general subroutine CPFEM_forward call homogenization_forward - call constitutive_forward + call phase_forward end subroutine CPFEM_forward @@ -272,7 +272,7 @@ subroutine CPFEM_results(inc,time) call results_openJobFile call results_addIncrement(inc,time) - call constitutive_results + call phase_results call homogenization_results call discretization_results call results_finalizeIncrement diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index 2b32a0cbb..e57de7f67 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -60,7 +60,7 @@ subroutine CPFEM_initAll call discretization_grid_init(restart=interface_restartInc>0) #endif call material_init(restart=interface_restartInc>0) - call constitutive_init + call phase_init call homogenization_init call crystallite_init call CPFEM_init @@ -87,7 +87,7 @@ subroutine CPFEM_init fileHandle = HDF5_openFile(fileName) call homogenization_restartRead(fileHandle) - call constitutive_restartRead(fileHandle) + call phase_restartRead(fileHandle) call HDF5_closeFile(fileHandle) endif @@ -110,7 +110,7 @@ subroutine CPFEM_restartWrite fileHandle = HDF5_openFile(fileName,'a') call homogenization_restartWrite(fileHandle) - call constitutive_restartWrite(fileHandle) + call phase_restartWrite(fileHandle) call HDF5_closeFile(fileHandle) @@ -123,7 +123,7 @@ end subroutine CPFEM_restartWrite subroutine CPFEM_forward call homogenization_forward - call constitutive_forward + call phase_forward end subroutine CPFEM_forward @@ -138,7 +138,7 @@ subroutine CPFEM_results(inc,time) call results_openJobFile call results_addIncrement(inc,time) - call constitutive_results + call phase_results call homogenization_results call discretization_results call results_finalizeIncrement diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index 6480f7382..a191298a3 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -20,19 +20,19 @@ #include "material.f90" #include "lattice.f90" #include "phase.f90" -#include "phase_mechanics.f90" -#include "phase_mechanics_plastic.f90" -#include "phase_mechanics_plastic_none.f90" -#include "phase_mechanics_plastic_isotropic.f90" -#include "phase_mechanics_plastic_phenopowerlaw.f90" -#include "phase_mechanics_plastic_kinehardening.f90" -#include "phase_mechanics_plastic_dislotwin.f90" -#include "phase_mechanics_plastic_dislotungsten.f90" -#include "phase_mechanics_plastic_nonlocal.f90" -#include "phase_mechanics_eigendeformation.f90" -#include "phase_mechanics_eigendeformation_cleavageopening.f90" -#include "phase_mechanics_eigendeformation_slipplaneopening.f90" -#include "phase_mechanics_eigendeformation_thermalexpansion.f90" +#include "phase_mechanical.f90" +#include "phase_mechanical_plastic.f90" +#include "phase_mechanical_plastic_none.f90" +#include "phase_mechanical_plastic_isotropic.f90" +#include "phase_mechanical_plastic_phenopowerlaw.f90" +#include "phase_mechanical_plastic_kinehardening.f90" +#include "phase_mechanical_plastic_dislotwin.f90" +#include "phase_mechanical_plastic_dislotungsten.f90" +#include "phase_mechanical_plastic_nonlocal.f90" +#include "phase_mechanical_eigen.f90" +#include "phase_mechanical_eigen_cleavageopening.f90" +#include "phase_mechanical_eigen_slipplaneopening.f90" +#include "phase_mechanical_eigen_thermalexpansion.f90" #include "phase_thermal.f90" #include "phase_thermal_dissipation.f90" #include "phase_thermal_externalheat.f90" @@ -44,10 +44,10 @@ #include "damage_none.f90" #include "damage_nonlocal.f90" #include "homogenization.f90" -#include "homogenization_mechanics.f90" -#include "homogenization_mechanics_none.f90" -#include "homogenization_mechanics_isostrain.f90" -#include "homogenization_mechanics_RGC.f90" +#include "homogenization_mechanical.f90" +#include "homogenization_mechanical_pass.f90" +#include "homogenization_mechanical_isostrain.f90" +#include "homogenization_mechanical_RGC.f90" #include "homogenization_thermal.f90" #include "homogenization_damage.f90" #include "CPFEM.f90" diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 7e649ff38..ed1ada171 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -18,9 +18,9 @@ program DAMASK_grid use CPFEM2 use material use spectral_utilities - use grid_mech_spectral_basic - use grid_mech_spectral_polarisation - use grid_mech_FEM + use grid_mechanical_spectral_basic + use grid_mechanical_spectral_polarisation + use grid_mechanical_FEM use grid_damage_spectral use grid_thermal_spectral use results @@ -83,16 +83,16 @@ program DAMASK_grid type(tLoadCase), allocatable, dimension(:) :: loadCases !< array of all load cases type(tSolutionState), allocatable, dimension(:) :: solres - procedure(grid_mech_spectral_basic_init), pointer :: & - mech_init - procedure(grid_mech_spectral_basic_forward), pointer :: & - mech_forward - procedure(grid_mech_spectral_basic_solution), pointer :: & - mech_solution - procedure(grid_mech_spectral_basic_updateCoords), pointer :: & - mech_updateCoords - procedure(grid_mech_spectral_basic_restartWrite), pointer :: & - mech_restartWrite + procedure(grid_mechanical_spectral_basic_init), pointer :: & + mechanical_init + procedure(grid_mechanical_spectral_basic_forward), pointer :: & + mechanical_forward + procedure(grid_mechanical_spectral_basic_solution), pointer :: & + mechanical_solution + procedure(grid_mechanical_spectral_basic_updateCoords), pointer :: & + mechanical_updateCoords + procedure(grid_mechanical_spectral_basic_restartWrite), pointer :: & + mechanical_restartWrite external :: & quit @@ -139,25 +139,25 @@ program DAMASK_grid debug_grid => config_debug%get('grid',defaultVal=emptyList) select case (trim(num_grid%get_asString('solver', defaultVal = 'Basic'))) case ('Basic') - mech_init => grid_mech_spectral_basic_init - mech_forward => grid_mech_spectral_basic_forward - mech_solution => grid_mech_spectral_basic_solution - mech_updateCoords => grid_mech_spectral_basic_updateCoords - mech_restartWrite => grid_mech_spectral_basic_restartWrite + mechanical_init => grid_mechanical_spectral_basic_init + mechanical_forward => grid_mechanical_spectral_basic_forward + mechanical_solution => grid_mechanical_spectral_basic_solution + mechanical_updateCoords => grid_mechanical_spectral_basic_updateCoords + mechanical_restartWrite => grid_mechanical_spectral_basic_restartWrite case ('Polarisation') - mech_init => grid_mech_spectral_polarisation_init - mech_forward => grid_mech_spectral_polarisation_forward - mech_solution => grid_mech_spectral_polarisation_solution - mech_updateCoords => grid_mech_spectral_polarisation_updateCoords - mech_restartWrite => grid_mech_spectral_polarisation_restartWrite + mechanical_init => grid_mechanical_spectral_polarisation_init + mechanical_forward => grid_mechanical_spectral_polarisation_forward + mechanical_solution => grid_mechanical_spectral_polarisation_solution + mechanical_updateCoords => grid_mechanical_spectral_polarisation_updateCoords + mechanical_restartWrite => grid_mechanical_spectral_polarisation_restartWrite case ('FEM') - mech_init => grid_mech_FEM_init - mech_forward => grid_mech_FEM_forward - mech_solution => grid_mech_FEM_solution - mech_updateCoords => grid_mech_FEM_updateCoords - mech_restartWrite => grid_mech_FEM_restartWrite + mechanical_init => grid_mechanical_FEM_init + mechanical_forward => grid_mechanical_FEM_forward + mechanical_solution => grid_mechanical_FEM_solution + mechanical_updateCoords => grid_mechanical_FEM_updateCoords + mechanical_restartWrite => grid_mechanical_FEM_restartWrite case default call IO_error(error_ID = 891, ext_msg = trim(num_grid%get_asString('solver'))) @@ -303,7 +303,7 @@ program DAMASK_grid do field = 1, nActiveFields select case (loadCases(1)%ID(field)) case(FIELD_MECH_ID) - call mech_init + call mechanical_init case(FIELD_THERMAL_ID) call grid_thermal_spectral_init @@ -379,7 +379,7 @@ program DAMASK_grid do field = 1, nActiveFields select case(loadCases(l)%ID(field)) case(FIELD_MECH_ID) - call mech_forward (& + call mechanical_forward (& cutBack,guess,timeinc,timeIncOld,remainingLoadCaseTime, & deformation_BC = loadCases(l)%deformation, & stress_BC = loadCases(l)%stress, & @@ -399,7 +399,7 @@ program DAMASK_grid do field = 1, nActiveFields select case(loadCases(l)%ID(field)) case(FIELD_MECH_ID) - solres(field) = mech_solution(incInfo) + solres(field) = mechanical_solution(incInfo) case(FIELD_THERMAL_ID) solres(field) = grid_thermal_spectral_solution(timeinc) case(FIELD_DAMAGE_ID) @@ -420,7 +420,7 @@ program DAMASK_grid if ( (all(solres(:)%converged .and. solres(:)%stagConverged)) & ! converged .and. .not. solres(1)%termIll) then ! and acceptable solution found - call mech_updateCoords + call mechanical_updateCoords timeIncOld = timeinc cutBack = .false. guess = .true. ! start guessing after first converged (sub)inc @@ -463,7 +463,7 @@ program DAMASK_grid call MPI_Allreduce(interface_SIGUSR2,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) if (ierr /= 0) error stop 'MPI error' if (mod(inc,loadCases(l)%f_restart) == 0 .or. signal) then - call mech_restartWrite + call mechanical_restartWrite call CPFEM_restartWrite endif if(signal) call interface_setSIGUSR2(.false.) diff --git a/src/grid/grid_mech_FEM.f90 b/src/grid/grid_mech_FEM.f90 index 003f568c6..806973a4d 100644 --- a/src/grid/grid_mech_FEM.f90 +++ b/src/grid/grid_mech_FEM.f90 @@ -4,7 +4,7 @@ !> @author Pratheek Shanthraj, Max-Planck-Institut für Eisenforschung GmbH !> @brief Grid solver for mechanics: FEM !-------------------------------------------------------------------------------------------------- -module grid_mech_FEM +module grid_mechanical_FEM #include #include use PETScdmda @@ -45,8 +45,8 @@ module grid_mech_FEM !-------------------------------------------------------------------------------------------------- ! PETSc data - DM :: mech_grid - SNES :: mech_snes + DM :: mechanical_grid + SNES :: mechanical_snes Vec :: solution_current, solution_lastInc, solution_rate !-------------------------------------------------------------------------------------------------- @@ -79,18 +79,18 @@ module grid_mech_FEM totalIter = 0 !< total iteration in current increment public :: & - grid_mech_FEM_init, & - grid_mech_FEM_solution, & - grid_mech_FEM_forward, & - grid_mech_FEM_updateCoords, & - grid_mech_FEM_restartWrite + grid_mechanical_FEM_init, & + grid_mechanical_FEM_solution, & + grid_mechanical_FEM_forward, & + grid_mechanical_FEM_updateCoords, & + grid_mechanical_FEM_restartWrite contains !-------------------------------------------------------------------------------------------------- !> @brief allocates all necessary fields and fills them with data, potentially from restart info !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_FEM_init +subroutine grid_mechanical_FEM_init real(pReal), parameter :: HGCoeff = 0.0e-2_pReal real(pReal), parameter, dimension(4,8) :: & @@ -114,7 +114,7 @@ subroutine grid_mech_FEM_init num_grid, & debug_grid - print'(/,a)', ' <<<+- grid_mech_FEM init -+>>>'; flush(IO_STDOUT) + print'(/,a)', ' <<<+- grid_mechanical_FEM init -+>>>'; flush(IO_STDOUT) !------------------------------------------------------------------------------------------------- ! debugging options @@ -141,8 +141,11 @@ subroutine grid_mech_FEM_init !-------------------------------------------------------------------------------------------------- ! set default and user defined options for PETSc - call PetscOptionsInsertString(PETSC_NULL_OPTIONS,'-mech_snes_type newtonls -mech_ksp_type fgmres & - &-mech_ksp_max_it 25 -mech_pc_type ml -mech_mg_levels_ksp_type chebyshev',ierr) + call PetscOptionsInsertString(PETSC_NULL_OPTIONS, & + '-mechanical_snes_type newtonls -mechanical_ksp_type fgmres & + &-mechanical_ksp_max_it 25 -mechanical_pc_type ml & + &-mechanical_mg_levels_ksp_type chebyshev', & + ierr) CHKERRQ(ierr) call PetscOptionsInsertString(PETSC_NULL_OPTIONS,num_grid%get_asString('petsc_options',defaultVal=''),ierr) CHKERRQ(ierr) @@ -155,8 +158,10 @@ subroutine grid_mech_FEM_init !-------------------------------------------------------------------------------------------------- ! initialize solver specific parts of PETSc - call SNESCreate(PETSC_COMM_WORLD,mech_snes,ierr); CHKERRQ(ierr) - call SNESSetOptionsPrefix(mech_snes,'mech_',ierr);CHKERRQ(ierr) + call SNESCreate(PETSC_COMM_WORLD,mechanical_snes,ierr) + CHKERRQ(ierr) + call SNESSetOptionsPrefix(mechanical_snes,'mechanical_',ierr) + CHKERRQ(ierr) localK = 0 localK(worldrank) = grid3 call MPI_Allreduce(MPI_IN_PLACE,localK,worldsize,MPI_INTEGER,MPI_SUM,PETSC_COMM_WORLD,ierr) @@ -167,34 +172,44 @@ subroutine grid_mech_FEM_init 1, 1, worldsize, & 3, 1, & [grid(1)],[grid(2)],localK, & - mech_grid,ierr) + mechanical_grid,ierr) CHKERRQ(ierr) - call SNESSetDM(mech_snes,mech_grid,ierr); CHKERRQ(ierr) - call DMsetFromOptions(mech_grid,ierr); CHKERRQ(ierr) - call DMsetUp(mech_grid,ierr); CHKERRQ(ierr) - call DMDASetUniformCoordinates(mech_grid,0.0_pReal,geomSize(1),0.0_pReal,geomSize(2),0.0_pReal,geomSize(3),ierr) + call SNESSetDM(mechanical_snes,mechanical_grid,ierr) CHKERRQ(ierr) - call DMCreateGlobalVector(mech_grid,solution_current,ierr); CHKERRQ(ierr) - call DMCreateGlobalVector(mech_grid,solution_lastInc,ierr); CHKERRQ(ierr) - call DMCreateGlobalVector(mech_grid,solution_rate ,ierr); CHKERRQ(ierr) - call DMSNESSetFunctionLocal(mech_grid,formResidual,PETSC_NULL_SNES,ierr) + call DMsetFromOptions(mechanical_grid,ierr) CHKERRQ(ierr) - call DMSNESSetJacobianLocal(mech_grid,formJacobian,PETSC_NULL_SNES,ierr) + call DMsetUp(mechanical_grid,ierr) CHKERRQ(ierr) - call SNESSetConvergenceTest(mech_snes,converged,PETSC_NULL_SNES,PETSC_NULL_FUNCTION,ierr) ! specify custom convergence check function "_converged" + call DMDASetUniformCoordinates(mechanical_grid,0.0_pReal,geomSize(1),0.0_pReal,geomSize(2),0.0_pReal,geomSize(3),ierr) + CHKERRQ(ierr) + call DMCreateGlobalVector(mechanical_grid,solution_current,ierr) + CHKERRQ(ierr) + call DMCreateGlobalVector(mechanical_grid,solution_lastInc,ierr) + CHKERRQ(ierr) + call DMCreateGlobalVector(mechanical_grid,solution_rate ,ierr) + CHKERRQ(ierr) + call DMSNESSetFunctionLocal(mechanical_grid,formResidual,PETSC_NULL_SNES,ierr) + CHKERRQ(ierr) + call DMSNESSetJacobianLocal(mechanical_grid,formJacobian,PETSC_NULL_SNES,ierr) + CHKERRQ(ierr) + call SNESSetConvergenceTest(mechanical_snes,converged,PETSC_NULL_SNES,PETSC_NULL_FUNCTION,ierr) ! specify custom convergence check function "_converged" + CHKERRQ(ierr) + call SNESSetMaxLinearSolveFailures(mechanical_snes, huge(1), ierr) ! ignore linear solve failures + CHKERRQ(ierr) + call SNESSetFromOptions(mechanical_snes,ierr) ! pull it all together with additional cli arguments CHKERRQ(ierr) - call SNESSetMaxLinearSolveFailures(mech_snes, huge(1), ierr); CHKERRQ(ierr) ! ignore linear solve failures - call SNESSetFromOptions(mech_snes,ierr); CHKERRQ(ierr) ! pull it all together with additional cli arguments !-------------------------------------------------------------------------------------------------- ! init fields call VecSet(solution_current,0.0_pReal,ierr);CHKERRQ(ierr) call VecSet(solution_lastInc,0.0_pReal,ierr);CHKERRQ(ierr) call VecSet(solution_rate ,0.0_pReal,ierr);CHKERRQ(ierr) - call DMDAVecGetArrayF90(mech_grid,solution_current,u_current,ierr); CHKERRQ(ierr) - call DMDAVecGetArrayF90(mech_grid,solution_lastInc,u_lastInc,ierr); CHKERRQ(ierr) + call DMDAVecGetArrayF90(mechanical_grid,solution_current,u_current,ierr) + CHKERRQ(ierr) + call DMDAVecGetArrayF90(mechanical_grid,solution_lastInc,u_lastInc,ierr) + CHKERRQ(ierr) - call DMDAGetCorners(mech_grid,xstart,ystart,zstart,xend,yend,zend,ierr) ! local grid extent + call DMDAGetCorners(mechanical_grid,xstart,ystart,zstart,xend,yend,zend,ierr) ! local grid extent CHKERRQ(ierr) xend = xstart+xend-1 yend = ystart+yend-1 @@ -242,9 +257,9 @@ subroutine grid_mech_FEM_init call utilities_constitutiveResponse(P_current,P_av,C_volAvg,devNull, & ! stress field, stress avg, global average of stiffness and (min+max)/2 F, & ! target F 0.0_pReal) ! time increment - call DMDAVecRestoreArrayF90(mech_grid,solution_current,u_current,ierr) + call DMDAVecRestoreArrayF90(mechanical_grid,solution_current,u_current,ierr) CHKERRQ(ierr) - call DMDAVecRestoreArrayF90(mech_grid,solution_lastInc,u_lastInc,ierr) + call DMDAVecRestoreArrayF90(mechanical_grid,solution_lastInc,u_lastInc,ierr) CHKERRQ(ierr) restartRead2: if (interface_restartInc > 0) then @@ -257,13 +272,13 @@ subroutine grid_mech_FEM_init endif restartRead2 -end subroutine grid_mech_FEM_init +end subroutine grid_mechanical_FEM_init !-------------------------------------------------------------------------------------------------- !> @brief solution for the FEM scheme with internal iterations !-------------------------------------------------------------------------------------------------- -function grid_mech_FEM_solution(incInfoIn) result(solution) +function grid_mechanical_FEM_solution(incInfoIn) result(solution) !-------------------------------------------------------------------------------------------------- ! input data for solution @@ -284,11 +299,13 @@ function grid_mech_FEM_solution(incInfoIn) result(solution) !-------------------------------------------------------------------------------------------------- ! solve BVP - call SNESsolve(mech_snes,PETSC_NULL_VEC,solution_current,ierr); CHKERRQ(ierr) + call SNESsolve(mechanical_snes,PETSC_NULL_VEC,solution_current,ierr) + CHKERRQ(ierr) !-------------------------------------------------------------------------------------------------- ! check convergence - call SNESGetConvergedReason(mech_snes,reason,ierr); CHKERRQ(ierr) + call SNESGetConvergedReason(mechanical_snes,reason,ierr) + CHKERRQ(ierr) solution%converged = reason > 0 solution%iterationsNeeded = totalIter @@ -296,14 +313,14 @@ function grid_mech_FEM_solution(incInfoIn) result(solution) terminallyIll = .false. P_aim = merge(P_aim,P_av,params%stress_mask) -end function grid_mech_FEM_solution +end function grid_mechanical_FEM_solution !-------------------------------------------------------------------------------------------------- !> @brief forwarding routine !> @details find new boundary conditions and best F estimate for end of current timestep !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_FEM_forward(cutBack,guess,Delta_t,Delta_t_old,t_remaining,& +subroutine grid_mechanical_FEM_forward(cutBack,guess,Delta_t,Delta_t_old,t_remaining,& deformation_BC,stress_BC,rotation_BC) logical, intent(in) :: & @@ -323,8 +340,10 @@ subroutine grid_mech_FEM_forward(cutBack,guess,Delta_t,Delta_t_old,t_remaining,& u_current,u_lastInc - call DMDAVecGetArrayF90(mech_grid,solution_current,u_current,ierr); CHKERRQ(ierr) - call DMDAVecGetArrayF90(mech_grid,solution_lastInc,u_lastInc,ierr); CHKERRQ(ierr) + call DMDAVecGetArrayF90(mechanical_grid,solution_current,u_current,ierr) + CHKERRQ(ierr) + call DMDAVecGetArrayF90(mechanical_grid,solution_lastInc,u_lastInc,ierr) + CHKERRQ(ierr) if (cutBack) then C_volAvg = C_volAvgLastInc @@ -371,8 +390,10 @@ subroutine grid_mech_FEM_forward(cutBack,guess,Delta_t,Delta_t_old,t_remaining,& call VecAXPY(solution_current,Delta_t,solution_rate,ierr); CHKERRQ(ierr) - call DMDAVecRestoreArrayF90(mech_grid,solution_current,u_current,ierr); CHKERRQ(ierr) - call DMDAVecRestoreArrayF90(mech_grid,solution_lastInc,u_lastInc,ierr); CHKERRQ(ierr) + call DMDAVecRestoreArrayF90(mechanical_grid,solution_current,u_current,ierr) + CHKERRQ(ierr) + call DMDAVecRestoreArrayF90(mechanical_grid,solution_lastInc,u_lastInc,ierr) + CHKERRQ(ierr) !-------------------------------------------------------------------------------------------------- ! set module wide available data @@ -380,31 +401,33 @@ subroutine grid_mech_FEM_forward(cutBack,guess,Delta_t,Delta_t_old,t_remaining,& params%rotation_BC = rotation_BC params%timeinc = Delta_t -end subroutine grid_mech_FEM_forward +end subroutine grid_mechanical_FEM_forward !-------------------------------------------------------------------------------------------------- !> @brief Update coordinates !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_FEM_updateCoords +subroutine grid_mechanical_FEM_updateCoords call utilities_updateCoords(F) -end subroutine grid_mech_FEM_updateCoords +end subroutine grid_mechanical_FEM_updateCoords !-------------------------------------------------------------------------------------------------- !> @brief Write current solver and constitutive data for restart to file !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_FEM_restartWrite +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(mech_grid,solution_current,u_current,ierr); CHKERRQ(ierr) - call DMDAVecGetArrayF90(mech_grid,solution_lastInc,u_lastInc,ierr); CHKERRQ(ierr) + call DMDAVecGetArrayF90(mechanical_grid,solution_current,u_current,ierr) + CHKERRQ(ierr) + call DMDAVecGetArrayF90(mechanical_grid,solution_lastInc,u_lastInc,ierr) + CHKERRQ(ierr) print*, 'writing solver data required for restart to file'; flush(IO_STDOUT) @@ -427,10 +450,12 @@ subroutine grid_mech_FEM_restartWrite call HDF5_closeGroup(groupHandle) call HDF5_closeFile(fileHandle) - call DMDAVecRestoreArrayF90(mech_grid,solution_current,u_current,ierr);CHKERRQ(ierr) - call DMDAVecRestoreArrayF90(mech_grid,solution_lastInc,u_lastInc,ierr);CHKERRQ(ierr) + call DMDAVecRestoreArrayF90(mechanical_grid,solution_current,u_current,ierr) + CHKERRQ(ierr) + call DMDAVecRestoreArrayF90(mechanical_grid,solution_lastInc,u_lastInc,ierr) + CHKERRQ(ierr) -end subroutine grid_mech_FEM_restartWrite +end subroutine grid_mechanical_FEM_restartWrite !-------------------------------------------------------------------------------------------------- @@ -498,8 +523,10 @@ subroutine formResidual(da_local,x_local, & PetscErrorCode :: ierr real(pReal), dimension(3,3,3,3) :: devNull - call SNESGetNumberFunctionEvals(mech_snes,nfuncs,ierr); CHKERRQ(ierr) - call SNESGetIterationNumber(mech_snes,PETScIter,ierr); CHKERRQ(ierr) + call SNESGetNumberFunctionEvals(mechanical_snes,nfuncs,ierr) + CHKERRQ(ierr) + call SNESGetIterationNumber(mechanical_snes,PETScIter,ierr) + CHKERRQ(ierr) if (nfuncs == 0 .and. PETScIter == 0) totalIter = -1 ! new increment @@ -679,4 +706,4 @@ subroutine formJacobian(da_local,x_local,Jac_pre,Jac,dummy,ierr) end subroutine formJacobian -end module grid_mech_FEM +end module grid_mechanical_FEM diff --git a/src/grid/grid_mech_spectral_basic.f90 b/src/grid/grid_mech_spectral_basic.f90 index 9bc36165f..f3f30c0af 100644 --- a/src/grid/grid_mech_spectral_basic.f90 +++ b/src/grid/grid_mech_spectral_basic.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH !> @brief Grid solver for mechanics: Spectral basic !-------------------------------------------------------------------------------------------------- -module grid_mech_spectral_basic +module grid_mechanical_spectral_basic #include #include use PETScdmda @@ -79,18 +79,18 @@ module grid_mech_spectral_basic totalIter = 0 !< total iteration in current increment public :: & - grid_mech_spectral_basic_init, & - grid_mech_spectral_basic_solution, & - grid_mech_spectral_basic_forward, & - grid_mech_spectral_basic_updateCoords, & - grid_mech_spectral_basic_restartWrite + grid_mechanical_spectral_basic_init, & + grid_mechanical_spectral_basic_solution, & + grid_mechanical_spectral_basic_forward, & + grid_mechanical_spectral_basic_updateCoords, & + grid_mechanical_spectral_basic_restartWrite contains !-------------------------------------------------------------------------------------------------- !> @brief allocates all necessary fields and fills them with data, potentially from restart info !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_basic_init +subroutine grid_mechanical_spectral_basic_init real(pReal), dimension(3,3,grid(1),grid(2),grid3) :: P PetscErrorCode :: ierr @@ -105,7 +105,7 @@ subroutine grid_mech_spectral_basic_init num_grid, & debug_grid - print'(/,a)', ' <<<+- grid_mech_spectral_basic init -+>>>'; flush(IO_STDOUT) + print'(/,a)', ' <<<+- grid_mechanical_spectral_basic init -+>>>'; flush(IO_STDOUT) print*, 'Eisenlohr et al., International Journal of Plasticity 46:37–53, 2013' print*, 'https://doi.org/10.1016/j.ijplas.2012.09.012'//IO_EOL @@ -139,7 +139,7 @@ subroutine grid_mech_spectral_basic_init !-------------------------------------------------------------------------------------------------- ! set default and user defined options for PETSc - call PetscOptionsInsertString(PETSC_NULL_OPTIONS,'-mech_snes_type ngmres',ierr) + call PetscOptionsInsertString(PETSC_NULL_OPTIONS,'-mechanical_snes_type ngmres',ierr) CHKERRQ(ierr) call PetscOptionsInsertString(PETSC_NULL_OPTIONS,num_grid%get_asString('petsc_options',defaultVal=''),ierr) CHKERRQ(ierr) @@ -152,7 +152,7 @@ subroutine grid_mech_spectral_basic_init !-------------------------------------------------------------------------------------------------- ! initialize solver specific parts of PETSc call SNESCreate(PETSC_COMM_WORLD,snes,ierr); CHKERRQ(ierr) - call SNESSetOptionsPrefix(snes,'mech_',ierr);CHKERRQ(ierr) + call SNESSetOptionsPrefix(snes,'mechanical_',ierr);CHKERRQ(ierr) localK = 0 localK(worldrank) = grid3 call MPI_Allreduce(MPI_IN_PLACE,localK,worldsize,MPI_INTEGER,MPI_SUM,PETSC_COMM_WORLD,ierr) @@ -222,13 +222,13 @@ subroutine grid_mech_spectral_basic_init call utilities_updateGamma(C_minMaxAvg) call utilities_saveReferenceStiffness -end subroutine grid_mech_spectral_basic_init +end subroutine grid_mechanical_spectral_basic_init !-------------------------------------------------------------------------------------------------- !> @brief solution for the basic scheme with internal iterations !-------------------------------------------------------------------------------------------------- -function grid_mech_spectral_basic_solution(incInfoIn) result(solution) +function grid_mechanical_spectral_basic_solution(incInfoIn) result(solution) !-------------------------------------------------------------------------------------------------- ! input data for solution @@ -262,14 +262,14 @@ function grid_mech_spectral_basic_solution(incInfoIn) result(solution) terminallyIll = .false. P_aim = merge(P_aim,P_av,params%stress_mask) -end function grid_mech_spectral_basic_solution +end function grid_mechanical_spectral_basic_solution !-------------------------------------------------------------------------------------------------- !> @brief forwarding routine !> @details find new boundary conditions and best F estimate for end of current timestep !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_basic_forward(cutBack,guess,Delta_t,Delta_t_old,t_remaining,& +subroutine grid_mechanical_spectral_basic_forward(cutBack,guess,Delta_t,Delta_t_old,t_remaining,& deformation_BC,stress_BC,rotation_BC) logical, intent(in) :: & @@ -339,13 +339,13 @@ subroutine grid_mech_spectral_basic_forward(cutBack,guess,Delta_t,Delta_t_old,t_ params%rotation_BC = rotation_BC params%timeinc = Delta_t -end subroutine grid_mech_spectral_basic_forward +end subroutine grid_mechanical_spectral_basic_forward !-------------------------------------------------------------------------------------------------- !> @brief Update coordinates !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_basic_updateCoords +subroutine grid_mechanical_spectral_basic_updateCoords PetscErrorCode :: ierr PetscScalar, dimension(:,:,:,:), pointer :: F @@ -354,13 +354,13 @@ subroutine grid_mech_spectral_basic_updateCoords call utilities_updateCoords(F) call DMDAVecRestoreArrayF90(da,solution_vec,F,ierr); CHKERRQ(ierr) -end subroutine grid_mech_spectral_basic_updateCoords +end subroutine grid_mechanical_spectral_basic_updateCoords !-------------------------------------------------------------------------------------------------- !> @brief Write current solver and constitutive data for restart to file !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_basic_restartWrite +subroutine grid_mechanical_spectral_basic_restartWrite PetscErrorCode :: ierr integer(HID_T) :: fileHandle, groupHandle @@ -393,7 +393,7 @@ subroutine grid_mech_spectral_basic_restartWrite call DMDAVecRestoreArrayF90(da,solution_vec,F,ierr); CHKERRQ(ierr) -end subroutine grid_mech_spectral_basic_restartWrite +end subroutine grid_mechanical_spectral_basic_restartWrite !-------------------------------------------------------------------------------------------------- @@ -506,4 +506,4 @@ subroutine formResidual(in, F, & end subroutine formResidual -end module grid_mech_spectral_basic +end module grid_mechanical_spectral_basic diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index 7160c1adc..633fced7f 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH !> @brief Grid solver for mechanics: Spectral Polarisation !-------------------------------------------------------------------------------------------------- -module grid_mech_spectral_polarisation +module grid_mechanical_spectral_polarisation #include #include use PETScdmda @@ -90,18 +90,18 @@ module grid_mech_spectral_polarisation totalIter = 0 !< total iteration in current increment public :: & - grid_mech_spectral_polarisation_init, & - grid_mech_spectral_polarisation_solution, & - grid_mech_spectral_polarisation_forward, & - grid_mech_spectral_polarisation_updateCoords, & - grid_mech_spectral_polarisation_restartWrite + grid_mechanical_spectral_polarisation_init, & + grid_mechanical_spectral_polarisation_solution, & + grid_mechanical_spectral_polarisation_forward, & + grid_mechanical_spectral_polarisation_updateCoords, & + grid_mechanical_spectral_polarisation_restartWrite contains !-------------------------------------------------------------------------------------------------- !> @brief allocates all necessary fields and fills them with data, potentially from restart info !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_polarisation_init +subroutine grid_mechanical_spectral_polarisation_init real(pReal), dimension(3,3,grid(1),grid(2),grid3) :: P PetscErrorCode :: ierr @@ -118,7 +118,7 @@ subroutine grid_mech_spectral_polarisation_init num_grid, & debug_grid - print'(/,a)', ' <<<+- grid_mech_spectral_polarisation init -+>>>'; flush(IO_STDOUT) + print'(/,a)', ' <<<+- grid_mechanical_spectral_polarisation init -+>>>'; flush(IO_STDOUT) print*, 'Shanthraj et al., International Journal of Plasticity 66:31–45, 2015' print*, 'https://doi.org/10.1016/j.ijplas.2014.02.006' @@ -157,7 +157,7 @@ subroutine grid_mech_spectral_polarisation_init !-------------------------------------------------------------------------------------------------- ! set default and user defined options for PETSc - call PetscOptionsInsertString(PETSC_NULL_OPTIONS,'-mech_snes_type ngmres',ierr) + call PetscOptionsInsertString(PETSC_NULL_OPTIONS,'-mechanical_snes_type ngmres',ierr) CHKERRQ(ierr) call PetscOptionsInsertString(PETSC_NULL_OPTIONS,num_grid%get_asString('petsc_options',defaultVal=''),ierr) CHKERRQ(ierr) @@ -172,7 +172,7 @@ subroutine grid_mech_spectral_polarisation_init !-------------------------------------------------------------------------------------------------- ! initialize solver specific parts of PETSc call SNESCreate(PETSC_COMM_WORLD,snes,ierr); CHKERRQ(ierr) - call SNESSetOptionsPrefix(snes,'mech_',ierr);CHKERRQ(ierr) + call SNESSetOptionsPrefix(snes,'mechanical_',ierr);CHKERRQ(ierr) localK = 0 localK(worldrank) = grid3 call MPI_Allreduce(MPI_IN_PLACE,localK,worldsize,MPI_INTEGER,MPI_SUM,PETSC_COMM_WORLD,ierr) @@ -250,13 +250,13 @@ subroutine grid_mech_spectral_polarisation_init C_scale = C_minMaxAvg S_scale = math_invSym3333(C_minMaxAvg) -end subroutine grid_mech_spectral_polarisation_init +end subroutine grid_mechanical_spectral_polarisation_init !-------------------------------------------------------------------------------------------------- !> @brief solution for the Polarisation scheme with internal iterations !-------------------------------------------------------------------------------------------------- -function grid_mech_spectral_polarisation_solution(incInfoIn) result(solution) +function grid_mechanical_spectral_polarisation_solution(incInfoIn) result(solution) !-------------------------------------------------------------------------------------------------- ! input data for solution @@ -294,14 +294,14 @@ function grid_mech_spectral_polarisation_solution(incInfoIn) result(solution) terminallyIll = .false. P_aim = merge(P_aim,P_av,params%stress_mask) -end function grid_mech_spectral_polarisation_solution +end function grid_mechanical_spectral_polarisation_solution !-------------------------------------------------------------------------------------------------- !> @brief forwarding routine !> @details find new boundary conditions and best F estimate for end of current timestep !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_polarisation_forward(cutBack,guess,Delta_t,Delta_t_old,t_remaining,& +subroutine grid_mechanical_spectral_polarisation_forward(cutBack,guess,Delta_t,Delta_t_old,t_remaining,& deformation_BC,stress_BC,rotation_BC) logical, intent(in) :: & @@ -393,13 +393,13 @@ subroutine grid_mech_spectral_polarisation_forward(cutBack,guess,Delta_t,Delta_t params%rotation_BC = rotation_BC params%timeinc = Delta_t -end subroutine grid_mech_spectral_polarisation_forward +end subroutine grid_mechanical_spectral_polarisation_forward !-------------------------------------------------------------------------------------------------- !> @brief Update coordinates !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_polarisation_updateCoords +subroutine grid_mechanical_spectral_polarisation_updateCoords PetscErrorCode :: ierr PetscScalar, dimension(:,:,:,:), pointer :: FandF_tau @@ -408,13 +408,13 @@ subroutine grid_mech_spectral_polarisation_updateCoords call utilities_updateCoords(FandF_tau(0:8,:,:,:)) call DMDAVecRestoreArrayF90(da,solution_vec,FandF_tau,ierr); CHKERRQ(ierr) -end subroutine grid_mech_spectral_polarisation_updateCoords +end subroutine grid_mechanical_spectral_polarisation_updateCoords !-------------------------------------------------------------------------------------------------- !> @brief Write current solver and constitutive data for restart to file !-------------------------------------------------------------------------------------------------- -subroutine grid_mech_spectral_polarisation_restartWrite +subroutine grid_mechanical_spectral_polarisation_restartWrite PetscErrorCode :: ierr integer(HID_T) :: fileHandle, groupHandle @@ -450,7 +450,7 @@ subroutine grid_mech_spectral_polarisation_restartWrite call DMDAVecRestoreArrayF90(da,solution_vec,FandF_tau,ierr); CHKERRQ(ierr) -end subroutine grid_mech_spectral_polarisation_restartWrite +end subroutine grid_mechanical_spectral_polarisation_restartWrite !-------------------------------------------------------------------------------------------------- @@ -618,4 +618,4 @@ subroutine formResidual(in, FandF_tau, & end subroutine formResidual -end module grid_mech_spectral_polarisation +end module grid_mechanical_spectral_polarisation diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 2255e83b0..62ac52f06 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -45,10 +45,10 @@ module homogenization !-------------------------------------------------------------------------------------------------- interface - module subroutine mech_init(num_homog) + module subroutine mechanical_init(num_homog) class(tNode), pointer, intent(in) :: & num_homog !< pointer to mechanical homogenization numerics data - end subroutine mech_init + end subroutine mechanical_init module subroutine thermal_init end subroutine thermal_init @@ -56,13 +56,13 @@ module homogenization module subroutine damage_init end subroutine damage_init - module subroutine mech_partition(subF,ip,el) + module subroutine mechanical_partition(subF,ip,el) real(pReal), intent(in), dimension(3,3) :: & subF integer, intent(in) :: & ip, & !< integration point el !< element number - end subroutine mech_partition + end subroutine mechanical_partition module subroutine thermal_partition(ce) integer, intent(in) :: ce @@ -76,19 +76,19 @@ module homogenization integer, intent(in) :: ip,el end subroutine thermal_homogenize - module subroutine mech_homogenize(dt,ip,el) + module subroutine mechanical_homogenize(dt,ip,el) real(pReal), intent(in) :: dt integer, intent(in) :: & ip, & !< integration point el !< element number - end subroutine mech_homogenize + end subroutine mechanical_homogenize - module subroutine mech_results(group_base,h) + module subroutine mechanical_results(group_base,h) character(len=*), intent(in) :: group_base integer, intent(in) :: h - end subroutine mech_results + end subroutine mechanical_results - module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) + module function mechanical_updateState(subdt,subF,ip,el) result(doneAndHappy) real(pReal), intent(in) :: & subdt !< current time step real(pReal), intent(in), dimension(3,3) :: & @@ -97,7 +97,7 @@ module homogenization ip, & !< integration point el !< element number logical, dimension(2) :: doneAndHappy - end function mech_updateState + end function mechanical_updateState module function thermal_conduction_getConductivity(ip,el) result(K) @@ -216,7 +216,7 @@ subroutine homogenization_init() if (num%nMPstate < 1) call IO_error(301,ext_msg='nMPstate') - call mech_init(num_homog) + call mechanical_init(num_homog) call thermal_init() call damage_init() @@ -253,7 +253,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE ce = (el-1)*discretization_nIPs + ip me = material_homogenizationMemberAt2(ce) - call constitutive_restore(ce,.false.) ! wrong name (is more a forward function) + call phase_restore(ce,.false.) ! wrong name (is more a forward function) if(homogState(ho)%sizeState > 0) homogState(ho)%State(:,me) = homogState(ho)%State0(:,me) if(damageState_h(ho)%sizeState > 0) damageState_h(ho)%State(:,me) = damageState_h(ho)%State0(:,me) @@ -267,7 +267,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if (.not. doneAndHappy(1)) then - call mech_partition(homogenization_F(1:3,1:3,ce),ip,el) + call mechanical_partition(homogenization_F(1:3,1:3,ce),ip,el) converged = .true. do co = 1, myNgrains converged = converged .and. crystallite_stress(dt,co,ip,el) @@ -276,7 +276,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if (.not. converged) then doneAndHappy = [.true.,.false.] else - doneAndHappy = mech_updateState(dt,homogenization_F(1:3,1:3,ce),ip,el) + doneAndHappy = mechanical_updateState(dt,homogenization_F(1:3,1:3,ce),ip,el) converged = all(doneAndHappy) endif endif @@ -338,7 +338,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE do co = 1, homogenization_Nconstituents(ho) call crystallite_orientations(co,ip,el) enddo - call mech_homogenize(dt,ip,el) + call mechanical_homogenize(dt,ip,el) enddo IpLooping3 enddo elementLooping3 !$OMP END DO @@ -365,7 +365,7 @@ subroutine homogenization_results group_base = 'current/homogenization/'//trim(material_name_homogenization(ho)) call results_closeGroup(results_addGroup(group_base)) - call mech_results(group_base,ho) + call mechanical_results(group_base,ho) group = trim(group_base)//'/damage' call results_closeGroup(results_addGroup(group)) diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index ba021a0e0..8b73ed54a 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -74,7 +74,7 @@ module subroutine damage_partition(ce) phi = current(material_homogenizationAt2(ce))%phi(material_homogenizationMemberAt2(ce)) do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) - call constitutive_damage_set_phi(phi,co,ce) + call phase_damage_set_phi(phi,co,ce) enddo end subroutine damage_partition @@ -120,7 +120,7 @@ module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, p phiDot = 0.0_pReal dPhiDot_dPhi = 0.0_pReal - call constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) + call phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) phiDot = phiDot/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) dPhiDot_dPhi = dPhiDot_dPhi/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) diff --git a/src/homogenization_mechanics.f90 b/src/homogenization_mechanical.f90 similarity index 79% rename from src/homogenization_mechanics.f90 rename to src/homogenization_mechanical.f90 index 4eae859ee..91e1d3d84 100644 --- a/src/homogenization_mechanics.f90 +++ b/src/homogenization_mechanical.f90 @@ -7,52 +7,52 @@ submodule(homogenization) mechanics interface - module subroutine mech_none_init - end subroutine mech_none_init + module subroutine mechanical_pass_init + end subroutine mechanical_pass_init - module subroutine mech_isostrain_init - end subroutine mech_isostrain_init + module subroutine mechanical_isostrain_init + end subroutine mechanical_isostrain_init - module subroutine mech_RGC_init(num_homogMech) + module subroutine mechanical_RGC_init(num_homogMech) class(tNode), pointer, intent(in) :: & num_homogMech !< pointer to mechanical homogenization numerics data - end subroutine mech_RGC_init + end subroutine mechanical_RGC_init - module subroutine mech_isostrain_partitionDeformation(F,avgF) + module subroutine mechanical_isostrain_partitionDeformation(F,avgF) real(pReal), dimension (:,:,:), intent(out) :: F !< partitioned deformation gradient real(pReal), dimension (3,3), intent(in) :: avgF !< average deformation gradient at material point - end subroutine mech_isostrain_partitionDeformation + end subroutine mechanical_isostrain_partitionDeformation - module subroutine mech_RGC_partitionDeformation(F,avgF,instance,of) + module subroutine mechanical_RGC_partitionDeformation(F,avgF,instance,of) real(pReal), dimension (:,:,:), intent(out) :: F !< partitioned deformation gradient real(pReal), dimension (3,3), intent(in) :: avgF !< average deformation gradient at material point integer, intent(in) :: & instance, & of - end subroutine mech_RGC_partitionDeformation + end subroutine mechanical_RGC_partitionDeformation - module subroutine mech_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) + module subroutine mechanical_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point real(pReal), dimension (:,:,:), intent(in) :: P !< partitioned stresses real(pReal), dimension (:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses integer, intent(in) :: instance - end subroutine mech_isostrain_averageStressAndItsTangent + end subroutine mechanical_isostrain_averageStressAndItsTangent - module subroutine mech_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) + module subroutine mechanical_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point real(pReal), dimension (:,:,:), intent(in) :: P !< partitioned stresses real(pReal), dimension (:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses integer, intent(in) :: instance - end subroutine mech_RGC_averageStressAndItsTangent + end subroutine mechanical_RGC_averageStressAndItsTangent - module function mech_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy) + module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy) logical, dimension(2) :: doneAndHappy real(pReal), dimension(:,:,:), intent(in) :: & P,& !< partitioned stresses @@ -63,13 +63,13 @@ submodule(homogenization) mechanics integer, intent(in) :: & ip, & !< integration point number el !< element number - end function mech_RGC_updateState + end function mechanical_RGC_updateState - module subroutine mech_RGC_results(instance,group) + module subroutine mechanical_RGC_results(instance,group) integer, intent(in) :: instance !< homogenization instance character(len=*), intent(in) :: group !< group name in HDF5 file - end subroutine mech_RGC_results + end subroutine mechanical_RGC_results end interface @@ -78,7 +78,7 @@ contains !-------------------------------------------------------------------------------------------------- !> @brief Allocate variables and set parameters. !-------------------------------------------------------------------------------------------------- -module subroutine mech_init(num_homog) +module subroutine mechanical_init(num_homog) class(tNode), pointer, intent(in) :: & num_homog @@ -94,17 +94,17 @@ module subroutine mech_init(num_homog) allocate(homogenization_P(3,3,discretization_nIPs*discretization_Nelems), source=0.0_pReal) num_homogMech => num_homog%get('mech',defaultVal=emptyDict) - if (any(homogenization_type == HOMOGENIZATION_NONE_ID)) call mech_none_init - if (any(homogenization_type == HOMOGENIZATION_ISOSTRAIN_ID)) call mech_isostrain_init - if (any(homogenization_type == HOMOGENIZATION_RGC_ID)) call mech_RGC_init(num_homogMech) + if (any(homogenization_type == HOMOGENIZATION_NONE_ID)) call mechanical_pass_init + if (any(homogenization_type == HOMOGENIZATION_ISOSTRAIN_ID)) call mechanical_isostrain_init + if (any(homogenization_type == HOMOGENIZATION_RGC_ID)) call mechanical_RGC_init(num_homogMech) -end subroutine mech_init +end subroutine mechanical_init !-------------------------------------------------------------------------------------------------- !> @brief Partition F onto the individual constituents. !-------------------------------------------------------------------------------------------------- -module subroutine mech_partition(subF,ip,el) +module subroutine mechanical_partition(subF,ip,el) real(pReal), intent(in), dimension(3,3) :: & subF @@ -122,25 +122,25 @@ module subroutine mech_partition(subF,ip,el) Fs(1:3,1:3,1) = subF case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization - call mech_isostrain_partitionDeformation(Fs,subF) + call mechanical_isostrain_partitionDeformation(Fs,subF) case (HOMOGENIZATION_RGC_ID) chosenHomogenization - call mech_RGC_partitionDeformation(Fs,subF,ip,el) + call mechanical_RGC_partitionDeformation(Fs,subF,ip,el) end select chosenHomogenization do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - call constitutive_mech_setF(Fs(1:3,1:3,co),co,ip,el) + call phase_mechanical_setF(Fs(1:3,1:3,co),co,ip,el) enddo -end subroutine mech_partition +end subroutine mechanical_partition !-------------------------------------------------------------------------------------------------- !> @brief Average P and dPdF from the individual constituents. !-------------------------------------------------------------------------------------------------- -module subroutine mech_homogenize(dt,ip,el) +module subroutine mechanical_homogenize(dt,ip,el) real(pReal), intent(in) :: dt integer, intent(in) :: & @@ -156,15 +156,15 @@ module subroutine mech_homogenize(dt,ip,el) chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) case (HOMOGENIZATION_NONE_ID) chosenHomogenization - homogenization_P(1:3,1:3,ce) = constitutive_mech_getP(1,ip,el) - homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = constitutive_mech_dPdF(dt,1,ip,el) + homogenization_P(1:3,1:3,ce) = phase_mechanical_getP(1,ip,el) + homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = phase_mechanical_dPdF(dt,1,ip,el) case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = constitutive_mech_dPdF(dt,co,ip,el) - Ps(:,:,co) = constitutive_mech_getP(co,ip,el) + dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ip,el) + Ps(:,:,co) = phase_mechanical_getP(co,ip,el) enddo - call mech_isostrain_averageStressAndItsTangent(& + call mechanical_isostrain_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& Ps,dPdFs, & @@ -172,10 +172,10 @@ module subroutine mech_homogenize(dt,ip,el) case (HOMOGENIZATION_RGC_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = constitutive_mech_dPdF(dt,co,ip,el) - Ps(:,:,co) = constitutive_mech_getP(co,ip,el) + dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ip,el) + Ps(:,:,co) = phase_mechanical_getP(co,ip,el) enddo - call mech_RGC_averageStressAndItsTangent(& + call mechanical_RGC_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& Ps,dPdFs, & @@ -183,14 +183,14 @@ module subroutine mech_homogenize(dt,ip,el) end select chosenHomogenization -end subroutine mech_homogenize +end subroutine mechanical_homogenize !-------------------------------------------------------------------------------------------------- !> @brief update the internal state of the homogenization scheme and tell whether "done" and !> "happy" with result !-------------------------------------------------------------------------------------------------- -module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) +module function mechanical_updateState(subdt,subF,ip,el) result(doneAndHappy) real(pReal), intent(in) :: & subdt !< current time step @@ -209,22 +209,22 @@ module function mech_updateState(subdt,subF,ip,el) result(doneAndHappy) if (homogenization_type(material_homogenizationAt(el)) == HOMOGENIZATION_RGC_ID) then do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = constitutive_mech_dPdF(subdt,co,ip,el) - Fs(:,:,co) = constitutive_mech_getF(co,ip,el) - Ps(:,:,co) = constitutive_mech_getP(co,ip,el) + dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(subdt,co,ip,el) + Fs(:,:,co) = phase_mechanical_getF(co,ip,el) + Ps(:,:,co) = phase_mechanical_getP(co,ip,el) enddo - doneAndHappy = mech_RGC_updateState(Ps,Fs,subF,subdt,dPdFs,ip,el) + doneAndHappy = mechanical_RGC_updateState(Ps,Fs,subF,subdt,dPdFs,ip,el) else doneAndHappy = .true. endif -end function mech_updateState +end function mechanical_updateState !-------------------------------------------------------------------------------------------------- !> @brief Write results to file. !-------------------------------------------------------------------------------------------------- -module subroutine mech_results(group_base,h) +module subroutine mechanical_results(group_base,h) use material, only: & material_homogenization_type => homogenization_type @@ -239,7 +239,7 @@ module subroutine mech_results(group_base,h) select case(material_homogenization_type(h)) case(HOMOGENIZATION_rgc_ID) - call mech_RGC_results(homogenization_typeInstance(h),group) + call mechanical_RGC_results(homogenization_typeInstance(h),group) end select @@ -250,7 +250,7 @@ module subroutine mech_results(group_base,h) !call results_writeDataset(group,temp,'P',& ! '1st Piola-Kirchhoff stress','Pa') -end subroutine mech_results +end subroutine mechanical_results end submodule mechanics diff --git a/src/homogenization_mechanics_RGC.f90 b/src/homogenization_mechanical_RGC.f90 similarity index 98% rename from src/homogenization_mechanics_RGC.f90 rename to src/homogenization_mechanical_RGC.f90 index 89a84314b..546c2b65c 100644 --- a/src/homogenization_mechanics_RGC.f90 +++ b/src/homogenization_mechanical_RGC.f90 @@ -71,7 +71,7 @@ contains !-------------------------------------------------------------------------------------------------- !> @brief allocates all necessary fields, reads information from material configuration file !-------------------------------------------------------------------------------------------------- -module subroutine mech_RGC_init(num_homogMech) +module subroutine mechanical_RGC_init(num_homogMech) class(tNode), pointer, intent(in) :: & num_homogMech !< pointer to mechanical homogenization numerics data @@ -155,7 +155,7 @@ module subroutine mech_RGC_init(num_homogMech) prm%N_constituents = homogMech%get_asInts('cluster_size',requiredSize=3) if (homogenization_Nconstituents(h) /= product(prm%N_constituents)) & - call IO_error(211,ext_msg='N_constituents (mech_RGC)') + call IO_error(211,ext_msg='N_constituents (mechanical_RGC)') prm%xi_alpha = homogMech%get_asFloat('xi_alpha') prm%c_alpha = homogMech%get_asFloat('c_alpha') @@ -190,13 +190,13 @@ module subroutine mech_RGC_init(num_homogMech) enddo -end subroutine mech_RGC_init +end subroutine mechanical_RGC_init !-------------------------------------------------------------------------------------------------- !> @brief partitions the deformation gradient onto the constituents !-------------------------------------------------------------------------------------------------- -module subroutine mech_RGC_partitionDeformation(F,avgF,instance,of) +module subroutine mechanical_RGC_partitionDeformation(F,avgF,instance,of) real(pReal), dimension (:,:,:), intent(out) :: F !< partitioned F per grain @@ -229,14 +229,14 @@ module subroutine mech_RGC_partitionDeformation(F,avgF,instance,of) end associate -end subroutine mech_RGC_partitionDeformation +end subroutine mechanical_RGC_partitionDeformation !-------------------------------------------------------------------------------------------------- !> @brief update the internal state of the homogenization scheme and tell whether "done" and ! "happy" with result !-------------------------------------------------------------------------------------------------- -module function mech_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy) +module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy) logical, dimension(2) :: doneAndHappy real(pReal), dimension(:,:,:), intent(in) :: & P,& !< partitioned stresses @@ -658,7 +658,7 @@ module function mech_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy real(pReal), dimension(6,6) :: C - C = constitutive_homogenizedC(material_phaseAt(grainID,el),material_phaseMemberAt(grainID,ip,el)) + C = phase_homogenizedC(material_phaseAt(grainID,el),material_phaseMemberAt(grainID,ip,el)) equivalentMu = lattice_equivalent_mu(C,'voigt') end function equivalentMu @@ -704,13 +704,13 @@ module function mech_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy end subroutine grainDeformation -end function mech_RGC_updateState +end function mechanical_RGC_updateState !-------------------------------------------------------------------------------------------------- !> @brief derive average stress and stiffness from constituent quantities !-------------------------------------------------------------------------------------------------- -module subroutine mech_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) +module subroutine mechanical_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point @@ -722,13 +722,13 @@ module subroutine mech_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,ins avgP = sum(P,3) /real(product(param(instance)%N_constituents),pReal) dAvgPdAvgF = sum(dPdF,5)/real(product(param(instance)%N_constituents),pReal) -end subroutine mech_RGC_averageStressAndItsTangent +end subroutine mechanical_RGC_averageStressAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief writes results to HDF5 output file !-------------------------------------------------------------------------------------------------- -module subroutine mech_RGC_results(instance,group) +module subroutine mechanical_RGC_results(instance,group) integer, intent(in) :: instance character(len=*), intent(in) :: group @@ -754,7 +754,7 @@ module subroutine mech_RGC_results(instance,group) enddo outputsLoop end associate -end subroutine mech_RGC_results +end subroutine mechanical_RGC_results !-------------------------------------------------------------------------------------------------- diff --git a/src/homogenization_mechanics_isostrain.f90 b/src/homogenization_mechanical_isostrain.f90 similarity index 91% rename from src/homogenization_mechanics_isostrain.f90 rename to src/homogenization_mechanical_isostrain.f90 index 9634b2a38..f9616de42 100644 --- a/src/homogenization_mechanics_isostrain.f90 +++ b/src/homogenization_mechanical_isostrain.f90 @@ -26,7 +26,7 @@ contains !-------------------------------------------------------------------------------------------------- !> @brief allocates all neccessary fields, reads information from material configuration file !-------------------------------------------------------------------------------------------------- -module subroutine mech_isostrain_init +module subroutine mechanical_isostrain_init integer :: & Ninstances, & @@ -58,7 +58,7 @@ module subroutine mech_isostrain_init case ('avg') prm%mapping = average_ID case default - call IO_error(211,ext_msg='sum'//' (mech_isostrain)') + call IO_error(211,ext_msg='sum'//' (mechanical_isostrain)') end select Nmaterialpoints = count(material_homogenizationAt == h) @@ -70,13 +70,13 @@ module subroutine mech_isostrain_init enddo -end subroutine mech_isostrain_init +end subroutine mechanical_isostrain_init !-------------------------------------------------------------------------------------------------- !> @brief partitions the deformation gradient onto the constituents !-------------------------------------------------------------------------------------------------- -module subroutine mech_isostrain_partitionDeformation(F,avgF) +module subroutine mechanical_isostrain_partitionDeformation(F,avgF) real(pReal), dimension (:,:,:), intent(out) :: F !< partitioned deformation gradient @@ -84,13 +84,13 @@ module subroutine mech_isostrain_partitionDeformation(F,avgF) F = spread(avgF,3,size(F,3)) -end subroutine mech_isostrain_partitionDeformation +end subroutine mechanical_isostrain_partitionDeformation !-------------------------------------------------------------------------------------------------- !> @brief derive average stress and stiffness from constituent quantities !-------------------------------------------------------------------------------------------------- -module subroutine mech_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) +module subroutine mechanical_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point @@ -112,6 +112,6 @@ module subroutine mech_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dP end associate -end subroutine mech_isostrain_averageStressAndItsTangent +end subroutine mechanical_isostrain_averageStressAndItsTangent end submodule isostrain diff --git a/src/homogenization_mechanics_none.f90 b/src/homogenization_mechanical_pass.f90 similarity index 87% rename from src/homogenization_mechanics_none.f90 rename to src/homogenization_mechanical_pass.f90 index ebe2ea8f1..9e8f3e44c 100644 --- a/src/homogenization_mechanics_none.f90 +++ b/src/homogenization_mechanical_pass.f90 @@ -11,14 +11,14 @@ contains !-------------------------------------------------------------------------------------------------- !> @brief allocates all necessary fields, reads information from material configuration file !-------------------------------------------------------------------------------------------------- -module subroutine mech_none_init +module subroutine mechanical_pass_init integer :: & Ninstances, & h, & Nmaterialpoints - print'(/,a)', ' <<<+- homogenization:mechanics:none init -+>>>' + print'(/,a)', ' <<<+- homogenization:mechanics:pass init -+>>>' Ninstances = count(homogenization_type == HOMOGENIZATION_NONE_ID) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) @@ -27,7 +27,7 @@ module subroutine mech_none_init if(homogenization_type(h) /= HOMOGENIZATION_NONE_ID) cycle if(homogenization_Nconstituents(h) /= 1) & - call IO_error(211,ext_msg='N_constituents (mech_none)') + call IO_error(211,ext_msg='N_constituents (mechanical_pass)') Nmaterialpoints = count(material_homogenizationAt == h) homogState(h)%sizeState = 0 @@ -36,6 +36,6 @@ module subroutine mech_none_init enddo -end subroutine mech_none_init +end subroutine mechanical_pass_init end submodule none diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index b7170e6ec..67027f52a 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -78,7 +78,7 @@ module subroutine thermal_partition(ce) T = current(material_homogenizationAt2(ce))%T(material_homogenizationMemberAt2(ce)) dot_T = current(material_homogenizationAt2(ce))%dot_T(material_homogenizationMemberAt2(ce)) do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) - call constitutive_thermal_setField(T,dot_T,co,ce) + call phase_thermal_setField(T,dot_T,co,ce) enddo end subroutine thermal_partition @@ -91,7 +91,7 @@ module subroutine thermal_homogenize(ip,el) integer, intent(in) :: ip,el - !call constitutive_thermal_getRate(homogenization_dot_T((el-1)*discretization_nIPs+ip), ip,el) + !call phase_thermal_getRate(homogenization_dot_T((el-1)*discretization_nIPs+ip), ip,el) end subroutine thermal_homogenize @@ -235,7 +235,7 @@ module subroutine thermal_conduction_getSource(Tdot, ip,el) do co = 1, homogenization_Nconstituents(ho) ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) - call constitutive_thermal_getRate(dot_T_temp, ph,me) + call phase_thermal_getRate(dot_T_temp, ph,me) Tdot = Tdot + dot_T_temp enddo diff --git a/src/mesh/DAMASK_mesh.f90 b/src/mesh/DAMASK_mesh.f90 index 7369520c1..5ef0f7a36 100644 --- a/src/mesh/DAMASK_mesh.f90 +++ b/src/mesh/DAMASK_mesh.f90 @@ -18,7 +18,7 @@ program DAMASK_mesh use config use discretization_mesh use FEM_Utilities - use mesh_mech_FEM + use mesh_mechanical_FEM implicit none @@ -242,7 +242,7 @@ program DAMASK_mesh do field = 1, nActiveFields select case (loadCases(1)%fieldBC(field)%ID) case(FIELD_MECH_ID) - call FEM_mech_init(loadCases(1)%fieldBC(field)) + call FEM_mechanical_init(loadCases(1)%fieldBC(field)) end select enddo @@ -306,7 +306,7 @@ program DAMASK_mesh do field = 1, nActiveFields select case (loadCases(currentLoadCase)%fieldBC(field)%ID) case(FIELD_MECH_ID) - call FEM_mech_forward (& + call FEM_mechanical_forward (& guess,timeinc,timeIncOld,loadCases(currentLoadCase)%fieldBC(field)) end select @@ -320,7 +320,7 @@ program DAMASK_mesh do field = 1, nActiveFields select case (loadCases(currentLoadCase)%fieldBC(field)%ID) case(FIELD_MECH_ID) - solres(field) = FEM_mech_solution (& + solres(field) = FEM_mechanical_solution (& incInfo,timeinc,timeIncOld,loadCases(currentLoadCase)%fieldBC(field)) end select diff --git a/src/mesh/FEM_utilities.f90 b/src/mesh/FEM_utilities.f90 index 2f3633e11..4b3be8a42 100644 --- a/src/mesh/FEM_utilities.f90 +++ b/src/mesh/FEM_utilities.f90 @@ -127,12 +127,12 @@ subroutine FEM_utilities_init CHKERRQ(ierr) if(debugPETSc) call PetscOptionsInsertString(PETSC_NULL_OPTIONS,trim(PETSCDEBUG),ierr) CHKERRQ(ierr) - call PetscOptionsInsertString(PETSC_NULL_OPTIONS,'-mech_snes_type newtonls & - &-mech_snes_linesearch_type cp -mech_snes_ksp_ew & - &-mech_snes_ksp_ew_rtol0 0.01 -mech_snes_ksp_ew_rtolmax 0.01 & - &-mech_ksp_type fgmres -mech_ksp_max_it 25 & - &-mech_pc_type ml -mech_mg_levels_ksp_type chebyshev & - &-mech_mg_levels_pc_type sor -mech_pc_ml_nullspace user',ierr) + call PetscOptionsInsertString(PETSC_NULL_OPTIONS,'-mechanical_snes_type newtonls & + &-mechanical_snes_linesearch_type cp -mechanical_snes_ksp_ew & + &-mechanical_snes_ksp_ew_rtol0 0.01 -mechanical_snes_ksp_ew_rtolmax 0.01 & + &-mechanical_ksp_type fgmres -mechanical_ksp_max_it 25 & + &-mechanical_pc_type ml -mechanical_mg_levels_ksp_type chebyshev & + &-mechanical_mg_levels_pc_type sor -mechanical_pc_ml_nullspace user',ierr) CHKERRQ(ierr) call PetscOptionsInsertString(PETSC_NULL_OPTIONS,num_mesh%get_asString('petsc_options',defaultVal=''),ierr) CHKERRQ(ierr) diff --git a/src/mesh/mesh_mech_FEM.f90 b/src/mesh/mesh_mech_FEM.f90 index e19c35998..c811d842b 100644 --- a/src/mesh/mesh_mech_FEM.f90 +++ b/src/mesh/mesh_mech_FEM.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH !> @brief FEM PETSc solver !-------------------------------------------------------------------------------------------------- -module mesh_mech_FEM +module mesh_mechanical_FEM #include #include #include @@ -50,7 +50,7 @@ module mesh_mech_FEM type(tNumerics), private :: num !-------------------------------------------------------------------------------------------------- ! PETSc data - SNES :: mech_snes + SNES :: mechanical_snes Vec :: solution, solution_rate, solution_local PetscInt :: dimPlex, cellDof, nQuadrature, nBasis PetscReal, allocatable, target :: qPoints(:), qWeights(:) @@ -65,20 +65,20 @@ module mesh_mech_FEM real(pReal), parameter :: eps = 1.0e-18_pReal public :: & - FEM_mech_init, & - FEM_mech_solution, & - FEM_mech_forward + FEM_mechanical_init, & + FEM_mechanical_solution, & + FEM_mechanical_forward contains !-------------------------------------------------------------------------------------------------- !> @brief allocates all neccessary fields and fills them with data !-------------------------------------------------------------------------------------------------- -subroutine FEM_mech_init(fieldBC) +subroutine FEM_mechanical_init(fieldBC) type(tFieldBC), intent(in) :: fieldBC - DM :: mech_mesh + DM :: mechanical_mesh PetscFE :: mechFE PetscQuadrature :: mechQuad, functional PetscDS :: mechDS @@ -126,8 +126,8 @@ subroutine FEM_mech_init(fieldBC) !-------------------------------------------------------------------------------------------------- ! Setup FEM mech mesh - call DMClone(geomMesh,mech_mesh,ierr); CHKERRQ(ierr) - call DMGetDimension(mech_mesh,dimPlex,ierr); CHKERRQ(ierr) + call DMClone(geomMesh,mechanical_mesh,ierr); CHKERRQ(ierr) + call DMGetDimension(mechanical_mesh,dimPlex,ierr); CHKERRQ(ierr) !-------------------------------------------------------------------------------------------------- ! Setup FEM mech discretization @@ -146,22 +146,22 @@ subroutine FEM_mech_init(fieldBC) call PetscFESetQuadrature(mechFE,mechQuad,ierr); CHKERRQ(ierr) call PetscFEGetDimension(mechFE,nBasis,ierr); CHKERRQ(ierr) nBasis = nBasis/nc - call DMAddField(mech_mesh,PETSC_NULL_DMLABEL,mechFE,ierr); CHKERRQ(ierr) - call DMCreateDS(mech_mesh,ierr); CHKERRQ(ierr) - call DMGetDS(mech_mesh,mechDS,ierr); CHKERRQ(ierr) + call DMAddField(mechanical_mesh,PETSC_NULL_DMLABEL,mechFE,ierr); CHKERRQ(ierr) + call DMCreateDS(mechanical_mesh,ierr); CHKERRQ(ierr) + call DMGetDS(mechanical_mesh,mechDS,ierr); CHKERRQ(ierr) call PetscDSGetTotalDimension(mechDS,cellDof,ierr); CHKERRQ(ierr) call PetscFEDestroy(mechFE,ierr); CHKERRQ(ierr) call PetscQuadratureDestroy(mechQuad,ierr); CHKERRQ(ierr) !-------------------------------------------------------------------------------------------------- ! Setup FEM mech boundary conditions - call DMGetLabel(mech_mesh,'Face Sets',BCLabel,ierr); CHKERRQ(ierr) - call DMPlexLabelComplete(mech_mesh,BCLabel,ierr); CHKERRQ(ierr) - call DMGetLocalSection(mech_mesh,section,ierr); CHKERRQ(ierr) + call DMGetLabel(mechanical_mesh,'Face Sets',BCLabel,ierr); CHKERRQ(ierr) + call DMPlexLabelComplete(mechanical_mesh,BCLabel,ierr); CHKERRQ(ierr) + call DMGetLocalSection(mechanical_mesh,section,ierr); CHKERRQ(ierr) allocate(pnumComp(1), source=dimPlex) allocate(pnumDof(0:dimPlex), source = 0) do topologDim = 0, dimPlex - call DMPlexGetDepthStratum(mech_mesh,topologDim,cellStart,cellEnd,ierr) + call DMPlexGetDepthStratum(mechanical_mesh,topologDim,cellStart,cellEnd,ierr) CHKERRQ(ierr) call PetscSectionGetDof(section,cellStart,pnumDof(topologDim),ierr) CHKERRQ(ierr) @@ -179,10 +179,10 @@ subroutine FEM_mech_init(fieldBC) numBC = numBC + 1 call ISCreateGeneral(PETSC_COMM_WORLD,1,[field-1],PETSC_COPY_VALUES,pbcComps(numBC),ierr) CHKERRQ(ierr) - call DMGetStratumSize(mech_mesh,'Face Sets',mesh_boundaries(faceSet),bcSize,ierr) + call DMGetStratumSize(mechanical_mesh,'Face Sets',mesh_boundaries(faceSet),bcSize,ierr) CHKERRQ(ierr) if (bcSize > 0) then - call DMGetStratumIS(mech_mesh,'Face Sets',mesh_boundaries(faceSet),bcPoint,ierr) + call DMGetStratumIS(mechanical_mesh,'Face Sets',mesh_boundaries(faceSet),bcPoint,ierr) CHKERRQ(ierr) call ISGetIndicesF90(bcPoint,pBcPoint,ierr); CHKERRQ(ierr) call ISCreateGeneral(PETSC_COMM_WORLD,bcSize,pBcPoint,PETSC_COPY_VALUES,pbcPoints(numBC),ierr) @@ -195,32 +195,32 @@ subroutine FEM_mech_init(fieldBC) endif endif enddo; enddo - call DMPlexCreateSection(mech_mesh,nolabel,pNumComp,pNumDof, & + call DMPlexCreateSection(mechanical_mesh,nolabel,pNumComp,pNumDof, & numBC,pBcField,pBcComps,pBcPoints,PETSC_NULL_IS,section,ierr) CHKERRQ(ierr) - call DMSetSection(mech_mesh,section,ierr); CHKERRQ(ierr) + call DMSetSection(mechanical_mesh,section,ierr); CHKERRQ(ierr) do faceSet = 1, numBC call ISDestroy(pbcPoints(faceSet),ierr); CHKERRQ(ierr) enddo !-------------------------------------------------------------------------------------------------- ! initialize solver specific parts of PETSc - call SNESCreate(PETSC_COMM_WORLD,mech_snes,ierr);CHKERRQ(ierr) - call SNESSetOptionsPrefix(mech_snes,'mech_',ierr);CHKERRQ(ierr) - call SNESSetDM(mech_snes,mech_mesh,ierr); CHKERRQ(ierr) !< set the mesh for non-linear solver - call DMCreateGlobalVector(mech_mesh,solution ,ierr); CHKERRQ(ierr) !< locally owned displacement Dofs - call DMCreateGlobalVector(mech_mesh,solution_rate ,ierr); CHKERRQ(ierr) !< locally owned velocity Dofs to guess solution at next load step - call DMCreateLocalVector (mech_mesh,solution_local ,ierr); CHKERRQ(ierr) !< locally owned velocity Dofs to guess solution at next load step - call DMSNESSetFunctionLocal(mech_mesh,FEM_mech_formResidual,PETSC_NULL_VEC,ierr) !< function to evaluate residual forces + call SNESCreate(PETSC_COMM_WORLD,mechanical_snes,ierr);CHKERRQ(ierr) + call SNESSetOptionsPrefix(mechanical_snes,'mechanical_',ierr);CHKERRQ(ierr) + call SNESSetDM(mechanical_snes,mechanical_mesh,ierr); CHKERRQ(ierr) !< set the mesh for non-linear solver + call DMCreateGlobalVector(mechanical_mesh,solution ,ierr); CHKERRQ(ierr) !< locally owned displacement Dofs + call DMCreateGlobalVector(mechanical_mesh,solution_rate ,ierr); CHKERRQ(ierr) !< locally owned velocity Dofs to guess solution at next load step + call DMCreateLocalVector (mechanical_mesh,solution_local ,ierr); CHKERRQ(ierr) !< locally owned velocity Dofs to guess solution at next load step + call DMSNESSetFunctionLocal(mechanical_mesh,FEM_mechanical_formResidual,PETSC_NULL_VEC,ierr) !< function to evaluate residual forces CHKERRQ(ierr) - call DMSNESSetJacobianLocal(mech_mesh,FEM_mech_formJacobian,PETSC_NULL_VEC,ierr) !< function to evaluate stiffness matrix + call DMSNESSetJacobianLocal(mechanical_mesh,FEM_mechanical_formJacobian,PETSC_NULL_VEC,ierr) !< function to evaluate stiffness matrix CHKERRQ(ierr) - call SNESSetMaxLinearSolveFailures(mech_snes, huge(1), ierr); CHKERRQ(ierr) !< ignore linear solve failures - call SNESSetConvergenceTest(mech_snes,FEM_mech_converged,PETSC_NULL_VEC,PETSC_NULL_FUNCTION,ierr) + call SNESSetMaxLinearSolveFailures(mechanical_snes, huge(1), ierr); CHKERRQ(ierr) !< ignore linear solve failures + call SNESSetConvergenceTest(mechanical_snes,FEM_mechanical_converged,PETSC_NULL_VEC,PETSC_NULL_FUNCTION,ierr) CHKERRQ(ierr) - call SNESSetTolerances(mech_snes,1.0,0.0,0.0,num%itmax,num%itmax,ierr) + call SNESSetTolerances(mechanical_snes,1.0,0.0,0.0,num%itmax,num%itmax,ierr) CHKERRQ(ierr) - call SNESSetFromOptions(mech_snes,ierr); CHKERRQ(ierr) + call SNESSetFromOptions(mechanical_snes,ierr); CHKERRQ(ierr) !-------------------------------------------------------------------------------------------------- ! init fields @@ -236,11 +236,11 @@ subroutine FEM_mech_init(fieldBC) call PetscDSGetDiscretization(mechDS,0,mechFE,ierr) CHKERRQ(ierr) call PetscFEGetDualSpace(mechFE,mechDualSpace,ierr); CHKERRQ(ierr) - call DMPlexGetHeightStratum(mech_mesh,0,cellStart,cellEnd,ierr) + call DMPlexGetHeightStratum(mechanical_mesh,0,cellStart,cellEnd,ierr) CHKERRQ(ierr) do cell = cellStart, cellEnd-1 !< loop over all elements x_scal = 0.0_pReal - call DMPlexComputeCellGeometryAffineFEM(mech_mesh,cell,pV0,pCellJ,pInvcellJ,detJ,ierr) + call DMPlexComputeCellGeometryAffineFEM(mechanical_mesh,cell,pV0,pCellJ,pInvcellJ,detJ,ierr) CHKERRQ(ierr) cellJMat = reshape(pCellJ,shape=[dimPlex,dimPlex]) do basis = 0, nBasis*dimPlex-1, dimPlex @@ -251,17 +251,17 @@ subroutine FEM_mech_init(fieldBC) x_scal(basis+1:basis+dimPlex) = pV0 + matmul(transpose(cellJMat),nodalPointsP + 1.0_pReal) enddo px_scal => x_scal - call DMPlexVecSetClosure(mech_mesh,section,solution_local,cell,px_scal,5,ierr) + call DMPlexVecSetClosure(mechanical_mesh,section,solution_local,cell,px_scal,5,ierr) CHKERRQ(ierr) enddo -end subroutine FEM_mech_init +end subroutine FEM_mechanical_init !-------------------------------------------------------------------------------------------------- !> @brief solution for the FEM load step !-------------------------------------------------------------------------------------------------- -type(tSolutionState) function FEM_mech_solution( & +type(tSolutionState) function FEM_mechanical_solution( & incInfoIn,timeinc,timeinc_old,fieldBC) !-------------------------------------------------------------------------------------------------- @@ -278,35 +278,35 @@ type(tSolutionState) function FEM_mech_solution( & SNESConvergedReason :: reason incInfo = incInfoIn - FEM_mech_solution%converged =.false. + FEM_mechanical_solution%converged =.false. !-------------------------------------------------------------------------------------------------- ! set module wide availabe data params%timeinc = timeinc params%fieldBC = fieldBC - call SNESSolve(mech_snes,PETSC_NULL_VEC,solution,ierr); CHKERRQ(ierr) ! solve mech_snes based on solution guess (result in solution) - call SNESGetConvergedReason(mech_snes,reason,ierr); CHKERRQ(ierr) ! solution converged? + call SNESSolve(mechanical_snes,PETSC_NULL_VEC,solution,ierr); CHKERRQ(ierr) ! solve mechanical_snes based on solution guess (result in solution) + call SNESGetConvergedReason(mechanical_snes,reason,ierr); CHKERRQ(ierr) ! solution converged? terminallyIll = .false. if (reason < 1) then ! 0: still iterating (will not occur), negative -> convergence error - FEM_mech_solution%converged = .false. - FEM_mech_solution%iterationsNeeded = num%itmax + FEM_mechanical_solution%converged = .false. + FEM_mechanical_solution%iterationsNeeded = num%itmax else ! >= 1 proper convergence (or terminally ill) - FEM_mech_solution%converged = .true. - call SNESGetIterationNumber(mech_snes,FEM_mech_solution%iterationsNeeded,ierr) + FEM_mechanical_solution%converged = .true. + call SNESGetIterationNumber(mechanical_snes,FEM_mechanical_solution%iterationsNeeded,ierr) CHKERRQ(ierr) endif print'(/,a)', ' ===========================================================================' flush(IO_STDOUT) -end function FEM_mech_solution +end function FEM_mechanical_solution !-------------------------------------------------------------------------------------------------- !> @brief forms the FEM residual vector !-------------------------------------------------------------------------------------------------- -subroutine FEM_mech_formResidual(dm_local,xx_local,f_local,dummy,ierr) +subroutine FEM_mechanical_formResidual(dm_local,xx_local,f_local,dummy,ierr) DM :: dm_local PetscObject,intent(in) :: dummy @@ -431,13 +431,13 @@ subroutine FEM_mech_formResidual(dm_local,xx_local,f_local,dummy,ierr) enddo call DMRestoreLocalVector(dm_local,x_local,ierr); CHKERRQ(ierr) -end subroutine FEM_mech_formResidual +end subroutine FEM_mechanical_formResidual !-------------------------------------------------------------------------------------------------- !> @brief forms the FEM stiffness matrix !-------------------------------------------------------------------------------------------------- -subroutine FEM_mech_formJacobian(dm_local,xx_local,Jac_pre,Jac,dummy,ierr) +subroutine FEM_mechanical_formJacobian(dm_local,xx_local,Jac_pre,Jac,dummy,ierr) DM :: dm_local @@ -575,13 +575,13 @@ subroutine FEM_mech_formJacobian(dm_local,xx_local,Jac_pre,Jac,dummy,ierr) call MatSetNearNullSpace(Jac,matnull,ierr); CHKERRQ(ierr) call MatNullSpaceDestroy(matnull,ierr); CHKERRQ(ierr) -end subroutine FEM_mech_formJacobian +end subroutine FEM_mechanical_formJacobian !-------------------------------------------------------------------------------------------------- !> @brief forwarding routine !-------------------------------------------------------------------------------------------------- -subroutine FEM_mech_forward(guess,timeinc,timeinc_old,fieldBC) +subroutine FEM_mechanical_forward(guess,timeinc,timeinc_old,fieldBC) type(tFieldBC), intent(in) :: & fieldBC @@ -603,7 +603,7 @@ subroutine FEM_mech_forward(guess,timeinc,timeinc_old,fieldBC) if (guess .and. .not. cutBack) then ForwardData = .True. homogenization_F0 = homogenization_F - call SNESGetDM(mech_snes,dm_local,ierr); CHKERRQ(ierr) !< retrieve mesh info from mech_snes into dm_local + call SNESGetDM(mechanical_snes,dm_local,ierr); CHKERRQ(ierr) !< retrieve mesh info from mechanical_snes into dm_local call DMGetSection(dm_local,section,ierr); CHKERRQ(ierr) call DMGetLocalVector(dm_local,x_local,ierr); CHKERRQ(ierr) call VecSet(x_local,0.0_pReal,ierr); CHKERRQ(ierr) @@ -634,13 +634,13 @@ subroutine FEM_mech_forward(guess,timeinc,timeinc_old,fieldBC) call VecCopy(solution_rate,solution,ierr); CHKERRQ(ierr) call VecScale(solution,timeinc,ierr); CHKERRQ(ierr) -end subroutine FEM_mech_forward +end subroutine FEM_mechanical_forward !-------------------------------------------------------------------------------------------------- !> @brief reporting !-------------------------------------------------------------------------------------------------- -subroutine FEM_mech_converged(snes_local,PETScIter,xnorm,snorm,fnorm,reason,dummy,ierr) +subroutine FEM_mechanical_converged(snes_local,PETScIter,xnorm,snorm,fnorm,reason,dummy,ierr) SNES :: snes_local PetscInt :: PETScIter @@ -662,6 +662,6 @@ subroutine FEM_mech_converged(snes_local,PETScIter,xnorm,snorm,fnorm,reason,dumm ' Piola--Kirchhoff stress / MPa =',transpose(P_av)*1.e-6_pReal flush(IO_STDOUT) -end subroutine FEM_mech_converged +end subroutine FEM_mechanical_converged -end module mesh_mech_FEM +end module mesh_mechanical_FEM diff --git a/src/phase.f90 b/src/phase.f90 index dd14e0831..628bfc443 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -62,7 +62,7 @@ module phase phase_Nsources, & !< number of source mechanisms active in each phase phase_Nkinematics, & !< number of kinematic mechanisms active in each phase phase_NstiffnessDegradations, & !< number of stiffness degradation mechanisms active in each phase - phase_plasticityInstance, & !< instance of particular plasticity of each phase + phase_plasticInstance, & !< instance of particular plasticity of each phase phase_elasticityInstance !< instance of particular elasticity of each phase logical, dimension(:), allocatable, public :: & ! ToDo: should be protected (bug in Intel Compiler) @@ -75,15 +75,15 @@ module phase integer, public, protected :: & - constitutive_plasticity_maxSizeDotState, & - constitutive_source_maxSizeDotState + phase_plasticity_maxSizeDotState, & + phase_source_maxSizeDotState interface ! == cleaned:begin ================================================================================= - module subroutine mech_init(phases) + module subroutine mechanical_init(phases) class(tNode), pointer :: phases - end subroutine mech_init + end subroutine mechanical_init module subroutine damage_init end subroutine damage_init @@ -93,83 +93,83 @@ module phase end subroutine thermal_init - module subroutine mech_results(group,ph) + module subroutine mechanical_results(group,ph) character(len=*), intent(in) :: group integer, intent(in) :: ph - end subroutine mech_results + end subroutine mechanical_results module subroutine damage_results(group,ph) character(len=*), intent(in) :: group integer, intent(in) :: ph end subroutine damage_results - module subroutine mech_windForward(ph,me) + module subroutine mechanical_windForward(ph,me) integer, intent(in) :: ph, me - end subroutine mech_windForward + end subroutine mechanical_windForward - module subroutine mech_forward() - end subroutine mech_forward + module subroutine mechanical_forward() + end subroutine mechanical_forward module subroutine thermal_forward() end subroutine thermal_forward - module subroutine mech_restore(ce,includeL) + module subroutine mechanical_restore(ce,includeL) integer, intent(in) :: ce logical, intent(in) :: includeL - end subroutine mech_restore + end subroutine mechanical_restore - module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) + module function phase_mechanical_dPdF(dt,co,ip,el) result(dPdF) real(pReal), intent(in) :: dt integer, intent(in) :: & co, & !< counter in constituent loop ip, & !< counter in integration point loop el !< counter in element loop real(pReal), dimension(3,3,3,3) :: dPdF - end function constitutive_mech_dPdF + end function phase_mechanical_dPdF - module subroutine mech_restartWrite(groupHandle,ph) + module subroutine mechanical_restartWrite(groupHandle,ph) integer(HID_T), intent(in) :: groupHandle integer, intent(in) :: ph - end subroutine mech_restartWrite + end subroutine mechanical_restartWrite - module subroutine mech_restartRead(groupHandle,ph) + module subroutine mechanical_restartRead(groupHandle,ph) integer(HID_T), intent(in) :: groupHandle integer, intent(in) :: ph - end subroutine mech_restartRead + end subroutine mechanical_restartRead - module function mech_S(ph,me) result(S) + module function mechanical_S(ph,me) result(S) integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: S - end function mech_S + end function mechanical_S - module function mech_L_p(ph,me) result(L_p) + module function mechanical_L_p(ph,me) result(L_p) integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: L_p - end function mech_L_p + end function mechanical_L_p - module function constitutive_mech_getF(co,ip,el) result(F) + module function phase_mechanical_getF(co,ip,el) result(F) integer, intent(in) :: co, ip, el real(pReal), dimension(3,3) :: F - end function constitutive_mech_getF + end function phase_mechanical_getF - module function mech_F_e(ph,me) result(F_e) + module function mechanical_F_e(ph,me) result(F_e) integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: F_e - end function mech_F_e + end function mechanical_F_e - module function constitutive_mech_getP(co,ip,el) result(P) + module function phase_mechanical_getP(co,ip,el) result(P) integer, intent(in) :: co, ip, el real(pReal), dimension(3,3) :: P - end function constitutive_mech_getP + end function phase_mechanical_getP - module function constitutive_damage_get_phi(co,ip,el) result(phi) + module function phase_damage_get_phi(co,ip,el) result(phi) integer, intent(in) :: co, ip, el real(pReal) :: phi - end function constitutive_damage_get_phi + end function phase_damage_get_phi module function thermal_T(ph,me) result(T) integer, intent(in) :: ph,me @@ -182,20 +182,20 @@ module phase end function thermal_dot_T - module subroutine constitutive_mech_setF(F,co,ip,el) + module subroutine phase_mechanical_setF(F,co,ip,el) real(pReal), dimension(3,3), intent(in) :: F integer, intent(in) :: co, ip, el - end subroutine constitutive_mech_setF + end subroutine phase_mechanical_setF - module subroutine constitutive_thermal_setField(T,dot_T, co,ce) + module subroutine phase_thermal_setField(T,dot_T, co,ce) real(pReal), intent(in) :: T, dot_T integer, intent(in) :: ce, co - end subroutine constitutive_thermal_setField + end subroutine phase_thermal_setField - module subroutine constitutive_damage_set_phi(phi,co,ce) + module subroutine phase_damage_set_phi(phi,co,ce) real(pReal), intent(in) :: phi integer, intent(in) :: co, ce - end subroutine constitutive_damage_set_phi + end subroutine phase_damage_set_phi ! == cleaned:end =================================================================================== @@ -222,13 +222,13 @@ module phase logical :: converged_ end function crystallite_stress - module function constitutive_homogenizedC(ph,me) result(C) + module function phase_homogenizedC(ph,me) result(C) integer, intent(in) :: ph, me real(pReal), dimension(6,6) :: C - end function constitutive_homogenizedC + end function phase_homogenizedC - module subroutine constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) + module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) integer, intent(in) :: & ip, & !< integration point number el !< element number @@ -237,13 +237,13 @@ module phase real(pReal), intent(inout) :: & phiDot, & dPhiDot_dPhi - end subroutine constitutive_damage_getRateAndItsTangents + end subroutine phase_damage_getRateAndItsTangents - module subroutine constitutive_thermal_getRate(TDot, ph,me) + module subroutine phase_thermal_getRate(TDot, ph,me) integer, intent(in) :: ph, me real(pReal), intent(out) :: & TDot - end subroutine constitutive_thermal_getRate + end subroutine phase_thermal_getRate module subroutine plastic_nonlocal_updateCompatibility(orientation,instance,i,e) integer, intent(in) :: & @@ -281,39 +281,39 @@ module phase #endif public :: & - constitutive_init, & - constitutive_homogenizedC, & - constitutive_damage_getRateAndItsTangents, & - constitutive_thermal_getRate, & - constitutive_results, & - constitutive_allocateState, & - constitutive_forward, & - constitutive_restore, & + phase_init, & + phase_homogenizedC, & + phase_damage_getRateAndItsTangents, & + phase_thermal_getRate, & + phase_results, & + phase_allocateState, & + phase_forward, & + phase_restore, & plastic_nonlocal_updateCompatibility, & converged, & crystallite_init, & crystallite_stress, & thermal_stress, & - constitutive_mech_dPdF, & + phase_mechanical_dPdF, & crystallite_orientations, & crystallite_push33ToRef, & - constitutive_restartWrite, & - constitutive_restartRead, & + phase_restartWrite, & + phase_restartRead, & integrateDamageState, & - constitutive_thermal_setField, & - constitutive_damage_set_phi, & - constitutive_damage_get_phi, & - constitutive_mech_getP, & - constitutive_mech_setF, & - constitutive_mech_getF, & - constitutive_windForward + phase_thermal_setField, & + phase_damage_set_phi, & + phase_damage_get_phi, & + phase_mechanical_getP, & + phase_mechanical_setF, & + phase_mechanical_getF, & + phase_windForward contains !-------------------------------------------------------------------------------------------------- !> @brief Initialze constitutive models for individual physics !-------------------------------------------------------------------------------------------------- -subroutine constitutive_init +subroutine phase_init integer :: & ph, & !< counter in phase loop @@ -336,12 +336,12 @@ subroutine constitutive_init phases => config_material%get('phase') - call mech_init(phases) + call mechanical_init(phases) call damage_init call thermal_init(phases) - constitutive_source_maxSizeDotState = 0 + phase_source_maxSizeDotState = 0 PhaseLoop2:do ph = 1,phases%length !-------------------------------------------------------------------------------------------------- ! partition and initialize state @@ -350,18 +350,18 @@ subroutine constitutive_init damageState(ph)%p(so)%state = damageState(ph)%p(so)%state0 end forall - constitutive_source_maxSizeDotState = max(constitutive_source_maxSizeDotState, & + phase_source_maxSizeDotState = max(phase_source_maxSizeDotState, & maxval(damageState(ph)%p%sizeDotState)) enddo PhaseLoop2 - constitutive_plasticity_maxSizeDotState = maxval(plasticState%sizeDotState) + phase_plasticity_maxSizeDotState = maxval(plasticState%sizeDotState) -end subroutine constitutive_init +end subroutine phase_init !-------------------------------------------------------------------------------------------------- !> @brief Allocate the components of the state structure for a given phase !-------------------------------------------------------------------------------------------------- -subroutine constitutive_allocateState(state, & +subroutine phase_allocateState(state, & Nconstituents,sizeState,sizeDotState,sizeDeltaState) class(tState), intent(out) :: & @@ -387,13 +387,13 @@ subroutine constitutive_allocateState(state, & allocate(state%deltaState (sizeDeltaState,Nconstituents), source=0.0_pReal) -end subroutine constitutive_allocateState +end subroutine phase_allocateState !-------------------------------------------------------------------------------------------------- !> @brief Restore data after homog cutback. !-------------------------------------------------------------------------------------------------- -subroutine constitutive_restore(ce,includeL) +subroutine phase_restore(ce,includeL) logical, intent(in) :: includeL integer, intent(in) :: ce @@ -410,21 +410,21 @@ subroutine constitutive_restore(ce,includeL) enddo enddo - call mech_restore(ce,includeL) + call mechanical_restore(ce,includeL) -end subroutine constitutive_restore +end subroutine phase_restore !-------------------------------------------------------------------------------------------------- !> @brief Forward data after successful increment. ! ToDo: Any guessing for the current states possible? !-------------------------------------------------------------------------------------------------- -subroutine constitutive_forward() +subroutine phase_forward() integer :: ph, so - call mech_forward() + call mechanical_forward() call thermal_forward() do ph = 1, size(damageState) @@ -432,13 +432,13 @@ subroutine constitutive_forward() damageState(ph)%p(so)%state0 = damageState(ph)%p(so)%state enddo; enddo -end subroutine constitutive_forward +end subroutine phase_forward !-------------------------------------------------------------------------------------------------- !> @brief writes constitutive results to HDF5 output file !-------------------------------------------------------------------------------------------------- -subroutine constitutive_results() +subroutine phase_results() integer :: ph character(len=:), allocatable :: group @@ -451,12 +451,12 @@ subroutine constitutive_results() group = '/current/phase/'//trim(material_name_phase(ph))//'/' call results_closeGroup(results_addGroup(group)) - call mech_results(group,ph) + call mechanical_results(group,ph) call damage_results(group,ph) enddo -end subroutine constitutive_results +end subroutine phase_results !-------------------------------------------------------------------------------------------------- @@ -557,7 +557,7 @@ end subroutine crystallite_init !-------------------------------------------------------------------------------------------------- !> @brief Wind homog inc forward. !-------------------------------------------------------------------------------------------------- -subroutine constitutive_windForward(ip,el) +subroutine phase_windForward(ip,el) integer, intent(in) :: & ip, & !< integration point number @@ -572,7 +572,7 @@ subroutine constitutive_windForward(ip,el) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - call mech_windForward(ph,me) + call mechanical_windForward(ph,me) do so = 1, phase_Nsources(material_phaseAt(co,el)) damageState(ph)%p(so)%state0(:,me) = damageState(ph)%p(so)%state(:,me) @@ -580,7 +580,7 @@ subroutine constitutive_windForward(ip,el) enddo -end subroutine constitutive_windForward +end subroutine phase_windForward !-------------------------------------------------------------------------------------------------- @@ -595,11 +595,11 @@ subroutine crystallite_orientations(co,ip,el) call crystallite_orientation(co,ip,el)%fromMatrix(transpose(math_rotationalPart(& - mech_F_e(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el))))) + mechanical_F_e(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el))))) if (plasticState(material_phaseAt(1,el))%nonlocal) & call plastic_nonlocal_updateCompatibility(crystallite_orientation, & - phase_plasticityInstance(material_phaseAt(1,el)),ip,el) + phase_plasticInstance(material_phaseAt(1,el)),ip,el) end subroutine crystallite_orientations @@ -620,7 +620,7 @@ function crystallite_push33ToRef(co,ip,el, tensor33) real(pReal), dimension(3,3) :: T - T = matmul(material_orientation0(co,ip,el)%asMatrix(),transpose(math_inv33(constitutive_mech_getF(co,ip,el)))) ! ToDo: initial orientation correct? + T = matmul(material_orientation0(co,ip,el)%asMatrix(),transpose(math_inv33(phase_mechanical_getF(co,ip,el)))) ! ToDo: initial orientation correct? crystallite_push33ToRef = matmul(transpose(T),matmul(tensor33,T)) @@ -648,7 +648,7 @@ end function converged !> @brief Write current restart information (Field and constitutive data) to file. ! ToDo: Merge data into one file for MPI !-------------------------------------------------------------------------------------------------- -subroutine constitutive_restartWrite(fileHandle) +subroutine phase_restartWrite(fileHandle) integer(HID_T), intent(in) :: fileHandle @@ -662,7 +662,7 @@ subroutine constitutive_restartWrite(fileHandle) groupHandle(2) = HDF5_addGroup(groupHandle(1),material_name_phase(ph)) - call mech_restartWrite(groupHandle(2),ph) + call mechanical_restartWrite(groupHandle(2),ph) call HDF5_closeGroup(groupHandle(2)) @@ -670,14 +670,14 @@ subroutine constitutive_restartWrite(fileHandle) call HDF5_closeGroup(groupHandle(1)) -end subroutine constitutive_restartWrite +end subroutine phase_restartWrite !-------------------------------------------------------------------------------------------------- !> @brief Read data for restart ! ToDo: Merge data into one file for MPI !-------------------------------------------------------------------------------------------------- -subroutine constitutive_restartRead(fileHandle) +subroutine phase_restartRead(fileHandle) integer(HID_T), intent(in) :: fileHandle @@ -691,7 +691,7 @@ subroutine constitutive_restartRead(fileHandle) groupHandle(2) = HDF5_openGroup(groupHandle(1),material_name_phase(ph)) - call mech_restartRead(groupHandle(2),ph) + call mechanical_restartRead(groupHandle(2),ph) call HDF5_closeGroup(groupHandle(2)) @@ -699,7 +699,7 @@ subroutine constitutive_restartRead(fileHandle) call HDF5_closeGroup(groupHandle(1)) -end subroutine constitutive_restartRead +end subroutine phase_restartRead end module phase diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 014347c1a..57145c550 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -196,7 +196,7 @@ end subroutine damage_init !---------------------------------------------------------------------------------------------- !< @brief returns local part of nonlocal damage driving force !---------------------------------------------------------------------------------------------- -module subroutine constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) +module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) integer, intent(in) :: & ip, & !< integration point number @@ -246,7 +246,7 @@ module subroutine constitutive_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi enddo enddo -end subroutine constitutive_damage_getRateAndItsTangents +end subroutine phase_damage_getRateAndItsTangents @@ -272,9 +272,9 @@ module function integrateDamageState(dt,co,ip,el) result(broken) size_so real(pReal) :: & zeta - real(pReal), dimension(constitutive_source_maxSizeDotState) :: & + real(pReal), dimension(phase_source_maxSizeDotState) :: & r ! state residuum - real(pReal), dimension(constitutive_source_maxSizeDotState,2,maxval(phase_Nsources)) :: source_dotState + real(pReal), dimension(phase_source_maxSizeDotState,2,maxval(phase_Nsources)) :: source_dotState logical :: & converged_ @@ -283,7 +283,7 @@ module function integrateDamageState(dt,co,ip,el) result(broken) me = material_phaseMemberAt(co,ip,el) converged_ = .true. - broken = constitutive_damage_collectDotState(co,ip,el,ph,me) + broken = phase_damage_collectDotState(co,ip,el,ph,me) if(broken) return do so = 1, phase_Nsources(ph) @@ -300,7 +300,7 @@ module function integrateDamageState(dt,co,ip,el) result(broken) source_dotState(1:size_so(so),1,so) = damageState(ph)%p(so)%dotState(:,me) enddo - broken = constitutive_damage_collectDotState(co,ip,el,ph,me) + broken = phase_damage_collectDotState(co,ip,el,ph,me) if(broken) exit iteration do so = 1, phase_Nsources(ph) @@ -320,7 +320,7 @@ module function integrateDamageState(dt,co,ip,el) result(broken) enddo if(converged_) then - broken = constitutive_damage_deltaState(mech_F_e(ph,me),ph,me) + broken = phase_damage_deltaState(mechanical_F_e(ph,me),ph,me) exit iteration endif @@ -393,7 +393,7 @@ end subroutine damage_results !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the rate of change of microstructure !-------------------------------------------------------------------------------------------------- -function constitutive_damage_collectDotState(co,ip,el,ph,me) result(broken) +function phase_damage_collectDotState(co,ip,el,ph,me) result(broken) integer, intent(in) :: & co, & !< component-ID me integration point @@ -419,7 +419,7 @@ function constitutive_damage_collectDotState(co,ip,el,ph,me) result(broken) call anisoductile_dotState(co, ip, el) case (DAMAGE_ANISOBRITTLE_ID) sourceType - call anisobrittle_dotState(mech_S(ph,me),co, ip, el) ! correct stress? + call anisobrittle_dotState(mechanical_S(ph,me),co, ip, el) ! correct stress? end select sourceType @@ -427,7 +427,7 @@ function constitutive_damage_collectDotState(co,ip,el,ph,me) result(broken) enddo SourceLoop -end function constitutive_damage_collectDotState +end function phase_damage_collectDotState @@ -435,7 +435,7 @@ end function constitutive_damage_collectDotState !> @brief for constitutive models having an instantaneous change of state !> will return false if delta state is not needed/supported by the constitutive model !-------------------------------------------------------------------------------------------------- -function constitutive_damage_deltaState(Fe, ph, me) result(broken) +function phase_damage_deltaState(Fe, ph, me) result(broken) integer, intent(in) :: & ph, & @@ -457,7 +457,7 @@ function constitutive_damage_deltaState(Fe, ph, me) result(broken) sourceType: select case (phase_source(so,ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType - call source_damage_isoBrittle_deltaState(constitutive_homogenizedC(ph,me), Fe, ph,me) + call source_damage_isoBrittle_deltaState(phase_homogenizedC(ph,me), Fe, ph,me) broken = any(IEEE_is_NaN(damageState(ph)%p(so)%deltaState(:,me))) if(.not. broken) then myOffset = damageState(ph)%p(so)%offsetDeltaState @@ -470,7 +470,7 @@ function constitutive_damage_deltaState(Fe, ph, me) result(broken) enddo SourceLoop -end function constitutive_damage_deltaState +end function phase_damage_deltaState !-------------------------------------------------------------------------------------------------- @@ -507,7 +507,7 @@ end function source_active !---------------------------------------------------------------------------------------------- !< @brief Set damage parameter !---------------------------------------------------------------------------------------------- -module subroutine constitutive_damage_set_phi(phi,co,ce) +module subroutine phase_damage_set_phi(phi,co,ce) real(pReal), intent(in) :: phi integer, intent(in) :: ce, co @@ -515,17 +515,17 @@ module subroutine constitutive_damage_set_phi(phi,co,ce) current(material_phaseAt2(co,ce))%phi(material_phaseMemberAt2(co,ce)) = phi -end subroutine constitutive_damage_set_phi +end subroutine phase_damage_set_phi -module function constitutive_damage_get_phi(co,ip,el) result(phi) +module function phase_damage_get_phi(co,ip,el) result(phi) integer, intent(in) :: co, ip, el real(pReal) :: phi phi = current(material_phaseAt(co,el))%phi(material_phaseMemberAt(co,ip,el)) -end function constitutive_damage_get_phi +end function phase_damage_get_phi end submodule damagee diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 2ae5ca951..51ca7786a 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -101,7 +101,7 @@ module function anisobrittle_init(source_length) result(mySources) if (any(prm%s_crit < 0.0_pReal)) extmsg = trim(extmsg)//' s_crit' Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) + call phase_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) damageState(p)%p(sourceOffset)%atol = src%get_asFloat('anisobrittle_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisobrittle_atol' diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index 8d5904e6b..e54eff201 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -87,7 +87,7 @@ module function anisoductile_init(source_length) result(mySources) if (any(prm%gamma_crit < 0.0_pReal)) extmsg = trim(extmsg)//' gamma_crit' Nconstituents=count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) + call phase_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) damageState(p)%p(sourceOffset)%atol = src%get_asFloat('anisoDuctile_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisoductile_atol' diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 091377171..529ecd404 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -74,7 +74,7 @@ module function isobrittle_init(source_length) result(mySources) if (prm%W_crit <= 0.0_pReal) extmsg = trim(extmsg)//' W_crit' Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,1) + call phase_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,1) damageState(p)%p(sourceOffset)%atol = src%get_asFloat('isoBrittle_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isobrittle_atol' diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index 6f0a2d0fb..71f99078b 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -78,7 +78,7 @@ module function isoductile_init(source_length) result(mySources) if (prm%gamma_crit <= 0.0_pReal) extmsg = trim(extmsg)//' gamma_crit' Nconstituents=count(material_phaseAt==p) * discretization_nIPs - call constitutive_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) + call phase_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) damageState(p)%p(sourceOffset)%atol = src%get_asFloat('isoDuctile_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isoductile_atol' diff --git a/src/phase_mechanics.f90 b/src/phase_mechanical.f90 similarity index 82% rename from src/phase_mechanics.f90 rename to src/phase_mechanical.f90 index a84c1a385..efd4d51d2 100644 --- a/src/phase_mechanics.f90 +++ b/src/phase_mechanical.f90 @@ -31,21 +31,21 @@ submodule(phase) mechanics type(tTensorContainer), dimension(:), allocatable :: & ! current value - constitutive_mech_Fe, & - constitutive_mech_Fi, & - constitutive_mech_Fp, & - constitutive_mech_F, & - constitutive_mech_Li, & - constitutive_mech_Lp, & - constitutive_mech_S, & - constitutive_mech_P, & + phase_mechanical_Fe, & + phase_mechanical_Fi, & + phase_mechanical_Fp, & + phase_mechanical_F, & + phase_mechanical_Li, & + phase_mechanical_Lp, & + phase_mechanical_S, & + phase_mechanical_P, & ! converged value at end of last solver increment - constitutive_mech_Fi0, & - constitutive_mech_Fp0, & - constitutive_mech_F0, & - constitutive_mech_Li0, & - constitutive_mech_Lp0, & - constitutive_mech_S0 + phase_mechanical_Fi0, & + phase_mechanical_Fp0, & + phase_mechanical_F0, & + phase_mechanical_Li0, & + phase_mechanical_Lp0, & + phase_mechanical_S0 integer(kind(PLASTICITY_undefined_ID)), dimension(:), allocatable :: & @@ -97,7 +97,7 @@ submodule(phase) mechanics broken end function plastic_deltaState - module subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & + module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & S, Fi, co, ip, el) integer, intent(in) :: & @@ -114,7 +114,7 @@ submodule(phase) mechanics dLi_dS, & !< derivative of Li with respect to S dLi_dFi - end subroutine constitutive_LiAndItsTangents + end subroutine phase_LiAndItsTangents module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & @@ -186,7 +186,7 @@ contains !> @brief Initialize mechanical field related constitutive models !> @details Initialize elasticity, plasticity and stiffness degradation models. !-------------------------------------------------------------------------------------------------- -module subroutine mech_init(phases) +module subroutine mechanical_init(phases) class(tNode), pointer :: & phases @@ -215,38 +215,38 @@ module subroutine mech_init(phases) allocate(phase_NstiffnessDegradations(phases%length),source=0) allocate(output_constituent(phases%length)) - allocate(constitutive_mech_Fe(phases%length)) - allocate(constitutive_mech_Fi(phases%length)) - allocate(constitutive_mech_Fi0(phases%length)) - allocate(constitutive_mech_Fp(phases%length)) - allocate(constitutive_mech_Fp0(phases%length)) - allocate(constitutive_mech_F(phases%length)) - allocate(constitutive_mech_F0(phases%length)) - allocate(constitutive_mech_Li(phases%length)) - allocate(constitutive_mech_Li0(phases%length)) - allocate(constitutive_mech_Lp0(phases%length)) - allocate(constitutive_mech_Lp(phases%length)) - allocate(constitutive_mech_S(phases%length)) - allocate(constitutive_mech_P(phases%length)) - allocate(constitutive_mech_S0(phases%length)) + allocate(phase_mechanical_Fe(phases%length)) + allocate(phase_mechanical_Fi(phases%length)) + allocate(phase_mechanical_Fi0(phases%length)) + allocate(phase_mechanical_Fp(phases%length)) + allocate(phase_mechanical_Fp0(phases%length)) + allocate(phase_mechanical_F(phases%length)) + allocate(phase_mechanical_F0(phases%length)) + allocate(phase_mechanical_Li(phases%length)) + allocate(phase_mechanical_Li0(phases%length)) + allocate(phase_mechanical_Lp0(phases%length)) + allocate(phase_mechanical_Lp(phases%length)) + allocate(phase_mechanical_S(phases%length)) + allocate(phase_mechanical_P(phases%length)) + allocate(phase_mechanical_S0(phases%length)) do ph = 1, phases%length Nconstituents = count(material_phaseAt == ph) * discretization_nIPs - allocate(constitutive_mech_Fi(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Fe(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Fi0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Fp(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Fp0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Li(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Li0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Lp0(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_Lp(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_S(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(constitutive_mech_P(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(constitutive_mech_S0(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(constitutive_mech_F(ph)%data(3,3,Nconstituents)) - allocate(constitutive_mech_F0(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Fi(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Fe(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Fi0(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Fp(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Fp0(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Li(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Li0(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Lp0(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Lp(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_S(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(phase_mechanical_P(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(phase_mechanical_S0(ph)%data(3,3,Nconstituents),source=0.0_pReal) + allocate(phase_mechanical_F(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_F0(ph)%data(3,3,Nconstituents)) phase => phases%get(ph) mech => phase%get('mechanics') @@ -287,17 +287,17 @@ module subroutine mech_init(phases) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = material_orientation0(co,ip,el)%asMatrix() ! Fp reflects initial orientation (see 10.1016/j.actamat.2006.01.005) - constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) & - / math_det33(constitutive_mech_Fp0(ph)%data(1:3,1:3,me))**(1.0_pReal/3.0_pReal) - constitutive_mech_Fi0(ph)%data(1:3,1:3,me) = math_I3 - constitutive_mech_F0(ph)%data(1:3,1:3,me) = math_I3 + phase_mechanical_Fp0(ph)%data(1:3,1:3,me) = material_orientation0(co,ip,el)%asMatrix() ! Fp reflects initial orientation (see 10.1016/j.actamat.2006.01.005) + phase_mechanical_Fp0(ph)%data(1:3,1:3,me) = phase_mechanical_Fp0(ph)%data(1:3,1:3,me) & + / math_det33(phase_mechanical_Fp0(ph)%data(1:3,1:3,me))**(1.0_pReal/3.0_pReal) + phase_mechanical_Fi0(ph)%data(1:3,1:3,me) = math_I3 + phase_mechanical_F0(ph)%data(1:3,1:3,me) = math_I3 - constitutive_mech_Fe(ph)%data(1:3,1:3,me) = math_inv33(matmul(constitutive_mech_Fi0(ph)%data(1:3,1:3,me), & - constitutive_mech_Fp0(ph)%data(1:3,1:3,me))) ! assuming that euler angles are given in internal strain free configuration - constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) - constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) - constitutive_mech_F(ph)%data(1:3,1:3,me) = constitutive_mech_F0(ph)%data(1:3,1:3,me) + phase_mechanical_Fe(ph)%data(1:3,1:3,me) = math_inv33(matmul(phase_mechanical_Fi0(ph)%data(1:3,1:3,me), & + phase_mechanical_Fp0(ph)%data(1:3,1:3,me))) ! assuming that euler angles are given in internal strain free configuration + phase_mechanical_Fp(ph)%data(1:3,1:3,me) = phase_mechanical_Fp0(ph)%data(1:3,1:3,me) + phase_mechanical_Fi(ph)%data(1:3,1:3,me) = phase_mechanical_Fi0(ph)%data(1:3,1:3,me) + phase_mechanical_F(ph)%data(1:3,1:3,me) = phase_mechanical_F0(ph)%data(1:3,1:3,me) enddo enddo; enddo @@ -307,14 +307,14 @@ module subroutine mech_init(phases) ! initialize plasticity allocate(plasticState(phases%length)) allocate(phase_plasticity(phases%length),source = PLASTICITY_undefined_ID) - allocate(phase_plasticityInstance(phases%length),source = 0) + allocate(phase_plasticInstance(phases%length),source = 0) allocate(phase_localPlasticity(phases%length), source=.true.) call plastic_init() do ph = 1, phases%length phase_elasticityInstance(ph) = count(phase_elasticity(1:ph) == phase_elasticity(ph)) - phase_plasticityInstance(ph) = count(phase_plasticity(1:ph) == phase_plasticity(ph)) + phase_plasticInstance(ph) = count(phase_plasticity(1:ph) == phase_plasticity(ph)) enddo num_crystallite => config_numerics%get('crystallite',defaultVal=emptyDict) @@ -345,14 +345,14 @@ module subroutine mech_init(phases) call eigendeformation_init(phases) -end subroutine mech_init +end subroutine mechanical_init !-------------------------------------------------------------------------------------------------- !> @brief returns the 2nd Piola-Kirchhoff stress tensor and its tangent with respect to !> the elastic and intermediate deformation gradients using Hooke's law !-------------------------------------------------------------------------------------------------- -subroutine constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & +subroutine phase_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & Fe, Fi, co, ip, el) integer, intent(in) :: & @@ -376,7 +376,7 @@ subroutine constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & i, j, ph, me ho = material_homogenizationAt(el) - C = math_66toSym3333(constitutive_homogenizedC(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el))) + C = math_66toSym3333(phase_homogenizedC(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el))) DegradationLoop: do d = 1, phase_NstiffnessDegradations(material_phaseAt(co,el)) degradationType: select case(phase_stiffnessDegradation(d,material_phaseAt(co,el))) @@ -393,10 +393,10 @@ subroutine constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & dS_dFi(i,j,1:3,1:3) = 2.0_pReal*matmul(matmul(E,Fi),C(i,j,1:3,1:3)) !< dS_ij/dFi_kl = C_ijln * E_km * Fe_mn enddo; enddo -end subroutine constitutive_hooke_SandItsTangents +end subroutine phase_hooke_SandItsTangents -module subroutine mech_results(group,ph) +module subroutine mechanical_results(group,ph) character(len=*), intent(in) :: group integer, intent(in) :: ph @@ -407,28 +407,28 @@ module subroutine mech_results(group,ph) select case(phase_plasticity(ph)) case(PLASTICITY_ISOTROPIC_ID) - call plastic_isotropic_results(phase_plasticityInstance(ph),group//'plastic/') + call plastic_isotropic_results(phase_plasticInstance(ph),group//'plastic/') case(PLASTICITY_PHENOPOWERLAW_ID) - call plastic_phenopowerlaw_results(phase_plasticityInstance(ph),group//'plastic/') + call plastic_phenopowerlaw_results(phase_plasticInstance(ph),group//'plastic/') case(PLASTICITY_KINEHARDENING_ID) - call plastic_kinehardening_results(phase_plasticityInstance(ph),group//'plastic/') + call plastic_kinehardening_results(phase_plasticInstance(ph),group//'plastic/') case(PLASTICITY_DISLOTWIN_ID) - call plastic_dislotwin_results(phase_plasticityInstance(ph),group//'plastic/') + call plastic_dislotwin_results(phase_plasticInstance(ph),group//'plastic/') case(PLASTICITY_DISLOTUNGSTEN_ID) - call plastic_dislotungsten_results(phase_plasticityInstance(ph),group//'plastic/') + call plastic_dislotungsten_results(phase_plasticInstance(ph),group//'plastic/') case(PLASTICITY_NONLOCAL_ID) - call plastic_nonlocal_results(phase_plasticityInstance(ph),group//'plastic/') + call plastic_nonlocal_results(phase_plasticInstance(ph),group//'plastic/') end select call crystallite_results(group,ph) -end subroutine mech_results +end subroutine mechanical_results !-------------------------------------------------------------------------------------------------- @@ -503,8 +503,8 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) call plastic_dependentState(co,ip,el) - Lpguess = constitutive_mech_Lp(ph)%data(1:3,1:3,me) ! take as first guess - Liguess = constitutive_mech_Li(ph)%data(1:3,1:3,me) ! take as first guess + Lpguess = phase_mechanical_Lp(ph)%data(1:3,1:3,me) ! take as first guess + Liguess = phase_mechanical_Li(ph)%data(1:3,1:3,me) ! take as first guess call math_invert33(invFp_current,devNull,error,subFp0) if (error) return ! error @@ -538,7 +538,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) B = math_I3 - Delta_t*Lpguess Fe = matmul(matmul(A,B), invFi_new) - call constitutive_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & + call phase_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & Fe, Fi_new, co, ip, el) call plastic_LpAndItsTangents(Lp_constitutive, dLp_dS, dLp_dFi, & @@ -582,7 +582,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) + deltaLp * steplengthLp enddo LpLoop - call constitutive_LiAndItsTangents(Li_constitutive, dLi_dS, dLi_dFi, & + call phase_LiAndItsTangents(Li_constitutive, dLi_dS, dLi_dFi, & S, Fi_new, co, ip, el) !* update current residuum and check for convergence of loop @@ -633,13 +633,13 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) call math_invert33(Fp_new,devNull,error,invFp_new) if (error) return ! error - constitutive_mech_P(ph)%data(1:3,1:3,me) = matmul(matmul(F,invFp_new),matmul(S,transpose(invFp_new))) - constitutive_mech_S(ph)%data(1:3,1:3,me) = S - constitutive_mech_Lp(ph)%data(1:3,1:3,me) = Lpguess - constitutive_mech_Li(ph)%data(1:3,1:3,me) = Liguess - constitutive_mech_Fp(ph)%data(1:3,1:3,me) = Fp_new / math_det33(Fp_new)**(1.0_pReal/3.0_pReal) ! regularize - constitutive_mech_Fi(ph)%data(1:3,1:3,me) = Fi_new - constitutive_mech_Fe(ph)%data(1:3,1:3,me) = matmul(matmul(F,invFp_new),invFi_new) + phase_mechanical_P(ph)%data(1:3,1:3,me) = matmul(matmul(F,invFp_new),matmul(S,transpose(invFp_new))) + phase_mechanical_S(ph)%data(1:3,1:3,me) = S + phase_mechanical_Lp(ph)%data(1:3,1:3,me) = Lpguess + phase_mechanical_Li(ph)%data(1:3,1:3,me) = Liguess + phase_mechanical_Fp(ph)%data(1:3,1:3,me) = Fp_new / math_det33(Fp_new)**(1.0_pReal/3.0_pReal) ! regularize + phase_mechanical_Fi(ph)%data(1:3,1:3,me) = Fi_new + phase_mechanical_Fe(ph)%data(1:3,1:3,me) = matmul(matmul(F,invFp_new),invFi_new) broken = .false. end function integrateStress @@ -668,9 +668,9 @@ function integrateStateFPI(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) resul sizeDotState real(pReal) :: & zeta - real(pReal), dimension(constitutive_plasticity_maxSizeDotState) :: & + real(pReal), dimension(phase_plasticity_maxSizeDotState) :: & r ! state residuum - real(pReal), dimension(constitutive_plasticity_maxSizeDotState,2) :: & + real(pReal), dimension(phase_plasticity_maxSizeDotState,2) :: & dotState @@ -796,7 +796,7 @@ function integrateStateAdaptiveEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip ph, & me, & sizeDotState - real(pReal), dimension(constitutive_plasticity_maxSizeDotState) :: residuum_plastic + real(pReal), dimension(phase_plasticity_maxSizeDotState) :: residuum_plastic ph = material_phaseAt(co,el) @@ -914,7 +914,7 @@ function integrateStateRK(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el,A,B,C,D ph, & me, & sizeDotState - real(pReal), dimension(constitutive_plasticity_maxSizeDotState,size(B)) :: plastic_RKdotState + real(pReal), dimension(phase_plasticity_maxSizeDotState,size(B)) :: plastic_RKdotState ph = material_phaseAt(co,el) @@ -987,28 +987,28 @@ subroutine crystallite_results(group,ph) select case (output_constituent(ph)%label(ou)) case('F') - call results_writeDataset(group//'/mechanics/',constitutive_mech_F(ph)%data,'F',& + call results_writeDataset(group//'/mechanics/',phase_mechanical_F(ph)%data,'F',& 'deformation gradient','1') case('F_e') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Fe(ph)%data,'F_e',& + call results_writeDataset(group//'/mechanics/',phase_mechanical_Fe(ph)%data,'F_e',& 'elastic deformation gradient','1') case('F_p') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Fp(ph)%data,'F_p', & + call results_writeDataset(group//'/mechanics/',phase_mechanical_Fp(ph)%data,'F_p', & 'plastic deformation gradient','1') case('F_i') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Fi(ph)%data,'F_i', & + call results_writeDataset(group//'/mechanics/',phase_mechanical_Fi(ph)%data,'F_i', & 'inelastic deformation gradient','1') case('L_p') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Lp(ph)%data,'L_p', & + call results_writeDataset(group//'/mechanics/',phase_mechanical_Lp(ph)%data,'L_p', & 'plastic velocity gradient','1/s') case('L_i') - call results_writeDataset(group//'/mechanics/',constitutive_mech_Li(ph)%data,'L_i', & + call results_writeDataset(group//'/mechanics/',phase_mechanical_Li(ph)%data,'L_i', & 'inelastic velocity gradient','1/s') case('P') - call results_writeDataset(group//'/mechanics/',constitutive_mech_P(ph)%data,'P', & + call results_writeDataset(group//'/mechanics/',phase_mechanical_P(ph)%data,'P', & 'First Piola-Kirchhoff stress','Pa') case('S') - call results_writeDataset(group//'/mechanics/',constitutive_mech_S(ph)%data,'S', & + call results_writeDataset(group//'/mechanics/',phase_mechanical_S(ph)%data,'S', & 'Second Piola-Kirchhoff stress','Pa') case('O') select case(lattice_structure(ph)) @@ -1067,43 +1067,43 @@ end subroutine crystallite_results !-------------------------------------------------------------------------------------------------- !> @brief Wind homog inc forward. !-------------------------------------------------------------------------------------------------- -module subroutine mech_windForward(ph,me) +module subroutine mechanical_windForward(ph,me) integer, intent(in) :: ph, me - constitutive_mech_Fp0(ph)%data(1:3,1:3,me) = constitutive_mech_Fp(ph)%data(1:3,1:3,me) - constitutive_mech_Fi0(ph)%data(1:3,1:3,me) = constitutive_mech_Fi(ph)%data(1:3,1:3,me) - constitutive_mech_F0(ph)%data(1:3,1:3,me) = constitutive_mech_F(ph)%data(1:3,1:3,me) - constitutive_mech_Li0(ph)%data(1:3,1:3,me) = constitutive_mech_Li(ph)%data(1:3,1:3,me) - constitutive_mech_Lp0(ph)%data(1:3,1:3,me) = constitutive_mech_Lp(ph)%data(1:3,1:3,me) - constitutive_mech_S0(ph)%data(1:3,1:3,me) = constitutive_mech_S(ph)%data(1:3,1:3,me) + phase_mechanical_Fp0(ph)%data(1:3,1:3,me) = phase_mechanical_Fp(ph)%data(1:3,1:3,me) + phase_mechanical_Fi0(ph)%data(1:3,1:3,me) = phase_mechanical_Fi(ph)%data(1:3,1:3,me) + phase_mechanical_F0(ph)%data(1:3,1:3,me) = phase_mechanical_F(ph)%data(1:3,1:3,me) + phase_mechanical_Li0(ph)%data(1:3,1:3,me) = phase_mechanical_Li(ph)%data(1:3,1:3,me) + phase_mechanical_Lp0(ph)%data(1:3,1:3,me) = phase_mechanical_Lp(ph)%data(1:3,1:3,me) + phase_mechanical_S0(ph)%data(1:3,1:3,me) = phase_mechanical_S(ph)%data(1:3,1:3,me) plasticState(ph)%State0(:,me) = plasticState(ph)%state(:,me) -end subroutine mech_windForward +end subroutine mechanical_windForward !-------------------------------------------------------------------------------------------------- !> @brief Forward data after successful increment. ! ToDo: Any guessing for the current states possible? !-------------------------------------------------------------------------------------------------- -module subroutine mech_forward() +module subroutine mechanical_forward() integer :: ph do ph = 1, size(plasticState) - constitutive_mech_Fi0(ph) = constitutive_mech_Fi(ph) - constitutive_mech_Fp0(ph) = constitutive_mech_Fp(ph) - constitutive_mech_F0(ph) = constitutive_mech_F(ph) - constitutive_mech_Li0(ph) = constitutive_mech_Li(ph) - constitutive_mech_Lp0(ph) = constitutive_mech_Lp(ph) - constitutive_mech_S0(ph) = constitutive_mech_S(ph) + phase_mechanical_Fi0(ph) = phase_mechanical_Fi(ph) + phase_mechanical_Fp0(ph) = phase_mechanical_Fp(ph) + phase_mechanical_F0(ph) = phase_mechanical_F(ph) + phase_mechanical_Li0(ph) = phase_mechanical_Li(ph) + phase_mechanical_Lp0(ph) = phase_mechanical_Lp(ph) + phase_mechanical_S0(ph) = phase_mechanical_S(ph) plasticState(ph)%state0 = plasticState(ph)%state enddo -end subroutine mech_forward +end subroutine mechanical_forward @@ -1111,19 +1111,19 @@ end subroutine mech_forward !> @brief returns the homogenize elasticity matrix !> ToDo: homogenizedC66 would be more consistent !-------------------------------------------------------------------------------------------------- -module function constitutive_homogenizedC(ph,me) result(C) +module function phase_homogenizedC(ph,me) result(C) real(pReal), dimension(6,6) :: C integer, intent(in) :: ph, me - plasticityType: select case (phase_plasticity(ph)) - case (PLASTICITY_DISLOTWIN_ID) plasticityType + plasticType: select case (phase_plasticity(ph)) + case (PLASTICITY_DISLOTWIN_ID) plasticType C = plastic_dislotwin_homogenizedC(ph,me) - case default plasticityType + case default plasticType C = lattice_C66(1:6,1:6,ph) - end select plasticityType + end select plasticType -end function constitutive_homogenizedC +end function phase_homogenizedC !-------------------------------------------------------------------------------------------------- @@ -1158,17 +1158,17 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) me = material_phaseMemberAt(co,ip,el) sizeDotState = plasticState(ph)%sizeDotState - subLi0 = constitutive_mech_Li0(ph)%data(1:3,1:3,me) - subLp0 = constitutive_mech_Lp0(ph)%data(1:3,1:3,me) + subLi0 = phase_mechanical_Li0(ph)%data(1:3,1:3,me) + subLp0 = phase_mechanical_Lp0(ph)%data(1:3,1:3,me) subState0 = plasticState(ph)%State0(:,me) do so = 1, phase_Nsources(ph) damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%state0(:,me) enddo - subFp0 = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) - subFi0 = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) - subF0 = constitutive_mech_F0(ph)%data(1:3,1:3,me) + subFp0 = phase_mechanical_Fp0(ph)%data(1:3,1:3,me) + subFi0 = phase_mechanical_Fi0(ph)%data(1:3,1:3,me) + subF0 = phase_mechanical_F0(ph)%data(1:3,1:3,me) subFrac = 0.0_pReal subStep = 1.0_pReal/num%subStepSizeCryst todo = .true. @@ -1186,10 +1186,10 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) if (todo) then subF0 = subF - subLp0 = constitutive_mech_Lp(ph)%data(1:3,1:3,me) - subLi0 = constitutive_mech_Li(ph)%data(1:3,1:3,me) - subFp0 = constitutive_mech_Fp(ph)%data(1:3,1:3,me) - subFi0 = constitutive_mech_Fi(ph)%data(1:3,1:3,me) + subLp0 = phase_mechanical_Lp(ph)%data(1:3,1:3,me) + subLi0 = phase_mechanical_Li(ph)%data(1:3,1:3,me) + subFp0 = phase_mechanical_Fp(ph)%data(1:3,1:3,me) + subFi0 = phase_mechanical_Fi(ph)%data(1:3,1:3,me) subState0 = plasticState(ph)%state(:,me) do so = 1, phase_Nsources(ph) damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%state(:,me) @@ -1199,12 +1199,12 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) ! cut back (reduced time and restore) else subStep = num%subStepSizeCryst * subStep - constitutive_mech_Fp(ph)%data(1:3,1:3,me) = subFp0 - constitutive_mech_Fi(ph)%data(1:3,1:3,me) = subFi0 - constitutive_mech_S(ph)%data(1:3,1:3,me) = constitutive_mech_S0(ph)%data(1:3,1:3,me) ! why no subS0 ? is S0 of any use? + phase_mechanical_Fp(ph)%data(1:3,1:3,me) = subFp0 + phase_mechanical_Fi(ph)%data(1:3,1:3,me) = subFi0 + phase_mechanical_S(ph)%data(1:3,1:3,me) = phase_mechanical_S0(ph)%data(1:3,1:3,me) ! why no subS0 ? is S0 of any use? if (subStep < 1.0_pReal) then ! actual (not initial) cutback - constitutive_mech_Lp(ph)%data(1:3,1:3,me) = subLp0 - constitutive_mech_Li(ph)%data(1:3,1:3,me) = subLi0 + phase_mechanical_Lp(ph)%data(1:3,1:3,me) = subLp0 + phase_mechanical_Li(ph)%data(1:3,1:3,me) = subLi0 endif plasticState(ph)%state(:,me) = subState0 do so = 1, phase_Nsources(ph) @@ -1218,9 +1218,9 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) ! prepare for integration if (todo) then subF = subF0 & - + subStep * (constitutive_mech_F(ph)%data(1:3,1:3,me) - constitutive_mech_F0(ph)%data(1:3,1:3,me)) - constitutive_mech_Fe(ph)%data(1:3,1:3,me) = matmul(subF,math_inv33(matmul(constitutive_mech_Fi(ph)%data(1:3,1:3,me), & - constitutive_mech_Fp(ph)%data(1:3,1:3,me)))) + + subStep * (phase_mechanical_F(ph)%data(1:3,1:3,me) - phase_mechanical_F0(ph)%data(1:3,1:3,me)) + phase_mechanical_Fe(ph)%data(1:3,1:3,me) = matmul(subF,math_inv33(matmul(phase_mechanical_Fi(ph)%data(1:3,1:3,me), & + phase_mechanical_Fp(ph)%data(1:3,1:3,me)))) converged_ = .not. integrateState(subF0,subF,subFp0,subFi0,subState0(1:sizeDotState),subStep * dt,co,ip,el) converged_ = converged_ .and. .not. integrateDamageState(subStep * dt,co,ip,el) endif @@ -1233,7 +1233,7 @@ end function crystallite_stress !-------------------------------------------------------------------------------------------------- !> @brief Restore data after homog cutback. !-------------------------------------------------------------------------------------------------- -module subroutine mech_restore(ce,includeL) +module subroutine mechanical_restore(ce,includeL) integer, intent(in) :: ce logical, intent(in) :: & @@ -1247,23 +1247,23 @@ module subroutine mech_restore(ce,includeL) ph = material_phaseAt2(co,ce) me = material_phaseMemberAt2(co,ce) if (includeL) then - constitutive_mech_Lp(ph)%data(1:3,1:3,me) = constitutive_mech_Lp0(ph)%data(1:3,1:3,me) - constitutive_mech_Li(ph)%data(1:3,1:3,me) = constitutive_mech_Li0(ph)%data(1:3,1:3,me) + phase_mechanical_Lp(ph)%data(1:3,1:3,me) = phase_mechanical_Lp0(ph)%data(1:3,1:3,me) + phase_mechanical_Li(ph)%data(1:3,1:3,me) = phase_mechanical_Li0(ph)%data(1:3,1:3,me) endif ! maybe protecting everything from overwriting makes more sense - constitutive_mech_Fp(ph)%data(1:3,1:3,me) = constitutive_mech_Fp0(ph)%data(1:3,1:3,me) - constitutive_mech_Fi(ph)%data(1:3,1:3,me) = constitutive_mech_Fi0(ph)%data(1:3,1:3,me) - constitutive_mech_S(ph)%data(1:3,1:3,me) = constitutive_mech_S0(ph)%data(1:3,1:3,me) + phase_mechanical_Fp(ph)%data(1:3,1:3,me) = phase_mechanical_Fp0(ph)%data(1:3,1:3,me) + phase_mechanical_Fi(ph)%data(1:3,1:3,me) = phase_mechanical_Fi0(ph)%data(1:3,1:3,me) + phase_mechanical_S(ph)%data(1:3,1:3,me) = phase_mechanical_S0(ph)%data(1:3,1:3,me) plasticState(ph)%state(:,me) = plasticState(ph)%State0(:,me) enddo -end subroutine mech_restore +end subroutine mechanical_restore !-------------------------------------------------------------------------------------------------- !> @brief Calculate tangent (dPdF). !-------------------------------------------------------------------------------------------------- -module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) +module function phase_mechanical_dPdF(dt,co,ip,el) result(dPdF) real(pReal), intent(in) :: dt integer, intent(in) :: & @@ -1297,18 +1297,18 @@ module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - call constitutive_hooke_SandItsTangents(devNull,dSdFe,dSdFi, & - constitutive_mech_Fe(ph)%data(1:3,1:3,me), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) - call constitutive_LiAndItsTangents(devNull,dLidS,dLidFi, & - constitutive_mech_S(ph)%data(1:3,1:3,me), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me), & + call phase_hooke_SandItsTangents(devNull,dSdFe,dSdFi, & + phase_mechanical_Fe(ph)%data(1:3,1:3,me), & + phase_mechanical_Fi(ph)%data(1:3,1:3,me),co,ip,el) + call phase_LiAndItsTangents(devNull,dLidS,dLidFi, & + phase_mechanical_S(ph)%data(1:3,1:3,me), & + phase_mechanical_Fi(ph)%data(1:3,1:3,me), & co,ip,el) - invFp = math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me)) - invFi = math_inv33(constitutive_mech_Fi(ph)%data(1:3,1:3,me)) - invSubFp0 = math_inv33(constitutive_mech_Fp0(ph)%data(1:3,1:3,me)) - invSubFi0 = math_inv33(constitutive_mech_Fi0(ph)%data(1:3,1:3,me)) + invFp = math_inv33(phase_mechanical_Fp(ph)%data(1:3,1:3,me)) + invFi = math_inv33(phase_mechanical_Fi(ph)%data(1:3,1:3,me)) + invSubFp0 = math_inv33(phase_mechanical_Fp0(ph)%data(1:3,1:3,me)) + invSubFi0 = math_inv33(phase_mechanical_Fi0(ph)%data(1:3,1:3,me)) if (sum(abs(dLidS)) < tol_math_check) then dFidS = 0.0_pReal @@ -1334,15 +1334,15 @@ module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) endif call plastic_LpAndItsTangents(devNull,dLpdS,dLpdFi, & - constitutive_mech_S(ph)%data(1:3,1:3,me), & - constitutive_mech_Fi(ph)%data(1:3,1:3,me),co,ip,el) + phase_mechanical_S(ph)%data(1:3,1:3,me), & + phase_mechanical_Fi(ph)%data(1:3,1:3,me),co,ip,el) dLpdS = math_mul3333xx3333(dLpdFi,dFidS) + dLpdS !-------------------------------------------------------------------------------------------------- ! calculate dSdF temp_33_1 = transpose(matmul(invFp,invFi)) - temp_33_2 = matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invSubFp0) - temp_33_3 = matmul(matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invFp), invSubFi0) + temp_33_2 = matmul(phase_mechanical_F(ph)%data(1:3,1:3,me),invSubFp0) + temp_33_3 = matmul(matmul(phase_mechanical_F(ph)%data(1:3,1:3,me),invFp), invSubFi0) do o=1,3; do p=1,3 rhs_3333(p,o,1:3,1:3) = matmul(dSdFe(p,o,1:3,1:3),temp_33_1) @@ -1370,9 +1370,9 @@ module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) !-------------------------------------------------------------------------------------------------- ! assemble dPdF - temp_33_1 = matmul(constitutive_mech_S(ph)%data(1:3,1:3,me),transpose(invFp)) - temp_33_2 = matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),invFp) - temp_33_3 = matmul(temp_33_2,constitutive_mech_S(ph)%data(1:3,1:3,me)) + temp_33_1 = matmul(phase_mechanical_S(ph)%data(1:3,1:3,me),transpose(invFp)) + temp_33_2 = matmul(phase_mechanical_F(ph)%data(1:3,1:3,me),invFp) + temp_33_3 = matmul(temp_33_2,phase_mechanical_S(ph)%data(1:3,1:3,me)) dPdF = 0.0_pReal do p=1,3 @@ -1380,129 +1380,129 @@ module function constitutive_mech_dPdF(dt,co,ip,el) result(dPdF) enddo do o=1,3; do p=1,3 dPdF(1:3,1:3,p,o) = dPdF(1:3,1:3,p,o) & - + matmul(matmul(constitutive_mech_F(ph)%data(1:3,1:3,me),dFpinvdF(1:3,1:3,p,o)),temp_33_1) & + + matmul(matmul(phase_mechanical_F(ph)%data(1:3,1:3,me),dFpinvdF(1:3,1:3,p,o)),temp_33_1) & + matmul(matmul(temp_33_2,dSdF(1:3,1:3,p,o)),transpose(invFp)) & + matmul(temp_33_3,transpose(dFpinvdF(1:3,1:3,p,o))) enddo; enddo -end function constitutive_mech_dPdF +end function phase_mechanical_dPdF -module subroutine mech_restartWrite(groupHandle,ph) +module subroutine mechanical_restartWrite(groupHandle,ph) integer(HID_T), intent(in) :: groupHandle integer, intent(in) :: ph call HDF5_write(groupHandle,plasticState(ph)%state,'omega') - call HDF5_write(groupHandle,constitutive_mech_Fi(ph)%data,'F_i') - call HDF5_write(groupHandle,constitutive_mech_Li(ph)%data,'L_i') - call HDF5_write(groupHandle,constitutive_mech_Lp(ph)%data,'L_p') - call HDF5_write(groupHandle,constitutive_mech_Fp(ph)%data,'F_p') - call HDF5_write(groupHandle,constitutive_mech_S(ph)%data,'S') - call HDF5_write(groupHandle,constitutive_mech_F(ph)%data,'F') + call HDF5_write(groupHandle,phase_mechanical_Fi(ph)%data,'F_i') + call HDF5_write(groupHandle,phase_mechanical_Li(ph)%data,'L_i') + call HDF5_write(groupHandle,phase_mechanical_Lp(ph)%data,'L_p') + call HDF5_write(groupHandle,phase_mechanical_Fp(ph)%data,'F_p') + call HDF5_write(groupHandle,phase_mechanical_S(ph)%data,'S') + call HDF5_write(groupHandle,phase_mechanical_F(ph)%data,'F') -end subroutine mech_restartWrite +end subroutine mechanical_restartWrite -module subroutine mech_restartRead(groupHandle,ph) +module subroutine mechanical_restartRead(groupHandle,ph) integer(HID_T), intent(in) :: groupHandle integer, intent(in) :: ph call HDF5_read(groupHandle,plasticState(ph)%state0,'omega') - call HDF5_read(groupHandle,constitutive_mech_Fi0(ph)%data,'F_i') - call HDF5_read(groupHandle,constitutive_mech_Li0(ph)%data,'L_i') - call HDF5_read(groupHandle,constitutive_mech_Lp0(ph)%data,'L_p') - call HDF5_read(groupHandle,constitutive_mech_Fp0(ph)%data,'F_p') - call HDF5_read(groupHandle,constitutive_mech_S0(ph)%data,'S') - call HDF5_read(groupHandle,constitutive_mech_F0(ph)%data,'F') + call HDF5_read(groupHandle,phase_mechanical_Fi0(ph)%data,'F_i') + call HDF5_read(groupHandle,phase_mechanical_Li0(ph)%data,'L_i') + call HDF5_read(groupHandle,phase_mechanical_Lp0(ph)%data,'L_p') + call HDF5_read(groupHandle,phase_mechanical_Fp0(ph)%data,'F_p') + call HDF5_read(groupHandle,phase_mechanical_S0(ph)%data,'S') + call HDF5_read(groupHandle,phase_mechanical_F0(ph)%data,'F') -end subroutine mech_restartRead +end subroutine mechanical_restartRead !---------------------------------------------------------------------------------------------- !< @brief Get first Piola-Kichhoff stress (for use by non-mech physics) !---------------------------------------------------------------------------------------------- -module function mech_S(ph,me) result(S) +module function mechanical_S(ph,me) result(S) integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: S - S = constitutive_mech_S(ph)%data(1:3,1:3,me) + S = phase_mechanical_S(ph)%data(1:3,1:3,me) -end function mech_S +end function mechanical_S !---------------------------------------------------------------------------------------------- !< @brief Get plastic velocity gradient (for use by non-mech physics) !---------------------------------------------------------------------------------------------- -module function mech_L_p(ph,me) result(L_p) +module function mechanical_L_p(ph,me) result(L_p) integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: L_p - L_p = constitutive_mech_Lp(ph)%data(1:3,1:3,me) + L_p = phase_mechanical_Lp(ph)%data(1:3,1:3,me) -end function mech_L_p +end function mechanical_L_p !---------------------------------------------------------------------------------------------- !< @brief Get deformation gradient (for use by homogenization) !---------------------------------------------------------------------------------------------- -module function constitutive_mech_getF(co,ip,el) result(F) +module function phase_mechanical_getF(co,ip,el) result(F) integer, intent(in) :: co, ip, el real(pReal), dimension(3,3) :: F - F = constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + F = phase_mechanical_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) -end function constitutive_mech_getF +end function phase_mechanical_getF !---------------------------------------------------------------------------------------------- !< @brief Get elastic deformation gradient (for use by non-mech physics) !---------------------------------------------------------------------------------------------- -module function mech_F_e(ph,me) result(F_e) +module function mechanical_F_e(ph,me) result(F_e) integer, intent(in) :: ph,me real(pReal), dimension(3,3) :: F_e - F_e = constitutive_mech_Fe(ph)%data(1:3,1:3,me) + F_e = phase_mechanical_Fe(ph)%data(1:3,1:3,me) -end function mech_F_e +end function mechanical_F_e !---------------------------------------------------------------------------------------------- !< @brief Get second Piola-Kichhoff stress (for use by homogenization) !---------------------------------------------------------------------------------------------- -module function constitutive_mech_getP(co,ip,el) result(P) +module function phase_mechanical_getP(co,ip,el) result(P) integer, intent(in) :: co, ip, el real(pReal), dimension(3,3) :: P - P = constitutive_mech_P(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + P = phase_mechanical_P(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) -end function constitutive_mech_getP +end function phase_mechanical_getP ! setter for homogenization -module subroutine constitutive_mech_setF(F,co,ip,el) +module subroutine phase_mechanical_setF(F,co,ip,el) real(pReal), dimension(3,3), intent(in) :: F integer, intent(in) :: co, ip, el - constitutive_mech_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) = F + phase_mechanical_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) = F -end subroutine constitutive_mech_setF +end subroutine phase_mechanical_setF end submodule mechanics diff --git a/src/phase_mechanics_eigendeformation.f90 b/src/phase_mechanical_eigen.f90 similarity index 96% rename from src/phase_mechanics_eigendeformation.f90 rename to src/phase_mechanical_eigen.f90 index 45cfd82d3..6df993565 100644 --- a/src/phase_mechanics_eigendeformation.f90 +++ b/src/phase_mechanical_eigen.f90 @@ -126,7 +126,7 @@ end function kinematics_active !> @brief contains the constitutive equation for calculating the velocity gradient ! ToDo: MD: S is Mi? !-------------------------------------------------------------------------------------------------- -module subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & +module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & S, Fi, co, ip, el) integer, intent(in) :: & @@ -159,15 +159,15 @@ module subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & dLi_dS = 0.0_pReal dLi_dFi = 0.0_pReal - plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) - case (PLASTICITY_isotropic_ID) plasticityType + plasticType: select case (phase_plasticity(material_phaseAt(co,el))) + case (PLASTICITY_isotropic_ID) plasticType of = material_phasememberAt(co,ip,el) - instance = phase_plasticityInstance(material_phaseAt(co,el)) + instance = phase_plasticInstance(material_phaseAt(co,el)) call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,instance,of) - case default plasticityType + case default plasticType my_Li = 0.0_pReal my_dLi_dS = 0.0_pReal - end select plasticityType + end select plasticType Li = Li + my_Li dLi_dS = dLi_dS + my_dLi_dS @@ -201,7 +201,7 @@ module subroutine constitutive_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & dLi_dFi(1:3,i,1:3,j) = dLi_dFi(1:3,i,1:3,j) + math_I3*temp_33(j,i) + Li*FiInv(j,i) enddo; enddo -end subroutine constitutive_LiAndItsTangents +end subroutine phase_LiAndItsTangents end submodule eigendeformation diff --git a/src/phase_mechanics_eigendeformation_cleavageopening.f90 b/src/phase_mechanical_eigen_cleavageopening.f90 similarity index 100% rename from src/phase_mechanics_eigendeformation_cleavageopening.f90 rename to src/phase_mechanical_eigen_cleavageopening.f90 diff --git a/src/phase_mechanics_eigendeformation_slipplaneopening.f90 b/src/phase_mechanical_eigen_slipplaneopening.f90 similarity index 100% rename from src/phase_mechanics_eigendeformation_slipplaneopening.f90 rename to src/phase_mechanical_eigen_slipplaneopening.f90 diff --git a/src/phase_mechanics_eigendeformation_thermalexpansion.f90 b/src/phase_mechanical_eigen_thermalexpansion.f90 similarity index 100% rename from src/phase_mechanics_eigendeformation_thermalexpansion.f90 rename to src/phase_mechanical_eigen_thermalexpansion.f90 diff --git a/src/phase_mechanics_plastic.f90 b/src/phase_mechanical_plastic.f90 similarity index 91% rename from src/phase_mechanics_plastic.f90 rename to src/phase_mechanical_plastic.f90 index fff1fbdcf..ed1dc64fb 100644 --- a/src/phase_mechanics_plastic.f90 +++ b/src/phase_mechanical_plastic.f90 @@ -270,31 +270,31 @@ module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & me = material_phasememberAt(co,ip,el) ph = material_phaseAt(co,el) - plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) + plasticType: select case (phase_plasticity(material_phaseAt(co,el))) - case (PLASTICITY_NONE_ID) plasticityType + case (PLASTICITY_NONE_ID) plasticType Lp = 0.0_pReal dLp_dMp = 0.0_pReal - case (PLASTICITY_ISOTROPIC_ID) plasticityType + case (PLASTICITY_ISOTROPIC_ID) plasticType call isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) - case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType + case (PLASTICITY_PHENOPOWERLAW_ID) plasticType call phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) - case (PLASTICITY_KINEHARDENING_ID) plasticityType + case (PLASTICITY_KINEHARDENING_ID) plasticType call kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) - case (PLASTICITY_NONLOCAL_ID) plasticityType + case (PLASTICITY_NONLOCAL_ID) plasticType call nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),ph,me,ip,el) - case (PLASTICITY_DISLOTWIN_ID) plasticityType + case (PLASTICITY_DISLOTWIN_ID) plasticType call dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),ph,me) - case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType + case (PLASTICITY_DISLOTUNGSTEN_ID) plasticType call dislotungsten_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),ph,me) - end select plasticityType + end select plasticType do i=1,3; do j=1,3 dLp_dFi(i,j,1:3,1:3) = matmul(matmul(Fi,S),transpose(dLp_dMp(i,j,1:3,1:3))) + & @@ -323,29 +323,29 @@ module function plastic_dotState(subdt,co,ip,el,ph,me) result(broken) logical :: broken - Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,me)),& - constitutive_mech_Fi(ph)%data(1:3,1:3,me)),constitutive_mech_S(ph)%data(1:3,1:3,me)) + Mp = matmul(matmul(transpose(phase_mechanical_Fi(ph)%data(1:3,1:3,me)),& + phase_mechanical_Fi(ph)%data(1:3,1:3,me)),phase_mechanical_S(ph)%data(1:3,1:3,me)) - plasticityType: select case (phase_plasticity(ph)) + plasticType: select case (phase_plasticity(ph)) - case (PLASTICITY_ISOTROPIC_ID) plasticityType + case (PLASTICITY_ISOTROPIC_ID) plasticType call isotropic_dotState(Mp,ph,me) - case (PLASTICITY_PHENOPOWERLAW_ID) plasticityType + case (PLASTICITY_PHENOPOWERLAW_ID) plasticType call phenopowerlaw_dotState(Mp,ph,me) - case (PLASTICITY_KINEHARDENING_ID) plasticityType + case (PLASTICITY_KINEHARDENING_ID) plasticType call plastic_kinehardening_dotState(Mp,ph,me) - case (PLASTICITY_DISLOTWIN_ID) plasticityType + case (PLASTICITY_DISLOTWIN_ID) plasticType call dislotwin_dotState(Mp,thermal_T(ph,me),ph,me) - case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType + case (PLASTICITY_DISLOTUNGSTEN_ID) plasticType call dislotungsten_dotState(Mp,thermal_T(ph,me),ph,me) - case (PLASTICITY_NONLOCAL_ID) plasticityType + case (PLASTICITY_NONLOCAL_ID) plasticType call nonlocal_dotState(Mp,thermal_T(ph,me),subdt,ph,me,ip,el) - end select plasticityType + end select plasticType broken = any(IEEE_is_NaN(plasticState(ph)%dotState(:,me))) @@ -369,20 +369,20 @@ module subroutine plastic_dependentState(co, ip, el) ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) - instance = phase_plasticityInstance(ph) + instance = phase_plasticInstance(ph) - plasticityType: select case (phase_plasticity(material_phaseAt(co,el))) + plasticType: select case (phase_plasticity(material_phaseAt(co,el))) - case (PLASTICITY_DISLOTWIN_ID) plasticityType + case (PLASTICITY_DISLOTWIN_ID) plasticType call dislotwin_dependentState(thermal_T(ph,me),instance,me) - case (PLASTICITY_DISLOTUNGSTEN_ID) plasticityType + case (PLASTICITY_DISLOTUNGSTEN_ID) plasticType call dislotungsten_dependentState(instance,me) - case (PLASTICITY_NONLOCAL_ID) plasticityType + case (PLASTICITY_NONLOCAL_ID) plasticType call nonlocal_dependentState(instance,me,ip,el) - end select plasticityType + end select plasticType end subroutine plastic_dependentState @@ -410,24 +410,24 @@ module function plastic_deltaState(co, ip, el, ph, me) result(broken) mySize - Mp = matmul(matmul(transpose(constitutive_mech_Fi(ph)%data(1:3,1:3,me)),& - constitutive_mech_Fi(ph)%data(1:3,1:3,me)),constitutive_mech_S(ph)%data(1:3,1:3,me)) - instance = phase_plasticityInstance(ph) + Mp = matmul(matmul(transpose(phase_mechanical_Fi(ph)%data(1:3,1:3,me)),& + phase_mechanical_Fi(ph)%data(1:3,1:3,me)),phase_mechanical_S(ph)%data(1:3,1:3,me)) + instance = phase_plasticInstance(ph) - plasticityType: select case (phase_plasticity(ph)) + plasticType: select case (phase_plasticity(ph)) - case (PLASTICITY_KINEHARDENING_ID) plasticityType + case (PLASTICITY_KINEHARDENING_ID) plasticType call plastic_kinehardening_deltaState(Mp,instance,me) broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,me))) - case (PLASTICITY_NONLOCAL_ID) plasticityType + case (PLASTICITY_NONLOCAL_ID) plasticType call plastic_nonlocal_deltaState(Mp,instance,me,ip,el) broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,me))) case default broken = .false. - end select plasticityType + end select plasticType if(.not. broken) then select case(phase_plasticity(ph)) diff --git a/src/phase_mechanics_plastic_dislotungsten.f90 b/src/phase_mechanical_plastic_dislotungsten.f90 similarity index 97% rename from src/phase_mechanics_plastic_dislotungsten.f90 rename to src/phase_mechanical_plastic_dislotungsten.f90 index a47132c63..a9946b6e7 100644 --- a/src/phase_mechanics_plastic_dislotungsten.f90 +++ b/src/phase_mechanical_plastic_dislotungsten.f90 @@ -226,7 +226,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) sizeDotState = size(['rho_mob ','rho_dip ','gamma_sl']) * prm%sum_N_sl sizeState = sizeDotState - call constitutive_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization @@ -289,16 +289,16 @@ pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & integer :: & i,k,l,m,n - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & dot_gamma_pos,dot_gamma_neg, & ddot_gamma_dtau_pos,ddot_gamma_dtau_neg Lp = 0.0_pReal dLp_dMp = 0.0_pReal - associate(prm => param(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph))) - call kinetics(Mp,T,phase_plasticityInstance(ph),me,dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg) + call kinetics(Mp,T,phase_plasticInstance(ph),me,dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg) do i = 1, prm%sum_N_sl Lp = Lp + (dot_gamma_pos(i)+dot_gamma_neg(i))*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -327,7 +327,7 @@ module subroutine dislotungsten_dotState(Mp,T,ph,me) real(pReal) :: & VacancyDiffusion - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & gdot_pos, gdot_neg,& tau_pos,& tau_neg, & @@ -336,10 +336,10 @@ module subroutine dislotungsten_dotState(Mp,T,ph,me) dot_rho_dip_climb, & dip_distance - associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)),& - dot => dotState(phase_plasticityInstance(ph)), dst => dependentState(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)),& + dot => dotState(phase_plasticInstance(ph)), dst => dependentState(phase_plasticInstance(ph))) - call kinetics(Mp,T,phase_plasticityInstance(ph),me,& + call kinetics(Mp,T,phase_plasticInstance(ph),me,& gdot_pos,gdot_neg, & tau_pos_out = tau_pos,tau_neg_out = tau_neg) diff --git a/src/phase_mechanics_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 similarity index 97% rename from src/phase_mechanics_plastic_dislotwin.f90 rename to src/phase_mechanical_plastic_dislotwin.f90 index 9f7464323..e1259fbd2 100644 --- a/src/phase_mechanics_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -415,7 +415,7 @@ module function plastic_dislotwin_init() result(myPlasticity) sizeState = sizeDotState - call constitutive_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! locally defined state aliases and initialization of state0 and atol @@ -496,8 +496,8 @@ module function plastic_dislotwin_homogenizedC(ph,me) result(homogenizedC) real(pReal) :: f_unrotated - associate(prm => param(phase_plasticityInstance(ph)),& - stt => state(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)),& + stt => state(phase_plasticInstance(ph))) f_unrotated = 1.0_pReal & - sum(stt%f_tw(1:prm%sum_N_tw,me)) & @@ -535,11 +535,11 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) BoltzmannRatio, & ddot_gamma_dtau, & tau - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & dot_gamma_sl,ddot_gamma_dtau_slip - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tw) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tw) :: & dot_gamma_twin,ddot_gamma_dtau_twin - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tr) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tr) :: & dot_gamma_tr,ddot_gamma_dtau_trans real(pReal):: dot_gamma_sb real(pReal), dimension(3,3) :: eigVectors, P_sb @@ -564,7 +564,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) 0, 1, 1 & ],pReal),[ 3,6]) - associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph))) f_unrotated = 1.0_pReal & - sum(stt%f_tw(1:prm%sum_N_tw,me)) & @@ -573,7 +573,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) Lp = 0.0_pReal dLp_dMp = 0.0_pReal - call kinetics_slip(Mp,T,phase_plasticityInstance(ph),me,dot_gamma_sl,ddot_gamma_dtau_slip) + call kinetics_slip(Mp,T,phase_plasticInstance(ph),me,dot_gamma_sl,ddot_gamma_dtau_slip) slipContribution: do i = 1, prm%sum_N_sl Lp = Lp + dot_gamma_sl(i)*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -581,7 +581,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) + ddot_gamma_dtau_slip(i) * prm%P_sl(k,l,i) * prm%P_sl(m,n,i) enddo slipContribution - call kinetics_twin(Mp,T,dot_gamma_sl,phase_plasticityInstance(ph),me,dot_gamma_twin,ddot_gamma_dtau_twin) + call kinetics_twin(Mp,T,dot_gamma_sl,phase_plasticInstance(ph),me,dot_gamma_twin,ddot_gamma_dtau_twin) twinContibution: do i = 1, prm%sum_N_tw Lp = Lp + dot_gamma_twin(i)*prm%P_tw(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -589,7 +589,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) + ddot_gamma_dtau_twin(i)* prm%P_tw(k,l,i)*prm%P_tw(m,n,i) enddo twinContibution - call kinetics_trans(Mp,T,dot_gamma_sl,phase_plasticityInstance(ph),me,dot_gamma_tr,ddot_gamma_dtau_trans) + call kinetics_trans(Mp,T,dot_gamma_sl,phase_plasticInstance(ph),me,dot_gamma_tr,ddot_gamma_dtau_trans) transContibution: do i = 1, prm%sum_N_tr Lp = Lp + dot_gamma_tr(i)*prm%P_tr(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -653,24 +653,24 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) tau, & sigma_cl, & !< climb stress b_d !< ratio of Burgers vector to stacking fault width - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & dot_rho_dip_formation, & dot_rho_dip_climb, & rho_dip_distance_min, & dot_gamma_sl - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tw) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tw) :: & dot_gamma_twin - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tr) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tr) :: & dot_gamma_tr - associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)), & - dot => dotState(phase_plasticityInstance(ph)), dst => dependentState(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)), & + dot => dotState(phase_plasticInstance(ph)), dst => dependentState(phase_plasticInstance(ph))) f_unrotated = 1.0_pReal & - sum(stt%f_tw(1:prm%sum_N_tw,me)) & - sum(stt%f_tr(1:prm%sum_N_tr,me)) - call kinetics_slip(Mp,T,phase_plasticityInstance(ph),me,dot_gamma_sl) + call kinetics_slip(Mp,T,phase_plasticInstance(ph),me,dot_gamma_sl) dot%gamma_sl(:,me) = abs(dot_gamma_sl) rho_dip_distance_min = prm%D_a*prm%b_sl @@ -721,10 +721,10 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) - 2.0_pReal*rho_dip_distance_min/prm%b_sl * stt%rho_dip(:,me)*abs(dot_gamma_sl) & - dot_rho_dip_climb - call kinetics_twin(Mp,T,dot_gamma_sl,phase_plasticityInstance(ph),me,dot_gamma_twin) + call kinetics_twin(Mp,T,dot_gamma_sl,phase_plasticInstance(ph),me,dot_gamma_twin) dot%f_tw(:,me) = f_unrotated*dot_gamma_twin/prm%gamma_char - call kinetics_trans(Mp,T,dot_gamma_sl,phase_plasticityInstance(ph),me,dot_gamma_tr) + call kinetics_trans(Mp,T,dot_gamma_sl,phase_plasticInstance(ph),me,dot_gamma_tr) dot%f_tr(:,me) = f_unrotated*dot_gamma_tr end associate diff --git a/src/phase_mechanics_plastic_isotropic.f90 b/src/phase_mechanical_plastic_isotropic.f90 similarity index 97% rename from src/phase_mechanics_plastic_isotropic.f90 rename to src/phase_mechanical_plastic_isotropic.f90 index 6789e74b4..1a4e1449a 100644 --- a/src/phase_mechanics_plastic_isotropic.f90 +++ b/src/phase_mechanical_plastic_isotropic.f90 @@ -135,7 +135,7 @@ module function plastic_isotropic_init() result(myPlasticity) sizeDotState = size(['xi ','gamma']) sizeState = sizeDotState - call constitutive_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization @@ -190,7 +190,7 @@ module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) integer :: & k, l, m, n - associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph))) Mp_dev = math_deviatoric33(Mp) squarenorm_Mp_dev = math_tensordot(Mp_dev,Mp_dev) @@ -275,8 +275,8 @@ module subroutine isotropic_dotState(Mp,ph,me) xi_inf_star, & !< saturation xi norm_Mp !< norm of the (deviatoric) Mandel stress - associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)), & - dot => dotState(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)), & + dot => dotState(phase_plasticInstance(ph))) if (prm%dilatation) then norm_Mp = sqrt(math_tensordot(Mp,Mp)) diff --git a/src/phase_mechanics_plastic_kinehardening.f90 b/src/phase_mechanical_plastic_kinehardening.f90 similarity index 97% rename from src/phase_mechanics_plastic_kinehardening.f90 rename to src/phase_mechanical_plastic_kinehardening.f90 index 919302bc1..f00e4171b 100644 --- a/src/phase_mechanics_plastic_kinehardening.f90 +++ b/src/phase_mechanical_plastic_kinehardening.f90 @@ -180,7 +180,7 @@ module function plastic_kinehardening_init() result(myPlasticity) sizeDeltaState = size(['sense ', 'chi0 ', 'gamma0' ]) * prm%sum_N_sl !ToDo: adjust names sizeState = sizeDotState + sizeDeltaState - call constitutive_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,sizeDeltaState) + call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,sizeDeltaState) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization @@ -255,16 +255,16 @@ pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) integer :: & i,k,l,m,n - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & gdot_pos,gdot_neg, & dgdot_dtau_pos,dgdot_dtau_neg Lp = 0.0_pReal dLp_dMp = 0.0_pReal - associate(prm => param(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph))) - call kinetics(Mp,phase_plasticityInstance(ph),me,gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) + call kinetics(Mp,phase_plasticInstance(ph),me,gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) do i = 1, prm%sum_N_sl Lp = Lp + (gdot_pos(i)+gdot_neg(i))*prm%P(1:3,1:3,i) @@ -292,14 +292,14 @@ module subroutine plastic_kinehardening_dotState(Mp,ph,me) real(pReal) :: & sumGamma - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & gdot_pos,gdot_neg - associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)),& - dot => dotState(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)),& + dot => dotState(phase_plasticInstance(ph))) - call kinetics(Mp,phase_plasticityInstance(ph),me,gdot_pos,gdot_neg) + call kinetics(Mp,phase_plasticInstance(ph),me,gdot_pos,gdot_neg) dot%accshear(:,me) = abs(gdot_pos+gdot_neg) sumGamma = sum(stt%accshear(:,me)) diff --git a/src/phase_mechanics_plastic_none.f90 b/src/phase_mechanical_plastic_none.f90 similarity index 96% rename from src/phase_mechanics_plastic_none.f90 rename to src/phase_mechanical_plastic_none.f90 index b8d1678eb..b95eaa039 100644 --- a/src/phase_mechanics_plastic_none.f90 +++ b/src/phase_mechanical_plastic_none.f90 @@ -44,7 +44,7 @@ module function plastic_none_init() result(myPlasticity) phase => phases%get(p) if(.not. myPlasticity(p)) cycle Nconstituents = count(material_phaseAt2 == p) - call constitutive_allocateState(plasticState(p),Nconstituents,0,0,0) + call phase_allocateState(plasticState(p),Nconstituents,0,0,0) enddo end function plastic_none_init diff --git a/src/phase_mechanics_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 similarity index 97% rename from src/phase_mechanics_plastic_nonlocal.f90 rename to src/phase_mechanical_plastic_nonlocal.f90 index 693ffcf93..724086916 100644 --- a/src/phase_mechanics_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -407,7 +407,7 @@ module function plastic_nonlocal_init() result(myPlasticity) 'maxDipoleHeightEdge ','maxDipoleHeightScrew' ]) * prm%sum_N_sl !< other dependent state variables that are not updated by microstructure sizeDeltaState = sizeDotState - call constitutive_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,sizeDeltaState) + call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,sizeDeltaState) plasticState(p)%nonlocal = pl%get_asBool('nonlocal') if(plasticState(p)%nonlocal .and. .not. allocated(IPneighborhood)) & @@ -642,8 +642,8 @@ module subroutine nonlocal_dependentState(instance, me, ip, el) rho0 = getRho0(instance,me,ip,el) if (.not. phase_localPlasticity(material_phaseAt(1,el)) .and. prm%shortRangeStressCorrection) then ph = material_phaseAt(1,el) - invFp = math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me)) - invFe = math_inv33(constitutive_mech_Fe(ph)%data(1:3,1:3,me)) + invFp = math_inv33(phase_mechanical_Fp(ph)%data(1:3,1:3,me)) + invFe = math_inv33(phase_mechanical_Fe(ph)%data(1:3,1:3,me)) rho_edg_delta = rho0(:,mob_edg_pos) - rho0(:,mob_edg_neg) rho_scr_delta = rho0(:,mob_scr_pos) - rho0(:,mob_scr_neg) @@ -662,7 +662,7 @@ module subroutine nonlocal_dependentState(instance, me, ip, el) neighbor_ip = IPneighborhood(2,n,ip,el) no = material_phasememberAt(1,neighbor_ip,neighbor_el) if (neighbor_el > 0 .and. neighbor_ip > 0) then - neighbor_instance = phase_plasticityInstance(material_phaseAt(1,neighbor_el)) + neighbor_instance = phase_plasticInstance(material_phaseAt(1,neighbor_el)) if (neighbor_instance == instance) then nRealNeighbors = nRealNeighbors + 1.0_pReal @@ -782,25 +782,25 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & l, & t, & !< dislocation type s !< index of my current slip system - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,8) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,8) :: & rhoSgl !< single dislocation densities (including blocked) - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,10) :: & rho - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,4) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,4) :: & v, & !< velocity tauNS, & !< resolved shear stress including non Schmid and backstress terms dv_dtau, & !< velocity derivative with respect to the shear stress dv_dtauNS !< velocity derivative with respect to the shear stress - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & tau, & !< resolved shear stress including backstress terms gdotTotal !< shear rate - associate(prm => param(phase_plasticityInstance(ph)),dst=>microstructure(phase_plasticityInstance(ph)),& - stt=>state(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)),dst=>microstructure(phase_plasticInstance(ph)),& + stt=>state(phase_plasticInstance(ph))) ns = prm%sum_N_sl !*** shortcut to state variables - rho = getRho(phase_plasticityInstance(ph),me,ip,el) + rho = getRho(phase_plasticInstance(ph),me,ip,el) rhoSgl = rho(:,sgl) do s = 1,ns @@ -820,7 +820,7 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & ! edges call kinetics(v(:,1), dv_dtau(:,1), dv_dtauNS(:,1), & - tau, tauNS(:,1), dst%tau_pass(:,me),1,Temperature, phase_plasticityInstance(ph)) + tau, tauNS(:,1), dst%tau_pass(:,me),1,Temperature, phase_plasticInstance(ph)) v(:,2) = v(:,1) dv_dtau(:,2) = dv_dtau(:,1) dv_dtauNS(:,2) = dv_dtauNS(:,1) @@ -833,7 +833,7 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & else do t = 3,4 call kinetics(v(:,t), dv_dtau(:,t), dv_dtauNS(:,t), & - tau, tauNS(:,t), dst%tau_pass(:,me),2,Temperature, phase_plasticityInstance(ph)) + tau, tauNS(:,t), dst%tau_pass(:,me),2,Temperature, phase_plasticInstance(ph)) enddo endif @@ -992,7 +992,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & c, & !< character of dislocation t, & !< type of dislocation s !< index of my current slip system - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,10) :: & rho, & rho0, & !< dislocation density at beginning of time step rhoDot, & !< density evolution @@ -1000,17 +1000,17 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & rhoDotSingle2DipoleGlide, & !< density evolution by dipole formation (by glide) rhoDotAthermalAnnihilation, & !< density evolution by athermal annihilation rhoDotThermalAnnihilation !< density evolution by thermal annihilation - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,8) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,8) :: & rhoSgl, & !< current single dislocation densities (positive/negative screw and edge without dipoles) my_rhoSgl0 !< single dislocation densities of central ip (positive/negative screw and edge without dipoles) - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,4) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,4) :: & v, & !< current dislocation glide velocity v0, & gdot !< shear rates - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & tau, & !< current resolved shear stress vClimb !< climb velocity of edge dipoles - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl,2) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,2) :: & rhoDip, & !< current dipole dislocation densities (screw and edge dipoles) dLower, & !< minimum stable dipole distance for edges and screws dUpper !< current maximum stable dipole distance for edges and screws @@ -1022,22 +1022,22 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & return endif - associate(prm => param(phase_plasticityInstance(ph)), & - dst => microstructure(phase_plasticityInstance(ph)), & - dot => dotState(phase_plasticityInstance(ph)), & - stt => state(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)), & + dst => microstructure(phase_plasticInstance(ph)), & + dot => dotState(phase_plasticInstance(ph)), & + stt => state(phase_plasticInstance(ph))) ns = prm%sum_N_sl tau = 0.0_pReal gdot = 0.0_pReal - rho = getRho(phase_plasticityInstance(ph),me,ip,el) + rho = getRho(phase_plasticInstance(ph),me,ip,el) rhoSgl = rho(:,sgl) rhoDip = rho(:,dip) - rho0 = getRho0(phase_plasticityInstance(ph),me,ip,el) + rho0 = getRho0(phase_plasticInstance(ph),me,ip,el) my_rhoSgl0 = rho0(:,sgl) - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,phase_plasticityInstance(ph)),me) + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,phase_plasticInstance(ph)),me) gdot = rhoSgl(:,1:4) * v * spread(prm%b_sl,2,4) #ifdef DEBUG @@ -1086,7 +1086,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & * sqrt(stt%rho_forest(:,me)) / prm%i_sl / prm%b_sl, 2, 4) endif isBCC - forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,phase_plasticityInstance(ph)),me) + forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,phase_plasticInstance(ph)),me) !**************************************************************************** @@ -1142,7 +1142,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & - rhoDip(s,1) / timestep - rhoDotAthermalAnnihilation(s,9) & - rhoDotSingle2DipoleGlide(s,9)) ! make sure that we do not annihilate more dipoles than we have - rhoDot = rhoDotFlux(timestep, phase_plasticityInstance(ph),me,ip,el) & + rhoDot = rhoDotFlux(timestep, phase_plasticInstance(ph),me,ip,el) & + rhoDotMultiplication & + rhoDotSingle2DipoleGlide & + rhoDotAthermalAnnihilation & @@ -1284,8 +1284,8 @@ function rhoDotFlux(timestep,instance,me,ip,el) m(1:3,:,3) = -prm%slip_transverse m(1:3,:,4) = prm%slip_transverse - my_F = constitutive_mech_F(ph)%data(1:3,1:3,me) - my_Fe = matmul(my_F, math_inv33(constitutive_mech_Fp(ph)%data(1:3,1:3,me))) + my_F = phase_mechanical_F(ph)%data(1:3,1:3,me) + my_Fe = matmul(my_F, math_inv33(phase_mechanical_Fp(ph)%data(1:3,1:3,me))) neighbors: do n = 1,nIPneighbors @@ -1301,9 +1301,9 @@ function rhoDotFlux(timestep,instance,me,ip,el) opposite_n = IPneighborhood(3,opposite_neighbor,ip,el) if (neighbor_n > 0) then ! if neighbor exists, average deformation gradient - neighbor_instance = phase_plasticityInstance(material_phaseAt(1,neighbor_el)) - neighbor_F = constitutive_mech_F(np)%data(1:3,1:3,no) - neighbor_Fe = matmul(neighbor_F, math_inv33(constitutive_mech_Fp(np)%data(1:3,1:3,no))) + neighbor_instance = phase_plasticInstance(material_phaseAt(1,neighbor_el)) + neighbor_F = phase_mechanical_F(np)%data(1:3,1:3,no) + neighbor_Fe = matmul(neighbor_F, math_inv33(phase_mechanical_Fp(np)%data(1:3,1:3,no))) Favg = 0.5_pReal * (my_F + neighbor_F) else ! if no neighbor, take my value as average Favg = my_F diff --git a/src/phase_mechanics_plastic_phenopowerlaw.f90 b/src/phase_mechanical_plastic_phenopowerlaw.f90 similarity index 96% rename from src/phase_mechanics_plastic_phenopowerlaw.f90 rename to src/phase_mechanical_plastic_phenopowerlaw.f90 index ea2f53100..f9791faa6 100644 --- a/src/phase_mechanics_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanical_plastic_phenopowerlaw.f90 @@ -231,7 +231,7 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) sizeState = sizeDotState - call constitutive_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization @@ -300,18 +300,18 @@ pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) integer :: & i,k,l,m,n - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & gdot_slip_pos,gdot_slip_neg, & dgdot_dtauslip_pos,dgdot_dtauslip_neg - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_tw) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tw) :: & gdot_twin,dgdot_dtautwin Lp = 0.0_pReal dLp_dMp = 0.0_pReal - associate(prm => param(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph))) - call kinetics_slip(Mp,phase_plasticityInstance(ph),me,gdot_slip_pos,gdot_slip_neg,dgdot_dtauslip_pos,dgdot_dtauslip_neg) + call kinetics_slip(Mp,phase_plasticInstance(ph),me,gdot_slip_pos,gdot_slip_neg,dgdot_dtauslip_pos,dgdot_dtauslip_neg) slipSystems: do i = 1, prm%sum_N_sl Lp = Lp + (gdot_slip_pos(i)+gdot_slip_neg(i))*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -320,7 +320,7 @@ pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) + dgdot_dtauslip_neg(i) * prm%P_sl(k,l,i) * prm%nonSchmid_neg(m,n,i) enddo slipSystems - call kinetics_twin(Mp,phase_plasticityInstance(ph),me,gdot_twin,dgdot_dtautwin) + call kinetics_twin(Mp,phase_plasticInstance(ph),me,gdot_twin,dgdot_dtautwin) twinSystems: do i = 1, prm%sum_N_tw Lp = Lp + gdot_twin(i)*prm%P_tw(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -348,12 +348,12 @@ module subroutine phenopowerlaw_dotState(Mp,ph,me) c_SlipSlip,c_TwinSlip,c_TwinTwin, & xi_slip_sat_offset,& sumGamma,sumF - real(pReal), dimension(param(phase_plasticityInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & left_SlipSlip,right_SlipSlip, & gdot_slip_pos,gdot_slip_neg - associate(prm => param(phase_plasticityInstance(ph)), stt => state(phase_plasticityInstance(ph)), & - dot => dotState(phase_plasticityInstance(ph))) + associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)), & + dot => dotState(phase_plasticInstance(ph))) sumGamma = sum(stt%gamma_slip(:,me)) sumF = sum(stt%gamma_twin(:,me)/prm%gamma_tw_char) @@ -373,9 +373,9 @@ module subroutine phenopowerlaw_dotState(Mp,ph,me) !-------------------------------------------------------------------------------------------------- ! shear rates - call kinetics_slip(Mp,phase_plasticityInstance(ph),me,gdot_slip_pos,gdot_slip_neg) + call kinetics_slip(Mp,phase_plasticInstance(ph),me,gdot_slip_pos,gdot_slip_neg) dot%gamma_slip(:,me) = abs(gdot_slip_pos+gdot_slip_neg) - call kinetics_twin(Mp,phase_plasticityInstance(ph),me,dot%gamma_twin(:,me)) + call kinetics_twin(Mp,phase_plasticInstance(ph),me,dot%gamma_twin(:,me)) !-------------------------------------------------------------------------------------------------- ! hardening diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index d5d52b010..85ca2f7a5 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -124,7 +124,7 @@ end subroutine thermal_init !---------------------------------------------------------------------------------------------- !< @brief calculates thermal dissipation rate !---------------------------------------------------------------------------------------------- -module subroutine constitutive_thermal_getRate(TDot, ph,me) +module subroutine phase_thermal_getRate(TDot, ph,me) integer, intent(in) :: ph, me real(pReal), intent(out) :: & @@ -153,13 +153,13 @@ module subroutine constitutive_thermal_getRate(TDot, ph,me) enddo -end subroutine constitutive_thermal_getRate +end subroutine phase_thermal_getRate !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the rate of change of microstructure !-------------------------------------------------------------------------------------------------- -function constitutive_thermal_collectDotState(ph,me) result(broken) +function phase_thermal_collectDotState(ph,me) result(broken) integer, intent(in) :: ph, me logical :: broken @@ -178,7 +178,7 @@ function constitutive_thermal_collectDotState(ph,me) result(broken) enddo SourceLoop -end function constitutive_thermal_collectDotState +end function phase_thermal_collectDotState module function thermal_stress(Delta_t,ph,me) result(converged_) @@ -207,7 +207,7 @@ function integrateThermalState(Delta_t, ph,me) result(broken) so, & sizeDotState - broken = constitutive_thermal_collectDotState(ph,me) + broken = phase_thermal_collectDotState(ph,me) if(broken) return do so = 1, thermal_Nsources(ph) @@ -264,7 +264,7 @@ end function thermal_dot_T !---------------------------------------------------------------------------------------------- !< @brief Set temperature !---------------------------------------------------------------------------------------------- -module subroutine constitutive_thermal_setField(T,dot_T, co,ce) +module subroutine phase_thermal_setField(T,dot_T, co,ce) real(pReal), intent(in) :: T, dot_T integer, intent(in) :: ce, co @@ -273,7 +273,7 @@ module subroutine constitutive_thermal_setField(T,dot_T, co,ce) current(material_phaseAt2(co,ce))%T(material_phaseMemberAt2(co,ce)) = T current(material_phaseAt2(co,ce))%dot_T(material_phaseMemberAt2(co,ce)) = dot_T -end subroutine constitutive_thermal_setField +end subroutine phase_thermal_setField diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index 7a043308d..3c0095401 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -56,7 +56,7 @@ module function dissipation_init(source_length) result(mySources) prm%kappa = src%get_asFloat('kappa') Nconstituents = count(material_phaseAt2 == ph) - call constitutive_allocateState(thermalState(ph)%p(so),Nconstituents,0,0,0) + call phase_allocateState(thermalState(ph)%p(so),Nconstituents,0,0,0) end associate endif @@ -78,7 +78,7 @@ module subroutine dissipation_getRate(TDot, ph,me) associate(prm => param(ph)) - TDot = prm%kappa*sum(abs(mech_S(ph,me)*mech_L_p(ph,me))) + TDot = prm%kappa*sum(abs(mechanical_S(ph,me)*mechanical_L_p(ph,me))) end associate end subroutine dissipation_getRate diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index ddae6763b..d2874ded0 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -69,7 +69,7 @@ module function externalheat_init(source_length) result(mySources) prm%f_T = src%get_asFloats('f_T',requiredSize = size(prm%t_n)) Nconstituents = count(material_phaseAt2 == ph) - call constitutive_allocateState(thermalState(ph)%p(so),Nconstituents,1,1,0) + call phase_allocateState(thermalState(ph)%p(so),Nconstituents,1,1,0) end associate endif enddo From e8fae6b2a719eab09d2cdc21386bf11e28e7c320 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 11 Feb 2021 21:56:53 +0100 Subject: [PATCH 212/352] simplified --- python/damask/_vtk.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index ad017ee1e..00a07efa5 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -347,23 +347,21 @@ class VTK: See http://compilatrix.com/article/vtk-1 for further ideas. """ - def screen_size(): + try: + import wx + _ = wx.App(False) # noqa + width, height = wx.GetDisplaySize() + except ImportError: try: - import wx - _ = wx.App(False) # noqa - width, height = wx.GetDisplaySize() - except ImportError: - try: - import tkinter - tk = tkinter.Tk() - width = tk.winfo_screenwidth() - height = tk.winfo_screenheight() - tk.destroy() - except Exception as e: - width = 1024 - height = 768 + import tkinter + tk = tkinter.Tk() + width = tk.winfo_screenwidth() + height = tk.winfo_screenheight() + tk.destroy() + except Exception as e: + width = 1024 + height = 768 - return (width,height) mapper = vtk.vtkDataSetMapper() mapper.SetInputData(self.vtk_data) actor = vtk.vtkActor() @@ -377,7 +375,7 @@ class VTK: ren.AddActor(actor) ren.SetBackground(0.2,0.2,0.2) - window.SetSize(screen_size[0],screen_size[1]) + window.SetSize(width,height) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(window) From 09c330b8d2932003d5e4942386cef80913a13cef Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 11 Feb 2021 21:57:44 +0100 Subject: [PATCH 213/352] test for CRLF error (got lost) --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 91a4329a6..e74cf0062 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 91a4329a6fe073fc2ef17e5c2c8e2f796e3b897b +Subproject commit e74cf00628285a587ced1e551cc9837c1011ca1c From 4515920b695e01aa6b0a343eb3ffa41887e7fc4d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 11 Feb 2021 23:54:43 +0100 Subject: [PATCH 214/352] not needed --- src/homogenization.f90 | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 62ac52f06..14dd26726 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -311,26 +311,6 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE enddo !$OMP END DO -! !$OMP DO PRIVATE(ho,ph,ce) -! do el = FEsolving_execElem(1),FEsolving_execElem(2) -! if (terminallyIll) continue -! ho = material_homogenizationAt(el) -! do ip = FEsolving_execIP(1),FEsolving_execIP(2) -! ce = (el-1)*discretization_nIPs + ip -! call damage_partition(ce) -! do co = 1, homogenization_Nconstituents(ho) -! ph = material_phaseAt(co,el) -! if (.not. thermal_stress(dt,ph,material_phaseMemberAt(co,ip,el))) then -! if (.not. terminallyIll) & ! so first signals terminally ill... -! print*, ' Integration point ', ip,' at element ', el, ' terminally ill' -! terminallyIll = .true. ! ...and kills all others -! endif -! call thermal_homogenize(ip,el) -! enddo -! enddo -! enddo -! !$OMP END DO - !$OMP DO PRIVATE(ho) elementLooping3: do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) From f6be3fe0b74be7b4ee2e3d728fee9b75d0327f42 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 12 Feb 2021 00:12:57 +0100 Subject: [PATCH 215/352] no need for pointer --- src/damage_none.f90 | 4 ---- src/damage_nonlocal.f90 | 2 -- src/homogenization_damage.f90 | 4 ++-- src/material.f90 | 6 ------ src/phase_damage_anisobrittle.f90 | 2 +- src/phase_damage_anisoductile.f90 | 2 +- src/phase_damage_isoductile.f90 | 2 +- src/phase_mechanical.f90 | 2 +- src/phase_mechanical_eigen_cleavageopening.f90 | 2 +- src/phase_mechanical_eigen_slipplaneopening.f90 | 2 +- 10 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/damage_none.f90 b/src/damage_none.f90 index 680110d55..c4b1c1589 100644 --- a/src/damage_none.f90 +++ b/src/damage_none.f90 @@ -3,8 +3,6 @@ !> @brief material subroutine for constant damage field !-------------------------------------------------------------------------------------------------- module damage_none - use prec - use config use material implicit none @@ -29,8 +27,6 @@ subroutine damage_none_init allocate(damageState_h(h)%state0 (0,Nmaterialpoints)) allocate(damageState_h(h)%state (0,Nmaterialpoints)) - allocate (damage(h)%p(Nmaterialpoints), source=1.0_pReal) - enddo end subroutine damage_none_init diff --git a/src/damage_nonlocal.f90 b/src/damage_nonlocal.f90 index 807231889..dd50cf4cf 100644 --- a/src/damage_nonlocal.f90 +++ b/src/damage_nonlocal.f90 @@ -57,8 +57,6 @@ subroutine damage_nonlocal_init allocate(damageState_h(h)%state0 (1,Nmaterialpoints), source=1.0_pReal) allocate(damageState_h(h)%state (1,Nmaterialpoints), source=1.0_pReal) - damage(h)%p => damageState_h(h)%state(1,:) - enddo end subroutine damage_nonlocal_init diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index 8b73ed54a..4f23af3be 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -143,7 +143,7 @@ module subroutine damage_nonlocal_putNonLocalDamage(phi,ip,el) homog = material_homogenizationAt(el) offset = material_homogenizationMemberAt(ip,el) - damage(homog)%p(offset) = phi + damagestate_h(homog)%state(1,offset) = phi end subroutine damage_nonlocal_putNonLocalDamage @@ -162,7 +162,7 @@ module subroutine damage_nonlocal_results(homog,group) outputsLoop: do o = 1,size(prm%output) select case(prm%output(o)) case ('phi') - call results_writeDataset(group,damage(homog)%p,prm%output(o),& + call results_writeDataset(group,damagestate_h(homog)%state(1,:),prm%output(o),& 'damage indicator','-') end select enddo outputsLoop diff --git a/src/material.f90 b/src/material.f90 index ccc6898be..3689cd0b0 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -70,9 +70,6 @@ module material type(Rotation), dimension(:,:,:), allocatable, public, protected :: & material_orientation0 !< initial orientation of each grain,IP,element - type(group_float), allocatable, dimension(:), public :: & - damage !< damage field - public :: & material_init, & THERMAL_ISOTHERMAL_ID, & @@ -105,9 +102,6 @@ subroutine material_init(restart) allocate(homogState (size(material_name_homogenization))) allocate(damageState_h (size(material_name_homogenization))) - allocate(damage (size(material_name_homogenization))) - - if (.not. restart) then call results_openJobFile call results_mapping_phase(material_phaseAt,material_phaseMemberAt,material_name_phase) diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 51ca7786a..b328dfed7 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -152,7 +152,7 @@ module subroutine anisobrittle_dotState(S, co, ip, el) traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) traction_n = math_tensordot(S,prm%cleavage_systems(1:3,1:3,3,i)) - traction_crit = prm%g_crit(i)*damage(homog)%p(damageOffset)**2.0_pReal + traction_crit = prm%g_crit(i)*damagestate_h(homog)%state(1,damageOffset)**2.0_pReal damageState(ph)%p(sourceOffset)%dotState(1,me) & = damageState(ph)%p(sourceOffset)%dotState(1,me) & diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index e54eff201..18c29fdfc 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -129,7 +129,7 @@ module subroutine anisoductile_dotState(co, ip, el) associate(prm => param(source_damage_anisoDuctile_instance(ph))) damageState(ph)%p(sourceOffset)%dotState(1,me) & - = sum(plasticState(ph)%slipRate(:,me)/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit) + = sum(plasticState(ph)%slipRate(:,me)/(damagestate_h(homog)%state(1,damageOffset)**prm%q)/prm%gamma_crit) end associate end subroutine anisoductile_dotState diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index 71f99078b..9dac17cd8 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -120,7 +120,7 @@ module subroutine isoductile_dotState(co, ip, el) associate(prm => param(source_damage_isoDuctile_instance(ph))) damageState(ph)%p(sourceOffset)%dotState(1,me) = & - sum(plasticState(ph)%slipRate(:,me))/(damage(homog)%p(damageOffset)**prm%q)/prm%gamma_crit + sum(plasticState(ph)%slipRate(:,me))/(damagestate_h(homog)%state(1,damageOffset)**prm%q)/prm%gamma_crit end associate end subroutine isoductile_dotState diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index efd4d51d2..f2f3333d3 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -381,7 +381,7 @@ subroutine phase_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & DegradationLoop: do d = 1, phase_NstiffnessDegradations(material_phaseAt(co,el)) degradationType: select case(phase_stiffnessDegradation(d,material_phaseAt(co,el))) case (STIFFNESS_DEGRADATION_damage_ID) degradationType - C = C * damage(ho)%p(material_homogenizationMemberAt(ip,el))**2 + C = C * damagestate_h(ho)%state(1,material_homogenizationMemberAt(ip,el))**2 end select degradationType enddo DegradationLoop diff --git a/src/phase_mechanical_eigen_cleavageopening.f90 b/src/phase_mechanical_eigen_cleavageopening.f90 index 59be7837a..b41cb1e9c 100644 --- a/src/phase_mechanical_eigen_cleavageopening.f90 +++ b/src/phase_mechanical_eigen_cleavageopening.f90 @@ -126,7 +126,7 @@ module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, dLd_dTstar = 0.0_pReal associate(prm => param(kinematics_cleavage_opening_instance(material_phaseAt(co,el)))) do i = 1,prm%sum_N_cl - traction_crit = prm%g_crit(i)* damage(homog)%p(damageOffset)**2.0_pReal + traction_crit = prm%g_crit(i)*damagestate_h(homog)%state(1,damageOffset)**2.0_pReal traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) if (abs(traction_d) > traction_crit + tol_math_check) then diff --git a/src/phase_mechanical_eigen_slipplaneopening.f90 b/src/phase_mechanical_eigen_slipplaneopening.f90 index a144d39a6..682f0b825 100644 --- a/src/phase_mechanical_eigen_slipplaneopening.f90 +++ b/src/phase_mechanical_eigen_slipplaneopening.f90 @@ -152,7 +152,7 @@ module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S traction_t = math_tensordot(S,prm%P_t(1:3,1:3,i)) traction_n = math_tensordot(S,prm%P_n(1:3,1:3,i)) - traction_crit = prm%g_crit(i)* damage(homog)%p(damageOffset) ! degrading critical load carrying capacity by damage + traction_crit = prm%g_crit(i)* damagestate_h(homog)%state(1,damageOffset) ! degrading critical load carrying capacity by damage udotd = sign(1.0_pReal,traction_d)* prm%dot_o* ( abs(traction_d)/traction_crit & - abs(traction_d)/prm%g_crit(i))**prm%q From 462ca1a30b2893fb0897b26eb1eeb5ac95fbf07d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 12 Feb 2021 08:10:25 +0100 Subject: [PATCH 216/352] not needed --- src/commercialFEM_fileList.f90 | 1 - src/damage_none.f90 | 34 ---------------------------------- src/homogenization.f90 | 2 -- 3 files changed, 37 deletions(-) delete mode 100644 src/damage_none.f90 diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index a191298a3..cf48e19ce 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -41,7 +41,6 @@ #include "phase_damage_isoductile.f90" #include "phase_damage_anisobrittle.f90" #include "phase_damage_anisoductile.f90" -#include "damage_none.f90" #include "damage_nonlocal.f90" #include "homogenization.f90" #include "homogenization_mechanical.f90" diff --git a/src/damage_none.f90 b/src/damage_none.f90 deleted file mode 100644 index c4b1c1589..000000000 --- a/src/damage_none.f90 +++ /dev/null @@ -1,34 +0,0 @@ -!-------------------------------------------------------------------------------------------------- -!> @author Pratheek Shanthraj, Max-Planck-Institut für Eisenforschung GmbH -!> @brief material subroutine for constant damage field -!-------------------------------------------------------------------------------------------------- -module damage_none - use material - - implicit none - public - -contains - -!-------------------------------------------------------------------------------------------------- -!> @brief allocates all neccessary fields, reads information from material configuration file -!-------------------------------------------------------------------------------------------------- -subroutine damage_none_init - - integer :: h,Nmaterialpoints - - print'(/,a)', ' <<<+- damage_none init -+>>>'; flush(6) - - do h = 1, size(material_name_homogenization) - if (damage_type(h) /= DAMAGE_NONE_ID) cycle - - Nmaterialpoints = count(material_homogenizationAt == h) - damageState_h(h)%sizeState = 0 - allocate(damageState_h(h)%state0 (0,Nmaterialpoints)) - allocate(damageState_h(h)%state (0,Nmaterialpoints)) - - enddo - -end subroutine damage_none_init - -end module damage_none diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 14dd26726..87b15c43e 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -12,7 +12,6 @@ module homogenization use material use phase use discretization - use damage_none use damage_nonlocal use HDF5_utilities use results @@ -220,7 +219,6 @@ subroutine homogenization_init() call thermal_init() call damage_init() - if (any(damage_type == DAMAGE_none_ID)) call damage_none_init if (any(damage_type == DAMAGE_nonlocal_ID)) call damage_nonlocal_init From 7bec3e03630d8daa0c957b7cb5714fecf1274d5f Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 12 Feb 2021 09:31:02 +0100 Subject: [PATCH 217/352] use partitioned damage --- src/homogenization.f90 | 6 ++++-- src/homogenization_damage.f90 | 3 ++- src/material.f90 | 2 +- src/phase_damage_anisobrittle.f90 | 2 +- src/phase_damage_anisoductile.f90 | 2 +- src/phase_damage_isoductile.f90 | 2 +- src/phase_mechanical.f90 | 2 +- src/phase_mechanical_eigen_cleavageopening.f90 | 2 +- src/phase_mechanical_eigen_slipplaneopening.f90 | 2 +- 9 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 87b15c43e..3d0a4bb7a 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -219,7 +219,7 @@ subroutine homogenization_init() call thermal_init() call damage_init() - if (any(damage_type == DAMAGE_nonlocal_ID)) call damage_nonlocal_init + call damage_nonlocal_init end subroutine homogenization_init @@ -255,6 +255,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if(homogState(ho)%sizeState > 0) homogState(ho)%State(:,me) = homogState(ho)%State0(:,me) if(damageState_h(ho)%sizeState > 0) damageState_h(ho)%State(:,me) = damageState_h(ho)%State0(:,me) + call damage_partition(ce) doneAndHappy = [.false.,.true.] @@ -375,7 +376,8 @@ subroutine homogenization_forward do ho = 1, size(material_name_homogenization) homogState (ho)%state0 = homogState (ho)%state - damageState_h(ho)%state0 = damageState_h(ho)%state + if(damageState_h(ho)%sizeState > 0) & + damageState_h(ho)%state0 = damageState_h(ho)%state enddo end subroutine homogenization_forward diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index 4f23af3be..502174309 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -72,7 +72,8 @@ module subroutine damage_partition(ce) integer :: co - phi = current(material_homogenizationAt2(ce))%phi(material_homogenizationMemberAt2(ce)) + if(damageState_h(material_homogenizationAt2(ce))%sizeState < 1) return + phi = damagestate_h(material_homogenizationAt2(ce))%state(1,material_homogenizationMemberAt2(ce)) do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) call phase_damage_set_phi(phi,co,ce) enddo diff --git a/src/material.f90 b/src/material.f90 index 3689cd0b0..b76b2b296 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -100,7 +100,7 @@ subroutine material_init(restart) allocate(homogState (size(material_name_homogenization))) - allocate(damageState_h (size(material_name_homogenization))) + allocate(damageState_h (size(material_name_homogenization))) if (.not. restart) then call results_openJobFile diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index b328dfed7..699e9508b 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -152,7 +152,7 @@ module subroutine anisobrittle_dotState(S, co, ip, el) traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) traction_n = math_tensordot(S,prm%cleavage_systems(1:3,1:3,3,i)) - traction_crit = prm%g_crit(i)*damagestate_h(homog)%state(1,damageOffset)**2.0_pReal + traction_crit = prm%g_crit(i)*phase_damage_get_phi(co,ip,el)**2.0_pReal damageState(ph)%p(sourceOffset)%dotState(1,me) & = damageState(ph)%p(sourceOffset)%dotState(1,me) & diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index 18c29fdfc..b22f5b3d6 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -129,7 +129,7 @@ module subroutine anisoductile_dotState(co, ip, el) associate(prm => param(source_damage_anisoDuctile_instance(ph))) damageState(ph)%p(sourceOffset)%dotState(1,me) & - = sum(plasticState(ph)%slipRate(:,me)/(damagestate_h(homog)%state(1,damageOffset)**prm%q)/prm%gamma_crit) + = sum(plasticState(ph)%slipRate(:,me)/(phase_damage_get_phi(co,ip,el)**prm%q)/prm%gamma_crit) end associate end subroutine anisoductile_dotState diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index 9dac17cd8..e9aec1944 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -120,7 +120,7 @@ module subroutine isoductile_dotState(co, ip, el) associate(prm => param(source_damage_isoDuctile_instance(ph))) damageState(ph)%p(sourceOffset)%dotState(1,me) = & - sum(plasticState(ph)%slipRate(:,me))/(damagestate_h(homog)%state(1,damageOffset)**prm%q)/prm%gamma_crit + sum(plasticState(ph)%slipRate(:,me))/(phase_damage_get_phi(co,ip,el)**prm%q)/prm%gamma_crit end associate end subroutine isoductile_dotState diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index f2f3333d3..61151d33b 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -381,7 +381,7 @@ subroutine phase_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & DegradationLoop: do d = 1, phase_NstiffnessDegradations(material_phaseAt(co,el)) degradationType: select case(phase_stiffnessDegradation(d,material_phaseAt(co,el))) case (STIFFNESS_DEGRADATION_damage_ID) degradationType - C = C * damagestate_h(ho)%state(1,material_homogenizationMemberAt(ip,el))**2 + C = C * phase_damage_get_phi(co,ip,el)**2 end select degradationType enddo DegradationLoop diff --git a/src/phase_mechanical_eigen_cleavageopening.f90 b/src/phase_mechanical_eigen_cleavageopening.f90 index b41cb1e9c..55102e196 100644 --- a/src/phase_mechanical_eigen_cleavageopening.f90 +++ b/src/phase_mechanical_eigen_cleavageopening.f90 @@ -126,7 +126,7 @@ module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, dLd_dTstar = 0.0_pReal associate(prm => param(kinematics_cleavage_opening_instance(material_phaseAt(co,el)))) do i = 1,prm%sum_N_cl - traction_crit = prm%g_crit(i)*damagestate_h(homog)%state(1,damageOffset)**2.0_pReal + traction_crit = prm%g_crit(i)*phase_damage_get_phi(co,ip,el)**2.0_pReal traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) if (abs(traction_d) > traction_crit + tol_math_check) then diff --git a/src/phase_mechanical_eigen_slipplaneopening.f90 b/src/phase_mechanical_eigen_slipplaneopening.f90 index 682f0b825..cf5e918b3 100644 --- a/src/phase_mechanical_eigen_slipplaneopening.f90 +++ b/src/phase_mechanical_eigen_slipplaneopening.f90 @@ -152,7 +152,7 @@ module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S traction_t = math_tensordot(S,prm%P_t(1:3,1:3,i)) traction_n = math_tensordot(S,prm%P_n(1:3,1:3,i)) - traction_crit = prm%g_crit(i)* damagestate_h(homog)%state(1,damageOffset) ! degrading critical load carrying capacity by damage + traction_crit = prm%g_crit(i)* phase_damage_get_phi(co,ip,el) ! degrading critical load carrying capacity by damage udotd = sign(1.0_pReal,traction_d)* prm%dot_o* ( abs(traction_d)/traction_crit & - abs(traction_d)/prm%g_crit(i))**prm%q From f1b8978e2107f058dcaebb299eb61ddde166a7ef Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Wed, 10 Feb 2021 21:08:48 +0100 Subject: [PATCH 218/352] accept variables that will be used **kwargs allowed the use of extraneous arguments --- python/damask/_orientation.py | 101 ++++++++++++++++++++++++---------- python/damask/_rotation.py | 32 ++++------- 2 files changed, 82 insertions(+), 51 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index cf31f4089..47334d555 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -1,3 +1,5 @@ +import inspect + import numpy as np from . import Rotation @@ -107,8 +109,7 @@ class Orientation(Rotation): lattice = None, a = None,b = None,c = None, alpha = None,beta = None,gamma = None, - degrees = False, - **kwargs): + degrees = False): """ Initialize orientation object. @@ -263,71 +264,111 @@ class Orientation(Rotation): raise TypeError('Use "O@b", i.e. matmul, to apply Orientation "O" to object "b"') + @staticmethod + def _separate_arguments(parent_dict,function): + """ + Separate arguments required by Rotation and Orientation objects respectively. + + Parameters + ---------- + parent_dict : Dictionary + Contains all **kwargs + function: Method + Function whose signature list is required + + Returns + ------- + ori_dict: dictionary + Dictionary consisting of valid keys accepted by Orientation class + rot_dict: dictionary + Dictionary consisting of valid keys accepted by 'function' in Rotation class + + """ + set_ori = set(inspect.signature(Orientation.__init__).parameters.keys()) & set(parent_dict.keys()) + set_rot = set(inspect.signature(function).parameters.keys()) & set(parent_dict.keys()) + ori_dict = {key: parent_dict[key] for key in set_ori} + rot_dict = {key: parent_dict[key] for key in set_rot} + if(set(parent_dict.keys())-(set_ori|set_rot)): + raise KeyError(f'Unknown key {set(parent_dict.keys())-(set_ori|set_rot)} present') + return rot_dict,ori_dict + + @classmethod @util.extended_docstring(Rotation.from_random,_parameter_doc) def from_random(cls,**kwargs): - return cls(rotation=Rotation.from_random(**kwargs),**kwargs) + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_random) + return cls(rotation=Rotation.from_random(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_quaternion,_parameter_doc) def from_quaternion(cls,**kwargs): - return cls(rotation=Rotation.from_quaternion(**kwargs),**kwargs) + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_quaternion) + return cls(rotation=Rotation.from_quaternion(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_Euler_angles,_parameter_doc) def from_Euler_angles(cls,**kwargs): - return cls(rotation=Rotation.from_Euler_angles(**kwargs),**kwargs) - - + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_Euler_angles) + return cls(rotation=Rotation.from_Euler_angles(**kwargs_rot),**kwargs_ori) + + @classmethod @util.extended_docstring(Rotation.from_axis_angle,_parameter_doc) def from_axis_angle(cls,**kwargs): - return cls(rotation=Rotation.from_axis_angle(**kwargs),**kwargs) - - + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_axis_angle) + return cls(rotation=Rotation.from_axis_angle(**kwargs_rot),**kwargs_ori) + + @classmethod @util.extended_docstring(Rotation.from_basis,_parameter_doc) def from_basis(cls,**kwargs): - return cls(rotation=Rotation.from_basis(**kwargs),**kwargs) - - + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_basis) + return cls(rotation=Rotation.from_basis(**kwargs_rot),**kwargs_ori) + + @classmethod @util.extended_docstring(Rotation.from_matrix,_parameter_doc) def from_matrix(cls,**kwargs): - return cls(rotation=Rotation.from_matrix(**kwargs),**kwargs) - - + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_matrix) + return cls(rotation=Rotation.from_matrix(**kwargs_rot),**kwargs_ori) + + @classmethod @util.extended_docstring(Rotation.from_Rodrigues_vector,_parameter_doc) def from_Rodrigues_vector(cls,**kwargs): - return cls(rotation=Rotation.from_Rodrigues_vector(**kwargs),**kwargs) - - + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_Rodrigues_vector) + return cls(rotation=Rotation.from_Rodrigues_vector(**kwargs_rot),**kwargs_ori) + + @classmethod @util.extended_docstring(Rotation.from_homochoric,_parameter_doc) def from_homochoric(cls,**kwargs): - return cls(rotation=Rotation.from_homochoric(**kwargs),**kwargs) - - + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_homochoric) + return cls(rotation=Rotation.from_homochoric(**kwargs_rot),**kwargs_ori) + + @classmethod @util.extended_docstring(Rotation.from_cubochoric,_parameter_doc) def from_cubochoric(cls,**kwargs): - return cls(rotation=Rotation.from_cubochoric(**kwargs),**kwargs) - - + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_cubochoric) + return cls(rotation=Rotation.from_cubochoric(**kwargs_rot),**kwargs_ori) + + @classmethod @util.extended_docstring(Rotation.from_spherical_component,_parameter_doc) def from_spherical_component(cls,**kwargs): - return cls(rotation=Rotation.from_spherical_component(**kwargs),**kwargs) - - + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_spherical_component) + return cls(rotation=Rotation.from_spherical_component(**kwargs_rot),**kwargs_ori) + + @classmethod @util.extended_docstring(Rotation.from_fiber_component,_parameter_doc) def from_fiber_component(cls,**kwargs): - return cls(rotation=Rotation.from_fiber_component(**kwargs),**kwargs) - + kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_fiber_component) + return cls(rotation=Rotation.from_fiber_component(**kwargs_rot),**kwargs_ori) + @classmethod @util.extend_docstring(_parameter_doc) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 441fb5b01..389215798 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -514,8 +514,7 @@ class Rotation: @staticmethod def from_quaternion(q, accept_homomorph = False, - P = -1, - **kwargs): + P = -1): """ Initialize from quaternion. @@ -550,8 +549,7 @@ class Rotation: @staticmethod def from_Euler_angles(phi, - degrees = False, - **kwargs): + degrees = False): """ Initialize from Bunge-Euler angles. @@ -578,8 +576,7 @@ class Rotation: def from_axis_angle(axis_angle, degrees = False, normalize = False, - P = -1, - **kwargs): + P = -1): """ Initialize from Axis angle pair. @@ -616,8 +613,7 @@ class Rotation: @staticmethod def from_basis(basis, orthonormal = True, - reciprocal = False, - **kwargs): + reciprocal = False): """ Initialize from lattice basis vectors. @@ -651,7 +647,7 @@ class Rotation: return Rotation(Rotation._om2qu(om)) @staticmethod - def from_matrix(R,**kwargs): + def from_matrix(R): """ Initialize from rotation matrix. @@ -695,8 +691,7 @@ class Rotation: @staticmethod def from_Rodrigues_vector(rho, normalize = False, - P = -1, - **kwargs): + P = -1): """ Initialize from Rodrigues-Frank vector (angle separated from axis). @@ -727,8 +722,7 @@ class Rotation: @staticmethod def from_homochoric(h, - P = -1, - **kwargs): + P = -1): """ Initialize from homochoric vector. @@ -755,8 +749,7 @@ class Rotation: @staticmethod def from_cubochoric(c, - P = -1, - **kwargs): + P = -1): """ Initialize from cubochoric vector. @@ -784,8 +777,7 @@ class Rotation: @staticmethod def from_random(shape = None, - rng_seed = None, - **kwargs): + rng_seed = None): """ Draw random rotation. @@ -878,8 +870,7 @@ class Rotation: sigma, N = 500, degrees = True, - rng_seed = None, - **kwargs): + rng_seed = None): """ Calculate set of rotations with Gaussian distribution around center. @@ -915,8 +906,7 @@ class Rotation: sigma = 0.0, N = 500, degrees = True, - rng_seed = None, - **kwargs): + rng_seed = None): """ Calculate set of rotations with Gaussian distribution around direction. From 9e8a243d6f4596dce91b4bf76e2aaad4400beb41 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Fri, 12 Feb 2021 12:15:08 +0100 Subject: [PATCH 219/352] avoid name conflict with lattice parameter 'c' --- python/damask/_rotation.py | 12 ++++++------ python/tests/test_Orientation.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 389215798..4109c181e 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -502,8 +502,8 @@ class Rotation: Returns ------- - c : numpy.ndarray of shape (...,3) - Cubochoric vector: (c_1, c_2, c_3), max(c_i) < 1/2*π^(2/3). + x : numpy.ndarray of shape (...,3) + Cubochoric vector: (x_1, x_2, x_3), max(x_i) < 1/2*π^(2/3). """ return Rotation._qu2cu(self.quaternion) @@ -748,20 +748,20 @@ class Rotation: return Rotation(Rotation._ho2qu(ho)) @staticmethod - def from_cubochoric(c, + def from_cubochoric(x, P = -1): """ Initialize from cubochoric vector. Parameters ---------- - c : numpy.ndarray of shape (...,3) - Cubochoric vector: (c_1, c_2, c_3), max(c_i) < 1/2*π^(2/3). + x : numpy.ndarray of shape (...,3) + Cubochoric vector: (x_1, x_2, x_3), max(x_i) < 1/2*π^(2/3). P : int ∈ {-1,1}, optional Convention used. Defaults to -1. """ - cu = np.array(c,dtype=float) + cu = np.array(x,dtype=float) if cu.shape[:-2:-1] != (3,): raise ValueError('Invalid shape.') if abs(P) != 1: diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 436b73c04..92c3f63ab 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -118,7 +118,7 @@ class TestOrientation: == np.eye(3)) def test_from_cubochoric(self): - assert np.all(Orientation.from_cubochoric(c=np.zeros(3),lattice='triclinic').as_matrix() + assert np.all(Orientation.from_cubochoric(x=np.zeros(3),lattice='triclinic').as_matrix() == np.eye(3)) def test_from_spherical_component(self): From a09989fe0b53946e7607a2ddb309db6af31c6bb4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 12 Feb 2021 12:35:50 +0100 Subject: [PATCH 220/352] homogenized damage only needed in homogenization --- src/damage_nonlocal.f90 | 69 ----------------------------------- src/homogenization.f90 | 79 +++++++++++++++++++++++++++++++++++++++++ src/material.f90 | 7 ++-- 3 files changed, 81 insertions(+), 74 deletions(-) diff --git a/src/damage_nonlocal.f90 b/src/damage_nonlocal.f90 index dd50cf4cf..fab08d500 100644 --- a/src/damage_nonlocal.f90 +++ b/src/damage_nonlocal.f90 @@ -14,79 +14,10 @@ module damage_nonlocal implicit none private - type, private :: tNumerics - real(pReal) :: & - charLength !< characteristic length scale for gradient problems - end type tNumerics - type(tNumerics), private :: & - num - - public :: & - damage_nonlocal_init, & - damage_nonlocal_getDiffusion contains -!-------------------------------------------------------------------------------------------------- -!> @brief module initialization -!> @details reads in material parameters, allocates arrays, and does sanity checks -!-------------------------------------------------------------------------------------------------- -subroutine damage_nonlocal_init - - integer :: Ninstances,Nmaterialpoints,h - class(tNode), pointer :: & - num_generic, & - material_homogenization - - print'(/,a)', ' <<<+- damage_nonlocal init -+>>>'; flush(6) - -!------------------------------------------------------------------------------------ -! read numerics parameter - num_generic => config_numerics%get('generic',defaultVal= emptyDict) - num%charLength = num_generic%get_asFloat('charLength',defaultVal=1.0_pReal) - - Ninstances = count(damage_type == DAMAGE_nonlocal_ID) - - material_homogenization => config_material%get('homogenization') - do h = 1, material_homogenization%length - if (damage_type(h) /= DAMAGE_NONLOCAL_ID) cycle - - Nmaterialpoints = count(material_homogenizationAt == h) - damageState_h(h)%sizeState = 1 - allocate(damageState_h(h)%state0 (1,Nmaterialpoints), source=1.0_pReal) - allocate(damageState_h(h)%state (1,Nmaterialpoints), source=1.0_pReal) - - enddo - -end subroutine damage_nonlocal_init - - -!-------------------------------------------------------------------------------------------------- -!> @brief returns homogenized non local damage diffusion tensor in reference configuration -!-------------------------------------------------------------------------------------------------- -function damage_nonlocal_getDiffusion(ip,el) - - integer, intent(in) :: & - ip, & !< integration point number - el !< element number - real(pReal), dimension(3,3) :: & - damage_nonlocal_getDiffusion - integer :: & - homog, & - grain - - homog = material_homogenizationAt(el) - damage_nonlocal_getDiffusion = 0.0_pReal - do grain = 1, homogenization_Nconstituents(homog) - damage_nonlocal_getDiffusion = damage_nonlocal_getDiffusion + & - crystallite_push33ToRef(grain,ip,el,lattice_D(1:3,1:3,material_phaseAt(grain,el))) - enddo - - damage_nonlocal_getDiffusion = & - num%charLength**2*damage_nonlocal_getDiffusion/real(homogenization_Nconstituents(homog),pReal) - -end function damage_nonlocal_getDiffusion end module damage_nonlocal diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 3d0a4bb7a..36c03a314 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -15,10 +15,20 @@ module homogenization use damage_nonlocal use HDF5_utilities use results + use lattice implicit none private + type, private :: tNumerics_damage + real(pReal) :: & + charLength !< characteristic length scale for gradient problems + end type tNumerics_damage + + type(tNumerics_damage), private :: & + num_damage + + logical, public :: & terminallyIll = .false. !< at least one material point is terminally ill @@ -194,6 +204,10 @@ module homogenization homogenization_restartRead, & homogenization_restartWrite + public :: & + damage_nonlocal_init, & + damage_nonlocal_getDiffusion + contains @@ -208,6 +222,9 @@ subroutine homogenization_init() print'(/,a)', ' <<<+- homogenization init -+>>>'; flush(IO_STDOUT) + call material_parseHomogenization + print*, 'Homogenization parsed' + num_homog => config_numerics%get('homogenization',defaultVal=emptyDict) num_homogGeneric => num_homog%get('generic',defaultVal=emptyDict) @@ -437,4 +454,66 @@ subroutine homogenization_restartRead(fileHandle) end subroutine homogenization_restartRead + +!-------------------------------------------------------------------------------------------------- +!> @brief module initialization +!> @details reads in material parameters, allocates arrays, and does sanity checks +!-------------------------------------------------------------------------------------------------- +subroutine damage_nonlocal_init + + integer :: Ninstances,Nmaterialpoints,h + class(tNode), pointer :: & + num_generic, & + material_homogenization + + print'(/,a)', ' <<<+- damage_nonlocal init -+>>>'; flush(6) + +!------------------------------------------------------------------------------------ +! read numerics parameter + num_generic => config_numerics%get('generic',defaultVal= emptyDict) + num_damage%charLength = num_generic%get_asFloat('charLength',defaultVal=1.0_pReal) + + Ninstances = count(damage_type == DAMAGE_nonlocal_ID) + + material_homogenization => config_material%get('homogenization') + do h = 1, material_homogenization%length + if (damage_type(h) /= DAMAGE_NONLOCAL_ID) cycle + + Nmaterialpoints = count(material_homogenizationAt == h) + damageState_h(h)%sizeState = 1 + allocate(damageState_h(h)%state0 (1,Nmaterialpoints), source=1.0_pReal) + allocate(damageState_h(h)%state (1,Nmaterialpoints), source=1.0_pReal) + + enddo + +end subroutine damage_nonlocal_init + + +!-------------------------------------------------------------------------------------------------- +!> @brief returns homogenized non local damage diffusion tensor in reference configuration +!-------------------------------------------------------------------------------------------------- +function damage_nonlocal_getDiffusion(ip,el) + + integer, intent(in) :: & + ip, & !< integration point number + el !< element number + real(pReal), dimension(3,3) :: & + damage_nonlocal_getDiffusion + integer :: & + homog, & + grain + + homog = material_homogenizationAt(el) + damage_nonlocal_getDiffusion = 0.0_pReal + do grain = 1, homogenization_Nconstituents(homog) + damage_nonlocal_getDiffusion = damage_nonlocal_getDiffusion + & + crystallite_push33ToRef(grain,ip,el,lattice_D(1:3,1:3,material_phaseAt(grain,el))) + enddo + + damage_nonlocal_getDiffusion = & + num_damage%charLength**2*damage_nonlocal_getDiffusion/real(homogenization_Nconstituents(homog),pReal) + +end function damage_nonlocal_getDiffusion + + end module homogenization diff --git a/src/material.f90 b/src/material.f90 index b76b2b296..1c8292e5f 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -78,7 +78,8 @@ module material DAMAGE_NONLOCAL_ID, & HOMOGENIZATION_NONE_ID, & HOMOGENIZATION_ISOSTRAIN_ID, & - HOMOGENIZATION_RGC_ID + HOMOGENIZATION_RGC_ID, & + material_parseHomogenization contains @@ -95,10 +96,6 @@ subroutine material_init(restart) call material_parseMaterial print*, 'Material parsed' - call material_parseHomogenization - print*, 'Homogenization parsed' - - allocate(homogState (size(material_name_homogenization))) allocate(damageState_h (size(material_name_homogenization))) From 4eb2a981cab505e3a53be2a907d9e7d4aa3bf204 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 12 Feb 2021 15:31:43 +0100 Subject: [PATCH 221/352] keeping variables local --- src/commercialFEM_fileList.f90 | 1 - src/damage_nonlocal.f90 | 23 ------ src/grid/grid_damage_spectral.f90 | 1 - src/homogenization.f90 | 116 +++++++++++++++++++++++++++- src/homogenization_mechanical.f90 | 4 +- src/material.f90 | 123 ++---------------------------- 6 files changed, 120 insertions(+), 148 deletions(-) delete mode 100644 src/damage_nonlocal.f90 diff --git a/src/commercialFEM_fileList.f90 b/src/commercialFEM_fileList.f90 index cf48e19ce..97e7520f9 100644 --- a/src/commercialFEM_fileList.f90 +++ b/src/commercialFEM_fileList.f90 @@ -41,7 +41,6 @@ #include "phase_damage_isoductile.f90" #include "phase_damage_anisobrittle.f90" #include "phase_damage_anisoductile.f90" -#include "damage_nonlocal.f90" #include "homogenization.f90" #include "homogenization_mechanical.f90" #include "homogenization_mechanical_pass.f90" diff --git a/src/damage_nonlocal.f90 b/src/damage_nonlocal.f90 deleted file mode 100644 index fab08d500..000000000 --- a/src/damage_nonlocal.f90 +++ /dev/null @@ -1,23 +0,0 @@ -!-------------------------------------------------------------------------------------------------- -!> @author Pratheek Shanthraj, Max-Planck-Institut für Eisenforschung GmbH -!> @brief material subroutine for non-locally evolving damage field -!-------------------------------------------------------------------------------------------------- -module damage_nonlocal - use prec - use material - use config - use YAML_types - use lattice - use phase - use results - - implicit none - private - - - -contains - - - -end module damage_nonlocal diff --git a/src/grid/grid_damage_spectral.f90 b/src/grid/grid_damage_spectral.f90 index dc78d9e44..afbae027f 100644 --- a/src/grid/grid_damage_spectral.f90 +++ b/src/grid/grid_damage_spectral.f90 @@ -15,7 +15,6 @@ module grid_damage_spectral use IO use spectral_utilities use discretization_grid - use damage_nonlocal use YAML_types use homogenization use config diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 36c03a314..073482c9a 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -12,7 +12,6 @@ module homogenization use material use phase use discretization - use damage_nonlocal use HDF5_utilities use results use lattice @@ -20,6 +19,37 @@ module homogenization implicit none private + + enum, bind(c); enumerator :: & + THERMAL_ISOTHERMAL_ID, & + THERMAL_CONDUCTION_ID, & + DAMAGE_NONE_ID, & + DAMAGE_NONLOCAL_ID, & + HOMOGENIZATION_UNDEFINED_ID, & + HOMOGENIZATION_NONE_ID, & + HOMOGENIZATION_ISOSTRAIN_ID, & + HOMOGENIZATION_RGC_ID + end enum + + type(tState), allocatable, dimension(:), public :: & + homogState, & + damageState_h + + integer, dimension(:), allocatable, public, protected :: & + homogenization_typeInstance, & !< instance of particular type of each homogenization + thermal_typeInstance, & !< instance of particular type of each thermal transport + damage_typeInstance !< instance of particular type of each nonlocal damage + + real(pReal), dimension(:), allocatable, public, protected :: & + thermal_initialT + + integer(kind(THERMAL_isothermal_ID)), dimension(:), allocatable, public, protected :: & + thermal_type !< thermal transport model + integer(kind(DAMAGE_none_ID)), dimension(:), allocatable, public, protected :: & + damage_type !< nonlocal damage model + integer(kind(HOMOGENIZATION_undefined_ID)), dimension(:), allocatable, public, protected :: & + homogenization_type !< type of each homogenization + type, private :: tNumerics_damage real(pReal) :: & charLength !< characteristic length scale for gradient problems @@ -202,7 +232,9 @@ module homogenization homogenization_forward, & homogenization_results, & homogenization_restartRead, & - homogenization_restartWrite + homogenization_restartWrite, & + THERMAL_CONDUCTION_ID, & + DAMAGE_NONLOCAL_ID public :: & damage_nonlocal_init, & @@ -222,6 +254,9 @@ subroutine homogenization_init() print'(/,a)', ' <<<+- homogenization init -+>>>'; flush(IO_STDOUT) + + allocate(homogState (size(material_name_homogenization))) + allocate(damageState_h (size(material_name_homogenization))) call material_parseHomogenization print*, 'Homogenization parsed' @@ -516,4 +551,81 @@ function damage_nonlocal_getDiffusion(ip,el) end function damage_nonlocal_getDiffusion +!-------------------------------------------------------------------------------------------------- +!> @brief parses the homogenization part from the material configuration +! ToDo: This should be done in homogenization +!-------------------------------------------------------------------------------------------------- +subroutine material_parseHomogenization + + class(tNode), pointer :: & + material_homogenization, & + homog, & + homogMech, & + homogThermal, & + homogDamage + + integer :: h + + material_homogenization => config_material%get('homogenization') + + allocate(homogenization_type(size(material_name_homogenization)), source=HOMOGENIZATION_undefined_ID) + allocate(thermal_type(size(material_name_homogenization)), source=THERMAL_isothermal_ID) + allocate(damage_type (size(material_name_homogenization)), source=DAMAGE_none_ID) + allocate(homogenization_typeInstance(size(material_name_homogenization)), source=0) + allocate(thermal_typeInstance(size(material_name_homogenization)), source=0) + allocate(damage_typeInstance(size(material_name_homogenization)), source=0) + allocate(thermal_initialT(size(material_name_homogenization)), source=300.0_pReal) + + do h=1, size(material_name_homogenization) + homog => material_homogenization%get(h) + homogMech => homog%get('mechanics') + select case (homogMech%get_asString('type')) + case('pass') + homogenization_type(h) = HOMOGENIZATION_NONE_ID + case('isostrain') + homogenization_type(h) = HOMOGENIZATION_ISOSTRAIN_ID + case('RGC') + homogenization_type(h) = HOMOGENIZATION_RGC_ID + case default + call IO_error(500,ext_msg=homogMech%get_asString('type')) + end select + + homogenization_typeInstance(h) = count(homogenization_type==homogenization_type(h)) + + if(homog%contains('thermal')) then + homogThermal => homog%get('thermal') + thermal_initialT(h) = homogThermal%get_asFloat('T_0',defaultVal=300.0_pReal) + + select case (homogThermal%get_asString('type')) + case('isothermal') + thermal_type(h) = THERMAL_isothermal_ID + case('conduction') + thermal_type(h) = THERMAL_conduction_ID + case default + call IO_error(500,ext_msg=homogThermal%get_asString('type')) + end select + endif + + if(homog%contains('damage')) then + homogDamage => homog%get('damage') + select case (homogDamage%get_asString('type')) + case('none') + damage_type(h) = DAMAGE_none_ID + case('nonlocal') + damage_type(h) = DAMAGE_nonlocal_ID + case default + call IO_error(500,ext_msg=homogDamage%get_asString('type')) + end select + endif + enddo + + do h=1, size(material_name_homogenization) + homogenization_typeInstance(h) = count(homogenization_type(1:h) == homogenization_type(h)) + thermal_typeInstance(h) = count(thermal_type (1:h) == thermal_type (h)) + damage_typeInstance(h) = count(damage_type (1:h) == damage_type (h)) + enddo + +end subroutine material_parseHomogenization + + end module homogenization diff --git a/src/homogenization_mechanical.f90 b/src/homogenization_mechanical.f90 index 91e1d3d84..c05b576da 100644 --- a/src/homogenization_mechanical.f90 +++ b/src/homogenization_mechanical.f90 @@ -225,8 +225,6 @@ end function mechanical_updateState !> @brief Write results to file. !-------------------------------------------------------------------------------------------------- module subroutine mechanical_results(group_base,h) - use material, only: & - material_homogenization_type => homogenization_type character(len=*), intent(in) :: group_base integer, intent(in) :: h @@ -236,7 +234,7 @@ module subroutine mechanical_results(group_base,h) group = trim(group_base)//'/mech' call results_closeGroup(results_addGroup(group)) - select case(material_homogenization_type(h)) + select case(homogenization_type(h)) case(HOMOGENIZATION_rgc_ID) call mechanical_RGC_results(homogenization_typeInstance(h),group) diff --git a/src/material.f90 b/src/material.f90 index 1c8292e5f..df6dc6dd1 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -6,50 +6,26 @@ !-------------------------------------------------------------------------------------------------- module material use prec - use math use config use results use IO use rotations use discretization + use YAML_types implicit none private - enum, bind(c); enumerator :: & - THERMAL_ISOTHERMAL_ID, & - THERMAL_CONDUCTION_ID, & - DAMAGE_NONE_ID, & - DAMAGE_NONLOCAL_ID, & - HOMOGENIZATION_UNDEFINED_ID, & - HOMOGENIZATION_NONE_ID, & - HOMOGENIZATION_ISOSTRAIN_ID, & - HOMOGENIZATION_RGC_ID - end enum + integer, dimension(:), allocatable, public, protected :: & + homogenization_Nconstituents !< number of grains in each homogenization character(len=:), public, protected, allocatable, dimension(:) :: & material_name_phase, & !< name of each phase material_name_homogenization !< name of each homogenization - integer(kind(THERMAL_isothermal_ID)), dimension(:), allocatable, public, protected :: & - thermal_type !< thermal transport model - integer(kind(DAMAGE_none_ID)), dimension(:), allocatable, public, protected :: & - damage_type !< nonlocal damage model - integer(kind(HOMOGENIZATION_undefined_ID)), dimension(:), allocatable, public, protected :: & - homogenization_type !< type of each homogenization - integer, public, protected :: & homogenization_maxNconstituents !< max number of grains in any USED homogenization - integer, dimension(:), allocatable, public, protected :: & - homogenization_Nconstituents, & !< number of grains in each homogenization - homogenization_typeInstance, & !< instance of particular type of each homogenization - thermal_typeInstance, & !< instance of particular type of each thermal transport - damage_typeInstance !< instance of particular type of each nonlocal damage - - real(pReal), dimension(:), allocatable, public, protected :: & - thermal_initialT !< initial temperature per each homogenization - integer, dimension(:), allocatable, public, protected :: & ! (elem) material_homogenizationAt, & !< homogenization ID of each element material_homogenizationAt2, & !< per cell @@ -63,23 +39,11 @@ module material integer, dimension(:,:,:), allocatable, public, protected :: & ! (constituent,IP,elem) material_phaseMemberAt !< position of the element within its phase instance - type(tState), allocatable, dimension(:), public :: & - homogState, & - damageState_h - type(Rotation), dimension(:,:,:), allocatable, public, protected :: & material_orientation0 !< initial orientation of each grain,IP,element public :: & - material_init, & - THERMAL_ISOTHERMAL_ID, & - THERMAL_CONDUCTION_ID, & - DAMAGE_NONE_ID, & - DAMAGE_NONLOCAL_ID, & - HOMOGENIZATION_NONE_ID, & - HOMOGENIZATION_ISOSTRAIN_ID, & - HOMOGENIZATION_RGC_ID, & - material_parseHomogenization + material_init contains @@ -90,14 +54,13 @@ subroutine material_init(restart) logical, intent(in) :: restart + print'(/,a)', ' <<<+- material init -+>>>'; flush(IO_STDOUT) call material_parseMaterial print*, 'Material parsed' - allocate(homogState (size(material_name_homogenization))) - allocate(damageState_h (size(material_name_homogenization))) if (.not. restart) then call results_openJobFile @@ -109,82 +72,6 @@ subroutine material_init(restart) end subroutine material_init -!-------------------------------------------------------------------------------------------------- -!> @brief parses the homogenization part from the material configuration -! ToDo: This should be done in homogenization -!-------------------------------------------------------------------------------------------------- -subroutine material_parseHomogenization - - class(tNode), pointer :: & - material_homogenization, & - homog, & - homogMech, & - homogThermal, & - homogDamage - - integer :: h - - material_homogenization => config_material%get('homogenization') - - allocate(homogenization_type(size(material_name_homogenization)), source=HOMOGENIZATION_undefined_ID) - allocate(thermal_type(size(material_name_homogenization)), source=THERMAL_isothermal_ID) - allocate(damage_type (size(material_name_homogenization)), source=DAMAGE_none_ID) - allocate(homogenization_typeInstance(size(material_name_homogenization)), source=0) - allocate(thermal_typeInstance(size(material_name_homogenization)), source=0) - allocate(damage_typeInstance(size(material_name_homogenization)), source=0) - allocate(thermal_initialT(size(material_name_homogenization)), source=300.0_pReal) - - do h=1, size(material_name_homogenization) - homog => material_homogenization%get(h) - homogMech => homog%get('mechanics') - select case (homogMech%get_asString('type')) - case('pass') - homogenization_type(h) = HOMOGENIZATION_NONE_ID - case('isostrain') - homogenization_type(h) = HOMOGENIZATION_ISOSTRAIN_ID - case('RGC') - homogenization_type(h) = HOMOGENIZATION_RGC_ID - case default - call IO_error(500,ext_msg=homogMech%get_asString('type')) - end select - - homogenization_typeInstance(h) = count(homogenization_type==homogenization_type(h)) - - if(homog%contains('thermal')) then - homogThermal => homog%get('thermal') - thermal_initialT(h) = homogThermal%get_asFloat('T_0',defaultVal=300.0_pReal) - - select case (homogThermal%get_asString('type')) - case('isothermal') - thermal_type(h) = THERMAL_isothermal_ID - case('conduction') - thermal_type(h) = THERMAL_conduction_ID - case default - call IO_error(500,ext_msg=homogThermal%get_asString('type')) - end select - endif - - if(homog%contains('damage')) then - homogDamage => homog%get('damage') - select case (homogDamage%get_asString('type')) - case('none') - damage_type(h) = DAMAGE_none_ID - case('nonlocal') - damage_type(h) = DAMAGE_nonlocal_ID - case default - call IO_error(500,ext_msg=homogDamage%get_asString('type')) - end select - endif - enddo - - do h=1, size(material_name_homogenization) - homogenization_typeInstance(h) = count(homogenization_type(1:h) == homogenization_type(h)) - thermal_typeInstance(h) = count(thermal_type (1:h) == thermal_type (h)) - damage_typeInstance(h) = count(damage_type (1:h) == damage_type (h)) - enddo - -end subroutine material_parseHomogenization - !-------------------------------------------------------------------------------------------------- !> @brief parses the material part in the material configuration file From fe63adcca4cbcb2e1c207a3e9e093f0762bae3bb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 12 Feb 2021 17:04:35 +0100 Subject: [PATCH 222/352] mimic python error message and ensure that error is raised --- python/damask/_orientation.py | 49 +++++++++++++++++--------------- python/tests/test_Orientation.py | 17 ++++++++++- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 47334d555..f01156903 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -268,30 +268,33 @@ class Orientation(Rotation): def _separate_arguments(parent_dict,function): """ Separate arguments required by Rotation and Orientation objects respectively. - + Parameters ---------- parent_dict : Dictionary Contains all **kwargs function: Method Function whose signature list is required - + Returns ------- ori_dict: dictionary Dictionary consisting of valid keys accepted by Orientation class rot_dict: dictionary Dictionary consisting of valid keys accepted by 'function' in Rotation class - + """ set_ori = set(inspect.signature(Orientation.__init__).parameters.keys()) & set(parent_dict.keys()) set_rot = set(inspect.signature(function).parameters.keys()) & set(parent_dict.keys()) ori_dict = {key: parent_dict[key] for key in set_ori} rot_dict = {key: parent_dict[key] for key in set_rot} - if(set(parent_dict.keys())-(set_ori|set_rot)): - raise KeyError(f'Unknown key {set(parent_dict.keys())-(set_ori|set_rot)} present') + + invalid_keys = set(parent_dict.keys())-(set_ori|set_rot) + if invalid_keys: + raise TypeError(f"{inspect.stack()[1][3]}() got an unexpected keyword argument '{invalid_keys.pop()}'") + return rot_dict,ori_dict - + @classmethod @util.extended_docstring(Rotation.from_random,_parameter_doc) @@ -312,63 +315,63 @@ class Orientation(Rotation): def from_Euler_angles(cls,**kwargs): kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_Euler_angles) return cls(rotation=Rotation.from_Euler_angles(**kwargs_rot),**kwargs_ori) - - + + @classmethod @util.extended_docstring(Rotation.from_axis_angle,_parameter_doc) def from_axis_angle(cls,**kwargs): kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_axis_angle) return cls(rotation=Rotation.from_axis_angle(**kwargs_rot),**kwargs_ori) - - + + @classmethod @util.extended_docstring(Rotation.from_basis,_parameter_doc) def from_basis(cls,**kwargs): kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_basis) return cls(rotation=Rotation.from_basis(**kwargs_rot),**kwargs_ori) - - + + @classmethod @util.extended_docstring(Rotation.from_matrix,_parameter_doc) def from_matrix(cls,**kwargs): kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_matrix) return cls(rotation=Rotation.from_matrix(**kwargs_rot),**kwargs_ori) - - + + @classmethod @util.extended_docstring(Rotation.from_Rodrigues_vector,_parameter_doc) def from_Rodrigues_vector(cls,**kwargs): kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_Rodrigues_vector) return cls(rotation=Rotation.from_Rodrigues_vector(**kwargs_rot),**kwargs_ori) - - + + @classmethod @util.extended_docstring(Rotation.from_homochoric,_parameter_doc) def from_homochoric(cls,**kwargs): kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_homochoric) return cls(rotation=Rotation.from_homochoric(**kwargs_rot),**kwargs_ori) - - + + @classmethod @util.extended_docstring(Rotation.from_cubochoric,_parameter_doc) def from_cubochoric(cls,**kwargs): kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_cubochoric) return cls(rotation=Rotation.from_cubochoric(**kwargs_rot),**kwargs_ori) - - + + @classmethod @util.extended_docstring(Rotation.from_spherical_component,_parameter_doc) def from_spherical_component(cls,**kwargs): kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_spherical_component) return cls(rotation=Rotation.from_spherical_component(**kwargs_rot),**kwargs_ori) - - + + @classmethod @util.extended_docstring(Rotation.from_fiber_component,_parameter_doc) def from_fiber_component(cls,**kwargs): kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_fiber_component) return cls(rotation=Rotation.from_fiber_component(**kwargs_rot),**kwargs_ori) - + @classmethod @util.extend_docstring(_parameter_doc) diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 92c3f63ab..e4174f795 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -141,7 +141,7 @@ class TestOrientation: dict(lattice='hP',a=1.0 ), dict(lattice='cI',a=1.0, ), ]) - def test_from_direction(self,kwargs): + def test_from_directions(self,kwargs): for a,b in np.random.random((10,2,3)): c = np.cross(b,a) if np.all(np.isclose(c,0)): continue @@ -151,6 +151,21 @@ class TestOrientation: assert np.isclose(np.dot(x/np.linalg.norm(x),np.array([1,0,0])),1) \ and np.isclose(np.dot(z/np.linalg.norm(z),np.array([0,0,1])),1) + @pytest.mark.parametrize('function',[Orientation.from_random, + Orientation.from_quaternion, + Orientation.from_Euler_angles, + Orientation.from_axis_angle, + Orientation.from_basis, + Orientation.from_matrix, + Orientation.from_Rodrigues_vector, + Orientation.from_homochoric, + Orientation.from_cubochoric, + Orientation.from_spherical_component, + Orientation.from_fiber_component, + Orientation.from_directions]) + def test_invalid_from(self,function): + with pytest.raises(TypeError): + function(c=.1,degrees=True,invalid=66) def test_negative_angle(self): with pytest.raises(ValueError): From 26768375781c781db96ab3e0c1f425becf835411 Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 12 Feb 2021 22:30:53 +0100 Subject: [PATCH 223/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-428-gb7b764ab5 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a1f129287..ce989b710 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-421-ge96352b0e +v3.0.0-alpha2-428-gb7b764ab5 From 830d00fa675b960c6d5225638c48585915e2c04b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 12 Feb 2021 22:41:35 +0100 Subject: [PATCH 224/352] simplified structure choice of damage model triggers eigendeformation, no repeated variables This implementation is the most ugly hack I could imagine. I just serves the purpose of having a stable material.yaml --- PRIVATE | 2 +- src/phase_damage.f90 | 4 +- src/phase_damage_anisobrittle.f90 | 4 +- src/phase_damage_isobrittle.f90 | 4 +- src/phase_damage_isoductile.f90 | 4 +- src/phase_mechanical_eigen.f90 | 44 ++++++++++++++++++- ...phase_mechanical_eigen_cleavageopening.f90 | 4 +- ...hase_mechanical_eigen_slipplaneopening.f90 | 4 +- 8 files changed, 55 insertions(+), 15 deletions(-) diff --git a/PRIVATE b/PRIVATE index e74cf0062..07d125fe4 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit e74cf00628285a587ced1e551cc9837c1011ca1c +Subproject commit 07d125fe476621224d9f2ef73b0cf88f3b07bc60 diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 57145c550..6063f3583 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -175,7 +175,7 @@ module subroutine damage_init allocate(current(ph)%d_phi_d_dot_phi(Nconstituents),source=0.0_pReal) phase => phases%get(ph) - sources => phase%get('source',defaultVal=emptyList) + sources => phase%get('damage',defaultVal=emptyList) phase_Nsources(ph) = sources%length allocate(damageState(ph)%p(phase_Nsources(ph))) enddo @@ -493,7 +493,7 @@ function source_active(source_label,src_length) result(active_source) allocate(active_source(src_length,phases%length), source = .false. ) do p = 1, phases%length phase => phases%get(p) - sources => phase%get('source',defaultVal=emptyList) + sources => phase%get('damage',defaultVal=emptyList) do s = 1, sources%length src => sources%get(s) if(src%get_asString('type') == source_label) active_source(s,p) = .true. diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 699e9508b..ad7f80604 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -51,7 +51,7 @@ module function anisobrittle_init(source_length) result(mySources) print'(/,a)', ' <<<+- phase:damage:anisobrittle init -+>>>' - mySources = source_active('damage_anisoBrittle',source_length) + mySources = source_active('anisobrittle',source_length) Ninstances = count(mySources) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -65,7 +65,7 @@ module function anisobrittle_init(source_length) result(mySources) phase => phases%get(p) if(any(mySources(:,p))) source_damage_anisoBrittle_instance(p) = count(mySources(:,1:p)) if(count(mySources(:,p)) == 0) cycle - sources => phase%get('source') + sources => phase%get('damage') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then source_damage_anisoBrittle_offset(p) = sourceOffset diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 529ecd404..a2ae7dfb7 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -41,7 +41,7 @@ module function isobrittle_init(source_length) result(mySources) print'(/,a)', ' <<<+- phase:damage:isobrittle init -+>>>' - mySources = source_active('damage_isoBrittle',source_length) + mySources = source_active('isobrittle',source_length) Ninstances = count(mySources) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -55,7 +55,7 @@ module function isobrittle_init(source_length) result(mySources) phase => phases%get(p) if(any(mySources(:,p))) source_damage_isoBrittle_instance(p) = count(mySources(:,1:p)) if(count(mySources(:,p)) == 0) cycle - sources => phase%get('source') + sources => phase%get('damage') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then source_damage_isoBrittle_offset(p) = sourceOffset diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index e9aec1944..f378b7ad2 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -43,7 +43,7 @@ module function isoductile_init(source_length) result(mySources) print'(/,a)', ' <<<+- phase:damage:isoductile init -+>>>' - mySources = source_active('damage_isoDuctile',source_length) + mySources = source_active('isoductile',source_length) Ninstances = count(mySources) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -57,7 +57,7 @@ module function isoductile_init(source_length) result(mySources) phase => phases%get(p) if(count(mySources(:,p)) == 0) cycle if(any(mySources(:,p))) source_damage_isoDuctile_instance(p) = count(mySources(:,1:p)) - sources => phase%get('source') + sources => phase%get('damage') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then source_damage_isoDuctile_offset(p) = sourceOffset diff --git a/src/phase_mechanical_eigen.f90 b/src/phase_mechanical_eigen.f90 index 6df993565..3fb2d1bf2 100644 --- a/src/phase_mechanical_eigen.f90 +++ b/src/phase_mechanical_eigen.f90 @@ -66,7 +66,8 @@ module subroutine eigendeformation_init(phases) ph class(tNode), pointer :: & phase, & - kinematics + kinematics, & + damage print'(/,a)', ' <<<+- phase:mechanics:eigendeformation init -+>>>' @@ -77,6 +78,12 @@ module subroutine eigendeformation_init(phases) phase => phases%get(ph) kinematics => phase%get('kinematics',defaultVal=emptyList) phase_Nkinematics(ph) = kinematics%length + kinematics => phase%get('damage',defaultVal=emptyList) + if(kinematics%length >0) then + damage => kinematics%get(1) + if(damage%get_asString('type') == 'anisobrittle') phase_Nkinematics(ph) = phase_Nkinematics(ph) +1 + if(damage%get_asString('type') == 'isoductile') phase_Nkinematics(ph) = phase_Nkinematics(ph) +1 + endif enddo allocate(phase_kinematics(maxval(phase_Nkinematics),phases%length), source = KINEMATICS_undefined_ID) @@ -90,7 +97,6 @@ module subroutine eigendeformation_init(phases) end subroutine eigendeformation_init - !-------------------------------------------------------------------------------------------------- !> @brief checks if a kinematic mechanism is active or not !-------------------------------------------------------------------------------------------------- @@ -122,6 +128,38 @@ function kinematics_active(kinematics_label,kinematics_length) result(active_ki end function kinematics_active + +!-------------------------------------------------------------------------------------------------- +!> @brief checks if a kinematic mechanism is active or not +!-------------------------------------------------------------------------------------------------- +function kinematics_active2(kinematics_label,kinematics_length) result(active_kinematics) + + character(len=*), intent(in) :: kinematics_label !< name of kinematic mechanism + integer, intent(in) :: kinematics_length !< max. number of kinematics in system + logical, dimension(:,:), allocatable :: active_kinematics + + class(tNode), pointer :: & + phases, & + phase, & + kinematics, & + kinematics_type + integer :: p,k + + phases => config_material%get('phase') + allocate(active_kinematics(kinematics_length,phases%length), source = .false. ) + do p = 1, phases%length + phase => phases%get(p) + kinematics => phase%get('damage',defaultVal=emptyList) + do k = 1, kinematics%length + kinematics_type => kinematics%get(k) + if(kinematics_type%get_asString('type') == kinematics_label) active_kinematics(k,p) = .true. + enddo + enddo + + +end function kinematics_active2 + + !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the velocity gradient ! ToDo: MD: S is Mi? @@ -175,8 +213,10 @@ module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & KinematicsLoop: do k = 1, phase_Nkinematics(material_phaseAt(co,el)) kinematicsType: select case (phase_kinematics(k,material_phaseAt(co,el))) case (KINEMATICS_cleavage_opening_ID) kinematicsType + print*, 'clea' call kinematics_cleavage_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) case (KINEMATICS_slipplane_opening_ID) kinematicsType + print*, 'slipp' call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) case (KINEMATICS_thermal_expansion_ID) kinematicsType me = material_phaseMemberAt(co,ip,el) diff --git a/src/phase_mechanical_eigen_cleavageopening.f90 b/src/phase_mechanical_eigen_cleavageopening.f90 index 55102e196..f1774c78e 100644 --- a/src/phase_mechanical_eigen_cleavageopening.f90 +++ b/src/phase_mechanical_eigen_cleavageopening.f90 @@ -46,7 +46,7 @@ module function kinematics_cleavage_opening_init(kinematics_length) result(myKin print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:cleavageopening init -+>>>' - myKinematics = kinematics_active('cleavage_opening',kinematics_length) + myKinematics = kinematics_active2('anisobrittle',kinematics_length) Ninstances = count(myKinematics) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -59,7 +59,7 @@ module function kinematics_cleavage_opening_init(kinematics_length) result(myKin if(any(myKinematics(:,p))) kinematics_cleavage_opening_instance(p) = count(myKinematics(:,1:p)) phase => phases%get(p) if(count(myKinematics(:,p)) == 0) cycle - kinematics => phase%get('kinematics') + kinematics => phase%get('damage') do k = 1, kinematics%length if(myKinematics(k,p)) then associate(prm => param(kinematics_cleavage_opening_instance(p))) diff --git a/src/phase_mechanical_eigen_slipplaneopening.f90 b/src/phase_mechanical_eigen_slipplaneopening.f90 index cf5e918b3..dd5f172d9 100644 --- a/src/phase_mechanical_eigen_slipplaneopening.f90 +++ b/src/phase_mechanical_eigen_slipplaneopening.f90 @@ -51,7 +51,7 @@ module function kinematics_slipplane_opening_init(kinematics_length) result(myKi print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:slipplaneopening init -+>>>' - myKinematics = kinematics_active('slipplane_opening',kinematics_length) + myKinematics = kinematics_active2('isoductile',kinematics_length) Ninstances = count(myKinematics) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -66,7 +66,7 @@ module function kinematics_slipplane_opening_init(kinematics_length) result(myKi mech => phase%get('mechanics') pl => mech%get('plasticity') if(count(myKinematics(:,p)) == 0) cycle - kinematics => phase%get('kinematics') + kinematics => phase%get('damage') do k = 1, kinematics%length if(myKinematics(k,p)) then associate(prm => param(kinematics_slipplane_opening_instance(p))) From 2b0b1aeffe0c18e0350ebcf2e9039cae98151724 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 12 Feb 2021 23:35:06 +0100 Subject: [PATCH 225/352] jobname.yaml not supported anymore --- PRIVATE | 2 +- src/config.f90 | 23 +++++++---------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/PRIVATE b/PRIVATE index 07d125fe4..2a0f30ec4 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 07d125fe476621224d9f2ef73b0cf88f3b07bc60 +Subproject commit 2a0f30ec47473f42e0da922055b72b527730378d diff --git a/src/config.f90 b/src/config.f90 index b10edf013..02b16f2a2 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -5,16 +5,10 @@ !! precedence over material.yaml. !-------------------------------------------------------------------------------------------------- module config - use prec - use DAMASK_interface use IO use YAML_parse use YAML_types -#ifdef PETSc -#include - use petscsys -#endif implicit none private @@ -50,17 +44,12 @@ end subroutine config_init subroutine parse_material logical :: fileExists - character(len=:), allocatable :: fname - fname = getSolverJobName()//'.yaml' - inquire(file=fname,exist=fileExists) - if(.not. fileExists) then - fname = 'material.yaml' - inquire(file=fname,exist=fileExists) - if(.not. fileExists) call IO_error(100,ext_msg=fname) - endif - print*, 'reading '//fname; flush(IO_STDOUT) - config_material => YAML_parse_file(fname) + + inquire(file='material.yaml',exist=fileExists) + if(.not. fileExists) call IO_error(100,ext_msg='material.yaml') + print*, 'reading material.yaml'; flush(IO_STDOUT) + config_material => YAML_parse_file('material.yaml') end subroutine parse_material @@ -72,6 +61,7 @@ subroutine parse_numerics logical :: fexist + config_numerics => emptyDict inquire(file='numerics.yaml', exist=fexist) if (fexist) then @@ -89,6 +79,7 @@ subroutine parse_debug logical :: fexist + config_debug => emptyDict inquire(file='debug.yaml', exist=fexist) fileExists: if (fexist) then From c790c82a427de2a024e935af18488ee9dcc6c85d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 06:59:18 +0100 Subject: [PATCH 226/352] separating by instance just complicates things --- src/material.f90 | 2 +- src/phase_mechanical_eigen_cleavageopening.f90 | 15 ++++----------- src/phase_mechanical_eigen_slipplaneopening.f90 | 14 +++----------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/material.f90 b/src/material.f90 index df6dc6dd1..3656f0f0a 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -48,7 +48,7 @@ module material contains !-------------------------------------------------------------------------------------------------- -!> @brief parses material configuration file +!> @brief Parse material configuration file (material.yaml). !-------------------------------------------------------------------------------------------------- subroutine material_init(restart) diff --git a/src/phase_mechanical_eigen_cleavageopening.f90 b/src/phase_mechanical_eigen_cleavageopening.f90 index f1774c78e..8878c10bd 100644 --- a/src/phase_mechanical_eigen_cleavageopening.f90 +++ b/src/phase_mechanical_eigen_cleavageopening.f90 @@ -6,8 +6,6 @@ !-------------------------------------------------------------------------------------------------- submodule(phase:eigendeformation) cleavageopening - integer, dimension(:), allocatable :: kinematics_cleavage_opening_instance - type :: tParameters !< container type for internal constitutive parameters integer :: & sum_N_cl !< total number of cleavage planes @@ -20,7 +18,7 @@ submodule(phase:eigendeformation) cleavageopening cleavage_systems end type tParameters - type(tParameters), dimension(:), allocatable :: param !< containers of constitutive parameters (len Ninstances) + type(tParameters), dimension(:), allocatable :: param !< containers of constitutive parameters contains @@ -52,17 +50,15 @@ module function kinematics_cleavage_opening_init(kinematics_length) result(myKin if(Ninstances == 0) return phases => config_material%get('phase') - allocate(param(Ninstances)) - allocate(kinematics_cleavage_opening_instance(phases%length), source=0) + allocate(param(phases%length)) do p = 1, phases%length - if(any(myKinematics(:,p))) kinematics_cleavage_opening_instance(p) = count(myKinematics(:,1:p)) phase => phases%get(p) if(count(myKinematics(:,p)) == 0) cycle kinematics => phase%get('damage') do k = 1, kinematics%length if(myKinematics(k,p)) then - associate(prm => param(kinematics_cleavage_opening_instance(p))) + associate(prm => param(p)) kinematic_type => kinematics%get(k) N_cl = kinematic_type%get_asInts('N_cl') @@ -113,18 +109,15 @@ module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) integer :: & - homog, damageOffset, & i, k, l, m, n real(pReal) :: & traction_d, traction_t, traction_n, traction_crit, & udotd, dudotd_dt, udott, dudott_dt, udotn, dudotn_dt - homog = material_homogenizationAt(el) - damageOffset = material_homogenizationMemberAt(ip,el) Ld = 0.0_pReal dLd_dTstar = 0.0_pReal - associate(prm => param(kinematics_cleavage_opening_instance(material_phaseAt(co,el)))) + associate(prm => param(material_phaseAt(co,el))) do i = 1,prm%sum_N_cl traction_crit = prm%g_crit(i)*phase_damage_get_phi(co,ip,el)**2.0_pReal diff --git a/src/phase_mechanical_eigen_slipplaneopening.f90 b/src/phase_mechanical_eigen_slipplaneopening.f90 index dd5f172d9..e8410a935 100644 --- a/src/phase_mechanical_eigen_slipplaneopening.f90 +++ b/src/phase_mechanical_eigen_slipplaneopening.f90 @@ -57,11 +57,9 @@ module function kinematics_slipplane_opening_init(kinematics_length) result(myKi if(Ninstances == 0) return phases => config_material%get('phase') - allocate(kinematics_slipplane_opening_instance(phases%length), source=0) - allocate(param(Ninstances)) + allocate(param(phases%length)) do p = 1, phases%length - if(any(myKinematics(:,p))) kinematics_slipplane_opening_instance(p) = count(myKinematics(:,1:p)) phase => phases%get(p) mech => phase%get('mechanics') pl => mech%get('plasticity') @@ -69,7 +67,7 @@ module function kinematics_slipplane_opening_init(kinematics_length) result(myKi kinematics => phase%get('damage') do k = 1, kinematics%length if(myKinematics(k,p)) then - associate(prm => param(kinematics_slipplane_opening_instance(p))) + associate(prm => param(p)) kinematic_type => kinematics%get(k) prm%dot_o = kinematic_type%get_asFloat('dot_o') @@ -131,19 +129,13 @@ module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) integer :: & - instance, phase, & - homog, damageOffset, & i, k, l, m, n real(pReal) :: & traction_d, traction_t, traction_n, traction_crit, & udotd, dudotd_dt, udott, dudott_dt, udotn, dudotn_dt - phase = material_phaseAt(co,el) - instance = kinematics_slipplane_opening_instance(phase) - homog = material_homogenizationAt(el) - damageOffset = material_homogenizationMemberAt(ip,el) - associate(prm => param(instance)) + associate(prm => param(material_phaseAt(co,el))) Ld = 0.0_pReal dLd_dTstar = 0.0_pReal do i = 1, prm%sum_N_sl From f95e3bc08d58f7434a23c730c02c1585bc30035a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 07:15:57 +0100 Subject: [PATCH 227/352] simplified access pattern --- src/phase.f90 | 5 +++ src/phase_damage.f90 | 11 +++++ src/phase_mechanical.f90 | 11 ++--- src/phase_mechanical_eigen.f90 | 43 ++++++------------- ...phase_mechanical_eigen_cleavageopening.f90 | 10 ++--- ...hase_mechanical_eigen_slipplaneopening.f90 | 10 ++--- 6 files changed, 42 insertions(+), 48 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index 628bfc443..82b82d71d 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -181,6 +181,11 @@ module phase real(pReal) :: dot_T end function thermal_dot_T + module function damage_phi(ph,me) result(phi) + integer, intent(in) :: ph,me + real(pReal) :: phi + end function damage_phi + module subroutine phase_mechanical_setF(F,co,ip,el) real(pReal), dimension(3,3), intent(in) :: F diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 6063f3583..8defcf3a1 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -528,4 +528,15 @@ module function phase_damage_get_phi(co,ip,el) result(phi) end function phase_damage_get_phi +module function damage_phi(ph,me) result(phi) + + integer, intent(in) :: ph, me + real(pReal) :: phi + + + phi = current(ph)%phi(me) + +end function damage_phi + + end submodule damagee diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index 61151d33b..f7631a38d 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -98,12 +98,9 @@ submodule(phase) mechanics end function plastic_deltaState module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & - S, Fi, co, ip, el) - + S, Fi, ph,me) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + ph,me real(pReal), intent(in), dimension(3,3) :: & S !< 2nd Piola-Kirchhoff stress real(pReal), intent(in), dimension(3,3) :: & @@ -583,7 +580,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) enddo LpLoop call phase_LiAndItsTangents(Li_constitutive, dLi_dS, dLi_dFi, & - S, Fi_new, co, ip, el) + S, Fi_new, ph,me) !* update current residuum and check for convergence of loop atol_Li = max(num%rtol_crystalliteStress * max(norm2(Liguess),norm2(Li_constitutive)), & ! absolute tolerance from largest acceptable relative error @@ -1303,7 +1300,7 @@ module function phase_mechanical_dPdF(dt,co,ip,el) result(dPdF) call phase_LiAndItsTangents(devNull,dLidS,dLidFi, & phase_mechanical_S(ph)%data(1:3,1:3,me), & phase_mechanical_Fi(ph)%data(1:3,1:3,me), & - co,ip,el) + ph,me) invFp = math_inv33(phase_mechanical_Fp(ph)%data(1:3,1:3,me)) invFi = math_inv33(phase_mechanical_Fi(ph)%data(1:3,1:3,me)) diff --git a/src/phase_mechanical_eigen.f90 b/src/phase_mechanical_eigen.f90 index 3fb2d1bf2..9eb3c5767 100644 --- a/src/phase_mechanical_eigen.f90 +++ b/src/phase_mechanical_eigen.f90 @@ -16,11 +16,8 @@ submodule(phase:mechanics) eigendeformation logical, dimension(:,:), allocatable :: myKinematics end function kinematics_thermal_expansion_init - module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, co, ip, el) - integer, intent(in) :: & - co, & !< grain number - ip, & !< integration point number - el !< element number + module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) + integer, intent(in) :: ph, me real(pReal), intent(in), dimension(3,3) :: & S real(pReal), intent(out), dimension(3,3) :: & @@ -29,11 +26,8 @@ submodule(phase:mechanics) eigendeformation dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) end subroutine kinematics_cleavage_opening_LiAndItsTangent - module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S, co, ip, el) - integer, intent(in) :: & - co, & !< grain number - ip, & !< integration point number - el !< element number + module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) + integer, intent(in) :: ph, me real(pReal), intent(in), dimension(3,3) :: & S real(pReal), intent(out), dimension(3,3) :: & @@ -44,7 +38,6 @@ submodule(phase:mechanics) eigendeformation module subroutine thermalexpansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) integer, intent(in) :: ph, me - !< element number real(pReal), intent(out), dimension(3,3) :: & Li !< thermal velocity gradient real(pReal), intent(out), dimension(3,3,3,3) :: & @@ -165,12 +158,10 @@ end function kinematics_active2 ! ToDo: MD: S is Mi? !-------------------------------------------------------------------------------------------------- module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & - S, Fi, co, ip, el) + S, Fi, ph,me) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + ph,me real(pReal), intent(in), dimension(3,3) :: & S !< 2nd Piola-Kirchhoff stress real(pReal), intent(in), dimension(3,3) :: & @@ -190,18 +181,16 @@ module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & real(pReal) :: & detFi integer :: & - k, i, j, & - instance, of, me, ph + k, i, j Li = 0.0_pReal dLi_dS = 0.0_pReal dLi_dFi = 0.0_pReal - plasticType: select case (phase_plasticity(material_phaseAt(co,el))) + + plasticType: select case (phase_plasticity(ph)) case (PLASTICITY_isotropic_ID) plasticType - of = material_phasememberAt(co,ip,el) - instance = phase_plasticInstance(material_phaseAt(co,el)) - call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,instance,of) + call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,phase_plasticInstance(ph),me) case default plasticType my_Li = 0.0_pReal my_dLi_dS = 0.0_pReal @@ -210,17 +199,13 @@ module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & Li = Li + my_Li dLi_dS = dLi_dS + my_dLi_dS - KinematicsLoop: do k = 1, phase_Nkinematics(material_phaseAt(co,el)) - kinematicsType: select case (phase_kinematics(k,material_phaseAt(co,el))) + KinematicsLoop: do k = 1, phase_Nkinematics(ph) + kinematicsType: select case (phase_kinematics(k,ph)) case (KINEMATICS_cleavage_opening_ID) kinematicsType - print*, 'clea' - call kinematics_cleavage_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) + call kinematics_cleavage_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, ph, me) case (KINEMATICS_slipplane_opening_ID) kinematicsType - print*, 'slipp' - call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, co, ip, el) + call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, ph, me) case (KINEMATICS_thermal_expansion_ID) kinematicsType - me = material_phaseMemberAt(co,ip,el) - ph = material_phaseAt(co,el) call thermalexpansion_LiAndItsTangent(my_Li, my_dLi_dS, ph,me) case default kinematicsType my_Li = 0.0_pReal diff --git a/src/phase_mechanical_eigen_cleavageopening.f90 b/src/phase_mechanical_eigen_cleavageopening.f90 index 8878c10bd..5bb9847f4 100644 --- a/src/phase_mechanical_eigen_cleavageopening.f90 +++ b/src/phase_mechanical_eigen_cleavageopening.f90 @@ -95,12 +95,10 @@ end function kinematics_cleavage_opening_init !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the velocity gradient !-------------------------------------------------------------------------------------------------- -module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, co, ip, el) +module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) integer, intent(in) :: & - co, & !< grain number - ip, & !< integration point number - el !< element number + ph,me real(pReal), intent(in), dimension(3,3) :: & S real(pReal), intent(out), dimension(3,3) :: & @@ -117,9 +115,9 @@ module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, Ld = 0.0_pReal dLd_dTstar = 0.0_pReal - associate(prm => param(material_phaseAt(co,el))) + associate(prm => param(ph)) do i = 1,prm%sum_N_cl - traction_crit = prm%g_crit(i)*phase_damage_get_phi(co,ip,el)**2.0_pReal + traction_crit = prm%g_crit(i)*damage_phi(ph,me)**2.0_pReal traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) if (abs(traction_d) > traction_crit + tol_math_check) then diff --git a/src/phase_mechanical_eigen_slipplaneopening.f90 b/src/phase_mechanical_eigen_slipplaneopening.f90 index e8410a935..64988d87f 100644 --- a/src/phase_mechanical_eigen_slipplaneopening.f90 +++ b/src/phase_mechanical_eigen_slipplaneopening.f90 @@ -115,12 +115,10 @@ end function kinematics_slipplane_opening_init !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the velocity gradient !-------------------------------------------------------------------------------------------------- -module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S, co, ip, el) +module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) integer, intent(in) :: & - co, & !< grain number - ip, & !< integration point number - el !< element number + ph, me real(pReal), intent(in), dimension(3,3) :: & S real(pReal), intent(out), dimension(3,3) :: & @@ -135,7 +133,7 @@ module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S udotd, dudotd_dt, udott, dudott_dt, udotn, dudotn_dt - associate(prm => param(material_phaseAt(co,el))) + associate(prm => param(ph)) Ld = 0.0_pReal dLd_dTstar = 0.0_pReal do i = 1, prm%sum_N_sl @@ -144,7 +142,7 @@ module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S traction_t = math_tensordot(S,prm%P_t(1:3,1:3,i)) traction_n = math_tensordot(S,prm%P_n(1:3,1:3,i)) - traction_crit = prm%g_crit(i)* phase_damage_get_phi(co,ip,el) ! degrading critical load carrying capacity by damage + traction_crit = prm%g_crit(i)* damage_phi(ph,me) udotd = sign(1.0_pReal,traction_d)* prm%dot_o* ( abs(traction_d)/traction_crit & - abs(traction_d)/prm%g_crit(i))**prm%q From 6e3515982d6fe4c727731297577d4aafe1930665 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 07:55:32 +0100 Subject: [PATCH 228/352] not needed outside of thermal --- src/phase.f90 | 2 +- src/phase_thermal.f90 | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/phase.f90 b/src/phase.f90 index 82b82d71d..1d08f680d 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -71,7 +71,7 @@ module phase type(tPlasticState), allocatable, dimension(:), public :: & plasticState type(tSourceState), allocatable, dimension(:), public :: & - damageState, thermalState + damageState integer, public, protected :: & diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 85ca2f7a5..5d3d89ccb 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -3,6 +3,9 @@ !---------------------------------------------------------------------------------------------------- submodule(phase) thermal + type(tSourceState), allocatable, dimension(:) :: & + thermalState + enum, bind(c); enumerator :: & THERMAL_UNDEFINED_ID ,& THERMAL_DISSIPATION_ID, & From b3dde6d7227b60a830c2486d068ca8b6b5b0343c Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 08:32:43 +0100 Subject: [PATCH 229/352] only one damage mechanism per phase material.yaml specification is designed to allow more than one, but that requires to have two phase fields etc. For the moment, keep it as simple as possible. --- PRIVATE | 2 +- src/phase.f90 | 43 +++++++++---------- src/phase_damage.f90 | 71 +++++++++++++------------------ src/phase_damage_anisobrittle.f90 | 30 +++++-------- src/phase_damage_anisoductile.f90 | 29 ++++--------- src/phase_damage_isobrittle.f90 | 37 ++++++---------- src/phase_damage_isoductile.f90 | 29 ++++--------- src/phase_mechanical.f90 | 18 ++++---- 8 files changed, 97 insertions(+), 162 deletions(-) diff --git a/PRIVATE b/PRIVATE index 2a0f30ec4..571b06ac4 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 2a0f30ec47473f42e0da922055b72b527730378d +Subproject commit 571b06ac4b42ed217eacfa5c71281e571bdab1df diff --git a/src/phase.f90 b/src/phase.f90 index 1d08f680d..8ea1fa5f7 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -70,7 +70,7 @@ module phase type(tPlasticState), allocatable, dimension(:), public :: & plasticState - type(tSourceState), allocatable, dimension(:), public :: & + type(tState), allocatable, dimension(:), public :: & damageState @@ -350,14 +350,12 @@ subroutine phase_init PhaseLoop2:do ph = 1,phases%length !-------------------------------------------------------------------------------------------------- ! partition and initialize state - plasticState(ph)%state = plasticState(ph)%state0 - forall(so = 1:phase_Nsources(ph)) - damageState(ph)%p(so)%state = damageState(ph)%p(so)%state0 - end forall - - phase_source_maxSizeDotState = max(phase_source_maxSizeDotState, & - maxval(damageState(ph)%p%sizeDotState)) + plasticState(ph)%state = plasticState(ph)%state0 + if(phase_Nsources(ph) > 0) & + damageState(ph)%state = damageState(ph)%state0 enddo PhaseLoop2 + + phase_source_maxSizeDotState = maxval(damageState%sizeDotState) phase_plasticity_maxSizeDotState = maxval(plasticState%sizeDotState) end subroutine phase_init @@ -404,15 +402,13 @@ subroutine phase_restore(ce,includeL) integer, intent(in) :: ce integer :: & - co, & !< constituent number - so + co do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce)) - do so = 1, phase_Nsources(material_phaseAt2(co,ce)) - damageState(material_phaseAt2(co,ce))%p(so)%state( :,material_phasememberAt2(co,ce)) = & - damageState(material_phaseAt2(co,ce))%p(so)%state0(:,material_phasememberAt2(co,ce)) - enddo + if (phase_Nsources(material_phaseAt2(co,ce)) > 0) & + damageState(material_phaseAt2(co,ce))%state( :,material_phasememberAt2(co,ce)) = & + damageState(material_phaseAt2(co,ce))%state0(:,material_phasememberAt2(co,ce)) enddo call mechanical_restore(ce,includeL) @@ -426,16 +422,16 @@ end subroutine phase_restore !-------------------------------------------------------------------------------------------------- subroutine phase_forward() - integer :: ph, so + integer :: ph call mechanical_forward() call thermal_forward() do ph = 1, size(damageState) - do so = 1,phase_Nsources(ph) - damageState(ph)%p(so)%state0 = damageState(ph)%p(so)%state - enddo; enddo + if (phase_Nsources(ph) > 0) & + damageState(ph)%state0 = damageState(ph)%state + enddo end subroutine phase_forward @@ -531,9 +527,8 @@ subroutine crystallite_init() phases => config_material%get('phase') do ph = 1, phases%length - do so = 1, phase_Nsources(ph) - allocate(damageState(ph)%p(so)%subState0,source=damageState(ph)%p(so)%state0) ! ToDo: hack - enddo + if (phase_Nsources(ph) > 0) & + allocate(damageState(ph)%subState0,source=damageState(ph)%state0) ! ToDo: hack enddo print'(a42,1x,i10)', ' # of elements: ', eMax @@ -579,9 +574,9 @@ subroutine phase_windForward(ip,el) call mechanical_windForward(ph,me) - do so = 1, phase_Nsources(material_phaseAt(co,el)) - damageState(ph)%p(so)%state0(:,me) = damageState(ph)%p(so)%state(:,me) - enddo + if (phase_Nsources(ph) > 0) & + damageState(ph)%state0(:,me) = damageState(ph)%state(:,me) + enddo diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 8defcf3a1..5f323c3a2 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -176,8 +176,8 @@ module subroutine damage_init phase => phases%get(ph) sources => phase%get('damage',defaultVal=emptyList) - phase_Nsources(ph) = sources%length - allocate(damageState(ph)%p(phase_Nsources(ph))) + if (sources%length > 1) error stop + enddo allocate(phase_source(maxval(phase_Nsources),phases%length), source = DAMAGE_UNDEFINED_ID) @@ -267,57 +267,48 @@ module function integrateDamageState(dt,co,ip,el) result(broken) NiterationState, & !< number of iterations in state loop ph, & me, & - so - integer, dimension(maxval(phase_Nsources)) :: & size_so real(pReal) :: & zeta real(pReal), dimension(phase_source_maxSizeDotState) :: & r ! state residuum - real(pReal), dimension(phase_source_maxSizeDotState,2,maxval(phase_Nsources)) :: source_dotState + real(pReal), dimension(phase_source_maxSizeDotState,2) :: source_dotState logical :: & converged_ - ph = material_phaseAt(co,el) + if (phase_Nsources(ph) == 0) return me = material_phaseMemberAt(co,ip,el) converged_ = .true. broken = phase_damage_collectDotState(co,ip,el,ph,me) if(broken) return - do so = 1, phase_Nsources(ph) - size_so(so) = damageState(ph)%p(so)%sizeDotState - damageState(ph)%p(so)%state(1:size_so(so),me) = damageState(ph)%p(so)%subState0(1:size_so(so),me) & - + damageState(ph)%p(so)%dotState (1:size_so(so),me) * dt - source_dotState(1:size_so(so),2,so) = 0.0_pReal - enddo + size_so = damageState(ph)%sizeDotState + damageState(ph)%state(1:size_so,me) = damageState(ph)%subState0(1:size_so,me) & + + damageState(ph)%dotState (1:size_so,me) * dt + source_dotState(1:size_so,2) = 0.0_pReal iteration: do NiterationState = 1, num%nState - do so = 1, phase_Nsources(ph) - if(nIterationState > 1) source_dotState(1:size_so(so),2,so) = source_dotState(1:size_so(so),1,so) - source_dotState(1:size_so(so),1,so) = damageState(ph)%p(so)%dotState(:,me) - enddo + if(nIterationState > 1) source_dotState(1:size_so,2) = source_dotState(1:size_so,1) + source_dotState(1:size_so,1) = damageState(ph)%dotState(:,me) broken = phase_damage_collectDotState(co,ip,el,ph,me) if(broken) exit iteration - do so = 1, phase_Nsources(ph) - zeta = damper(damageState(ph)%p(so)%dotState(:,me), & - source_dotState(1:size_so(so),1,so),& - source_dotState(1:size_so(so),2,so)) - damageState(ph)%p(so)%dotState(:,me) = damageState(ph)%p(so)%dotState(:,me) * zeta & - + source_dotState(1:size_so(so),1,so)* (1.0_pReal - zeta) - r(1:size_so(so)) = damageState(ph)%p(so)%state (1:size_so(so),me) & - - damageState(ph)%p(so)%subState0(1:size_so(so),me) & - - damageState(ph)%p(so)%dotState (1:size_so(so),me) * dt - damageState(ph)%p(so)%state(1:size_so(so),me) = damageState(ph)%p(so)%state(1:size_so(so),me) & - - r(1:size_so(so)) - converged_ = converged_ .and. converged(r(1:size_so(so)), & - damageState(ph)%p(so)%state(1:size_so(so),me), & - damageState(ph)%p(so)%atol(1:size_so(so))) - enddo + + zeta = damper(damageState(ph)%dotState(:,me),source_dotState(1:size_so,1),source_dotState(1:size_so,2)) + damageState(ph)%dotState(:,me) = damageState(ph)%dotState(:,me) * zeta & + + source_dotState(1:size_so,1)* (1.0_pReal - zeta) + r(1:size_so) = damageState(ph)%state (1:size_so,me) & + - damageState(ph)%subState0(1:size_so,me) & + - damageState(ph)%dotState (1:size_so,me) * dt + damageState(ph)%state(1:size_so,me) = damageState(ph)%state(1:size_so,me) - r(1:size_so) + converged_ = converged_ .and. converged(r(1:size_so), & + damageState(ph)%state(1:size_so,me), & + damageState(ph)%atol(1:size_so)) + if(converged_) then broken = phase_damage_deltaState(mechanical_F_e(ph,me),ph,me) @@ -423,7 +414,7 @@ function phase_damage_collectDotState(co,ip,el,ph,me) result(broken) end select sourceType - broken = broken .or. any(IEEE_is_NaN(damageState(ph)%p(so)%dotState(:,me))) + broken = broken .or. any(IEEE_is_NaN(damageState(ph)%dotState(:,me))) enddo SourceLoop @@ -443,7 +434,6 @@ function phase_damage_deltaState(Fe, ph, me) result(broken) real(pReal), intent(in), dimension(3,3) :: & Fe !< elastic deformation gradient integer :: & - so, & myOffset, & mySize logical :: & @@ -452,23 +442,22 @@ function phase_damage_deltaState(Fe, ph, me) result(broken) broken = .false. - sourceLoop: do so = 1, phase_Nsources(ph) + if (phase_Nsources(ph) == 0) return - sourceType: select case (phase_source(so,ph)) + sourceType: select case (phase_source(1,ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType call source_damage_isoBrittle_deltaState(phase_homogenizedC(ph,me), Fe, ph,me) - broken = any(IEEE_is_NaN(damageState(ph)%p(so)%deltaState(:,me))) + broken = any(IEEE_is_NaN(damageState(ph)%deltaState(:,me))) if(.not. broken) then - myOffset = damageState(ph)%p(so)%offsetDeltaState - mySize = damageState(ph)%p(so)%sizeDeltaState - damageState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,me) = & - damageState(ph)%p(so)%state(myOffset + 1: myOffset + mySize,me) + damageState(ph)%p(so)%deltaState(1:mySize,me) + myOffset = damageState(ph)%offsetDeltaState + mySize = damageState(ph)%sizeDeltaState + damageState(ph)%state(myOffset + 1: myOffset + mySize,me) = & + damageState(ph)%state(myOffset + 1: myOffset + mySize,me) + damageState(ph)%deltaState(1:mySize,me) endif end select sourceType - enddo SourceLoop end function phase_damage_deltaState diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index ad7f80604..422b2a91a 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -6,8 +6,7 @@ !-------------------------------------------------------------------------------------------------- submodule (phase:damagee) anisobrittle - integer, dimension(:), allocatable :: & - source_damage_anisoBrittle_offset, & !< which source is my current source mechanism? + integer, dimension(:), allocatable :: & source_damage_anisoBrittle_instance !< instance of source mechanism type :: tParameters !< container type for internal constitutive parameters @@ -58,7 +57,6 @@ module function anisobrittle_init(source_length) result(mySources) phases => config_material%get('phase') allocate(param(Ninstances)) - allocate(source_damage_anisoBrittle_offset (phases%length), source=0) allocate(source_damage_anisoBrittle_instance(phases%length), source=0) do p = 1, phases%length @@ -68,7 +66,6 @@ module function anisobrittle_init(source_length) result(mySources) sources => phase%get('damage') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then - source_damage_anisoBrittle_offset(p) = sourceOffset associate(prm => param(source_damage_anisoBrittle_instance(p))) src => sources%get(sourceOffset) @@ -101,9 +98,9 @@ module function anisobrittle_init(source_length) result(mySources) if (any(prm%s_crit < 0.0_pReal)) extmsg = trim(extmsg)//' s_crit' Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call phase_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) - damageState(p)%p(sourceOffset)%atol = src%get_asFloat('anisobrittle_atol',defaultVal=1.0e-3_pReal) - if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisobrittle_atol' + call phase_allocateState(damageState(p),Nconstituents,1,1,0) + damageState(p)%atol = src%get_asFloat('anisobrittle_atol',defaultVal=1.0e-3_pReal) + if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisobrittle_atol' end associate @@ -139,14 +136,13 @@ module subroutine anisobrittle_dotState(S, co, ip, el) real(pReal) :: & traction_d, traction_t, traction_n, traction_crit + ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) - sourceOffset = source_damage_anisoBrittle_offset(ph) - homog = material_homogenizationAt(el) - damageOffset = material_homogenizationMemberAt(ip,el) + associate(prm => param(source_damage_anisoBrittle_instance(ph))) - damageState(ph)%p(sourceOffset)%dotState(1,me) = 0.0_pReal + damageState(ph)%dotState(1,me) = 0.0_pReal do i = 1, prm%sum_N_cl traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) @@ -154,8 +150,8 @@ module subroutine anisobrittle_dotState(S, co, ip, el) traction_crit = prm%g_crit(i)*phase_damage_get_phi(co,ip,el)**2.0_pReal - damageState(ph)%p(sourceOffset)%dotState(1,me) & - = damageState(ph)%p(sourceOffset)%dotState(1,me) & + damageState(ph)%dotState(1,me) & + = damageState(ph)%dotState(1,me) & + prm%dot_o / prm%s_crit(i) & * ((max(0.0_pReal, abs(traction_d) - traction_crit)/traction_crit)**prm%q + & (max(0.0_pReal, abs(traction_t) - traction_crit)/traction_crit)**prm%q + & @@ -180,12 +176,8 @@ module subroutine source_damage_anisobrittle_getRateAndItsTangent(localphiDot, d localphiDot, & dLocalphiDot_dPhi - integer :: & - sourceOffset - sourceOffset = source_damage_anisoBrittle_offset(phase) - - dLocalphiDot_dPhi = -damageState(phase)%p(sourceOffset)%state(1,constituent) + dLocalphiDot_dPhi = -damageState(phase)%state(1,constituent) localphiDot = 1.0_pReal & + dLocalphiDot_dPhi*phi @@ -204,7 +196,7 @@ module subroutine anisobrittle_results(phase,group) integer :: o associate(prm => param(source_damage_anisoBrittle_instance(phase)), & - stt => damageState(phase)%p(source_damage_anisoBrittle_offset(phase))%state) + stt => damageState(phase)%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('f_phi') diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index b22f5b3d6..bafcf80a2 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -7,7 +7,6 @@ submodule(phase:damagee) anisoductile integer, dimension(:), allocatable :: & - source_damage_anisoDuctile_offset, & !< which source is my current damage mechanism? source_damage_anisoDuctile_instance !< instance of damage source mechanism type :: tParameters !< container type for internal constitutive parameters @@ -53,7 +52,6 @@ module function anisoductile_init(source_length) result(mySources) phases => config_material%get('phase') allocate(param(Ninstances)) - allocate(source_damage_anisoDuctile_offset (phases%length), source=0) allocate(source_damage_anisoDuctile_instance(phases%length), source=0) do p = 1, phases%length @@ -65,7 +63,6 @@ module function anisoductile_init(source_length) result(mySources) sources => phase%get('source') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then - source_damage_anisoDuctile_offset(p) = sourceOffset associate(prm => param(source_damage_anisoDuctile_instance(p))) src => sources%get(sourceOffset) @@ -87,9 +84,9 @@ module function anisoductile_init(source_length) result(mySources) if (any(prm%gamma_crit < 0.0_pReal)) extmsg = trim(extmsg)//' gamma_crit' Nconstituents=count(material_phaseAt==p) * discretization_nIPs - call phase_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) - damageState(p)%p(sourceOffset)%atol = src%get_asFloat('anisoDuctile_atol',defaultVal=1.0e-3_pReal) - if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisoductile_atol' + call phase_allocateState(damageState(p),Nconstituents,1,1,0) + damageState(p)%atol = src%get_asFloat('anisoDuctile_atol',defaultVal=1.0e-3_pReal) + if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisoductile_atol' end associate @@ -116,20 +113,14 @@ module subroutine anisoductile_dotState(co, ip, el) integer :: & ph, & - me, & - sourceOffset, & - damageOffset, & - homog + me ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) - sourceOffset = source_damage_anisoDuctile_offset(ph) - homog = material_homogenizationAt(el) - damageOffset = material_homogenizationMemberAt(ip,el) + associate(prm => param(source_damage_anisoDuctile_instance(ph))) - damageState(ph)%p(sourceOffset)%dotState(1,me) & - = sum(plasticState(ph)%slipRate(:,me)/(phase_damage_get_phi(co,ip,el)**prm%q)/prm%gamma_crit) + damageState(ph)%dotState(1,me) = sum(plasticState(ph)%slipRate(:,me)/(phase_damage_get_phi(co,ip,el)**prm%q)/prm%gamma_crit) end associate end subroutine anisoductile_dotState @@ -149,12 +140,8 @@ module subroutine source_damage_anisoDuctile_getRateAndItsTangent(localphiDot, d localphiDot, & dLocalphiDot_dPhi - integer :: & - sourceOffset - sourceOffset = source_damage_anisoDuctile_offset(phase) - - dLocalphiDot_dPhi = -damageState(phase)%p(sourceOffset)%state(1,constituent) + dLocalphiDot_dPhi = -damageState(phase)%state(1,constituent) localphiDot = 1.0_pReal & + dLocalphiDot_dPhi*phi @@ -173,7 +160,7 @@ module subroutine anisoductile_results(phase,group) integer :: o associate(prm => param(source_damage_anisoDuctile_instance(phase)), & - stt => damageState(phase)%p(source_damage_anisoDuctile_offset(phase))%state) + stt => damageState(phase)%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('f_phi') diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index a2ae7dfb7..0a87493a6 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -7,7 +7,6 @@ submodule(phase:damagee) isobrittle integer, dimension(:), allocatable :: & - source_damage_isoBrittle_offset, & source_damage_isoBrittle_instance type :: tParameters !< container type for internal constitutive parameters @@ -48,7 +47,6 @@ module function isobrittle_init(source_length) result(mySources) phases => config_material%get('phase') allocate(param(Ninstances)) - allocate(source_damage_isoBrittle_offset (phases%length), source=0) allocate(source_damage_isoBrittle_instance(phases%length), source=0) do p = 1, phases%length @@ -58,7 +56,6 @@ module function isobrittle_init(source_length) result(mySources) sources => phase%get('damage') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then - source_damage_isoBrittle_offset(p) = sourceOffset associate(prm => param(source_damage_isoBrittle_instance(p))) src => sources%get(sourceOffset) @@ -74,9 +71,9 @@ module function isobrittle_init(source_length) result(mySources) if (prm%W_crit <= 0.0_pReal) extmsg = trim(extmsg)//' W_crit' Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call phase_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,1) - damageState(p)%p(sourceOffset)%atol = src%get_asFloat('isoBrittle_atol',defaultVal=1.0e-3_pReal) - if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isobrittle_atol' + call phase_allocateState(damageState(p),Nconstituents,1,1,1) + damageState(p)%atol = src%get_asFloat('isoBrittle_atol',defaultVal=1.0e-3_pReal) + if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isobrittle_atol' end associate @@ -102,14 +99,11 @@ module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph,me) real(pReal), intent(in), dimension(6,6) :: & C - integer :: & - sourceOffset real(pReal), dimension(6) :: & strain real(pReal) :: & strainenergy - sourceOffset = source_damage_isoBrittle_offset(ph) strain = 0.5_pReal*math_sym33to6(matmul(transpose(Fe),Fe)-math_I3) @@ -117,14 +111,11 @@ module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph,me) strainenergy = 2.0_pReal*sum(strain*matmul(C,strain))/prm%W_crit ! ToDo: check strainenergy = 2.0_pReal*dot_product(strain,matmul(C,strain))/prm%W_crit - if (strainenergy > damageState(ph)%p(sourceOffset)%subState0(1,me)) then - damageState(ph)%p(sourceOffset)%deltaState(1,me) = & - strainenergy - damageState(ph)%p(sourceOffset)%state(1,me) - else - damageState(ph)%p(sourceOffset)%deltaState(1,me) = & - damageState(ph)%p(sourceOffset)%subState0(1,me) - & - damageState(ph)%p(sourceOffset)%state(1,me) - endif + if (strainenergy > damageState(ph)%subState0(1,me)) then + damageState(ph)%deltaState(1,me) = strainenergy - damageState(ph)%state(1,me) + else + damageState(ph)%deltaState(1,me) = damageState(ph)%subState0(1,me) - damageState(ph)%state(1,me) + endif end associate end subroutine source_damage_isoBrittle_deltaState @@ -144,15 +135,11 @@ module subroutine source_damage_isoBrittle_getRateAndItsTangent(localphiDot, dLo localphiDot, & dLocalphiDot_dPhi - integer :: & - sourceOffset - - sourceOffset = source_damage_isoBrittle_offset(phase) associate(prm => param(source_damage_isoBrittle_instance(phase))) - localphiDot = 1.0_pReal & - - phi*damageState(phase)%p(sourceOffset)%state(1,constituent) - dLocalphiDot_dPhi = - damageState(phase)%p(sourceOffset)%state(1,constituent) + localphiDot = 1.0_pReal & + - phi*damageState(phase)%state(1,constituent) + dLocalphiDot_dPhi = - damageState(phase)%state(1,constituent) end associate end subroutine source_damage_isoBrittle_getRateAndItsTangent @@ -169,7 +156,7 @@ module subroutine isobrittle_results(phase,group) integer :: o associate(prm => param(source_damage_isoBrittle_instance(phase)), & - stt => damageState(phase)%p(source_damage_isoBrittle_offset(phase))%state) + stt => damageState(phase)%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('f_phi') diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index f378b7ad2..657f9da39 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -7,7 +7,6 @@ submodule(phase:damagee) isoductile integer, dimension(:), allocatable :: & - source_damage_isoDuctile_offset, & !< which source is my current damage mechanism? source_damage_isoDuctile_instance !< instance of damage source mechanism type:: tParameters !< container type for internal constitutive parameters @@ -50,7 +49,6 @@ module function isoductile_init(source_length) result(mySources) phases => config_material%get('phase') allocate(param(Ninstances)) - allocate(source_damage_isoDuctile_offset (phases%length), source=0) allocate(source_damage_isoDuctile_instance(phases%length), source=0) do p = 1, phases%length @@ -60,7 +58,6 @@ module function isoductile_init(source_length) result(mySources) sources => phase%get('damage') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then - source_damage_isoDuctile_offset(p) = sourceOffset associate(prm => param(source_damage_isoDuctile_instance(p))) src => sources%get(sourceOffset) @@ -78,9 +75,9 @@ module function isoductile_init(source_length) result(mySources) if (prm%gamma_crit <= 0.0_pReal) extmsg = trim(extmsg)//' gamma_crit' Nconstituents=count(material_phaseAt==p) * discretization_nIPs - call phase_allocateState(damageState(p)%p(sourceOffset),Nconstituents,1,1,0) - damageState(p)%p(sourceOffset)%atol = src%get_asFloat('isoDuctile_atol',defaultVal=1.0e-3_pReal) - if(any(damageState(p)%p(sourceOffset)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isoductile_atol' + call phase_allocateState(damageState(p),Nconstituents,1,1,0) + damageState(p)%atol = src%get_asFloat('isoDuctile_atol',defaultVal=1.0e-3_pReal) + if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isoductile_atol' end associate @@ -107,20 +104,14 @@ module subroutine isoductile_dotState(co, ip, el) integer :: & ph, & - me, & - sourceOffset, & - damageOffset, & - homog + me ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) - sourceOffset = source_damage_isoDuctile_offset(ph) - homog = material_homogenizationAt(el) - damageOffset = material_homogenizationMemberAt(ip,el) + associate(prm => param(source_damage_isoDuctile_instance(ph))) - damageState(ph)%p(sourceOffset)%dotState(1,me) = & - sum(plasticState(ph)%slipRate(:,me))/(phase_damage_get_phi(co,ip,el)**prm%q)/prm%gamma_crit + damageState(ph)%dotState(1,me) = sum(plasticState(ph)%slipRate(:,me))/(phase_damage_get_phi(co,ip,el)**prm%q)/prm%gamma_crit end associate end subroutine isoductile_dotState @@ -140,12 +131,8 @@ module subroutine source_damage_isoDuctile_getRateAndItsTangent(localphiDot, dLo localphiDot, & dLocalphiDot_dPhi - integer :: & - sourceOffset - sourceOffset = source_damage_isoDuctile_offset(phase) - - dLocalphiDot_dPhi = -damageState(phase)%p(sourceOffset)%state(1,constituent) + dLocalphiDot_dPhi = -damageState(phase)%state(1,constituent) localphiDot = 1.0_pReal & + dLocalphiDot_dPhi*phi @@ -164,7 +151,7 @@ module subroutine isoductile_results(phase,group) integer :: o associate(prm => param(source_damage_isoDuctile_instance(phase)), & - stt => damageState(phase)%p(source_damage_isoDuctile_offset(phase))%state) + stt => damageState(phase)%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('f_phi') diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index f7631a38d..bc4b2cd47 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -1138,7 +1138,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) real(pReal) :: & formerSubStep integer :: & - so, ph, me, sizeDotState + ph, me, sizeDotState logical :: todo real(pReal) :: subFrac,subStep real(pReal), dimension(3,3) :: & @@ -1159,10 +1159,9 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) subLp0 = phase_mechanical_Lp0(ph)%data(1:3,1:3,me) subState0 = plasticState(ph)%State0(:,me) + if (phase_Nsources(ph) > 0) & + damageState(ph)%subState0(:,me) = damageState(ph)%state0(:,me) - do so = 1, phase_Nsources(ph) - damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%state0(:,me) - enddo subFp0 = phase_mechanical_Fp0(ph)%data(1:3,1:3,me) subFi0 = phase_mechanical_Fi0(ph)%data(1:3,1:3,me) subF0 = phase_mechanical_F0(ph)%data(1:3,1:3,me) @@ -1188,9 +1187,9 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) subFp0 = phase_mechanical_Fp(ph)%data(1:3,1:3,me) subFi0 = phase_mechanical_Fi(ph)%data(1:3,1:3,me) subState0 = plasticState(ph)%state(:,me) - do so = 1, phase_Nsources(ph) - damageState(ph)%p(so)%subState0(:,me) = damageState(ph)%p(so)%state(:,me) - enddo + if (phase_Nsources(ph) > 0) & + damageState(ph)%subState0(:,me) = damageState(ph)%state(:,me) + endif !-------------------------------------------------------------------------------------------------- ! cut back (reduced time and restore) @@ -1204,9 +1203,8 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) phase_mechanical_Li(ph)%data(1:3,1:3,me) = subLi0 endif plasticState(ph)%state(:,me) = subState0 - do so = 1, phase_Nsources(ph) - damageState(ph)%p(so)%state(:,me) = damageState(ph)%p(so)%subState0(:,me) - enddo + if (phase_Nsources(ph) > 0) & + damageState(ph)%state(:,me) = damageState(ph)%subState0(:,me) todo = subStep > num%subStepMinCryst ! still on track or already done (beyond repair) endif From 775a51faa11ae9d75d85cdf30e583e8f5dcc4966 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 10:11:39 +0100 Subject: [PATCH 230/352] explicit instance mapping not needed --- src/phase_damage_anisobrittle.f90 | 52 ++++++++++++++----------------- src/phase_damage_anisoductile.f90 | 29 +++++++---------- src/phase_damage_isobrittle.f90 | 32 +++++++++---------- src/phase_damage_isoductile.f90 | 28 +++++++---------- 4 files changed, 60 insertions(+), 81 deletions(-) diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 422b2a91a..81072e16d 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -6,9 +6,6 @@ !-------------------------------------------------------------------------------------------------- submodule (phase:damagee) anisobrittle - integer, dimension(:), allocatable :: & - source_damage_anisoBrittle_instance !< instance of source mechanism - type :: tParameters !< container type for internal constitutive parameters real(pReal) :: & dot_o, & !< opening rate of cleavage planes @@ -56,17 +53,16 @@ module function anisobrittle_init(source_length) result(mySources) if(Ninstances == 0) return phases => config_material%get('phase') - allocate(param(Ninstances)) - allocate(source_damage_anisoBrittle_instance(phases%length), source=0) + allocate(param(phases%length)) + do p = 1, phases%length phase => phases%get(p) - if(any(mySources(:,p))) source_damage_anisoBrittle_instance(p) = count(mySources(:,1:p)) if(count(mySources(:,p)) == 0) cycle sources => phase%get('damage') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then - associate(prm => param(source_damage_anisoBrittle_instance(p))) + associate(prm => param(p)) src => sources%get(sourceOffset) N_cl = src%get_asInts('N_cl',defaultVal=emptyIntArray) @@ -141,22 +137,21 @@ module subroutine anisobrittle_dotState(S, co, ip, el) me = material_phasememberAt(co,ip,el) - associate(prm => param(source_damage_anisoBrittle_instance(ph))) - damageState(ph)%dotState(1,me) = 0.0_pReal - do i = 1, prm%sum_N_cl - traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) - traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) - traction_n = math_tensordot(S,prm%cleavage_systems(1:3,1:3,3,i)) + associate(prm => param(ph)) + damageState(ph)%dotState(1,me) = 0.0_pReal + do i = 1, prm%sum_N_cl + traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) + traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) + traction_n = math_tensordot(S,prm%cleavage_systems(1:3,1:3,3,i)) - traction_crit = prm%g_crit(i)*phase_damage_get_phi(co,ip,el)**2.0_pReal + traction_crit = prm%g_crit(i)*phase_damage_get_phi(co,ip,el)**2.0_pReal - damageState(ph)%dotState(1,me) & - = damageState(ph)%dotState(1,me) & - + prm%dot_o / prm%s_crit(i) & - * ((max(0.0_pReal, abs(traction_d) - traction_crit)/traction_crit)**prm%q + & - (max(0.0_pReal, abs(traction_t) - traction_crit)/traction_crit)**prm%q + & - (max(0.0_pReal, abs(traction_n) - traction_crit)/traction_crit)**prm%q) - enddo + damageState(ph)%dotState(1,me) = damageState(ph)%dotState(1,me) & + + prm%dot_o / prm%s_crit(i) & + * ((max(0.0_pReal, abs(traction_d) - traction_crit)/traction_crit)**prm%q + & + (max(0.0_pReal, abs(traction_t) - traction_crit)/traction_crit)**prm%q + & + (max(0.0_pReal, abs(traction_n) - traction_crit)/traction_crit)**prm%q) + enddo end associate end subroutine anisobrittle_dotState @@ -195,14 +190,13 @@ module subroutine anisobrittle_results(phase,group) integer :: o - associate(prm => param(source_damage_anisoBrittle_instance(phase)), & - stt => damageState(phase)%state) - outputsLoop: do o = 1,size(prm%output) - select case(trim(prm%output(o))) - case ('f_phi') - call results_writeDataset(group,stt,trim(prm%output(o)),'driving force','J/m³') - end select - enddo outputsLoop + associate(prm => param(phase), stt => damageState(phase)%state) + outputsLoop: do o = 1,size(prm%output) + select case(trim(prm%output(o))) + case ('f_phi') + call results_writeDataset(group,stt,trim(prm%output(o)),'driving force','J/m³') + end select + enddo outputsLoop end associate end subroutine anisobrittle_results diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index bafcf80a2..4d2392589 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -6,9 +6,6 @@ !-------------------------------------------------------------------------------------------------- submodule(phase:damagee) anisoductile - integer, dimension(:), allocatable :: & - source_damage_anisoDuctile_instance !< instance of damage source mechanism - type :: tParameters !< container type for internal constitutive parameters real(pReal) :: & q !< damage rate sensitivity @@ -18,7 +15,7 @@ submodule(phase:damagee) anisoductile output end type tParameters - type(tParameters), dimension(:), allocatable :: param !< containers of constitutive parameters (len Ninstances) + type(tParameters), dimension(:), allocatable :: param !< containers of constitutive parameters contains @@ -51,19 +48,17 @@ module function anisoductile_init(source_length) result(mySources) if(Ninstances == 0) return phases => config_material%get('phase') - allocate(param(Ninstances)) - allocate(source_damage_anisoDuctile_instance(phases%length), source=0) + allocate(param(phases%length)) do p = 1, phases%length phase => phases%get(p) - if(any(mySources(:,p))) source_damage_anisoDuctile_instance(p) = count(mySources(:,1:p)) if(count(mySources(:,p)) == 0) cycle mech => phase%get('mechanics') pl => mech%get('plasticity') sources => phase%get('source') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then - associate(prm => param(source_damage_anisoDuctile_instance(p))) + associate(prm => param(p)) src => sources%get(sourceOffset) N_sl = pl%get_asInts('N_sl',defaultVal=emptyIntArray) @@ -119,8 +114,8 @@ module subroutine anisoductile_dotState(co, ip, el) me = material_phasememberAt(co,ip,el) - associate(prm => param(source_damage_anisoDuctile_instance(ph))) - damageState(ph)%dotState(1,me) = sum(plasticState(ph)%slipRate(:,me)/(phase_damage_get_phi(co,ip,el)**prm%q)/prm%gamma_crit) + associate(prm => param(ph)) + damageState(ph)%dotState(1,me) = sum(plasticState(ph)%slipRate(:,me)/(damage_phi(ph,me)**prm%q)/prm%gamma_crit) end associate end subroutine anisoductile_dotState @@ -159,14 +154,14 @@ module subroutine anisoductile_results(phase,group) integer :: o - associate(prm => param(source_damage_anisoDuctile_instance(phase)), & + associate(prm => param(phase), & stt => damageState(phase)%state) - outputsLoop: do o = 1,size(prm%output) - select case(trim(prm%output(o))) - case ('f_phi') - call results_writeDataset(group,stt,trim(prm%output(o)),'driving force','J/m³') - end select - enddo outputsLoop + outputsLoop: do o = 1,size(prm%output) + select case(trim(prm%output(o))) + case ('f_phi') + call results_writeDataset(group,stt,trim(prm%output(o)),'driving force','J/m³') + end select + enddo outputsLoop end associate end subroutine anisoductile_results diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 0a87493a6..4e37f3ee9 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -6,9 +6,6 @@ !-------------------------------------------------------------------------------------------------- submodule(phase:damagee) isobrittle - integer, dimension(:), allocatable :: & - source_damage_isoBrittle_instance - type :: tParameters !< container type for internal constitutive parameters real(pReal) :: & W_crit !< critical elastic strain energy @@ -46,17 +43,15 @@ module function isobrittle_init(source_length) result(mySources) if(Ninstances == 0) return phases => config_material%get('phase') - allocate(param(Ninstances)) - allocate(source_damage_isoBrittle_instance(phases%length), source=0) + allocate(param(phases%length)) do p = 1, phases%length phase => phases%get(p) - if(any(mySources(:,p))) source_damage_isoBrittle_instance(p) = count(mySources(:,1:p)) if(count(mySources(:,p)) == 0) cycle sources => phase%get('damage') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then - associate(prm => param(source_damage_isoBrittle_instance(p))) + associate(prm => param(p)) src => sources%get(sourceOffset) prm%W_crit = src%get_asFloat('W_crit') @@ -107,9 +102,9 @@ module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph,me) strain = 0.5_pReal*math_sym33to6(matmul(transpose(Fe),Fe)-math_I3) - associate(prm => param(source_damage_isoBrittle_instance(ph))) - strainenergy = 2.0_pReal*sum(strain*matmul(C,strain))/prm%W_crit - ! ToDo: check strainenergy = 2.0_pReal*dot_product(strain,matmul(C,strain))/prm%W_crit + associate(prm => param(ph)) + strainenergy = 2.0_pReal*sum(strain*matmul(C,strain))/prm%W_crit + ! ToDo: check strainenergy = 2.0_pReal*dot_product(strain,matmul(C,strain))/prm%W_crit if (strainenergy > damageState(ph)%subState0(1,me)) then damageState(ph)%deltaState(1,me) = strainenergy - damageState(ph)%state(1,me) @@ -136,7 +131,7 @@ module subroutine source_damage_isoBrittle_getRateAndItsTangent(localphiDot, dLo dLocalphiDot_dPhi - associate(prm => param(source_damage_isoBrittle_instance(phase))) + associate(prm => param(phase)) localphiDot = 1.0_pReal & - phi*damageState(phase)%state(1,constituent) dLocalphiDot_dPhi = - damageState(phase)%state(1,constituent) @@ -155,14 +150,15 @@ module subroutine isobrittle_results(phase,group) integer :: o - associate(prm => param(source_damage_isoBrittle_instance(phase)), & + + associate(prm => param(phase), & stt => damageState(phase)%state) - outputsLoop: do o = 1,size(prm%output) - select case(trim(prm%output(o))) - case ('f_phi') - call results_writeDataset(group,stt,trim(prm%output(o)),'driving force','J/m³') - end select - enddo outputsLoop + outputsLoop: do o = 1,size(prm%output) + select case(trim(prm%output(o))) + case ('f_phi') + call results_writeDataset(group,stt,trim(prm%output(o)),'driving force','J/m³') + end select + enddo outputsLoop end associate end subroutine isobrittle_results diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index 657f9da39..89211b746 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -6,9 +6,6 @@ !-------------------------------------------------------------------------------------------------- submodule(phase:damagee) isoductile - integer, dimension(:), allocatable :: & - source_damage_isoDuctile_instance !< instance of damage source mechanism - type:: tParameters !< container type for internal constitutive parameters real(pReal) :: & gamma_crit, & !< critical plastic strain @@ -48,17 +45,15 @@ module function isoductile_init(source_length) result(mySources) if(Ninstances == 0) return phases => config_material%get('phase') - allocate(param(Ninstances)) - allocate(source_damage_isoDuctile_instance(phases%length), source=0) + allocate(param(phases%length)) do p = 1, phases%length phase => phases%get(p) if(count(mySources(:,p)) == 0) cycle - if(any(mySources(:,p))) source_damage_isoDuctile_instance(p) = count(mySources(:,1:p)) sources => phase%get('damage') do sourceOffset = 1, sources%length if(mySources(sourceOffset,p)) then - associate(prm => param(source_damage_isoDuctile_instance(p))) + associate(prm => param(p)) src => sources%get(sourceOffset) prm%q = src%get_asFloat('q') @@ -110,8 +105,8 @@ module subroutine isoductile_dotState(co, ip, el) me = material_phasememberAt(co,ip,el) - associate(prm => param(source_damage_isoDuctile_instance(ph))) - damageState(ph)%dotState(1,me) = sum(plasticState(ph)%slipRate(:,me))/(phase_damage_get_phi(co,ip,el)**prm%q)/prm%gamma_crit + associate(prm => param(ph)) + damageState(ph)%dotState(1,me) = sum(plasticState(ph)%slipRate(:,me))/(damage_phi(ph,me)**prm%q)/prm%gamma_crit end associate end subroutine isoductile_dotState @@ -150,14 +145,13 @@ module subroutine isoductile_results(phase,group) integer :: o - associate(prm => param(source_damage_isoDuctile_instance(phase)), & - stt => damageState(phase)%state) - outputsLoop: do o = 1,size(prm%output) - select case(trim(prm%output(o))) - case ('f_phi') - call results_writeDataset(group,stt,trim(prm%output(o)),'driving force','J/m³') - end select - enddo outputsLoop + associate(prm => param(phase), stt => damageState(phase)%state) + outputsLoop: do o = 1,size(prm%output) + select case(trim(prm%output(o))) + case ('f_phi') + call results_writeDataset(group,stt,trim(prm%output(o)),'driving force','J/m³') + end select + enddo outputsLoop end associate end subroutine isoductile_results From d9699b0f2e2c5126871f62b4ad8ab3183fd14b1d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 11:01:08 +0100 Subject: [PATCH 231/352] simplified access pattern --- src/phase_damage.f90 | 92 ++++++++++++------------------- src/phase_damage_anisobrittle.f90 | 25 +++------ src/phase_damage_anisoductile.f90 | 24 +++----- src/phase_damage_isobrittle.f90 | 25 ++++----- src/phase_damage_isoductile.f90 | 23 +++----- 5 files changed, 71 insertions(+), 118 deletions(-) diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 5f323c3a2..803a9251d 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -43,82 +43,65 @@ submodule(phase) damagee end function isoductile_init - module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph, me) + module subroutine isobrittle_deltaState(C, Fe, ph, me) integer, intent(in) :: ph,me real(pReal), intent(in), dimension(3,3) :: & Fe real(pReal), intent(in), dimension(6,6) :: & C - end subroutine source_damage_isoBrittle_deltaState + end subroutine isobrittle_deltaState - module subroutine anisobrittle_dotState(S, co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + module subroutine anisobrittle_dotState(S, ph, me) + integer, intent(in) :: ph,me real(pReal), intent(in), dimension(3,3) :: & S end subroutine anisobrittle_dotState - module subroutine anisoductile_dotState(co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + module subroutine anisoductile_dotState(ph,me) + integer, intent(in) :: ph,me end subroutine anisoductile_dotState - module subroutine isoductile_dotState(co, ip, el) - integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + module subroutine isoductile_dotState(ph,me) + integer, intent(in) :: ph,me end subroutine isoductile_dotState - module subroutine source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - integer, intent(in) :: & - phase, & !< phase ID of element - constituent !< position of element within its phase instance + module subroutine anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) + integer, intent(in) :: ph,me real(pReal), intent(in) :: & phi !< damage parameter real(pReal), intent(out) :: & localphiDot, & dLocalphiDot_dPhi - end subroutine source_damage_anisoBrittle_getRateAndItsTangent + end subroutine anisobrittle_getRateAndItsTangent - module subroutine source_damage_anisoDuctile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - integer, intent(in) :: & - phase, & !< phase ID of element - constituent !< position of element within its phase instance + module subroutine anisoductile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph,me) + integer, intent(in) :: ph,me real(pReal), intent(in) :: & phi !< damage parameter real(pReal), intent(out) :: & localphiDot, & dLocalphiDot_dPhi - end subroutine source_damage_anisoDuctile_getRateAndItsTangent + end subroutine anisoductile_getRateAndItsTangent - module subroutine source_damage_isoBrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - integer, intent(in) :: & - phase, & !< phase ID of element - constituent !< position of element within its phase instance + module subroutine isobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph,me) + integer, intent(in) :: ph,me real(pReal), intent(in) :: & phi !< damage parameter real(pReal), intent(out) :: & localphiDot, & dLocalphiDot_dPhi - end subroutine source_damage_isoBrittle_getRateAndItsTangent + end subroutine isobrittle_getRateAndItsTangent - module subroutine source_damage_isoDuctile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) - integer, intent(in) :: & - phase, & !< phase ID of element - constituent !< position of element within its phase instance + module subroutine isoductile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph,me) + integer, intent(in) :: ph,me real(pReal), intent(in) :: & phi !< damage parameter real(pReal), intent(out) :: & localphiDot, & dLocalphiDot_dPhi - end subroutine source_damage_isoDuctile_getRateAndItsTangent + end subroutine isoductile_getRateAndItsTangent module subroutine anisobrittle_results(phase,group) integer, intent(in) :: phase @@ -225,16 +208,16 @@ module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, do so = 1, phase_Nsources(ph) select case(phase_source(so,ph)) case (DAMAGE_ISOBRITTLE_ID) - call source_damage_isobrittle_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, ph, me) + call isobrittle_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, ph, me) case (DAMAGE_ISODUCTILE_ID) - call source_damage_isoductile_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, ph, me) + call isoductile_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, ph, me) case (DAMAGE_ANISOBRITTLE_ID) - call source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) + call anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) case (DAMAGE_ANISODUCTILE_ID) - call source_damage_anisoductile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) + call anisoductile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) case default localphiDot = 0.0_pReal @@ -281,7 +264,7 @@ module function integrateDamageState(dt,co,ip,el) result(broken) me = material_phaseMemberAt(co,ip,el) converged_ = .true. - broken = phase_damage_collectDotState(co,ip,el,ph,me) + broken = phase_damage_collectDotState(ph,me) if(broken) return size_so = damageState(ph)%sizeDotState @@ -294,7 +277,7 @@ module function integrateDamageState(dt,co,ip,el) result(broken) if(nIterationState > 1) source_dotState(1:size_so,2) = source_dotState(1:size_so,1) source_dotState(1:size_so,1) = damageState(ph)%dotState(:,me) - broken = phase_damage_collectDotState(co,ip,el,ph,me) + broken = phase_damage_collectDotState(ph,me) if(broken) exit iteration @@ -384,39 +367,34 @@ end subroutine damage_results !-------------------------------------------------------------------------------------------------- !> @brief contains the constitutive equation for calculating the rate of change of microstructure !-------------------------------------------------------------------------------------------------- -function phase_damage_collectDotState(co,ip,el,ph,me) result(broken) +function phase_damage_collectDotState(ph,me) result(broken) integer, intent(in) :: & - co, & !< component-ID me integration point - ip, & !< integration point - el, & !< element ph, & - me - integer :: & - so !< counter in source loop + me !< counter in source loop logical :: broken broken = .false. - SourceLoop: do so = 1, phase_Nsources(ph) + if (phase_Nsources(ph)==1) then - sourceType: select case (phase_source(so,ph)) + sourceType: select case (phase_source(1,ph)) case (DAMAGE_ISODUCTILE_ID) sourceType - call isoductile_dotState(co, ip, el) + call isoductile_dotState(ph,me) case (DAMAGE_ANISODUCTILE_ID) sourceType - call anisoductile_dotState(co, ip, el) + call anisoductile_dotState(ph,me) case (DAMAGE_ANISOBRITTLE_ID) sourceType - call anisobrittle_dotState(mechanical_S(ph,me),co, ip, el) ! correct stress? + call anisobrittle_dotState(mechanical_S(ph,me), ph,me) ! correct stress? end select sourceType broken = broken .or. any(IEEE_is_NaN(damageState(ph)%dotState(:,me))) - enddo SourceLoop + endif end function phase_damage_collectDotState @@ -447,7 +425,7 @@ function phase_damage_deltaState(Fe, ph, me) result(broken) sourceType: select case (phase_source(1,ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType - call source_damage_isoBrittle_deltaState(phase_homogenizedC(ph,me), Fe, ph,me) + call isobrittle_deltaState(phase_homogenizedC(ph,me), Fe, ph,me) broken = any(IEEE_is_NaN(damageState(ph)%deltaState(:,me))) if(.not. broken) then myOffset = damageState(ph)%offsetDeltaState diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 81072e16d..a121ee932 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -113,18 +113,14 @@ end function anisobrittle_init !-------------------------------------------------------------------------------------------------- !> @brief calculates derived quantities from state !-------------------------------------------------------------------------------------------------- -module subroutine anisobrittle_dotState(S, co, ip, el) +module subroutine anisobrittle_dotState(S, ph,me) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + ph,me real(pReal), intent(in), dimension(3,3) :: & S integer :: & - ph, & - me, & sourceOffset, & damageOffset, & homog, & @@ -133,10 +129,6 @@ module subroutine anisobrittle_dotState(S, co, ip, el) traction_d, traction_t, traction_n, traction_crit - ph = material_phaseAt(co,el) - me = material_phasememberAt(co,ip,el) - - associate(prm => param(ph)) damageState(ph)%dotState(1,me) = 0.0_pReal do i = 1, prm%sum_N_cl @@ -144,7 +136,7 @@ module subroutine anisobrittle_dotState(S, co, ip, el) traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) traction_n = math_tensordot(S,prm%cleavage_systems(1:3,1:3,3,i)) - traction_crit = prm%g_crit(i)*phase_damage_get_phi(co,ip,el)**2.0_pReal + traction_crit = prm%g_crit(i)*damage_phi(ph,me)**2.0_pReal damageState(ph)%dotState(1,me) = damageState(ph)%dotState(1,me) & + prm%dot_o / prm%s_crit(i) & @@ -160,11 +152,11 @@ end subroutine anisobrittle_dotState !-------------------------------------------------------------------------------------------------- !> @brief returns local part of nonlocal damage driving force !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) +module subroutine anisobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) integer, intent(in) :: & - phase, & - constituent + ph, & + me real(pReal), intent(in) :: & phi real(pReal), intent(out) :: & @@ -172,12 +164,12 @@ module subroutine source_damage_anisobrittle_getRateAndItsTangent(localphiDot, d dLocalphiDot_dPhi - dLocalphiDot_dPhi = -damageState(phase)%state(1,constituent) + dLocalphiDot_dPhi = -damageState(ph)%state(1,me) localphiDot = 1.0_pReal & + dLocalphiDot_dPhi*phi -end subroutine source_damage_anisoBrittle_getRateAndItsTangent +end subroutine anisobrittle_getRateAndItsTangent !-------------------------------------------------------------------------------------------------- @@ -190,6 +182,7 @@ module subroutine anisobrittle_results(phase,group) integer :: o + associate(prm => param(phase), stt => damageState(phase)%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index 4d2392589..cf55e398b 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -99,20 +99,12 @@ end function anisoductile_init !-------------------------------------------------------------------------------------------------- !> @brief calculates derived quantities from state !-------------------------------------------------------------------------------------------------- -module subroutine anisoductile_dotState(co, ip, el) +module subroutine anisoductile_dotState(ph,me) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - - integer :: & ph, & me - ph = material_phaseAt(co,el) - me = material_phasememberAt(co,ip,el) - associate(prm => param(ph)) damageState(ph)%dotState(1,me) = sum(plasticState(ph)%slipRate(:,me)/(damage_phi(ph,me)**prm%q)/prm%gamma_crit) @@ -124,11 +116,11 @@ end subroutine anisoductile_dotState !-------------------------------------------------------------------------------------------------- !> @brief returns local part of nonlocal damage driving force !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_anisoDuctile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) +module subroutine anisoductile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph,me) integer, intent(in) :: & - phase, & - constituent + ph, & + me real(pReal), intent(in) :: & phi real(pReal), intent(out) :: & @@ -136,12 +128,12 @@ module subroutine source_damage_anisoDuctile_getRateAndItsTangent(localphiDot, d dLocalphiDot_dPhi - dLocalphiDot_dPhi = -damageState(phase)%state(1,constituent) + dLocalphiDot_dPhi = -damageState(ph)%state(1,me) localphiDot = 1.0_pReal & + dLocalphiDot_dPhi*phi -end subroutine source_damage_anisoDuctile_getRateAndItsTangent +end subroutine anisoductile_getRateAndItsTangent !-------------------------------------------------------------------------------------------------- @@ -154,8 +146,8 @@ module subroutine anisoductile_results(phase,group) integer :: o - associate(prm => param(phase), & - stt => damageState(phase)%state) + + associate(prm => param(phase), stt => damageState(phase)%state) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('f_phi') diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 4e37f3ee9..e267ffcc9 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -86,7 +86,7 @@ end function isobrittle_init !-------------------------------------------------------------------------------------------------- !> @brief calculates derived quantities from state !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph,me) +module subroutine isobrittle_deltaState(C, Fe, ph,me) integer, intent(in) :: ph,me real(pReal), intent(in), dimension(3,3) :: & @@ -106,24 +106,21 @@ module subroutine source_damage_isoBrittle_deltaState(C, Fe, ph,me) strainenergy = 2.0_pReal*sum(strain*matmul(C,strain))/prm%W_crit ! ToDo: check strainenergy = 2.0_pReal*dot_product(strain,matmul(C,strain))/prm%W_crit - if (strainenergy > damageState(ph)%subState0(1,me)) then - damageState(ph)%deltaState(1,me) = strainenergy - damageState(ph)%state(1,me) - else - damageState(ph)%deltaState(1,me) = damageState(ph)%subState0(1,me) - damageState(ph)%state(1,me) - endif + damageState(ph)%deltaState(1,me) = merge(strainenergy - damageState(ph)%state(1,me), & + damageState(ph)%subState0(1,me) - damageState(ph)%state(1,me), & + strainenergy > damageState(ph)%subState0(1,me)) end associate -end subroutine source_damage_isoBrittle_deltaState +end subroutine isobrittle_deltaState !-------------------------------------------------------------------------------------------------- !> @brief returns local part of nonlocal damage driving force !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_isoBrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) +module subroutine isobrittle_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) integer, intent(in) :: & - phase, & - constituent + ph, me real(pReal), intent(in) :: & phi real(pReal), intent(out) :: & @@ -131,13 +128,13 @@ module subroutine source_damage_isoBrittle_getRateAndItsTangent(localphiDot, dLo dLocalphiDot_dPhi - associate(prm => param(phase)) + associate(prm => param(ph)) localphiDot = 1.0_pReal & - - phi*damageState(phase)%state(1,constituent) - dLocalphiDot_dPhi = - damageState(phase)%state(1,constituent) + - phi*damageState(ph)%state(1,me) + dLocalphiDot_dPhi = - damageState(ph)%state(1,me) end associate -end subroutine source_damage_isoBrittle_getRateAndItsTangent +end subroutine isobrittle_getRateAndItsTangent !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index 89211b746..f59952222 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -90,23 +90,16 @@ end function isoductile_init !-------------------------------------------------------------------------------------------------- !> @brief calculates derived quantities from state !-------------------------------------------------------------------------------------------------- -module subroutine isoductile_dotState(co, ip, el) +module subroutine isoductile_dotState(ph, me) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element - - integer :: & ph, & me - ph = material_phaseAt(co,el) - me = material_phasememberAt(co,ip,el) - associate(prm => param(ph)) - damageState(ph)%dotState(1,me) = sum(plasticState(ph)%slipRate(:,me))/(damage_phi(ph,me)**prm%q)/prm%gamma_crit + damageState(ph)%dotState(1,me) = sum(plasticState(ph)%slipRate(:,me)) & + / (prm%gamma_crit*damage_phi(ph,me)**prm%q) end associate end subroutine isoductile_dotState @@ -115,11 +108,11 @@ end subroutine isoductile_dotState !-------------------------------------------------------------------------------------------------- !> @brief returns local part of nonlocal damage driving force !-------------------------------------------------------------------------------------------------- -module subroutine source_damage_isoDuctile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, phase, constituent) +module subroutine isoductile_getRateAndItsTangent(localphiDot, dLocalphiDot_dPhi, phi, ph, me) integer, intent(in) :: & - phase, & - constituent + ph, & + me real(pReal), intent(in) :: & phi real(pReal), intent(out) :: & @@ -127,12 +120,12 @@ module subroutine source_damage_isoDuctile_getRateAndItsTangent(localphiDot, dLo dLocalphiDot_dPhi - dLocalphiDot_dPhi = -damageState(phase)%state(1,constituent) + dLocalphiDot_dPhi = -damageState(ph)%state(1,me) localphiDot = 1.0_pReal & + dLocalphiDot_dPhi*phi -end subroutine source_damage_isoDuctile_getRateAndItsTangent +end subroutine isoductile_getRateAndItsTangent !-------------------------------------------------------------------------------------------------- From 570086c814c22062bfd7b9582b64d805c6ae970b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 12:44:47 +0100 Subject: [PATCH 232/352] hard code at max 1 damage mechanism --- src/homogenization.f90 | 4 +- src/phase_damage.f90 | 61 ++++++++++++++----------------- src/phase_damage_anisobrittle.f90 | 18 ++++----- src/phase_damage_anisoductile.f90 | 29 +++++++-------- src/phase_damage_isobrittle.f90 | 20 +++++----- src/phase_damage_isoductile.f90 | 23 +++++------- 6 files changed, 70 insertions(+), 85 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 073482c9a..3e1b939b5 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -257,8 +257,8 @@ subroutine homogenization_init() allocate(homogState (size(material_name_homogenization))) allocate(damageState_h (size(material_name_homogenization))) - call material_parseHomogenization - print*, 'Homogenization parsed' + call material_parseHomogenization + num_homog => config_numerics%get('homogenization',defaultVal=emptyDict) num_homogGeneric => num_homog%get('generic',defaultVal=emptyDict) diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 803a9251d..ca08d8aea 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -15,31 +15,27 @@ submodule(phase) damagee real(pReal), dimension(:), allocatable :: phi, d_phi_d_dot_phi end type tDataContainer - integer(kind(DAMAGE_UNDEFINED_ID)), dimension(:,:), allocatable :: & + integer(kind(DAMAGE_UNDEFINED_ID)), dimension(:), allocatable :: & phase_source !< active sources mechanisms of each phase type(tDataContainer), dimension(:), allocatable :: current interface - module function anisobrittle_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources + module function anisobrittle_init() result(mySources) + logical, dimension(:), allocatable :: mySources end function anisobrittle_init - module function anisoductile_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources + module function anisoductile_init() result(mySources) + logical, dimension(:), allocatable :: mySources end function anisoductile_init - module function isobrittle_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources + module function isobrittle_init() result(mySources) + logical, dimension(:), allocatable :: mySources end function isobrittle_init - module function isoductile_init(source_length) result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources + module function isoductile_init() result(mySources) + logical, dimension(:), allocatable :: mySources end function isoductile_init @@ -163,14 +159,14 @@ module subroutine damage_init enddo - allocate(phase_source(maxval(phase_Nsources),phases%length), source = DAMAGE_UNDEFINED_ID) + allocate(phase_source(phases%length), source = DAMAGE_UNDEFINED_ID) ! initialize source mechanisms if(maxval(phase_Nsources) /= 0) then - where(isobrittle_init (maxval(phase_Nsources))) phase_source = DAMAGE_ISOBRITTLE_ID - where(isoductile_init (maxval(phase_Nsources))) phase_source = DAMAGE_ISODUCTILE_ID - where(anisobrittle_init (maxval(phase_Nsources))) phase_source = DAMAGE_ANISOBRITTLE_ID - where(anisoductile_init (maxval(phase_Nsources))) phase_source = DAMAGE_ANISODUCTILE_ID + where(isobrittle_init() ) phase_source = DAMAGE_ISOBRITTLE_ID + where(isoductile_init() ) phase_source = DAMAGE_ISODUCTILE_ID + where(anisobrittle_init()) phase_source = DAMAGE_ANISOBRITTLE_ID + where(anisoductile_init()) phase_source = DAMAGE_ANISODUCTILE_ID endif end subroutine damage_init @@ -206,7 +202,7 @@ module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) do so = 1, phase_Nsources(ph) - select case(phase_source(so,ph)) + select case(phase_source(ph)) case (DAMAGE_ISOBRITTLE_ID) call isobrittle_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, ph, me) @@ -340,10 +336,10 @@ module subroutine damage_results(group,ph) sourceLoop: do so = 1, phase_Nsources(ph) - if (phase_source(so,ph) /= DAMAGE_UNDEFINED_ID) & + if (phase_source(ph) /= DAMAGE_UNDEFINED_ID) & call results_closeGroup(results_addGroup(group//'sources/')) ! should be 'damage' - sourceType: select case (phase_source(so,ph)) + sourceType: select case (phase_source(ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType call isobrittle_results(ph,group//'sources/') @@ -379,7 +375,7 @@ function phase_damage_collectDotState(ph,me) result(broken) if (phase_Nsources(ph)==1) then - sourceType: select case (phase_source(1,ph)) + sourceType: select case (phase_source(ph)) case (DAMAGE_ISODUCTILE_ID) sourceType call isoductile_dotState(ph,me) @@ -422,7 +418,7 @@ function phase_damage_deltaState(Fe, ph, me) result(broken) if (phase_Nsources(ph) == 0) return - sourceType: select case (phase_source(1,ph)) + sourceType: select case (phase_source(ph)) case (DAMAGE_ISOBRITTLE_ID) sourceType call isobrittle_deltaState(phase_homogenizedC(ph,me), Fe, ph,me) @@ -443,28 +439,25 @@ end function phase_damage_deltaState !-------------------------------------------------------------------------------------------------- !> @brief checks if a source mechanism is active or not !-------------------------------------------------------------------------------------------------- -function source_active(source_label,src_length) result(active_source) +function source_active(source_label) result(active_source) character(len=*), intent(in) :: source_label !< name of source mechanism - integer, intent(in) :: src_length !< max. number of sources in system - logical, dimension(:,:), allocatable :: active_source + logical, dimension(:), allocatable :: active_source class(tNode), pointer :: & phases, & phase, & sources, & src - integer :: p,s + integer :: ph phases => config_material%get('phase') - allocate(active_source(src_length,phases%length), source = .false. ) - do p = 1, phases%length - phase => phases%get(p) + allocate(active_source(phases%length)) + do ph = 1, phases%length + phase => phases%get(ph) sources => phase%get('damage',defaultVal=emptyList) - do s = 1, sources%length - src => sources%get(s) - if(src%get_asString('type') == source_label) active_source(s,p) = .true. - enddo + src => sources%get(1) + active_source(ph) = src%get_asString('type') == source_label enddo diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index a121ee932..07dd42945 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -31,23 +31,22 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function anisobrittle_init(source_length) result(mySources) +module function anisobrittle_init() result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources + logical, dimension(:), allocatable :: mySources class(tNode), pointer :: & phases, & phase, & sources, & src - integer :: Ninstances,sourceOffset,Nconstituents,p + integer :: Ninstances,Nconstituents,p integer, dimension(:), allocatable :: N_cl character(len=pStringLen) :: extmsg = '' print'(/,a)', ' <<<+- phase:damage:anisobrittle init -+>>>' - mySources = source_active('anisobrittle',source_length) + mySources = source_active('anisobrittle') Ninstances = count(mySources) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -57,13 +56,12 @@ module function anisobrittle_init(source_length) result(mySources) do p = 1, phases%length + if(mySources(p)) then phase => phases%get(p) - if(count(mySources(:,p)) == 0) cycle sources => phase%get('damage') - do sourceOffset = 1, sources%length - if(mySources(sourceOffset,p)) then + associate(prm => param(p)) - src => sources%get(sourceOffset) + src => sources%get(1) N_cl = src%get_asInts('N_cl',defaultVal=emptyIntArray) prm%sum_N_cl = sum(abs(N_cl)) @@ -104,7 +102,7 @@ module function anisobrittle_init(source_length) result(mySources) ! exit if any parameter is out of range if (extmsg /= '') call IO_error(211,ext_msg=trim(extmsg)//'(damage_anisoBrittle)') endif - enddo + enddo end function anisobrittle_init diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index cf55e398b..aad361238 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -24,10 +24,9 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function anisoductile_init(source_length) result(mySources) +module function anisoductile_init() result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources + logical, dimension(:), allocatable :: mySources class(tNode), pointer :: & phases, & @@ -36,13 +35,13 @@ module function anisoductile_init(source_length) result(mySources) pl, & sources, & src - integer :: Ninstances,sourceOffset,Nconstituents,p + integer :: Ninstances,Nconstituents,p integer, dimension(:), allocatable :: N_sl character(len=pStringLen) :: extmsg = '' print'(/,a)', ' <<<+- phase:damage:anisoductile init -+>>>' - mySources = source_active('damage_anisoDuctile',source_length) + mySources = source_active('damage_anisoDuctile') Ninstances = count(mySources) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -51,15 +50,15 @@ module function anisoductile_init(source_length) result(mySources) allocate(param(phases%length)) do p = 1, phases%length - phase => phases%get(p) - if(count(mySources(:,p)) == 0) cycle - mech => phase%get('mechanics') - pl => mech%get('plasticity') - sources => phase%get('source') - do sourceOffset = 1, sources%length - if(mySources(sourceOffset,p)) then + if(mySources(p)) then + phase => phases%get(p) + mech => phase%get('mechanics') + pl => mech%get('plasticity') + sources => phase%get('damage') + + associate(prm => param(p)) - src => sources%get(sourceOffset) + src => sources%get(1) N_sl = pl%get_asInts('N_sl',defaultVal=emptyIntArray) prm%q = src%get_asFloat('q') @@ -78,7 +77,7 @@ module function anisoductile_init(source_length) result(mySources) if (prm%q <= 0.0_pReal) extmsg = trim(extmsg)//' q' if (any(prm%gamma_crit < 0.0_pReal)) extmsg = trim(extmsg)//' gamma_crit' - Nconstituents=count(material_phaseAt==p) * discretization_nIPs + Nconstituents=count(material_phaseAt2==p) call phase_allocateState(damageState(p),Nconstituents,1,1,0) damageState(p)%atol = src%get_asFloat('anisoDuctile_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisoductile_atol' @@ -89,7 +88,7 @@ module function anisoductile_init(source_length) result(mySources) ! exit if any parameter is out of range if (extmsg /= '') call IO_error(211,ext_msg=trim(extmsg)//'(damage_anisoDuctile)') endif - enddo + enddo diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index e267ffcc9..973817ec6 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -22,22 +22,21 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function isobrittle_init(source_length) result(mySources) +module function isobrittle_init() result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources + logical, dimension(:), allocatable :: mySources class(tNode), pointer :: & phases, & phase, & sources, & src - integer :: Ninstances,sourceOffset,Nconstituents,p + integer :: Ninstances,Nconstituents,p character(len=pStringLen) :: extmsg = '' print'(/,a)', ' <<<+- phase:damage:isobrittle init -+>>>' - mySources = source_active('isobrittle',source_length) + mySources = source_active('isobrittle') Ninstances = count(mySources) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -46,13 +45,12 @@ module function isobrittle_init(source_length) result(mySources) allocate(param(phases%length)) do p = 1, phases%length + if(mySources(p)) then phase => phases%get(p) - if(count(mySources(:,p)) == 0) cycle sources => phase%get('damage') - do sourceOffset = 1, sources%length - if(mySources(sourceOffset,p)) then + associate(prm => param(p)) - src => sources%get(sourceOffset) + src => sources%get(1) prm%W_crit = src%get_asFloat('W_crit') @@ -65,7 +63,7 @@ module function isobrittle_init(source_length) result(mySources) ! sanity checks if (prm%W_crit <= 0.0_pReal) extmsg = trim(extmsg)//' W_crit' - Nconstituents = count(material_phaseAt==p) * discretization_nIPs + Nconstituents = count(material_phaseAt2==p) call phase_allocateState(damageState(p),Nconstituents,1,1,1) damageState(p)%atol = src%get_asFloat('isoBrittle_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isobrittle_atol' @@ -76,7 +74,7 @@ module function isobrittle_init(source_length) result(mySources) ! exit if any parameter is out of range if (extmsg /= '') call IO_error(211,ext_msg=trim(extmsg)//'(damage_isoBrittle)') endif - enddo + enddo diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index f59952222..abcef1236 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -24,22 +24,21 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function isoductile_init(source_length) result(mySources) +module function isoductile_init() result(mySources) - integer, intent(in) :: source_length - logical, dimension(:,:), allocatable :: mySources + logical, dimension(:), allocatable :: mySources class(tNode), pointer :: & phases, & phase, & sources, & src - integer :: Ninstances,sourceOffset,Nconstituents,p + integer :: Ninstances,Nconstituents,p character(len=pStringLen) :: extmsg = '' print'(/,a)', ' <<<+- phase:damage:isoductile init -+>>>' - mySources = source_active('isoductile',source_length) + mySources = source_active('isoductile') Ninstances = count(mySources) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return @@ -48,13 +47,12 @@ module function isoductile_init(source_length) result(mySources) allocate(param(phases%length)) do p = 1, phases%length - phase => phases%get(p) - if(count(mySources(:,p)) == 0) cycle - sources => phase%get('damage') - do sourceOffset = 1, sources%length - if(mySources(sourceOffset,p)) then + if(mySources(p)) then + phase => phases%get(p) + sources => phase%get('damage') + associate(prm => param(p)) - src => sources%get(sourceOffset) + src => sources%get(1) prm%q = src%get_asFloat('q') prm%gamma_crit = src%get_asFloat('gamma_crit') @@ -69,7 +67,7 @@ module function isoductile_init(source_length) result(mySources) if (prm%q <= 0.0_pReal) extmsg = trim(extmsg)//' q' if (prm%gamma_crit <= 0.0_pReal) extmsg = trim(extmsg)//' gamma_crit' - Nconstituents=count(material_phaseAt==p) * discretization_nIPs + Nconstituents=count(material_phaseAt2==p) call phase_allocateState(damageState(p),Nconstituents,1,1,0) damageState(p)%atol = src%get_asFloat('isoDuctile_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isoductile_atol' @@ -80,7 +78,6 @@ module function isoductile_init(source_length) result(mySources) ! exit if any parameter is out of range if (extmsg /= '') call IO_error(211,ext_msg=trim(extmsg)//'(damage_isoDuctile)') endif - enddo enddo From ab202b8e7314ca2a1049a2e4195744d9eae8de98 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 13:07:35 +0100 Subject: [PATCH 233/352] less verbose reporting --- src/phase_damage_anisobrittle.f90 | 11 +++++---- src/phase_damage_anisoductile.f90 | 11 +++++---- src/phase_damage_isobrittle.f90 | 11 +++++---- src/phase_damage_isoductile.f90 | 9 +++---- ...phase_mechanical_plastic_dislotungsten.f90 | 7 +++--- src/phase_mechanical_plastic_dislotwin.f90 | 6 ++--- src/phase_mechanical_plastic_isotropic.f90 | 7 +++--- ...phase_mechanical_plastic_kinehardening.f90 | 7 +++--- src/phase_mechanical_plastic_none.f90 | 24 +++++-------------- src/phase_mechanical_plastic_nonlocal.f90 | 6 ++--- ...phase_mechanical_plastic_phenopowerlaw.f90 | 6 +++-- 11 files changed, 51 insertions(+), 54 deletions(-) diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 07dd42945..bfd069031 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -40,16 +40,17 @@ module function anisobrittle_init() result(mySources) phase, & sources, & src - integer :: Ninstances,Nconstituents,p + integer :: Nconstituents,p integer, dimension(:), allocatable :: N_cl character(len=pStringLen) :: extmsg = '' - print'(/,a)', ' <<<+- phase:damage:anisobrittle init -+>>>' mySources = source_active('anisobrittle') - Ninstances = count(mySources) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - if(Ninstances == 0) return + if(count(mySources) == 0) return + + print'(/,a)', ' <<<+- phase:damage:anisobrittle init -+>>>' + print'(a,i0)', ' # phases: ',count(mySources); flush(IO_STDOUT) + phases => config_material%get('phase') allocate(param(phases%length)) diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index aad361238..f50c05f07 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -39,12 +39,13 @@ module function anisoductile_init() result(mySources) integer, dimension(:), allocatable :: N_sl character(len=pStringLen) :: extmsg = '' - print'(/,a)', ' <<<+- phase:damage:anisoductile init -+>>>' - mySources = source_active('damage_anisoDuctile') - Ninstances = count(mySources) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - if(Ninstances == 0) return + mySources = source_active('anisoductile') + if(count(mySources) == 0) return + + print'(/,a)', ' <<<+- phase:damage:anisoductile init -+>>>' + print'(a,i0)', ' # phases: ',count(mySources); flush(IO_STDOUT) + phases => config_material%get('phase') allocate(param(phases%length)) diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 973817ec6..1cc0d7900 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -31,15 +31,16 @@ module function isobrittle_init() result(mySources) phase, & sources, & src - integer :: Ninstances,Nconstituents,p + integer :: Nconstituents,p character(len=pStringLen) :: extmsg = '' - print'(/,a)', ' <<<+- phase:damage:isobrittle init -+>>>' mySources = source_active('isobrittle') - Ninstances = count(mySources) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - if(Ninstances == 0) return + if(count(mySources) == 0) return + + print'(/,a)', ' <<<+- phase:damage:isobrittle init -+>>>' + print'(a,i0)', ' # phases: ',count(mySources); flush(IO_STDOUT) + phases => config_material%get('phase') allocate(param(phases%length)) diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index abcef1236..247cd715a 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -36,12 +36,13 @@ module function isoductile_init() result(mySources) integer :: Ninstances,Nconstituents,p character(len=pStringLen) :: extmsg = '' - print'(/,a)', ' <<<+- phase:damage:isoductile init -+>>>' mySources = source_active('isoductile') - Ninstances = count(mySources) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - if(Ninstances == 0) return + if(count(mySources) == 0) return + + print'(/,a)', ' <<<+- phase:damage:isoductile init -+>>>' + print'(a,i0)', ' # phases: ',count(mySources); flush(IO_STDOUT) + phases => config_material%get('phase') allocate(param(phases%length)) diff --git a/src/phase_mechanical_plastic_dislotungsten.f90 b/src/phase_mechanical_plastic_dislotungsten.f90 index a9946b6e7..4db546b67 100644 --- a/src/phase_mechanical_plastic_dislotungsten.f90 +++ b/src/phase_mechanical_plastic_dislotungsten.f90 @@ -97,13 +97,14 @@ module function plastic_dislotungsten_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- phase:mechanics:plastic:dislotungsten init -+>>>' - myPlasticity = plastic_active('dislotungsten') Ninstances = count(myPlasticity) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return + print'(/,a)', ' <<<+- phase:mechanics:plastic:dislotungsten init -+>>>' + print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) + + print*, 'Cereceda et al., International Journal of Plasticity 78:242–256, 2016' print*, 'https://dx.doi.org/10.1016/j.ijplas.2015.09.002' diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index e1259fbd2..2a011dfda 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -144,13 +144,13 @@ module function plastic_dislotwin_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- phase:mechanics:plastic:dislotwin init -+>>>' - myPlasticity = plastic_active('dislotwin') Ninstances = count(myPlasticity) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return + print'(/,a)', ' <<<+- phase:mechanics:plastic:dislotwin init -+>>>' + print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) + print*, 'Ma and Roters, Acta Materialia 52(12):3603–3612, 2004' print*, 'https://doi.org/10.1016/j.actamat.2004.04.012'//IO_EOL diff --git a/src/phase_mechanical_plastic_isotropic.f90 b/src/phase_mechanical_plastic_isotropic.f90 index 1a4e1449a..4cb1bf28c 100644 --- a/src/phase_mechanical_plastic_isotropic.f90 +++ b/src/phase_mechanical_plastic_isotropic.f90 @@ -68,13 +68,14 @@ module function plastic_isotropic_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- phase:mechanics:plastic:isotropic init -+>>>' - myPlasticity = plastic_active('isotropic') Ninstances = count(myPlasticity) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return + print'(/,a)', ' <<<+- phase:mechanics:plastic:isotropic init -+>>>' + print'(a,i0)', ' # phses: ',Ninstances; flush(IO_STDOUT) + + print*, 'Maiti and Eisenlohr, Scripta Materialia 145:37–40, 2018' print*, 'https://doi.org/10.1016/j.scriptamat.2017.09.047' diff --git a/src/phase_mechanical_plastic_kinehardening.f90 b/src/phase_mechanical_plastic_kinehardening.f90 index f00e4171b..0ef762ffe 100644 --- a/src/phase_mechanical_plastic_kinehardening.f90 +++ b/src/phase_mechanical_plastic_kinehardening.f90 @@ -80,13 +80,14 @@ module function plastic_kinehardening_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- phase:mechanics:plastic:kinehardening init -+>>>' - myPlasticity = plastic_active('kinehardening') Ninstances = count(myPlasticity) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return + print'(/,a)', ' <<<+- phase:mechanics:plastic:kinehardening init -+>>>' + print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) + + allocate(param(Ninstances)) allocate(state(Ninstances)) allocate(dotState(Ninstances)) diff --git a/src/phase_mechanical_plastic_none.f90 b/src/phase_mechanical_plastic_none.f90 index b95eaa039..053fe6507 100644 --- a/src/phase_mechanical_plastic_none.f90 +++ b/src/phase_mechanical_plastic_none.f90 @@ -16,32 +16,20 @@ module function plastic_none_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - Ninstances, & p, & Nconstituents class(tNode), pointer :: & - phases, & - phase, & - mech, & - pl + phases + + + myPlasticity = plastic_active('nonlocal') + if(count(myPlasticity) == 0) return print'(/,a)', ' <<<+- phase:mechanics:plastic:none init -+>>>' + print'(a,i0)', ' # phases: ',count(myPlasticity); flush(IO_STDOUT) phases => config_material%get('phase') - allocate(myPlasticity(phases%length), source = .false.) do p = 1, phases%length - phase => phases%get(p) - mech => phase%get('mechanics') - pl => mech%get ('plasticity') - if(pl%get_asString('type') == 'none') myPlasticity(p) = .true. - enddo - - Ninstances = count(myPlasticity) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - if(Ninstances == 0) return - - do p = 1, phases%length - phase => phases%get(p) if(.not. myPlasticity(p)) cycle Nconstituents = count(material_phaseAt2 == p) call phase_allocateState(plasticState(p),Nconstituents,0,0,0) diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 724086916..5cfd9cf4d 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -187,16 +187,16 @@ module function plastic_nonlocal_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- phase:mechanics:plastic:nonlocal init -+>>>' - myPlasticity = plastic_active('nonlocal') Ninstances = count(myPlasticity) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) then call geometry_plastic_nonlocal_disable return endif + print'(/,a)', ' <<<+- phase:mechanics:plastic:nonlocal init -+>>>' + print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) + print*, 'Reuber et al., Acta Materialia 71:333–348, 2014' print*, 'https://doi.org/10.1016/j.actamat.2014.03.012'//IO_EOL diff --git a/src/phase_mechanical_plastic_phenopowerlaw.f90 b/src/phase_mechanical_plastic_phenopowerlaw.f90 index f9791faa6..6a7d5ea7f 100644 --- a/src/phase_mechanical_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanical_plastic_phenopowerlaw.f90 @@ -89,13 +89,15 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) mech, & pl - print'(/,a)', ' <<<+- phase:mechanics:plastic:phenopowerlaw init -+>>>' myPlasticity = plastic_active('phenopowerlaw') Ninstances = count(myPlasticity) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) if(Ninstances == 0) return + print'(/,a)', ' <<<+- phase:mechanics:plastic:phenopowerlaw init -+>>>' + print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) + + allocate(param(Ninstances)) allocate(state(Ninstances)) allocate(dotState(Ninstances)) From 9ba185973fe539d530ab40276dc6624117661002 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 13:33:58 +0100 Subject: [PATCH 234/352] more systematic directory structure --- PRIVATE | 2 +- examples/{SpectralMethod/Polycrystal => grid}/20grains.seeds | 0 .../{SpectralMethod/Polycrystal => grid}/20grains16x16x16.vtr | 0 .../{SpectralMethod/Polycrystal => grid}/20grains32x32x32.vtr | 0 .../{SpectralMethod/Polycrystal => grid}/20grains64x64x64.vtr | 0 examples/{SpectralMethod/Polycrystal => grid}/material.yaml | 0 examples/{SpectralMethod/Polycrystal => grid}/numerics.yaml | 0 examples/{SpectralMethod/Polycrystal => grid}/shearXY.yaml | 0 examples/{SpectralMethod/Polycrystal => grid}/shearZX.yaml | 0 examples/{SpectralMethod/Polycrystal => grid}/tensionX.yaml | 0 10 files changed, 1 insertion(+), 1 deletion(-) rename examples/{SpectralMethod/Polycrystal => grid}/20grains.seeds (100%) rename examples/{SpectralMethod/Polycrystal => grid}/20grains16x16x16.vtr (100%) rename examples/{SpectralMethod/Polycrystal => grid}/20grains32x32x32.vtr (100%) rename examples/{SpectralMethod/Polycrystal => grid}/20grains64x64x64.vtr (100%) rename examples/{SpectralMethod/Polycrystal => grid}/material.yaml (100%) rename examples/{SpectralMethod/Polycrystal => grid}/numerics.yaml (100%) rename examples/{SpectralMethod/Polycrystal => grid}/shearXY.yaml (100%) rename examples/{SpectralMethod/Polycrystal => grid}/shearZX.yaml (100%) rename examples/{SpectralMethod/Polycrystal => grid}/tensionX.yaml (100%) diff --git a/PRIVATE b/PRIVATE index 571b06ac4..d7f8460aa 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 571b06ac4b42ed217eacfa5c71281e571bdab1df +Subproject commit d7f8460aa2afceb89f9b82054555d5dc6f9e5c43 diff --git a/examples/SpectralMethod/Polycrystal/20grains.seeds b/examples/grid/20grains.seeds similarity index 100% rename from examples/SpectralMethod/Polycrystal/20grains.seeds rename to examples/grid/20grains.seeds diff --git a/examples/SpectralMethod/Polycrystal/20grains16x16x16.vtr b/examples/grid/20grains16x16x16.vtr similarity index 100% rename from examples/SpectralMethod/Polycrystal/20grains16x16x16.vtr rename to examples/grid/20grains16x16x16.vtr diff --git a/examples/SpectralMethod/Polycrystal/20grains32x32x32.vtr b/examples/grid/20grains32x32x32.vtr similarity index 100% rename from examples/SpectralMethod/Polycrystal/20grains32x32x32.vtr rename to examples/grid/20grains32x32x32.vtr diff --git a/examples/SpectralMethod/Polycrystal/20grains64x64x64.vtr b/examples/grid/20grains64x64x64.vtr similarity index 100% rename from examples/SpectralMethod/Polycrystal/20grains64x64x64.vtr rename to examples/grid/20grains64x64x64.vtr diff --git a/examples/SpectralMethod/Polycrystal/material.yaml b/examples/grid/material.yaml similarity index 100% rename from examples/SpectralMethod/Polycrystal/material.yaml rename to examples/grid/material.yaml diff --git a/examples/SpectralMethod/Polycrystal/numerics.yaml b/examples/grid/numerics.yaml similarity index 100% rename from examples/SpectralMethod/Polycrystal/numerics.yaml rename to examples/grid/numerics.yaml diff --git a/examples/SpectralMethod/Polycrystal/shearXY.yaml b/examples/grid/shearXY.yaml similarity index 100% rename from examples/SpectralMethod/Polycrystal/shearXY.yaml rename to examples/grid/shearXY.yaml diff --git a/examples/SpectralMethod/Polycrystal/shearZX.yaml b/examples/grid/shearZX.yaml similarity index 100% rename from examples/SpectralMethod/Polycrystal/shearZX.yaml rename to examples/grid/shearZX.yaml diff --git a/examples/SpectralMethod/Polycrystal/tensionX.yaml b/examples/grid/tensionX.yaml similarity index 100% rename from examples/SpectralMethod/Polycrystal/tensionX.yaml rename to examples/grid/tensionX.yaml From b3231bf0a82989e3c90e422feba9fb389766b771 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 14:15:41 +0100 Subject: [PATCH 235/352] avoid undefined return --- src/phase_damage.f90 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index ca08d8aea..2eda9540d 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -256,16 +256,20 @@ module function integrateDamageState(dt,co,ip,el) result(broken) converged_ ph = material_phaseAt(co,el) - if (phase_Nsources(ph) == 0) return me = material_phaseMemberAt(co,ip,el) + if (phase_Nsources(ph) == 0) then + broken = .false. + return + endif + converged_ = .true. broken = phase_damage_collectDotState(ph,me) if(broken) return size_so = damageState(ph)%sizeDotState damageState(ph)%state(1:size_so,me) = damageState(ph)%subState0(1:size_so,me) & - + damageState(ph)%dotState (1:size_so,me) * dt + + damageState(ph)%dotState (1:size_so,me) * dt source_dotState(1:size_so,2) = 0.0_pReal iteration: do NiterationState = 1, num%nState From 595ee7a35a3d4519d30b28e8a030a10764453362 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 14:38:53 +0100 Subject: [PATCH 236/352] copy and paste error --- src/phase_mechanical_plastic_none.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phase_mechanical_plastic_none.f90 b/src/phase_mechanical_plastic_none.f90 index 053fe6507..f16cf98fb 100644 --- a/src/phase_mechanical_plastic_none.f90 +++ b/src/phase_mechanical_plastic_none.f90 @@ -22,7 +22,7 @@ module function plastic_none_init() result(myPlasticity) phases - myPlasticity = plastic_active('nonlocal') + myPlasticity = plastic_active('none') if(count(myPlasticity) == 0) return print'(/,a)', ' <<<+- phase:mechanics:plastic:none init -+>>>' From 72c099dbbe9f6990d21458889bea5e355105dec9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 14:17:08 +0100 Subject: [PATCH 237/352] store data separetly --- PRIVATE | 2 +- src/lattice.f90 | 17 +++++++++++------ src/phase_mechanical_eigen.f90 | 15 +++++++-------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/PRIVATE b/PRIVATE index d7f8460aa..42ebe55f0 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit d7f8460aa2afceb89f9b82054555d5dc6f9e5c43 +Subproject commit 42ebe55f0ef1cd799115bd87e45d6025db42f7a7 diff --git a/src/lattice.f90 b/src/lattice.f90 index c9b6d99ef..e5f5453d4 100644 --- a/src/lattice.f90 +++ b/src/lattice.f90 @@ -459,7 +459,8 @@ subroutine lattice_init phase, & mech, & elasticity, & - thermal + thermal, & + damage print'(/,a)', ' <<<+- lattice init -+>>>'; flush(IO_STDOUT) @@ -535,13 +536,17 @@ subroutine lattice_init endif - lattice_D(1,1,ph) = phase%get_asFloat('D_11',defaultVal=0.0_pReal) - lattice_D(2,2,ph) = phase%get_asFloat('D_22',defaultVal=0.0_pReal) - lattice_D(3,3,ph) = phase%get_asFloat('D_33',defaultVal=0.0_pReal) - lattice_D(1:3,1:3,ph) = lattice_applyLatticeSymmetry33(lattice_D(1:3,1:3,ph), & + if (phase%contains('damage')) then + damage => phase%get('damage') + damage => damage%get(1) + lattice_D(1,1,ph) = damage%get_asFloat('D_11',defaultVal=0.0_pReal) + lattice_D(2,2,ph) = damage%get_asFloat('D_22',defaultVal=0.0_pReal) + lattice_D(3,3,ph) = damage%get_asFloat('D_33',defaultVal=0.0_pReal) + lattice_D(1:3,1:3,ph) = lattice_applyLatticeSymmetry33(lattice_D(1:3,1:3,ph), & phase%get_asString('lattice')) - lattice_M(ph) = phase%get_asFloat('M',defaultVal=0.0_pReal) + lattice_M(ph) = damage%get_asFloat('M',defaultVal=0.0_pReal) + endif ! SHOULD NOT BE PART OF LATTICE END call selfTest diff --git a/src/phase_mechanical_eigen.f90 b/src/phase_mechanical_eigen.f90 index 9eb3c5767..439f2bef9 100644 --- a/src/phase_mechanical_eigen.f90 +++ b/src/phase_mechanical_eigen.f90 @@ -74,8 +74,8 @@ module subroutine eigendeformation_init(phases) kinematics => phase%get('damage',defaultVal=emptyList) if(kinematics%length >0) then damage => kinematics%get(1) - if(damage%get_asString('type') == 'anisobrittle') phase_Nkinematics(ph) = phase_Nkinematics(ph) +1 - if(damage%get_asString('type') == 'isoductile') phase_Nkinematics(ph) = phase_Nkinematics(ph) +1 + if(damage%get_asString('type',defaultVal='n/a') == 'anisobrittle') phase_Nkinematics(ph) = phase_Nkinematics(ph) +1 + if(damage%get_asString('type',defaultVal='n/a') == 'isoductile' ) phase_Nkinematics(ph) = phase_Nkinematics(ph) +1 endif enddo @@ -113,7 +113,7 @@ function kinematics_active(kinematics_label,kinematics_length) result(active_ki kinematics => phase%get('kinematics',defaultVal=emptyList) do k = 1, kinematics%length kinematics_type => kinematics%get(k) - if(kinematics_type%get_asString('type') == kinematics_label) active_kinematics(k,p) = .true. + active_kinematics(k,p) = kinematics_type%get_asString('type') == kinematics_label enddo enddo @@ -136,17 +136,16 @@ function kinematics_active2(kinematics_label,kinematics_length) result(active_k phase, & kinematics, & kinematics_type - integer :: p,k + integer :: p phases => config_material%get('phase') allocate(active_kinematics(kinematics_length,phases%length), source = .false. ) do p = 1, phases%length phase => phases%get(p) kinematics => phase%get('damage',defaultVal=emptyList) - do k = 1, kinematics%length - kinematics_type => kinematics%get(k) - if(kinematics_type%get_asString('type') == kinematics_label) active_kinematics(k,p) = .true. - enddo + kinematics_type => kinematics%get(1) + if (.not. kinematics_type%contains('type')) continue + active_kinematics(1,p) = kinematics_type%get_asString('type',defaultVal='n/a') == kinematics_label enddo From 22a0aff488f69b07a757fdb8c1649072be2bbee8 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 18:41:30 +0100 Subject: [PATCH 238/352] separting thermal and damage sources --- src/phase.f90 | 20 ++-- src/phase_damage.f90 | 16 +-- src/phase_mechanical.f90 | 9 +- src/phase_mechanical_eigen.f90 | 102 ++++++++++-------- ...phase_mechanical_eigen_cleavageopening.f90 | 36 +++---- ...hase_mechanical_eigen_slipplaneopening.f90 | 40 ++++--- ...hase_mechanical_eigen_thermalexpansion.f90 | 4 +- src/phase_thermal.f90 | 5 +- src/phase_thermal_dissipation.f90 | 9 +- src/phase_thermal_externalheat.f90 | 11 +- 10 files changed, 129 insertions(+), 123 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index 8ea1fa5f7..eb6e61eb8 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -58,12 +58,9 @@ module phase type(tDebugOptions) :: debugCrystallite integer, dimension(:), allocatable, public :: & !< ToDo: should be protected (bug in Intel compiler) - thermal_Nsources, & - phase_Nsources, & !< number of source mechanisms active in each phase - phase_Nkinematics, & !< number of kinematic mechanisms active in each phase + phase_elasticityInstance, & phase_NstiffnessDegradations, & !< number of stiffness degradation mechanisms active in each phase - phase_plasticInstance, & !< instance of particular plasticity of each phase - phase_elasticityInstance !< instance of particular elasticity of each phase + phase_plasticInstance logical, dimension(:), allocatable, public :: & ! ToDo: should be protected (bug in Intel Compiler) phase_localPlasticity !< flags phases with local constitutive law @@ -351,7 +348,7 @@ subroutine phase_init !-------------------------------------------------------------------------------------------------- ! partition and initialize state plasticState(ph)%state = plasticState(ph)%state0 - if(phase_Nsources(ph) > 0) & + if(damageState(ph)%sizeState > 0) & damageState(ph)%state = damageState(ph)%state0 enddo PhaseLoop2 @@ -365,7 +362,7 @@ end subroutine phase_init !> @brief Allocate the components of the state structure for a given phase !-------------------------------------------------------------------------------------------------- subroutine phase_allocateState(state, & - Nconstituents,sizeState,sizeDotState,sizeDeltaState) + Nconstituents,sizeState,sizeDotState,sizeDeltaState) class(tState), intent(out) :: & state @@ -406,7 +403,7 @@ subroutine phase_restore(ce,includeL) do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce)) - if (phase_Nsources(material_phaseAt2(co,ce)) > 0) & + if (damageState(material_phaseAt2(co,ce))%sizeState > 0) & damageState(material_phaseAt2(co,ce))%state( :,material_phasememberAt2(co,ce)) = & damageState(material_phaseAt2(co,ce))%state0(:,material_phasememberAt2(co,ce)) enddo @@ -429,7 +426,7 @@ subroutine phase_forward() call thermal_forward() do ph = 1, size(damageState) - if (phase_Nsources(ph) > 0) & + if (damageState(ph)%sizeState > 0) & damageState(ph)%state0 = damageState(ph)%state enddo @@ -527,7 +524,7 @@ subroutine crystallite_init() phases => config_material%get('phase') do ph = 1, phases%length - if (phase_Nsources(ph) > 0) & + if (damageState(ph)%sizeState > 0) & allocate(damageState(ph)%subState0,source=damageState(ph)%state0) ! ToDo: hack enddo @@ -574,8 +571,7 @@ subroutine phase_windForward(ip,el) call mechanical_windForward(ph,me) - if (phase_Nsources(ph) > 0) & - damageState(ph)%state0(:,me) = damageState(ph)%state(:,me) + if(damageState(ph)%sizeState > 0) damageState(ph)%state0(:,me) = damageState(ph)%state(:,me) enddo diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 2eda9540d..5e4e43017 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -18,6 +18,9 @@ submodule(phase) damagee integer(kind(DAMAGE_UNDEFINED_ID)), dimension(:), allocatable :: & phase_source !< active sources mechanisms of each phase + integer, dimension(:), allocatable :: & + phase_Nsources + type(tDataContainer), dimension(:), allocatable :: current interface @@ -156,6 +159,7 @@ module subroutine damage_init phase => phases%get(ph) sources => phase%get('damage',defaultVal=emptyList) if (sources%length > 1) error stop + phase_Nsources(ph) = sources%length enddo @@ -192,7 +196,6 @@ module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, integer :: & ph, & co, & - so, & me phiDot = 0.0_pReal @@ -201,7 +204,7 @@ module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) - do so = 1, phase_Nsources(ph) + select case(phase_source(ph)) case (DAMAGE_ISOBRITTLE_ID) call isobrittle_getRateAndItsTangent (localphiDot, dLocalphiDot_dPhi, phi, ph, me) @@ -222,7 +225,6 @@ module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, end select phiDot = phiDot + localphiDot dPhiDot_dPhi = dPhiDot_dPhi + dLocalphiDot_dPhi - enddo enddo end subroutine phase_damage_getRateAndItsTangents @@ -258,7 +260,7 @@ module function integrateDamageState(dt,co,ip,el) result(broken) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - if (phase_Nsources(ph) == 0) then + if (damageState(ph)%sizeState == 0) then broken = .false. return endif @@ -377,7 +379,7 @@ function phase_damage_collectDotState(ph,me) result(broken) broken = .false. - if (phase_Nsources(ph)==1) then + if (damageState(ph)%sizeState > 0) then sourceType: select case (phase_source(ph)) @@ -420,7 +422,7 @@ function phase_damage_deltaState(Fe, ph, me) result(broken) broken = .false. - if (phase_Nsources(ph) == 0) return + if (damageState(ph)%sizeState == 0) return sourceType: select case (phase_source(ph)) @@ -461,7 +463,7 @@ function source_active(source_label) result(active_source) phase => phases%get(ph) sources => phase%get('damage',defaultVal=emptyList) src => sources%get(1) - active_source(ph) = src%get_asString('type') == source_label + active_source(ph) = src%get_asString('type',defaultVal = 'x') == source_label enddo diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index bc4b2cd47..ef962b7e6 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -3,6 +3,7 @@ !---------------------------------------------------------------------------------------------------- submodule(phase) mechanics + enum, bind(c); enumerator :: & ELASTICITY_UNDEFINED_ID, & ELASTICITY_HOOKE_ID, & @@ -22,8 +23,6 @@ submodule(phase) mechanics KINEMATICS_THERMAL_EXPANSION_ID end enum - integer(kind(KINEMATICS_UNDEFINED_ID)), dimension(:,:), allocatable :: & - phase_kinematics integer(kind(ELASTICITY_UNDEFINED_ID)), dimension(:), allocatable :: & phase_elasticity !< elasticity of each phase integer(kind(STIFFNESS_DEGRADATION_UNDEFINED_ID)), dimension(:,:), allocatable :: & @@ -1159,7 +1158,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) subLp0 = phase_mechanical_Lp0(ph)%data(1:3,1:3,me) subState0 = plasticState(ph)%State0(:,me) - if (phase_Nsources(ph) > 0) & + if (damageState(ph)%sizeState > 0) & damageState(ph)%subState0(:,me) = damageState(ph)%state0(:,me) subFp0 = phase_mechanical_Fp0(ph)%data(1:3,1:3,me) @@ -1187,7 +1186,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) subFp0 = phase_mechanical_Fp(ph)%data(1:3,1:3,me) subFi0 = phase_mechanical_Fi(ph)%data(1:3,1:3,me) subState0 = plasticState(ph)%state(:,me) - if (phase_Nsources(ph) > 0) & + if (damageState(ph)%sizeState > 0) & damageState(ph)%subState0(:,me) = damageState(ph)%state(:,me) endif @@ -1203,7 +1202,7 @@ module function crystallite_stress(dt,co,ip,el) result(converged_) phase_mechanical_Li(ph)%data(1:3,1:3,me) = subLi0 endif plasticState(ph)%state(:,me) = subState0 - if (phase_Nsources(ph) > 0) & + if (damageState(ph)%sizeState > 0) & damageState(ph)%state(:,me) = damageState(ph)%subState0(:,me) todo = subStep > num%subStepMinCryst ! still on track or already done (beyond repair) diff --git a/src/phase_mechanical_eigen.f90 b/src/phase_mechanical_eigen.f90 index 439f2bef9..d55ff8759 100644 --- a/src/phase_mechanical_eigen.f90 +++ b/src/phase_mechanical_eigen.f90 @@ -1,20 +1,26 @@ submodule(phase:mechanics) eigendeformation + integer, dimension(:), allocatable :: & + Nmodels + + integer(kind(KINEMATICS_UNDEFINED_ID)), dimension(:,:), allocatable :: & + model + integer(kind(KINEMATICS_UNDEFINED_ID)), dimension(:), allocatable :: & + model_damage + interface - module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics + module function kinematics_cleavage_opening_init() result(myKinematics) + logical, dimension(:), allocatable :: myKinematics end function kinematics_cleavage_opening_init - module function kinematics_slipplane_opening_init(kinematics_length) result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics + module function kinematics_slipplane_opening_init() result(myKinematics) + logical, dimension(:), allocatable :: myKinematics end function kinematics_slipplane_opening_init - module function kinematics_thermal_expansion_init(kinematics_length) result(myKinematics) + module function thermalexpansion_init(kinematics_length) result(myKinematics) integer, intent(in) :: kinematics_length logical, dimension(:,:), allocatable :: myKinematics - end function kinematics_thermal_expansion_init + end function thermalexpansion_init module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) integer, intent(in) :: ph, me @@ -65,28 +71,27 @@ module subroutine eigendeformation_init(phases) print'(/,a)', ' <<<+- phase:mechanics:eigendeformation init -+>>>' !-------------------------------------------------------------------------------------------------- -! initialize kinematic mechanisms - allocate(phase_Nkinematics(phases%length),source = 0) +! explicit eigen mechanisms + allocate(Nmodels(phases%length),source = 0) + do ph = 1,phases%length phase => phases%get(ph) kinematics => phase%get('kinematics',defaultVal=emptyList) - phase_Nkinematics(ph) = kinematics%length - kinematics => phase%get('damage',defaultVal=emptyList) - if(kinematics%length >0) then - damage => kinematics%get(1) - if(damage%get_asString('type',defaultVal='n/a') == 'anisobrittle') phase_Nkinematics(ph) = phase_Nkinematics(ph) +1 - if(damage%get_asString('type',defaultVal='n/a') == 'isoductile' ) phase_Nkinematics(ph) = phase_Nkinematics(ph) +1 - endif + Nmodels(ph) = kinematics%length enddo - allocate(phase_kinematics(maxval(phase_Nkinematics),phases%length), source = KINEMATICS_undefined_ID) + allocate(model(maxval(Nmodels),phases%length), source = KINEMATICS_undefined_ID) - if(maxval(phase_Nkinematics) /= 0) then - where(kinematics_cleavage_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_cleavage_opening_ID - where(kinematics_slipplane_opening_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_slipplane_opening_ID - where(kinematics_thermal_expansion_init(maxval(phase_Nkinematics))) phase_kinematics = KINEMATICS_thermal_expansion_ID + if(maxval(Nmodels) /= 0) then + where(thermalexpansion_init(maxval(Nmodels))) model = KINEMATICS_thermal_expansion_ID endif + allocate(model_damage(phases%length), source = KINEMATICS_UNDEFINED_ID) + + where(kinematics_cleavage_opening_init()) model_damage = KINEMATICS_cleavage_opening_ID + where(kinematics_slipplane_opening_init()) model_damage = KINEMATICS_slipplane_opening_ID + + end subroutine eigendeformation_init @@ -125,11 +130,10 @@ end function kinematics_active !-------------------------------------------------------------------------------------------------- !> @brief checks if a kinematic mechanism is active or not !-------------------------------------------------------------------------------------------------- -function kinematics_active2(kinematics_label,kinematics_length) result(active_kinematics) +function kinematics_active2(kinematics_label) result(active_kinematics) - character(len=*), intent(in) :: kinematics_label !< name of kinematic mechanism - integer, intent(in) :: kinematics_length !< max. number of kinematics in system - logical, dimension(:,:), allocatable :: active_kinematics + character(len=*), intent(in) :: kinematics_label !< name of kinematic mechanism + logical, dimension(:), allocatable :: active_kinematics class(tNode), pointer :: & phases, & @@ -139,13 +143,14 @@ function kinematics_active2(kinematics_label,kinematics_length) result(active_k integer :: p phases => config_material%get('phase') - allocate(active_kinematics(kinematics_length,phases%length), source = .false. ) + allocate(active_kinematics(phases%length), source = .false. ) do p = 1, phases%length phase => phases%get(p) kinematics => phase%get('damage',defaultVal=emptyList) + if(kinematics%length < 1) return kinematics_type => kinematics%get(1) if (.not. kinematics_type%contains('type')) continue - active_kinematics(1,p) = kinematics_type%get_asString('type',defaultVal='n/a') == kinematics_label + active_kinematics(p) = kinematics_type%get_asString('type',defaultVal='n/a') == kinematics_label enddo @@ -181,7 +186,9 @@ module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & detFi integer :: & k, i, j + logical :: active + active = .false. Li = 0.0_pReal dLi_dS = 0.0_pReal dLi_dFi = 0.0_pReal @@ -190,30 +197,37 @@ module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & plasticType: select case (phase_plasticity(ph)) case (PLASTICITY_isotropic_ID) plasticType call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,phase_plasticInstance(ph),me) - case default plasticType - my_Li = 0.0_pReal - my_dLi_dS = 0.0_pReal + Li = Li + my_Li + dLi_dS = dLi_dS + my_dLi_dS + active = .true. end select plasticType - Li = Li + my_Li - dLi_dS = dLi_dS + my_dLi_dS - KinematicsLoop: do k = 1, phase_Nkinematics(ph) - kinematicsType: select case (phase_kinematics(k,ph)) - case (KINEMATICS_cleavage_opening_ID) kinematicsType - call kinematics_cleavage_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, ph, me) - case (KINEMATICS_slipplane_opening_ID) kinematicsType - call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, ph, me) + KinematicsLoop: do k = 1, Nmodels(ph) + kinematicsType: select case (model(k,ph)) case (KINEMATICS_thermal_expansion_ID) kinematicsType call thermalexpansion_LiAndItsTangent(my_Li, my_dLi_dS, ph,me) - case default kinematicsType - my_Li = 0.0_pReal - my_dLi_dS = 0.0_pReal + Li = Li + my_Li + dLi_dS = dLi_dS + my_dLi_dS + active = .true. end select kinematicsType - Li = Li + my_Li - dLi_dS = dLi_dS + my_dLi_dS enddo KinematicsLoop + select case (model_damage(ph)) + case (KINEMATICS_cleavage_opening_ID) + call kinematics_cleavage_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, ph, me) + Li = Li + my_Li + dLi_dS = dLi_dS + my_dLi_dS + active = .true. + case (KINEMATICS_slipplane_opening_ID) + call kinematics_slipplane_opening_LiAndItsTangent(my_Li, my_dLi_dS, S, ph, me) + Li = Li + my_Li + dLi_dS = dLi_dS + my_dLi_dS + active = .true. + end select + + if(.not. active) return + FiInv = math_inv33(Fi) detFi = math_det33(Fi) Li = matmul(matmul(Fi,Li),FiInv)*detFi !< push forward to intermediate configuration diff --git a/src/phase_mechanical_eigen_cleavageopening.f90 b/src/phase_mechanical_eigen_cleavageopening.f90 index 5bb9847f4..aaa1beb97 100644 --- a/src/phase_mechanical_eigen_cleavageopening.f90 +++ b/src/phase_mechanical_eigen_cleavageopening.f90 @@ -28,12 +28,11 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function kinematics_cleavage_opening_init(kinematics_length) result(myKinematics) +module function kinematics_cleavage_opening_init() result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics + logical, dimension(:), allocatable :: myKinematics - integer :: Ninstances,p,k + integer :: p integer, dimension(:), allocatable :: N_cl !< active number of cleavage systems per family character(len=pStringLen) :: extmsg = '' class(tNode), pointer :: & @@ -42,24 +41,24 @@ module function kinematics_cleavage_opening_init(kinematics_length) result(myKin kinematics, & kinematic_type - print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:cleavageopening init -+>>>' - myKinematics = kinematics_active2('anisobrittle',kinematics_length) - Ninstances = count(myKinematics) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - if(Ninstances == 0) return + myKinematics = kinematics_active2('anisobrittle') + if(count(myKinematics) == 0) return + + print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:cleavageopening init -+>>>' + print'(a,i2)', ' # phases: ',count(myKinematics); flush(IO_STDOUT) + phases => config_material%get('phase') allocate(param(phases%length)) do p = 1, phases%length - phase => phases%get(p) - if(count(myKinematics(:,p)) == 0) cycle - kinematics => phase%get('damage') - do k = 1, kinematics%length - if(myKinematics(k,p)) then - associate(prm => param(p)) - kinematic_type => kinematics%get(k) + if(myKinematics(p)) then + phase => phases%get(p) + kinematics => phase%get('damage') + + associate(prm => param(p)) + kinematic_type => kinematics%get(1) N_cl = kinematic_type%get_asInts('N_cl') prm%sum_N_cl = sum(abs(N_cl)) @@ -83,9 +82,8 @@ module function kinematics_cleavage_opening_init(kinematics_length) result(myKin !-------------------------------------------------------------------------------------------------- ! exit if any parameter is out of range if (extmsg /= '') call IO_error(211,ext_msg=trim(extmsg)//'(cleavage_opening)') - end associate - endif - enddo + end associate + endif enddo diff --git a/src/phase_mechanical_eigen_slipplaneopening.f90 b/src/phase_mechanical_eigen_slipplaneopening.f90 index 64988d87f..ccba98b14 100644 --- a/src/phase_mechanical_eigen_slipplaneopening.f90 +++ b/src/phase_mechanical_eigen_slipplaneopening.f90 @@ -32,12 +32,11 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function kinematics_slipplane_opening_init(kinematics_length) result(myKinematics) +module function kinematics_slipplane_opening_init() result(myKinematics) - integer, intent(in) :: kinematics_length - logical, dimension(:,:), allocatable :: myKinematics + logical, dimension(:), allocatable :: myKinematics - integer :: Ninstances,p,i,k + integer :: p,i character(len=pStringLen) :: extmsg = '' integer, dimension(:), allocatable :: N_sl real(pReal), dimension(:,:), allocatable :: d,n,t @@ -49,26 +48,26 @@ module function kinematics_slipplane_opening_init(kinematics_length) result(myKi kinematics, & kinematic_type - print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:slipplaneopening init -+>>>' - myKinematics = kinematics_active2('isoductile',kinematics_length) - Ninstances = count(myKinematics) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - if(Ninstances == 0) return + myKinematics = kinematics_active2('isoductile') + if(count(myKinematics) == 0) return + print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:slipplaneopening init -+>>>' + print'(a,i2)', ' # phases: ',count(myKinematics); flush(IO_STDOUT) + phases => config_material%get('phase') allocate(param(phases%length)) do p = 1, phases%length - phase => phases%get(p) - mech => phase%get('mechanics') - pl => mech%get('plasticity') - if(count(myKinematics(:,p)) == 0) cycle - kinematics => phase%get('damage') - do k = 1, kinematics%length - if(myKinematics(k,p)) then - associate(prm => param(p)) - kinematic_type => kinematics%get(k) + if(myKinematics(p)) then + phase => phases%get(p) + mech => phase%get('mechanics') + pl => mech%get('plasticity') + + kinematics => phase%get('damage') + + associate(prm => param(p)) + kinematic_type => kinematics%get(1) prm%dot_o = kinematic_type%get_asFloat('dot_o') prm%q = kinematic_type%get_asFloat('q') @@ -103,9 +102,8 @@ module function kinematics_slipplane_opening_init(kinematics_length) result(myKi ! exit if any parameter is out of range if (extmsg /= '') call IO_error(211,ext_msg=trim(extmsg)//'(slipplane_opening)') - end associate - endif - enddo + end associate + endif enddo diff --git a/src/phase_mechanical_eigen_thermalexpansion.f90 b/src/phase_mechanical_eigen_thermalexpansion.f90 index 6630f0eb7..1041e0957 100644 --- a/src/phase_mechanical_eigen_thermalexpansion.f90 +++ b/src/phase_mechanical_eigen_thermalexpansion.f90 @@ -23,7 +23,7 @@ contains !> @brief module initialization !> @details reads in material parameters, allocates arrays, and does sanity checks !-------------------------------------------------------------------------------------------------- -module function kinematics_thermal_expansion_init(kinematics_length) result(myKinematics) +module function thermalexpansion_init(kinematics_length) result(myKinematics) integer, intent(in) :: kinematics_length logical, dimension(:,:), allocatable :: myKinematics @@ -77,7 +77,7 @@ module function kinematics_thermal_expansion_init(kinematics_length) result(myKi enddo -end function kinematics_thermal_expansion_init +end function thermalexpansion_init !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 5d3d89ccb..012554aef 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -3,6 +3,9 @@ !---------------------------------------------------------------------------------------------------- submodule(phase) thermal + integer, dimension(:), allocatable :: & + thermal_Nsources + type(tSourceState), allocatable, dimension(:) :: & thermalState @@ -36,8 +39,6 @@ submodule(phase) thermal end function externalheat_init - - module subroutine externalheat_dotState(ph, me) integer, intent(in) :: & ph, & diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index 3c0095401..9c75763dc 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -31,15 +31,14 @@ module function dissipation_init(source_length) result(mySources) phase, & sources, thermal, & src - integer :: Ninstances,so,Nconstituents,ph + integer :: so,Nconstituents,ph - print'(/,a)', ' <<<+- phase:thermal:dissipation init -+>>>' mySources = thermal_active('dissipation',source_length) + if(count(mySources) == 0) return + print'(/,a)', ' <<<+- phase:thermal:dissipation init -+>>>' + print'(a,i2)', ' # phases: ',count(mySources); flush(IO_STDOUT) - Ninstances = count(mySources) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - if(Ninstances == 0) return phases => config_material%get('phase') allocate(param(phases%length)) diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index d2874ded0..c7f894215 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -8,7 +8,7 @@ submodule(phase:thermal) externalheat integer, dimension(:), allocatable :: & - source_thermal_externalheat_offset !< which source is my current thermal dissipation mechanism? + source_thermal_externalheat_offset !< which source is my current thermal dissipation mechanism? type :: tParameters !< container type for internal constitutive parameters real(pReal), dimension(:), allocatable :: & @@ -38,15 +38,14 @@ module function externalheat_init(source_length) result(mySources) phase, & sources, thermal, & src - integer :: Ninstances,so,Nconstituents,ph + integer :: so,Nconstituents,ph - print'(/,a)', ' <<<+- phase:thermal:externalheat init -+>>>' mySources = thermal_active('externalheat',source_length) + if(count(mySources) == 0) return + print'(/,a)', ' <<<+- phase:thermal:externalheat init -+>>>' + print'(a,i2)', ' # phases: ',count(mySources); flush(IO_STDOUT) - Ninstances = count(mySources) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - if(Ninstances == 0) return phases => config_material%get('phase') allocate(param(phases%length)) From 8dc53344ecd169fa4885d3f8256b8588e101bbe2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 18:52:37 +0100 Subject: [PATCH 239/352] 'kinematics'=>'eigen', now part of 'mechanics' --- PRIVATE | 2 +- src/phase_mechanical_eigen.f90 | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/PRIVATE b/PRIVATE index 42ebe55f0..fa5ef6139 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 42ebe55f0ef1cd799115bd87e45d6025db42f7a7 +Subproject commit fa5ef61395381b103a4babe52be145f960af0bbe diff --git a/src/phase_mechanical_eigen.f90 b/src/phase_mechanical_eigen.f90 index d55ff8759..bee469385 100644 --- a/src/phase_mechanical_eigen.f90 +++ b/src/phase_mechanical_eigen.f90 @@ -66,7 +66,8 @@ module subroutine eigendeformation_init(phases) class(tNode), pointer :: & phase, & kinematics, & - damage + damage, & + mechanics print'(/,a)', ' <<<+- phase:mechanics:eigendeformation init -+>>>' @@ -76,7 +77,8 @@ module subroutine eigendeformation_init(phases) do ph = 1,phases%length phase => phases%get(ph) - kinematics => phase%get('kinematics',defaultVal=emptyList) + mechanics => phase%get('mechanics') + kinematics => mechanics%get('eigen',defaultVal=emptyList) Nmodels(ph) = kinematics%length enddo @@ -108,14 +110,16 @@ function kinematics_active(kinematics_label,kinematics_length) result(active_ki phases, & phase, & kinematics, & - kinematics_type + kinematics_type, & + mechanics integer :: p,k phases => config_material%get('phase') allocate(active_kinematics(kinematics_length,phases%length), source = .false. ) do p = 1, phases%length phase => phases%get(p) - kinematics => phase%get('kinematics',defaultVal=emptyList) + mechanics => phase%get('mechanics') + kinematics => mechanics%get('eigen',defaultVal=emptyList) do k = 1, kinematics%length kinematics_type => kinematics%get(k) active_kinematics(k,p) = kinematics_type%get_asString('type') == kinematics_label From 9481b168789de60187a0232789043c7ca58345b2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 18:57:41 +0100 Subject: [PATCH 240/352] missing renames --- src/homogenization_mechanical.f90 | 6 ++--- src/homogenization_mechanical_RGC.f90 | 4 +-- src/homogenization_mechanical_isostrain.f90 | 4 +-- src/homogenization_mechanical_pass.f90 | 4 +-- src/phase.f90 | 21 +++++++++++++++ src/phase_mechanical.f90 | 6 ++--- src/phase_mechanical_eigen.f90 | 26 +++---------------- ...phase_mechanical_eigen_cleavageopening.f90 | 4 +-- ...hase_mechanical_eigen_slipplaneopening.f90 | 4 +-- ...hase_mechanical_eigen_thermalexpansion.f90 | 4 +-- src/phase_mechanical_plastic.f90 | 4 +-- ...phase_mechanical_plastic_dislotungsten.f90 | 2 +- src/phase_mechanical_plastic_dislotwin.f90 | 2 +- src/phase_mechanical_plastic_isotropic.f90 | 2 +- ...phase_mechanical_plastic_kinehardening.f90 | 2 +- src/phase_mechanical_plastic_none.f90 | 2 +- src/phase_mechanical_plastic_nonlocal.f90 | 2 +- ...phase_mechanical_plastic_phenopowerlaw.f90 | 2 +- 18 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/homogenization_mechanical.f90 b/src/homogenization_mechanical.f90 index c05b576da..a19a61f72 100644 --- a/src/homogenization_mechanical.f90 +++ b/src/homogenization_mechanical.f90 @@ -2,7 +2,7 @@ !> @author Martin Diehl, KU Leuven !> @brief Partition F and homogenize P/dPdF !-------------------------------------------------------------------------------------------------- -submodule(homogenization) mechanics +submodule(homogenization) mechanical interface @@ -86,7 +86,7 @@ module subroutine mechanical_init(num_homog) class(tNode), pointer :: & num_homogMech - print'(/,a)', ' <<<+- homogenization:mechanics init -+>>>' + print'(/,a)', ' <<<+- homogenization:mechanical init -+>>>' allocate(homogenization_dPdF(3,3,3,3,discretization_nIPs*discretization_Nelems), source=0.0_pReal) homogenization_F0 = spread(math_I3,3,discretization_nIPs*discretization_Nelems) ! initialize to identity @@ -251,4 +251,4 @@ module subroutine mechanical_results(group_base,h) end subroutine mechanical_results -end submodule mechanics +end submodule mechanical diff --git a/src/homogenization_mechanical_RGC.f90 b/src/homogenization_mechanical_RGC.f90 index 546c2b65c..f1bcda380 100644 --- a/src/homogenization_mechanical_RGC.f90 +++ b/src/homogenization_mechanical_RGC.f90 @@ -6,7 +6,7 @@ !> @brief Relaxed grain cluster (RGC) homogenization scheme !> N_constituents is defined as p x q x r (cluster) !-------------------------------------------------------------------------------------------------- -submodule(homogenization:mechanics) RGC +submodule(homogenization:mechanical) RGC use rotations use lattice @@ -88,7 +88,7 @@ module subroutine mechanical_RGC_init(num_homogMech) homog, & homogMech - print'(/,a)', ' <<<+- homogenization:mechanics:RGC init -+>>>' + print'(/,a)', ' <<<+- homogenization:mechanical:RGC init -+>>>' Ninstances = count(homogenization_type == HOMOGENIZATION_RGC_ID) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) diff --git a/src/homogenization_mechanical_isostrain.f90 b/src/homogenization_mechanical_isostrain.f90 index f9616de42..b492499d8 100644 --- a/src/homogenization_mechanical_isostrain.f90 +++ b/src/homogenization_mechanical_isostrain.f90 @@ -4,7 +4,7 @@ !> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH !> @brief Isostrain (full constraint Taylor assuption) homogenization scheme !-------------------------------------------------------------------------------------------------- -submodule(homogenization:mechanics) isostrain +submodule(homogenization:mechanical) isostrain enum, bind(c); enumerator :: & parallel_ID, & @@ -37,7 +37,7 @@ module subroutine mechanical_isostrain_init homog, & homogMech - print'(/,a)', ' <<<+- homogenization:mechanics:isostrain init -+>>>' + print'(/,a)', ' <<<+- homogenization:mechanical:isostrain init -+>>>' Ninstances = count(homogenization_type == HOMOGENIZATION_ISOSTRAIN_ID) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) diff --git a/src/homogenization_mechanical_pass.f90 b/src/homogenization_mechanical_pass.f90 index 9e8f3e44c..6217e6836 100644 --- a/src/homogenization_mechanical_pass.f90 +++ b/src/homogenization_mechanical_pass.f90 @@ -4,7 +4,7 @@ !> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH !> @brief dummy homogenization homogenization scheme for 1 constituent per material point !-------------------------------------------------------------------------------------------------- -submodule(homogenization:mechanics) none +submodule(homogenization:mechanical) none contains @@ -18,7 +18,7 @@ module subroutine mechanical_pass_init h, & Nmaterialpoints - print'(/,a)', ' <<<+- homogenization:mechanics:pass init -+>>>' + print'(/,a)', ' <<<+- homogenization:mechanical:pass init -+>>>' Ninstances = count(homogenization_type == HOMOGENIZATION_NONE_ID) print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) diff --git a/src/phase.f90 b/src/phase.f90 index eb6e61eb8..f129ba92f 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -263,6 +263,27 @@ module phase el !< element end subroutine plastic_dependentState + + module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) + integer, intent(in) :: ph, me + real(pReal), intent(in), dimension(3,3) :: & + S + real(pReal), intent(out), dimension(3,3) :: & + Ld !< damage velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) + end subroutine kinematics_cleavage_opening_LiAndItsTangent + + module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) + integer, intent(in) :: ph, me + real(pReal), intent(in), dimension(3,3) :: & + S + real(pReal), intent(out), dimension(3,3) :: & + Ld !< damage velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) + end subroutine kinematics_slipplane_opening_LiAndItsTangent + end interface diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index ef962b7e6..c10a916da 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -1,7 +1,7 @@ !---------------------------------------------------------------------------------------------------- !> @brief internal microstructure state for all plasticity constitutive models !---------------------------------------------------------------------------------------------------- -submodule(phase) mechanics +submodule(phase) mechanical enum, bind(c); enumerator :: & @@ -202,7 +202,7 @@ module subroutine mechanical_init(phases) elastic, & stiffDegradation - print'(/,a)', ' <<<+- phase:mechanics init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical init -+>>>' !------------------------------------------------------------------------------------------------- ! initialize elasticity (hooke) !ToDO: Maybe move to elastic submodule along with function homogenizedC? @@ -1499,4 +1499,4 @@ module subroutine phase_mechanical_setF(F,co,ip,el) end subroutine phase_mechanical_setF -end submodule mechanics +end submodule mechanical diff --git a/src/phase_mechanical_eigen.f90 b/src/phase_mechanical_eigen.f90 index bee469385..bee7dc2d2 100644 --- a/src/phase_mechanical_eigen.f90 +++ b/src/phase_mechanical_eigen.f90 @@ -1,4 +1,4 @@ -submodule(phase:mechanics) eigendeformation +submodule(phase:mechanical) eigen integer, dimension(:), allocatable :: & Nmodels @@ -22,26 +22,6 @@ submodule(phase:mechanics) eigendeformation logical, dimension(:,:), allocatable :: myKinematics end function thermalexpansion_init - module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) - integer, intent(in) :: ph, me - real(pReal), intent(in), dimension(3,3) :: & - S - real(pReal), intent(out), dimension(3,3) :: & - Ld !< damage velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) - end subroutine kinematics_cleavage_opening_LiAndItsTangent - - module subroutine kinematics_slipplane_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) - integer, intent(in) :: ph, me - real(pReal), intent(in), dimension(3,3) :: & - S - real(pReal), intent(out), dimension(3,3) :: & - Ld !< damage velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) - end subroutine kinematics_slipplane_opening_LiAndItsTangent - module subroutine thermalexpansion_LiAndItsTangent(Li, dLi_dTstar, ph,me) integer, intent(in) :: ph, me real(pReal), intent(out), dimension(3,3) :: & @@ -69,7 +49,7 @@ module subroutine eigendeformation_init(phases) damage, & mechanics - print'(/,a)', ' <<<+- phase:mechanics:eigendeformation init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:eigen init -+>>>' !-------------------------------------------------------------------------------------------------- ! explicit eigen mechanisms @@ -246,4 +226,4 @@ module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & end subroutine phase_LiAndItsTangents -end submodule eigendeformation +end submodule eigen diff --git a/src/phase_mechanical_eigen_cleavageopening.f90 b/src/phase_mechanical_eigen_cleavageopening.f90 index aaa1beb97..9f29b1634 100644 --- a/src/phase_mechanical_eigen_cleavageopening.f90 +++ b/src/phase_mechanical_eigen_cleavageopening.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating kinematics resulting from opening of cleavage planes !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(phase:eigendeformation) cleavageopening +submodule(phase:eigen) cleavageopening type :: tParameters !< container type for internal constitutive parameters integer :: & @@ -45,7 +45,7 @@ module function kinematics_cleavage_opening_init() result(myKinematics) myKinematics = kinematics_active2('anisobrittle') if(count(myKinematics) == 0) return - print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:cleavageopening init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:eigen:cleavageopening init -+>>>' print'(a,i2)', ' # phases: ',count(myKinematics); flush(IO_STDOUT) diff --git a/src/phase_mechanical_eigen_slipplaneopening.f90 b/src/phase_mechanical_eigen_slipplaneopening.f90 index ccba98b14..e8a7d65b9 100644 --- a/src/phase_mechanical_eigen_slipplaneopening.f90 +++ b/src/phase_mechanical_eigen_slipplaneopening.f90 @@ -4,7 +4,7 @@ !> @brief material subroutine incorporating kinematics resulting from opening of slip planes !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(phase:eigendeformation) slipplaneopening +submodule(phase:eigen) slipplaneopening integer, dimension(:), allocatable :: kinematics_slipplane_opening_instance @@ -51,7 +51,7 @@ module function kinematics_slipplane_opening_init() result(myKinematics) myKinematics = kinematics_active2('isoductile') if(count(myKinematics) == 0) return - print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:slipplaneopening init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:eigen:slipplaneopening init -+>>>' print'(a,i2)', ' # phases: ',count(myKinematics); flush(IO_STDOUT) diff --git a/src/phase_mechanical_eigen_thermalexpansion.f90 b/src/phase_mechanical_eigen_thermalexpansion.f90 index 1041e0957..86e7fa907 100644 --- a/src/phase_mechanical_eigen_thermalexpansion.f90 +++ b/src/phase_mechanical_eigen_thermalexpansion.f90 @@ -3,7 +3,7 @@ !> @brief material subroutine incorporating kinematics resulting from thermal expansion !> @details to be done !-------------------------------------------------------------------------------------------------- -submodule(phase:eigendeformation) thermalexpansion +submodule(phase:eigen) thermalexpansion integer, dimension(:), allocatable :: kinematics_thermal_expansion_instance @@ -36,7 +36,7 @@ module function thermalexpansion_init(kinematics_length) result(myKinematics) kinematics, & kinematic_type - print'(/,a)', ' <<<+- phase:mechanics:eigendeformation:thermalexpansion init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:eigen:thermalexpansion init -+>>>' myKinematics = kinematics_active('thermal_expansion',kinematics_length) Ninstances = count(myKinematics) diff --git a/src/phase_mechanical_plastic.f90 b/src/phase_mechanical_plastic.f90 index ed1dc64fb..843273c72 100644 --- a/src/phase_mechanical_plastic.f90 +++ b/src/phase_mechanical_plastic.f90 @@ -1,4 +1,4 @@ -submodule(phase:mechanics) plastic +submodule(phase:mechanical) plastic interface @@ -226,7 +226,7 @@ contains module subroutine plastic_init - print'(/,a)', ' <<<+- phase:mechanics:plastic init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:plastic init -+>>>' where(plastic_none_init()) phase_plasticity = PLASTICITY_NONE_ID where(plastic_isotropic_init()) phase_plasticity = PLASTICITY_ISOTROPIC_ID diff --git a/src/phase_mechanical_plastic_dislotungsten.f90 b/src/phase_mechanical_plastic_dislotungsten.f90 index 4db546b67..6eb1e4abe 100644 --- a/src/phase_mechanical_plastic_dislotungsten.f90 +++ b/src/phase_mechanical_plastic_dislotungsten.f90 @@ -101,7 +101,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) Ninstances = count(myPlasticity) if(Ninstances == 0) return - print'(/,a)', ' <<<+- phase:mechanics:plastic:dislotungsten init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:plastic:dislotungsten init -+>>>' print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index 2a011dfda..ca385f417 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -148,7 +148,7 @@ module function plastic_dislotwin_init() result(myPlasticity) Ninstances = count(myPlasticity) if(Ninstances == 0) return - print'(/,a)', ' <<<+- phase:mechanics:plastic:dislotwin init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:plastic:dislotwin init -+>>>' print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) print*, 'Ma and Roters, Acta Materialia 52(12):3603–3612, 2004' diff --git a/src/phase_mechanical_plastic_isotropic.f90 b/src/phase_mechanical_plastic_isotropic.f90 index 4cb1bf28c..e315a38fb 100644 --- a/src/phase_mechanical_plastic_isotropic.f90 +++ b/src/phase_mechanical_plastic_isotropic.f90 @@ -72,7 +72,7 @@ module function plastic_isotropic_init() result(myPlasticity) Ninstances = count(myPlasticity) if(Ninstances == 0) return - print'(/,a)', ' <<<+- phase:mechanics:plastic:isotropic init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:plastic:isotropic init -+>>>' print'(a,i0)', ' # phses: ',Ninstances; flush(IO_STDOUT) diff --git a/src/phase_mechanical_plastic_kinehardening.f90 b/src/phase_mechanical_plastic_kinehardening.f90 index 0ef762ffe..1244988de 100644 --- a/src/phase_mechanical_plastic_kinehardening.f90 +++ b/src/phase_mechanical_plastic_kinehardening.f90 @@ -84,7 +84,7 @@ module function plastic_kinehardening_init() result(myPlasticity) Ninstances = count(myPlasticity) if(Ninstances == 0) return - print'(/,a)', ' <<<+- phase:mechanics:plastic:kinehardening init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:plastic:kinehardening init -+>>>' print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) diff --git a/src/phase_mechanical_plastic_none.f90 b/src/phase_mechanical_plastic_none.f90 index f16cf98fb..1510262cc 100644 --- a/src/phase_mechanical_plastic_none.f90 +++ b/src/phase_mechanical_plastic_none.f90 @@ -25,7 +25,7 @@ module function plastic_none_init() result(myPlasticity) myPlasticity = plastic_active('none') if(count(myPlasticity) == 0) return - print'(/,a)', ' <<<+- phase:mechanics:plastic:none init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:plastic:none init -+>>>' print'(a,i0)', ' # phases: ',count(myPlasticity); flush(IO_STDOUT) phases => config_material%get('phase') diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 5cfd9cf4d..4e94f83ae 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -194,7 +194,7 @@ module function plastic_nonlocal_init() result(myPlasticity) return endif - print'(/,a)', ' <<<+- phase:mechanics:plastic:nonlocal init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:plastic:nonlocal init -+>>>' print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) print*, 'Reuber et al., Acta Materialia 71:333–348, 2014' diff --git a/src/phase_mechanical_plastic_phenopowerlaw.f90 b/src/phase_mechanical_plastic_phenopowerlaw.f90 index 6a7d5ea7f..bea7ef06b 100644 --- a/src/phase_mechanical_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanical_plastic_phenopowerlaw.f90 @@ -94,7 +94,7 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) Ninstances = count(myPlasticity) if(Ninstances == 0) return - print'(/,a)', ' <<<+- phase:mechanics:plastic:phenopowerlaw init -+>>>' + print'(/,a)', ' <<<+- phase:mechanical:plastic:phenopowerlaw init -+>>>' print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) From 5126370934dfcfc66dc808a05128ae2843a0be41 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 19:20:52 +0100 Subject: [PATCH 241/352] cleavageopening+anisobrittle are strongly coupled --- src/phase_damage_anisobrittle.f90 | 62 +++++++++ ...phase_mechanical_eigen_cleavageopening.f90 | 122 ------------------ 2 files changed, 62 insertions(+), 122 deletions(-) diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index bfd069031..fd82b74c4 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -193,4 +193,66 @@ module subroutine anisobrittle_results(phase,group) end subroutine anisobrittle_results + +!-------------------------------------------------------------------------------------------------- +!> @brief contains the constitutive equation for calculating the velocity gradient +!-------------------------------------------------------------------------------------------------- +module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) + + integer, intent(in) :: & + ph,me + real(pReal), intent(in), dimension(3,3) :: & + S + real(pReal), intent(out), dimension(3,3) :: & + Ld !< damage velocity gradient + real(pReal), intent(out), dimension(3,3,3,3) :: & + dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) + + integer :: & + i, k, l, m, n + real(pReal) :: & + traction_d, traction_t, traction_n, traction_crit, & + udotd, dudotd_dt, udott, dudott_dt, udotn, dudotn_dt + + + Ld = 0.0_pReal + dLd_dTstar = 0.0_pReal + associate(prm => param(ph)) + do i = 1,prm%sum_N_cl + traction_crit = prm%g_crit(i)*damage_phi(ph,me)**2.0_pReal + + traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) + if (abs(traction_d) > traction_crit + tol_math_check) then + udotd = sign(1.0_pReal,traction_d)* prm%dot_o * ((abs(traction_d) - traction_crit)/traction_crit)**prm%q + Ld = Ld + udotd*prm%cleavage_systems(1:3,1:3,1,i) + dudotd_dt = sign(1.0_pReal,traction_d)*udotd*prm%q / (abs(traction_d) - traction_crit) + forall (k=1:3,l=1:3,m=1:3,n=1:3) & + dLd_dTstar(k,l,m,n) = dLd_dTstar(k,l,m,n) & + + dudotd_dt*prm%cleavage_systems(k,l,1,i) * prm%cleavage_systems(m,n,1,i) + endif + + traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) + if (abs(traction_t) > traction_crit + tol_math_check) then + udott = sign(1.0_pReal,traction_t)* prm%dot_o * ((abs(traction_t) - traction_crit)/traction_crit)**prm%q + Ld = Ld + udott*prm%cleavage_systems(1:3,1:3,2,i) + dudott_dt = sign(1.0_pReal,traction_t)*udott*prm%q / (abs(traction_t) - traction_crit) + forall (k=1:3,l=1:3,m=1:3,n=1:3) & + dLd_dTstar(k,l,m,n) = dLd_dTstar(k,l,m,n) & + + dudott_dt*prm%cleavage_systems(k,l,2,i) * prm%cleavage_systems(m,n,2,i) + endif + + traction_n = math_tensordot(S,prm%cleavage_systems(1:3,1:3,3,i)) + if (abs(traction_n) > traction_crit + tol_math_check) then + udotn = sign(1.0_pReal,traction_n)* prm%dot_o * ((abs(traction_n) - traction_crit)/traction_crit)**prm%q + Ld = Ld + udotn*prm%cleavage_systems(1:3,1:3,3,i) + dudotn_dt = sign(1.0_pReal,traction_n)*udotn*prm%q / (abs(traction_n) - traction_crit) + forall (k=1:3,l=1:3,m=1:3,n=1:3) & + dLd_dTstar(k,l,m,n) = dLd_dTstar(k,l,m,n) & + + dudotn_dt*prm%cleavage_systems(k,l,3,i) * prm%cleavage_systems(m,n,3,i) + endif + enddo + end associate + +end subroutine kinematics_cleavage_opening_LiAndItsTangent + end submodule anisobrittle diff --git a/src/phase_mechanical_eigen_cleavageopening.f90 b/src/phase_mechanical_eigen_cleavageopening.f90 index 9f29b1634..0f48be1a4 100644 --- a/src/phase_mechanical_eigen_cleavageopening.f90 +++ b/src/phase_mechanical_eigen_cleavageopening.f90 @@ -6,21 +6,6 @@ !-------------------------------------------------------------------------------------------------- submodule(phase:eigen) cleavageopening - type :: tParameters !< container type for internal constitutive parameters - integer :: & - sum_N_cl !< total number of cleavage planes - real(pReal) :: & - dot_o, & !< opening rate of cleavage planes - q !< damage rate sensitivity - real(pReal), dimension(:), allocatable :: & - g_crit - real(pReal), dimension(:,:,:,:), allocatable :: & - cleavage_systems - end type tParameters - - type(tParameters), dimension(:), allocatable :: param !< containers of constitutive parameters - - contains @@ -32,15 +17,6 @@ module function kinematics_cleavage_opening_init() result(myKinematics) logical, dimension(:), allocatable :: myKinematics - integer :: p - integer, dimension(:), allocatable :: N_cl !< active number of cleavage systems per family - character(len=pStringLen) :: extmsg = '' - class(tNode), pointer :: & - phases, & - phase, & - kinematics, & - kinematic_type - myKinematics = kinematics_active2('anisobrittle') if(count(myKinematics) == 0) return @@ -48,107 +24,9 @@ module function kinematics_cleavage_opening_init() result(myKinematics) print'(/,a)', ' <<<+- phase:mechanical:eigen:cleavageopening init -+>>>' print'(a,i2)', ' # phases: ',count(myKinematics); flush(IO_STDOUT) - - phases => config_material%get('phase') - allocate(param(phases%length)) - - do p = 1, phases%length - if(myKinematics(p)) then - phase => phases%get(p) - kinematics => phase%get('damage') - - associate(prm => param(p)) - kinematic_type => kinematics%get(1) - - N_cl = kinematic_type%get_asInts('N_cl') - prm%sum_N_cl = sum(abs(N_cl)) - - prm%q = kinematic_type%get_asFloat('q') - prm%dot_o = kinematic_type%get_asFloat('dot_o') - - prm%g_crit = kinematic_type%get_asFloats('g_crit',requiredSize=size(N_cl)) - - prm%cleavage_systems = lattice_SchmidMatrix_cleavage(N_cl,phase%get_asString('lattice'),& - phase%get_asFloat('c/a',defaultVal=0.0_pReal)) - - ! expand: family => system - prm%g_crit = math_expand(prm%g_crit,N_cl) - - ! sanity checks - if (prm%q <= 0.0_pReal) extmsg = trim(extmsg)//' q' - if (prm%dot_o <= 0.0_pReal) extmsg = trim(extmsg)//' dot_o' - if (any(prm%g_crit < 0.0_pReal)) extmsg = trim(extmsg)//' g_crit' - -!-------------------------------------------------------------------------------------------------- -! exit if any parameter is out of range - if (extmsg /= '') call IO_error(211,ext_msg=trim(extmsg)//'(cleavage_opening)') - end associate - endif - enddo - - end function kinematics_cleavage_opening_init -!-------------------------------------------------------------------------------------------------- -!> @brief contains the constitutive equation for calculating the velocity gradient -!-------------------------------------------------------------------------------------------------- -module subroutine kinematics_cleavage_opening_LiAndItsTangent(Ld, dLd_dTstar, S, ph,me) - integer, intent(in) :: & - ph,me - real(pReal), intent(in), dimension(3,3) :: & - S - real(pReal), intent(out), dimension(3,3) :: & - Ld !< damage velocity gradient - real(pReal), intent(out), dimension(3,3,3,3) :: & - dLd_dTstar !< derivative of Ld with respect to Tstar (4th-order tensor) - - integer :: & - i, k, l, m, n - real(pReal) :: & - traction_d, traction_t, traction_n, traction_crit, & - udotd, dudotd_dt, udott, dudott_dt, udotn, dudotn_dt - - - Ld = 0.0_pReal - dLd_dTstar = 0.0_pReal - associate(prm => param(ph)) - do i = 1,prm%sum_N_cl - traction_crit = prm%g_crit(i)*damage_phi(ph,me)**2.0_pReal - - traction_d = math_tensordot(S,prm%cleavage_systems(1:3,1:3,1,i)) - if (abs(traction_d) > traction_crit + tol_math_check) then - udotd = sign(1.0_pReal,traction_d)* prm%dot_o * ((abs(traction_d) - traction_crit)/traction_crit)**prm%q - Ld = Ld + udotd*prm%cleavage_systems(1:3,1:3,1,i) - dudotd_dt = sign(1.0_pReal,traction_d)*udotd*prm%q / (abs(traction_d) - traction_crit) - forall (k=1:3,l=1:3,m=1:3,n=1:3) & - dLd_dTstar(k,l,m,n) = dLd_dTstar(k,l,m,n) & - + dudotd_dt*prm%cleavage_systems(k,l,1,i) * prm%cleavage_systems(m,n,1,i) - endif - - traction_t = math_tensordot(S,prm%cleavage_systems(1:3,1:3,2,i)) - if (abs(traction_t) > traction_crit + tol_math_check) then - udott = sign(1.0_pReal,traction_t)* prm%dot_o * ((abs(traction_t) - traction_crit)/traction_crit)**prm%q - Ld = Ld + udott*prm%cleavage_systems(1:3,1:3,2,i) - dudott_dt = sign(1.0_pReal,traction_t)*udott*prm%q / (abs(traction_t) - traction_crit) - forall (k=1:3,l=1:3,m=1:3,n=1:3) & - dLd_dTstar(k,l,m,n) = dLd_dTstar(k,l,m,n) & - + dudott_dt*prm%cleavage_systems(k,l,2,i) * prm%cleavage_systems(m,n,2,i) - endif - - traction_n = math_tensordot(S,prm%cleavage_systems(1:3,1:3,3,i)) - if (abs(traction_n) > traction_crit + tol_math_check) then - udotn = sign(1.0_pReal,traction_n)* prm%dot_o * ((abs(traction_n) - traction_crit)/traction_crit)**prm%q - Ld = Ld + udotn*prm%cleavage_systems(1:3,1:3,3,i) - dudotn_dt = sign(1.0_pReal,traction_n)*udotn*prm%q / (abs(traction_n) - traction_crit) - forall (k=1:3,l=1:3,m=1:3,n=1:3) & - dLd_dTstar(k,l,m,n) = dLd_dTstar(k,l,m,n) & - + dudotn_dt*prm%cleavage_systems(k,l,3,i) * prm%cleavage_systems(m,n,3,i) - endif - enddo - end associate - -end subroutine kinematics_cleavage_opening_LiAndItsTangent end submodule cleavageopening From a34edda4d9c7098543980b9caca91ca15cf97d47 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Feb 2021 22:06:44 +0100 Subject: [PATCH 242/352] fixed test for damage --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index fa5ef6139..2ed5cd4ba 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit fa5ef61395381b103a4babe52be145f960af0bbe +Subproject commit 2ed5cd4ba97b44ad9c8b61ced94060aee57a2dd8 From c09c2a6c8e123d42ee33527675a5096275cdf236 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 14 Feb 2021 00:50:42 +0100 Subject: [PATCH 243/352] easier to read without instance --- src/phase_mechanical.f90 | 12 +-- src/phase_mechanical_plastic.f90 | 6 +- ...phase_mechanical_plastic_kinehardening.f90 | 73 ++++++++----------- ...phase_mechanical_plastic_phenopowerlaw.f90 | 69 +++++++++--------- 4 files changed, 74 insertions(+), 86 deletions(-) diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index c10a916da..ae3967b26 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -135,13 +135,13 @@ submodule(phase) mechanical character(len=*), intent(in) :: group end subroutine plastic_isotropic_results - module subroutine plastic_phenopowerlaw_results(instance,group) - integer, intent(in) :: instance + module subroutine plastic_phenopowerlaw_results(ph,group) + integer, intent(in) :: ph character(len=*), intent(in) :: group end subroutine plastic_phenopowerlaw_results - module subroutine plastic_kinehardening_results(instance,group) - integer, intent(in) :: instance + module subroutine plastic_kinehardening_results(ph,group) + integer, intent(in) :: ph character(len=*), intent(in) :: group end subroutine plastic_kinehardening_results @@ -406,10 +406,10 @@ module subroutine mechanical_results(group,ph) call plastic_isotropic_results(phase_plasticInstance(ph),group//'plastic/') case(PLASTICITY_PHENOPOWERLAW_ID) - call plastic_phenopowerlaw_results(phase_plasticInstance(ph),group//'plastic/') + call plastic_phenopowerlaw_results(ph,group//'plastic/') case(PLASTICITY_KINEHARDENING_ID) - call plastic_kinehardening_results(phase_plasticInstance(ph),group//'plastic/') + call plastic_kinehardening_results(ph,group//'plastic/') case(PLASTICITY_DISLOTWIN_ID) call plastic_dislotwin_results(phase_plasticInstance(ph),group//'plastic/') diff --git a/src/phase_mechanical_plastic.f90 b/src/phase_mechanical_plastic.f90 index 843273c72..b08e27276 100644 --- a/src/phase_mechanical_plastic.f90 +++ b/src/phase_mechanical_plastic.f90 @@ -201,11 +201,11 @@ submodule(phase:mechanical) plastic el !< current element number end subroutine nonlocal_dependentState - module subroutine plastic_kinehardening_deltaState(Mp,instance,me) + module subroutine plastic_kinehardening_deltaState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me end subroutine plastic_kinehardening_deltaState @@ -417,7 +417,7 @@ module function plastic_deltaState(co, ip, el, ph, me) result(broken) plasticType: select case (phase_plasticity(ph)) case (PLASTICITY_KINEHARDENING_ID) plasticType - call plastic_kinehardening_deltaState(Mp,instance,me) + call plastic_kinehardening_deltaState(Mp,ph,me) broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,me))) case (PLASTICITY_NONLOCAL_ID) plasticType diff --git a/src/phase_mechanical_plastic_kinehardening.f90 b/src/phase_mechanical_plastic_kinehardening.f90 index 1244988de..14aa58fb9 100644 --- a/src/phase_mechanical_plastic_kinehardening.f90 +++ b/src/phase_mechanical_plastic_kinehardening.f90 @@ -62,7 +62,6 @@ module function plastic_kinehardening_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - Ninstances, & p, i, o, & Nconstituents, & sizeState, sizeDeltaState, sizeDotState, & @@ -81,25 +80,24 @@ module function plastic_kinehardening_init() result(myPlasticity) pl myPlasticity = plastic_active('kinehardening') - Ninstances = count(myPlasticity) - if(Ninstances == 0) return + if(count(myPlasticity) == 0) return print'(/,a)', ' <<<+- phase:mechanical:plastic:kinehardening init -+>>>' - print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) + print'(a,i0)', ' # phases: ',count(myPlasticity); flush(IO_STDOUT) - allocate(param(Ninstances)) - allocate(state(Ninstances)) - allocate(dotState(Ninstances)) - allocate(deltaState(Ninstances)) - phases => config_material%get('phase') - i = 0 + allocate(param(phases%length)) + allocate(state(phases%length)) + allocate(dotState(phases%length)) + allocate(deltaState(phases%length)) + + do p = 1, phases%length + if(.not. myPlasticity(p)) cycle phase => phases%get(p) mech => phase%get('mechanics') - if(.not. myPlasticity(p)) cycle - i = i + 1 + i = p associate(prm => param(i), & dot => dotState(i), & dlt => deltaState(i), & @@ -256,16 +254,16 @@ pure module subroutine kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) integer :: & i,k,l,m,n - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & gdot_pos,gdot_neg, & dgdot_dtau_pos,dgdot_dtau_neg Lp = 0.0_pReal dLp_dMp = 0.0_pReal - associate(prm => param(phase_plasticInstance(ph))) + associate(prm => param(ph)) - call kinetics(Mp,phase_plasticInstance(ph),me,gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) + call kinetics(Mp,ph,me,gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) do i = 1, prm%sum_N_sl Lp = Lp + (gdot_pos(i)+gdot_neg(i))*prm%P(1:3,1:3,i) @@ -293,14 +291,14 @@ module subroutine plastic_kinehardening_dotState(Mp,ph,me) real(pReal) :: & sumGamma - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & gdot_pos,gdot_neg - associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)),& - dot => dotState(phase_plasticInstance(ph))) + associate(prm => param(ph), stt => state(ph),& + dot => dotState(ph)) - call kinetics(Mp,phase_plasticInstance(ph),me,gdot_pos,gdot_neg) + call kinetics(Mp,ph,me,gdot_pos,gdot_neg) dot%accshear(:,me) = abs(gdot_pos+gdot_neg) sumGamma = sum(stt%accshear(:,me)) @@ -326,32 +324,25 @@ end subroutine plastic_kinehardening_dotState !-------------------------------------------------------------------------------------------------- !> @brief Calculate (instantaneous) incremental change of microstructure. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_kinehardening_deltaState(Mp,instance,me) +module subroutine plastic_kinehardening_deltaState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & gdot_pos,gdot_neg, & sense - associate(prm => param(instance), stt => state(instance), dlt => deltaState(instance)) + associate(prm => param(ph), stt => state(ph), dlt => deltaState(ph)) - call kinetics(Mp,instance,me,gdot_pos,gdot_neg) - sense = merge(state(instance)%sense(:,me), & ! keep existing... + call kinetics(Mp,ph,me,gdot_pos,gdot_neg) + sense = merge(state(ph)%sense(:,me), & ! keep existing... sign(1.0_pReal,gdot_pos+gdot_neg), & ! ...or have a defined dEq0(gdot_pos+gdot_neg,1e-10_pReal)) ! current sense of shear direction -#ifdef DEBUG - if (debugConstitutive%extensive & - .and. (me == prm%of_debug .or. .not. debugConstitutive%selective)) then - print*, '======= kinehardening delta state =======' - print*, sense,state(instance)%sense(:,me) - endif -#endif !-------------------------------------------------------------------------------------------------- ! switch in sense me shear? @@ -373,14 +364,14 @@ end subroutine plastic_kinehardening_deltaState !-------------------------------------------------------------------------------------------------- !> @brief Write results to HDF5 output file. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_kinehardening_results(instance,group) +module subroutine plastic_kinehardening_results(ph,group) - integer, intent(in) :: instance + integer, intent(in) :: ph character(len=*), intent(in) :: group integer :: o - associate(prm => param(instance), stt => state(instance)) + associate(prm => param(ph), stt => state(ph)) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case('xi') @@ -415,28 +406,28 @@ end subroutine plastic_kinehardening_results ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics(Mp,instance,me, & +pure subroutine kinetics(Mp,ph,me, & gdot_pos,gdot_neg,dgdot_dtau_pos,dgdot_dtau_neg) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me - real(pReal), intent(out), dimension(param(instance)%sum_N_sl) :: & + real(pReal), intent(out), dimension(param(ph)%sum_N_sl) :: & gdot_pos, & gdot_neg - real(pReal), intent(out), optional, dimension(param(instance)%sum_N_sl) :: & + real(pReal), intent(out), optional, dimension(param(ph)%sum_N_sl) :: & dgdot_dtau_pos, & dgdot_dtau_neg - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & tau_pos, & tau_neg integer :: i - associate(prm => param(instance), stt => state(instance)) + associate(prm => param(ph), stt => state(ph)) do i = 1, prm%sum_N_sl tau_pos(i) = math_tensordot(Mp,prm%nonSchmid_pos(1:3,1:3,i)) - stt%crss_back(i,me) diff --git a/src/phase_mechanical_plastic_phenopowerlaw.f90 b/src/phase_mechanical_plastic_phenopowerlaw.f90 index bea7ef06b..94214f14a 100644 --- a/src/phase_mechanical_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanical_plastic_phenopowerlaw.f90 @@ -70,7 +70,6 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - Ninstances, & p, i, & Nconstituents, & sizeState, sizeDotState, & @@ -91,24 +90,22 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) myPlasticity = plastic_active('phenopowerlaw') - Ninstances = count(myPlasticity) - if(Ninstances == 0) return + if(count(myPlasticity) == 0) return print'(/,a)', ' <<<+- phase:mechanical:plastic:phenopowerlaw init -+>>>' - print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) + print'(a,i0)', ' # phases: ',count(myPlasticity); flush(IO_STDOUT) - allocate(param(Ninstances)) - allocate(state(Ninstances)) - allocate(dotState(Ninstances)) - phases => config_material%get('phase') - i = 0 + allocate(param(phases%length)) + allocate(state(phases%length)) + allocate(dotState(phases%length)) + do p = 1, phases%length + if(.not. myPlasticity(p)) cycle phase => phases%get(p) mech => phase%get('mechanics') - if(.not. myPlasticity(p)) cycle - i = i + 1 + i = p associate(prm => param(i), & dot => dotState(i), & stt => state(i)) @@ -302,18 +299,18 @@ pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) integer :: & i,k,l,m,n - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & gdot_slip_pos,gdot_slip_neg, & dgdot_dtauslip_pos,dgdot_dtauslip_neg - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tw) :: & + real(pReal), dimension(param(ph)%sum_N_tw) :: & gdot_twin,dgdot_dtautwin Lp = 0.0_pReal dLp_dMp = 0.0_pReal - associate(prm => param(phase_plasticInstance(ph))) + associate(prm => param(ph)) - call kinetics_slip(Mp,phase_plasticInstance(ph),me,gdot_slip_pos,gdot_slip_neg,dgdot_dtauslip_pos,dgdot_dtauslip_neg) + call kinetics_slip(Mp,ph,me,gdot_slip_pos,gdot_slip_neg,dgdot_dtauslip_pos,dgdot_dtauslip_neg) slipSystems: do i = 1, prm%sum_N_sl Lp = Lp + (gdot_slip_pos(i)+gdot_slip_neg(i))*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -322,7 +319,7 @@ pure module subroutine phenopowerlaw_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) + dgdot_dtauslip_neg(i) * prm%P_sl(k,l,i) * prm%nonSchmid_neg(m,n,i) enddo slipSystems - call kinetics_twin(Mp,phase_plasticInstance(ph),me,gdot_twin,dgdot_dtautwin) + call kinetics_twin(Mp,ph,me,gdot_twin,dgdot_dtautwin) twinSystems: do i = 1, prm%sum_N_tw Lp = Lp + gdot_twin(i)*prm%P_tw(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -350,12 +347,12 @@ module subroutine phenopowerlaw_dotState(Mp,ph,me) c_SlipSlip,c_TwinSlip,c_TwinTwin, & xi_slip_sat_offset,& sumGamma,sumF - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & left_SlipSlip,right_SlipSlip, & gdot_slip_pos,gdot_slip_neg - associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)), & - dot => dotState(phase_plasticInstance(ph))) + associate(prm => param(ph), stt => state(ph), & + dot => dotState(ph)) sumGamma = sum(stt%gamma_slip(:,me)) sumF = sum(stt%gamma_twin(:,me)/prm%gamma_tw_char) @@ -375,9 +372,9 @@ module subroutine phenopowerlaw_dotState(Mp,ph,me) !-------------------------------------------------------------------------------------------------- ! shear rates - call kinetics_slip(Mp,phase_plasticInstance(ph),me,gdot_slip_pos,gdot_slip_neg) + call kinetics_slip(Mp,ph,me,gdot_slip_pos,gdot_slip_neg) dot%gamma_slip(:,me) = abs(gdot_slip_pos+gdot_slip_neg) - call kinetics_twin(Mp,phase_plasticInstance(ph),me,dot%gamma_twin(:,me)) + call kinetics_twin(Mp,ph,me,dot%gamma_twin(:,me)) !-------------------------------------------------------------------------------------------------- ! hardening @@ -395,14 +392,14 @@ end subroutine phenopowerlaw_dotState !-------------------------------------------------------------------------------------------------- !> @brief Write results to HDF5 output file. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_phenopowerlaw_results(instance,group) +module subroutine plastic_phenopowerlaw_results(ph,group) - integer, intent(in) :: instance + integer, intent(in) :: ph character(len=*), intent(in) :: group integer :: o - associate(prm => param(instance), stt => state(instance)) + associate(prm => param(ph), stt => state(ph)) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) @@ -434,28 +431,28 @@ end subroutine plastic_phenopowerlaw_results ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_slip(Mp,instance,me, & +pure subroutine kinetics_slip(Mp,ph,me, & gdot_slip_pos,gdot_slip_neg,dgdot_dtau_slip_pos,dgdot_dtau_slip_neg) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me - real(pReal), intent(out), dimension(param(instance)%sum_N_sl) :: & + real(pReal), intent(out), dimension(param(ph)%sum_N_sl) :: & gdot_slip_pos, & gdot_slip_neg - real(pReal), intent(out), optional, dimension(param(instance)%sum_N_sl) :: & + real(pReal), intent(out), optional, dimension(param(ph)%sum_N_sl) :: & dgdot_dtau_slip_pos, & dgdot_dtau_slip_neg - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & tau_slip_pos, & tau_slip_neg integer :: i - associate(prm => param(instance), stt => state(instance)) + associate(prm => param(ph), stt => state(ph)) do i = 1, prm%sum_N_sl tau_slip_pos(i) = math_tensordot(Mp,prm%nonSchmid_pos(1:3,1:3,i)) @@ -503,25 +500,25 @@ end subroutine kinetics_slip ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_twin(Mp,instance,me,& +pure subroutine kinetics_twin(Mp,ph,me,& gdot_twin,dgdot_dtau_twin) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me - real(pReal), dimension(param(instance)%sum_N_tw), intent(out) :: & + real(pReal), dimension(param(ph)%sum_N_tw), intent(out) :: & gdot_twin - real(pReal), dimension(param(instance)%sum_N_tw), intent(out), optional :: & + real(pReal), dimension(param(ph)%sum_N_tw), intent(out), optional :: & dgdot_dtau_twin - real(pReal), dimension(param(instance)%sum_N_tw) :: & + real(pReal), dimension(param(ph)%sum_N_tw) :: & tau_twin integer :: i - associate(prm => param(instance), stt => state(instance)) + associate(prm => param(ph), stt => state(ph)) do i = 1, prm%sum_N_tw tau_twin(i) = math_tensordot(Mp,prm%P_tw(1:3,1:3,i)) From 18971d7d8b54900fcca829cfa2253be4c2da27ce Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 14 Feb 2021 07:06:14 +0100 Subject: [PATCH 244/352] separation by instance does not add any value --- src/phase_mechanical.f90 | 22 ++-- src/phase_mechanical_eigen.f90 | 2 +- src/phase_mechanical_plastic.f90 | 12 +- ...phase_mechanical_plastic_dislotungsten.f90 | 63 +++++---- src/phase_mechanical_plastic_dislotwin.f90 | 122 +++++++++--------- src/phase_mechanical_plastic_isotropic.f90 | 39 +++--- src/phase_mechanical_plastic_nonlocal.f90 | 2 +- 7 files changed, 129 insertions(+), 133 deletions(-) diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index ae3967b26..394c3d3ba 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -60,7 +60,7 @@ submodule(phase) mechanical module subroutine plastic_init end subroutine plastic_init - module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) + module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,ph,me) real(pReal), dimension(3,3), intent(out) :: & Li !< inleastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -68,7 +68,7 @@ submodule(phase) mechanical real(pReal), dimension(3,3), intent(in) :: & Mi !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me end subroutine plastic_isotropic_LiAndItsTangent @@ -130,8 +130,8 @@ submodule(phase) mechanical end subroutine plastic_LpAndItsTangents - module subroutine plastic_isotropic_results(instance,group) - integer, intent(in) :: instance + module subroutine plastic_isotropic_results(ph,group) + integer, intent(in) :: ph character(len=*), intent(in) :: group end subroutine plastic_isotropic_results @@ -145,13 +145,13 @@ submodule(phase) mechanical character(len=*), intent(in) :: group end subroutine plastic_kinehardening_results - module subroutine plastic_dislotwin_results(instance,group) - integer, intent(in) :: instance + module subroutine plastic_dislotwin_results(ph,group) + integer, intent(in) :: ph character(len=*), intent(in) :: group end subroutine plastic_dislotwin_results - module subroutine plastic_dislotungsten_results(instance,group) - integer, intent(in) :: instance + module subroutine plastic_dislotungsten_results(ph,group) + integer, intent(in) :: ph character(len=*), intent(in) :: group end subroutine plastic_dislotungsten_results @@ -403,7 +403,7 @@ module subroutine mechanical_results(group,ph) select case(phase_plasticity(ph)) case(PLASTICITY_ISOTROPIC_ID) - call plastic_isotropic_results(phase_plasticInstance(ph),group//'plastic/') + call plastic_isotropic_results(ph,group//'plastic/') case(PLASTICITY_PHENOPOWERLAW_ID) call plastic_phenopowerlaw_results(ph,group//'plastic/') @@ -412,10 +412,10 @@ module subroutine mechanical_results(group,ph) call plastic_kinehardening_results(ph,group//'plastic/') case(PLASTICITY_DISLOTWIN_ID) - call plastic_dislotwin_results(phase_plasticInstance(ph),group//'plastic/') + call plastic_dislotwin_results(ph,group//'plastic/') case(PLASTICITY_DISLOTUNGSTEN_ID) - call plastic_dislotungsten_results(phase_plasticInstance(ph),group//'plastic/') + call plastic_dislotungsten_results(ph,group//'plastic/') case(PLASTICITY_NONLOCAL_ID) call plastic_nonlocal_results(phase_plasticInstance(ph),group//'plastic/') diff --git a/src/phase_mechanical_eigen.f90 b/src/phase_mechanical_eigen.f90 index bee7dc2d2..ce974a6a6 100644 --- a/src/phase_mechanical_eigen.f90 +++ b/src/phase_mechanical_eigen.f90 @@ -180,7 +180,7 @@ module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & plasticType: select case (phase_plasticity(ph)) case (PLASTICITY_isotropic_ID) plasticType - call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,phase_plasticInstance(ph),me) + call plastic_isotropic_LiAndItsTangent(my_Li, my_dLi_dS, S ,ph,me) Li = Li + my_Li dLi_dS = dLi_dS + my_dLi_dS active = .true. diff --git a/src/phase_mechanical_plastic.f90 b/src/phase_mechanical_plastic.f90 index b08e27276..a13b5c73f 100644 --- a/src/phase_mechanical_plastic.f90 +++ b/src/phase_mechanical_plastic.f90 @@ -179,17 +179,17 @@ submodule(phase:mechanical) plastic el !< current element number end subroutine nonlocal_dotState - module subroutine dislotwin_dependentState(T,instance,me) + module subroutine dislotwin_dependentState(T,ph,me) integer, intent(in) :: & - instance, & + ph, & me real(pReal), intent(in) :: & T end subroutine dislotwin_dependentState - module subroutine dislotungsten_dependentState(instance,me) + module subroutine dislotungsten_dependentState(ph,me) integer, intent(in) :: & - instance, & + ph, & me end subroutine dislotungsten_dependentState @@ -374,10 +374,10 @@ module subroutine plastic_dependentState(co, ip, el) plasticType: select case (phase_plasticity(material_phaseAt(co,el))) case (PLASTICITY_DISLOTWIN_ID) plasticType - call dislotwin_dependentState(thermal_T(ph,me),instance,me) + call dislotwin_dependentState(thermal_T(ph,me),ph,me) case (PLASTICITY_DISLOTUNGSTEN_ID) plasticType - call dislotungsten_dependentState(instance,me) + call dislotungsten_dependentState(ph,me) case (PLASTICITY_NONLOCAL_ID) plasticType call nonlocal_dependentState(instance,me,ip,el) diff --git a/src/phase_mechanical_plastic_dislotungsten.f90 b/src/phase_mechanical_plastic_dislotungsten.f90 index 6eb1e4abe..81c4605ac 100644 --- a/src/phase_mechanical_plastic_dislotungsten.f90 +++ b/src/phase_mechanical_plastic_dislotungsten.f90 @@ -78,7 +78,6 @@ module function plastic_dislotungsten_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - Ninstances, & p, i, & Nconstituents, & sizeState, sizeDotState, & @@ -97,29 +96,29 @@ module function plastic_dislotungsten_init() result(myPlasticity) mech, & pl + myPlasticity = plastic_active('dislotungsten') - Ninstances = count(myPlasticity) - if(Ninstances == 0) return + if(count(myPlasticity) == 0) return print'(/,a)', ' <<<+- phase:mechanical:plastic:dislotungsten init -+>>>' - print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) - + print'(a,i0)', ' # phases: ',count(myPlasticity); flush(IO_STDOUT) print*, 'Cereceda et al., International Journal of Plasticity 78:242–256, 2016' print*, 'https://dx.doi.org/10.1016/j.ijplas.2015.09.002' - allocate(param(Ninstances)) - allocate(state(Ninstances)) - allocate(dotState(Ninstances)) - allocate(dependentState(Ninstances)) phases => config_material%get('phase') - i = 0 + allocate(param(phases%length)) + allocate(state(phases%length)) + allocate(dotState(phases%length)) + allocate(dependentState(phases%length)) + + do p = 1, phases%length + if(.not. myPlasticity(p)) cycle phase => phases%get(p) mech => phase%get('mechanics') - if(.not. myPlasticity(p)) cycle - i = i + 1 + i = p associate(prm => param(i), & dot => dotState(i), & stt => state(i), & @@ -290,16 +289,16 @@ pure module subroutine dislotungsten_LpAndItsTangent(Lp,dLp_dMp, & integer :: & i,k,l,m,n - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & dot_gamma_pos,dot_gamma_neg, & ddot_gamma_dtau_pos,ddot_gamma_dtau_neg Lp = 0.0_pReal dLp_dMp = 0.0_pReal - associate(prm => param(phase_plasticInstance(ph))) + associate(prm => param(ph)) - call kinetics(Mp,T,phase_plasticInstance(ph),me,dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg) + call kinetics(Mp,T,ph,me,dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg) do i = 1, prm%sum_N_sl Lp = Lp + (dot_gamma_pos(i)+dot_gamma_neg(i))*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -328,7 +327,7 @@ module subroutine dislotungsten_dotState(Mp,T,ph,me) real(pReal) :: & VacancyDiffusion - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & gdot_pos, gdot_neg,& tau_pos,& tau_neg, & @@ -337,10 +336,10 @@ module subroutine dislotungsten_dotState(Mp,T,ph,me) dot_rho_dip_climb, & dip_distance - associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)),& - dot => dotState(phase_plasticInstance(ph)), dst => dependentState(phase_plasticInstance(ph))) + associate(prm => param(ph), stt => state(ph),& + dot => dotState(ph), dst => dependentState(ph)) - call kinetics(Mp,T,phase_plasticInstance(ph),me,& + call kinetics(Mp,T,ph,me,& gdot_pos,gdot_neg, & tau_pos_out = tau_pos,tau_neg_out = tau_neg) @@ -377,16 +376,16 @@ end subroutine dislotungsten_dotState !-------------------------------------------------------------------------------------------------- !> @brief Calculate derived quantities from state. !-------------------------------------------------------------------------------------------------- -module subroutine dislotungsten_dependentState(instance,me) +module subroutine dislotungsten_dependentState(ph,me) integer, intent(in) :: & - instance, & + ph, & me - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & dislocationSpacing - associate(prm => param(instance), stt => state(instance),dst => dependentState(instance)) + associate(prm => param(ph), stt => state(ph),dst => dependentState(ph)) dislocationSpacing = sqrt(matmul(prm%forestProjection,stt%rho_mob(:,me)+stt%rho_dip(:,me))) dst%threshold_stress(:,me) = prm%mu*prm%b_sl & @@ -402,14 +401,14 @@ end subroutine dislotungsten_dependentState !-------------------------------------------------------------------------------------------------- !> @brief Write results to HDF5 output file. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotungsten_results(instance,group) +module subroutine plastic_dislotungsten_results(ph,group) - integer, intent(in) :: instance + integer, intent(in) :: ph character(len=*), intent(in) :: group integer :: o - associate(prm => param(instance), stt => state(instance), dst => dependentState(instance)) + associate(prm => param(ph), stt => state(ph), dst => dependentState(ph)) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case('rho_mob') @@ -441,7 +440,7 @@ end subroutine plastic_dislotungsten_results ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics(Mp,T,instance,me, & +pure subroutine kinetics(Mp,T,ph,me, & dot_gamma_pos,dot_gamma_neg,ddot_gamma_dtau_pos,ddot_gamma_dtau_neg,tau_pos_out,tau_neg_out) real(pReal), dimension(3,3), intent(in) :: & @@ -449,18 +448,18 @@ pure subroutine kinetics(Mp,T,instance,me, & real(pReal), intent(in) :: & T !< temperature integer, intent(in) :: & - instance, & + ph, & me - real(pReal), intent(out), dimension(param(instance)%sum_N_sl) :: & + real(pReal), intent(out), dimension(param(ph)%sum_N_sl) :: & dot_gamma_pos, & dot_gamma_neg - real(pReal), intent(out), optional, dimension(param(instance)%sum_N_sl) :: & + real(pReal), intent(out), optional, dimension(param(ph)%sum_N_sl) :: & ddot_gamma_dtau_pos, & ddot_gamma_dtau_neg, & tau_pos_out, & tau_neg_out - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & StressRatio, & StressRatio_p,StressRatio_pminus1, & dvel, vel, & @@ -469,7 +468,7 @@ pure subroutine kinetics(Mp,T,instance,me, & needsGoodName ! ToDo: @Karo: any idea? integer :: j - associate(prm => param(instance), stt => state(instance), dst => dependentState(instance)) + associate(prm => param(ph), stt => state(ph), dst => dependentState(ph)) do j = 1, prm%sum_N_sl tau_pos(j) = math_tensordot(Mp,prm%nonSchmid_pos(1:3,1:3,j)) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index ca385f417..3b33196d9 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -48,7 +48,7 @@ submodule(phase:plastic) dislotwin dot_N_0_tr, & !< trans nucleation rate [1/m³s] for each trans system t_tw, & !< twin thickness [m] for each twin system i_sl, & !< Adj. parameter for distance between 2 forest dislocations for each slip system - t_tr, & !< martensite lamellar thickness [m] for each trans system and instance + t_tr, & !< martensite lamellar thickness [m] for each trans system p, & !< p-exponent in glide velocity q, & !< q-exponent in glide velocity r, & !< r-exponent in twin nucleation rate @@ -126,7 +126,6 @@ module function plastic_dislotwin_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - Ninstances, & p, i, & Nconstituents, & sizeState, sizeDotState, & @@ -144,12 +143,12 @@ module function plastic_dislotwin_init() result(myPlasticity) mech, & pl + myPlasticity = plastic_active('dislotwin') - Ninstances = count(myPlasticity) - if(Ninstances == 0) return + if(count(myPlasticity) == 0) return print'(/,a)', ' <<<+- phase:mechanical:plastic:dislotwin init -+>>>' - print'(a,i0)', ' # phases: ',Ninstances; flush(IO_STDOUT) + print'(a,i0)', ' # phases: ',count(myPlasticity); flush(IO_STDOUT) print*, 'Ma and Roters, Acta Materialia 52(12):3603–3612, 2004' print*, 'https://doi.org/10.1016/j.actamat.2004.04.012'//IO_EOL @@ -160,18 +159,19 @@ module function plastic_dislotwin_init() result(myPlasticity) print*, 'Wong et al., Acta Materialia 118:140–151, 2016' print*, 'https://doi.org/10.1016/j.actamat.2016.07.032' - allocate(param(Ninstances)) - allocate(state(Ninstances)) - allocate(dotState(Ninstances)) - allocate(dependentState(Ninstances)) phases => config_material%get('phase') - i = 0 + allocate(param(phases%length)) + allocate(state(phases%length)) + allocate(dotState(phases%length)) + allocate(dependentState(phases%length)) + + do p = 1, phases%length + if(.not. myPlasticity(p)) cycle phase => phases%get(p) mech => phase%get('mechanics') - if(.not. myPlasticity(p)) cycle - i = i + 1 + i = p associate(prm => param(i), & dot => dotState(i), & stt => state(i), & @@ -496,8 +496,8 @@ module function plastic_dislotwin_homogenizedC(ph,me) result(homogenizedC) real(pReal) :: f_unrotated - associate(prm => param(phase_plasticInstance(ph)),& - stt => state(phase_plasticInstance(ph))) + associate(prm => param(ph),& + stt => state(ph)) f_unrotated = 1.0_pReal & - sum(stt%f_tw(1:prm%sum_N_tw,me)) & @@ -535,11 +535,11 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) BoltzmannRatio, & ddot_gamma_dtau, & tau - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & dot_gamma_sl,ddot_gamma_dtau_slip - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tw) :: & + real(pReal), dimension(param(ph)%sum_N_tw) :: & dot_gamma_twin,ddot_gamma_dtau_twin - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tr) :: & + real(pReal), dimension(param(ph)%sum_N_tr) :: & dot_gamma_tr,ddot_gamma_dtau_trans real(pReal):: dot_gamma_sb real(pReal), dimension(3,3) :: eigVectors, P_sb @@ -564,7 +564,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) 0, 1, 1 & ],pReal),[ 3,6]) - associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph))) + associate(prm => param(ph), stt => state(ph)) f_unrotated = 1.0_pReal & - sum(stt%f_tw(1:prm%sum_N_tw,me)) & @@ -573,7 +573,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) Lp = 0.0_pReal dLp_dMp = 0.0_pReal - call kinetics_slip(Mp,T,phase_plasticInstance(ph),me,dot_gamma_sl,ddot_gamma_dtau_slip) + call kinetics_slip(Mp,T,ph,me,dot_gamma_sl,ddot_gamma_dtau_slip) slipContribution: do i = 1, prm%sum_N_sl Lp = Lp + dot_gamma_sl(i)*prm%P_sl(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -581,7 +581,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) + ddot_gamma_dtau_slip(i) * prm%P_sl(k,l,i) * prm%P_sl(m,n,i) enddo slipContribution - call kinetics_twin(Mp,T,dot_gamma_sl,phase_plasticInstance(ph),me,dot_gamma_twin,ddot_gamma_dtau_twin) + call kinetics_twin(Mp,T,dot_gamma_sl,ph,me,dot_gamma_twin,ddot_gamma_dtau_twin) twinContibution: do i = 1, prm%sum_N_tw Lp = Lp + dot_gamma_twin(i)*prm%P_tw(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -589,7 +589,7 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) + ddot_gamma_dtau_twin(i)* prm%P_tw(k,l,i)*prm%P_tw(m,n,i) enddo twinContibution - call kinetics_trans(Mp,T,dot_gamma_sl,phase_plasticInstance(ph),me,dot_gamma_tr,ddot_gamma_dtau_trans) + call kinetics_trans(Mp,T,dot_gamma_sl,ph,me,dot_gamma_tr,ddot_gamma_dtau_trans) transContibution: do i = 1, prm%sum_N_tr Lp = Lp + dot_gamma_tr(i)*prm%P_tr(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & @@ -653,24 +653,24 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) tau, & sigma_cl, & !< climb stress b_d !< ratio of Burgers vector to stacking fault width - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & dot_rho_dip_formation, & dot_rho_dip_climb, & rho_dip_distance_min, & dot_gamma_sl - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tw) :: & + real(pReal), dimension(param(ph)%sum_N_tw) :: & dot_gamma_twin - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_tr) :: & + real(pReal), dimension(param(ph)%sum_N_tr) :: & dot_gamma_tr - associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)), & - dot => dotState(phase_plasticInstance(ph)), dst => dependentState(phase_plasticInstance(ph))) + associate(prm => param(ph), stt => state(ph), & + dot => dotState(ph), dst => dependentState(ph)) f_unrotated = 1.0_pReal & - sum(stt%f_tw(1:prm%sum_N_tw,me)) & - sum(stt%f_tr(1:prm%sum_N_tr,me)) - call kinetics_slip(Mp,T,phase_plasticInstance(ph),me,dot_gamma_sl) + call kinetics_slip(Mp,T,ph,me,dot_gamma_sl) dot%gamma_sl(:,me) = abs(dot_gamma_sl) rho_dip_distance_min = prm%D_a*prm%b_sl @@ -721,10 +721,10 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) - 2.0_pReal*rho_dip_distance_min/prm%b_sl * stt%rho_dip(:,me)*abs(dot_gamma_sl) & - dot_rho_dip_climb - call kinetics_twin(Mp,T,dot_gamma_sl,phase_plasticInstance(ph),me,dot_gamma_twin) + call kinetics_twin(Mp,T,dot_gamma_sl,ph,me,dot_gamma_twin) dot%f_tw(:,me) = f_unrotated*dot_gamma_twin/prm%gamma_char - call kinetics_trans(Mp,T,dot_gamma_sl,phase_plasticInstance(ph),me,dot_gamma_tr) + call kinetics_trans(Mp,T,dot_gamma_sl,ph,me,dot_gamma_tr) dot%f_tr(:,me) = f_unrotated*dot_gamma_tr end associate @@ -735,33 +735,33 @@ end subroutine dislotwin_dotState !-------------------------------------------------------------------------------------------------- !> @brief Calculate derived quantities from state. !-------------------------------------------------------------------------------------------------- -module subroutine dislotwin_dependentState(T,instance,me) +module subroutine dislotwin_dependentState(T,ph,me) integer, intent(in) :: & - instance, & + ph, & me real(pReal), intent(in) :: & T real(pReal) :: & sumf_twin,Gamma,sumf_trans - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & inv_lambda_sl_sl, & !< 1/mean free distance between 2 forest dislocations seen by a moving dislocation inv_lambda_sl_tw, & !< 1/mean free distance between 2 twin stacks from different systems seen by a moving dislocation inv_lambda_sl_tr !< 1/mean free distance between 2 martensite lamellar from different systems seen by a moving dislocation - real(pReal), dimension(param(instance)%sum_N_tw) :: & + real(pReal), dimension(param(ph)%sum_N_tw) :: & inv_lambda_tw_tw, & !< 1/mean free distance between 2 twin stacks from different systems seen by a growing twin f_over_t_tw - real(pReal), dimension(param(instance)%sum_N_tr) :: & + real(pReal), dimension(param(ph)%sum_N_tr) :: & inv_lambda_tr_tr, & !< 1/mean free distance between 2 martensite stacks from different systems seen by a growing martensite f_over_t_tr real(pReal), dimension(:), allocatable :: & x0 - associate(prm => param(instance),& - stt => state(instance),& - dst => dependentState(instance)) + associate(prm => param(ph),& + stt => state(ph),& + dst => dependentState(ph)) sumf_twin = sum(stt%f_tw(1:prm%sum_N_tw,me)) sumf_trans = sum(stt%f_tr(1:prm%sum_N_tr,me)) @@ -827,14 +827,14 @@ end subroutine dislotwin_dependentState !-------------------------------------------------------------------------------------------------- !> @brief Write results to HDF5 output file. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_dislotwin_results(instance,group) +module subroutine plastic_dislotwin_results(ph,group) - integer, intent(in) :: instance + integer, intent(in) :: ph character(len=*), intent(in) :: group integer :: o - associate(prm => param(instance), stt => state(instance), dst => dependentState(instance)) + associate(prm => param(ph), stt => state(ph), dst => dependentState(ph)) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) @@ -882,7 +882,7 @@ end subroutine plastic_dislotwin_results ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_slip(Mp,T,instance,me, & +pure subroutine kinetics_slip(Mp,T,ph,me, & dot_gamma_sl,ddot_gamma_dtau_slip,tau_slip) real(pReal), dimension(3,3), intent(in) :: & @@ -890,18 +890,18 @@ pure subroutine kinetics_slip(Mp,T,instance,me, & real(pReal), intent(in) :: & T !< temperature integer, intent(in) :: & - instance, & + ph, & me - real(pReal), dimension(param(instance)%sum_N_sl), intent(out) :: & + real(pReal), dimension(param(ph)%sum_N_sl), intent(out) :: & dot_gamma_sl - real(pReal), dimension(param(instance)%sum_N_sl), optional, intent(out) :: & + real(pReal), dimension(param(ph)%sum_N_sl), optional, intent(out) :: & ddot_gamma_dtau_slip, & tau_slip - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & ddot_gamma_dtau - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & tau, & stressRatio, & StressRatio_p, & @@ -914,7 +914,7 @@ pure subroutine kinetics_slip(Mp,T,instance,me, & tau_eff !< effective resolved stress integer :: i - associate(prm => param(instance), stt => state(instance), dst => dependentState(instance)) + associate(prm => param(ph), stt => state(ph), dst => dependentState(ph)) do i = 1, prm%sum_N_sl tau(i) = math_tensordot(Mp,prm%P_sl(1:3,1:3,i)) @@ -959,7 +959,7 @@ end subroutine kinetics_slip ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,instance,me,& +pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,ph,me,& dot_gamma_twin,ddot_gamma_dtau_twin) real(pReal), dimension(3,3), intent(in) :: & @@ -967,17 +967,17 @@ pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,instance,me,& real(pReal), intent(in) :: & T !< temperature integer, intent(in) :: & - instance, & + ph, & me - real(pReal), dimension(param(instance)%sum_N_sl), intent(in) :: & + real(pReal), dimension(param(ph)%sum_N_sl), intent(in) :: & dot_gamma_sl - real(pReal), dimension(param(instance)%sum_N_tw), intent(out) :: & + real(pReal), dimension(param(ph)%sum_N_tw), intent(out) :: & dot_gamma_twin - real(pReal), dimension(param(instance)%sum_N_tw), optional, intent(out) :: & + real(pReal), dimension(param(ph)%sum_N_tw), optional, intent(out) :: & ddot_gamma_dtau_twin - real, dimension(param(instance)%sum_N_tw) :: & + real, dimension(param(ph)%sum_N_tw) :: & tau, & Ndot0, & stressRatio_r, & @@ -985,7 +985,7 @@ pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,instance,me,& integer :: i,s1,s2 - associate(prm => param(instance), stt => state(instance), dst => dependentState(instance)) + associate(prm => param(ph), stt => state(ph), dst => dependentState(ph)) do i = 1, prm%sum_N_tw tau(i) = math_tensordot(Mp,prm%P_tw(1:3,1:3,i)) @@ -1028,7 +1028,7 @@ end subroutine kinetics_twin ! NOTE: Against the common convention, the result (i.e. intent(out)) variables are the last to ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,instance,me,& +pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,ph,me,& dot_gamma_tr,ddot_gamma_dtau_trans) real(pReal), dimension(3,3), intent(in) :: & @@ -1036,24 +1036,24 @@ pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,instance,me,& real(pReal), intent(in) :: & T !< temperature integer, intent(in) :: & - instance, & + ph, & me - real(pReal), dimension(param(instance)%sum_N_sl), intent(in) :: & + real(pReal), dimension(param(ph)%sum_N_sl), intent(in) :: & dot_gamma_sl - real(pReal), dimension(param(instance)%sum_N_tr), intent(out) :: & + real(pReal), dimension(param(ph)%sum_N_tr), intent(out) :: & dot_gamma_tr - real(pReal), dimension(param(instance)%sum_N_tr), optional, intent(out) :: & + real(pReal), dimension(param(ph)%sum_N_tr), optional, intent(out) :: & ddot_gamma_dtau_trans - real, dimension(param(instance)%sum_N_tr) :: & + real, dimension(param(ph)%sum_N_tr) :: & tau, & Ndot0, & stressRatio_s, & ddot_gamma_dtau integer :: i,s1,s2 - associate(prm => param(instance), stt => state(instance), dst => dependentState(instance)) + associate(prm => param(ph), stt => state(ph), dst => dependentState(ph)) do i = 1, prm%sum_N_tr tau(i) = math_tensordot(Mp,prm%P_tr(1:3,1:3,i)) diff --git a/src/phase_mechanical_plastic_isotropic.f90 b/src/phase_mechanical_plastic_isotropic.f90 index e315a38fb..39a4b3a7c 100644 --- a/src/phase_mechanical_plastic_isotropic.f90 +++ b/src/phase_mechanical_plastic_isotropic.f90 @@ -53,7 +53,6 @@ module function plastic_isotropic_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - Ninstances, & p, & i, & Nconstituents, & @@ -68,28 +67,26 @@ module function plastic_isotropic_init() result(myPlasticity) mech, & pl + myPlasticity = plastic_active('isotropic') - Ninstances = count(myPlasticity) - if(Ninstances == 0) return + if(count(myPlasticity) == 0) return print'(/,a)', ' <<<+- phase:mechanical:plastic:isotropic init -+>>>' - print'(a,i0)', ' # phses: ',Ninstances; flush(IO_STDOUT) - + print'(a,i0)', ' # phases: ',count(myPlasticity); flush(IO_STDOUT) print*, 'Maiti and Eisenlohr, Scripta Materialia 145:37–40, 2018' print*, 'https://doi.org/10.1016/j.scriptamat.2017.09.047' - allocate(param(Ninstances)) - allocate(state(Ninstances)) - allocate(dotState(Ninstances)) - phases => config_material%get('phase') - i = 0 + allocate(param(phases%length)) + allocate(state(phases%length)) + allocate(dotState(phases%length)) + do p = 1, phases%length + if(.not. myPlasticity(p)) cycle phase => phases%get(p) mech => phase%get('mechanics') - if(.not. myPlasticity(p)) cycle - i = i + 1 + i = p associate(prm => param(i), & dot => dotState(i), & stt => state(i)) @@ -191,7 +188,7 @@ module subroutine isotropic_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) integer :: & k, l, m, n - associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph))) + associate(prm => param(ph), stt => state(ph)) Mp_dev = math_deviatoric33(Mp) squarenorm_Mp_dev = math_tensordot(Mp_dev,Mp_dev) @@ -221,7 +218,7 @@ end subroutine isotropic_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief Calculate inelastic velocity gradient and its tangent. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) +module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,ph,me) real(pReal), dimension(3,3), intent(out) :: & Li !< inleastic velocity gradient @@ -231,7 +228,7 @@ module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) real(pReal), dimension(3,3), intent(in) :: & Mi !< Mandel stress integer, intent(in) :: & - instance, & + ph, & me real(pReal) :: & @@ -239,7 +236,7 @@ module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,instance,me) integer :: & k, l, m, n - associate(prm => param(instance), stt => state(instance)) + associate(prm => param(ph), stt => state(ph)) tr=math_trace33(math_spherical33(Mi)) @@ -276,8 +273,8 @@ module subroutine isotropic_dotState(Mp,ph,me) xi_inf_star, & !< saturation xi norm_Mp !< norm of the (deviatoric) Mandel stress - associate(prm => param(phase_plasticInstance(ph)), stt => state(phase_plasticInstance(ph)), & - dot => dotState(phase_plasticInstance(ph))) + associate(prm => param(ph), stt => state(ph), & + dot => dotState(ph)) if (prm%dilatation) then norm_Mp = sqrt(math_tensordot(Mp,Mp)) @@ -313,14 +310,14 @@ end subroutine isotropic_dotState !-------------------------------------------------------------------------------------------------- !> @brief Write results to HDF5 output file. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_isotropic_results(instance,group) +module subroutine plastic_isotropic_results(ph,group) - integer, intent(in) :: instance + integer, intent(in) :: ph character(len=*), intent(in) :: group integer :: o - associate(prm => param(instance), stt => state(instance)) + associate(prm => param(ph), stt => state(ph)) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case ('xi') diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 4e94f83ae..285217e1b 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -521,7 +521,7 @@ module function plastic_nonlocal_init() result(myPlasticity) if(.not. myPlasticity(p)) cycle i = i + 1 - Nconstituents = count(material_phaseAt==p) * discretization_nIPs + Nconstituents = count(material_phaseAt2 == p) l = 0 do t = 1,4 do s = 1,param(i)%sum_N_sl From 5a1ca012f8f0abb1d9ca1ff6a4bbdecde24145b3 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 14 Feb 2021 14:36:56 +0100 Subject: [PATCH 245/352] more suitable data structure no need to know (ip,el) at the constitutive level --- src/phase_mechanical_eigen.f90 | 1 - src/phase_mechanical_plastic_nonlocal.f90 | 38 +++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/phase_mechanical_eigen.f90 b/src/phase_mechanical_eigen.f90 index ce974a6a6..eb6d4f219 100644 --- a/src/phase_mechanical_eigen.f90 +++ b/src/phase_mechanical_eigen.f90 @@ -186,7 +186,6 @@ module subroutine phase_LiAndItsTangents(Li, dLi_dS, dLi_dFi, & active = .true. end select plasticType - KinematicsLoop: do k = 1, Nmodels(ph) kinematicsType: select case (model(k,ph)) case (KINEMATICS_thermal_expansion_ID) kinematicsType diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 285217e1b..8f8e6cf3d 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -13,6 +13,12 @@ submodule(phase:plastic) nonlocal IPareaNormal => geometry_plastic_nonlocal_IPareaNormal0, & geometry_plastic_nonlocal_disable + type :: tGeometry + real(pReal), dimension(:), allocatable :: V_0 + end type tGeometry + + type(tGeometry), dimension(:), allocatable :: geom + real(pReal), parameter :: & kB = 1.38e-23_pReal !< Boltzmann constant in J/Kelvin @@ -203,6 +209,10 @@ module function plastic_nonlocal_init() result(myPlasticity) print*, 'Kords, Dissertation RWTH Aachen, 2014' print*, 'http://publications.rwth-aachen.de/record/229993' + + phases => config_material%get('phase') + allocate(geom(phases%length)) + allocate(param(Ninstances)) allocate(state(Ninstances)) allocate(state0(Ninstances)) @@ -210,7 +220,7 @@ module function plastic_nonlocal_init() result(myPlasticity) allocate(deltaState(Ninstances)) allocate(microstructure(Ninstances)) - phases => config_material%get('phase') + i = 0 do p = 1, phases%length phase => phases%get(p) @@ -225,7 +235,7 @@ module function plastic_nonlocal_init() result(myPlasticity) dst => microstructure(i)) pl => mech%get('plasticity') - phase_localPlasticity(p) = .not. pl%contains('nonlocal') + phase_localPlasticity(p) = .not. pl%contains('nonlocal') #if defined (__GFORTRAN__) prm%output = output_asStrings(pl) @@ -409,6 +419,9 @@ module function plastic_nonlocal_init() result(myPlasticity) call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,sizeDeltaState) + allocate(geom(p)%V_0(Nconstituents)) + call storeGeometry(p) + plasticState(p)%nonlocal = pl%get_asBool('nonlocal') if(plasticState(p)%nonlocal .and. .not. allocated(IPneighborhood)) & call IO_error(212,ext_msg='IPneighborhood does not exist') @@ -1831,4 +1844,25 @@ pure function getRho0(instance,me,ip,el) end function getRho0 + +subroutine storeGeometry(ph) + + integer, intent(in) :: ph + + integer :: ip, el, ce, co + + ce = 0 + do el = 1, size(material_homogenizationMemberAt,2) + do ip = 1, size(material_homogenizationMemberAt,1) + ce = ce + 1 + do co = 1, homogenization_maxNconstituents + if(material_phaseAt2(co,ce) == ph) then + geom(ph)%V_0(material_phaseMemberAt2(co,ce)) = IPvolume(ip,el) + endif + enddo + enddo + enddo + +end subroutine + end submodule nonlocal From 4026881e5a08204c2e117cd1bcb8e9eaf62f2954 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 14 Feb 2021 15:29:10 +0100 Subject: [PATCH 246/352] clean interface still need to get rid of internal converstion to instance and el,ip arguments --- src/phase.f90 | 6 +- src/phase_mechanical.f90 | 6 +- src/phase_mechanical_plastic.f90 | 12 +- src/phase_mechanical_plastic_nonlocal.f90 | 195 +++++++++++----------- 4 files changed, 107 insertions(+), 112 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index f129ba92f..39d5cc340 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -247,9 +247,9 @@ module phase TDot end subroutine phase_thermal_getRate - module subroutine plastic_nonlocal_updateCompatibility(orientation,instance,i,e) + module subroutine plastic_nonlocal_updateCompatibility(orientation,ph,i,e) integer, intent(in) :: & - instance, & + ph, & i, & e type(rotation), dimension(1,discretization_nIPs,discretization_Nelems), intent(in) :: & @@ -616,7 +616,7 @@ subroutine crystallite_orientations(co,ip,el) if (plasticState(material_phaseAt(1,el))%nonlocal) & call plastic_nonlocal_updateCompatibility(crystallite_orientation, & - phase_plasticInstance(material_phaseAt(1,el)),ip,el) + material_phaseAt(1,el),ip,el) end subroutine crystallite_orientations diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index 394c3d3ba..824c1e257 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -155,8 +155,8 @@ submodule(phase) mechanical character(len=*), intent(in) :: group end subroutine plastic_dislotungsten_results - module subroutine plastic_nonlocal_results(instance,group) - integer, intent(in) :: instance + module subroutine plastic_nonlocal_results(ph,group) + integer, intent(in) :: ph character(len=*), intent(in) :: group end subroutine plastic_nonlocal_results @@ -418,7 +418,7 @@ module subroutine mechanical_results(group,ph) call plastic_dislotungsten_results(ph,group//'plastic/') case(PLASTICITY_NONLOCAL_ID) - call plastic_nonlocal_results(phase_plasticInstance(ph),group//'plastic/') + call plastic_nonlocal_results(ph,group//'plastic/') end select diff --git a/src/phase_mechanical_plastic.f90 b/src/phase_mechanical_plastic.f90 index a13b5c73f..cf9faf6c9 100644 --- a/src/phase_mechanical_plastic.f90 +++ b/src/phase_mechanical_plastic.f90 @@ -193,9 +193,9 @@ submodule(phase:mechanical) plastic me end subroutine dislotungsten_dependentState - module subroutine nonlocal_dependentState(instance, me, ip, el) + module subroutine nonlocal_dependentState(ph, me, ip, el) integer, intent(in) :: & - instance, & + ph, & me, & ip, & !< current integration point el !< current element number @@ -209,11 +209,11 @@ submodule(phase:mechanical) plastic me end subroutine plastic_kinehardening_deltaState - module subroutine plastic_nonlocal_deltaState(Mp,instance,me,ip,el) + module subroutine plastic_nonlocal_deltaState(Mp,ph,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp integer, intent(in) :: & - instance, & + ph, & me, & ip, & el @@ -380,7 +380,7 @@ module subroutine plastic_dependentState(co, ip, el) call dislotungsten_dependentState(ph,me) case (PLASTICITY_NONLOCAL_ID) plasticType - call nonlocal_dependentState(instance,me,ip,el) + call nonlocal_dependentState(ph,me,ip,el) end select plasticType @@ -421,7 +421,7 @@ module function plastic_deltaState(co, ip, el, ph, me) result(broken) broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,me))) case (PLASTICITY_NONLOCAL_ID) plasticType - call plastic_nonlocal_deltaState(Mp,instance,me,ip,el) + call plastic_nonlocal_deltaState(Mp,ph,me,ip,el) broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,me))) case default diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 8f8e6cf3d..1f6fce029 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -12,6 +12,8 @@ submodule(phase:plastic) nonlocal IParea => geometry_plastic_nonlocal_IParea0, & IPareaNormal => geometry_plastic_nonlocal_IPareaNormal0, & geometry_plastic_nonlocal_disable + use phase, & + ins => phase_plasticInstance type :: tGeometry real(pReal), dimension(:), allocatable :: V_0 @@ -160,7 +162,7 @@ submodule(phase:plastic) nonlocal state, & state0 - type(tParameters), dimension(:), allocatable :: param !< containers of constitutive parameters (len Ninstances) + type(tParameters), dimension(:), allocatable :: param !< containers of constitutive parameters type(tNonlocalMicrostructure), dimension(:), allocatable :: microstructure @@ -510,7 +512,7 @@ module function plastic_nonlocal_init() result(myPlasticity) allocate(dst%tau_back(prm%sum_N_sl,Nconstituents),source=0.0_pReal) end associate - if (Nconstituents > 0) call stateInit(ini,p,Nconstituents,i) + if (Nconstituents > 0) call stateInit(ini,p,Nconstituents) plasticState(p)%state0 = plasticState(p)%state !-------------------------------------------------------------------------------------------------- @@ -565,10 +567,10 @@ end function plastic_nonlocal_init !-------------------------------------------------------------------------------------------------- !> @brief calculates quantities characterizing the microstructure !-------------------------------------------------------------------------------------------------- -module subroutine nonlocal_dependentState(instance, me, ip, el) +module subroutine nonlocal_dependentState(ph, me, ip, el) integer, intent(in) :: & - instance, & + ph, & me, & ip, & el @@ -602,29 +604,29 @@ module subroutine nonlocal_dependentState(instance, me, ip, el) invConnections real(pReal), dimension(3,nIPneighbors) :: & connection_latticeConf - real(pReal), dimension(2,param(instance)%sum_N_sl) :: & + real(pReal), dimension(2,param(ins(ph))%sum_N_sl) :: & rhoExcess - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl) :: & rho_edg_delta, & rho_scr_delta - real(pReal), dimension(param(instance)%sum_N_sl,10) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & rho, & rho0, & rho_neighbor0 - real(pReal), dimension(param(instance)%sum_N_sl,param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,param(ins(ph))%sum_N_sl) :: & myInteractionMatrix ! corrected slip interaction matrix - real(pReal), dimension(param(instance)%sum_N_sl,nIPneighbors) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,nIPneighbors) :: & rho_edg_delta_neighbor, & rho_scr_delta_neighbor real(pReal), dimension(2,maxval(param%sum_N_sl),nIPneighbors) :: & neighbor_rhoExcess, & ! excess density at neighboring material point neighbor_rhoTotal ! total density at neighboring material point - real(pReal), dimension(3,param(instance)%sum_N_sl,2) :: & + real(pReal), dimension(3,param(ins(ph))%sum_N_sl,2) :: & m ! direction of dislocation motion - associate(prm => param(instance),dst => microstructure(instance), stt => state(instance)) + associate(prm => param(ins(ph)),dst => microstructure(ins(ph)), stt => state(ins(ph))) - rho = getRho(instance,me,ip,el) + rho = getRho(ph,me,ip,el) stt%rho_forest(:,me) = matmul(prm%forestProjection_Edge, sum(abs(rho(:,edg)),2)) & + matmul(prm%forestProjection_Screw,sum(abs(rho(:,scr)),2)) @@ -652,9 +654,8 @@ module subroutine nonlocal_dependentState(instance, me, ip, el) ! ToDo: MD: this is most likely only correct for F_i = I !################################################################################################# - rho0 = getRho0(instance,me,ip,el) + rho0 = getRho0(ph,me,ip,el) if (.not. phase_localPlasticity(material_phaseAt(1,el)) .and. prm%shortRangeStressCorrection) then - ph = material_phaseAt(1,el) invFp = math_inv33(phase_mechanical_Fp(ph)%data(1:3,1:3,me)) invFe = math_inv33(phase_mechanical_Fe(ph)%data(1:3,1:3,me)) @@ -675,11 +676,11 @@ module subroutine nonlocal_dependentState(instance, me, ip, el) neighbor_ip = IPneighborhood(2,n,ip,el) no = material_phasememberAt(1,neighbor_ip,neighbor_el) if (neighbor_el > 0 .and. neighbor_ip > 0) then - neighbor_instance = phase_plasticInstance(material_phaseAt(1,neighbor_el)) - if (neighbor_instance == instance) then + neighbor_instance = ins(material_phaseAt(1,neighbor_el)) + if (neighbor_instance == ins(ph)) then nRealNeighbors = nRealNeighbors + 1.0_pReal - rho_neighbor0 = getRho0(instance,no,neighbor_ip,neighbor_el) + rho_neighbor0 = getRho0(ph,no,neighbor_ip,neighbor_el) rho_edg_delta_neighbor(:,n) = rho_neighbor0(:,mob_edg_pos) - rho_neighbor0(:,mob_edg_neg) rho_scr_delta_neighbor(:,n) = rho_neighbor0(:,mob_scr_pos) - rho_neighbor0(:,mob_scr_neg) @@ -795,25 +796,25 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & l, & t, & !< dislocation type s !< index of my current slip system - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,8) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,8) :: & rhoSgl !< single dislocation densities (including blocked) - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & rho - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,4) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,4) :: & v, & !< velocity tauNS, & !< resolved shear stress including non Schmid and backstress terms dv_dtau, & !< velocity derivative with respect to the shear stress dv_dtauNS !< velocity derivative with respect to the shear stress - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl) :: & tau, & !< resolved shear stress including backstress terms gdotTotal !< shear rate - associate(prm => param(phase_plasticInstance(ph)),dst=>microstructure(phase_plasticInstance(ph)),& - stt=>state(phase_plasticInstance(ph))) + associate(prm => param(ins(ph)),dst=>microstructure(ins(ph)),& + stt=>state(ins(ph))) ns = prm%sum_N_sl !*** shortcut to state variables - rho = getRho(phase_plasticInstance(ph),me,ip,el) + rho = getRho(ph,me,ip,el) rhoSgl = rho(:,sgl) do s = 1,ns @@ -833,7 +834,7 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & ! edges call kinetics(v(:,1), dv_dtau(:,1), dv_dtauNS(:,1), & - tau, tauNS(:,1), dst%tau_pass(:,me),1,Temperature, phase_plasticInstance(ph)) + tau, tauNS(:,1), dst%tau_pass(:,me),1,Temperature, ph) v(:,2) = v(:,1) dv_dtau(:,2) = dv_dtau(:,1) dv_dtauNS(:,2) = dv_dtauNS(:,1) @@ -846,7 +847,7 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & else do t = 3,4 call kinetics(v(:,t), dv_dtau(:,t), dv_dtauNS(:,t), & - tau, tauNS(:,t), dst%tau_pass(:,me),2,Temperature, phase_plasticInstance(ph)) + tau, tauNS(:,t), dst%tau_pass(:,me),2,Temperature, ph) enddo endif @@ -879,12 +880,12 @@ end subroutine nonlocal_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief (instantaneous) incremental change of microstructure !-------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_deltaState(Mp,instance,me,ip,el) +module subroutine plastic_nonlocal_deltaState(Mp,ph,me,ip,el) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress integer, intent(in) :: & - instance, & ! current instance of this plasticity + ph, & me, & !< offset ip, & el @@ -895,31 +896,29 @@ module subroutine plastic_nonlocal_deltaState(Mp,instance,me,ip,el) c, & ! character of dislocation t, & ! type of dislocation s ! index of my current slip system - real(pReal), dimension(param(instance)%sum_N_sl,10) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & deltaRhoRemobilization, & ! density increment by remobilization deltaRhoDipole2SingleStress ! density increment by dipole dissociation (by stress change) - real(pReal), dimension(param(instance)%sum_N_sl,10) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & rho ! current dislocation densities - real(pReal), dimension(param(instance)%sum_N_sl,4) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,4) :: & v ! dislocation glide velocity - real(pReal), dimension(param(instance)%sum_N_sl) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl) :: & tau ! current resolved shear stress - real(pReal), dimension(param(instance)%sum_N_sl,2) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,2) :: & rhoDip, & ! current dipole dislocation densities (screw and edge dipoles) dUpper, & ! current maximum stable dipole distance for edges and screws dUpperOld, & ! old maximum stable dipole distance for edges and screws deltaDUpper ! change in maximum stable dipole distance for edges and screws - ph = material_phaseAt(1,el) - - associate(prm => param(instance),dst => microstructure(instance),del => deltaState(instance)) - ns = prm%sum_N_sl + associate(prm => param(ins(ph)),dst => microstructure(ins(ph)),del => deltaState(ins(ph))) + ns = prm%sum_N_sl !*** shortcut to state variables - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,instance),me) - forall (s = 1:ns, c = 1:2) dUpperOld(s,c) = plasticState(ph)%state(iD(s,c,instance),me) + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ins(ph)),me) + forall (s = 1:ns, c = 1:2) dUpperOld(s,c) = plasticState(ph)%state(iD(s,c,ins(ph)),me) - rho = getRho(instance,me,ip,el) + rho = getRho(ph,me,ip,el) rhoDip = rho(:,dip) !**************************************************************************** @@ -964,7 +963,7 @@ module subroutine plastic_nonlocal_deltaState(Mp,instance,me,ip,el) / (dUpperOld(s,c) - prm%minDipoleHeight(s,c)) forall (t=1:4) deltaRhoDipole2SingleStress(:,t) = -0.5_pReal * deltaRhoDipole2SingleStress(:,(t-1)/2+9) - forall (s = 1:ns, c = 1:2) plasticState(ph)%state(iD(s,c,instance),me) = dUpper(s,c) + forall (s = 1:ns, c = 1:2) plasticState(ph)%state(iD(s,c,ins(ph)),me) = dUpper(s,c) plasticState(ph)%deltaState(:,me) = 0.0_pReal del%rho(:,me) = reshape(deltaRhoRemobilization + deltaRhoDipole2SingleStress, [10*ns]) @@ -1005,7 +1004,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & c, & !< character of dislocation t, & !< type of dislocation s !< index of my current slip system - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & rho, & rho0, & !< dislocation density at beginning of time step rhoDot, & !< density evolution @@ -1013,17 +1012,17 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & rhoDotSingle2DipoleGlide, & !< density evolution by dipole formation (by glide) rhoDotAthermalAnnihilation, & !< density evolution by athermal annihilation rhoDotThermalAnnihilation !< density evolution by thermal annihilation - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,8) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,8) :: & rhoSgl, & !< current single dislocation densities (positive/negative screw and edge without dipoles) my_rhoSgl0 !< single dislocation densities of central ip (positive/negative screw and edge without dipoles) - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,4) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,4) :: & v, & !< current dislocation glide velocity v0, & gdot !< shear rates - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl) :: & tau, & !< current resolved shear stress vClimb !< climb velocity of edge dipoles - real(pReal), dimension(param(phase_plasticInstance(ph))%sum_N_sl,2) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,2) :: & rhoDip, & !< current dipole dislocation densities (screw and edge dipoles) dLower, & !< minimum stable dipole distance for edges and screws dUpper !< current maximum stable dipole distance for edges and screws @@ -1035,22 +1034,22 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & return endif - associate(prm => param(phase_plasticInstance(ph)), & - dst => microstructure(phase_plasticInstance(ph)), & - dot => dotState(phase_plasticInstance(ph)), & - stt => state(phase_plasticInstance(ph))) + associate(prm => param(ins(ph)), & + dst => microstructure(ins(ph)), & + dot => dotState(ins(ph)), & + stt => state(ins(ph))) ns = prm%sum_N_sl tau = 0.0_pReal gdot = 0.0_pReal - rho = getRho(phase_plasticInstance(ph),me,ip,el) + rho = getRho(ph,me,ip,el) rhoSgl = rho(:,sgl) rhoDip = rho(:,dip) - rho0 = getRho0(phase_plasticInstance(ph),me,ip,el) + rho0 = getRho0(ph,me,ip,el) my_rhoSgl0 = rho0(:,sgl) - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,phase_plasticInstance(ph)),me) + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ins(ph)),me) gdot = rhoSgl(:,1:4) * v * spread(prm%b_sl,2,4) #ifdef DEBUG @@ -1099,7 +1098,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & * sqrt(stt%rho_forest(:,me)) / prm%i_sl / prm%b_sl, 2, 4) endif isBCC - forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,phase_plasticInstance(ph)),me) + forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,ins(ph)),me) !**************************************************************************** @@ -1155,7 +1154,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & - rhoDip(s,1) / timestep - rhoDotAthermalAnnihilation(s,9) & - rhoDotSingle2DipoleGlide(s,9)) ! make sure that we do not annihilate more dipoles than we have - rhoDot = rhoDotFlux(timestep, phase_plasticInstance(ph),me,ip,el) & + rhoDot = rhoDotFlux(timestep, ph,me,ip,el) & + rhoDotMultiplication & + rhoDotSingle2DipoleGlide & + rhoDotAthermalAnnihilation & @@ -1184,12 +1183,12 @@ end subroutine nonlocal_dotState !--------------------------------------------------------------------------------------------------- !> @brief calculates the rate of change of microstructure !--------------------------------------------------------------------------------------------------- -function rhoDotFlux(timestep,instance,me,ip,el) +function rhoDotFlux(timestep,ph,me,ip,el) real(pReal), intent(in) :: & timestep !< substepped crystallite time increment integer, intent(in) :: & - instance, & + ph, & me, & ip, & !< current integration point el !< current element number @@ -1212,20 +1211,20 @@ function rhoDotFlux(timestep,instance,me,ip,el) np,& !< neighbor phase shortcut topp, & !< type of dislocation with opposite sign to t s !< index of my current slip system - real(pReal), dimension(param(instance)%sum_N_sl,10) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & rho, & rho0, & !< dislocation density at beginning of time step rhoDotFlux !< density evolution by flux - real(pReal), dimension(param(instance)%sum_N_sl,8) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,8) :: & rhoSgl, & !< current single dislocation densities (positive/negative screw and edge without dipoles) neighbor_rhoSgl0, & !< current single dislocation densities of neighboring ip (positive/negative screw and edge without dipoles) my_rhoSgl0 !< single dislocation densities of central ip (positive/negative screw and edge without dipoles) - real(pReal), dimension(param(instance)%sum_N_sl,4) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl,4) :: & v, & !< current dislocation glide velocity v0, & neighbor_v0, & !< dislocation glide velocity of enighboring ip gdot !< shear rates - real(pReal), dimension(3,param(instance)%sum_N_sl,4) :: & + real(pReal), dimension(3,param(ins(ph))%sum_N_sl,4) :: & m !< direction of dislocation motion real(pReal), dimension(3,3) :: & my_F, & !< my total deformation gradient @@ -1243,26 +1242,25 @@ function rhoDotFlux(timestep,instance,me,ip,el) transmissivity, & !< overall transmissivity of dislocation flux to neighboring material point lineLength !< dislocation line length leaving the current interface - ph = material_phaseAt(1,el) - associate(prm => param(instance), & - dst => microstructure(instance), & - dot => dotState(instance), & - stt => state(instance)) + associate(prm => param(ins(ph)), & + dst => microstructure(ins(ph)), & + dot => dotState(ins(ph)), & + stt => state(ins(ph))) ns = prm%sum_N_sl gdot = 0.0_pReal - rho = getRho(instance,me,ip,el) + rho = getRho(ph,me,ip,el) rhoSgl = rho(:,sgl) - rho0 = getRho0(instance,me,ip,el) + rho0 = getRho0(ph,me,ip,el) my_rhoSgl0 = rho0(:,sgl) - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,instance),me) !ToDo: MD: I think we should use state0 here + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ins(ph)),me) !ToDo: MD: I think we should use state0 here gdot = rhoSgl(:,1:4) * v * spread(prm%b_sl,2,4) - forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,instance),me) + forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,ins(ph)),me) !**************************************************************************** !*** calculate dislocation fluxes (only for nonlocal plasticity) @@ -1314,7 +1312,7 @@ function rhoDotFlux(timestep,instance,me,ip,el) opposite_n = IPneighborhood(3,opposite_neighbor,ip,el) if (neighbor_n > 0) then ! if neighbor exists, average deformation gradient - neighbor_instance = phase_plasticInstance(material_phaseAt(1,neighbor_el)) + neighbor_instance = ins(material_phaseAt(1,neighbor_el)) neighbor_F = phase_mechanical_F(np)%data(1:3,1:3,no) neighbor_Fe = matmul(neighbor_F, math_inv33(phase_mechanical_Fp(np)%data(1:3,1:3,no))) Favg = 0.5_pReal * (my_F + neighbor_F) @@ -1421,12 +1419,12 @@ end function rhoDotFlux ! plane normals and signed cosine of the angle between the slip directions. Only the largest values ! that sum up to a total of 1 are considered, all others are set to zero. !-------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_updateCompatibility(orientation,instance,i,e) +module subroutine plastic_nonlocal_updateCompatibility(orientation,ph,i,e) type(rotation), dimension(1,discretization_nIPs,discretization_Nelems), intent(in) :: & orientation ! crystal orientation integer, intent(in) :: & - instance, & + ph, & i, & e @@ -1439,19 +1437,17 @@ module subroutine plastic_nonlocal_updateCompatibility(orientation,instance,i,e) ns, & ! number of active slip systems s1, & ! slip system index (me) s2 ! slip system index (my neighbor) - real(pReal), dimension(2,param(instance)%sum_N_sl,param(instance)%sum_N_sl,nIPneighbors) :: & + real(pReal), dimension(2,param(ins(ph))%sum_N_sl,param(ins(ph))%sum_N_sl,nIPneighbors) :: & my_compatibility ! my_compatibility for current element and ip real(pReal) :: & my_compatibilitySum, & thresholdValue, & nThresholdValues - logical, dimension(param(instance)%sum_N_sl) :: & + logical, dimension(param(ins(ph))%sum_N_sl) :: & belowThreshold type(rotation) :: mis - ph = material_phaseAt(1,e) - - associate(prm => param(instance)) + associate(prm => param(ins(ph))) ns = prm%sum_N_sl !*** start out fully compatible @@ -1537,14 +1533,14 @@ end subroutine plastic_nonlocal_updateCompatibility !-------------------------------------------------------------------------------------------------- !> @brief writes results to HDF5 output file !-------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_results(instance,group) +module subroutine plastic_nonlocal_results(ph,group) - integer, intent(in) :: instance + integer, intent(in) :: ph character(len=*),intent(in) :: group integer :: o - associate(prm => param(instance),dst => microstructure(instance),stt=>state(instance)) + associate(prm => param(ins(ph)),dst => microstructure(ins(ph)),stt=>state(ins(ph))) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case('rho_u_ed_pos') @@ -1608,14 +1604,13 @@ end subroutine plastic_nonlocal_results !-------------------------------------------------------------------------------------------------- !> @brief populates the initial dislocation density !-------------------------------------------------------------------------------------------------- -subroutine stateInit(ini,phase,Nconstituents,instance) +subroutine stateInit(ini,phase,Nconstituents) type(tInitialParameters) :: & ini integer,intent(in) :: & phase, & - Nconstituents, & - instance + Nconstituents integer :: & e, & i, & @@ -1636,7 +1631,7 @@ subroutine stateInit(ini,phase,Nconstituents,instance) volume - associate(stt => state(instance)) + associate(stt => state(ins(phase))) if (ini%random_rho_u > 0.0_pReal) then ! randomly distribute dislocation segments on random slip system and of random type in the volume do e = 1,discretization_Nelems @@ -1684,18 +1679,18 @@ end subroutine stateInit !-------------------------------------------------------------------------------------------------- !> @brief calculates kinetics !-------------------------------------------------------------------------------------------------- -pure subroutine kinetics(v, dv_dtau, dv_dtauNS, tau, tauNS, tauThreshold, c, Temperature, instance) +pure subroutine kinetics(v, dv_dtau, dv_dtauNS, tau, tauNS, tauThreshold, c, Temperature, ph) integer, intent(in) :: & c, & !< dislocation character (1:edge, 2:screw) - instance + ph real(pReal), intent(in) :: & Temperature !< temperature - real(pReal), dimension(param(instance)%sum_N_sl), intent(in) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl), intent(in) :: & tau, & !< resolved external shear stress (without non Schmid effects) tauNS, & !< resolved external shear stress (including non Schmid effects) tauThreshold !< threshold shear stress - real(pReal), dimension(param(instance)%sum_N_sl), intent(out) :: & + real(pReal), dimension(param(ins(ph))%sum_N_sl), intent(out) :: & v, & !< velocity dv_dtau, & !< velocity derivative with respect to resolved shear stress (without non Schmid contributions) dv_dtauNS !< velocity derivative with respect to resolved shear stress (including non Schmid contributions) @@ -1726,7 +1721,7 @@ pure subroutine kinetics(v, dv_dtau, dv_dtauNS, tau, tauNS, tauThreshold, c, Tem criticalStress_S, & !< maximum obstacle strength mobility !< dislocation mobility - associate(prm => param(instance)) + associate(prm => param(ins(ph))) ns = prm%sum_N_sl v = 0.0_pReal dv_dtau = 0.0_pReal @@ -1799,14 +1794,14 @@ end subroutine kinetics !> @brief returns copy of current dislocation densities from state !> @details raw values is rectified !-------------------------------------------------------------------------------------------------- -pure function getRho(instance,me,ip,el) +pure function getRho(ph,me,ip,el) - integer, intent(in) :: instance, me,ip,el - real(pReal), dimension(param(instance)%sum_N_sl,10) :: getRho + integer, intent(in) :: ph, me,ip,el + real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: getRho - associate(prm => param(instance)) + associate(prm => param(ins(ph))) - getRho = reshape(state(instance)%rho(:,me),[prm%sum_N_sl,10]) + getRho = reshape(state(ins(ph))%rho(:,me),[prm%sum_N_sl,10]) ! ensure positive densities (not for imm, they have a sign) getRho(:,mob) = max(getRho(:,mob),0.0_pReal) @@ -1824,14 +1819,14 @@ end function getRho !> @brief returns copy of current dislocation densities from state !> @details raw values is rectified !-------------------------------------------------------------------------------------------------- -pure function getRho0(instance,me,ip,el) +pure function getRho0(ph,me,ip,el) - integer, intent(in) :: instance, me,ip,el - real(pReal), dimension(param(instance)%sum_N_sl,10) :: getRho0 + integer, intent(in) :: ph, me,ip,el + real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: getRho0 - associate(prm => param(instance)) + associate(prm => param(ins(ph))) - getRho0 = reshape(state0(instance)%rho(:,me),[prm%sum_N_sl,10]) + getRho0 = reshape(state0(ins(ph))%rho(:,me),[prm%sum_N_sl,10]) ! ensure positive densities (not for imm, they have a sign) getRho0(:,mob) = max(getRho0(:,mob),0.0_pReal) From f46d212e47bdc3e675092dc236ee99a0dd3e3b66 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 14 Feb 2021 17:29:23 +0100 Subject: [PATCH 247/352] simplified access pattern --- src/phase_mechanical.f90 | 23 +++--- src/phase_mechanical_plastic.f90 | 34 ++++----- src/phase_mechanical_plastic_nonlocal.f90 | 85 ++++++++++------------- 3 files changed, 56 insertions(+), 86 deletions(-) diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index 824c1e257..381820dcc 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -85,11 +85,8 @@ submodule(phase) mechanical logical :: broken end function plastic_dotState - module function plastic_deltaState(co, ip, el, ph, me) result(broken) + module function plastic_deltaState(ph, me) result(broken) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el, & !< element ph, & me logical :: & @@ -114,11 +111,9 @@ submodule(phase) mechanical module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & - S, Fi, co, ip, el) + S, Fi, ph,me) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + ph,me real(pReal), intent(in), dimension(3,3) :: & S, & !< 2nd Piola-Kirchhoff stress Fi !< intermediate deformation gradient @@ -538,7 +533,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) Fe, Fi_new, co, ip, el) call plastic_LpAndItsTangents(Lp_constitutive, dLp_dS, dLp_dFi, & - S, Fi_new, co, ip, el) + S, Fi_new, ph,me) !* update current residuum and check for convergence of loop atol_Lp = max(num%rtol_crystalliteStress * max(norm2(Lpguess),norm2(Lp_constitutive)), & ! absolute tolerance from largest acceptable relative error @@ -702,7 +697,7 @@ function integrateStateFPI(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) resul plasticState(ph)%state(1:sizeDotState,me) = plasticState(ph)%state(1:sizeDotState,me) & - r(1:sizeDotState) if (converged(r(1:sizeDotState),plasticState(ph)%state(1:sizeDotState,me),plasticState(ph)%atol(1:sizeDotState))) then - broken = plastic_deltaState(co,ip,el,ph,me) + broken = plastic_deltaState(ph,me) exit iteration endif @@ -765,7 +760,7 @@ function integrateStateEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el) res plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotState(1:sizeDotState,me) * Delta_t - broken = plastic_deltaState(co,ip,el,ph,me) + broken = plastic_deltaState(ph,me) if(broken) return broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) @@ -807,7 +802,7 @@ function integrateStateAdaptiveEuler(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip plasticState(ph)%state(1:sizeDotState,me) = subState0 & + plasticState(ph)%dotstate(1:sizeDotState,me) * Delta_t - broken = plastic_deltaState(co,ip,el,ph,me) + broken = plastic_deltaState(ph,me) if(broken) return broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) @@ -956,7 +951,7 @@ function integrateStateRK(F_0,F,subFp0,subFi0,subState0,Delta_t,co,ip,el,A,B,C,D if(broken) return - broken = plastic_deltaState(co,ip,el,ph,me) + broken = plastic_deltaState(ph,me) if(broken) return broken = integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) @@ -1329,7 +1324,7 @@ module function phase_mechanical_dPdF(dt,co,ip,el) result(dPdF) call plastic_LpAndItsTangents(devNull,dLpdS,dLpdFi, & phase_mechanical_S(ph)%data(1:3,1:3,me), & - phase_mechanical_Fi(ph)%data(1:3,1:3,me),co,ip,el) + phase_mechanical_Fi(ph)%data(1:3,1:3,me),ph,me) dLpdS = math_mul3333xx3333(dLpdFi,dFidS) + dLpdS !-------------------------------------------------------------------------------------------------- diff --git a/src/phase_mechanical_plastic.f90 b/src/phase_mechanical_plastic.f90 index cf9faf6c9..c8e9b6271 100644 --- a/src/phase_mechanical_plastic.f90 +++ b/src/phase_mechanical_plastic.f90 @@ -104,7 +104,7 @@ submodule(phase:mechanical) plastic end subroutine dislotungsten_LpAndItsTangent module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & - Mp,Temperature,ph,me,ip,el) + Mp,Temperature,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp real(pReal), dimension(3,3,3,3), intent(out) :: & @@ -116,9 +116,7 @@ submodule(phase:mechanical) plastic Temperature integer, intent(in) :: & ph, & - me, & - ip, & !< current integration point - el !< current element number + me end subroutine nonlocal_LpAndItsTangent @@ -209,14 +207,12 @@ submodule(phase:mechanical) plastic me end subroutine plastic_kinehardening_deltaState - module subroutine plastic_nonlocal_deltaState(Mp,ph,me,ip,el) + module subroutine plastic_nonlocal_deltaState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp integer, intent(in) :: & ph, & - me, & - ip, & - el + me end subroutine plastic_nonlocal_deltaState end interface @@ -244,11 +240,9 @@ end subroutine plastic_init ! Mp in, dLp_dMp out !-------------------------------------------------------------------------------------------------- module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & - S, Fi, co, ip, el) + S, Fi, ph,me) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + ph,me real(pReal), intent(in), dimension(3,3) :: & S, & !< 2nd Piola-Kirchhoff stress Fi !< intermediate deformation gradient @@ -263,14 +257,13 @@ module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & real(pReal), dimension(3,3) :: & Mp !< Mandel stress work conjugate with Lp integer :: & - i, j, me, ph + i, j Mp = matmul(matmul(transpose(Fi),Fi),S) - me = material_phasememberAt(co,ip,el) - ph = material_phaseAt(co,el) - plasticType: select case (phase_plasticity(material_phaseAt(co,el))) + + plasticType: select case (phase_plasticity(ph)) case (PLASTICITY_NONE_ID) plasticType Lp = 0.0_pReal @@ -286,7 +279,7 @@ module subroutine plastic_LpAndItsTangents(Lp, dLp_dS, dLp_dFi, & call kinehardening_LpAndItsTangent(Lp,dLp_dMp,Mp,ph,me) case (PLASTICITY_NONLOCAL_ID) plasticType - call nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),ph,me,ip,el) + call nonlocal_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),ph,me) case (PLASTICITY_DISLOTWIN_ID) plasticType call dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp, thermal_T(ph,me),ph,me) @@ -391,12 +384,9 @@ end subroutine plastic_dependentState !> @brief for constitutive models having an instantaneous change of state !> will return false if delta state is not needed/supported by the constitutive model !-------------------------------------------------------------------------------------------------- -module function plastic_deltaState(co, ip, el, ph, me) result(broken) +module function plastic_deltaState(ph, me) result(broken) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el, & !< element ph, & me logical :: & @@ -421,7 +411,7 @@ module function plastic_deltaState(co, ip, el, ph, me) result(broken) broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,me))) case (PLASTICITY_NONLOCAL_ID) plasticType - call plastic_nonlocal_deltaState(Mp,ph,me,ip,el) + call plastic_nonlocal_deltaState(Mp,ph,me) broken = any(IEEE_is_NaN(plasticState(ph)%deltaState(:,me))) case default diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 1f6fce029..b579a3164 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -512,7 +512,7 @@ module function plastic_nonlocal_init() result(myPlasticity) allocate(dst%tau_back(prm%sum_N_sl,Nconstituents),source=0.0_pReal) end associate - if (Nconstituents > 0) call stateInit(ini,p,Nconstituents) + if (Nconstituents > 0) call stateInit(ini,p,Nconstituents,i) plasticState(p)%state0 = plasticState(p)%state !-------------------------------------------------------------------------------------------------- @@ -576,7 +576,6 @@ module subroutine nonlocal_dependentState(ph, me, ip, el) el integer :: & - ph, & no, & !< neighbor offset neighbor_el, & ! element number of neighboring material point neighbor_ip, & ! integration point of neighboring material point @@ -626,7 +625,7 @@ module subroutine nonlocal_dependentState(ph, me, ip, el) associate(prm => param(ins(ph)),dst => microstructure(ins(ph)), stt => state(ins(ph))) - rho = getRho(ph,me,ip,el) + rho = getRho(ph,me) stt%rho_forest(:,me) = matmul(prm%forestProjection_Edge, sum(abs(rho(:,edg)),2)) & + matmul(prm%forestProjection_Screw,sum(abs(rho(:,scr)),2)) @@ -654,7 +653,7 @@ module subroutine nonlocal_dependentState(ph, me, ip, el) ! ToDo: MD: this is most likely only correct for F_i = I !################################################################################################# - rho0 = getRho0(ph,me,ip,el) + rho0 = getRho0(ph,me) if (.not. phase_localPlasticity(material_phaseAt(1,el)) .and. prm%shortRangeStressCorrection) then invFp = math_inv33(phase_mechanical_Fp(ph)%data(1:3,1:3,me)) invFe = math_inv33(phase_mechanical_Fe(ph)%data(1:3,1:3,me)) @@ -665,7 +664,7 @@ module subroutine nonlocal_dependentState(ph, me, ip, el) rhoExcess(1,:) = rho_edg_delta rhoExcess(2,:) = rho_scr_delta - FVsize = IPvolume(ip,el) ** (1.0_pReal/3.0_pReal) + FVsize = geom(ph)%V_0(me) ** (1.0_pReal/3.0_pReal) !* loop through my neighborhood and get the connection vectors (in lattice frame) and the excess densities @@ -680,7 +679,7 @@ module subroutine nonlocal_dependentState(ph, me, ip, el) if (neighbor_instance == ins(ph)) then nRealNeighbors = nRealNeighbors + 1.0_pReal - rho_neighbor0 = getRho0(ph,no,neighbor_ip,neighbor_el) + rho_neighbor0 = getRho0(ph,no) rho_edg_delta_neighbor(:,n) = rho_neighbor0(:,mob_edg_pos) - rho_neighbor0(:,mob_edg_neg) rho_scr_delta_neighbor(:,n) = rho_neighbor0(:,mob_scr_pos) - rho_neighbor0(:,mob_scr_neg) @@ -772,16 +771,14 @@ end subroutine nonlocal_dependentState !> @brief calculates plastic velocity gradient and its tangent !-------------------------------------------------------------------------------------------------- module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & - Mp,Temperature,ph,me,ip,el) + Mp,Temperature,ph,me) real(pReal), dimension(3,3), intent(out) :: & Lp !< plastic velocity gradient real(pReal), dimension(3,3,3,3), intent(out) :: & dLp_dMp integer, intent(in) :: & ph, & - me, & - ip, & !< current integration point - el !< current element number + me real(pReal), intent(in) :: & Temperature !< temperature @@ -814,7 +811,7 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & ns = prm%sum_N_sl !*** shortcut to state variables - rho = getRho(ph,me,ip,el) + rho = getRho(ph,me) rhoSgl = rho(:,sgl) do s = 1,ns @@ -880,18 +877,15 @@ end subroutine nonlocal_LpAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief (instantaneous) incremental change of microstructure !-------------------------------------------------------------------------------------------------- -module subroutine plastic_nonlocal_deltaState(Mp,ph,me,ip,el) +module subroutine plastic_nonlocal_deltaState(Mp,ph,me) real(pReal), dimension(3,3), intent(in) :: & Mp !< MandelStress integer, intent(in) :: & ph, & - me, & !< offset - ip, & - el + me integer :: & - ph, & !< phase ns, & ! short notation for the total number of active slip systems c, & ! character of dislocation t, & ! type of dislocation @@ -918,7 +912,7 @@ module subroutine plastic_nonlocal_deltaState(Mp,ph,me,ip,el) forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ins(ph)),me) forall (s = 1:ns, c = 1:2) dUpperOld(s,c) = plasticState(ph)%state(iD(s,c,ins(ph)),me) - rho = getRho(ph,me,ip,el) + rho = getRho(ph,me) rhoDip = rho(:,dip) !**************************************************************************** @@ -968,15 +962,6 @@ module subroutine plastic_nonlocal_deltaState(Mp,ph,me,ip,el) plasticState(ph)%deltaState(:,me) = 0.0_pReal del%rho(:,me) = reshape(deltaRhoRemobilization + deltaRhoDipole2SingleStress, [10*ns]) -#ifdef DEBUG - if (debugConstitutive%extensive & - .and. ((debugConstitutive%element == el .and. debugConstitutive%ip == ip)& - .or. .not. debugConstitutive%selective)) then - print'(a,/,8(12x,12(e12.5,1x),/))', '<< CONST >> dislocation remobilization', deltaRhoRemobilization(:,1:8) - print'(a,/,10(12x,12(e12.5,1x),/),/)', '<< CONST >> dipole dissociation by stress increase', deltaRhoDipole2SingleStress - endif -#endif - end associate end subroutine plastic_nonlocal_deltaState @@ -1043,10 +1028,10 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & tau = 0.0_pReal gdot = 0.0_pReal - rho = getRho(ph,me,ip,el) + rho = getRho(ph,me) rhoSgl = rho(:,sgl) rhoDip = rho(:,dip) - rho0 = getRho0(ph,me,ip,el) + rho0 = getRho0(ph,me) my_rhoSgl0 = rho0(:,sgl) forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ins(ph)),me) @@ -1194,7 +1179,6 @@ function rhoDotFlux(timestep,ph,me,ip,el) el !< current element number integer :: & - ph, & neighbor_instance, & !< instance of my neighbor's plasticity ns, & !< short notation for the total number of active slip systems c, & !< character of dislocation @@ -1251,9 +1235,9 @@ function rhoDotFlux(timestep,ph,me,ip,el) gdot = 0.0_pReal - rho = getRho(ph,me,ip,el) + rho = getRho(ph,me) rhoSgl = rho(:,sgl) - rho0 = getRho0(ph,me,ip,el) + rho0 = getRho0(ph,me) my_rhoSgl0 = rho0(:,sgl) forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ins(ph)),me) !ToDo: MD: I think we should use state0 here @@ -1432,7 +1416,6 @@ module subroutine plastic_nonlocal_updateCompatibility(orientation,ph,i,e) n, & ! neighbor index neighbor_e, & ! element index of my neighbor neighbor_i, & ! integration point index of my neighbor - ph, & neighbor_phase, & ns, & ! number of active slip systems s1, & ! slip system index (me) @@ -1604,7 +1587,7 @@ end subroutine plastic_nonlocal_results !-------------------------------------------------------------------------------------------------- !> @brief populates the initial dislocation density !-------------------------------------------------------------------------------------------------- -subroutine stateInit(ini,phase,Nconstituents) +subroutine stateInit(ini,phase,Nconstituents,i) type(tInitialParameters) :: & ini @@ -1631,7 +1614,7 @@ subroutine stateInit(ini,phase,Nconstituents) volume - associate(stt => state(ins(phase))) + associate(stt => state(i)) if (ini%random_rho_u > 0.0_pReal) then ! randomly distribute dislocation segments on random slip system and of random type in the volume do e = 1,discretization_Nelems @@ -1794,21 +1777,22 @@ end subroutine kinetics !> @brief returns copy of current dislocation densities from state !> @details raw values is rectified !-------------------------------------------------------------------------------------------------- -pure function getRho(ph,me,ip,el) +pure function getRho(ph,me) - integer, intent(in) :: ph, me,ip,el + integer, intent(in) :: ph, me real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: getRho + associate(prm => param(ins(ph))) - getRho = reshape(state(ins(ph))%rho(:,me),[prm%sum_N_sl,10]) + getRho = reshape(state(ins(ph))%rho(:,me),[prm%sum_N_sl,10]) - ! ensure positive densities (not for imm, they have a sign) - getRho(:,mob) = max(getRho(:,mob),0.0_pReal) - getRho(:,dip) = max(getRho(:,dip),0.0_pReal) + ! ensure positive densities (not for imm, they have a sign) + getRho(:,mob) = max(getRho(:,mob),0.0_pReal) + getRho(:,dip) = max(getRho(:,dip),0.0_pReal) - where(abs(getRho) < max(prm%rho_min/IPvolume(ip,el)**(2.0_pReal/3.0_pReal),prm%rho_significant)) & - getRho = 0.0_pReal + where(abs(getRho) < max(prm%rho_min/geom(ph)%V_0(me)**(2.0_pReal/3.0_pReal),prm%rho_significant)) & + getRho = 0.0_pReal end associate @@ -1819,21 +1803,22 @@ end function getRho !> @brief returns copy of current dislocation densities from state !> @details raw values is rectified !-------------------------------------------------------------------------------------------------- -pure function getRho0(ph,me,ip,el) +pure function getRho0(ph,me) - integer, intent(in) :: ph, me,ip,el + integer, intent(in) :: ph, me real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: getRho0 + associate(prm => param(ins(ph))) - getRho0 = reshape(state0(ins(ph))%rho(:,me),[prm%sum_N_sl,10]) + getRho0 = reshape(state0(ins(ph))%rho(:,me),[prm%sum_N_sl,10]) - ! ensure positive densities (not for imm, they have a sign) - getRho0(:,mob) = max(getRho0(:,mob),0.0_pReal) - getRho0(:,dip) = max(getRho0(:,dip),0.0_pReal) + ! ensure positive densities (not for imm, they have a sign) + getRho0(:,mob) = max(getRho0(:,mob),0.0_pReal) + getRho0(:,dip) = max(getRho0(:,dip),0.0_pReal) - where(abs(getRho0) < max(prm%rho_min/IPvolume(ip,el)**(2.0_pReal/3.0_pReal),prm%rho_significant)) & - getRho0 = 0.0_pReal + where(abs(getRho0) < max(prm%rho_min/geom(ph)%V_0(me)**(2.0_pReal/3.0_pReal),prm%rho_significant)) & + getRho0 = 0.0_pReal end associate From 341e8ddd6a7d60631d0a212d3c30009fa75e7be6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 14 Feb 2021 18:30:57 +0100 Subject: [PATCH 248/352] storing per instance does not add any value --- src/phase.f90 | 3 +- src/phase_mechanical.f90 | 2 - src/phase_mechanical_plastic.f90 | 5 +- src/phase_mechanical_plastic_nonlocal.f90 | 166 +++++++++++----------- 4 files changed, 82 insertions(+), 94 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index 39d5cc340..a36ddc157 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -59,8 +59,7 @@ module phase integer, dimension(:), allocatable, public :: & !< ToDo: should be protected (bug in Intel compiler) phase_elasticityInstance, & - phase_NstiffnessDegradations, & !< number of stiffness degradation mechanisms active in each phase - phase_plasticInstance + phase_NstiffnessDegradations logical, dimension(:), allocatable, public :: & ! ToDo: should be protected (bug in Intel Compiler) phase_localPlasticity !< flags phases with local constitutive law diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index 381820dcc..57d4ea5ec 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -298,14 +298,12 @@ module subroutine mechanical_init(phases) ! initialize plasticity allocate(plasticState(phases%length)) allocate(phase_plasticity(phases%length),source = PLASTICITY_undefined_ID) - allocate(phase_plasticInstance(phases%length),source = 0) allocate(phase_localPlasticity(phases%length), source=.true.) call plastic_init() do ph = 1, phases%length phase_elasticityInstance(ph) = count(phase_elasticity(1:ph) == phase_elasticity(ph)) - phase_plasticInstance(ph) = count(phase_plasticity(1:ph) == phase_plasticity(ph)) enddo num_crystallite => config_numerics%get('crystallite',defaultVal=emptyDict) diff --git a/src/phase_mechanical_plastic.f90 b/src/phase_mechanical_plastic.f90 index c8e9b6271..136f0884c 100644 --- a/src/phase_mechanical_plastic.f90 +++ b/src/phase_mechanical_plastic.f90 @@ -357,12 +357,11 @@ module subroutine plastic_dependentState(co, ip, el) integer :: & ph, & - instance, me + me ph = material_phaseAt(co,el) me = material_phasememberAt(co,ip,el) - instance = phase_plasticInstance(ph) plasticType: select case (phase_plasticity(material_phaseAt(co,el))) @@ -395,14 +394,12 @@ module function plastic_deltaState(ph, me) result(broken) real(pReal), dimension(3,3) :: & Mp integer :: & - instance, & myOffset, & mySize Mp = matmul(matmul(transpose(phase_mechanical_Fi(ph)%data(1:3,1:3,me)),& phase_mechanical_Fi(ph)%data(1:3,1:3,me)),phase_mechanical_S(ph)%data(1:3,1:3,me)) - instance = phase_plasticInstance(ph) plasticType: select case (phase_plasticity(ph)) diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index b579a3164..0212baee8 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -12,8 +12,6 @@ submodule(phase:plastic) nonlocal IParea => geometry_plastic_nonlocal_IParea0, & IPareaNormal => geometry_plastic_nonlocal_IPareaNormal0, & geometry_plastic_nonlocal_disable - use phase, & - ins => phase_plasticInstance type :: tGeometry real(pReal), dimension(:), allocatable :: V_0 @@ -215,20 +213,19 @@ module function plastic_nonlocal_init() result(myPlasticity) phases => config_material%get('phase') allocate(geom(phases%length)) - allocate(param(Ninstances)) - allocate(state(Ninstances)) - allocate(state0(Ninstances)) - allocate(dotState(Ninstances)) - allocate(deltaState(Ninstances)) - allocate(microstructure(Ninstances)) + allocate(param(phases%length)) + allocate(state(phases%length)) + allocate(state0(phases%length)) + allocate(dotState(phases%length)) + allocate(deltaState(phases%length)) + allocate(microstructure(phases%length)) - - i = 0 do p = 1, phases%length + if(.not. myPlasticity(p)) cycle phase => phases%get(p) mech => phase%get('mechanics') - if(.not. myPlasticity(p)) cycle - i = i + 1 + + i = p associate(prm => param(i), & dot => dotState(i), & stt => state(i), & @@ -512,7 +509,7 @@ module function plastic_nonlocal_init() result(myPlasticity) allocate(dst%tau_back(prm%sum_N_sl,Nconstituents),source=0.0_pReal) end associate - if (Nconstituents > 0) call stateInit(ini,p,Nconstituents,i) + if (Nconstituents > 0) call stateInit(ini,p,Nconstituents) plasticState(p)%state0 = plasticState(p)%state !-------------------------------------------------------------------------------------------------- @@ -525,16 +522,15 @@ module function plastic_nonlocal_init() result(myPlasticity) discretization_nIPs,discretization_Nelems), source=0.0_pReal) ! BEGIN DEPRECATED---------------------------------------------------------------------------------- - allocate(iRhoU(maxval(param%sum_N_sl),4,Ninstances), source=0) - allocate(iV(maxval(param%sum_N_sl),4,Ninstances), source=0) - allocate(iD(maxval(param%sum_N_sl),2,Ninstances), source=0) + allocate(iRhoU(maxval(param%sum_N_sl),4,phases%length), source=0) + allocate(iV(maxval(param%sum_N_sl),4,phases%length), source=0) + allocate(iD(maxval(param%sum_N_sl),2,phases%length), source=0) - i = 0 do p = 1, phases%length phase => phases%get(p) if(.not. myPlasticity(p)) cycle - i = i + 1 + i = p Nconstituents = count(material_phaseAt2 == p) l = 0 @@ -579,7 +575,6 @@ module subroutine nonlocal_dependentState(ph, me, ip, el) no, & !< neighbor offset neighbor_el, & ! element number of neighboring material point neighbor_ip, & ! integration point of neighboring material point - neighbor_instance, & ! instance of this plasticity of neighboring material point c, & ! index of dilsocation character (edge, screw) s, & ! slip system index dir, & @@ -603,27 +598,27 @@ module subroutine nonlocal_dependentState(ph, me, ip, el) invConnections real(pReal), dimension(3,nIPneighbors) :: & connection_latticeConf - real(pReal), dimension(2,param(ins(ph))%sum_N_sl) :: & + real(pReal), dimension(2,param(ph)%sum_N_sl) :: & rhoExcess - real(pReal), dimension(param(ins(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & rho_edg_delta, & rho_scr_delta - real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(ph)%sum_N_sl,10) :: & rho, & rho0, & rho_neighbor0 - real(pReal), dimension(param(ins(ph))%sum_N_sl,param(ins(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl,param(ph)%sum_N_sl) :: & myInteractionMatrix ! corrected slip interaction matrix - real(pReal), dimension(param(ins(ph))%sum_N_sl,nIPneighbors) :: & + real(pReal), dimension(param(ph)%sum_N_sl,nIPneighbors) :: & rho_edg_delta_neighbor, & rho_scr_delta_neighbor real(pReal), dimension(2,maxval(param%sum_N_sl),nIPneighbors) :: & neighbor_rhoExcess, & ! excess density at neighboring material point neighbor_rhoTotal ! total density at neighboring material point - real(pReal), dimension(3,param(ins(ph))%sum_N_sl,2) :: & + real(pReal), dimension(3,param(ph)%sum_N_sl,2) :: & m ! direction of dislocation motion - associate(prm => param(ins(ph)),dst => microstructure(ins(ph)), stt => state(ins(ph))) + associate(prm => param(ph),dst => microstructure(ph), stt => state(ph)) rho = getRho(ph,me) @@ -675,8 +670,7 @@ module subroutine nonlocal_dependentState(ph, me, ip, el) neighbor_ip = IPneighborhood(2,n,ip,el) no = material_phasememberAt(1,neighbor_ip,neighbor_el) if (neighbor_el > 0 .and. neighbor_ip > 0) then - neighbor_instance = ins(material_phaseAt(1,neighbor_el)) - if (neighbor_instance == ins(ph)) then + if (material_phaseAt(1,neighbor_el) == ph) then nRealNeighbors = nRealNeighbors + 1.0_pReal rho_neighbor0 = getRho0(ph,no) @@ -793,21 +787,21 @@ module subroutine nonlocal_LpAndItsTangent(Lp,dLp_dMp, & l, & t, & !< dislocation type s !< index of my current slip system - real(pReal), dimension(param(ins(ph))%sum_N_sl,8) :: & + real(pReal), dimension(param(ph)%sum_N_sl,8) :: & rhoSgl !< single dislocation densities (including blocked) - real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(ph)%sum_N_sl,10) :: & rho - real(pReal), dimension(param(ins(ph))%sum_N_sl,4) :: & + real(pReal), dimension(param(ph)%sum_N_sl,4) :: & v, & !< velocity tauNS, & !< resolved shear stress including non Schmid and backstress terms dv_dtau, & !< velocity derivative with respect to the shear stress dv_dtauNS !< velocity derivative with respect to the shear stress - real(pReal), dimension(param(ins(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & tau, & !< resolved shear stress including backstress terms gdotTotal !< shear rate - associate(prm => param(ins(ph)),dst=>microstructure(ins(ph)),& - stt=>state(ins(ph))) + associate(prm => param(ph),dst=>microstructure(ph),& + stt=>state(ph)) ns = prm%sum_N_sl !*** shortcut to state variables @@ -890,27 +884,27 @@ module subroutine plastic_nonlocal_deltaState(Mp,ph,me) c, & ! character of dislocation t, & ! type of dislocation s ! index of my current slip system - real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(ph)%sum_N_sl,10) :: & deltaRhoRemobilization, & ! density increment by remobilization deltaRhoDipole2SingleStress ! density increment by dipole dissociation (by stress change) - real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(ph)%sum_N_sl,10) :: & rho ! current dislocation densities - real(pReal), dimension(param(ins(ph))%sum_N_sl,4) :: & + real(pReal), dimension(param(ph)%sum_N_sl,4) :: & v ! dislocation glide velocity - real(pReal), dimension(param(ins(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & tau ! current resolved shear stress - real(pReal), dimension(param(ins(ph))%sum_N_sl,2) :: & + real(pReal), dimension(param(ph)%sum_N_sl,2) :: & rhoDip, & ! current dipole dislocation densities (screw and edge dipoles) dUpper, & ! current maximum stable dipole distance for edges and screws dUpperOld, & ! old maximum stable dipole distance for edges and screws deltaDUpper ! change in maximum stable dipole distance for edges and screws - associate(prm => param(ins(ph)),dst => microstructure(ins(ph)),del => deltaState(ins(ph))) + associate(prm => param(ph),dst => microstructure(ph),del => deltaState(ph)) ns = prm%sum_N_sl !*** shortcut to state variables - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ins(ph)),me) - forall (s = 1:ns, c = 1:2) dUpperOld(s,c) = plasticState(ph)%state(iD(s,c,ins(ph)),me) + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ph),me) + forall (s = 1:ns, c = 1:2) dUpperOld(s,c) = plasticState(ph)%state(iD(s,c,ph),me) rho = getRho(ph,me) rhoDip = rho(:,dip) @@ -957,7 +951,7 @@ module subroutine plastic_nonlocal_deltaState(Mp,ph,me) / (dUpperOld(s,c) - prm%minDipoleHeight(s,c)) forall (t=1:4) deltaRhoDipole2SingleStress(:,t) = -0.5_pReal * deltaRhoDipole2SingleStress(:,(t-1)/2+9) - forall (s = 1:ns, c = 1:2) plasticState(ph)%state(iD(s,c,ins(ph)),me) = dUpper(s,c) + forall (s = 1:ns, c = 1:2) plasticState(ph)%state(iD(s,c,ph),me) = dUpper(s,c) plasticState(ph)%deltaState(:,me) = 0.0_pReal del%rho(:,me) = reshape(deltaRhoRemobilization + deltaRhoDipole2SingleStress, [10*ns]) @@ -989,7 +983,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & c, & !< character of dislocation t, & !< type of dislocation s !< index of my current slip system - real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(ph)%sum_N_sl,10) :: & rho, & rho0, & !< dislocation density at beginning of time step rhoDot, & !< density evolution @@ -997,17 +991,17 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & rhoDotSingle2DipoleGlide, & !< density evolution by dipole formation (by glide) rhoDotAthermalAnnihilation, & !< density evolution by athermal annihilation rhoDotThermalAnnihilation !< density evolution by thermal annihilation - real(pReal), dimension(param(ins(ph))%sum_N_sl,8) :: & + real(pReal), dimension(param(ph)%sum_N_sl,8) :: & rhoSgl, & !< current single dislocation densities (positive/negative screw and edge without dipoles) my_rhoSgl0 !< single dislocation densities of central ip (positive/negative screw and edge without dipoles) - real(pReal), dimension(param(ins(ph))%sum_N_sl,4) :: & + real(pReal), dimension(param(ph)%sum_N_sl,4) :: & v, & !< current dislocation glide velocity v0, & gdot !< shear rates - real(pReal), dimension(param(ins(ph))%sum_N_sl) :: & + real(pReal), dimension(param(ph)%sum_N_sl) :: & tau, & !< current resolved shear stress vClimb !< climb velocity of edge dipoles - real(pReal), dimension(param(ins(ph))%sum_N_sl,2) :: & + real(pReal), dimension(param(ph)%sum_N_sl,2) :: & rhoDip, & !< current dipole dislocation densities (screw and edge dipoles) dLower, & !< minimum stable dipole distance for edges and screws dUpper !< current maximum stable dipole distance for edges and screws @@ -1019,10 +1013,10 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & return endif - associate(prm => param(ins(ph)), & - dst => microstructure(ins(ph)), & - dot => dotState(ins(ph)), & - stt => state(ins(ph))) + associate(prm => param(ph), & + dst => microstructure(ph), & + dot => dotState(ph), & + stt => state(ph)) ns = prm%sum_N_sl tau = 0.0_pReal @@ -1034,7 +1028,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & rho0 = getRho0(ph,me) my_rhoSgl0 = rho0(:,sgl) - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ins(ph)),me) + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ph),me) gdot = rhoSgl(:,1:4) * v * spread(prm%b_sl,2,4) #ifdef DEBUG @@ -1083,7 +1077,7 @@ module subroutine nonlocal_dotState(Mp, Temperature,timestep, & * sqrt(stt%rho_forest(:,me)) / prm%i_sl / prm%b_sl, 2, 4) endif isBCC - forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,ins(ph)),me) + forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,ph),me) !**************************************************************************** @@ -1179,7 +1173,7 @@ function rhoDotFlux(timestep,ph,me,ip,el) el !< current element number integer :: & - neighbor_instance, & !< instance of my neighbor's plasticity + neighbor_ph, & !< phase of my neighbor's plasticity ns, & !< short notation for the total number of active slip systems c, & !< character of dislocation n, & !< index of my current neighbor @@ -1195,20 +1189,20 @@ function rhoDotFlux(timestep,ph,me,ip,el) np,& !< neighbor phase shortcut topp, & !< type of dislocation with opposite sign to t s !< index of my current slip system - real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: & + real(pReal), dimension(param(ph)%sum_N_sl,10) :: & rho, & rho0, & !< dislocation density at beginning of time step rhoDotFlux !< density evolution by flux - real(pReal), dimension(param(ins(ph))%sum_N_sl,8) :: & + real(pReal), dimension(param(ph)%sum_N_sl,8) :: & rhoSgl, & !< current single dislocation densities (positive/negative screw and edge without dipoles) neighbor_rhoSgl0, & !< current single dislocation densities of neighboring ip (positive/negative screw and edge without dipoles) my_rhoSgl0 !< single dislocation densities of central ip (positive/negative screw and edge without dipoles) - real(pReal), dimension(param(ins(ph))%sum_N_sl,4) :: & + real(pReal), dimension(param(ph)%sum_N_sl,4) :: & v, & !< current dislocation glide velocity v0, & neighbor_v0, & !< dislocation glide velocity of enighboring ip gdot !< shear rates - real(pReal), dimension(3,param(ins(ph))%sum_N_sl,4) :: & + real(pReal), dimension(3,param(ph)%sum_N_sl,4) :: & m !< direction of dislocation motion real(pReal), dimension(3,3) :: & my_F, & !< my total deformation gradient @@ -1227,10 +1221,10 @@ function rhoDotFlux(timestep,ph,me,ip,el) lineLength !< dislocation line length leaving the current interface - associate(prm => param(ins(ph)), & - dst => microstructure(ins(ph)), & - dot => dotState(ins(ph)), & - stt => state(ins(ph))) + associate(prm => param(ph), & + dst => microstructure(ph), & + dot => dotState(ph), & + stt => state(ph)) ns = prm%sum_N_sl gdot = 0.0_pReal @@ -1240,11 +1234,11 @@ function rhoDotFlux(timestep,ph,me,ip,el) rho0 = getRho0(ph,me) my_rhoSgl0 = rho0(:,sgl) - forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ins(ph)),me) !ToDo: MD: I think we should use state0 here + forall (s = 1:ns, t = 1:4) v(s,t) = plasticState(ph)%state(iV(s,t,ph),me) !ToDo: MD: I think we should use state0 here gdot = rhoSgl(:,1:4) * v * spread(prm%b_sl,2,4) - forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,ins(ph)),me) + forall (s = 1:ns, t = 1:4) v0(s,t) = plasticState(ph)%state0(iV(s,t,ph),me) !**************************************************************************** !*** calculate dislocation fluxes (only for nonlocal plasticity) @@ -1296,7 +1290,7 @@ function rhoDotFlux(timestep,ph,me,ip,el) opposite_n = IPneighborhood(3,opposite_neighbor,ip,el) if (neighbor_n > 0) then ! if neighbor exists, average deformation gradient - neighbor_instance = ins(material_phaseAt(1,neighbor_el)) + neighbor_ph = material_phaseAt(1,neighbor_el) neighbor_F = phase_mechanical_F(np)%data(1:3,1:3,no) neighbor_Fe = matmul(neighbor_F, math_inv33(phase_mechanical_Fp(np)%data(1:3,1:3,no))) Favg = 0.5_pReal * (my_F + neighbor_F) @@ -1319,8 +1313,8 @@ function rhoDotFlux(timestep,ph,me,ip,el) any(compatibility(:,:,:,n,ip,el) > 0.0_pReal)) then forall (s = 1:ns, t = 1:4) - neighbor_v0(s,t) = plasticState(np)%state0(iV (s,t,neighbor_instance),no) - neighbor_rhoSgl0(s,t) = max(plasticState(np)%state0(iRhoU(s,t,neighbor_instance),no),0.0_pReal) + neighbor_v0(s,t) = plasticState(np)%state0(iV (s,t,neighbor_ph),no) + neighbor_rhoSgl0(s,t) = max(plasticState(np)%state0(iRhoU(s,t,neighbor_ph),no),0.0_pReal) endforall where (neighbor_rhoSgl0 * IPvolume(neighbor_ip,neighbor_el) ** 0.667_pReal < prm%rho_min & @@ -1420,17 +1414,17 @@ module subroutine plastic_nonlocal_updateCompatibility(orientation,ph,i,e) ns, & ! number of active slip systems s1, & ! slip system index (me) s2 ! slip system index (my neighbor) - real(pReal), dimension(2,param(ins(ph))%sum_N_sl,param(ins(ph))%sum_N_sl,nIPneighbors) :: & + real(pReal), dimension(2,param(ph)%sum_N_sl,param(ph)%sum_N_sl,nIPneighbors) :: & my_compatibility ! my_compatibility for current element and ip real(pReal) :: & my_compatibilitySum, & thresholdValue, & nThresholdValues - logical, dimension(param(ins(ph))%sum_N_sl) :: & + logical, dimension(param(ph)%sum_N_sl) :: & belowThreshold type(rotation) :: mis - associate(prm => param(ins(ph))) + associate(prm => param(ph)) ns = prm%sum_N_sl !*** start out fully compatible @@ -1523,7 +1517,7 @@ module subroutine plastic_nonlocal_results(ph,group) integer :: o - associate(prm => param(ins(ph)),dst => microstructure(ins(ph)),stt=>state(ins(ph))) + associate(prm => param(ph),dst => microstructure(ph),stt=>state(ph)) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case('rho_u_ed_pos') @@ -1587,7 +1581,7 @@ end subroutine plastic_nonlocal_results !-------------------------------------------------------------------------------------------------- !> @brief populates the initial dislocation density !-------------------------------------------------------------------------------------------------- -subroutine stateInit(ini,phase,Nconstituents,i) +subroutine stateInit(ini,phase,Nconstituents) type(tInitialParameters) :: & ini @@ -1595,8 +1589,8 @@ subroutine stateInit(ini,phase,Nconstituents,i) phase, & Nconstituents integer :: & - e, & i, & + e, & f, & from, & upto, & @@ -1614,7 +1608,7 @@ subroutine stateInit(ini,phase,Nconstituents,i) volume - associate(stt => state(i)) + associate(stt => state(phase)) if (ini%random_rho_u > 0.0_pReal) then ! randomly distribute dislocation segments on random slip system and of random type in the volume do e = 1,discretization_Nelems @@ -1643,8 +1637,8 @@ subroutine stateInit(ini,phase,Nconstituents,i) do s = from,upto noise = [math_sampleGaussVar(0.0_pReal, ini%sigma_rho_u), & math_sampleGaussVar(0.0_pReal, ini%sigma_rho_u)] - stt%rho_sgl_mob_edg_pos(s,e) = ini%rho_u_ed_pos_0(f) + noise(1) - stt%rho_sgl_mob_edg_neg(s,e) = ini%rho_u_ed_neg_0(f) + noise(1) + stt%rho_sgl_mob_edg_pos(s,e) = ini%rho_u_ed_pos_0(f) + noise(1) + stt%rho_sgl_mob_edg_neg(s,e) = ini%rho_u_ed_neg_0(f) + noise(1) stt%rho_sgl_mob_scr_pos(s,e) = ini%rho_u_sc_pos_0(f) + noise(2) stt%rho_sgl_mob_scr_neg(s,e) = ini%rho_u_sc_neg_0(f) + noise(2) enddo @@ -1669,11 +1663,11 @@ pure subroutine kinetics(v, dv_dtau, dv_dtauNS, tau, tauNS, tauThreshold, c, Tem ph real(pReal), intent(in) :: & Temperature !< temperature - real(pReal), dimension(param(ins(ph))%sum_N_sl), intent(in) :: & + real(pReal), dimension(param(ph)%sum_N_sl), intent(in) :: & tau, & !< resolved external shear stress (without non Schmid effects) tauNS, & !< resolved external shear stress (including non Schmid effects) tauThreshold !< threshold shear stress - real(pReal), dimension(param(ins(ph))%sum_N_sl), intent(out) :: & + real(pReal), dimension(param(ph)%sum_N_sl), intent(out) :: & v, & !< velocity dv_dtau, & !< velocity derivative with respect to resolved shear stress (without non Schmid contributions) dv_dtauNS !< velocity derivative with respect to resolved shear stress (including non Schmid contributions) @@ -1704,7 +1698,7 @@ pure subroutine kinetics(v, dv_dtau, dv_dtauNS, tau, tauNS, tauThreshold, c, Tem criticalStress_S, & !< maximum obstacle strength mobility !< dislocation mobility - associate(prm => param(ins(ph))) + associate(prm => param(ph)) ns = prm%sum_N_sl v = 0.0_pReal dv_dtau = 0.0_pReal @@ -1780,12 +1774,12 @@ end subroutine kinetics pure function getRho(ph,me) integer, intent(in) :: ph, me - real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: getRho + real(pReal), dimension(param(ph)%sum_N_sl,10) :: getRho - associate(prm => param(ins(ph))) + associate(prm => param(ph)) - getRho = reshape(state(ins(ph))%rho(:,me),[prm%sum_N_sl,10]) + getRho = reshape(state(ph)%rho(:,me),[prm%sum_N_sl,10]) ! ensure positive densities (not for imm, they have a sign) getRho(:,mob) = max(getRho(:,mob),0.0_pReal) @@ -1806,12 +1800,12 @@ end function getRho pure function getRho0(ph,me) integer, intent(in) :: ph, me - real(pReal), dimension(param(ins(ph))%sum_N_sl,10) :: getRho0 + real(pReal), dimension(param(ph)%sum_N_sl,10) :: getRho0 - associate(prm => param(ins(ph))) + associate(prm => param(ph)) - getRho0 = reshape(state0(ins(ph))%rho(:,me),[prm%sum_N_sl,10]) + getRho0 = reshape(state0(ph)%rho(:,me),[prm%sum_N_sl,10]) ! ensure positive densities (not for imm, they have a sign) getRho0(:,mob) = max(getRho0(:,mob),0.0_pReal) From 89e8ca45351297871bf54662283038ac011901ab Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 15 Feb 2021 11:22:42 -0500 Subject: [PATCH 249/352] renamed and shortened _separate_arguments() --- python/damask/_orientation.py | 55 +++++++++++++++++------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index f01156903..ad381712d 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -9,7 +9,7 @@ from . import tensor _parameter_doc = \ """lattice : str Either a crystal family out of [triclinic, monoclinic, orthorhombic, tetragonal, hexagonal, cubic] - or a Bravais lattice out of [aP, mP, mS, oP, oS, oI, oF, tP, tI, hP, cP, cI, cF]. + or a Bravais lattice out of [aP, mP, mS, oP, oS, oI, oF, tP, tI, hP, cP, cI, cF]. When specifying a Bravais lattice, additional lattice parameters might be required: a : float, optional Length of lattice parameter "a". @@ -265,111 +265,110 @@ class Orientation(Rotation): @staticmethod - def _separate_arguments(parent_dict,function): + def _split_kwargs(kwargs,target): """ - Separate arguments required by Rotation and Orientation objects respectively. + Separate keyword arguments in 'kwargs' targeted at 'target' from general keyword arguments of Orientation objects. Parameters ---------- - parent_dict : Dictionary - Contains all **kwargs - function: Method - Function whose signature list is required + kwargs : dictionary + Contains all **kwargs. + target: method + Function to scan for kwarg signature. Returns ------- - ori_dict: dictionary - Dictionary consisting of valid keys accepted by Orientation class - rot_dict: dictionary - Dictionary consisting of valid keys accepted by 'function' in Rotation class + rot_kwargs: dictionary + Valid keyword arguments of 'target' function of Rotation class. + ori_kwargs: dictionary + Valid keyword arguments of Orientation object. """ - set_ori = set(inspect.signature(Orientation.__init__).parameters.keys()) & set(parent_dict.keys()) - set_rot = set(inspect.signature(function).parameters.keys()) & set(parent_dict.keys()) - ori_dict = {key: parent_dict[key] for key in set_ori} - rot_dict = {key: parent_dict[key] for key in set_rot} + kws = () + for t in (target,Orientation.__init__): + kws += ({key: kwargs[key] for key in set(inspect.signature(t).parameters) & set(kwargs)},) - invalid_keys = set(parent_dict.keys())-(set_ori|set_rot) + invalid_keys = set(kwargs)-(set(kws[0])|set(kws[1])) if invalid_keys: raise TypeError(f"{inspect.stack()[1][3]}() got an unexpected keyword argument '{invalid_keys.pop()}'") - return rot_dict,ori_dict + return kws @classmethod @util.extended_docstring(Rotation.from_random,_parameter_doc) def from_random(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_random) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_random) return cls(rotation=Rotation.from_random(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_quaternion,_parameter_doc) def from_quaternion(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_quaternion) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_quaternion) return cls(rotation=Rotation.from_quaternion(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_Euler_angles,_parameter_doc) def from_Euler_angles(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_Euler_angles) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_Euler_angles) return cls(rotation=Rotation.from_Euler_angles(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_axis_angle,_parameter_doc) def from_axis_angle(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_axis_angle) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_axis_angle) return cls(rotation=Rotation.from_axis_angle(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_basis,_parameter_doc) def from_basis(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_basis) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_basis) return cls(rotation=Rotation.from_basis(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_matrix,_parameter_doc) def from_matrix(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_matrix) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_matrix) return cls(rotation=Rotation.from_matrix(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_Rodrigues_vector,_parameter_doc) def from_Rodrigues_vector(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_Rodrigues_vector) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_Rodrigues_vector) return cls(rotation=Rotation.from_Rodrigues_vector(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_homochoric,_parameter_doc) def from_homochoric(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_homochoric) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_homochoric) return cls(rotation=Rotation.from_homochoric(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_cubochoric,_parameter_doc) def from_cubochoric(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_cubochoric) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_cubochoric) return cls(rotation=Rotation.from_cubochoric(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_spherical_component,_parameter_doc) def from_spherical_component(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_spherical_component) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_spherical_component) return cls(rotation=Rotation.from_spherical_component(**kwargs_rot),**kwargs_ori) @classmethod @util.extended_docstring(Rotation.from_fiber_component,_parameter_doc) def from_fiber_component(cls,**kwargs): - kwargs_rot,kwargs_ori = Orientation._separate_arguments(kwargs,Rotation.from_fiber_component) + kwargs_rot,kwargs_ori = Orientation._split_kwargs(kwargs,Rotation.from_fiber_component) return cls(rotation=Rotation.from_fiber_component(**kwargs_rot),**kwargs_ori) From 9f78e27724c1d370efac661718ce0b508bdf89c9 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Mon, 15 Feb 2021 18:43:51 +0100 Subject: [PATCH 250/352] use cell mapping --- src/homogenization.f90 | 7 ++--- src/homogenization_mechanical.f90 | 20 ++++++-------- src/homogenization_mechanical_RGC.f90 | 40 ++++++++++++++++----------- src/phase.f90 | 4 +-- src/phase_mechanical.f90 | 6 ++-- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 3e1b939b5..a0e31632f 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -95,12 +95,11 @@ module homogenization module subroutine damage_init end subroutine damage_init - module subroutine mechanical_partition(subF,ip,el) + module subroutine mechanical_partition(subF,ce) real(pReal), intent(in), dimension(3,3) :: & subF integer, intent(in) :: & - ip, & !< integration point - el !< element number + ce end subroutine mechanical_partition module subroutine thermal_partition(ce) @@ -318,7 +317,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if (.not. doneAndHappy(1)) then - call mechanical_partition(homogenization_F(1:3,1:3,ce),ip,el) + call mechanical_partition(homogenization_F(1:3,1:3,ce),ce) converged = .true. do co = 1, myNgrains converged = converged .and. crystallite_stress(dt,co,ip,el) diff --git a/src/homogenization_mechanical.f90 b/src/homogenization_mechanical.f90 index a19a61f72..bdbbc35d4 100644 --- a/src/homogenization_mechanical.f90 +++ b/src/homogenization_mechanical.f90 @@ -24,12 +24,11 @@ submodule(homogenization) mechanical real(pReal), dimension (3,3), intent(in) :: avgF !< average deformation gradient at material point end subroutine mechanical_isostrain_partitionDeformation - module subroutine mechanical_RGC_partitionDeformation(F,avgF,instance,of) + module subroutine mechanical_RGC_partitionDeformation(F,avgF,ce) real(pReal), dimension (:,:,:), intent(out) :: F !< partitioned deformation gradient real(pReal), dimension (3,3), intent(in) :: avgF !< average deformation gradient at material point integer, intent(in) :: & - instance, & - of + ce end subroutine mechanical_RGC_partitionDeformation @@ -104,19 +103,18 @@ end subroutine mechanical_init !-------------------------------------------------------------------------------------------------- !> @brief Partition F onto the individual constituents. !-------------------------------------------------------------------------------------------------- -module subroutine mechanical_partition(subF,ip,el) +module subroutine mechanical_partition(subF,ce) real(pReal), intent(in), dimension(3,3) :: & subF integer, intent(in) :: & - ip, & !< integration point - el !< element number + ce integer :: co - real(pReal), dimension (3,3,homogenization_Nconstituents(material_homogenizationAt(el))) :: Fs + real(pReal), dimension (3,3,homogenization_Nconstituents(material_homogenizationAt2(ce))) :: Fs - chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) + chosenHomogenization: select case(homogenization_type(material_homogenizationAt2(ce))) case (HOMOGENIZATION_NONE_ID) chosenHomogenization Fs(1:3,1:3,1) = subF @@ -125,12 +123,12 @@ module subroutine mechanical_partition(subF,ip,el) call mechanical_isostrain_partitionDeformation(Fs,subF) case (HOMOGENIZATION_RGC_ID) chosenHomogenization - call mechanical_RGC_partitionDeformation(Fs,subF,ip,el) + call mechanical_RGC_partitionDeformation(Fs,subF,ce) end select chosenHomogenization - do co = 1,homogenization_Nconstituents(material_homogenizationAt(el)) - call phase_mechanical_setF(Fs(1:3,1:3,co),co,ip,el) + do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce)) + call phase_mechanical_setF(Fs(1:3,1:3,co),co,ce) enddo diff --git a/src/homogenization_mechanical_RGC.f90 b/src/homogenization_mechanical_RGC.f90 index f1bcda380..4a186a51b 100644 --- a/src/homogenization_mechanical_RGC.f90 +++ b/src/homogenization_mechanical_RGC.f90 @@ -196,22 +196,22 @@ end subroutine mechanical_RGC_init !-------------------------------------------------------------------------------------------------- !> @brief partitions the deformation gradient onto the constituents !-------------------------------------------------------------------------------------------------- -module subroutine mechanical_RGC_partitionDeformation(F,avgF,instance,of) +module subroutine mechanical_RGC_partitionDeformation(F,avgF,ce) real(pReal), dimension (:,:,:), intent(out) :: F !< partitioned F per grain real(pReal), dimension (3,3), intent(in) :: avgF !< averaged F integer, intent(in) :: & - instance, & - of + ce real(pReal), dimension(3) :: aVect,nVect integer, dimension(4) :: intFace integer, dimension(3) :: iGrain3 - integer :: iGrain,iFace,i,j - - associate(prm => param(instance)) + integer :: iGrain,iFace,i,j,me + associate(prm => param(homogenization_typeInstance(material_homogenizationAt2(ce)))) + + me = material_homogenizationMemberAt2(ce) !-------------------------------------------------------------------------------------------------- ! compute the deformation gradient of individual grains due to relaxations F = 0.0_pReal @@ -219,8 +219,8 @@ module subroutine mechanical_RGC_partitionDeformation(F,avgF,instance,of) iGrain3 = grain1to3(iGrain,prm%N_constituents) do iFace = 1,6 intFace = getInterface(iFace,iGrain3) ! identifying 6 interfaces of each grain - aVect = relaxationVector(intFace,instance,of) ! get the relaxation vectors for each interface from global relaxation vector array - nVect = interfaceNormal(intFace,instance,of) + aVect = relaxationVector(intFace,ce,me) ! get the relaxation vectors for each interface from global relaxation vector array + nVect = interfaceNormal(intFace,ce,me) forall (i=1:3,j=1:3) & F(i,j,iGrain) = F(i,j,iGrain) + aVect(i)*nVect(j) ! calculating deformation relaxations due to interface relaxation enddo @@ -760,11 +760,11 @@ end subroutine mechanical_RGC_results !-------------------------------------------------------------------------------------------------- !> @brief collect relaxation vectors of an interface !-------------------------------------------------------------------------------------------------- -pure function relaxationVector(intFace,instance,of) +pure function relaxationVector(intFace,ce,me) real(pReal), dimension (3) :: relaxationVector - integer, intent(in) :: instance,of + integer, intent(in) :: ce,me integer, dimension(4), intent(in) :: intFace !< set of interface ID in 4D array (normal and position) integer :: iNum @@ -772,29 +772,35 @@ pure function relaxationVector(intFace,instance,of) !-------------------------------------------------------------------------------------------------- ! collect the interface relaxation vector from the global state array - iNum = interface4to1(intFace,param(instance)%N_constituents) ! identify the position of the interface in global state array + associate (prm => param(homogenization_typeInstance(material_homogenizationAt2(ce))), & + stt => state(homogenization_typeInstance(material_homogenizationAt2(ce)))) + + iNum = interface4to1(intFace,prm%N_constituents) ! identify the position of the interface in global state array if (iNum > 0) then - relaxationVector = state(instance)%relaxationVector((3*iNum-2):(3*iNum),of) + relaxationVector = stt%relaxationVector((3*iNum-2):(3*iNum),me) else relaxationVector = 0.0_pReal endif + end associate + end function relaxationVector !-------------------------------------------------------------------------------------------------- !> @brief identify the normal of an interface !-------------------------------------------------------------------------------------------------- -pure function interfaceNormal(intFace,instance,of) +pure function interfaceNormal(intFace,ce,me) real(pReal), dimension(3) :: interfaceNormal integer, dimension(4), intent(in) :: intFace !< interface ID in 4D array (normal and position) integer, intent(in) :: & - instance, & - of + ce, & + me integer :: nPos + associate (dst => dependentState(homogenization_typeInstance(material_homogenizationAt2(ce)))) !-------------------------------------------------------------------------------------------------- ! get the normal of the interface, identified from the value of intFace(1) @@ -802,7 +808,9 @@ pure function interfaceNormal(intFace,instance,of) nPos = abs(intFace(1)) ! identify the position of the interface in global state array interfaceNormal(nPos) = real(intFace(1)/abs(intFace(1)),pReal) ! get the normal vector w.r.t. cluster axis - interfaceNormal = matmul(dependentState(instance)%orientation(1:3,1:3,of),interfaceNormal) ! map the normal vector into sample coordinate system (basis) + interfaceNormal = matmul(dst%orientation(1:3,1:3,me),interfaceNormal) ! map the normal vector into sample coordinate system (basis) + + end associate end function interfaceNormal diff --git a/src/phase.f90 b/src/phase.f90 index a36ddc157..c5de6d658 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -183,9 +183,9 @@ module phase end function damage_phi - module subroutine phase_mechanical_setF(F,co,ip,el) + module subroutine phase_mechanical_setF(F,co,ce) real(pReal), dimension(3,3), intent(in) :: F - integer, intent(in) :: co, ip, el + integer, intent(in) :: co, ce end subroutine phase_mechanical_setF module subroutine phase_thermal_setField(T,dot_T, co,ce) diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index 57d4ea5ec..24425bf0a 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -1481,13 +1481,13 @@ end function phase_mechanical_getP ! setter for homogenization -module subroutine phase_mechanical_setF(F,co,ip,el) +module subroutine phase_mechanical_setF(F,co,ce) real(pReal), dimension(3,3), intent(in) :: F - integer, intent(in) :: co, ip, el + integer, intent(in) :: co, ce - phase_mechanical_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) = F + phase_mechanical_F(material_phaseAt2(co,ce))%data(1:3,1:3,material_phaseMemberAt2(co,ce)) = F end subroutine phase_mechanical_setF From 2af7502ed4d3216ef44579b04ecc60ee6f0c4765 Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 15 Feb 2021 22:12:13 +0100 Subject: [PATCH 251/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-435-g8933dd856 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ce989b710..5fddb7702 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-428-gb7b764ab5 +v3.0.0-alpha2-435-g8933dd856 From 6bbd55d96711bba450f9f680e82e132dc2ab58ef Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 15 Feb 2021 16:25:36 -0500 Subject: [PATCH 252/352] exchanged c for x in from_cubochoric --- python/tests/test_Orientation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 4d1f958e2..2870189ed 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -221,14 +221,14 @@ class TestOrientation: o = Orientation.from_random(lattice=lattice,shape=shape) for r, theO in zip(o.reduced.flatten(),o.flatten()): assert r == theO.reduced - + @pytest.mark.parametrize('lattice',Orientation.crystal_families) def test_reduced_corner_cases(self,lattice): # test whether there is always a sym-eq rotation that falls into the FZ N = np.random.randint(10,40) size = np.ones(3)*np.pi**(2./3.) grid = grid_filters.coordinates0_node([N+1,N+1,N+1],size,-size*.5) - evenly_distributed = Orientation.from_cubochoric(c=grid[:-2,:-2,:-2],lattice=lattice) + evenly_distributed = Orientation.from_cubochoric(x=grid[:-2,:-2,:-2],lattice=lattice) assert evenly_distributed.shape == evenly_distributed.reduced.shape From 7332a92b322d298a67957fe258866e8672634160 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 16 Feb 2021 01:36:39 +0100 Subject: [PATCH 253/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-442-ge2708d29f --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5fddb7702..0a4efbf53 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-435-g8933dd856 +v3.0.0-alpha2-442-ge2708d29f From 53bab41b4762eb3c8da911d3f409da800eb9ed16 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 16 Feb 2021 16:06:09 +0100 Subject: [PATCH 254/352] consistent name 'ph' and cleaning --- ...phase_mechanical_plastic_dislotungsten.f90 | 46 ++--- src/phase_mechanical_plastic_dislotwin.f90 | 75 ++++--- src/phase_mechanical_plastic_isotropic.f90 | 54 ++--- ...phase_mechanical_plastic_kinehardening.f90 | 73 +++---- src/phase_mechanical_plastic_none.f90 | 10 +- src/phase_mechanical_plastic_nonlocal.f90 | 189 +++++++++--------- ...phase_mechanical_plastic_phenopowerlaw.f90 | 57 +++--- 7 files changed, 235 insertions(+), 269 deletions(-) diff --git a/src/phase_mechanical_plastic_dislotungsten.f90 b/src/phase_mechanical_plastic_dislotungsten.f90 index 81c4605ac..9c8baf0a5 100644 --- a/src/phase_mechanical_plastic_dislotungsten.f90 +++ b/src/phase_mechanical_plastic_dislotungsten.f90 @@ -78,7 +78,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - p, i, & + ph, i, & Nconstituents, & sizeState, sizeDotState, & startIndex, endIndex @@ -114,15 +114,13 @@ module function plastic_dislotungsten_init() result(myPlasticity) allocate(dependentState(phases%length)) - do p = 1, phases%length - if(.not. myPlasticity(p)) cycle - phase => phases%get(p) + do ph = 1, phases%length + if(.not. myPlasticity(ph)) cycle + + associate(prm => param(ph), dot => dotState(ph), stt => state(ph), dst => dependentState(ph)) + + phase => phases%get(ph) mech => phase%get('mechanics') - i = p - associate(prm => param(i), & - dot => dotState(i), & - stt => state(i), & - dst => dependentState(i)) pl => mech%get('plasticity') #if defined (__GFORTRAN__) @@ -132,7 +130,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) #endif ! This data is read in already in lattice - prm%mu = lattice_mu(p) + prm%mu = lattice_mu(ph) !-------------------------------------------------------------------------------------------------- ! slip related parameters @@ -222,41 +220,41 @@ module function plastic_dislotungsten_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == p) + Nconstituents = count(material_phaseAt2 == ph) sizeDotState = size(['rho_mob ','rho_dip ','gamma_sl']) * prm%sum_N_sl sizeState = sizeDotState - call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization startIndex = 1 endIndex = prm%sum_N_sl - stt%rho_mob => plasticState(p)%state(startIndex:endIndex,:) + stt%rho_mob => plasticState(ph)%state(startIndex:endIndex,:) stt%rho_mob = spread(rho_mob_0,2,Nconstituents) - dot%rho_mob => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) - if (any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_rho' + dot%rho_mob => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) + if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_rho' startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%rho_dip => plasticState(p)%state(startIndex:endIndex,:) + stt%rho_dip => plasticState(ph)%state(startIndex:endIndex,:) stt%rho_dip = spread(rho_dip_0,2,Nconstituents) - dot%rho_dip => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) + dot%rho_dip => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%gamma_sl => plasticState(p)%state(startIndex:endIndex,:) - dot%gamma_sl => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = 1.0e-2_pReal + stt%gamma_sl => plasticState(ph)%state(startIndex:endIndex,:) + dot%gamma_sl => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = 1.0e-2_pReal ! global alias - plasticState(p)%slipRate => plasticState(p)%dotState(startIndex:endIndex,:) + plasticState(ph)%slipRate => plasticState(ph)%dotState(startIndex:endIndex,:) allocate(dst%Lambda_sl(prm%sum_N_sl,Nconstituents), source=0.0_pReal) allocate(dst%threshold_stress(prm%sum_N_sl,Nconstituents), source=0.0_pReal) - plasticState(p)%state0 = plasticState(p)%state ! ToDo: this could be done centrally + plasticState(ph)%state0 = plasticState(ph)%state ! ToDo: this could be done centrally end associate diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index 3b33196d9..0c52176ce 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -126,7 +126,7 @@ module function plastic_dislotwin_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - p, i, & + ph, i, & Nconstituents, & sizeState, sizeDotState, & startIndex, endIndex @@ -167,15 +167,13 @@ module function plastic_dislotwin_init() result(myPlasticity) allocate(dependentState(phases%length)) - do p = 1, phases%length - if(.not. myPlasticity(p)) cycle - phase => phases%get(p) + do ph = 1, phases%length + if(.not. myPlasticity(ph)) cycle + + associate(prm => param(ph), dot => dotState(ph), stt => state(ph), dst => dependentState(ph)) + + phase => phases%get(ph) mech => phase%get('mechanics') - i = p - associate(prm => param(i), & - dot => dotState(i), & - stt => state(i), & - dst => dependentState(i)) pl => mech%get('plasticity') #if defined (__GFORTRAN__) @@ -185,9 +183,9 @@ module function plastic_dislotwin_init() result(myPlasticity) #endif ! This data is read in already in lattice - prm%mu = lattice_mu(p) - prm%nu = lattice_nu(p) - prm%C66 = lattice_C66(1:6,1:6,p) + prm%mu = lattice_mu(ph) + prm%nu = lattice_nu(ph) + prm%C66 = lattice_C66(1:6,1:6,ph) !-------------------------------------------------------------------------------------------------- ! slip related parameters @@ -204,8 +202,7 @@ module function plastic_dislotwin_init() result(myPlasticity) prm%n0_sl = lattice_slip_normal(N_sl,phase%get_asString('lattice'),& phase%get_asFloat('c/a',defaultVal=0.0_pReal)) - prm%fccTwinTransNucleation = merge(.true., .false., lattice_structure(p) == lattice_FCC_ID) & - .and. (N_sl(1) == 12) + prm%fccTwinTransNucleation = lattice_structure(ph) == lattice_FCC_ID .and. (N_sl(1) == 12) if(prm%fccTwinTransNucleation) prm%fcc_twinNucleationSlipPair = lattice_FCC_TWINNUCLEATIONSLIPPAIR rho_mob_0 = pl%get_asFloats('rho_mob_0', requiredSize=size(N_sl)) @@ -234,7 +231,7 @@ module function plastic_dislotwin_init() result(myPlasticity) ! multiplication factor according to crystal structure (nearest neighbors bcc vs fcc/hex) ! details: Argon & Moffat, Acta Metallurgica, Vol. 29, pg 293 to 299, 1981 prm%omega = pl%get_asFloat('omega', defaultVal = 1000.0_pReal) & - * merge(12.0_pReal,8.0_pReal,any(lattice_structure(p) == [lattice_FCC_ID,lattice_HEX_ID])) + * merge(12.0_pReal,8.0_pReal,any(lattice_structure(ph) == [lattice_FCC_ID,lattice_HEX_ID])) ! expand: family => system rho_mob_0 = math_expand(rho_mob_0, N_sl) @@ -342,7 +339,7 @@ module function plastic_dislotwin_init() result(myPlasticity) pl%get_asFloat('a_cI', defaultVal=0.0_pReal), & pl%get_asFloat('a_cF', defaultVal=0.0_pReal)) - if (lattice_structure(p) /= lattice_FCC_ID) then + if (lattice_structure(ph) /= lattice_FCC_ID) then prm%dot_N_0_tr = pl%get_asFloats('dot_N_0_tr') prm%dot_N_0_tr = math_expand(prm%dot_N_0_tr,N_tr) endif @@ -357,7 +354,7 @@ module function plastic_dislotwin_init() result(myPlasticity) if ( prm%i_tr < 0.0_pReal) extmsg = trim(extmsg)//' i_tr' if (any(prm%t_tr < 0.0_pReal)) extmsg = trim(extmsg)//' t_tr' if (any(prm%s < 0.0_pReal)) extmsg = trim(extmsg)//' p_tr' - if (lattice_structure(p) /= lattice_FCC_ID) then + if (lattice_structure(ph) /= lattice_FCC_ID) then if (any(prm%dot_N_0_tr < 0.0_pReal)) extmsg = trim(extmsg)//' dot_N_0_tr' endif else transActive @@ -408,53 +405,53 @@ module function plastic_dislotwin_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == p) + Nconstituents = count(material_phaseAt2 == ph) sizeDotState = size(['rho_mob ','rho_dip ','gamma_sl']) * prm%sum_N_sl & + size(['f_tw']) * prm%sum_N_tw & + size(['f_tr']) * prm%sum_N_tr sizeState = sizeDotState - call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! locally defined state aliases and initialization of state0 and atol startIndex = 1 endIndex = prm%sum_N_sl - stt%rho_mob=>plasticState(p)%state(startIndex:endIndex,:) + stt%rho_mob=>plasticState(ph)%state(startIndex:endIndex,:) stt%rho_mob= spread(rho_mob_0,2,Nconstituents) - dot%rho_mob=>plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) - if (any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_rho' + dot%rho_mob=>plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) + if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_rho' startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%rho_dip=>plasticState(p)%state(startIndex:endIndex,:) + stt%rho_dip=>plasticState(ph)%state(startIndex:endIndex,:) stt%rho_dip= spread(rho_dip_0,2,Nconstituents) - dot%rho_dip=>plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) + dot%rho_dip=>plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%gamma_sl=>plasticState(p)%state(startIndex:endIndex,:) - dot%gamma_sl=>plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = 1.0e-2_pReal + stt%gamma_sl=>plasticState(ph)%state(startIndex:endIndex,:) + dot%gamma_sl=>plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = 1.0e-2_pReal ! global alias - plasticState(p)%slipRate => plasticState(p)%dotState(startIndex:endIndex,:) + plasticState(ph)%slipRate => plasticState(ph)%dotState(startIndex:endIndex,:) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_tw - stt%f_tw=>plasticState(p)%state(startIndex:endIndex,:) - dot%f_tw=>plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('f_twin',defaultVal=1.0e-7_pReal) - if (any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' f_twin' + stt%f_tw=>plasticState(ph)%state(startIndex:endIndex,:) + dot%f_tw=>plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('f_twin',defaultVal=1.0e-7_pReal) + if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' f_twin' startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_tr - stt%f_tr=>plasticState(p)%state(startIndex:endIndex,:) - dot%f_tr=>plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('f_trans',defaultVal=1.0e-6_pReal) - if (any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' f_trans' + stt%f_tr=>plasticState(ph)%state(startIndex:endIndex,:) + dot%f_tr=>plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('f_trans',defaultVal=1.0e-6_pReal) + if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' f_trans' allocate(dst%Lambda_sl (prm%sum_N_sl,Nconstituents),source=0.0_pReal) allocate(dst%tau_pass (prm%sum_N_sl,Nconstituents),source=0.0_pReal) @@ -469,7 +466,7 @@ module function plastic_dislotwin_init() result(myPlasticity) allocate(dst%tau_r_tr (prm%sum_N_tr,Nconstituents),source=0.0_pReal) allocate(dst%V_tr (prm%sum_N_tr,Nconstituents),source=0.0_pReal) - plasticState(p)%state0 = plasticState(p)%state ! ToDo: this could be done centrally + plasticState(ph)%state0 = plasticState(ph)%state ! ToDo: this could be done centrally end associate diff --git a/src/phase_mechanical_plastic_isotropic.f90 b/src/phase_mechanical_plastic_isotropic.f90 index 39a4b3a7c..245f4293a 100644 --- a/src/phase_mechanical_plastic_isotropic.f90 +++ b/src/phase_mechanical_plastic_isotropic.f90 @@ -22,8 +22,6 @@ submodule(phase:plastic) isotropic c_4, & c_3, & c_2 - integer :: & - of_debug = 0 logical :: & dilatation character(len=pStringLen), allocatable, dimension(:) :: & @@ -53,8 +51,7 @@ module function plastic_isotropic_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - p, & - i, & + ph, & Nconstituents, & sizeState, sizeDotState real(pReal) :: & @@ -82,16 +79,14 @@ module function plastic_isotropic_init() result(myPlasticity) allocate(state(phases%length)) allocate(dotState(phases%length)) - do p = 1, phases%length - if(.not. myPlasticity(p)) cycle - phase => phases%get(p) - mech => phase%get('mechanics') - i = p - associate(prm => param(i), & - dot => dotState(i), & - stt => state(i)) - pl => mech%get('plasticity') + do ph = 1, phases%length + if(.not. myPlasticity(ph)) cycle + associate(prm => param(ph), dot => dotState(ph), stt => state(ph)) + + phase => phases%get(ph) + mech => phase%get('mechanics') + pl => mech%get('plasticity') #if defined (__GFORTRAN__) prm%output = output_asStrings(pl) @@ -99,11 +94,6 @@ module function plastic_isotropic_init() result(myPlasticity) prm%output = pl%get_asStrings('output',defaultVal=emptyStringArray) #endif -#ifdef DEBUG - if (p==material_phaseAt(debugConstitutive%grain,debugConstitutive%element)) & - prm%of_debug = material_phasememberAt(debugConstitutive%grain,debugConstitutive%ip,debugConstitutive%element) -#endif - xi_0 = pl%get_asFloat('xi_0') prm%xi_inf = pl%get_asFloat('xi_inf') prm%dot_gamma_0 = pl%get_asFloat('dot_gamma_0') @@ -129,28 +119,28 @@ module function plastic_isotropic_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == p) + Nconstituents = count(material_phaseAt2 == ph) sizeDotState = size(['xi ','gamma']) sizeState = sizeDotState - call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization - stt%xi => plasticState(p)%state (1,:) + stt%xi => plasticState(ph)%state (1,:) stt%xi = xi_0 - dot%xi => plasticState(p)%dotState(1,:) - plasticState(p)%atol(1) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) - if (plasticState(p)%atol(1) < 0.0_pReal) extmsg = trim(extmsg)//' atol_xi' + dot%xi => plasticState(ph)%dotState(1,:) + plasticState(ph)%atol(1) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) + if (plasticState(ph)%atol(1) < 0.0_pReal) extmsg = trim(extmsg)//' atol_xi' - stt%gamma => plasticState(p)%state (2,:) - dot%gamma => plasticState(p)%dotState(2,:) - plasticState(p)%atol(2) = pl%get_asFloat('atol_gamma',defaultVal=1.0e-6_pReal) - if (plasticState(p)%atol(2) < 0.0_pReal) extmsg = trim(extmsg)//' atol_gamma' + stt%gamma => plasticState(ph)%state (2,:) + dot%gamma => plasticState(ph)%dotState(2,:) + plasticState(ph)%atol(2) = pl%get_asFloat('atol_gamma',defaultVal=1.0e-6_pReal) + if (plasticState(ph)%atol(2) < 0.0_pReal) extmsg = trim(extmsg)//' atol_gamma' ! global alias - plasticState(p)%slipRate => plasticState(p)%dotState(2:2,:) + plasticState(ph)%slipRate => plasticState(ph)%dotState(2:2,:) - plasticState(p)%state0 = plasticState(p)%state ! ToDo: this could be done centrally + plasticState(ph)%state0 = plasticState(ph)%state ! ToDo: this could be done centrally end associate @@ -240,13 +230,11 @@ module subroutine plastic_isotropic_LiAndItsTangent(Li,dLi_dMi,Mi,ph,me) tr=math_trace33(math_spherical33(Mi)) - if (prm%dilatation .and. abs(tr) > 0.0_pReal) then ! no stress or J2 plasticity --> Li and its derivative are zero + if (prm%dilatation .and. abs(tr) > 0.0_pReal) then ! no stress or J2 plasticity --> Li and its derivative are zero Li = math_I3 & * prm%dot_gamma_0/prm%M * (3.0_pReal*prm%M*stt%xi(me))**(-prm%n) & * tr * abs(tr)**(prm%n-1.0_pReal) - forall (k=1:3,l=1:3,m=1:3,n=1:3) dLi_dMi(k,l,m,n) = prm%n / tr * Li(k,l) * math_I3(m,n) - else Li = 0.0_pReal dLi_dMi = 0.0_pReal diff --git a/src/phase_mechanical_plastic_kinehardening.f90 b/src/phase_mechanical_plastic_kinehardening.f90 index 14aa58fb9..8acf42710 100644 --- a/src/phase_mechanical_plastic_kinehardening.f90 +++ b/src/phase_mechanical_plastic_kinehardening.f90 @@ -25,8 +25,7 @@ submodule(phase:plastic) kinehardening nonSchmid_pos, & nonSchmid_neg integer :: & - sum_N_sl, & !< total number of active slip system - of_debug = 0 + sum_N_sl logical :: & nonSchmidActive = .false. character(len=pStringLen), allocatable, dimension(:) :: & @@ -62,7 +61,7 @@ module function plastic_kinehardening_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - p, i, o, & + ph, o, & Nconstituents, & sizeState, sizeDeltaState, sizeDotState, & startIndex, endIndex @@ -93,15 +92,13 @@ module function plastic_kinehardening_init() result(myPlasticity) allocate(deltaState(phases%length)) - do p = 1, phases%length - if(.not. myPlasticity(p)) cycle - phase => phases%get(p) + do ph = 1, phases%length + if(.not. myPlasticity(ph)) cycle + + associate(prm => param(ph), dot => dotState(ph), dlt => deltaState(ph), stt => state(ph)) + + phase => phases%get(ph) mech => phase%get('mechanics') - i = p - associate(prm => param(i), & - dot => dotState(i), & - dlt => deltaState(i), & - stt => state(i)) pl => mech%get('plasticity') #if defined (__GFORTRAN__) @@ -110,12 +107,6 @@ module function plastic_kinehardening_init() result(myPlasticity) prm%output = pl%get_asStrings('output',defaultVal=emptyStringArray) #endif -#ifdef DEBUG - if (p==material_phaseAt(debugConstitutive%grain,debugConstitutive%element)) then - prm%of_debug = material_phasememberAt(debugConstitutive%grain,debugConstitutive%ip,debugConstitutive%element) - endif -#endif - !-------------------------------------------------------------------------------------------------- ! slip related parameters N_sl = pl%get_asInts('N_sl',defaultVal=emptyIntArray) @@ -174,55 +165,55 @@ module function plastic_kinehardening_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == p) - sizeDotState = size(['crss ','crss_back', 'accshear ']) * prm%sum_N_sl!ToDo: adjust names, ask Philip - sizeDeltaState = size(['sense ', 'chi0 ', 'gamma0' ]) * prm%sum_N_sl !ToDo: adjust names + Nconstituents = count(material_phaseAt2 == ph) + sizeDotState = size(['crss ','crss_back', 'accshear ']) * prm%sum_N_sl !ToDo: adjust names like in material.yaml + sizeDeltaState = size(['sense ', 'chi0 ', 'gamma0' ]) * prm%sum_N_sl !ToDo: adjust names like in material.yaml sizeState = sizeDotState + sizeDeltaState - call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,sizeDeltaState) + call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,sizeDeltaState) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization startIndex = 1 endIndex = prm%sum_N_sl - stt%crss => plasticState(p)%state (startIndex:endIndex,:) + stt%crss => plasticState(ph)%state (startIndex:endIndex,:) stt%crss = spread(xi_0, 2, Nconstituents) - dot%crss => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) - if(any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_xi' + dot%crss => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) + if(any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_xi' startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%crss_back => plasticState(p)%state (startIndex:endIndex,:) - dot%crss_back => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) + stt%crss_back => plasticState(ph)%state (startIndex:endIndex,:) + dot%crss_back => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%accshear => plasticState(p)%state (startIndex:endIndex,:) - dot%accshear => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_gamma',defaultVal=1.0e-6_pReal) - if(any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_gamma' + stt%accshear => plasticState(ph)%state (startIndex:endIndex,:) + dot%accshear => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_gamma',defaultVal=1.0e-6_pReal) + if(any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_gamma' ! global alias - plasticState(p)%slipRate => plasticState(p)%dotState(startIndex:endIndex,:) + plasticState(ph)%slipRate => plasticState(ph)%dotState(startIndex:endIndex,:) - o = plasticState(p)%offsetDeltaState + o = plasticState(ph)%offsetDeltaState startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%sense => plasticState(p)%state (startIndex :endIndex ,:) - dlt%sense => plasticState(p)%deltaState(startIndex-o:endIndex-o,:) + stt%sense => plasticState(ph)%state (startIndex :endIndex ,:) + dlt%sense => plasticState(ph)%deltaState(startIndex-o:endIndex-o,:) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%chi0 => plasticState(p)%state (startIndex :endIndex ,:) - dlt%chi0 => plasticState(p)%deltaState(startIndex-o:endIndex-o,:) + stt%chi0 => plasticState(ph)%state (startIndex :endIndex ,:) + dlt%chi0 => plasticState(ph)%deltaState(startIndex-o:endIndex-o,:) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%gamma0 => plasticState(p)%state (startIndex :endIndex ,:) - dlt%gamma0 => plasticState(p)%deltaState(startIndex-o:endIndex-o,:) + stt%gamma0 => plasticState(ph)%state (startIndex :endIndex ,:) + dlt%gamma0 => plasticState(ph)%deltaState(startIndex-o:endIndex-o,:) - plasticState(p)%state0 = plasticState(p)%state ! ToDo: this could be done centrally + plasticState(ph)%state0 = plasticState(ph)%state ! ToDo: this could be done centrally end associate diff --git a/src/phase_mechanical_plastic_none.f90 b/src/phase_mechanical_plastic_none.f90 index 1510262cc..28e9fbc7c 100644 --- a/src/phase_mechanical_plastic_none.f90 +++ b/src/phase_mechanical_plastic_none.f90 @@ -16,8 +16,7 @@ module function plastic_none_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - p, & - Nconstituents + ph class(tNode), pointer :: & phases @@ -29,10 +28,9 @@ module function plastic_none_init() result(myPlasticity) print'(a,i0)', ' # phases: ',count(myPlasticity); flush(IO_STDOUT) phases => config_material%get('phase') - do p = 1, phases%length - if(.not. myPlasticity(p)) cycle - Nconstituents = count(material_phaseAt2 == p) - call phase_allocateState(plasticState(p),Nconstituents,0,0,0) + do ph = 1, phases%length + if(.not. myPlasticity(ph)) cycle + call phase_allocateState(plasticState(ph),count(material_phaseAt2 == ph),0,0,0) enddo end function plastic_none_init diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 0212baee8..fbfcfa5af 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -176,7 +176,7 @@ module function plastic_nonlocal_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & Ninstances, & - p, i, & + ph, & Nconstituents, & sizeState, sizeDotState, sizeDependentState, sizeDeltaState, & s1, s2, & @@ -220,21 +220,17 @@ module function plastic_nonlocal_init() result(myPlasticity) allocate(deltaState(phases%length)) allocate(microstructure(phases%length)) - do p = 1, phases%length - if(.not. myPlasticity(p)) cycle - phase => phases%get(p) - mech => phase%get('mechanics') + do ph = 1, phases%length + if(.not. myPlasticity(ph)) cycle - i = p - associate(prm => param(i), & - dot => dotState(i), & - stt => state(i), & - st0 => state0(i), & - del => deltaState(i), & - dst => microstructure(i)) + associate(prm => param(ph), dot => dotState(ph), stt => state(ph), & + st0 => state0(ph), del => deltaState(ph), dst => microstructure(ph)) + + phase => phases%get(ph) + mech => phase%get('mechanics') pl => mech%get('plasticity') - phase_localPlasticity(p) = .not. pl%contains('nonlocal') + phase_localPlasticity(ph) = .not. pl%contains('nonlocal') #if defined (__GFORTRAN__) prm%output = output_asStrings(pl) @@ -245,8 +241,8 @@ module function plastic_nonlocal_init() result(myPlasticity) prm%atol_rho = pl%get_asFloat('atol_rho',defaultVal=1.0e4_pReal) ! This data is read in already in lattice - prm%mu = lattice_mu(p) - prm%nu = lattice_nu(p) + prm%mu = lattice_mu(ph) + prm%nu = lattice_nu(ph) ini%N_sl = pl%get_asInts('N_sl',defaultVal=emptyIntArray) prm%sum_N_sl = sum(abs(ini%N_sl)) @@ -402,7 +398,7 @@ module function plastic_nonlocal_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == p) + Nconstituents = count(material_phaseAt2 == ph) sizeDotState = size([ 'rhoSglEdgePosMobile ','rhoSglEdgeNegMobile ', & 'rhoSglScrewPosMobile ','rhoSglScrewNegMobile ', & 'rhoSglEdgePosImmobile ','rhoSglEdgeNegImmobile ', & @@ -416,101 +412,101 @@ module function plastic_nonlocal_init() result(myPlasticity) 'maxDipoleHeightEdge ','maxDipoleHeightScrew' ]) * prm%sum_N_sl !< other dependent state variables that are not updated by microstructure sizeDeltaState = sizeDotState - call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,sizeDeltaState) + call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,sizeDeltaState) - allocate(geom(p)%V_0(Nconstituents)) - call storeGeometry(p) + allocate(geom(ph)%V_0(Nconstituents)) + call storeGeometry(ph) - plasticState(p)%nonlocal = pl%get_asBool('nonlocal') - if(plasticState(p)%nonlocal .and. .not. allocated(IPneighborhood)) & + plasticState(ph)%nonlocal = pl%get_asBool('nonlocal') + if(plasticState(ph)%nonlocal .and. .not. allocated(IPneighborhood)) & call IO_error(212,ext_msg='IPneighborhood does not exist') - plasticState(p)%offsetDeltaState = 0 ! ToDo: state structure does not follow convention + plasticState(ph)%offsetDeltaState = 0 ! ToDo: state structure does not follow convention - st0%rho => plasticState(p)%state0 (0*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - stt%rho => plasticState(p)%state (0*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - dot%rho => plasticState(p)%dotState (0*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - del%rho => plasticState(p)%deltaState (0*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - plasticState(p)%atol(1:10*prm%sum_N_sl) = prm%atol_rho + st0%rho => plasticState(ph)%state0 (0*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + stt%rho => plasticState(ph)%state (0*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + dot%rho => plasticState(ph)%dotState (0*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + del%rho => plasticState(ph)%deltaState (0*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + plasticState(ph)%atol(1:10*prm%sum_N_sl) = prm%atol_rho - stt%rhoSgl => plasticState(p)%state (0*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) - dot%rhoSgl => plasticState(p)%dotState (0*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) - del%rhoSgl => plasticState(p)%deltaState (0*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) + stt%rhoSgl => plasticState(ph)%state (0*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) + dot%rhoSgl => plasticState(ph)%dotState (0*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) + del%rhoSgl => plasticState(ph)%deltaState (0*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) - stt%rhoSglMobile => plasticState(p)%state (0*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) - dot%rhoSglMobile => plasticState(p)%dotState (0*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) - del%rhoSglMobile => plasticState(p)%deltaState (0*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) + stt%rhoSglMobile => plasticState(ph)%state (0*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) + dot%rhoSglMobile => plasticState(ph)%dotState (0*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) + del%rhoSglMobile => plasticState(ph)%deltaState (0*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) - stt%rho_sgl_mob_edg_pos => plasticState(p)%state (0*prm%sum_N_sl+1: 1*prm%sum_N_sl,:) - dot%rho_sgl_mob_edg_pos => plasticState(p)%dotState (0*prm%sum_N_sl+1: 1*prm%sum_N_sl,:) - del%rho_sgl_mob_edg_pos => plasticState(p)%deltaState (0*prm%sum_N_sl+1: 1*prm%sum_N_sl,:) + stt%rho_sgl_mob_edg_pos => plasticState(ph)%state (0*prm%sum_N_sl+1: 1*prm%sum_N_sl,:) + dot%rho_sgl_mob_edg_pos => plasticState(ph)%dotState (0*prm%sum_N_sl+1: 1*prm%sum_N_sl,:) + del%rho_sgl_mob_edg_pos => plasticState(ph)%deltaState (0*prm%sum_N_sl+1: 1*prm%sum_N_sl,:) - stt%rho_sgl_mob_edg_neg => plasticState(p)%state (1*prm%sum_N_sl+1: 2*prm%sum_N_sl,:) - dot%rho_sgl_mob_edg_neg => plasticState(p)%dotState (1*prm%sum_N_sl+1: 2*prm%sum_N_sl,:) - del%rho_sgl_mob_edg_neg => plasticState(p)%deltaState (1*prm%sum_N_sl+1: 2*prm%sum_N_sl,:) + stt%rho_sgl_mob_edg_neg => plasticState(ph)%state (1*prm%sum_N_sl+1: 2*prm%sum_N_sl,:) + dot%rho_sgl_mob_edg_neg => plasticState(ph)%dotState (1*prm%sum_N_sl+1: 2*prm%sum_N_sl,:) + del%rho_sgl_mob_edg_neg => plasticState(ph)%deltaState (1*prm%sum_N_sl+1: 2*prm%sum_N_sl,:) - stt%rho_sgl_mob_scr_pos => plasticState(p)%state (2*prm%sum_N_sl+1: 3*prm%sum_N_sl,:) - dot%rho_sgl_mob_scr_pos => plasticState(p)%dotState (2*prm%sum_N_sl+1: 3*prm%sum_N_sl,:) - del%rho_sgl_mob_scr_pos => plasticState(p)%deltaState (2*prm%sum_N_sl+1: 3*prm%sum_N_sl,:) + stt%rho_sgl_mob_scr_pos => plasticState(ph)%state (2*prm%sum_N_sl+1: 3*prm%sum_N_sl,:) + dot%rho_sgl_mob_scr_pos => plasticState(ph)%dotState (2*prm%sum_N_sl+1: 3*prm%sum_N_sl,:) + del%rho_sgl_mob_scr_pos => plasticState(ph)%deltaState (2*prm%sum_N_sl+1: 3*prm%sum_N_sl,:) - stt%rho_sgl_mob_scr_neg => plasticState(p)%state (3*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) - dot%rho_sgl_mob_scr_neg => plasticState(p)%dotState (3*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) - del%rho_sgl_mob_scr_neg => plasticState(p)%deltaState (3*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) + stt%rho_sgl_mob_scr_neg => plasticState(ph)%state (3*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) + dot%rho_sgl_mob_scr_neg => plasticState(ph)%dotState (3*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) + del%rho_sgl_mob_scr_neg => plasticState(ph)%deltaState (3*prm%sum_N_sl+1: 4*prm%sum_N_sl,:) - stt%rhoSglImmobile => plasticState(p)%state (4*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) - dot%rhoSglImmobile => plasticState(p)%dotState (4*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) - del%rhoSglImmobile => plasticState(p)%deltaState (4*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) + stt%rhoSglImmobile => plasticState(ph)%state (4*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) + dot%rhoSglImmobile => plasticState(ph)%dotState (4*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) + del%rhoSglImmobile => plasticState(ph)%deltaState (4*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) - stt%rho_sgl_imm_edg_pos => plasticState(p)%state (4*prm%sum_N_sl+1: 5*prm%sum_N_sl,:) - dot%rho_sgl_imm_edg_pos => plasticState(p)%dotState (4*prm%sum_N_sl+1: 5*prm%sum_N_sl,:) - del%rho_sgl_imm_edg_pos => plasticState(p)%deltaState (4*prm%sum_N_sl+1: 5*prm%sum_N_sl,:) + stt%rho_sgl_imm_edg_pos => plasticState(ph)%state (4*prm%sum_N_sl+1: 5*prm%sum_N_sl,:) + dot%rho_sgl_imm_edg_pos => plasticState(ph)%dotState (4*prm%sum_N_sl+1: 5*prm%sum_N_sl,:) + del%rho_sgl_imm_edg_pos => plasticState(ph)%deltaState (4*prm%sum_N_sl+1: 5*prm%sum_N_sl,:) - stt%rho_sgl_imm_edg_neg => plasticState(p)%state (5*prm%sum_N_sl+1: 6*prm%sum_N_sl,:) - dot%rho_sgl_imm_edg_neg => plasticState(p)%dotState (5*prm%sum_N_sl+1: 6*prm%sum_N_sl,:) - del%rho_sgl_imm_edg_neg => plasticState(p)%deltaState (5*prm%sum_N_sl+1: 6*prm%sum_N_sl,:) + stt%rho_sgl_imm_edg_neg => plasticState(ph)%state (5*prm%sum_N_sl+1: 6*prm%sum_N_sl,:) + dot%rho_sgl_imm_edg_neg => plasticState(ph)%dotState (5*prm%sum_N_sl+1: 6*prm%sum_N_sl,:) + del%rho_sgl_imm_edg_neg => plasticState(ph)%deltaState (5*prm%sum_N_sl+1: 6*prm%sum_N_sl,:) - stt%rho_sgl_imm_scr_pos => plasticState(p)%state (6*prm%sum_N_sl+1: 7*prm%sum_N_sl,:) - dot%rho_sgl_imm_scr_pos => plasticState(p)%dotState (6*prm%sum_N_sl+1: 7*prm%sum_N_sl,:) - del%rho_sgl_imm_scr_pos => plasticState(p)%deltaState (6*prm%sum_N_sl+1: 7*prm%sum_N_sl,:) + stt%rho_sgl_imm_scr_pos => plasticState(ph)%state (6*prm%sum_N_sl+1: 7*prm%sum_N_sl,:) + dot%rho_sgl_imm_scr_pos => plasticState(ph)%dotState (6*prm%sum_N_sl+1: 7*prm%sum_N_sl,:) + del%rho_sgl_imm_scr_pos => plasticState(ph)%deltaState (6*prm%sum_N_sl+1: 7*prm%sum_N_sl,:) - stt%rho_sgl_imm_scr_neg => plasticState(p)%state (7*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) - dot%rho_sgl_imm_scr_neg => plasticState(p)%dotState (7*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) - del%rho_sgl_imm_scr_neg => plasticState(p)%deltaState (7*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) + stt%rho_sgl_imm_scr_neg => plasticState(ph)%state (7*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) + dot%rho_sgl_imm_scr_neg => plasticState(ph)%dotState (7*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) + del%rho_sgl_imm_scr_neg => plasticState(ph)%deltaState (7*prm%sum_N_sl+1: 8*prm%sum_N_sl,:) - stt%rhoDip => plasticState(p)%state (8*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - dot%rhoDip => plasticState(p)%dotState (8*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - del%rhoDip => plasticState(p)%deltaState (8*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + stt%rhoDip => plasticState(ph)%state (8*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + dot%rhoDip => plasticState(ph)%dotState (8*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + del%rhoDip => plasticState(ph)%deltaState (8*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - stt%rho_dip_edg => plasticState(p)%state (8*prm%sum_N_sl+1: 9*prm%sum_N_sl,:) - dot%rho_dip_edg => plasticState(p)%dotState (8*prm%sum_N_sl+1: 9*prm%sum_N_sl,:) - del%rho_dip_edg => plasticState(p)%deltaState (8*prm%sum_N_sl+1: 9*prm%sum_N_sl,:) + stt%rho_dip_edg => plasticState(ph)%state (8*prm%sum_N_sl+1: 9*prm%sum_N_sl,:) + dot%rho_dip_edg => plasticState(ph)%dotState (8*prm%sum_N_sl+1: 9*prm%sum_N_sl,:) + del%rho_dip_edg => plasticState(ph)%deltaState (8*prm%sum_N_sl+1: 9*prm%sum_N_sl,:) - stt%rho_dip_scr => plasticState(p)%state (9*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - dot%rho_dip_scr => plasticState(p)%dotState (9*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - del%rho_dip_scr => plasticState(p)%deltaState (9*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + stt%rho_dip_scr => plasticState(ph)%state (9*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + dot%rho_dip_scr => plasticState(ph)%dotState (9*prm%sum_N_sl+1:10*prm%sum_N_sl,:) + del%rho_dip_scr => plasticState(ph)%deltaState (9*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - stt%gamma => plasticState(p)%state (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) - dot%gamma => plasticState(p)%dotState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) - del%gamma => plasticState(p)%deltaState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) - plasticState(p)%atol(10*prm%sum_N_sl+1:11*prm%sum_N_sl ) = pl%get_asFloat('atol_gamma', defaultVal = 1.0e-2_pReal) - if(any(plasticState(p)%atol(10*prm%sum_N_sl+1:11*prm%sum_N_sl) < 0.0_pReal)) & + stt%gamma => plasticState(ph)%state (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) + dot%gamma => plasticState(ph)%dotState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) + del%gamma => plasticState(ph)%deltaState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) + plasticState(ph)%atol(10*prm%sum_N_sl+1:11*prm%sum_N_sl ) = pl%get_asFloat('atol_gamma', defaultVal = 1.0e-2_pReal) + if(any(plasticState(ph)%atol(10*prm%sum_N_sl+1:11*prm%sum_N_sl) < 0.0_pReal)) & extmsg = trim(extmsg)//' atol_gamma' - plasticState(p)%slipRate => plasticState(p)%dotState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) + plasticState(ph)%slipRate => plasticState(ph)%dotState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) - stt%rho_forest => plasticState(p)%state (11*prm%sum_N_sl + 1:12*prm%sum_N_sl,1:Nconstituents) - stt%v => plasticState(p)%state (12*prm%sum_N_sl + 1:16*prm%sum_N_sl,1:Nconstituents) - stt%v_edg_pos => plasticState(p)%state (12*prm%sum_N_sl + 1:13*prm%sum_N_sl,1:Nconstituents) - stt%v_edg_neg => plasticState(p)%state (13*prm%sum_N_sl + 1:14*prm%sum_N_sl,1:Nconstituents) - stt%v_scr_pos => plasticState(p)%state (14*prm%sum_N_sl + 1:15*prm%sum_N_sl,1:Nconstituents) - stt%v_scr_neg => plasticState(p)%state (15*prm%sum_N_sl + 1:16*prm%sum_N_sl,1:Nconstituents) + stt%rho_forest => plasticState(ph)%state (11*prm%sum_N_sl + 1:12*prm%sum_N_sl,1:Nconstituents) + stt%v => plasticState(ph)%state (12*prm%sum_N_sl + 1:16*prm%sum_N_sl,1:Nconstituents) + stt%v_edg_pos => plasticState(ph)%state (12*prm%sum_N_sl + 1:13*prm%sum_N_sl,1:Nconstituents) + stt%v_edg_neg => plasticState(ph)%state (13*prm%sum_N_sl + 1:14*prm%sum_N_sl,1:Nconstituents) + stt%v_scr_pos => plasticState(ph)%state (14*prm%sum_N_sl + 1:15*prm%sum_N_sl,1:Nconstituents) + stt%v_scr_neg => plasticState(ph)%state (15*prm%sum_N_sl + 1:16*prm%sum_N_sl,1:Nconstituents) allocate(dst%tau_pass(prm%sum_N_sl,Nconstituents),source=0.0_pReal) allocate(dst%tau_back(prm%sum_N_sl,Nconstituents),source=0.0_pReal) end associate - if (Nconstituents > 0) call stateInit(ini,p,Nconstituents) - plasticState(p)%state0 = plasticState(p)%state + if (Nconstituents > 0) call stateInit(ini,ph,Nconstituents) + plasticState(ph)%state0 = plasticState(ph)%state !-------------------------------------------------------------------------------------------------- ! exit if any parameter is out of range @@ -526,35 +522,34 @@ module function plastic_nonlocal_init() result(myPlasticity) allocate(iV(maxval(param%sum_N_sl),4,phases%length), source=0) allocate(iD(maxval(param%sum_N_sl),2,phases%length), source=0) - do p = 1, phases%length - phase => phases%get(p) + do ph = 1, phases%length - if(.not. myPlasticity(p)) cycle - i = p + if(.not. myPlasticity(ph)) cycle - Nconstituents = count(material_phaseAt2 == p) + phase => phases%get(ph) + Nconstituents = count(material_phaseAt2 == ph) l = 0 do t = 1,4 - do s = 1,param(i)%sum_N_sl + do s = 1,param(ph)%sum_N_sl l = l + 1 - iRhoU(s,t,i) = l + iRhoU(s,t,ph) = l enddo enddo - l = l + (4+2+1+1)*param(i)%sum_N_sl ! immobile(4), dipole(2), shear, forest + l = l + (4+2+1+1)*param(ph)%sum_N_sl ! immobile(4), dipole(2), shear, forest do t = 1,4 - do s = 1,param(i)%sum_N_sl + do s = 1,param(ph)%sum_N_sl l = l + 1 - iV(s,t,i) = l + iV(s,t,ph) = l enddo enddo do t = 1,2 - do s = 1,param(i)%sum_N_sl + do s = 1,param(ph)%sum_N_sl l = l + 1 - iD(s,t,i) = l + iD(s,t,ph) = l enddo enddo - if (iD(param(i)%sum_N_sl,2,i) /= plasticState(p)%sizeState) & - call IO_error(0, ext_msg = 'state indices not properly set (nonlocal)') + if (iD(param(ph)%sum_N_sl,2,ph) /= plasticState(ph)%sizeState) & + error stop 'state indices not properly set (nonlocal)' enddo end function plastic_nonlocal_init diff --git a/src/phase_mechanical_plastic_phenopowerlaw.f90 b/src/phase_mechanical_plastic_phenopowerlaw.f90 index 94214f14a..d769431b4 100644 --- a/src/phase_mechanical_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanical_plastic_phenopowerlaw.f90 @@ -70,7 +70,7 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & - p, i, & + ph, i, & Nconstituents, & sizeState, sizeDotState, & startIndex, endIndex @@ -101,14 +101,13 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) allocate(state(phases%length)) allocate(dotState(phases%length)) - do p = 1, phases%length - if(.not. myPlasticity(p)) cycle - phase => phases%get(p) + do ph = 1, phases%length + if(.not. myPlasticity(ph)) cycle + + associate(prm => param(ph), dot => dotState(ph), stt => state(ph)) + + phase => phases%get(ph) mech => phase%get('mechanics') - i = p - associate(prm => param(i), & - dot => dotState(i), & - stt => state(i)) pl => mech%get('plasticity') !-------------------------------------------------------------------------------------------------- @@ -135,7 +134,7 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) xi_0_sl = pl%get_asFloats('xi_0_sl', requiredSize=size(N_sl)) prm%xi_inf_sl = pl%get_asFloats('xi_inf_sl', requiredSize=size(N_sl)) prm%h_int = pl%get_asFloats('h_int', requiredSize=size(N_sl), & - defaultVal=[(0.0_pReal,i=1,size(N_sl))]) + defaultVal=[(0.0_pReal,i=1,size(N_sl))]) prm%dot_gamma_0_sl = pl%get_asFloat('dot_gamma_0_sl') prm%n_sl = pl%get_asFloat('n_sl') @@ -224,49 +223,49 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == p) + Nconstituents = count(material_phaseAt2 == ph) sizeDotState = size(['xi_sl ','gamma_sl']) * prm%sum_N_sl & + size(['xi_tw ','gamma_tw']) * prm%sum_N_tw sizeState = sizeDotState - call phase_allocateState(plasticState(p),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization startIndex = 1 endIndex = prm%sum_N_sl - stt%xi_slip => plasticState(p)%state (startIndex:endIndex,:) + stt%xi_slip => plasticState(ph)%state (startIndex:endIndex,:) stt%xi_slip = spread(xi_0_sl, 2, Nconstituents) - dot%xi_slip => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) - if(any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_xi' + dot%xi_slip => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) + if(any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_xi' startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_tw - stt%xi_twin => plasticState(p)%state (startIndex:endIndex,:) + stt%xi_twin => plasticState(ph)%state (startIndex:endIndex,:) stt%xi_twin = spread(xi_0_tw, 2, Nconstituents) - dot%xi_twin => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) - if(any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_xi' + dot%xi_twin => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) + if(any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_xi' startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl - stt%gamma_slip => plasticState(p)%state (startIndex:endIndex,:) - dot%gamma_slip => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_gamma',defaultVal=1.0e-6_pReal) - if(any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_gamma' + stt%gamma_slip => plasticState(ph)%state (startIndex:endIndex,:) + dot%gamma_slip => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_gamma',defaultVal=1.0e-6_pReal) + if(any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_gamma' ! global alias - plasticState(p)%slipRate => plasticState(p)%dotState(startIndex:endIndex,:) + plasticState(ph)%slipRate => plasticState(ph)%dotState(startIndex:endIndex,:) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_tw - stt%gamma_twin => plasticState(p)%state (startIndex:endIndex,:) - dot%gamma_twin => plasticState(p)%dotState(startIndex:endIndex,:) - plasticState(p)%atol(startIndex:endIndex) = pl%get_asFloat('atol_gamma',defaultVal=1.0e-6_pReal) - if(any(plasticState(p)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_gamma' + stt%gamma_twin => plasticState(ph)%state (startIndex:endIndex,:) + dot%gamma_twin => plasticState(ph)%dotState(startIndex:endIndex,:) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_gamma',defaultVal=1.0e-6_pReal) + if(any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_gamma' - plasticState(p)%state0 = plasticState(p)%state ! ToDo: this could be done centrally + plasticState(ph)%state0 = plasticState(ph)%state ! ToDo: this could be done centrally end associate From b6146a8cc61ba710f597f70ab2fbd681dc18e27f Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 16 Feb 2021 19:17:18 +0100 Subject: [PATCH 255/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-469-gcf3084a5c --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0a4efbf53..341603c75 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-442-ge2708d29f +v3.0.0-alpha2-469-gcf3084a5c From 6c7201610e4c56a06cfb03d8459dc3efae502e90 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 17 Feb 2021 17:56:39 +0100 Subject: [PATCH 256/352] 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 257/352] 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 258/352] 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 36db53f260701bcffe9212511961f10486705edd Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 19 Feb 2021 16:05:33 +0100 Subject: [PATCH 259/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-478-gc9e4dc21f --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 341603c75..26e9be190 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-469-gcf3084a5c +v3.0.0-alpha2-478-gc9e4dc21f From f5f993435b6f59f1ea50eefbc63b1ded186e55e0 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 19 Feb 2021 16:34:28 +0100 Subject: [PATCH 260/352] 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 261/352] 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 262/352] 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 263/352] 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 264/352] 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 265/352] 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 266/352] 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 267/352] 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 268/352] 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 269/352] 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 270/352] 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 271/352] 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 272/352] [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 2f9d891fddd2a7cdd1d03f5ea9713a9cb6162cf1 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Mon, 22 Feb 2021 16:17:32 +0100 Subject: [PATCH 273/352] instance less; use cell mapping --- src/homogenization.f90 | 11 +-- src/homogenization_mechanical.f90 | 24 +++---- src/homogenization_mechanical_RGC.f90 | 100 +++++++++++++------------- 3 files changed, 67 insertions(+), 68 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index a0e31632f..72ae2231a 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -126,14 +126,15 @@ module homogenization integer, intent(in) :: h end subroutine mechanical_results - module function mechanical_updateState(subdt,subF,ip,el) result(doneAndHappy) + module function mechanical_updateState(subdt,subF,ce,ip,el) result(doneAndHappy) real(pReal), intent(in) :: & - subdt !< current time step + subdt !< current time step real(pReal), intent(in), dimension(3,3) :: & subF integer, intent(in) :: & - ip, & !< integration point - el !< element number + ce, & !< cell + ip, & + el logical, dimension(2) :: doneAndHappy end function mechanical_updateState @@ -326,7 +327,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if (.not. converged) then doneAndHappy = [.true.,.false.] else - doneAndHappy = mechanical_updateState(dt,homogenization_F(1:3,1:3,ce),ip,el) + doneAndHappy = mechanical_updateState(dt,homogenization_F(1:3,1:3,ce),ce,ip,el) converged = all(doneAndHappy) endif endif diff --git a/src/homogenization_mechanical.f90 b/src/homogenization_mechanical.f90 index bdbbc35d4..cd9eafdb2 100644 --- a/src/homogenization_mechanical.f90 +++ b/src/homogenization_mechanical.f90 @@ -51,7 +51,7 @@ submodule(homogenization) mechanical end subroutine mechanical_RGC_averageStressAndItsTangent - module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy) + module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHappy) logical, dimension(2) :: doneAndHappy real(pReal), dimension(:,:,:), intent(in) :: & P,& !< partitioned stresses @@ -60,8 +60,7 @@ submodule(homogenization) mechanical real(pReal), dimension(3,3), intent(in) :: avgF !< average F real(pReal), intent(in) :: dt !< time increment integer, intent(in) :: & - ip, & !< integration point number - el !< element number + ce !< cell end function mechanical_RGC_updateState @@ -188,30 +187,31 @@ end subroutine mechanical_homogenize !> @brief update the internal state of the homogenization scheme and tell whether "done" and !> "happy" with result !-------------------------------------------------------------------------------------------------- -module function mechanical_updateState(subdt,subF,ip,el) result(doneAndHappy) +module function mechanical_updateState(subdt,subF,ce,ip,el) result(doneAndHappy) real(pReal), intent(in) :: & subdt !< current time step real(pReal), intent(in), dimension(3,3) :: & subF integer, intent(in) :: & - ip, & !< integration point - el !< element number + ce, & + ip, & + el logical, dimension(2) :: doneAndHappy integer :: co - real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) - real(pReal) :: Fs(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) - real(pReal) :: Ps(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) + real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt2(ce))) + real(pReal) :: Fs(3,3,homogenization_Nconstituents(material_homogenizationAt2(ce))) + real(pReal) :: Ps(3,3,homogenization_Nconstituents(material_homogenizationAt2(ce))) - if (homogenization_type(material_homogenizationAt(el)) == HOMOGENIZATION_RGC_ID) then - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + if (homogenization_type(material_homogenizationAt2(ce)) == HOMOGENIZATION_RGC_ID) then + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(subdt,co,ip,el) Fs(:,:,co) = phase_mechanical_getF(co,ip,el) Ps(:,:,co) = phase_mechanical_getP(co,ip,el) enddo - doneAndHappy = mechanical_RGC_updateState(Ps,Fs,subF,subdt,dPdFs,ip,el) + doneAndHappy = mechanical_RGC_updateState(Ps,Fs,subF,subdt,dPdFs,ce) else doneAndHappy = .true. endif diff --git a/src/homogenization_mechanical_RGC.f90 b/src/homogenization_mechanical_RGC.f90 index 4a186a51b..4800369ee 100644 --- a/src/homogenization_mechanical_RGC.f90 +++ b/src/homogenization_mechanical_RGC.f90 @@ -236,7 +236,7 @@ end subroutine mechanical_RGC_partitionDeformation !> @brief update the internal state of the homogenization scheme and tell whether "done" and ! "happy" with result !-------------------------------------------------------------------------------------------------- -module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAndHappy) +module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHappy) logical, dimension(2) :: doneAndHappy real(pReal), dimension(:,:,:), intent(in) :: & P,& !< partitioned stresses @@ -245,12 +245,11 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn real(pReal), dimension(3,3), intent(in) :: avgF !< average F real(pReal), intent(in) :: dt !< time increment integer, intent(in) :: & - ip, & !< integration point number - el !< element number + ce !< cell integer, dimension(4) :: intFaceN,intFaceP,faceID integer, dimension(3) :: nGDim,iGr3N,iGr3P - integer :: instance,iNum,i,j,nIntFaceTot,iGrN,iGrP,iMun,iFace,k,l,ipert,iGrain,nGrain, of + integer :: instance,iNum,i,j,nIntFaceTot,iGrN,iGrP,iMun,iFace,k,l,ipert,iGrain,nGrain, me real(pReal), dimension(3,3,size(P,3)) :: R,pF,pR,D,pD real(pReal), dimension(3,size(P,3)) :: NN,devNull real(pReal), dimension(3) :: normP,normN,mornP,mornN @@ -264,9 +263,9 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn return endif zeroTimeStep - instance = homogenization_typeInstance(material_homogenizationAt(el)) - of = material_homogenizationMemberAt(ip,el) + instance = homogenization_typeInstance(material_homogenizationAt2(ce)) + me = material_homogenizationMemberAt2(ce) associate(stt => state(instance), st0 => state0(instance), dst => dependentState(instance), prm => param(instance)) !-------------------------------------------------------------------------------------------------- @@ -281,16 +280,16 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn ! allocate the size of the global relaxation arrays/jacobian matrices depending on the size of the cluster allocate(resid(3*nIntFaceTot), source=0.0_pReal) allocate(tract(nIntFaceTot,3), source=0.0_pReal) - relax = stt%relaxationVector(:,of) - drelax = stt%relaxationVector(:,of) - st0%relaxationVector(:,of) + relax = stt%relaxationVector(:,me) + drelax = stt%relaxationVector(:,me) - st0%relaxationVector(:,me) !-------------------------------------------------------------------------------------------------- ! computing interface mismatch and stress penalty tensor for all interfaces of all grains - call stressPenalty(R,NN,avgF,F,ip,el,instance,of) + call stressPenalty(R,NN,avgF,F,ce,me) !-------------------------------------------------------------------------------------------------- ! calculating volume discrepancy and stress penalty related to overall volume discrepancy - call volumePenalty(D,dst%volumeDiscrepancy(of),avgF,F,nGrain,instance,of) + call volumePenalty(D,dst%volumeDiscrepancy(me),avgF,F,nGrain,ce,me) !------------------------------------------------------------------------------------------------ ! computing the residual stress from the balance of traction at all (interior) interfaces @@ -302,7 +301,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn iGr3N = faceID(2:4) ! identifying the grain ID in local coordinate system (3-dimensional index) iGrN = grain3to1(iGr3N,param(instance)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceN = getInterface(2*faceID(1),iGr3N) - normN = interfaceNormal(intFaceN,instance,of) + normN = interfaceNormal(intFaceN,ce,me) !-------------------------------------------------------------------------------------------------- ! identify the right/up/front grain (+|P) @@ -310,7 +309,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn iGr3P(faceID(1)) = iGr3N(faceID(1))+1 ! identifying the grain ID in local coordinate system (3-dimensional index) iGrP = grain3to1(iGr3P,param(instance)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceP = getInterface(2*faceID(1)-1,iGr3P) - normP = interfaceNormal(intFaceP,instance,of) + normP = interfaceNormal(intFaceP,ce,me) !-------------------------------------------------------------------------------------------------- ! compute the residual of traction at the interface (in local system, 4-dimensional index) @@ -338,9 +337,9 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn if (residMax < num%rtol*stresMax .or. residMax < num%atol) then doneAndHappy = .true. - dst%mismatch(1:3,of) = sum(NN,2)/real(nGrain,pReal) - dst%relaxationRate_avg(of) = sum(abs(drelax))/dt/real(3*nIntFaceTot,pReal) - dst%relaxationRate_max(of) = maxval(abs(drelax))/dt + dst%mismatch(1:3,me) = sum(NN,2)/real(nGrain,pReal) + dst%relaxationRate_avg(me) = sum(abs(drelax))/dt/real(3*nIntFaceTot,pReal) + dst%relaxationRate_max(me) = maxval(abs(drelax))/dt return @@ -366,10 +365,10 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn iGr3N = faceID(2:4) ! identifying the grain ID in local coordinate sytem iGrN = grain3to1(iGr3N,param(instance)%N_constituents) ! translate into global grain ID intFaceN = getInterface(2*faceID(1),iGr3N) ! identifying the connecting interface in local coordinate system - normN = interfaceNormal(intFaceN,instance,of) + normN = interfaceNormal(intFaceN,ce,me) do iFace = 1,6 intFaceN = getInterface(iFace,iGr3N) ! identifying all interfaces that influence relaxation of the above interface - mornN = interfaceNormal(intFaceN,instance,of) + mornN = interfaceNormal(intFaceN,ce,me) iMun = interface4to1(intFaceN,param(instance)%N_constituents) ! translate the interfaces ID into local 4-dimensional index if (iMun > 0) then ! get the corresponding tangent do i=1,3; do j=1,3; do k=1,3; do l=1,3 @@ -387,10 +386,10 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn iGr3P(faceID(1)) = iGr3N(faceID(1))+1 ! identifying the grain ID in local coordinate sytem iGrP = grain3to1(iGr3P,param(instance)%N_constituents) ! translate into global grain ID intFaceP = getInterface(2*faceID(1)-1,iGr3P) ! identifying the connecting interface in local coordinate system - normP = interfaceNormal(intFaceP,instance,of) + normP = interfaceNormal(intFaceP,ce,me) do iFace = 1,6 intFaceP = getInterface(iFace,iGr3P) ! identifying all interfaces that influence relaxation of the above interface - mornP = interfaceNormal(intFaceP,instance,of) + mornP = interfaceNormal(intFaceP,ce,me) iMun = interface4to1(intFaceP,param(instance)%N_constituents) ! translate the interfaces ID into local 4-dimensional index if (iMun > 0) then ! get the corresponding tangent do i=1,3; do j=1,3; do k=1,3; do l=1,3 @@ -411,10 +410,10 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn do ipert = 1,3*nIntFaceTot p_relax = relax p_relax(ipert) = relax(ipert) + num%pPert ! perturb the relaxation vector - stt%relaxationVector(:,of) = p_relax - call grainDeformation(pF,avgF,instance,of) ! rain deformation from perturbed state - call stressPenalty(pR,DevNull, avgF,pF,ip,el,instance,of) ! stress penalty due to interface mismatch from perturbed state - call volumePenalty(pD,devNull(1,1), avgF,pF,nGrain,instance,of) ! stress penalty due to volume discrepancy from perturbed state + stt%relaxationVector(:,me) = p_relax + call grainDeformation(pF,avgF,ce,me) ! rain deformation from perturbed state + call stressPenalty(pR,DevNull, avgF,pF,ce,me) ! stress penalty due to interface mismatch from perturbed state + call volumePenalty(pD,devNull(1,1), avgF,pF,nGrain,ce,me) ! stress penalty due to volume discrepancy from perturbed state !-------------------------------------------------------------------------------------------------- ! computing the global stress residual array from the perturbed state @@ -427,7 +426,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn iGr3N = faceID(2:4) ! identify the grain ID in local coordinate system (3-dimensional index) iGrN = grain3to1(iGr3N,param(instance)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceN = getInterface(2*faceID(1),iGr3N) ! identify the interface ID of the grain - normN = interfaceNormal(intFaceN,instance,of) + normN = interfaceNormal(intFaceN,ce,me) !-------------------------------------------------------------------------------------------------- ! identify the right/up/front grain (+|P) @@ -435,7 +434,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn iGr3P(faceID(1)) = iGr3N(faceID(1))+1 ! identify the grain ID in local coordinate system (3-dimensional index) iGrP = grain3to1(iGr3P,param(instance)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceP = getInterface(2*faceID(1)-1,iGr3P) ! identify the interface ID of the grain - normP = interfaceNormal(intFaceP,instance,of) + normP = interfaceNormal(intFaceP,ce,me) !-------------------------------------------------------------------------------------------------- ! compute the residual stress (contribution of mismatch and volume penalties) from perturbed state @@ -475,11 +474,11 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn do i = 1,3*nIntFaceTot;do j = 1,3*nIntFaceTot drelax(i) = drelax(i) - jnverse(i,j)*resid(j) ! Calculate the correction for the state variable enddo; enddo - stt%relaxationVector(:,of) = relax + drelax ! Updateing the state variable for the next iteration + stt%relaxationVector(:,me) = relax + drelax ! Updateing the state variable for the next iteration if (any(abs(drelax) > num%maxdRelax)) then ! Forcing cutback when the incremental change of relaxation vector becomes too large doneAndHappy = [.true.,.false.] !$OMP CRITICAL (write2out) - print'(a,i3,a,i3,a)',' RGC_updateState: ip ',ip,' | el ',el,' enforces cutback' + ! print'(a,i3,a,i3,a)',' RGC_updateState: ip ',ip,' | el ',el,' enforces cutback' print'(a,e15.8)',' due to large relaxation change = ',maxval(abs(drelax)) flush(IO_STDOUT) !$OMP END CRITICAL (write2out) @@ -491,14 +490,14 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn !------------------------------------------------------------------------------------------------ !> @brief calculate stress-like penalty due to deformation mismatch !------------------------------------------------------------------------------------------------ - subroutine stressPenalty(rPen,nMis,avgF,fDef,ip,el,instance,of) + subroutine stressPenalty(rPen,nMis,avgF,fDef,ce,me) real(pReal), dimension (:,:,:), intent(out) :: rPen !< stress-like penalty real(pReal), dimension (:,:), intent(out) :: nMis !< total amount of mismatch real(pReal), dimension (:,:,:), intent(in) :: fDef !< deformation gradients real(pReal), dimension (3,3), intent(in) :: avgF !< initial effective stretch tensor - integer, intent(in) :: ip,el,instance,of + integer, intent(in) :: ce, me integer, dimension (4) :: intFace integer, dimension (3) :: iGrain3,iGNghb3,nGDim @@ -518,27 +517,27 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn ! get the correction factor the modulus of penalty stress representing the evolution of area of ! the interfaces due to deformations - surfCorr = surfaceCorrection(avgF,instance,of) + surfCorr = surfaceCorrection(avgF,ce,me) - associate(prm => param(instance)) + associate(prm => param(homogenization_typeInstance(material_homogenizationAt2(ce)))) !----------------------------------------------------------------------------------------------- ! computing the mismatch and penalty stress tensor of all grains grainLoop: do iGrain = 1,product(prm%N_constituents) - muGrain = equivalentMu(iGrain,ip,el) + muGrain = equivalentMu(iGrain,ce) iGrain3 = grain1to3(iGrain,prm%N_constituents) ! get the grain ID in local 3-dimensional index (x,y,z)-position interfaceLoop: do iFace = 1,6 intFace = getInterface(iFace,iGrain3) ! get the 4-dimensional index of the interface in local numbering system of the grain - nVect = interfaceNormal(intFace,instance,of) + nVect = interfaceNormal(intFace,ce,me) iGNghb3 = iGrain3 ! identify the neighboring grain across the interface iGNghb3(abs(intFace(1))) = iGNghb3(abs(intFace(1))) & + int(real(intFace(1),pReal)/real(abs(intFace(1)),pReal)) where(iGNghb3 < 1) iGNghb3 = nGDim where(iGNghb3 >nGDim) iGNghb3 = 1 iGNghb = grain3to1(iGNghb3,prm%N_constituents) ! get the ID of the neighboring grain - muGNghb = equivalentMu(iGNghb,ip,el) + muGNghb = equivalentMu(iGNghb,ce) gDef = 0.5_pReal*(fDef(1:3,1:3,iGNghb) - fDef(1:3,1:3,iGrain)) ! difference/jump in deformation gradeint across the neighbor !------------------------------------------------------------------------------------------- @@ -577,7 +576,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn !------------------------------------------------------------------------------------------------ !> @brief calculate stress-like penalty due to volume discrepancy !------------------------------------------------------------------------------------------------ - subroutine volumePenalty(vPen,vDiscrep,fAvg,fDef,nGrain,instance,of) + subroutine volumePenalty(vPen,vDiscrep,fAvg,fDef,nGrain,ce,me) real(pReal), dimension (:,:,:), intent(out) :: vPen ! stress-like penalty due to volume real(pReal), intent(out) :: vDiscrep ! total volume discrepancy @@ -586,8 +585,8 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn real(pReal), dimension (3,3), intent(in) :: fAvg ! overall deformation gradient integer, intent(in) :: & Ngrain, & - instance, & - of + ce, & + me real(pReal), dimension(size(vPen,3)) :: gVol integer :: i @@ -617,14 +616,14 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn !> @brief compute the correction factor accouted for surface evolution (area change) due to ! deformation !-------------------------------------------------------------------------------------------------- - function surfaceCorrection(avgF,instance,of) + function surfaceCorrection(avgF,ce,me) real(pReal), dimension(3) :: surfaceCorrection real(pReal), dimension(3,3), intent(in) :: avgF !< average F integer, intent(in) :: & - instance, & - of + ce, & + me real(pReal), dimension(3,3) :: invC real(pReal), dimension(3) :: nVect real(pReal) :: detF @@ -635,7 +634,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn surfaceCorrection = 0.0_pReal do iBase = 1,3 - nVect = interfaceNormal([iBase,1,1,1],instance,of) + nVect = interfaceNormal([iBase,1,1,1],ce,me) do i = 1,3; do j = 1,3 surfaceCorrection(iBase) = surfaceCorrection(iBase) + invC(i,j)*nVect(i)*nVect(j) ! compute the component of (the inverse of) the stretch in the direction of the normal enddo; enddo @@ -648,17 +647,16 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn !------------------------------------------------------------------------------------------------- !> @brief compute the equivalent shear and bulk moduli from the elasticity tensor !------------------------------------------------------------------------------------------------- - real(pReal) function equivalentMu(grainID,ip,el) + real(pReal) function equivalentMu(grainID,ce) integer, intent(in) :: & grainID,& - ip, & !< integration point number - el !< element number + ce !< cell real(pReal), dimension(6,6) :: C - C = phase_homogenizedC(material_phaseAt(grainID,el),material_phaseMemberAt(grainID,ip,el)) + C = phase_homogenizedC(material_phaseAt2(grainID,ce),material_phaseMemberAt2(grainID,ce)) equivalentMu = lattice_equivalent_mu(C,'voigt') end function equivalentMu @@ -668,14 +666,14 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn !> @brief calculating the grain deformation gradient (the same with ! homogenization_RGC_partitionDeformation, but used only for perturbation scheme) !------------------------------------------------------------------------------------------------- - subroutine grainDeformation(F, avgF, instance, of) + subroutine grainDeformation(F, avgF, ce, me) real(pReal), dimension(:,:,:), intent(out) :: F !< partitioned F per grain real(pReal), dimension(:,:), intent(in) :: avgF !< averaged F integer, intent(in) :: & - instance, & - of + ce, & + me real(pReal), dimension(3) :: aVect,nVect integer, dimension(4) :: intFace @@ -685,15 +683,15 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ip,el) result(doneAn !----------------------------------------------------------------------------------------------- ! compute the deformation gradient of individual grains due to relaxations - associate(prm => param(instance)) + associate (prm => param(homogenization_typeInstance(material_homogenizationAt2(ce)))) F = 0.0_pReal do iGrain = 1,product(prm%N_constituents) iGrain3 = grain1to3(iGrain,prm%N_constituents) do iFace = 1,6 intFace = getInterface(iFace,iGrain3) - aVect = relaxationVector(intFace,instance,of) - nVect = interfaceNormal(intFace,instance,of) + aVect = relaxationVector(intFace,ce,me) + nVect = interfaceNormal(intFace,ce,me) forall (i=1:3,j=1:3) & F(i,j,iGrain) = F(i,j,iGrain) + aVect(i)*nVect(j) ! effective relaxations enddo From 5c2b3846a21f6b50e1b4e2c08620dc259948566b Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 22 Feb 2021 10:20:04 -0500 Subject: [PATCH 274/352] 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 275/352] 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 276/352] 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 277/352] 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 278/352] 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 279/352] 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 280/352] [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 281/352] 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 282/352] [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 283/352] 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 284/352] 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 e249168189db9786fe39f0094322a9399a79fb43 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Mon, 22 Feb 2021 18:32:31 +0100 Subject: [PATCH 285/352] modifying storing of orientations; needed for nonlocal, and also to remove the use if ip,el at homogenization level. ip, el should be used only for looping eventually. --- src/homogenization.f90 | 6 +++-- src/homogenization_mechanical.f90 | 10 +++---- src/homogenization_thermal.f90 | 11 ++++---- src/material.f90 | 8 +----- src/phase.f90 | 32 ++++++++++++++--------- src/phase_mechanical.f90 | 29 ++++++++++++++------ src/phase_mechanical_plastic_nonlocal.f90 | 9 ++++--- 7 files changed, 62 insertions(+), 43 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 72ae2231a..0efe2b9af 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -536,13 +536,15 @@ function damage_nonlocal_getDiffusion(ip,el) damage_nonlocal_getDiffusion integer :: & homog, & - grain + grain, & + ce homog = material_homogenizationAt(el) damage_nonlocal_getDiffusion = 0.0_pReal + ce = (el-1)*discretization_nIPs + ip do grain = 1, homogenization_Nconstituents(homog) damage_nonlocal_getDiffusion = damage_nonlocal_getDiffusion + & - crystallite_push33ToRef(grain,ip,el,lattice_D(1:3,1:3,material_phaseAt(grain,el))) + crystallite_push33ToRef(grain,ce,lattice_D(1:3,1:3,material_phaseAt2(grain,ce))) enddo damage_nonlocal_getDiffusion = & diff --git a/src/homogenization_mechanical.f90 b/src/homogenization_mechanical.f90 index cd9eafdb2..74f3e475b 100644 --- a/src/homogenization_mechanical.f90 +++ b/src/homogenization_mechanical.f90 @@ -153,13 +153,13 @@ module subroutine mechanical_homogenize(dt,ip,el) chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) case (HOMOGENIZATION_NONE_ID) chosenHomogenization - homogenization_P(1:3,1:3,ce) = phase_mechanical_getP(1,ip,el) + homogenization_P(1:3,1:3,ce) = phase_mechanical_getP(1,ce) homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = phase_mechanical_dPdF(dt,1,ip,el) case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ip,el) - Ps(:,:,co) = phase_mechanical_getP(co,ip,el) + Ps(:,:,co) = phase_mechanical_getP(co,ce) enddo call mechanical_isostrain_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & @@ -170,7 +170,7 @@ module subroutine mechanical_homogenize(dt,ip,el) case (HOMOGENIZATION_RGC_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ip,el) - Ps(:,:,co) = phase_mechanical_getP(co,ip,el) + Ps(:,:,co) = phase_mechanical_getP(co,ce) enddo call mechanical_RGC_averageStressAndItsTangent(& homogenization_P(1:3,1:3,ce), & @@ -208,8 +208,8 @@ module function mechanical_updateState(subdt,subF,ce,ip,el) result(doneAndHappy) if (homogenization_type(material_homogenizationAt2(ce)) == HOMOGENIZATION_RGC_ID) then do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(subdt,co,ip,el) - Fs(:,:,co) = phase_mechanical_getF(co,ip,el) - Ps(:,:,co) = phase_mechanical_getP(co,ip,el) + Fs(:,:,co) = phase_mechanical_getF(co,ce) + Ps(:,:,co) = phase_mechanical_getP(co,ce) enddo doneAndHappy = mechanical_RGC_updateState(Ps,Fs,subF,subdt,dPdFs,ce) else diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index 67027f52a..a02f798cd 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -107,16 +107,17 @@ module function thermal_conduction_getConductivity(ip,el) result(K) real(pReal), dimension(3,3) :: K integer :: & - co - + co, & + ce K = 0.0_pReal - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - K = K + crystallite_push33ToRef(co,ip,el,lattice_K(:,:,material_phaseAt(co,el))) + ce = (el-1)*discretization_nIPs + ip + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) + K = K + crystallite_push33ToRef(co,ce,lattice_K(:,:,material_phaseAt2(co,ce))) enddo - K = K / real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) + K = K / real(homogenization_Nconstituents(material_homogenizationAt2(ce)),pReal) end function thermal_conduction_getConductivity diff --git a/src/material.f90 b/src/material.f90 index 3656f0f0a..c7d24b6f0 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -39,9 +39,6 @@ module material integer, dimension(:,:,:), allocatable, public, protected :: & ! (constituent,IP,elem) material_phaseMemberAt !< position of the element within its phase instance - type(Rotation), dimension(:,:,:), allocatable, public, protected :: & - material_orientation0 !< initial orientation of each grain,IP,element - public :: & material_init @@ -125,8 +122,6 @@ subroutine material_parseMaterial allocate(material_phaseAt2(homogenization_maxNconstituents,discretization_nIPs*discretization_Nelems),source=0) allocate(material_phaseMemberAt2(homogenization_maxNconstituents,discretization_nIPs*discretization_Nelems),source=0) - allocate(material_orientation0(homogenization_maxNconstituents,discretization_nIPs,discretization_Nelems)) - do el = 1, discretization_Nelems material => materials%get(discretization_materialAt(el)) constituents => material%get('constituents') @@ -135,7 +130,7 @@ subroutine material_parseMaterial do ip = 1, discretization_nIPs ce = (el-1)*discretization_nIPs + ip counterHomogenization(material_homogenizationAt(el)) = counterHomogenization(material_homogenizationAt(el)) + 1 - material_homogenizationMemberAt(ip,el) = counterHomogenization(material_homogenizationAt(el)) + material_homogenizationMemberAt(ip,el) = counterHomogenization(material_homogenizationAt(el)) material_homogenizationAt2(ce) = material_homogenizationAt(el) material_homogenizationMemberAt2(ce) = material_homogenizationMemberAt(ip,el) enddo @@ -153,7 +148,6 @@ subroutine material_parseMaterial material_phaseAt2(co,ce) = material_phaseAt(co,el) material_phaseMemberAt2(co,ce) = material_phaseMemberAt(co,ip,el) - call material_orientation0(co,ip,el)%fromQuaternion(constituent%get_asFloats('O',requiredSize=4)) ! should be done in crystallite enddo enddo diff --git a/src/phase.f90 b/src/phase.f90 index c5de6d658..6bea38161 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -19,6 +19,9 @@ module phase implicit none private + type(Rotation), dimension(:,:,:), allocatable, protected :: & + material_orientation0 !< initial orientation of each grain,IP,element + type(rotation), dimension(:,:,:), allocatable :: & crystallite_orientation !< current orientation @@ -77,8 +80,8 @@ module phase interface ! == cleaned:begin ================================================================================= - module subroutine mechanical_init(phases) - class(tNode), pointer :: phases + module subroutine mechanical_init(materials,phases) + class(tNode), pointer :: materials,phases end subroutine mechanical_init module subroutine damage_init @@ -147,8 +150,8 @@ module phase real(pReal), dimension(3,3) :: L_p end function mechanical_L_p - module function phase_mechanical_getF(co,ip,el) result(F) - integer, intent(in) :: co, ip, el + module function phase_mechanical_getF(co,ce) result(F) + integer, intent(in) :: co, ce real(pReal), dimension(3,3) :: F end function phase_mechanical_getF @@ -157,8 +160,8 @@ module phase real(pReal), dimension(3,3) :: F_e end function mechanical_F_e - module function phase_mechanical_getP(co,ip,el) result(P) - integer, intent(in) :: co, ip, el + module function phase_mechanical_getP(co,ce) result(P) + integer, intent(in) :: co, ce real(pReal), dimension(3,3) :: P end function phase_mechanical_getP @@ -342,6 +345,7 @@ subroutine phase_init so !< counter in source loop class (tNode), pointer :: & debug_constitutive, & + materials, & phases @@ -356,9 +360,10 @@ subroutine phase_init debugConstitutive%grain = config_debug%get_asInt('grain',defaultVal = 1) + materials => config_material%get('material') phases => config_material%get('phase') - call mechanical_init(phases) + call mechanical_init(materials,phases) call damage_init call thermal_init(phases) @@ -624,19 +629,20 @@ end subroutine crystallite_orientations !-------------------------------------------------------------------------------------------------- !> @brief Map 2nd order tensor to reference config !-------------------------------------------------------------------------------------------------- -function crystallite_push33ToRef(co,ip,el, tensor33) +function crystallite_push33ToRef(co,ce, tensor33) real(pReal), dimension(3,3), intent(in) :: tensor33 integer, intent(in):: & - el, & - ip, & - co + co, & + ce real(pReal), dimension(3,3) :: crystallite_push33ToRef real(pReal), dimension(3,3) :: T + integer :: ph, me - - T = matmul(material_orientation0(co,ip,el)%asMatrix(),transpose(math_inv33(phase_mechanical_getF(co,ip,el)))) ! ToDo: initial orientation correct? + ph = material_phaseAt2(co,ce) + me = material_phaseMemberAt2(co,ce) + T = matmul(material_orientation0(co,ph,me)%asMatrix(),transpose(math_inv33(phase_mechanical_getF(co,ce)))) ! ToDo: initial orientation correct? crystallite_push33ToRef = matmul(transpose(T),matmul(tensor33,T)) diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index 24425bf0a..383bf07a8 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -177,21 +177,26 @@ contains !> @brief Initialize mechanical field related constitutive models !> @details Initialize elasticity, plasticity and stiffness degradation models. !-------------------------------------------------------------------------------------------------- -module subroutine mechanical_init(phases) +module subroutine mechanical_init(materials,phases) class(tNode), pointer :: & + materials, & phases integer :: & el, & ip, & co, & + ce, & ph, & me, & stiffDegradationCtr, & Nconstituents class(tNode), pointer :: & num_crystallite, & + material, & + constituents, & + constituent, & phase, & mech, & elastic, & @@ -221,6 +226,8 @@ module subroutine mechanical_init(phases) allocate(phase_mechanical_P(phases%length)) allocate(phase_mechanical_S0(phases%length)) + allocate(material_orientation0(homogenization_maxNconstituents,phases%length,maxval(material_phaseMemberAt))) + do ph = 1, phases%length Nconstituents = count(material_phaseAt == ph) * discretization_nIPs @@ -271,14 +278,20 @@ module subroutine mechanical_init(phases) enddo endif + !$OMP PARALLEL DO PRIVATE(ph,me) do el = 1, size(material_phaseMemberAt,3); do ip = 1, size(material_phaseMemberAt,2) do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + material => materials%get(discretization_materialAt(el)) + constituents => material%get('constituents') + constituent => constituents%get(co) ph = material_phaseAt(co,el) me = material_phaseMemberAt(co,ip,el) - phase_mechanical_Fp0(ph)%data(1:3,1:3,me) = material_orientation0(co,ip,el)%asMatrix() ! Fp reflects initial orientation (see 10.1016/j.actamat.2006.01.005) + call material_orientation0(co,ph,me)%fromQuaternion(constituent%get_asFloats('O',requiredSize=4)) + + phase_mechanical_Fp0(ph)%data(1:3,1:3,me) = material_orientation0(co,ph,me)%asMatrix() ! Fp reflects initial orientation (see 10.1016/j.actamat.2006.01.005) phase_mechanical_Fp0(ph)%data(1:3,1:3,me) = phase_mechanical_Fp0(ph)%data(1:3,1:3,me) & / math_det33(phase_mechanical_Fp0(ph)%data(1:3,1:3,me))**(1.0_pReal/3.0_pReal) phase_mechanical_Fi0(ph)%data(1:3,1:3,me) = math_I3 @@ -1440,13 +1453,13 @@ end function mechanical_L_p !---------------------------------------------------------------------------------------------- !< @brief Get deformation gradient (for use by homogenization) !---------------------------------------------------------------------------------------------- -module function phase_mechanical_getF(co,ip,el) result(F) +module function phase_mechanical_getF(co,ce) result(F) - integer, intent(in) :: co, ip, el + integer, intent(in) :: co, ce real(pReal), dimension(3,3) :: F - F = phase_mechanical_F(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + F = phase_mechanical_F(material_phaseAt2(co,ce))%data(1:3,1:3,material_phaseMemberAt2(co,ce)) end function phase_mechanical_getF @@ -1469,13 +1482,13 @@ end function mechanical_F_e !---------------------------------------------------------------------------------------------- !< @brief Get second Piola-Kichhoff stress (for use by homogenization) !---------------------------------------------------------------------------------------------- -module function phase_mechanical_getP(co,ip,el) result(P) +module function phase_mechanical_getP(co,ce) result(P) - integer, intent(in) :: co, ip, el + integer, intent(in) :: co, ce real(pReal), dimension(3,3) :: P - P = phase_mechanical_P(material_phaseAt(co,el))%data(1:3,1:3,material_phaseMemberAt(co,ip,el)) + P = phase_mechanical_P(material_phaseAt2(co,ce))%data(1:3,1:3,material_phaseMemberAt2(co,ce)) end function phase_mechanical_getP diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index fbfcfa5af..601618425 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -1403,8 +1403,10 @@ module subroutine plastic_nonlocal_updateCompatibility(orientation,ph,i,e) integer :: & n, & ! neighbor index + me, & neighbor_e, & ! element index of my neighbor neighbor_i, & ! integration point index of my neighbor + neighbor_me, & neighbor_phase, & ns, & ! number of active slip systems s1, & ! slip system index (me) @@ -1422,6 +1424,7 @@ module subroutine plastic_nonlocal_updateCompatibility(orientation,ph,i,e) associate(prm => param(ph)) ns = prm%sum_N_sl + me = material_phaseMemberAt(1,i,e) !*** start out fully compatible my_compatibility = 0.0_pReal forall(s1 = 1:ns) my_compatibility(:,s1,s1,:) = 1.0_pReal @@ -1429,7 +1432,7 @@ module subroutine plastic_nonlocal_updateCompatibility(orientation,ph,i,e) neighbors: do n = 1,nIPneighbors neighbor_e = IPneighborhood(1,n,i,e) neighbor_i = IPneighborhood(2,n,i,e) - + neighbor_me = material_phaseMemberAt(1,neighbor_i,neighbor_e) neighbor_phase = material_phaseAt(1,neighbor_e) if (neighbor_e <= 0 .or. neighbor_i <= 0) then @@ -1447,8 +1450,8 @@ module subroutine plastic_nonlocal_updateCompatibility(orientation,ph,i,e) elseif (prm%chi_GB >= 0.0_pReal) then !* GRAIN BOUNDARY ! !* fixed transmissivity for adjacent ips with different texture (only if explicitly given in material.config) - if (any(dNeq(material_orientation0(1,i,e)%asQuaternion(), & - material_orientation0(1,neighbor_i,neighbor_e)%asQuaternion())) .and. & + if (any(dNeq(material_orientation0(1,ph,me)%asQuaternion(), & + material_orientation0(1,neighbor_phase,neighbor_me)%asQuaternion())) .and. & (.not. phase_localPlasticity(neighbor_phase))) & forall(s1 = 1:ns) my_compatibility(:,s1,s1,n) = sqrt(prm%chi_GB) else From d3726a08b15bce757f8207eb17490813b577c71f Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 23 Feb 2021 04:18:28 +0100 Subject: [PATCH 286/352] [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 287/352] 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 288/352] [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 286f59ed8c5dbd904586c7a6d5b3019878d03382 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 23 Feb 2021 10:47:04 +0100 Subject: [PATCH 289/352] fix for OpenMP --- src/phase.f90 | 2 +- src/phase_mechanical.f90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index 6bea38161..281f47de7 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -19,7 +19,7 @@ module phase implicit none private - type(Rotation), dimension(:,:,:), allocatable, protected :: & + type(Rotation), dimension(:,:,:), allocatable :: & material_orientation0 !< initial orientation of each grain,IP,element type(rotation), dimension(:,:,:), allocatable :: & diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index 383bf07a8..61782bab2 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -226,7 +226,7 @@ module subroutine mechanical_init(materials,phases) allocate(phase_mechanical_P(phases%length)) allocate(phase_mechanical_S0(phases%length)) - allocate(material_orientation0(homogenization_maxNconstituents,phases%length,maxval(material_phaseMemberAt))) + allocate(material_orientation0(homogenization_maxNconstituents,phases%length,maxVal(material_phaseMemberAt))) do ph = 1, phases%length Nconstituents = count(material_phaseAt == ph) * discretization_nIPs @@ -279,7 +279,7 @@ module subroutine mechanical_init(materials,phases) endif - !$OMP PARALLEL DO PRIVATE(ph,me) + !$OMP PARALLEL DO PRIVATE(ph,me,material,constituents,constituent) do el = 1, size(material_phaseMemberAt,3); do ip = 1, size(material_phaseMemberAt,2) do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) material => materials%get(discretization_materialAt(el)) From 89858543faf273d496e1f9e28bbc85ad219c6e3e Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 23 Feb 2021 11:44:39 +0100 Subject: [PATCH 290/352] more cleaning; use 'ce', 'ph', 'me' wherever applicable hide ip,el --- src/homogenization.f90 | 8 +++---- src/homogenization_mechanical.f90 | 14 +++++------- src/phase.f90 | 5 ++-- src/phase_mechanical.f90 | 38 ++++++++++++++----------------- 4 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 496963ce7..eb008042d 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -126,15 +126,13 @@ module homogenization integer, intent(in) :: h end subroutine mechanical_results - module function mechanical_updateState(subdt,subF,ce,ip,el) result(doneAndHappy) + module function mechanical_updateState(subdt,subF,ce) result(doneAndHappy) real(pReal), intent(in) :: & subdt !< current time step real(pReal), intent(in), dimension(3,3) :: & subF integer, intent(in) :: & - ce, & !< cell - ip, & - el + ce !< cell logical, dimension(2) :: doneAndHappy end function mechanical_updateState @@ -327,7 +325,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if (.not. converged) then doneAndHappy = [.true.,.false.] else - doneAndHappy = mechanical_updateState(dt,homogenization_F(1:3,1:3,ce),ce,ip,el) + doneAndHappy = mechanical_updateState(dt,homogenization_F(1:3,1:3,ce),ce) converged = all(doneAndHappy) endif endif diff --git a/src/homogenization_mechanical.f90 b/src/homogenization_mechanical.f90 index 74f3e475b..fed2f2c65 100644 --- a/src/homogenization_mechanical.f90 +++ b/src/homogenization_mechanical.f90 @@ -154,11 +154,11 @@ module subroutine mechanical_homogenize(dt,ip,el) case (HOMOGENIZATION_NONE_ID) chosenHomogenization homogenization_P(1:3,1:3,ce) = phase_mechanical_getP(1,ce) - homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = phase_mechanical_dPdF(dt,1,ip,el) + homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = phase_mechanical_dPdF(dt,1,ce) case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ip,el) + dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ce) Ps(:,:,co) = phase_mechanical_getP(co,ce) enddo call mechanical_isostrain_averageStressAndItsTangent(& @@ -169,7 +169,7 @@ module subroutine mechanical_homogenize(dt,ip,el) case (HOMOGENIZATION_RGC_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ip,el) + dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ce) Ps(:,:,co) = phase_mechanical_getP(co,ce) enddo call mechanical_RGC_averageStressAndItsTangent(& @@ -187,16 +187,14 @@ end subroutine mechanical_homogenize !> @brief update the internal state of the homogenization scheme and tell whether "done" and !> "happy" with result !-------------------------------------------------------------------------------------------------- -module function mechanical_updateState(subdt,subF,ce,ip,el) result(doneAndHappy) +module function mechanical_updateState(subdt,subF,ce) result(doneAndHappy) real(pReal), intent(in) :: & subdt !< current time step real(pReal), intent(in), dimension(3,3) :: & subF integer, intent(in) :: & - ce, & - ip, & - el + ce logical, dimension(2) :: doneAndHappy integer :: co @@ -207,7 +205,7 @@ module function mechanical_updateState(subdt,subF,ce,ip,el) result(doneAndHappy) if (homogenization_type(material_homogenizationAt2(ce)) == HOMOGENIZATION_RGC_ID) then do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) - dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(subdt,co,ip,el) + dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(subdt,co,ce) Fs(:,:,co) = phase_mechanical_getF(co,ce) Ps(:,:,co) = phase_mechanical_getP(co,ce) enddo diff --git a/src/phase.f90 b/src/phase.f90 index 281f47de7..9ab5c386a 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -120,12 +120,11 @@ module phase end subroutine mechanical_restore - module function phase_mechanical_dPdF(dt,co,ip,el) result(dPdF) + module function phase_mechanical_dPdF(dt,co,ce) result(dPdF) real(pReal), intent(in) :: dt integer, intent(in) :: & co, & !< counter in constituent loop - ip, & !< counter in integration point loop - el !< counter in element loop + ce real(pReal), dimension(3,3,3,3) :: dPdF end function phase_mechanical_dPdF diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index 61782bab2..be14c57e6 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -355,12 +355,11 @@ end subroutine mechanical_init !> the elastic and intermediate deformation gradients using Hooke's law !-------------------------------------------------------------------------------------------------- subroutine phase_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & - Fe, Fi, co, ip, el) + Fe, Fi, ph, me) integer, intent(in) :: & - co, & !< component-ID of integration point - ip, & !< integration point - el !< element + ph, & + me real(pReal), intent(in), dimension(3,3) :: & Fe, & !< elastic deformation gradient Fi !< intermediate deformation gradient @@ -373,17 +372,15 @@ subroutine phase_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & real(pReal), dimension(3,3) :: E real(pReal), dimension(3,3,3,3) :: C integer :: & - ho, & !< homogenization - d, & !< counter in degradation loop - i, j, ph, me + d, & !< counter in degradation loop + i, j - ho = material_homogenizationAt(el) - C = math_66toSym3333(phase_homogenizedC(material_phaseAt(co,el),material_phaseMemberAt(co,ip,el))) + C = math_66toSym3333(phase_homogenizedC(ph,me)) - DegradationLoop: do d = 1, phase_NstiffnessDegradations(material_phaseAt(co,el)) - degradationType: select case(phase_stiffnessDegradation(d,material_phaseAt(co,el))) + DegradationLoop: do d = 1, phase_NstiffnessDegradations(ph) + degradationType: select case(phase_stiffnessDegradation(d,ph)) case (STIFFNESS_DEGRADATION_damage_ID) degradationType - C = C * phase_damage_get_phi(co,ip,el)**2 + C = C * damage_phi(ph,me)**2 end select degradationType enddo DegradationLoop @@ -541,7 +538,7 @@ function integrateStress(F,subFp0,subFi0,Delta_t,co,ip,el) result(broken) B = math_I3 - Delta_t*Lpguess Fe = matmul(matmul(A,B), invFi_new) call phase_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & - Fe, Fi_new, co, ip, el) + Fe, Fi_new, ph, me) call plastic_LpAndItsTangents(Lp_constitutive, dLp_dS, dLp_dFi, & S, Fi_new, ph,me) @@ -1263,13 +1260,12 @@ end subroutine mechanical_restore !-------------------------------------------------------------------------------------------------- !> @brief Calculate tangent (dPdF). !-------------------------------------------------------------------------------------------------- -module function phase_mechanical_dPdF(dt,co,ip,el) result(dPdF) +module function phase_mechanical_dPdF(dt,co,ce) result(dPdF) real(pReal), intent(in) :: dt integer, intent(in) :: & co, & !< counter in constituent loop - ip, & !< counter in integration point loop - el !< counter in element loop + ce real(pReal), dimension(3,3,3,3) :: dPdF integer :: & @@ -1294,12 +1290,12 @@ module function phase_mechanical_dPdF(dt,co,ip,el) result(dPdF) logical :: error - ph = material_phaseAt(co,el) - me = material_phaseMemberAt(co,ip,el) + ph = material_phaseAt2(co,ce) + me = material_phaseMemberAt2(co,ce) call phase_hooke_SandItsTangents(devNull,dSdFe,dSdFi, & phase_mechanical_Fe(ph)%data(1:3,1:3,me), & - phase_mechanical_Fi(ph)%data(1:3,1:3,me),co,ip,el) + phase_mechanical_Fi(ph)%data(1:3,1:3,me),ph,me) call phase_LiAndItsTangents(devNull,dLidS,dLidFi, & phase_mechanical_S(ph)%data(1:3,1:3,me), & phase_mechanical_Fi(ph)%data(1:3,1:3,me), & @@ -1324,7 +1320,7 @@ module function phase_mechanical_dPdF(dt,co,ip,el) result(dPdF) enddo; enddo call math_invert(temp_99,error,math_3333to99(lhs_3333)) if (error) then - call IO_warning(warning_ID=600,el=el,ip=ip,g=co, & + call IO_warning(warning_ID=600, & ext_msg='inversion error in analytic tangent calculation') dFidS = 0.0_pReal else @@ -1354,7 +1350,7 @@ module function phase_mechanical_dPdF(dt,co,ip,el) result(dPdF) call math_invert(temp_99,error,math_eye(9)+math_3333to99(lhs_3333)) if (error) then - call IO_warning(warning_ID=600,el=el,ip=ip,g=co, & + call IO_warning(warning_ID=600, & ext_msg='inversion error in analytic tangent calculation') dSdF = rhs_3333 else From d8112cc2e1d3765659bb9e282cf9a4e99efcc167 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 23 Feb 2021 13:17:51 +0100 Subject: [PATCH 291/352] storing by instance just complicates the code --- src/homogenization.f90 | 21 ++---- src/homogenization_damage.f90 | 8 +-- src/homogenization_mechanical.f90 | 24 +++---- src/homogenization_mechanical_RGC.f90 | 80 ++++++++++----------- src/homogenization_mechanical_isostrain.f90 | 16 ++--- 5 files changed, 66 insertions(+), 83 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index eb008042d..49210806b 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -35,10 +35,6 @@ module homogenization homogState, & damageState_h - integer, dimension(:), allocatable, public, protected :: & - homogenization_typeInstance, & !< instance of particular type of each homogenization - thermal_typeInstance, & !< instance of particular type of each thermal transport - damage_typeInstance !< instance of particular type of each nonlocal damage real(pReal), dimension(:), allocatable, public, protected :: & thermal_initialT @@ -121,9 +117,9 @@ module homogenization el !< element number end subroutine mechanical_homogenize - module subroutine mechanical_results(group_base,h) + module subroutine mechanical_results(group_base,ho) character(len=*), intent(in) :: group_base - integer, intent(in) :: h + integer, intent(in) :: ho end subroutine mechanical_results module function mechanical_updateState(subdt,subF,ce) result(doneAndHappy) @@ -207,9 +203,9 @@ module homogenization end subroutine damage_nonlocal_putNonLocalDamage - module subroutine damage_nonlocal_results(homog,group) + module subroutine damage_nonlocal_results(ho,group) - integer, intent(in) :: homog + integer, intent(in) :: ho character(len=*), intent(in) :: group end subroutine damage_nonlocal_results @@ -571,9 +567,6 @@ subroutine material_parseHomogenization allocate(homogenization_type(size(material_name_homogenization)), source=HOMOGENIZATION_undefined_ID) allocate(thermal_type(size(material_name_homogenization)), source=THERMAL_isothermal_ID) allocate(damage_type (size(material_name_homogenization)), source=DAMAGE_none_ID) - allocate(homogenization_typeInstance(size(material_name_homogenization)), source=0) - allocate(thermal_typeInstance(size(material_name_homogenization)), source=0) - allocate(damage_typeInstance(size(material_name_homogenization)), source=0) allocate(thermal_initialT(size(material_name_homogenization)), source=300.0_pReal) do h=1, size(material_name_homogenization) @@ -590,7 +583,6 @@ subroutine material_parseHomogenization call IO_error(500,ext_msg=homogMech%get_asString('type')) end select - homogenization_typeInstance(h) = count(homogenization_type==homogenization_type(h)) if(homog%contains('thermal')) then homogThermal => homog%get('thermal') @@ -619,11 +611,6 @@ subroutine material_parseHomogenization endif enddo - do h=1, size(material_name_homogenization) - homogenization_typeInstance(h) = count(homogenization_type(1:h) == homogenization_type(h)) - thermal_typeInstance(h) = count(thermal_type (1:h) == thermal_type (h)) - damage_typeInstance(h) = count(damage_type (1:h) == damage_type (h)) - enddo end subroutine material_parseHomogenization diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index 502174309..128725839 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -152,18 +152,18 @@ end subroutine damage_nonlocal_putNonLocalDamage !-------------------------------------------------------------------------------------------------- !> @brief writes results to HDF5 output file !-------------------------------------------------------------------------------------------------- -module subroutine damage_nonlocal_results(homog,group) +module subroutine damage_nonlocal_results(ho,group) - integer, intent(in) :: homog + integer, intent(in) :: ho character(len=*), intent(in) :: group integer :: o - associate(prm => param(damage_typeInstance(homog))) + associate(prm => param(ho)) outputsLoop: do o = 1,size(prm%output) select case(prm%output(o)) case ('phi') - call results_writeDataset(group,damagestate_h(homog)%state(1,:),prm%output(o),& + call results_writeDataset(group,damagestate_h(ho)%state(1,:),prm%output(o),& 'damage indicator','-') end select enddo outputsLoop diff --git a/src/homogenization_mechanical.f90 b/src/homogenization_mechanical.f90 index fed2f2c65..e113fc9e1 100644 --- a/src/homogenization_mechanical.f90 +++ b/src/homogenization_mechanical.f90 @@ -32,22 +32,22 @@ submodule(homogenization) mechanical end subroutine mechanical_RGC_partitionDeformation - module subroutine mechanical_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) + module subroutine mechanical_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,ho) real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point real(pReal), dimension (:,:,:), intent(in) :: P !< partitioned stresses real(pReal), dimension (:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses - integer, intent(in) :: instance + integer, intent(in) :: ho end subroutine mechanical_isostrain_averageStressAndItsTangent - module subroutine mechanical_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) + module subroutine mechanical_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,ho) real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point real(pReal), dimension (:,:,:), intent(in) :: P !< partitioned stresses real(pReal), dimension (:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses - integer, intent(in) :: instance + integer, intent(in) :: ho end subroutine mechanical_RGC_averageStressAndItsTangent @@ -64,8 +64,8 @@ submodule(homogenization) mechanical end function mechanical_RGC_updateState - module subroutine mechanical_RGC_results(instance,group) - integer, intent(in) :: instance !< homogenization instance + module subroutine mechanical_RGC_results(ho,group) + integer, intent(in) :: ho !< homogenization type character(len=*), intent(in) :: group !< group name in HDF5 file end subroutine mechanical_RGC_results @@ -165,7 +165,7 @@ module subroutine mechanical_homogenize(dt,ip,el) homogenization_P(1:3,1:3,ce), & homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& Ps,dPdFs, & - homogenization_typeInstance(material_homogenizationAt(el))) + material_homogenizationAt(el)) case (HOMOGENIZATION_RGC_ID) chosenHomogenization do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) @@ -176,7 +176,7 @@ module subroutine mechanical_homogenize(dt,ip,el) homogenization_P(1:3,1:3,ce), & homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& Ps,dPdFs, & - homogenization_typeInstance(material_homogenizationAt(el))) + material_homogenizationAt(el)) end select chosenHomogenization @@ -220,20 +220,20 @@ end function mechanical_updateState !-------------------------------------------------------------------------------------------------- !> @brief Write results to file. !-------------------------------------------------------------------------------------------------- -module subroutine mechanical_results(group_base,h) +module subroutine mechanical_results(group_base,ho) character(len=*), intent(in) :: group_base - integer, intent(in) :: h + integer, intent(in) :: ho character(len=:), allocatable :: group group = trim(group_base)//'/mech' call results_closeGroup(results_addGroup(group)) - select case(homogenization_type(h)) + select case(homogenization_type(ho)) case(HOMOGENIZATION_rgc_ID) - call mechanical_RGC_results(homogenization_typeInstance(h),group) + call mechanical_RGC_results(ho,group) end select diff --git a/src/homogenization_mechanical_RGC.f90 b/src/homogenization_mechanical_RGC.f90 index 4800369ee..1f593b074 100644 --- a/src/homogenization_mechanical_RGC.f90 +++ b/src/homogenization_mechanical_RGC.f90 @@ -77,7 +77,6 @@ module subroutine mechanical_RGC_init(num_homogMech) num_homogMech !< pointer to mechanical homogenization numerics data integer :: & - Ninstances, & h, & Nmaterialpoints, & sizeState, nIntFaceTot @@ -90,8 +89,7 @@ module subroutine mechanical_RGC_init(num_homogMech) print'(/,a)', ' <<<+- homogenization:mechanical:RGC init -+>>>' - Ninstances = count(homogenization_type == HOMOGENIZATION_RGC_ID) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) + print'(a,i2)', ' # instances: ',count(homogenization_type == HOMOGENIZATION_RGC_ID); flush(IO_STDOUT) print*, 'Tjahjanto et al., International Journal of Material Forming 2(1):939–942, 2009' print*, 'https://doi.org/10.1007/s12289-009-0619-1'//IO_EOL @@ -101,10 +99,11 @@ module subroutine mechanical_RGC_init(num_homogMech) - allocate(param(Ninstances)) - allocate(state(Ninstances)) - allocate(state0(Ninstances)) - allocate(dependentState(Ninstances)) + material_homogenization => config_material%get('homogenization') + allocate(param(material_homogenization%length)) + allocate(state(material_homogenization%length)) + allocate(state0(material_homogenization%length)) + allocate(dependentState(material_homogenization%length)) num_RGC => num_homogMech%get('RGC',defaultVal=emptyDict) @@ -137,15 +136,14 @@ module subroutine mechanical_RGC_init(num_homogMech) if (num%volDiscrPow <= 0.0_pReal) call IO_error(301,ext_msg='volDiscrPw_RGC') - material_homogenization => config_material%get('homogenization') do h = 1, size(homogenization_type) if (homogenization_type(h) /= HOMOGENIZATION_RGC_ID) cycle homog => material_homogenization%get(h) homogMech => homog%get('mechanics') - associate(prm => param(homogenization_typeInstance(h)), & - stt => state(homogenization_typeInstance(h)), & - st0 => state0(homogenization_typeInstance(h)), & - dst => dependentState(homogenization_typeInstance(h))) + associate(prm => param(h), & + stt => state(h), & + st0 => state0(h), & + dst => dependentState(h)) #if defined (__GFORTRAN__) prm%output = output_asStrings(homogMech) @@ -183,7 +181,7 @@ module subroutine mechanical_RGC_init(num_homogMech) !-------------------------------------------------------------------------------------------------- ! assigning cluster orientations - dependentState(homogenization_typeInstance(h))%orientation = spread(eu2om(prm%a_g*inRad),3,Nmaterialpoints) + dependentState(h)%orientation = spread(eu2om(prm%a_g*inRad),3,Nmaterialpoints) !dst%orientation = spread(eu2om(prm%a_g*inRad),3,Nmaterialpoints) ifort version 18.0.1 crashes (for whatever reason) end associate @@ -209,7 +207,7 @@ module subroutine mechanical_RGC_partitionDeformation(F,avgF,ce) integer, dimension(3) :: iGrain3 integer :: iGrain,iFace,i,j,me - associate(prm => param(homogenization_typeInstance(material_homogenizationAt2(ce)))) + associate(prm => param(material_homogenizationAt2(ce))) me = material_homogenizationMemberAt2(ce) !-------------------------------------------------------------------------------------------------- @@ -249,7 +247,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa integer, dimension(4) :: intFaceN,intFaceP,faceID integer, dimension(3) :: nGDim,iGr3N,iGr3P - integer :: instance,iNum,i,j,nIntFaceTot,iGrN,iGrP,iMun,iFace,k,l,ipert,iGrain,nGrain, me + integer :: ho,iNum,i,j,nIntFaceTot,iGrN,iGrP,iMun,iFace,k,l,ipert,iGrain,nGrain, me real(pReal), dimension(3,3,size(P,3)) :: R,pF,pR,D,pD real(pReal), dimension(3,size(P,3)) :: NN,devNull real(pReal), dimension(3) :: normP,normN,mornP,mornN @@ -263,10 +261,10 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa return endif zeroTimeStep - instance = homogenization_typeInstance(material_homogenizationAt2(ce)) + ho = material_homogenizationAt2(ce) me = material_homogenizationMemberAt2(ce) - associate(stt => state(instance), st0 => state0(instance), dst => dependentState(instance), prm => param(instance)) + associate(stt => state(ho), st0 => state0(ho), dst => dependentState(ho), prm => param(ho)) !-------------------------------------------------------------------------------------------------- ! get the dimension of the cluster (grains and interfaces) @@ -294,12 +292,12 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa !------------------------------------------------------------------------------------------------ ! computing the residual stress from the balance of traction at all (interior) interfaces do iNum = 1,nIntFaceTot - faceID = interface1to4(iNum,param(instance)%N_constituents) ! identifying the interface ID in local coordinate system (4-dimensional index) + faceID = interface1to4(iNum,param(ho)%N_constituents) ! identifying the interface ID in local coordinate system (4-dimensional index) !-------------------------------------------------------------------------------------------------- ! identify the left/bottom/back grain (-|N) iGr3N = faceID(2:4) ! identifying the grain ID in local coordinate system (3-dimensional index) - iGrN = grain3to1(iGr3N,param(instance)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) + iGrN = grain3to1(iGr3N,param(ho)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceN = getInterface(2*faceID(1),iGr3N) normN = interfaceNormal(intFaceN,ce,me) @@ -307,7 +305,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa ! identify the right/up/front grain (+|P) iGr3P = iGr3N iGr3P(faceID(1)) = iGr3N(faceID(1))+1 ! identifying the grain ID in local coordinate system (3-dimensional index) - iGrP = grain3to1(iGr3P,param(instance)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) + iGrP = grain3to1(iGr3P,param(ho)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceP = getInterface(2*faceID(1)-1,iGr3P) normP = interfaceNormal(intFaceP,ce,me) @@ -358,18 +356,18 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa ! ... of the constitutive stress tangent, assembled from dPdF or material constitutive model "smatrix" allocate(smatrix(3*nIntFaceTot,3*nIntFaceTot), source=0.0_pReal) do iNum = 1,nIntFaceTot - faceID = interface1to4(iNum,param(instance)%N_constituents) ! assembling of local dPdF into global Jacobian matrix + faceID = interface1to4(iNum,param(ho)%N_constituents) ! assembling of local dPdF into global Jacobian matrix !-------------------------------------------------------------------------------------------------- ! identify the left/bottom/back grain (-|N) iGr3N = faceID(2:4) ! identifying the grain ID in local coordinate sytem - iGrN = grain3to1(iGr3N,param(instance)%N_constituents) ! translate into global grain ID + iGrN = grain3to1(iGr3N,param(ho)%N_constituents) ! translate into global grain ID intFaceN = getInterface(2*faceID(1),iGr3N) ! identifying the connecting interface in local coordinate system normN = interfaceNormal(intFaceN,ce,me) do iFace = 1,6 intFaceN = getInterface(iFace,iGr3N) ! identifying all interfaces that influence relaxation of the above interface mornN = interfaceNormal(intFaceN,ce,me) - iMun = interface4to1(intFaceN,param(instance)%N_constituents) ! translate the interfaces ID into local 4-dimensional index + iMun = interface4to1(intFaceN,param(ho)%N_constituents) ! translate the interfaces ID into local 4-dimensional index if (iMun > 0) then ! get the corresponding tangent do i=1,3; do j=1,3; do k=1,3; do l=1,3 smatrix(3*(iNum-1)+i,3*(iMun-1)+j) = smatrix(3*(iNum-1)+i,3*(iMun-1)+j) & @@ -384,13 +382,13 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa ! identify the right/up/front grain (+|P) iGr3P = iGr3N iGr3P(faceID(1)) = iGr3N(faceID(1))+1 ! identifying the grain ID in local coordinate sytem - iGrP = grain3to1(iGr3P,param(instance)%N_constituents) ! translate into global grain ID + iGrP = grain3to1(iGr3P,param(ho)%N_constituents) ! translate into global grain ID intFaceP = getInterface(2*faceID(1)-1,iGr3P) ! identifying the connecting interface in local coordinate system normP = interfaceNormal(intFaceP,ce,me) do iFace = 1,6 intFaceP = getInterface(iFace,iGr3P) ! identifying all interfaces that influence relaxation of the above interface mornP = interfaceNormal(intFaceP,ce,me) - iMun = interface4to1(intFaceP,param(instance)%N_constituents) ! translate the interfaces ID into local 4-dimensional index + iMun = interface4to1(intFaceP,param(ho)%N_constituents) ! translate the interfaces ID into local 4-dimensional index if (iMun > 0) then ! get the corresponding tangent do i=1,3; do j=1,3; do k=1,3; do l=1,3 smatrix(3*(iNum-1)+i,3*(iMun-1)+j) = smatrix(3*(iNum-1)+i,3*(iMun-1)+j) & @@ -419,12 +417,12 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa ! computing the global stress residual array from the perturbed state p_resid = 0.0_pReal do iNum = 1,nIntFaceTot - faceID = interface1to4(iNum,param(instance)%N_constituents) ! identifying the interface ID in local coordinate system (4-dimensional index) + faceID = interface1to4(iNum,param(ho)%N_constituents) ! identifying the interface ID in local coordinate system (4-dimensional index) !-------------------------------------------------------------------------------------------------- ! identify the left/bottom/back grain (-|N) iGr3N = faceID(2:4) ! identify the grain ID in local coordinate system (3-dimensional index) - iGrN = grain3to1(iGr3N,param(instance)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) + iGrN = grain3to1(iGr3N,param(ho)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceN = getInterface(2*faceID(1),iGr3N) ! identify the interface ID of the grain normN = interfaceNormal(intFaceN,ce,me) @@ -432,7 +430,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa ! identify the right/up/front grain (+|P) iGr3P = iGr3N iGr3P(faceID(1)) = iGr3N(faceID(1))+1 ! identify the grain ID in local coordinate system (3-dimensional index) - iGrP = grain3to1(iGr3P,param(instance)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) + iGrP = grain3to1(iGr3P,param(ho)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceP = getInterface(2*faceID(1)-1,iGr3P) ! identify the interface ID of the grain normP = interfaceNormal(intFaceP,ce,me) @@ -509,7 +507,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa nDefToler = 1.0e-10_pReal, & b = 2.5e-10_pReal ! Length of Burgers vector - nGDim = param(instance)%N_constituents + nGDim = param(ho)%N_constituents rPen = 0.0_pReal nMis = 0.0_pReal @@ -519,7 +517,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa surfCorr = surfaceCorrection(avgF,ce,me) - associate(prm => param(homogenization_typeInstance(material_homogenizationAt2(ce)))) + associate(prm => param(material_homogenizationAt2(ce))) !----------------------------------------------------------------------------------------------- @@ -683,7 +681,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa !----------------------------------------------------------------------------------------------- ! compute the deformation gradient of individual grains due to relaxations - associate (prm => param(homogenization_typeInstance(material_homogenizationAt2(ce)))) + associate (prm => param(material_homogenizationAt2(ce))) F = 0.0_pReal do iGrain = 1,product(prm%N_constituents) @@ -708,17 +706,17 @@ end function mechanical_RGC_updateState !-------------------------------------------------------------------------------------------------- !> @brief derive average stress and stiffness from constituent quantities !-------------------------------------------------------------------------------------------------- -module subroutine mechanical_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) +module subroutine mechanical_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,ho) real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point real(pReal), dimension (:,:,:), intent(in) :: P !< partitioned stresses real(pReal), dimension (:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses - integer, intent(in) :: instance + integer, intent(in) :: ho - avgP = sum(P,3) /real(product(param(instance)%N_constituents),pReal) - dAvgPdAvgF = sum(dPdF,5)/real(product(param(instance)%N_constituents),pReal) + avgP = sum(P,3) /real(product(param(ho)%N_constituents),pReal) + dAvgPdAvgF = sum(dPdF,5)/real(product(param(ho)%N_constituents),pReal) end subroutine mechanical_RGC_averageStressAndItsTangent @@ -726,14 +724,14 @@ end subroutine mechanical_RGC_averageStressAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief writes results to HDF5 output file !-------------------------------------------------------------------------------------------------- -module subroutine mechanical_RGC_results(instance,group) +module subroutine mechanical_RGC_results(ho,group) - integer, intent(in) :: instance + integer, intent(in) :: ho character(len=*), intent(in) :: group integer :: o - associate(stt => state(instance), dst => dependentState(instance), prm => param(instance)) + associate(stt => state(ho), dst => dependentState(ho), prm => param(ho)) outputsLoop: do o = 1,size(prm%output) select case(trim(prm%output(o))) case('M') @@ -770,8 +768,8 @@ pure function relaxationVector(intFace,ce,me) !-------------------------------------------------------------------------------------------------- ! collect the interface relaxation vector from the global state array - associate (prm => param(homogenization_typeInstance(material_homogenizationAt2(ce))), & - stt => state(homogenization_typeInstance(material_homogenizationAt2(ce)))) + associate (prm => param(material_homogenizationAt2(ce)), & + stt => state(material_homogenizationAt2(ce))) iNum = interface4to1(intFace,prm%N_constituents) ! identify the position of the interface in global state array if (iNum > 0) then @@ -798,7 +796,7 @@ pure function interfaceNormal(intFace,ce,me) me integer :: nPos - associate (dst => dependentState(homogenization_typeInstance(material_homogenizationAt2(ce)))) + associate (dst => dependentState(material_homogenizationAt2(ce))) !-------------------------------------------------------------------------------------------------- ! get the normal of the interface, identified from the value of intFace(1) diff --git a/src/homogenization_mechanical_isostrain.f90 b/src/homogenization_mechanical_isostrain.f90 index b492499d8..4773e3081 100644 --- a/src/homogenization_mechanical_isostrain.f90 +++ b/src/homogenization_mechanical_isostrain.f90 @@ -29,7 +29,6 @@ contains module subroutine mechanical_isostrain_init integer :: & - Ninstances, & h, & Nmaterialpoints class(tNode), pointer :: & @@ -39,17 +38,16 @@ module subroutine mechanical_isostrain_init print'(/,a)', ' <<<+- homogenization:mechanical:isostrain init -+>>>' - Ninstances = count(homogenization_type == HOMOGENIZATION_ISOSTRAIN_ID) - print'(a,i2)', ' # instances: ',Ninstances; flush(IO_STDOUT) - - allocate(param(Ninstances)) ! one container of parameters per instance + print'(a,i2)', ' # instances: ',count(homogenization_type == HOMOGENIZATION_ISOSTRAIN_ID); flush(IO_STDOUT) material_homogenization => config_material%get('homogenization') + allocate(param(material_homogenization%length)) ! one container of parameters per homog + do h = 1, size(homogenization_type) if (homogenization_type(h) /= HOMOGENIZATION_ISOSTRAIN_ID) cycle homog => material_homogenization%get(h) homogMech => homog%get('mechanics') - associate(prm => param(homogenization_typeInstance(h))) + associate(prm => param(h)) prm%N_constituents = homogenization_Nconstituents(h) select case(homogMech%get_asString('mapping',defaultVal = 'sum')) @@ -90,16 +88,16 @@ end subroutine mechanical_isostrain_partitionDeformation !-------------------------------------------------------------------------------------------------- !> @brief derive average stress and stiffness from constituent quantities !-------------------------------------------------------------------------------------------------- -module subroutine mechanical_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,instance) +module subroutine mechanical_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,ho) real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point real(pReal), dimension (:,:,:), intent(in) :: P !< partitioned stresses real(pReal), dimension (:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses - integer, intent(in) :: instance + integer, intent(in) :: ho - associate(prm => param(instance)) + associate(prm => param(ho)) select case (prm%mapping) case (parallel_ID) From 9679c5403e91fb780268b2729a4cf536b9ddecb0 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 23 Feb 2021 15:10:34 +0100 Subject: [PATCH 292/352] continue with cell based map (solver + homog) --- src/grid/grid_damage_spectral.f90 | 42 ++++++++++++------------- src/grid/grid_thermal_spectral.f90 | 6 ++-- src/homogenization.f90 | 49 ++++++++++++------------------ src/homogenization_damage.f90 | 40 +++++++++++------------- src/homogenization_thermal.f90 | 16 ++++------ src/phase.f90 | 6 ++-- src/phase_damage.f90 | 12 +++----- 7 files changed, 73 insertions(+), 98 deletions(-) diff --git a/src/grid/grid_damage_spectral.f90 b/src/grid/grid_damage_spectral.f90 index afbae027f..8d3f913fa 100644 --- a/src/grid/grid_damage_spectral.f90 +++ b/src/grid/grid_damage_spectral.f90 @@ -160,7 +160,7 @@ function grid_damage_spectral_solution(timeinc) result(solution) real(pReal), intent(in) :: & timeinc !< increment in time for current solution - integer :: i, j, k, cell + integer :: i, j, k, ce type(tSolutionState) :: solution PetscInt :: devNull PetscReal :: phi_min, phi_max, stagNorm, solnNorm @@ -193,10 +193,10 @@ function grid_damage_spectral_solution(timeinc) result(solution) !-------------------------------------------------------------------------------------------------- ! updating damage state - cell = 0 + ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 - call damage_nonlocal_putNonLocalDamage(phi_current(i,j,k),1,cell) + ce = ce + 1 + call damage_nonlocal_putNonLocalDamage(phi_current(i,j,k),ce) enddo; enddo; enddo call VecMin(solution_vec,devNull,phi_min,ierr); CHKERRQ(ierr) @@ -216,7 +216,7 @@ end function grid_damage_spectral_solution subroutine grid_damage_spectral_forward(cutBack) logical, intent(in) :: cutBack - integer :: i, j, k, cell + integer :: i, j, k, ce DM :: dm_local PetscScalar, dimension(:,:,:), pointer :: x_scal PetscErrorCode :: ierr @@ -226,14 +226,14 @@ subroutine grid_damage_spectral_forward(cutBack) phi_stagInc = phi_lastInc !-------------------------------------------------------------------------------------------------- ! reverting damage field state - cell = 0 + ce = 0 call SNESGetDM(damage_snes,dm_local,ierr); CHKERRQ(ierr) call DMDAVecGetArrayF90(dm_local,solution_vec,x_scal,ierr); CHKERRQ(ierr) !< get the data out of PETSc to work with x_scal(xstart:xend,ystart:yend,zstart:zend) = phi_current call DMDAVecRestoreArrayF90(dm_local,solution_vec,x_scal,ierr); CHKERRQ(ierr) do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 - call damage_nonlocal_putNonLocalDamage(phi_current(i,j,k),1,cell) + ce = ce + 1 + call damage_nonlocal_putNonLocalDamage(phi_current(i,j,k),ce) enddo; enddo; enddo else phi_lastInc = phi_current @@ -258,7 +258,7 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) f_scal PetscObject :: dummy PetscErrorCode :: ierr - integer :: i, j, k, cell + integer :: i, j, k, ce real(pReal) :: phiDot, dPhiDot_dPhi, mobility phi_current = x_scal @@ -269,20 +269,20 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) call utilities_FFTscalarForward call utilities_fourierScalarGradient !< calculate gradient of damage field call utilities_FFTvectorBackward - cell = 0 + ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 - vectorField_real(1:3,i,j,k) = matmul(damage_nonlocal_getDiffusion(1,cell) - K_ref, & + ce = ce + 1 + vectorField_real(1:3,i,j,k) = matmul(damage_nonlocal_getDiffusion(ce) - K_ref, & vectorField_real(1:3,i,j,k)) enddo; enddo; enddo call utilities_FFTvectorForward call utilities_fourierVectorDivergence !< calculate damage divergence in fourier field call utilities_FFTscalarBackward - cell = 0 + ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 - call damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi_current(i,j,k), 1, cell) - mobility = damage_nonlocal_getMobility(1,cell) + ce = ce + 1 + call damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi_current(i,j,k),ce) + mobility = damage_nonlocal_getMobility(ce) scalarField_real(i,j,k) = params%timeinc*(scalarField_real(i,j,k) + phiDot) & + mobility*(phi_lastInc(i,j,k) - phi_current(i,j,k)) & + mu_ref*phi_current(i,j,k) @@ -310,15 +310,15 @@ end subroutine formResidual !-------------------------------------------------------------------------------------------------- subroutine updateReference - integer :: i,j,k,cell,ierr + integer :: i,j,k,ce,ierr - cell = 0 + ce = 0 K_ref = 0.0_pReal mu_ref = 0.0_pReal do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) - cell = cell + 1 - K_ref = K_ref + damage_nonlocal_getDiffusion(1,cell) - mu_ref = mu_ref + damage_nonlocal_getMobility(1,cell) + ce = ce + 1 + K_ref = K_ref + damage_nonlocal_getDiffusion(ce) + mu_ref = mu_ref + damage_nonlocal_getMobility(ce) enddo; enddo; enddo K_ref = K_ref*wgt call MPI_Allreduce(MPI_IN_PLACE,K_ref,9,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD,ierr) diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 866914f5b..6403ee955 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -268,7 +268,7 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) ce = ce + 1 - vectorField_real(1:3,i,j,k) = matmul(thermal_conduction_getConductivity(1,ce) - K_ref, & + vectorField_real(1:3,i,j,k) = matmul(thermal_conduction_getConductivity(ce) - K_ref, & vectorField_real(1:3,i,j,k)) enddo; enddo; enddo call utilities_FFTvectorForward @@ -277,7 +277,7 @@ subroutine formResidual(in,x_scal,f_scal,dummy,ierr) ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) ce = ce + 1 - call thermal_conduction_getSource(Tdot, 1,ce) + call thermal_conduction_getSource(Tdot,1,ce) scalarField_real(i,j,k) = params%timeinc*(scalarField_real(i,j,k) + Tdot) & + thermal_conduction_getMassDensity (ce)* & thermal_conduction_getSpecificHeat(ce)*(T_lastInc(i,j,k) - & @@ -310,7 +310,7 @@ subroutine updateReference mu_ref = 0.0_pReal do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) ce = ce + 1 - K_ref = K_ref + thermal_conduction_getConductivity(1,ce) + K_ref = K_ref + thermal_conduction_getConductivity(ce) mu_ref = mu_ref + thermal_conduction_getMassDensity(ce)* thermal_conduction_getSpecificHeat(ce) enddo; enddo; enddo K_ref = K_ref*wgt diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 49210806b..3c424585b 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -133,11 +133,9 @@ module homogenization end function mechanical_updateState - module function thermal_conduction_getConductivity(ip,el) result(K) + module function thermal_conduction_getConductivity(ce) result(K) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce real(pReal), dimension(3,3) :: K end function thermal_conduction_getConductivity @@ -167,25 +165,21 @@ module homogenization real(pReal) :: T end function homogenization_thermal_T - module subroutine thermal_conduction_getSource(Tdot, ip,el) + module subroutine thermal_conduction_getSource(Tdot, ip, el) integer, intent(in) :: & - ip, & !< integration point number - el !< element number + ip, & + el real(pReal), intent(out) :: Tdot end subroutine thermal_conduction_getSource - module function damage_nonlocal_getMobility(ip,el) result(M) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + module function damage_nonlocal_getMobility(ce) result(M) + integer, intent(in) :: ce real(pReal) :: M end function damage_nonlocal_getMobility - module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ip, el) + module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ce) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce real(pReal), intent(in) :: & phi real(pReal) :: & @@ -193,11 +187,9 @@ module homogenization end subroutine damage_nonlocal_getSourceAndItsTangent - module subroutine damage_nonlocal_putNonLocalDamage(phi,ip,el) + module subroutine damage_nonlocal_putNonLocalDamage(phi,ce) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce real(pReal), intent(in) :: & phi @@ -521,28 +513,25 @@ end subroutine damage_nonlocal_init !-------------------------------------------------------------------------------------------------- !> @brief returns homogenized non local damage diffusion tensor in reference configuration !-------------------------------------------------------------------------------------------------- -function damage_nonlocal_getDiffusion(ip,el) +function damage_nonlocal_getDiffusion(ce) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce real(pReal), dimension(3,3) :: & damage_nonlocal_getDiffusion integer :: & - homog, & - grain, & - ce + ho, & + grain - homog = material_homogenizationAt(el) + ho = material_homogenizationAt2(ce) damage_nonlocal_getDiffusion = 0.0_pReal - ce = (el-1)*discretization_nIPs + ip - do grain = 1, homogenization_Nconstituents(homog) + + do grain = 1, homogenization_Nconstituents(ho) damage_nonlocal_getDiffusion = damage_nonlocal_getDiffusion + & crystallite_push33ToRef(grain,ce,lattice_D(1:3,1:3,material_phaseAt2(grain,ce))) enddo damage_nonlocal_getDiffusion = & - num_damage%charLength**2*damage_nonlocal_getDiffusion/real(homogenization_Nconstituents(homog),pReal) + num_damage%charLength**2*damage_nonlocal_getDiffusion/real(homogenization_Nconstituents(ho),pReal) end function damage_nonlocal_getDiffusion diff --git a/src/homogenization_damage.f90 b/src/homogenization_damage.f90 index 128725839..993ea84f6 100644 --- a/src/homogenization_damage.f90 +++ b/src/homogenization_damage.f90 @@ -85,22 +85,20 @@ end subroutine damage_partition !-------------------------------------------------------------------------------------------------- !> @brief Returns homogenized nonlocal damage mobility !-------------------------------------------------------------------------------------------------- -module function damage_nonlocal_getMobility(ip,el) result(M) +module function damage_nonlocal_getMobility(ce) result(M) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce integer :: & co real(pReal) :: M M = 0.0_pReal - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - M = M + lattice_M(material_phaseAt(co,el)) + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) + M = M + lattice_M(material_phaseAt2(co,ce)) enddo - M = M/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) + M = M/real(homogenization_Nconstituents(material_homogenizationAt2(ce)),pReal) end function damage_nonlocal_getMobility @@ -108,11 +106,9 @@ end function damage_nonlocal_getMobility !-------------------------------------------------------------------------------------------------- !> @brief calculates homogenized damage driving forces !-------------------------------------------------------------------------------------------------- -module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ip, el) +module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ce) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce real(pReal), intent(in) :: & phi real(pReal) :: & @@ -121,9 +117,9 @@ module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, p phiDot = 0.0_pReal dPhiDot_dPhi = 0.0_pReal - call phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) - phiDot = phiDot/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) - dPhiDot_dPhi = dPhiDot_dPhi/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal) + call phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ce) + phiDot = phiDot/real(homogenization_Nconstituents(material_homogenizationAt2(ce)),pReal) + dPhiDot_dPhi = dPhiDot_dPhi/real(homogenization_Nconstituents(material_homogenizationAt2(ce)),pReal) end subroutine damage_nonlocal_getSourceAndItsTangent @@ -131,20 +127,18 @@ end subroutine damage_nonlocal_getSourceAndItsTangent !-------------------------------------------------------------------------------------------------- !> @brief updated nonlocal damage field with solution from damage phase field PDE !-------------------------------------------------------------------------------------------------- -module subroutine damage_nonlocal_putNonLocalDamage(phi,ip,el) +module subroutine damage_nonlocal_putNonLocalDamage(phi,ce) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce real(pReal), intent(in) :: & phi integer :: & - homog, & - offset + ho, & + me - homog = material_homogenizationAt(el) - offset = material_homogenizationMemberAt(ip,el) - damagestate_h(homog)%state(1,offset) = phi + ho = material_homogenizationAt2(ce) + me = material_homogenizationMemberAt2(ce) + damagestate_h(ho)%state(1,me) = phi end subroutine damage_nonlocal_putNonLocalDamage diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index a02f798cd..928bd547b 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -99,20 +99,16 @@ end subroutine thermal_homogenize !-------------------------------------------------------------------------------------------------- !> @brief return homogenized thermal conductivity in reference configuration !-------------------------------------------------------------------------------------------------- -module function thermal_conduction_getConductivity(ip,el) result(K) +module function thermal_conduction_getConductivity(ce) result(K) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce real(pReal), dimension(3,3) :: K integer :: & - co, & - ce + co K = 0.0_pReal - ce = (el-1)*discretization_nIPs + ip do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) K = K + crystallite_push33ToRef(co,ce,lattice_K(:,:,material_phaseAt2(co,ce))) enddo @@ -220,11 +216,11 @@ end function homogenization_thermal_T !-------------------------------------------------------------------------------------------------- !> @brief return heat generation rate !-------------------------------------------------------------------------------------------------- -module subroutine thermal_conduction_getSource(Tdot, ip,el) +module subroutine thermal_conduction_getSource(Tdot, ip, el) integer, intent(in) :: & - ip, & !< integration point number - el !< element number + ip, & + el real(pReal), intent(out) :: & Tdot diff --git a/src/phase.f90 b/src/phase.f90 index 9ab5c386a..add26ae0b 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -231,10 +231,8 @@ module phase end function phase_homogenizedC - module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ce) + integer, intent(in) :: ce real(pReal), intent(in) :: & phi !< damage parameter real(pReal), intent(inout) :: & diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 5e4e43017..c6fd7bfab 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -179,11 +179,9 @@ end subroutine damage_init !---------------------------------------------------------------------------------------------- !< @brief returns local part of nonlocal damage driving force !---------------------------------------------------------------------------------------------- -module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el) +module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ce) - integer, intent(in) :: & - ip, & !< integration point number - el !< element number + integer, intent(in) :: ce real(pReal), intent(in) :: & phi !< damage parameter real(pReal), intent(inout) :: & @@ -201,9 +199,9 @@ module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, phiDot = 0.0_pReal dPhiDot_dPhi = 0.0_pReal - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) - ph = material_phaseAt(co,el) - me = material_phasememberAt(co,ip,el) + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) + ph = material_phaseAt2(co,ce) + me = material_phasememberAt2(co,ce) select case(phase_source(ph)) case (DAMAGE_ISOBRITTLE_ID) From dfe7ded893dcbca244b431dc46b04524724c9a21 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 23 Feb 2021 17:03:15 +0100 Subject: [PATCH 293/352] [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 294/352] 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 295/352] 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 296/352] 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 297/352] 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 298/352] 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 299/352] 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 9a9d287aed8ae91be49ef077a39eed068f73db0f Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Wed, 24 Feb 2021 12:06:46 +0100 Subject: [PATCH 300/352] tau_0 should be per slip family --- PRIVATE | 2 +- src/phase_mechanical_plastic_dislotwin.f90 | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/PRIVATE b/PRIVATE index f654a4143..bbbd3b769 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit f654a4143b1fbbecd137dc5d2193f5cf48ab1448 +Subproject commit bbbd3b7695aa72cffbf6ac37b67ca2f5bef4d5f0 diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index 0c52176ce..55c9c616e 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -24,7 +24,6 @@ submodule(phase:plastic) dislotwin q_sb = 1.0_pReal, & !< q-exponent in shear band velocity D_a = 1.0_pReal, & !< adjustment parameter to calculate minimum dipole distance i_tw = 1.0_pReal, & !< adjustment parameter to calculate MFP for twinning - tau_0 = 1.0_pReal, & !< strength due to elements in solid solution L_tw = 1.0_pReal, & !< Length of twin nuclei in Burgers vectors L_tr = 1.0_pReal, & !< Length of trans nuclei in Burgers vectors x_c_tw = 1.0_pReal, & !< critical distance for formation of twin nucleus @@ -53,6 +52,7 @@ submodule(phase:plastic) dislotwin q, & !< q-exponent in glide velocity r, & !< r-exponent in twin nucleation rate s, & !< s-exponent in trans nucleation rate + tau_0, & !< strength due to elements in solid solution gamma_char, & !< characteristic shear for twins B !< drag coefficient real(pReal), allocatable, dimension(:,:) :: & @@ -213,10 +213,10 @@ module function plastic_dislotwin_init() result(myPlasticity) prm%i_sl = pl%get_asFloats('i_sl', requiredSize=size(N_sl)) prm%p = pl%get_asFloats('p_sl', requiredSize=size(N_sl)) prm%q = pl%get_asFloats('q_sl', requiredSize=size(N_sl)) + prm%tau_0 = pl%get_asFloats('tau_0', requiredSize=size(N_sl)) prm%B = pl%get_asFloats('B', requiredSize=size(N_sl), & defaultVal=[(0.0_pReal, i=1,size(N_sl))]) - prm%tau_0 = pl%get_asFloat('tau_0') prm%D_a = pl%get_asFloat('D_a') prm%D_0 = pl%get_asFloat('D_0') prm%Q_cl = pl%get_asFloat('Q_cl') @@ -242,6 +242,7 @@ module function plastic_dislotwin_init() result(myPlasticity) prm%i_sl = math_expand(prm%i_sl, N_sl) prm%p = math_expand(prm%p, N_sl) prm%q = math_expand(prm%q, N_sl) + prm%tau_0 = math_expand(prm%tau_0, N_sl) prm%B = math_expand(prm%B, N_sl) ! sanity checks From 890e00880b24292dfce38409559226005a1e331b Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Wed, 24 Feb 2021 15:16:43 +0100 Subject: [PATCH 301/352] updated test repo --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index bbbd3b769..5fe205710 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit bbbd3b7695aa72cffbf6ac37b67ca2f5bef4d5f0 +Subproject commit 5fe205710fe079c77d0b4fa142248804cbb91563 From 2549d7a05a5dc94930a674d09aaa3456a583bb6e Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 24 Feb 2021 15:50:06 +0100 Subject: [PATCH 302/352] [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 303/352] [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 From c0e488881ea563c634769e141310f91417d6530f Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Wed, 24 Feb 2021 18:36:06 +0100 Subject: [PATCH 304/352] converted two examples to yaml --- PRIVATE | 2 +- .../Phase_Dislotwin_TWIP-Steel-FeMnC.config | 64 ------------------- .../Phase_Dislotwin_TWIP-Steel-FeMnC.yaml | 41 ++++++++++++ .../Phase_Dislotwin_Tungsten.config | 36 ----------- .../ConfigFiles/Phase_Dislotwin_Tungsten.yaml | 22 +++++++ python/tests/test_ConfigMaterial.py | 1 - 6 files changed, 64 insertions(+), 102 deletions(-) delete mode 100644 examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.config create mode 100644 examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml delete mode 100644 examples/ConfigFiles/Phase_Dislotwin_Tungsten.config create mode 100644 examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml diff --git a/PRIVATE b/PRIVATE index 5fe205710..48dd9972d 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 5fe205710fe079c77d0b4fa142248804cbb91563 +Subproject commit 48dd9972d9023caa8b04226112dcdd57fa0be6af diff --git a/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.config b/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.config deleted file mode 100644 index 3ca635d73..000000000 --- a/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.config +++ /dev/null @@ -1,64 +0,0 @@ -[TWIP_Steel_FeMnC] - -elasticity hooke -plasticity dislotwin - -(output) rho_mob -(output) rho_dip -(output) gamma_sl -(output) lambda_sl -(output) tau_pass -(output) f_tw -(output) lambda_tw -(output) tau_hat_tw -(output) f_tr - - -### Material parameters ### -lattice_structure fcc -C11 175.0e9 # From Music et al. Applied Physics Letters 91, 191904 (2007) -C12 115.0e9 -C44 135.0e9 -grainsize 2.0e-5 # Average grain size [m] -SolidSolutionStrength 1.5e8 # Strength due to elements in solid solution - -### Dislocation glide parameters ### -Nslip 12 -slipburgers 2.56e-10 # Burgers vector of slip system [m] -rhoedgedip0 1.0 # Initial dislocation density [m/m**3] -rhoedge0 1.0e12 # Initial dislocation density [m/m**3] -v0 1.0e-4 # Initial glide velocity [m/s] -Qedge 3.7e-19 # Activation energy for dislocation glide [J] -p_slip 1.0 # p-exponent in glide velocity -q_slip 1.0 # q-exponent in glide velocity - -# hardening of glide -CLambdaSlip 10.0 # Adj. parameter controlling dislocation mean free path -D0 4.0e-5 # Vacancy diffusion prefactor [m**2/s] -Qsd 4.5e-19 # Activation energy for climb [J] -Catomicvolume 1.0 # Adj. parameter controlling the atomic volume [in b^3] -Cedgedipmindistance 1.0 # Adj. parameter controlling the minimum dipole distance [in b] -interactionSlipSlip 0.122 0.122 0.625 0.07 0.137 0.122 # Interaction coefficients (Kubin et al. 2008) - -### Shearband parameters ### -shearbandresistance 180e6 -shearbandvelocity 0e-4 # set to zero to turn shear banding of -QedgePerSbSystem 3.7e-19 # Activation energy for shear banding [J] -p_shearband 1.0 # p-exponent in glide velocity -q_shearband 1.0 # q-exponent in glide velocity - -### Twinning parameters ### -Ntwin 12 -twinburgers 1.47e-10 # Burgers vector of twin system [m] -twinsize 5.0e-8 # Twin stack mean thickness [m] -L0_twin 442.0 # Length of twin nuclei in Burgers vectors -maxtwinfraction 1.0 # Maximum admissible twin volume fraction -xc_twin 1.0e-9 # critical distance for formation of twin nucleus -VcrossSlip 1.67e-29 # cross slip volume -r_twin 10.0 # r-exponent in twin formation probability -Cmfptwin 1.0 # Adj. parameter controlling twin mean free path -Cthresholdtwin 1.0 # Adj. parameter controlling twin threshold stress -interactionSlipTwin 0.0 1.0 1.0 # Dislocation-Twin interaction coefficients -interactionTwinTwin 0.0 1.0 # Twin-Twin interaction coefficients -SFE_0K -0.0396 # stacking fault energy at zero K; TWIP steel: -0.0526; Cu: -0.0396 -dSFE_dT 0.0002 # temperature dependance of stacking fault energy diff --git a/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml b/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml new file mode 100644 index 000000000..e4f325d66 --- /dev/null +++ b/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml @@ -0,0 +1,41 @@ +TWIP_STEEL_FeMnC: + lattice: cF + mechanics: + elasticity: {C_11: 175.0e9, C_12: 115.0e9, C_44: 135.0e9, type: hooke} + plasticity: + type: dislotwin + D: 2.0e-5 + N_sl: [12] + b_sl: [2.56e-10] + rho_mob_0: [1.0e12] + rho_dip_0: [1.0] + v_0: [1.0e-4] + Q_s: [3.7e-19] + p_sl: [1.0] + q_sl: [1.0] + tau_0: [1.5e8] + i_sl: [10.0] # Adj. parameter controlling dislocation mean free path + D_0: 4.0e-5 # Vacancy diffusion prefactor [m**2/s] + D_a: 1.0 # Adj. parameter controlling the minimum dipole distance [in b] + Q_cl: 4.5e-19 # Activation energy for climb [J] + h_sl_sl: [0.122, 0.122, 0.625, 0.07, 0.137, 0.122] # Interaction coefficients (Kubin et al. 2008) +# shear band params + xi_sb: 180.0e6 + Q_sb: 3.7e-19 + p_sb: 1.0 + q_sb: 1.0 + v_sb: 0.0 #set to 0, to turn it off + ### Twinning parameters ### + N_tw: [12] + b_tw: [1.47e-10] # Burgers vector of twin system [m] + t_tw: [5.0e-8] # Twin stack mean thickness [m] + L_tw: 442.0 # Length of twin nuclei in Burgers vectors + x_c_tw: 1.0e-9 # critical distance for formation of twin nucleus + V_cs: 1.67e-29 # cross slip volume + p_tw: [10.0] # r-exponent in twin formation probability + i_tw: 1.0 # Adj. parameter controlling twin mean free path + h_sl_tw: [0.0, 1.0, 1.0] # Dislocation-Twin interaction coefficients + h_tw_tw: [0.0, 1.0] # Twin-Twin interaction coefficients + Gamma_sf_0K: -0.0396 # stacking fault energy at zero K; TWIP steel: -0.0526; Cu: -0.0396 + dGamma_sf_dT: 0.0002 # temperature dependance of stacking fault energy + output: [rho_mob, rho_dip, gamma_sl, Lambda_sl, tau_pass, f_tw, Lambda_tw, tau_hat_tw, f_tr] diff --git a/examples/ConfigFiles/Phase_Dislotwin_Tungsten.config b/examples/ConfigFiles/Phase_Dislotwin_Tungsten.config deleted file mode 100644 index 30c04cb9a..000000000 --- a/examples/ConfigFiles/Phase_Dislotwin_Tungsten.config +++ /dev/null @@ -1,36 +0,0 @@ -[Tungsten] - -elasticity hooke -plasticity dislotwin - -### Material parameters ### -lattice_structure bcc -C11 523.0e9 # From Marinica et al. Journal of Physics: Condensed Matter(2013) -C12 202.0e9 -C44 161.0e9 - -grainsize 2.0e-5 # Average grain size [m] -SolidSolutionStrength 1.5e8 # Strength due to elements in solid solution - -### Dislocation glide parameters ### -#per family -Nslip 12 -slipburgers 2.72e-10 # Burgers vector of slip system [m] -rhoedge0 1.0e12 # Initial edge dislocation density [m/m**3] -rhoedgedip0 1.0 # Initial edged dipole dislocation density [m/m**3] -v0 1.0e-4 # Initial glide velocity [m/s] -Qedge 2.725e-19 # Activation energy for dislocation glide [J] -p_slip 0.78 # p-exponent in glide velocity -q_slip 1.58 # q-exponent in glide velocity -tau_peierls 2.03e9 # peierls stress (for bcc) -dipoleformationfactor 0 # to have hardening due to dipole formation off - -#hardening -CLambdaSlip 10.0 # Adj. parameter controlling dislocation mean free path -D0 4.0e-5 # Vacancy diffusion prefactor [m**2/s] -Qsd 4.5e-19 # Activation energy for climb [J] -Catomicvolume 1.0 # Adj. parameter controlling the atomic volume [in b] -Cedgedipmindistance 1.0 # Adj. parameter controlling the minimum dipole distance [in b] -interaction_slipslip 1 1 1.4 1.4 1.4 1.4 - - diff --git a/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml b/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml new file mode 100644 index 000000000..bbd6d0282 --- /dev/null +++ b/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml @@ -0,0 +1,22 @@ +Tungsten: + lattice: cI + mechanics: + elasticity: {C_11: 523.0e9, C_12: 202.0e9, C_44: 161.0e9, type: hooke} # From Marinica et al. Journal of Physics: Condensed Matter(2013) + plasticity: + type: dislotwin + D: 2.0e-5 # Average grain size [m] + N_sl: [12] + b_sl: [2.72e-10] # Burgers vector of slip system [m] + rho_mob_0: [1.0e12] + rho_dip_0: [1.0] + v_0: [1.0e-4] # Initial glide velocity [m/s] + Q_s: [2.725e-19] # Activation energy for dislocation glide [J] + p_sl: [0.78] # p-exponent in glide velocity + q_sl: [1.58] # q-exponent in glide velocity + tau_0: [1.5e8] + i_sl: [10.0] # Adj. parameter controlling dislocation mean free path + D_0: 4.0e-5 # Vacancy diffusion prefactor [m**2/s] + D_a: 1.0 # Adj. parameter controlling the minimum dipole distance [in b] + Q_cl: 4.5e-19 # Activation energy for climb [J] + h_sl_sl: [1, 1, 1.4, 1.4, 1.4, 1.4] + no_dipole_formation: True 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 3ca38dabacd2de82d97843c1a61a98db474e4abe Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 24 Feb 2021 14:10:40 -0500 Subject: [PATCH 305/352] indicate units according to SI standard --- .../Phase_Dislotwin_TWIP-Steel-FeMnC.yaml | 38 +++++++++---------- .../ConfigFiles/Phase_Dislotwin_Tungsten.yaml | 19 +++++----- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml b/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml index e4f325d66..e3705891f 100644 --- a/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml +++ b/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml @@ -1,9 +1,10 @@ -TWIP_STEEL_FeMnC: +TWIP_Steel_FeMnC: lattice: cF mechanics: - elasticity: {C_11: 175.0e9, C_12: 115.0e9, C_44: 135.0e9, type: hooke} + elasticity: {type: hooke, C_11: 175.0e9, C_12: 115.0e9, C_44: 135.0e9} plasticity: type: dislotwin + output: [rho_mob, rho_dip, gamma_sl, Lambda_sl, tau_pass, f_tw, Lambda_tw, tau_hat_tw, f_tr] D: 2.0e-5 N_sl: [12] b_sl: [2.56e-10] @@ -14,28 +15,27 @@ TWIP_STEEL_FeMnC: p_sl: [1.0] q_sl: [1.0] tau_0: [1.5e8] - i_sl: [10.0] # Adj. parameter controlling dislocation mean free path - D_0: 4.0e-5 # Vacancy diffusion prefactor [m**2/s] - D_a: 1.0 # Adj. parameter controlling the minimum dipole distance [in b] - Q_cl: 4.5e-19 # Activation energy for climb [J] + i_sl: [10.0] # Adj. parameter controlling dislocation mean free path + D_0: 4.0e-5 # Vacancy diffusion prefactor / m^2/s + D_a: 1.0 # minimum dipole distance / b + Q_cl: 4.5e-19 # Activation energy for climb / J h_sl_sl: [0.122, 0.122, 0.625, 0.07, 0.137, 0.122] # Interaction coefficients (Kubin et al. 2008) -# shear band params +# shear band parameters xi_sb: 180.0e6 Q_sb: 3.7e-19 p_sb: 1.0 q_sb: 1.0 - v_sb: 0.0 #set to 0, to turn it off - ### Twinning parameters ### + v_sb: 0.0 # set to 0, to turn it off +# twinning parameters N_tw: [12] - b_tw: [1.47e-10] # Burgers vector of twin system [m] - t_tw: [5.0e-8] # Twin stack mean thickness [m] - L_tw: 442.0 # Length of twin nuclei in Burgers vectors - x_c_tw: 1.0e-9 # critical distance for formation of twin nucleus - V_cs: 1.67e-29 # cross slip volume + b_tw: [1.47e-10] # Burgers vector length of twin system / b + t_tw: [5.0e-8] # Twin stack mean thickness / m + L_tw: 442.0 # Length of twin nuclei / b + x_c_tw: 1.0e-9 # critical distance for formation of twin nucleus / m + V_cs: 1.67e-29 # cross slip volume / m^3 p_tw: [10.0] # r-exponent in twin formation probability i_tw: 1.0 # Adj. parameter controlling twin mean free path - h_sl_tw: [0.0, 1.0, 1.0] # Dislocation-Twin interaction coefficients - h_tw_tw: [0.0, 1.0] # Twin-Twin interaction coefficients - Gamma_sf_0K: -0.0396 # stacking fault energy at zero K; TWIP steel: -0.0526; Cu: -0.0396 - dGamma_sf_dT: 0.0002 # temperature dependance of stacking fault energy - output: [rho_mob, rho_dip, gamma_sl, Lambda_sl, tau_pass, f_tw, Lambda_tw, tau_hat_tw, f_tr] + h_sl_tw: [0.0, 1.0, 1.0] # dislocation-twin interaction coefficients + h_tw_tw: [0.0, 1.0] # twin-twin interaction coefficients + Gamma_sf_0K: -0.0396 # stacking fault energy / J/m^2 at zero K; TWIP steel: -0.0526; Cu: -0.0396 + dGamma_sf_dT: 0.0002 # temperature dependence / J/(m^2 K) of stacking fault energy diff --git a/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml b/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml index bbd6d0282..3863899cb 100644 --- a/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml +++ b/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml @@ -1,22 +1,21 @@ Tungsten: lattice: cI mechanics: - elasticity: {C_11: 523.0e9, C_12: 202.0e9, C_44: 161.0e9, type: hooke} # From Marinica et al. Journal of Physics: Condensed Matter(2013) + elasticity: {type: hooke, C_11: 523.0e9, C_12: 202.0e9, C_44: 161.0e9} # Marinica et al. Journal of Physics: Condensed Matter(2013) plasticity: type: dislotwin - D: 2.0e-5 # Average grain size [m] + D: 2.0e-5 # Average grain size / m N_sl: [12] - b_sl: [2.72e-10] # Burgers vector of slip system [m] + b_sl: [2.72e-10] # Burgers vector length of slip families / m rho_mob_0: [1.0e12] rho_dip_0: [1.0] - v_0: [1.0e-4] # Initial glide velocity [m/s] - Q_s: [2.725e-19] # Activation energy for dislocation glide [J] + v_0: [1.0e-4] # Initial glide velocity / m/s + Q_s: [2.725e-19] # Activation energy for dislocation glide / J p_sl: [0.78] # p-exponent in glide velocity q_sl: [1.58] # q-exponent in glide velocity - tau_0: [1.5e8] + tau_0: [1.5e8] # solid solution strength / Pa i_sl: [10.0] # Adj. parameter controlling dislocation mean free path - D_0: 4.0e-5 # Vacancy diffusion prefactor [m**2/s] - D_a: 1.0 # Adj. parameter controlling the minimum dipole distance [in b] - Q_cl: 4.5e-19 # Activation energy for climb [J] + D_0: 4.0e-5 # Vacancy diffusion prefactor / m^2/s + D_a: 1.0 # minimum dipole distance / b + Q_cl: 4.5e-19 # Activation energy for climb / J h_sl_sl: [1, 1, 1.4, 1.4, 1.4, 1.4] - no_dipole_formation: True From f8bc2bf0c294840a224c5c642af603da2a200aa6 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 24 Feb 2021 14:12:50 -0500 Subject: [PATCH 306/352] renamed "no_dipole_formation" flag to "omit_dipoles"; shortened dipole dotState logic --- src/phase_mechanical_plastic_dislotwin.f90 | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index 55c9c616e..dad1ad773 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -81,7 +81,7 @@ submodule(phase:plastic) dislotwin logical :: & ExtendedDislocations, & !< consider split into partials for climb calculation fccTwinTransNucleation, & !< twinning and transformation models are for fcc - dipoleFormation !< flag indicating consideration of dipole formation + omitDipoles !< flag controlling consideration of dipole formation end type !< container type for internal constitutive parameters type :: tDislotwinState @@ -226,7 +226,7 @@ module function plastic_dislotwin_init() result(myPlasticity) prm%dGamma_sf_dT = pl%get_asFloat('dGamma_sf_dT') endif - prm%dipoleformation = .not. pl%get_asBool('no_dipole_formation',defaultVal = .false.) + prm%omitDipoles = pl%get_asBool('omit_dipoles',defaultVal = .false.) ! multiplication factor according to crystal structure (nearest neighbors bcc vs fcc/hex) ! details: Argon & Moffat, Acta Metallurgica, Vol. 29, pg 293 to 299, 1981 @@ -676,20 +676,16 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) slipState: do i = 1, prm%sum_N_sl tau = math_tensordot(Mp,prm%P_sl(1:3,1:3,i)) - significantSlipStress: if (dEq0(tau)) then + significantSlipStress: if (dEq0(tau) .or. prm%omitDipoles) then dot_rho_dip_formation(i) = 0.0_pReal dot_rho_dip_climb(i) = 0.0_pReal else significantSlipStress - rho_dip_distance = 3.0_pReal*prm%mu*prm%b_sl(i)/(16.0_pReal*PI*abs(tau)) - rho_dip_distance = math_clip(rho_dip_distance, right = dst%Lambda_sl(i,me)) - rho_dip_distance = math_clip(rho_dip_distance, left = rho_dip_distance_min(i)) + rho_dip_distance = math_clip(3.0_pReal*prm%mu*prm%b_sl(i)/(16.0_pReal*PI*abs(tau)), & + left = rho_dip_distance_min(i), & + right = dst%Lambda_sl(i,me)) - if (prm%dipoleFormation) then - dot_rho_dip_formation(i) = 2.0_pReal*(rho_dip_distance-rho_dip_distance_min(i))/prm%b_sl(i) & - * stt%rho_mob(i,me)*abs(dot_gamma_sl(i)) - else - dot_rho_dip_formation(i) = 0.0_pReal - endif + dot_rho_dip_formation(i) = 2.0_pReal*(rho_dip_distance-rho_dip_distance_min(i))/prm%b_sl(i) & + * stt%rho_mob(i,me)*abs(dot_gamma_sl(i)) if (dEq(rho_dip_distance,rho_dip_distance_min(i))) then dot_rho_dip_climb(i) = 0.0_pReal From 2f205e6123a008edd6f47d9408919275b314f08b Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 24 Feb 2021 14:28:31 -0500 Subject: [PATCH 307/352] updated to current PRIVATE --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 48dd9972d..effb7fe10 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 48dd9972d9023caa8b04226112dcdd57fa0be6af +Subproject commit effb7fe1016984ed90c1e6ec264da1227bc74cc3 From 533abd97b58674563f2042679fcaf13748283cfe Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 24 Feb 2021 15:56:34 -0500 Subject: [PATCH 308/352] now hopefully with the correct matching PRIVATE --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index effb7fe10..48dd9972d 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit effb7fe1016984ed90c1e6ec264da1227bc74cc3 +Subproject commit 48dd9972d9023caa8b04226112dcdd57fa0be6af From 59b7565961fc21e0cf77fb77338cc9050d38504d Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Thu, 25 Feb 2021 15:35:32 +0100 Subject: [PATCH 309/352] multiple clips throws NAN, back to sequential way of clipping --- src/phase_mechanical_plastic_dislotwin.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index dad1ad773..cc3d40cf3 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -680,12 +680,12 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) dot_rho_dip_formation(i) = 0.0_pReal dot_rho_dip_climb(i) = 0.0_pReal else significantSlipStress - rho_dip_distance = math_clip(3.0_pReal*prm%mu*prm%b_sl(i)/(16.0_pReal*PI*abs(tau)), & - left = rho_dip_distance_min(i), & - right = dst%Lambda_sl(i,me)) + rho_dip_distance = 3.0_pReal*prm%mu*prm%b_sl(i)/(16.0_pReal*PI*abs(tau)) + rho_dip_distance = math_clip(rho_dip_distance, right = dst%Lambda_sl(i,me)) + rho_dip_distance = math_clip(rho_dip_distance, left = rho_dip_distance_min(i)) dot_rho_dip_formation(i) = 2.0_pReal*(rho_dip_distance-rho_dip_distance_min(i))/prm%b_sl(i) & - * stt%rho_mob(i,me)*abs(dot_gamma_sl(i)) + * stt%rho_mob(i,me)*abs(dot_gamma_sl(i)) if (dEq(rho_dip_distance,rho_dip_distance_min(i))) then dot_rho_dip_climb(i) = 0.0_pReal From 988e584d7d07b6dfdb0febc450ee421fdc5ebabb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 25 Feb 2021 16:44:52 +0100 Subject: [PATCH 310/352] merge simplifies conditional assignment --- src/phase_mechanical_plastic_dislotwin.f90 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index cc3d40cf3..9398f0f6d 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -647,7 +647,6 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) f_unrotated, & rho_dip_distance, & v_cl, & !< climb velocity - Gamma, & !< stacking fault energy tau, & sigma_cl, & !< climb stress b_d !< ratio of Burgers vector to stacking fault width @@ -685,19 +684,17 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) rho_dip_distance = math_clip(rho_dip_distance, left = rho_dip_distance_min(i)) dot_rho_dip_formation(i) = 2.0_pReal*(rho_dip_distance-rho_dip_distance_min(i))/prm%b_sl(i) & - * stt%rho_mob(i,me)*abs(dot_gamma_sl(i)) + * stt%rho_mob(i,me)*abs(dot_gamma_sl(i)) if (dEq(rho_dip_distance,rho_dip_distance_min(i))) then dot_rho_dip_climb(i) = 0.0_pReal else - !@details: Refer: Argon & Moffat, Acta Metallurgica, Vol. 29, pg 293 to 299, 1981 + ! Argon & Moffat, Acta Metallurgica, Vol. 29, pg 293 to 299, 1981 sigma_cl = dot_product(prm%n0_sl(1:3,i),matmul(Mp,prm%n0_sl(1:3,i))) - if (prm%ExtendedDislocations) then - Gamma = prm%Gamma_sf_0K + prm%dGamma_sf_dT * T - b_d = 24.0_pReal*PI*(1.0_pReal - prm%nu)/(2.0_pReal + prm%nu)* Gamma/(prm%mu*prm%b_sl(i)) - else - b_d = 1.0_pReal - endif + b_d = merge(24.0_pReal*PI*(1.0_pReal - prm%nu)/(2.0_pReal + prm%nu) & + * (prm%Gamma_sf_0K + prm%dGamma_sf_dT * T) / (prm%mu*prm%b_sl(i)), & + 1.0_pReal, & + prm%ExtendedDislocations) v_cl = 2.0_pReal*prm%omega*b_d**2.0_pReal*exp(-prm%Q_cl/(kB*T)) & * (exp(abs(sigma_cl)*prm%b_sl(i)**3.0_pReal/(kB*T)) - 1.0_pReal) From be0e393e1db578ef47592b1a633ae52f9f507d84 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Thu, 25 Feb 2021 21:42:40 +0100 Subject: [PATCH 311/352] cleaning homogenization --- src/homogenization.f90 | 10 +-- src/homogenization_mechanical.f90 | 23 +++-- src/homogenization_mechanical_RGC.f90 | 118 +++++++++++++------------- 3 files changed, 73 insertions(+), 78 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 3c424585b..5078f0a09 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -110,11 +110,10 @@ module homogenization integer, intent(in) :: ip,el end subroutine thermal_homogenize - module subroutine mechanical_homogenize(dt,ip,el) + module subroutine mechanical_homogenize(dt,ce) real(pReal), intent(in) :: dt integer, intent(in) :: & - ip, & !< integration point - el !< element number + ce !< cell end subroutine mechanical_homogenize module subroutine mechanical_results(group_base,ho) @@ -348,14 +347,15 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE enddo !$OMP END DO - !$OMP DO PRIVATE(ho) + !$OMP DO PRIVATE(ho,ce) elementLooping3: do el = FEsolving_execElem(1),FEsolving_execElem(2) ho = material_homogenizationAt(el) IpLooping3: do ip = FEsolving_execIP(1),FEsolving_execIP(2) + ce = (el-1)*discretization_nIPs + ip do co = 1, homogenization_Nconstituents(ho) call crystallite_orientations(co,ip,el) enddo - call mechanical_homogenize(dt,ip,el) + call mechanical_homogenize(dt,ce) enddo IpLooping3 enddo elementLooping3 !$OMP END DO diff --git a/src/homogenization_mechanical.f90 b/src/homogenization_mechanical.f90 index e113fc9e1..f14ddf4db 100644 --- a/src/homogenization_mechanical.f90 +++ b/src/homogenization_mechanical.f90 @@ -137,27 +137,24 @@ end subroutine mechanical_partition !-------------------------------------------------------------------------------------------------- !> @brief Average P and dPdF from the individual constituents. !-------------------------------------------------------------------------------------------------- -module subroutine mechanical_homogenize(dt,ip,el) +module subroutine mechanical_homogenize(dt,ce) real(pReal), intent(in) :: dt - integer, intent(in) :: & - ip, & !< integration point - el !< element number + integer, intent(in) :: ce - integer :: co,ce - real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt(el))) - real(pReal) :: Ps(3,3,homogenization_Nconstituents(material_homogenizationAt(el))) + integer :: co + real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt2(ce))) + real(pReal) :: Ps(3,3,homogenization_Nconstituents(material_homogenizationAt2(ce))) - ce = (el-1)* discretization_nIPs + ip - chosenHomogenization: select case(homogenization_type(material_homogenizationAt(el))) + chosenHomogenization: select case(homogenization_type(material_homogenizationAt2(ce))) case (HOMOGENIZATION_NONE_ID) chosenHomogenization homogenization_P(1:3,1:3,ce) = phase_mechanical_getP(1,ce) homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = phase_mechanical_dPdF(dt,1,ce) case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ce) Ps(:,:,co) = phase_mechanical_getP(co,ce) enddo @@ -165,10 +162,10 @@ module subroutine mechanical_homogenize(dt,ip,el) homogenization_P(1:3,1:3,ce), & homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& Ps,dPdFs, & - material_homogenizationAt(el)) + material_homogenizationAt2(ce)) case (HOMOGENIZATION_RGC_ID) chosenHomogenization - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ce) Ps(:,:,co) = phase_mechanical_getP(co,ce) enddo @@ -176,7 +173,7 @@ module subroutine mechanical_homogenize(dt,ip,el) homogenization_P(1:3,1:3,ce), & homogenization_dPdF(1:3,1:3,1:3,1:3,ce),& Ps,dPdFs, & - material_homogenizationAt(el)) + material_homogenizationAt2(ce)) end select chosenHomogenization diff --git a/src/homogenization_mechanical_RGC.f90 b/src/homogenization_mechanical_RGC.f90 index 1f593b074..a68e9b772 100644 --- a/src/homogenization_mechanical_RGC.f90 +++ b/src/homogenization_mechanical_RGC.f90 @@ -77,7 +77,7 @@ module subroutine mechanical_RGC_init(num_homogMech) num_homogMech !< pointer to mechanical homogenization numerics data integer :: & - h, & + ho, & Nmaterialpoints, & sizeState, nIntFaceTot @@ -136,14 +136,14 @@ module subroutine mechanical_RGC_init(num_homogMech) if (num%volDiscrPow <= 0.0_pReal) call IO_error(301,ext_msg='volDiscrPw_RGC') - do h = 1, size(homogenization_type) - if (homogenization_type(h) /= HOMOGENIZATION_RGC_ID) cycle - homog => material_homogenization%get(h) + do ho = 1, size(homogenization_type) + if (homogenization_type(ho) /= HOMOGENIZATION_RGC_ID) cycle + homog => material_homogenization%get(ho) homogMech => homog%get('mechanics') - associate(prm => param(h), & - stt => state(h), & - st0 => state0(h), & - dst => dependentState(h)) + associate(prm => param(ho), & + stt => state(ho), & + st0 => state0(ho), & + dst => dependentState(ho)) #if defined (__GFORTRAN__) prm%output = output_asStrings(homogMech) @@ -152,7 +152,7 @@ module subroutine mechanical_RGC_init(num_homogMech) #endif prm%N_constituents = homogMech%get_asInts('cluster_size',requiredSize=3) - if (homogenization_Nconstituents(h) /= product(prm%N_constituents)) & + if (homogenization_Nconstituents(ho) /= product(prm%N_constituents)) & call IO_error(211,ext_msg='N_constituents (mechanical_RGC)') prm%xi_alpha = homogMech%get_asFloat('xi_alpha') @@ -161,18 +161,18 @@ module subroutine mechanical_RGC_init(num_homogMech) prm%D_alpha = homogMech%get_asFloats('D_alpha', requiredSize=3) prm%a_g = homogMech%get_asFloats('a_g', requiredSize=3) - Nmaterialpoints = count(material_homogenizationAt == h) + Nmaterialpoints = count(material_homogenizationAt == ho) nIntFaceTot = 3*( (prm%N_constituents(1)-1)*prm%N_constituents(2)*prm%N_constituents(3) & + prm%N_constituents(1)*(prm%N_constituents(2)-1)*prm%N_constituents(3) & + prm%N_constituents(1)*prm%N_constituents(2)*(prm%N_constituents(3)-1)) sizeState = nIntFaceTot - homogState(h)%sizeState = sizeState - allocate(homogState(h)%state0 (sizeState,Nmaterialpoints), source=0.0_pReal) - allocate(homogState(h)%state (sizeState,Nmaterialpoints), source=0.0_pReal) + homogState(ho)%sizeState = sizeState + allocate(homogState(ho)%state0 (sizeState,Nmaterialpoints), source=0.0_pReal) + allocate(homogState(ho)%state (sizeState,Nmaterialpoints), source=0.0_pReal) - stt%relaxationVector => homogState(h)%state(1:nIntFaceTot,:) - st0%relaxationVector => homogState(h)%state0(1:nIntFaceTot,:) + stt%relaxationVector => homogState(ho)%state(1:nIntFaceTot,:) + st0%relaxationVector => homogState(ho)%state0(1:nIntFaceTot,:) allocate(dst%volumeDiscrepancy( Nmaterialpoints), source=0.0_pReal) allocate(dst%relaxationRate_avg( Nmaterialpoints), source=0.0_pReal) @@ -181,7 +181,7 @@ module subroutine mechanical_RGC_init(num_homogMech) !-------------------------------------------------------------------------------------------------- ! assigning cluster orientations - dependentState(h)%orientation = spread(eu2om(prm%a_g*inRad),3,Nmaterialpoints) + dependentState(ho)%orientation = spread(eu2om(prm%a_g*inRad),3,Nmaterialpoints) !dst%orientation = spread(eu2om(prm%a_g*inRad),3,Nmaterialpoints) ifort version 18.0.1 crashes (for whatever reason) end associate @@ -205,10 +205,11 @@ module subroutine mechanical_RGC_partitionDeformation(F,avgF,ce) real(pReal), dimension(3) :: aVect,nVect integer, dimension(4) :: intFace integer, dimension(3) :: iGrain3 - integer :: iGrain,iFace,i,j,me + integer :: iGrain,iFace,i,j,ho,me associate(prm => param(material_homogenizationAt2(ce))) - + + ho = material_homogenizationAt2(ce) me = material_homogenizationMemberAt2(ce) !-------------------------------------------------------------------------------------------------- ! compute the deformation gradient of individual grains due to relaxations @@ -217,8 +218,8 @@ module subroutine mechanical_RGC_partitionDeformation(F,avgF,ce) iGrain3 = grain1to3(iGrain,prm%N_constituents) do iFace = 1,6 intFace = getInterface(iFace,iGrain3) ! identifying 6 interfaces of each grain - aVect = relaxationVector(intFace,ce,me) ! get the relaxation vectors for each interface from global relaxation vector array - nVect = interfaceNormal(intFace,ce,me) + aVect = relaxationVector(intFace,ho,me) ! get the relaxation vectors for each interface from global relaxation vector array + nVect = interfaceNormal(intFace,ho,me) forall (i=1:3,j=1:3) & F(i,j,iGrain) = F(i,j,iGrain) + aVect(i)*nVect(j) ! calculating deformation relaxations due to interface relaxation enddo @@ -283,11 +284,11 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa !-------------------------------------------------------------------------------------------------- ! computing interface mismatch and stress penalty tensor for all interfaces of all grains - call stressPenalty(R,NN,avgF,F,ce,me) + call stressPenalty(R,NN,avgF,F,ho,me) !-------------------------------------------------------------------------------------------------- ! calculating volume discrepancy and stress penalty related to overall volume discrepancy - call volumePenalty(D,dst%volumeDiscrepancy(me),avgF,F,nGrain,ce,me) + call volumePenalty(D,dst%volumeDiscrepancy(me),avgF,F,nGrain) !------------------------------------------------------------------------------------------------ ! computing the residual stress from the balance of traction at all (interior) interfaces @@ -299,7 +300,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa iGr3N = faceID(2:4) ! identifying the grain ID in local coordinate system (3-dimensional index) iGrN = grain3to1(iGr3N,param(ho)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceN = getInterface(2*faceID(1),iGr3N) - normN = interfaceNormal(intFaceN,ce,me) + normN = interfaceNormal(intFaceN,ho,me) !-------------------------------------------------------------------------------------------------- ! identify the right/up/front grain (+|P) @@ -307,7 +308,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa iGr3P(faceID(1)) = iGr3N(faceID(1))+1 ! identifying the grain ID in local coordinate system (3-dimensional index) iGrP = grain3to1(iGr3P,param(ho)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceP = getInterface(2*faceID(1)-1,iGr3P) - normP = interfaceNormal(intFaceP,ce,me) + normP = interfaceNormal(intFaceP,ho,me) !-------------------------------------------------------------------------------------------------- ! compute the residual of traction at the interface (in local system, 4-dimensional index) @@ -363,10 +364,10 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa iGr3N = faceID(2:4) ! identifying the grain ID in local coordinate sytem iGrN = grain3to1(iGr3N,param(ho)%N_constituents) ! translate into global grain ID intFaceN = getInterface(2*faceID(1),iGr3N) ! identifying the connecting interface in local coordinate system - normN = interfaceNormal(intFaceN,ce,me) + normN = interfaceNormal(intFaceN,ho,me) do iFace = 1,6 intFaceN = getInterface(iFace,iGr3N) ! identifying all interfaces that influence relaxation of the above interface - mornN = interfaceNormal(intFaceN,ce,me) + mornN = interfaceNormal(intFaceN,ho,me) iMun = interface4to1(intFaceN,param(ho)%N_constituents) ! translate the interfaces ID into local 4-dimensional index if (iMun > 0) then ! get the corresponding tangent do i=1,3; do j=1,3; do k=1,3; do l=1,3 @@ -384,10 +385,10 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa iGr3P(faceID(1)) = iGr3N(faceID(1))+1 ! identifying the grain ID in local coordinate sytem iGrP = grain3to1(iGr3P,param(ho)%N_constituents) ! translate into global grain ID intFaceP = getInterface(2*faceID(1)-1,iGr3P) ! identifying the connecting interface in local coordinate system - normP = interfaceNormal(intFaceP,ce,me) + normP = interfaceNormal(intFaceP,ho,me) do iFace = 1,6 intFaceP = getInterface(iFace,iGr3P) ! identifying all interfaces that influence relaxation of the above interface - mornP = interfaceNormal(intFaceP,ce,me) + mornP = interfaceNormal(intFaceP,ho,me) iMun = interface4to1(intFaceP,param(ho)%N_constituents) ! translate the interfaces ID into local 4-dimensional index if (iMun > 0) then ! get the corresponding tangent do i=1,3; do j=1,3; do k=1,3; do l=1,3 @@ -409,9 +410,9 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa p_relax = relax p_relax(ipert) = relax(ipert) + num%pPert ! perturb the relaxation vector stt%relaxationVector(:,me) = p_relax - call grainDeformation(pF,avgF,ce,me) ! rain deformation from perturbed state - call stressPenalty(pR,DevNull, avgF,pF,ce,me) ! stress penalty due to interface mismatch from perturbed state - call volumePenalty(pD,devNull(1,1), avgF,pF,nGrain,ce,me) ! stress penalty due to volume discrepancy from perturbed state + call grainDeformation(pF,avgF,ho,me) ! rain deformation from perturbed state + call stressPenalty(pR,DevNull, avgF,pF,ho,me) ! stress penalty due to interface mismatch from perturbed state + call volumePenalty(pD,devNull(1,1), avgF,pF,nGrain) ! stress penalty due to volume discrepancy from perturbed state !-------------------------------------------------------------------------------------------------- ! computing the global stress residual array from the perturbed state @@ -424,7 +425,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa iGr3N = faceID(2:4) ! identify the grain ID in local coordinate system (3-dimensional index) iGrN = grain3to1(iGr3N,param(ho)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceN = getInterface(2*faceID(1),iGr3N) ! identify the interface ID of the grain - normN = interfaceNormal(intFaceN,ce,me) + normN = interfaceNormal(intFaceN,ho,me) !-------------------------------------------------------------------------------------------------- ! identify the right/up/front grain (+|P) @@ -432,7 +433,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa iGr3P(faceID(1)) = iGr3N(faceID(1))+1 ! identify the grain ID in local coordinate system (3-dimensional index) iGrP = grain3to1(iGr3P,param(ho)%N_constituents) ! translate the local grain ID into global coordinate system (1-dimensional index) intFaceP = getInterface(2*faceID(1)-1,iGr3P) ! identify the interface ID of the grain - normP = interfaceNormal(intFaceP,ce,me) + normP = interfaceNormal(intFaceP,ho,me) !-------------------------------------------------------------------------------------------------- ! compute the residual stress (contribution of mismatch and volume penalties) from perturbed state @@ -476,7 +477,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa if (any(abs(drelax) > num%maxdRelax)) then ! Forcing cutback when the incremental change of relaxation vector becomes too large doneAndHappy = [.true.,.false.] !$OMP CRITICAL (write2out) - ! print'(a,i3,a,i3,a)',' RGC_updateState: ip ',ip,' | el ',el,' enforces cutback' + print'(a,i3,a,i3,a)',' RGC_updateState: enforces cutback' print'(a,e15.8)',' due to large relaxation change = ',maxval(abs(drelax)) flush(IO_STDOUT) !$OMP END CRITICAL (write2out) @@ -488,14 +489,14 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa !------------------------------------------------------------------------------------------------ !> @brief calculate stress-like penalty due to deformation mismatch !------------------------------------------------------------------------------------------------ - subroutine stressPenalty(rPen,nMis,avgF,fDef,ce,me) + subroutine stressPenalty(rPen,nMis,avgF,fDef,ho,me) real(pReal), dimension (:,:,:), intent(out) :: rPen !< stress-like penalty real(pReal), dimension (:,:), intent(out) :: nMis !< total amount of mismatch real(pReal), dimension (:,:,:), intent(in) :: fDef !< deformation gradients real(pReal), dimension (3,3), intent(in) :: avgF !< initial effective stretch tensor - integer, intent(in) :: ce, me + integer, intent(in) :: ho, me integer, dimension (4) :: intFace integer, dimension (3) :: iGrain3,iGNghb3,nGDim @@ -515,10 +516,9 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa ! get the correction factor the modulus of penalty stress representing the evolution of area of ! the interfaces due to deformations - surfCorr = surfaceCorrection(avgF,ce,me) - - associate(prm => param(material_homogenizationAt2(ce))) + surfCorr = surfaceCorrection(avgF,ho,me) + associate(prm => param(ho)) !----------------------------------------------------------------------------------------------- ! computing the mismatch and penalty stress tensor of all grains @@ -528,7 +528,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa interfaceLoop: do iFace = 1,6 intFace = getInterface(iFace,iGrain3) ! get the 4-dimensional index of the interface in local numbering system of the grain - nVect = interfaceNormal(intFace,ce,me) + nVect = interfaceNormal(intFace,ho,me) iGNghb3 = iGrain3 ! identify the neighboring grain across the interface iGNghb3(abs(intFace(1))) = iGNghb3(abs(intFace(1))) & + int(real(intFace(1),pReal)/real(abs(intFace(1)),pReal)) @@ -574,7 +574,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa !------------------------------------------------------------------------------------------------ !> @brief calculate stress-like penalty due to volume discrepancy !------------------------------------------------------------------------------------------------ - subroutine volumePenalty(vPen,vDiscrep,fAvg,fDef,nGrain,ce,me) + subroutine volumePenalty(vPen,vDiscrep,fAvg,fDef,nGrain) real(pReal), dimension (:,:,:), intent(out) :: vPen ! stress-like penalty due to volume real(pReal), intent(out) :: vDiscrep ! total volume discrepancy @@ -582,9 +582,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa real(pReal), dimension (:,:,:), intent(in) :: fDef ! deformation gradients real(pReal), dimension (3,3), intent(in) :: fAvg ! overall deformation gradient integer, intent(in) :: & - Ngrain, & - ce, & - me + Ngrain real(pReal), dimension(size(vPen,3)) :: gVol integer :: i @@ -614,13 +612,13 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa !> @brief compute the correction factor accouted for surface evolution (area change) due to ! deformation !-------------------------------------------------------------------------------------------------- - function surfaceCorrection(avgF,ce,me) + function surfaceCorrection(avgF,ho,me) real(pReal), dimension(3) :: surfaceCorrection real(pReal), dimension(3,3), intent(in) :: avgF !< average F integer, intent(in) :: & - ce, & + ho, & me real(pReal), dimension(3,3) :: invC real(pReal), dimension(3) :: nVect @@ -632,7 +630,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa surfaceCorrection = 0.0_pReal do iBase = 1,3 - nVect = interfaceNormal([iBase,1,1,1],ce,me) + nVect = interfaceNormal([iBase,1,1,1],ho,me) do i = 1,3; do j = 1,3 surfaceCorrection(iBase) = surfaceCorrection(iBase) + invC(i,j)*nVect(i)*nVect(j) ! compute the component of (the inverse of) the stretch in the direction of the normal enddo; enddo @@ -649,7 +647,7 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa integer, intent(in) :: & grainID,& - ce !< cell + ce real(pReal), dimension(6,6) :: C @@ -664,13 +662,13 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa !> @brief calculating the grain deformation gradient (the same with ! homogenization_RGC_partitionDeformation, but used only for perturbation scheme) !------------------------------------------------------------------------------------------------- - subroutine grainDeformation(F, avgF, ce, me) + subroutine grainDeformation(F, avgF, ho, me) real(pReal), dimension(:,:,:), intent(out) :: F !< partitioned F per grain real(pReal), dimension(:,:), intent(in) :: avgF !< averaged F integer, intent(in) :: & - ce, & + ho, & me real(pReal), dimension(3) :: aVect,nVect @@ -681,15 +679,15 @@ module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHa !----------------------------------------------------------------------------------------------- ! compute the deformation gradient of individual grains due to relaxations - associate (prm => param(material_homogenizationAt2(ce))) + associate (prm => param(ho)) F = 0.0_pReal do iGrain = 1,product(prm%N_constituents) iGrain3 = grain1to3(iGrain,prm%N_constituents) do iFace = 1,6 intFace = getInterface(iFace,iGrain3) - aVect = relaxationVector(intFace,ce,me) - nVect = interfaceNormal(intFace,ce,me) + aVect = relaxationVector(intFace,ho,me) + nVect = interfaceNormal(intFace,ho,me) forall (i=1:3,j=1:3) & F(i,j,iGrain) = F(i,j,iGrain) + aVect(i)*nVect(j) ! effective relaxations enddo @@ -756,11 +754,11 @@ end subroutine mechanical_RGC_results !-------------------------------------------------------------------------------------------------- !> @brief collect relaxation vectors of an interface !-------------------------------------------------------------------------------------------------- -pure function relaxationVector(intFace,ce,me) +pure function relaxationVector(intFace,ho,me) real(pReal), dimension (3) :: relaxationVector - integer, intent(in) :: ce,me + integer, intent(in) :: ho,me integer, dimension(4), intent(in) :: intFace !< set of interface ID in 4D array (normal and position) integer :: iNum @@ -768,8 +766,8 @@ pure function relaxationVector(intFace,ce,me) !-------------------------------------------------------------------------------------------------- ! collect the interface relaxation vector from the global state array - associate (prm => param(material_homogenizationAt2(ce)), & - stt => state(material_homogenizationAt2(ce))) + associate (prm => param(ho), & + stt => state(ho)) iNum = interface4to1(intFace,prm%N_constituents) ! identify the position of the interface in global state array if (iNum > 0) then @@ -786,17 +784,17 @@ end function relaxationVector !-------------------------------------------------------------------------------------------------- !> @brief identify the normal of an interface !-------------------------------------------------------------------------------------------------- -pure function interfaceNormal(intFace,ce,me) +pure function interfaceNormal(intFace,ho,me) real(pReal), dimension(3) :: interfaceNormal integer, dimension(4), intent(in) :: intFace !< interface ID in 4D array (normal and position) integer, intent(in) :: & - ce, & + ho, & me integer :: nPos - associate (dst => dependentState(material_homogenizationAt2(ce))) + associate (dst => dependentState(ho)) !-------------------------------------------------------------------------------------------------- ! get the normal of the interface, identified from the value of intFace(1) From 5de1ca0dd74450ade1f2599d63e77b39a18a1ed1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 25 Feb 2021 23:10:45 +0100 Subject: [PATCH 312/352] more reasonable value used in https://doi.org/10.1016/j.ijplas.2020.102779 --- examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml | 2 +- examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml b/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml index e3705891f..009443284 100644 --- a/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml +++ b/examples/ConfigFiles/Phase_Dislotwin_TWIP-Steel-FeMnC.yaml @@ -10,7 +10,7 @@ TWIP_Steel_FeMnC: b_sl: [2.56e-10] rho_mob_0: [1.0e12] rho_dip_0: [1.0] - v_0: [1.0e-4] + v_0: [1.0e4] Q_s: [3.7e-19] p_sl: [1.0] q_sl: [1.0] diff --git a/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml b/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml index 3863899cb..36467192b 100644 --- a/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml +++ b/examples/ConfigFiles/Phase_Dislotwin_Tungsten.yaml @@ -9,7 +9,7 @@ Tungsten: b_sl: [2.72e-10] # Burgers vector length of slip families / m rho_mob_0: [1.0e12] rho_dip_0: [1.0] - v_0: [1.0e-4] # Initial glide velocity / m/s + v_0: [1.0e4] # Initial glide velocity / m/s Q_s: [2.725e-19] # Activation energy for dislocation glide / J p_sl: [0.78] # p-exponent in glide velocity q_sl: [1.58] # q-exponent in glide velocity From 84da6a2deeaf0148e84e5f57f1e8b9f7646c89de Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 25 Feb 2021 23:11:21 +0100 Subject: [PATCH 313/352] not needed anymore --- examples/ConfigFiles/Microstructure_DP_Steel.config | 4 ---- examples/ConfigFiles/Phase_Hydrogen.config | 3 --- 2 files changed, 7 deletions(-) delete mode 100644 examples/ConfigFiles/Microstructure_DP_Steel.config delete mode 100644 examples/ConfigFiles/Phase_Hydrogen.config diff --git a/examples/ConfigFiles/Microstructure_DP_Steel.config b/examples/ConfigFiles/Microstructure_DP_Steel.config deleted file mode 100644 index 6c083e2c7..000000000 --- a/examples/ConfigFiles/Microstructure_DP_Steel.config +++ /dev/null @@ -1,4 +0,0 @@ -[DP_Steel] -crystallite 1 -(constituent) phase 1 texture 1 fraction 0.82 -(constituent) phase 2 texture 2 fraction 0.18 diff --git a/examples/ConfigFiles/Phase_Hydrogen.config b/examples/ConfigFiles/Phase_Hydrogen.config deleted file mode 100644 index c9ccfdc86..000000000 --- a/examples/ConfigFiles/Phase_Hydrogen.config +++ /dev/null @@ -1,3 +0,0 @@ -hydrogenflux_diffusion11 1.0 -hydrogenflux_mobility11 1.0 -hydrogenVolume 1e-28 From 2ca3a824a46ca53feee6b08de8788f3a7cef5f7d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 25 Feb 2021 23:11:36 +0100 Subject: [PATCH 314/352] better fail immediately --- src/math.f90 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/math.f90 b/src/math.f90 index 6b89a9923..6ef942677 100644 --- a/src/math.f90 +++ b/src/math.f90 @@ -1133,6 +1133,7 @@ real(pReal) pure function math_areaTriangle(v1,v2,v3) real(pReal), dimension (3), intent(in) :: v1,v2,v3 + math_areaTriangle = 0.5_pReal * norm2(math_cross(v1-v2,v1-v3)) end function math_areaTriangle @@ -1147,11 +1148,13 @@ real(pReal) pure elemental function math_clip(a, left, right) real(pReal), intent(in) :: a real(pReal), intent(in), optional :: left, right + math_clip = a if (present(left)) math_clip = max(left,math_clip) if (present(right)) math_clip = min(right,math_clip) - if (present(left) .and. present(right)) & - math_clip = merge (IEEE_value(1.0_pReal,IEEE_quiet_NaN),math_clip, left>right) + if (present(left) .and. present(right)) then + if(left>right) error stop 'left > right' + endif end function math_clip @@ -1182,6 +1185,7 @@ subroutine selfTest integer :: d logical :: e + if (any(abs([1.0_pReal,2.0_pReal,2.0_pReal,3.0_pReal,3.0_pReal,3.0_pReal] - & math_expand([1.0_pReal,2.0_pReal,3.0_pReal],[1,2,3,0])) > tol_math_check)) & error stop 'math_expand [1,2,3] by [1,2,3,0] => [1,2,2,3,3,3]' From 1d623418110d5f3913c0f58e1d6f50f1683039ae Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Fri, 26 Feb 2021 03:20:28 +0100 Subject: [PATCH 315/352] Fixed missing second-to-last entry in representation list. Polished help texts. --- python/damask/_result.py | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index 6f2494299..50e2aa720 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -105,7 +105,7 @@ class Result: self.view('increments',visible_increments) in_between = '' if len(visible_increments) < 3 else \ - ''.join([f'\n{inc}\n ...\n' for inc in visible_increments[1:-2]]) + ''.join([f'\n{inc}\n ...\n' for inc in visible_increments[1:-1]]) return util.srepr(first + in_between + last) @@ -119,10 +119,10 @@ class Result: action : str Select from 'set', 'add', and 'del'. what : str - Attribute to change (must be in self.visible). + Attribute to change (must be from self.visible). datasets : list of str or bool - Name of datasets as list, supports ? and * wildcards. - True is equivalent to [*], False is equivalent to [] + Name of datasets as list; supports ? and * wildcards. + True is equivalent to [*], False is equivalent to []. """ def natural_sort(key): @@ -200,7 +200,7 @@ class Result: self._allow_modification = True def disallow_modification(self): - """Disllow to overwrite existing data (default case).""" + """Disallow to overwrite existing data (default case).""" self._allow_modification = False @@ -272,10 +272,10 @@ class Result: Parameters ---------- what : str - attribute to change (must be from self.visible) + Attribute to change (must be from self.visible). datasets : list of str or bool - name of datasets as list, supports ? and * wildcards. - True is equivalent to [*], False is equivalent to [] + Name of datasets as list; supports ? and * wildcards. + True is equivalent to [*], False is equivalent to []. """ self._manage_view('set',what,datasets) @@ -288,10 +288,10 @@ class Result: Parameters ---------- what : str - attribute to change (must be from self.visible) + Attribute to change (must be from self.visible). datasets : list of str or bool - name of datasets as list, supports ? and * wildcards. - True is equivalent to [*], False is equivalent to [] + Name of datasets as list; supports ? and * wildcards. + True is equivalent to [*], False is equivalent to []. """ self._manage_view('add',what,datasets) @@ -304,10 +304,10 @@ class Result: Parameters ---------- what : str - attribute to change (must be from self.visible) + Attribute to change (must be from self.visible). datasets : list of str or bool - name of datasets as list, supports ? and * wildcards. - True is equivalent to [*], False is equivalent to [] + Name of datasets as list; supports ? and * wildcards. + True is equivalent to [*], False is equivalent to []. """ self._manage_view('del',what,datasets) @@ -315,14 +315,14 @@ class Result: def rename(self,name_old,name_new): """ - Rename datasets. + Rename dataset. Parameters ---------- name_old : str - name of the datasets to be renamed + Name of the dataset to be renamed. name_new : str - new name of the datasets + New name of the dataset. """ if self._allow_modification: @@ -353,13 +353,13 @@ class Result: ---------- datasets : iterable or str constituent : int - Constituent to consider for phase data + Constituent to consider for phase data. tagged : bool - tag Table.column name with '#constituent' - defaults to False + Tag Table.column name with '#constituent'. + Defaults to False. split : bool - split Table by increment and return dictionary of Tables - defaults to True + Split Table by increment and return dictionary of Tables. + Defaults to True. """ sets = datasets if hasattr(datasets,'__iter__') and not isinstance(datasets,str) else \ @@ -415,7 +415,7 @@ class Result: are considered as they contain user-relevant data. Single strings will be treated as list with one entry. - Wild card matching is allowed, but the number of arguments need to fit. + Wild card matching is allowed, but the number of arguments needs to fit. Parameters ---------- From e85f12fd2f59497f5fa21041fc917a78e6cf60ac Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 26 Feb 2021 04:53:05 +0100 Subject: [PATCH 316/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-534-g1d6234181 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3a0d0e38b..a0cb6a522 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-530-g0d0226f70 +v3.0.0-alpha2-534-g1d6234181 From bf223e8e0022760d23dac7e96399891034e4ba66 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 26 Feb 2021 06:35:42 +0100 Subject: [PATCH 317/352] helpful reporting in case of errors --- python/damask/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/damask/util.py b/python/damask/util.py index cda532bc0..d39adaee9 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -133,6 +133,8 @@ def execute(cmd, stdout = stdout.decode('utf-8').replace('\x08','') stderr = stderr.decode('utf-8').replace('\x08','') if process.returncode != 0: + print(stdout) + print(stderr) raise RuntimeError(f"'{cmd}' failed with returncode {process.returncode}") return stdout, stderr @@ -418,7 +420,7 @@ class _ProgressBar: bar = '█' * filled_length + '░' * (self.bar_length - filled_length) delta_time = datetime.datetime.now() - self.start_time remaining_time = (self.total - (iteration+1)) * delta_time / (iteration+1) - remaining_time -= datetime.timedelta(microseconds=remaining_time.microseconds) # remove μs + remaining_time -= datetime.timedelta(microseconds=remaining_time.microseconds) # remove μs sys.stderr.write(f'\r{self.prefix} {bar} {fraction:>4.0%} ETA {remaining_time}') sys.stderr.flush() From 8b9b0e30b1134042c4ea63119b6b3053ff2c3967 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 26 Feb 2021 07:09:04 +0100 Subject: [PATCH 318/352] read in correct values --- src/phase_mechanical_plastic_dislotwin.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index 9398f0f6d..b151741cc 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -444,14 +444,14 @@ module function plastic_dislotwin_init() result(myPlasticity) endIndex = endIndex + prm%sum_N_tw stt%f_tw=>plasticState(ph)%state(startIndex:endIndex,:) dot%f_tw=>plasticState(ph)%dotState(startIndex:endIndex,:) - plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('f_twin',defaultVal=1.0e-7_pReal) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_f_tw',defaultVal=1.0e-7_pReal) if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' f_twin' startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_tr stt%f_tr=>plasticState(ph)%state(startIndex:endIndex,:) dot%f_tr=>plasticState(ph)%dotState(startIndex:endIndex,:) - plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('f_trans',defaultVal=1.0e-6_pReal) + plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_f_tr',defaultVal=1.0e-6_pReal) if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' f_trans' allocate(dst%Lambda_sl (prm%sum_N_sl,Nconstituents),source=0.0_pReal) From 657d43308f7523a87755344636c84639ed8c0fe5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 27 Feb 2021 10:04:08 +0100 Subject: [PATCH 319/352] standardized names --- src/phase_mechanical_plastic_dislotwin.f90 | 60 +++++++++++----------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index b151741cc..ab58e0dd9 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -445,14 +445,14 @@ module function plastic_dislotwin_init() result(myPlasticity) stt%f_tw=>plasticState(ph)%state(startIndex:endIndex,:) dot%f_tw=>plasticState(ph)%dotState(startIndex:endIndex,:) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_f_tw',defaultVal=1.0e-7_pReal) - if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' f_twin' + if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_f_tw' startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_tr stt%f_tr=>plasticState(ph)%state(startIndex:endIndex,:) dot%f_tr=>plasticState(ph)%dotState(startIndex:endIndex,:) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_f_tr',defaultVal=1.0e-6_pReal) - if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' f_trans' + if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_f_tr' allocate(dst%Lambda_sl (prm%sum_N_sl,Nconstituents),source=0.0_pReal) allocate(dst%tau_pass (prm%sum_N_sl,Nconstituents),source=0.0_pReal) @@ -536,9 +536,9 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) real(pReal), dimension(param(ph)%sum_N_sl) :: & dot_gamma_sl,ddot_gamma_dtau_slip real(pReal), dimension(param(ph)%sum_N_tw) :: & - dot_gamma_twin,ddot_gamma_dtau_twin + dot_gamma_tw,ddot_gamma_dtau_tw real(pReal), dimension(param(ph)%sum_N_tr) :: & - dot_gamma_tr,ddot_gamma_dtau_trans + dot_gamma_tr,ddot_gamma_dtau_tr real(pReal):: dot_gamma_sb real(pReal), dimension(3,3) :: eigVectors, P_sb real(pReal), dimension(3) :: eigValues @@ -579,20 +579,20 @@ module subroutine dislotwin_LpAndItsTangent(Lp,dLp_dMp,Mp,T,ph,me) + ddot_gamma_dtau_slip(i) * prm%P_sl(k,l,i) * prm%P_sl(m,n,i) enddo slipContribution - call kinetics_twin(Mp,T,dot_gamma_sl,ph,me,dot_gamma_twin,ddot_gamma_dtau_twin) + call kinetics_twin(Mp,T,dot_gamma_sl,ph,me,dot_gamma_tw,ddot_gamma_dtau_tw) twinContibution: do i = 1, prm%sum_N_tw - Lp = Lp + dot_gamma_twin(i)*prm%P_tw(1:3,1:3,i) + Lp = Lp + dot_gamma_tw(i)*prm%P_tw(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & dLp_dMp(k,l,m,n) = dLp_dMp(k,l,m,n) & - + ddot_gamma_dtau_twin(i)* prm%P_tw(k,l,i)*prm%P_tw(m,n,i) + + ddot_gamma_dtau_tw(i)* prm%P_tw(k,l,i)*prm%P_tw(m,n,i) enddo twinContibution - call kinetics_trans(Mp,T,dot_gamma_sl,ph,me,dot_gamma_tr,ddot_gamma_dtau_trans) + call kinetics_trans(Mp,T,dot_gamma_sl,ph,me,dot_gamma_tr,ddot_gamma_dtau_tr) transContibution: do i = 1, prm%sum_N_tr Lp = Lp + dot_gamma_tr(i)*prm%P_tr(1:3,1:3,i) forall (k=1:3,l=1:3,m=1:3,n=1:3) & dLp_dMp(k,l,m,n) = dLp_dMp(k,l,m,n) & - + ddot_gamma_dtau_trans(i)* prm%P_tr(k,l,i)*prm%P_tr(m,n,i) + + ddot_gamma_dtau_tr(i)* prm%P_tr(k,l,i)*prm%P_tr(m,n,i) enddo transContibution Lp = Lp * f_unrotated @@ -656,7 +656,7 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) rho_dip_distance_min, & dot_gamma_sl real(pReal), dimension(param(ph)%sum_N_tw) :: & - dot_gamma_twin + dot_gamma_tw real(pReal), dimension(param(ph)%sum_N_tr) :: & dot_gamma_tr @@ -712,8 +712,8 @@ module subroutine dislotwin_dotState(Mp,T,ph,me) - 2.0_pReal*rho_dip_distance_min/prm%b_sl * stt%rho_dip(:,me)*abs(dot_gamma_sl) & - dot_rho_dip_climb - call kinetics_twin(Mp,T,dot_gamma_sl,ph,me,dot_gamma_twin) - dot%f_tw(:,me) = f_unrotated*dot_gamma_twin/prm%gamma_char + call kinetics_twin(Mp,T,dot_gamma_sl,ph,me,dot_gamma_tw) + dot%f_tw(:,me) = f_unrotated*dot_gamma_tw/prm%gamma_char call kinetics_trans(Mp,T,dot_gamma_sl,ph,me,dot_gamma_tr) dot%f_tr(:,me) = f_unrotated*dot_gamma_tr @@ -735,7 +735,7 @@ module subroutine dislotwin_dependentState(T,ph,me) T real(pReal) :: & - sumf_twin,Gamma,sumf_trans + sumf_tw,Gamma,sumf_tr real(pReal), dimension(param(ph)%sum_N_sl) :: & inv_lambda_sl_sl, & !< 1/mean free distance between 2 forest dislocations seen by a moving dislocation inv_lambda_sl_tw, & !< 1/mean free distance between 2 twin stacks from different systems seen by a moving dislocation @@ -754,28 +754,28 @@ module subroutine dislotwin_dependentState(T,ph,me) stt => state(ph),& dst => dependentState(ph)) - sumf_twin = sum(stt%f_tw(1:prm%sum_N_tw,me)) - sumf_trans = sum(stt%f_tr(1:prm%sum_N_tr,me)) + sumf_tw = sum(stt%f_tw(1:prm%sum_N_tw,me)) + sumf_tr = sum(stt%f_tr(1:prm%sum_N_tr,me)) Gamma = prm%Gamma_sf_0K + prm%dGamma_sf_dT * T !* rescaled volume fraction for topology f_over_t_tw = stt%f_tw(1:prm%sum_N_tw,me)/prm%t_tw ! this is per system ... - f_over_t_tr = sumf_trans/prm%t_tr ! but this not + f_over_t_tr = sumf_tr/prm%t_tr ! but this not ! ToDo ...Physically correct, but naming could be adjusted inv_lambda_sl_sl = sqrt(matmul(prm%forestProjection, & stt%rho_mob(:,me)+stt%rho_dip(:,me)))/prm%i_sl if (prm%sum_N_tw > 0 .and. prm%sum_N_sl > 0) & - inv_lambda_sl_tw = matmul(prm%h_sl_tw,f_over_t_tw)/(1.0_pReal-sumf_twin) + inv_lambda_sl_tw = matmul(prm%h_sl_tw,f_over_t_tw)/(1.0_pReal-sumf_tw) - inv_lambda_tw_tw = matmul(prm%h_tw_tw,f_over_t_tw)/(1.0_pReal-sumf_twin) + inv_lambda_tw_tw = matmul(prm%h_tw_tw,f_over_t_tw)/(1.0_pReal-sumf_tw) if (prm%sum_N_tr > 0 .and. prm%sum_N_sl > 0) & - inv_lambda_sl_tr = matmul(prm%h_sl_tr,f_over_t_tr)/(1.0_pReal-sumf_trans) + inv_lambda_sl_tr = matmul(prm%h_sl_tr,f_over_t_tr)/(1.0_pReal-sumf_tr) - inv_lambda_tr_tr = matmul(prm%h_tr_tr,f_over_t_tr)/(1.0_pReal-sumf_trans) + inv_lambda_tr_tr = matmul(prm%h_tr_tr,f_over_t_tr)/(1.0_pReal-sumf_tr) if ((prm%sum_N_tw > 0) .or. (prm%sum_N_tr > 0)) then ! ToDo: better logic needed here dst%Lambda_sl(:,me) = prm%D & @@ -951,7 +951,7 @@ end subroutine kinetics_slip ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,ph,me,& - dot_gamma_twin,ddot_gamma_dtau_twin) + dot_gamma_tw,ddot_gamma_dtau_tw) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress @@ -964,9 +964,9 @@ pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,ph,me,& dot_gamma_sl real(pReal), dimension(param(ph)%sum_N_tw), intent(out) :: & - dot_gamma_twin + dot_gamma_tw real(pReal), dimension(param(ph)%sum_N_tw), optional, intent(out) :: & - ddot_gamma_dtau_twin + ddot_gamma_dtau_tw real, dimension(param(ph)%sum_N_tw) :: & tau, & @@ -998,16 +998,16 @@ pure subroutine kinetics_twin(Mp,T,dot_gamma_sl,ph,me,& significantStress: where(tau > tol_math_check) StressRatio_r = (dst%tau_hat_tw(:,me)/tau)**prm%r - dot_gamma_twin = prm%gamma_char * dst%V_tw(:,me) * Ndot0*exp(-StressRatio_r) - ddot_gamma_dtau = (dot_gamma_twin*prm%r/tau)*StressRatio_r + dot_gamma_tw = prm%gamma_char * dst%V_tw(:,me) * Ndot0*exp(-StressRatio_r) + ddot_gamma_dtau = (dot_gamma_tw*prm%r/tau)*StressRatio_r else where significantStress - dot_gamma_twin = 0.0_pReal + dot_gamma_tw = 0.0_pReal ddot_gamma_dtau = 0.0_pReal end where significantStress end associate - if(present(ddot_gamma_dtau_twin)) ddot_gamma_dtau_twin = ddot_gamma_dtau + if(present(ddot_gamma_dtau_tw)) ddot_gamma_dtau_tw = ddot_gamma_dtau end subroutine kinetics_twin @@ -1020,7 +1020,7 @@ end subroutine kinetics_twin ! have the optional arguments at the end. !-------------------------------------------------------------------------------------------------- pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,ph,me,& - dot_gamma_tr,ddot_gamma_dtau_trans) + dot_gamma_tr,ddot_gamma_dtau_tr) real(pReal), dimension(3,3), intent(in) :: & Mp !< Mandel stress @@ -1035,7 +1035,7 @@ pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,ph,me,& real(pReal), dimension(param(ph)%sum_N_tr), intent(out) :: & dot_gamma_tr real(pReal), dimension(param(ph)%sum_N_tr), optional, intent(out) :: & - ddot_gamma_dtau_trans + ddot_gamma_dtau_tr real, dimension(param(ph)%sum_N_tr) :: & tau, & @@ -1075,7 +1075,7 @@ pure subroutine kinetics_trans(Mp,T,dot_gamma_sl,ph,me,& end associate - if(present(ddot_gamma_dtau_trans)) ddot_gamma_dtau_trans = ddot_gamma_dtau + if(present(ddot_gamma_dtau_tr)) ddot_gamma_dtau_tr = ddot_gamma_dtau end subroutine kinetics_trans From d92393ab70f4c65ba85e98c1cca3fef7d76a5dc5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 27 Feb 2021 10:11:43 +0100 Subject: [PATCH 320/352] avoid accessing uninitialized data --- src/phase_mechanical_plastic_dislotwin.f90 | 27 ++++++---------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index ab58e0dd9..f479ba007 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -737,9 +737,7 @@ module subroutine dislotwin_dependentState(T,ph,me) real(pReal) :: & sumf_tw,Gamma,sumf_tr real(pReal), dimension(param(ph)%sum_N_sl) :: & - inv_lambda_sl_sl, & !< 1/mean free distance between 2 forest dislocations seen by a moving dislocation - inv_lambda_sl_tw, & !< 1/mean free distance between 2 twin stacks from different systems seen by a moving dislocation - inv_lambda_sl_tr !< 1/mean free distance between 2 martensite lamellar from different systems seen by a moving dislocation + inv_lambda_sl real(pReal), dimension(param(ph)%sum_N_tw) :: & inv_lambda_tw_tw, & !< 1/mean free distance between 2 twin stacks from different systems seen by a growing twin f_over_t_tw @@ -764,28 +762,17 @@ module subroutine dislotwin_dependentState(T,ph,me) f_over_t_tr = sumf_tr/prm%t_tr ! but this not ! ToDo ...Physically correct, but naming could be adjusted - inv_lambda_sl_sl = sqrt(matmul(prm%forestProjection, & - stt%rho_mob(:,me)+stt%rho_dip(:,me)))/prm%i_sl - + inv_lambda_sl = sqrt(matmul(prm%forestProjection,stt%rho_mob(:,me)+stt%rho_dip(:,me)))/prm%i_sl if (prm%sum_N_tw > 0 .and. prm%sum_N_sl > 0) & - inv_lambda_sl_tw = matmul(prm%h_sl_tw,f_over_t_tw)/(1.0_pReal-sumf_tw) + inv_lambda_sl = inv_lambda_sl + matmul(prm%h_sl_tw,f_over_t_tw)/(1.0_pReal-sumf_tw) + if (prm%sum_N_tr > 0 .and. prm%sum_N_sl > 0) & + inv_lambda_sl = inv_lambda_sl + matmul(prm%h_sl_tr,f_over_t_tr)/(1.0_pReal-sumf_tr) + dst%Lambda_sl(:,me) = prm%D / (1.0_pReal+prm%D*inv_lambda_sl) inv_lambda_tw_tw = matmul(prm%h_tw_tw,f_over_t_tw)/(1.0_pReal-sumf_tw) - - if (prm%sum_N_tr > 0 .and. prm%sum_N_sl > 0) & - inv_lambda_sl_tr = matmul(prm%h_sl_tr,f_over_t_tr)/(1.0_pReal-sumf_tr) + dst%Lambda_tw(:,me) = prm%i_tw*prm%D/(1.0_pReal+prm%D*inv_lambda_tw_tw) inv_lambda_tr_tr = matmul(prm%h_tr_tr,f_over_t_tr)/(1.0_pReal-sumf_tr) - - if ((prm%sum_N_tw > 0) .or. (prm%sum_N_tr > 0)) then ! ToDo: better logic needed here - dst%Lambda_sl(:,me) = prm%D & - / (1.0_pReal+prm%D*(inv_lambda_sl_sl + inv_lambda_sl_tw + inv_lambda_sl_tr)) - else - dst%Lambda_sl(:,me) = prm%D & - / (1.0_pReal+prm%D*inv_lambda_sl_sl) !!!!!! correct? - endif - - dst%Lambda_tw(:,me) = prm%i_tw*prm%D/(1.0_pReal+prm%D*inv_lambda_tw_tw) dst%Lambda_tr(:,me) = prm%i_tr*prm%D/(1.0_pReal+prm%D*inv_lambda_tr_tr) !* threshold stress for dislocation motion From ea763fd941e86e979fbc82aba1ce3b313d6d54f7 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Sat, 27 Feb 2021 11:15:01 -0500 Subject: [PATCH 321/352] generalized stereographic projection to cope with all three directions (x,y,Z) --- python/damask/util.py | 15 ++++++++++----- python/tests/test_util.py | 18 +++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/python/damask/util.py b/python/damask/util.py index cda532bc0..6f148c418 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -193,7 +193,7 @@ def scale_to_coprime(v): return m -def project_stereographic(vector,normalize=False): +def project_stereographic(vector,normalize=False,direction='z'): """ Apply stereographic projection to vector. @@ -203,16 +203,21 @@ def project_stereographic(vector,normalize=False): Vector coordinates to be projected. normalize : bool Ensure unit length for vector. Defaults to False. + direction : str or int + Projection direction 'x'|0, 'y'|1, or 'z'|2. + Defaults to 'z'. Returns ------- - coordinates : numpy.ndarray of shape (...,2) + coordinates : numpy.ndarray of shape (...,3) Projected coordinates. """ - v_ = vector/np.linalg.norm(vector,axis=-1,keepdims=True) if normalize else vector - return np.block([v_[...,:2]/(1+np.abs(v_[...,2:3])), - np.zeros_like(v_[...,2:3])]) + shift = 2-('xyzXYZ'.index(direction)%3 if isinstance(direction,str) else int(direction)) + v_ = np.roll(vector/np.linalg.norm(vector,axis=-1,keepdims=True) if normalize else vector, + shift,axis=-1) + return np.roll(np.block([v_[...,:2]/(1+np.abs(v_[...,2:3])),np.zeros_like(v_[...,2:3])]), + -shift,axis=-1) def execution_stamp(class_name,function_name=None): diff --git a/python/tests/test_util.py b/python/tests/test_util.py index eb1084b09..3b0052070 100644 --- a/python/tests/test_util.py +++ b/python/tests/test_util.py @@ -49,17 +49,17 @@ class TestUtil: dist_sampled = np.histogram(centers[selected],bins)[0]/N_samples*np.sum(dist) assert np.sqrt(((dist - dist_sampled) ** 2).mean()) < .025 and selected.shape[0]==N_samples - @pytest.mark.parametrize('point,normalize,answer', + @pytest.mark.parametrize('point,normalize,direction,answer', [ - ([1,0,0],False,[1,0,0]), - ([1,0,0],True, [1,0,0]), - ([0,1,1],False,[0,0.5,0]), - ([0,1,1],True, [0,0.41421356,0]), - ([1,1,1],False,[0.5,0.5,0]), - ([1,1,1],True, [0.3660254, 0.3660254, 0]), + ([1,0,0],False,'z',[1,0,0]), + ([1,0,0],True, 'z',[1,0,0]), + ([0,1,1],False,'z',[0,0.5,0]), + ([0,1,1],True, 'y',[0,0,0.41421356]), + ([1,1,1],False,'x',[0,0.5,0.5]), + ([1,1,1],True, 'y',[0.3660254, 0,0.3660254]), ]) - def test_project_stereographic(self,point,normalize,answer): - assert np.allclose(util.project_stereographic(np.array(point),normalize=normalize),answer) + def test_project_stereographic(self,point,normalize,direction,answer): + assert np.allclose(util.project_stereographic(np.array(point),normalize=normalize,direction=direction),answer) @pytest.mark.parametrize('fro,to,mode,answer', [ From 175d724dedf9b05c176ee0c7d828fe825d163bd4 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Sat, 27 Feb 2021 18:32:53 -0500 Subject: [PATCH 322/352] added keepdims=False option to project_stereographic --- python/damask/util.py | 26 ++++++++++++++++++++------ python/tests/test_util.py | 19 ++++++++++--------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/python/damask/util.py b/python/damask/util.py index 6f148c418..951eb921e 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -193,7 +193,7 @@ def scale_to_coprime(v): return m -def project_stereographic(vector,normalize=False,direction='z'): +def project_stereographic(vector,direction='z',normalize=True,keepdims=False): """ Apply stereographic projection to vector. @@ -201,23 +201,37 @@ def project_stereographic(vector,normalize=False,direction='z'): ---------- vector : numpy.ndarray of shape (...,3) Vector coordinates to be projected. - normalize : bool - Ensure unit length for vector. Defaults to False. direction : str or int - Projection direction 'x'|0, 'y'|1, or 'z'|2. + Projection direction 'x' | 0, 'y' | 1, or 'z' | 2. Defaults to 'z'. + normalize : bool + Ensure unit length of input vector. Defaults to True. + keepdims : bool + Maintain three-dimensional output coordinates. + Default two-dimensional output uses right-handed frame spanned by + the next and next-next axis relative to the projection direction, + e.g. x-y when projecting along z and z-x when projecting along y. Returns ------- - coordinates : numpy.ndarray of shape (...,3) + coordinates : numpy.ndarray of shape (...,2 | 3) Projected coordinates. + Examples + -------- + >>> project_stereographic(np.ones(3)) + [0.3660254, 0.3660254] + >>> project_stereographic(np.ones(3),direction='x',normalize=False,keepdims=True) + [0, 0.5, 0.5] + >>> project_stereographic([0,1,1],direction='y',normalize=True,keepdims=False) + [0.41421356, 0] + """ shift = 2-('xyzXYZ'.index(direction)%3 if isinstance(direction,str) else int(direction)) v_ = np.roll(vector/np.linalg.norm(vector,axis=-1,keepdims=True) if normalize else vector, shift,axis=-1) return np.roll(np.block([v_[...,:2]/(1+np.abs(v_[...,2:3])),np.zeros_like(v_[...,2:3])]), - -shift,axis=-1) + -shift if keepdims else 0,axis=-1)[...,:3 if keepdims else 2] def execution_stamp(class_name,function_name=None): diff --git a/python/tests/test_util.py b/python/tests/test_util.py index 3b0052070..397926682 100644 --- a/python/tests/test_util.py +++ b/python/tests/test_util.py @@ -49,17 +49,18 @@ class TestUtil: dist_sampled = np.histogram(centers[selected],bins)[0]/N_samples*np.sum(dist) assert np.sqrt(((dist - dist_sampled) ** 2).mean()) < .025 and selected.shape[0]==N_samples - @pytest.mark.parametrize('point,normalize,direction,answer', + @pytest.mark.parametrize('point,direction,normalize,keepdims,answer', [ - ([1,0,0],False,'z',[1,0,0]), - ([1,0,0],True, 'z',[1,0,0]), - ([0,1,1],False,'z',[0,0.5,0]), - ([0,1,1],True, 'y',[0,0,0.41421356]), - ([1,1,1],False,'x',[0,0.5,0.5]), - ([1,1,1],True, 'y',[0.3660254, 0,0.3660254]), + ([1,0,0],'z',False,True, [1,0,0]), + ([1,0,0],'z',True, False,[1,0]), + ([0,1,1],'z',False,True, [0,0.5,0]), + ([0,1,1],'y',True, False,[0.41421356,0]), + ([1,1,0],'x',False,False,[0.5,0]), + ([1,1,1],'y',True, True, [0.3660254, 0,0.3660254]), ]) - def test_project_stereographic(self,point,normalize,direction,answer): - assert np.allclose(util.project_stereographic(np.array(point),normalize=normalize,direction=direction),answer) + def test_project_stereographic(self,point,direction,normalize,keepdims,answer): + assert np.allclose(util.project_stereographic(np.array(point),direction=direction, + normalize=normalize,keepdims=keepdims),answer) @pytest.mark.parametrize('fro,to,mode,answer', [ From c483dc609fdacebdba9cffdb3c74ee08f071f418 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 28 Feb 2021 10:08:16 +0100 Subject: [PATCH 323/352] common name --- src/homogenization.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 5078f0a09..52e90a857 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -520,14 +520,14 @@ function damage_nonlocal_getDiffusion(ce) damage_nonlocal_getDiffusion integer :: & ho, & - grain + co ho = material_homogenizationAt2(ce) damage_nonlocal_getDiffusion = 0.0_pReal - do grain = 1, homogenization_Nconstituents(ho) + do co = 1, homogenization_Nconstituents(ho) damage_nonlocal_getDiffusion = damage_nonlocal_getDiffusion + & - crystallite_push33ToRef(grain,ce,lattice_D(1:3,1:3,material_phaseAt2(grain,ce))) + crystallite_push33ToRef(co,ce,lattice_D(1:3,1:3,material_phaseAt2(co,ce))) enddo damage_nonlocal_getDiffusion = & From 464c62e7e707468e598bb47396b18965331bd7fc Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Sat, 27 Feb 2021 18:46:20 -0500 Subject: [PATCH 324/352] abandoned integer aliases for projection directions --- python/damask/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/damask/util.py b/python/damask/util.py index 951eb921e..61ec5e5cb 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -201,8 +201,8 @@ def project_stereographic(vector,direction='z',normalize=True,keepdims=False): ---------- vector : numpy.ndarray of shape (...,3) Vector coordinates to be projected. - direction : str or int - Projection direction 'x' | 0, 'y' | 1, or 'z' | 2. + direction : str + Projection direction 'x', 'y', or 'z'. Defaults to 'z'. normalize : bool Ensure unit length of input vector. Defaults to True. @@ -227,7 +227,7 @@ def project_stereographic(vector,direction='z',normalize=True,keepdims=False): [0.41421356, 0] """ - shift = 2-('xyzXYZ'.index(direction)%3 if isinstance(direction,str) else int(direction)) + shift = 'zyx'.index(direction) v_ = np.roll(vector/np.linalg.norm(vector,axis=-1,keepdims=True) if normalize else vector, shift,axis=-1) return np.roll(np.block([v_[...,:2]/(1+np.abs(v_[...,2:3])),np.zeros_like(v_[...,2:3])]), From dc50400863306069ddb86332160af315d5de5094 Mon Sep 17 00:00:00 2001 From: Test User Date: Sun, 28 Feb 2021 13:26:39 +0100 Subject: [PATCH 325/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-548-gc483dc609 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a0cb6a522..83ef4eefa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-534-g1d6234181 +v3.0.0-alpha2-548-gc483dc609 From 1be6950c0b9d66e9f30b4e8ae4da786c772e5066 Mon Sep 17 00:00:00 2001 From: Test User Date: Sun, 28 Feb 2021 16:32:50 +0100 Subject: [PATCH 326/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-553-g2691ef211 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 83ef4eefa..e41ad05a9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-548-gc483dc609 +v3.0.0-alpha2-553-g2691ef211 From 4dd99d4c39e3473e9f6146b0f4812ca14b4d0b0e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 28 Feb 2021 19:13:20 +0100 Subject: [PATCH 327/352] solver is selected in load case, not numerics.yaml --- PRIVATE | 2 +- src/grid/DAMASK_grid.f90 | 34 +++++++++----------- src/grid/grid_mech_spectral_polarisation.f90 | 2 +- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/PRIVATE b/PRIVATE index 0289c1bbf..738526ac7 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 0289c1bbfec1a1aef77a8cbaeed134035549e738 +Subproject commit 738526ac7ae63678c885faba7621782499f2bce9 diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index d250e2f53..e0eaef892 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -78,8 +78,7 @@ program DAMASK_grid maxCutBack, & !< max number of cut backs stagItMax !< max number of field level staggered iterations character(len=pStringLen) :: & - incInfo, & - loadcase_string + incInfo type(tLoadCase), allocatable, dimension(:) :: loadCases !< array of all load cases type(tSolutionState), allocatable, dimension(:) :: solres @@ -98,10 +97,10 @@ program DAMASK_grid quit class (tNode), pointer :: & num_grid, & - debug_grid, & ! pointer to grid debug options config_load, & load_steps, & load_step, & + solver, & step_bc, & step_mech, & step_discretization, & @@ -117,12 +116,6 @@ program DAMASK_grid print*, 'Shanthraj et al., Handbook of Mechanics of Materials, 2019' print*, 'https://doi.org/10.1007/978-981-10-6855-3_80' -!-------------------------------------------------------------------------------------------------- -! initialize field solver information - nActiveFields = 1 - if (any(thermal_type == THERMAL_conduction_ID )) nActiveFields = nActiveFields + 1 - if (any(damage_type == DAMAGE_nonlocal_ID )) nActiveFields = nActiveFields + 1 - allocate(solres(nActiveFields)) !------------------------------------------------------------------------------------------------- ! reading field paramters from numerics file and do sanity checks @@ -132,20 +125,23 @@ program DAMASK_grid if (stagItMax < 0) call IO_error(301,ext_msg='maxStaggeredIter') if (maxCutBack < 0) call IO_error(301,ext_msg='maxCutBack') + + config_load => YAML_parse_file(trim(interface_loadFile)) + solver => config_load%get('solver') !-------------------------------------------------------------------------------------------------- ! assign mechanics solver depending on selected type - debug_grid => config_debug%get('grid',defaultVal=emptyList) - select case (trim(num_grid%get_asString('solver', defaultVal = 'Basic'))) - case ('Basic') + nActiveFields = 1 + select case (solver%get_asString('mechanical')) + case ('spectral_basic') mechanical_init => grid_mechanical_spectral_basic_init mechanical_forward => grid_mechanical_spectral_basic_forward mechanical_solution => grid_mechanical_spectral_basic_solution mechanical_updateCoords => grid_mechanical_spectral_basic_updateCoords mechanical_restartWrite => grid_mechanical_spectral_basic_restartWrite - case ('Polarisation') + case ('spectral_polarization') mechanical_init => grid_mechanical_spectral_polarisation_init mechanical_forward => grid_mechanical_spectral_polarisation_forward mechanical_solution => grid_mechanical_spectral_polarisation_solution @@ -160,14 +156,17 @@ program DAMASK_grid mechanical_restartWrite => grid_mechanical_FEM_restartWrite case default - call IO_error(error_ID = 891, ext_msg = trim(num_grid%get_asString('solver'))) + call IO_error(error_ID = 891, ext_msg = trim(solver%get_asString('mechanical'))) end select +!-------------------------------------------------------------------------------------------------- +! initialize field solver information + if (any(thermal_type == THERMAL_conduction_ID )) nActiveFields = nActiveFields + 1 + if (any(damage_type == DAMAGE_nonlocal_ID )) nActiveFields = nActiveFields + 1 + allocate(solres(nActiveFields)) !-------------------------------------------------------------------------------------------------- -! reading information from load case file and to sanity checks - config_load => YAML_parse_file(trim(interface_loadFile)) load_steps => config_load%get('loadstep') allocate(loadCases(load_steps%length)) ! array of load cases @@ -232,7 +231,6 @@ program DAMASK_grid merge(.true.,.false.,l > 1)) reportAndCheck: if (worldrank == 0) then - write (loadcase_string, '(i0)' ) l print'(/,a,i0)', ' load case: ', l print*, ' estimate_rate:', loadCases(l)%estimate_rate if (loadCases(l)%deformation%myType == 'L') then @@ -292,7 +290,7 @@ program DAMASK_grid if (loadCases(l)%f_restart < huge(0)) & print'(a,i0)', ' f_restart: ', loadCases(l)%f_restart - if (errorID > 0) call IO_error(error_ID = errorID, ext_msg = loadcase_string) ! exit with error message + if (errorID > 0) call IO_error(error_ID = errorID, el = l) endif reportAndCheck enddo diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index 8caf41b31..31f69b4c5 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -116,7 +116,7 @@ subroutine grid_mechanical_spectral_polarisation_init num_grid, & debug_grid - print'(/,a)', ' <<<+- grid_mechanical_spectral_polarisation init -+>>>'; flush(IO_STDOUT) + print'(/,a)', ' <<<+- grid_mechanical_spectral_polarization init -+>>>'; flush(IO_STDOUT) print*, 'Shanthraj et al., International Journal of Plasticity 66:31–45, 2015' print*, 'https://doi.org/10.1016/j.ijplas.2014.02.006' From b2fea6b149a74511c3c5018137abb2a96945cea7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 28 Feb 2021 19:24:44 +0100 Subject: [PATCH 328/352] solver not specific to load case number --- src/grid/DAMASK_grid.f90 | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index e0eaef892..36ebf51a3 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -37,8 +37,9 @@ program DAMASK_grid f_out, & !< frequency of result writes f_restart !< frequency of restart writes logical :: estimate_rate !< follow trajectory of former loadcase - integer(kind(FIELD_UNDEFINED_ID)), allocatable :: ID(:) end type tLoadCase + + integer(kind(FIELD_UNDEFINED_ID)), allocatable :: ID(:) !-------------------------------------------------------------------------------------------------- ! variables related to information from load case and geom file @@ -165,6 +166,19 @@ program DAMASK_grid if (any(thermal_type == THERMAL_conduction_ID )) nActiveFields = nActiveFields + 1 if (any(damage_type == DAMAGE_nonlocal_ID )) nActiveFields = nActiveFields + 1 allocate(solres(nActiveFields)) + + allocate(ID(nActiveFields)) + field = 1 + ID(field) = FIELD_MECH_ID ! mechanical active by default + thermalActive: if (any(thermal_type == THERMAL_conduction_ID)) then + field = field + 1 + ID(field) = FIELD_THERMAL_ID + endif thermalActive + damageActive: if (any(damage_type == DAMAGE_nonlocal_ID)) then + field = field + 1 + ID(field) = FIELD_DAMAGE_ID + endif damageActive + !-------------------------------------------------------------------------------------------------- @@ -173,18 +187,6 @@ program DAMASK_grid do l = 1, load_steps%length - allocate(loadCases(l)%ID(nActiveFields)) - field = 1 - loadCases(l)%ID(field) = FIELD_MECH_ID ! mechanical active by default - thermalActive: if (any(thermal_type == THERMAL_conduction_ID)) then - field = field + 1 - loadCases(l)%ID(field) = FIELD_THERMAL_ID - endif thermalActive - damageActive: if (any(damage_type == DAMAGE_nonlocal_ID)) then - field = field + 1 - loadCases(l)%ID(field) = FIELD_DAMAGE_ID - endif damageActive - load_step => load_steps%get(l) step_bc => load_step%get('boundary_conditions') step_mech => step_bc%get('mechanical') @@ -299,7 +301,7 @@ program DAMASK_grid ! doing initialization depending on active solvers call spectral_Utilities_init do field = 1, nActiveFields - select case (loadCases(1)%ID(field)) + select case (ID(field)) case(FIELD_MECH_ID) call mechanical_init @@ -375,7 +377,7 @@ program DAMASK_grid !-------------------------------------------------------------------------------------------------- ! forward fields do field = 1, nActiveFields - select case(loadCases(l)%ID(field)) + select case(ID(field)) case(FIELD_MECH_ID) call mechanical_forward (& cutBack,guess,timeinc,timeIncOld,remainingLoadCaseTime, & @@ -395,7 +397,7 @@ program DAMASK_grid stagIterate = .true. do while (stagIterate) do field = 1, nActiveFields - select case(loadCases(l)%ID(field)) + select case(ID(field)) case(FIELD_MECH_ID) solres(field) = mechanical_solution(incInfo) case(FIELD_THERMAL_ID) From ef543a5b4970d7fd49b26a3bed72939bed393936 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 28 Feb 2021 20:06:31 +0100 Subject: [PATCH 329/352] thermal solver is defined in load case not in numerics.yaml --- src/CPFEM.f90 | 10 +++++----- src/grid/DAMASK_grid.f90 | 4 ++-- src/homogenization.f90 | 14 ++++++-------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/CPFEM.f90 b/src/CPFEM.f90 index f0e510433..01b4c034d 100644 --- a/src/CPFEM.f90 +++ b/src/CPFEM.f90 @@ -178,11 +178,11 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature_inp, dt, elFE, ip, cauchyS if (iand(mode, CPFEM_AGERESULTS) /= 0_pInt) call CPFEM_forward - chosenThermal1: select case (thermal_type(material_homogenizationAt(elCP))) - !case (THERMAL_conduction_ID) chosenThermal1 - ! temperature(material_homogenizationAt(elCP))%p(material_homogenizationMemberAt(ip,elCP)) = & - ! temperature_inp - end select chosenThermal1 + !chosenThermal1: select case (thermal_type(material_homogenizationAt(elCP))) + ! case (THERMAL_conduction_ID) chosenThermal1 + ! temperature(material_homogenizationAt(elCP))%p(material_homogenizationMemberAt(ip,elCP)) = & + ! temperature_inp + !end select chosenThermal1 homogenization_F0(1:3,1:3,ma) = ffn homogenization_F(1:3,1:3,ma) = ffn1 diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 36ebf51a3..7155a5c80 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -163,14 +163,14 @@ program DAMASK_grid !-------------------------------------------------------------------------------------------------- ! initialize field solver information - if (any(thermal_type == THERMAL_conduction_ID )) nActiveFields = nActiveFields + 1 + if (solver%get_asString('thermal',defaultVal = 'n/a') == 'spectral') nActiveFields = nActiveFields + 1 if (any(damage_type == DAMAGE_nonlocal_ID )) nActiveFields = nActiveFields + 1 allocate(solres(nActiveFields)) allocate(ID(nActiveFields)) field = 1 ID(field) = FIELD_MECH_ID ! mechanical active by default - thermalActive: if (any(thermal_type == THERMAL_conduction_ID)) then + thermalActive: if (solver%get_asString('thermal',defaultVal = 'n/a') == 'spectral') then field = field + 1 ID(field) = FIELD_THERMAL_ID endif thermalActive diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 52e90a857..7c0c1531b 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -39,11 +39,11 @@ module homogenization real(pReal), dimension(:), allocatable, public, protected :: & thermal_initialT - integer(kind(THERMAL_isothermal_ID)), dimension(:), allocatable, public, protected :: & + integer(kind(THERMAL_isothermal_ID)), dimension(:), allocatable :: & thermal_type !< thermal transport model integer(kind(DAMAGE_none_ID)), dimension(:), allocatable, public, protected :: & damage_type !< nonlocal damage model - integer(kind(HOMOGENIZATION_undefined_ID)), dimension(:), allocatable, public, protected :: & + integer(kind(HOMOGENIZATION_undefined_ID)), dimension(:), allocatable :: & homogenization_type !< type of each homogenization type, private :: tNumerics_damage @@ -553,10 +553,10 @@ subroutine material_parseHomogenization material_homogenization => config_material%get('homogenization') - allocate(homogenization_type(size(material_name_homogenization)), source=HOMOGENIZATION_undefined_ID) - allocate(thermal_type(size(material_name_homogenization)), source=THERMAL_isothermal_ID) - allocate(damage_type (size(material_name_homogenization)), source=DAMAGE_none_ID) - allocate(thermal_initialT(size(material_name_homogenization)), source=300.0_pReal) + allocate(homogenization_type(size(material_name_homogenization)), source=HOMOGENIZATION_undefined_ID) + allocate(thermal_type(size(material_name_homogenization)), source=THERMAL_isothermal_ID) + allocate(damage_type (size(material_name_homogenization)), source=DAMAGE_none_ID) + allocate(thermal_initialT(size(material_name_homogenization)), source=300.0_pReal) do h=1, size(material_name_homogenization) homog => material_homogenization%get(h) @@ -578,8 +578,6 @@ subroutine material_parseHomogenization thermal_initialT(h) = homogThermal%get_asFloat('T_0',defaultVal=300.0_pReal) select case (homogThermal%get_asString('type')) - case('isothermal') - thermal_type(h) = THERMAL_isothermal_ID case('conduction') thermal_type(h) = THERMAL_conduction_ID case default From ae57ba9707c774ad133a22ef35ec702073dd4486 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 28 Feb 2021 20:10:12 +0100 Subject: [PATCH 330/352] got random errors 'O not found' might be related to use of pointers in openMP. Not nice, but openMP during initialization is not really required --- src/phase_mechanical.f90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index be14c57e6..c934fed72 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -279,7 +279,6 @@ module subroutine mechanical_init(materials,phases) endif - !$OMP PARALLEL DO PRIVATE(ph,me,material,constituents,constituent) do el = 1, size(material_phaseMemberAt,3); do ip = 1, size(material_phaseMemberAt,2) do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) material => materials%get(discretization_materialAt(el)) @@ -305,7 +304,6 @@ module subroutine mechanical_init(materials,phases) enddo enddo; enddo - !$OMP END PARALLEL DO ! initialize plasticity From 0cde43198f5fdc89bc817dc5243c8cd9d7da669b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 28 Feb 2021 20:49:51 +0100 Subject: [PATCH 331/352] modernizing: - 'pass' for dummy thermal homogenization - setting temperature in load case --- PRIVATE | 2 +- src/grid/DAMASK_grid.f90 | 14 ++++++++++++-- src/grid/grid_thermal_spectral.f90 | 4 +++- src/homogenization.f90 | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/PRIVATE b/PRIVATE index 738526ac7..23ef2dcf3 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 738526ac7ae63678c885faba7621782499f2bce9 +Subproject commit 23ef2dcf34729c8b05caba62f648149ca37a68c9 diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 7155a5c80..0461b43d9 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -54,6 +54,7 @@ program DAMASK_grid integer, parameter :: & subStepFactor = 2 !< for each substep, divide the last time increment by 2.0 real(pReal) :: & + T_0 = 273.0_pReal, & time = 0.0_pReal, & !< elapsed time time0 = 0.0_pReal, & !< begin of interval timeinc = 1.0_pReal, & !< current time interval @@ -102,6 +103,9 @@ program DAMASK_grid load_steps, & load_step, & solver, & + initial_conditions, & + ic_thermal, & + thermal, & step_bc, & step_mech, & step_discretization, & @@ -181,7 +185,6 @@ program DAMASK_grid !-------------------------------------------------------------------------------------------------- - load_steps => config_load%get('loadstep') allocate(loadCases(load_steps%length)) ! array of load cases @@ -306,7 +309,14 @@ program DAMASK_grid call mechanical_init case(FIELD_THERMAL_ID) - call grid_thermal_spectral_init + if (solver%contains('initial_conditions')) then + initial_conditions => solver%get('initial_conditions') + if (initial_conditions%contains('thermal')) then + thermal => solver%get('thermal') + T_0 = thermal%get_asFloat('thermal',defaultVal = T_0) + endif + endif + call grid_thermal_spectral_init(T_0) case(FIELD_DAMAGE_ID) call grid_damage_spectral_init diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 6403ee955..40a84a02e 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -61,7 +61,9 @@ contains !> @brief allocates all neccessary fields and fills them with data ! ToDo: Restart not implemented !-------------------------------------------------------------------------------------------------- -subroutine grid_thermal_spectral_init +subroutine grid_thermal_spectral_init(T_0) + + real(pReal), intent(in) :: T_0 PetscInt, dimension(0:worldsize-1) :: localK integer :: i, j, k, ce diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 7c0c1531b..1572a0197 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -578,7 +578,7 @@ subroutine material_parseHomogenization thermal_initialT(h) = homogThermal%get_asFloat('T_0',defaultVal=300.0_pReal) select case (homogThermal%get_asString('type')) - case('conduction') + case('pass') thermal_type(h) = THERMAL_conduction_ID case default call IO_error(500,ext_msg=homogThermal%get_asString('type')) From 8af0c8dbc30aa067a94de19427b454cd9dba90b9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 28 Feb 2021 21:51:07 +0100 Subject: [PATCH 332/352] using initial temperature from load case file --- PRIVATE | 2 +- src/grid/DAMASK_grid.f90 | 10 +++++----- src/grid/grid_thermal_spectral.f90 | 3 ++- src/homogenization.f90 | 6 ------ src/homogenization_thermal.f90 | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/PRIVATE b/PRIVATE index 23ef2dcf3..89eb15f1d 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 23ef2dcf34729c8b05caba62f648149ca37a68c9 +Subproject commit 89eb15f1d771279be8ff444202c32b6797e77bd7 diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 0461b43d9..3930e0002 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -54,7 +54,7 @@ program DAMASK_grid integer, parameter :: & subStepFactor = 2 !< for each substep, divide the last time increment by 2.0 real(pReal) :: & - T_0 = 273.0_pReal, & + T_0 = 300.0_pReal, & time = 0.0_pReal, & !< elapsed time time0 = 0.0_pReal, & !< begin of interval timeinc = 1.0_pReal, & !< current time interval @@ -309,11 +309,11 @@ program DAMASK_grid call mechanical_init case(FIELD_THERMAL_ID) - if (solver%contains('initial_conditions')) then - initial_conditions => solver%get('initial_conditions') + if (config_load%contains('initial_conditions')) then + initial_conditions => config_load%get('initial_conditions') if (initial_conditions%contains('thermal')) then - thermal => solver%get('thermal') - T_0 = thermal%get_asFloat('thermal',defaultVal = T_0) + thermal => initial_conditions%get('thermal') + T_0 = thermal%get_asFloat('T',defaultVal = T_0) endif endif call grid_thermal_spectral_init(T_0) diff --git a/src/grid/grid_thermal_spectral.f90 b/src/grid/grid_thermal_spectral.f90 index 40a84a02e..5ac043a67 100644 --- a/src/grid/grid_thermal_spectral.f90 +++ b/src/grid/grid_thermal_spectral.f90 @@ -133,9 +133,10 @@ subroutine grid_thermal_spectral_init(T_0) ce = 0 do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1) ce = ce + 1 - T_current(i,j,k) = homogenization_thermal_T(ce) + T_current(i,j,k) = T_0 T_lastInc(i,j,k) = T_current(i,j,k) T_stagInc(i,j,k) = T_current(i,j,k) + call homogenization_thermal_setField(T_0,0.0_pReal,ce) enddo; enddo; enddo call DMDAVecGetArrayF90(thermal_grid,solution_vec,x_scal,ierr); CHKERRQ(ierr) !< get the data out of PETSc to work with x_scal(xstart:xend,ystart:yend,zstart:zend) = T_current diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 1572a0197..d5fdbd5cb 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -35,10 +35,6 @@ module homogenization homogState, & damageState_h - - real(pReal), dimension(:), allocatable, public, protected :: & - thermal_initialT - integer(kind(THERMAL_isothermal_ID)), dimension(:), allocatable :: & thermal_type !< thermal transport model integer(kind(DAMAGE_none_ID)), dimension(:), allocatable, public, protected :: & @@ -556,7 +552,6 @@ subroutine material_parseHomogenization allocate(homogenization_type(size(material_name_homogenization)), source=HOMOGENIZATION_undefined_ID) allocate(thermal_type(size(material_name_homogenization)), source=THERMAL_isothermal_ID) allocate(damage_type (size(material_name_homogenization)), source=DAMAGE_none_ID) - allocate(thermal_initialT(size(material_name_homogenization)), source=300.0_pReal) do h=1, size(material_name_homogenization) homog => material_homogenization%get(h) @@ -575,7 +570,6 @@ subroutine material_parseHomogenization if(homog%contains('thermal')) then homogThermal => homog%get('thermal') - thermal_initialT(h) = homogThermal%get_asFloat('T_0',defaultVal=300.0_pReal) select case (homogThermal%get_asString('type')) case('pass') diff --git a/src/homogenization_thermal.f90 b/src/homogenization_thermal.f90 index 928bd547b..efb6e7b58 100644 --- a/src/homogenization_thermal.f90 +++ b/src/homogenization_thermal.f90 @@ -44,7 +44,7 @@ module subroutine thermal_init() allocate(current(configHomogenizations%length)) do ho = 1, configHomogenizations%length - allocate(current(ho)%T(count(material_homogenizationAt2==ho)), source=thermal_initialT(ho)) + allocate(current(ho)%T(count(material_homogenizationAt2==ho)), source=300.0_pReal) allocate(current(ho)%dot_T(count(material_homogenizationAt2==ho)), source=0.0_pReal) configHomogenization => configHomogenizations%get(ho) associate(prm => param(ho)) From e7979c2223aeade8d92ab3fb7f2cd13768523fcf Mon Sep 17 00:00:00 2001 From: Test User Date: Sun, 28 Feb 2021 22:19:40 +0100 Subject: [PATCH 333/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-572-g7b89cb41f --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index e41ad05a9..4ebc52387 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-553-g2691ef211 +v3.0.0-alpha2-572-g7b89cb41f From 2f68c43755ca3af45dc01701789a732b868adcbd Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 1 Mar 2021 06:16:16 +0100 Subject: [PATCH 334/352] new style configuration for damage --- PRIVATE | 2 +- src/grid/DAMASK_grid.f90 | 4 ++-- src/homogenization.f90 | 6 ++---- src/material.f90 | 4 ++-- src/phase_mechanical_plastic_nonlocal.f90 | 15 ++++++--------- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/PRIVATE b/PRIVATE index 89eb15f1d..08e226ec7 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 89eb15f1d771279be8ff444202c32b6797e77bd7 +Subproject commit 08e226ec735589123dd67f3e0a5bc447c3dda812 diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 3930e0002..fda9d7b9a 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -168,7 +168,7 @@ program DAMASK_grid !-------------------------------------------------------------------------------------------------- ! initialize field solver information if (solver%get_asString('thermal',defaultVal = 'n/a') == 'spectral') nActiveFields = nActiveFields + 1 - if (any(damage_type == DAMAGE_nonlocal_ID )) nActiveFields = nActiveFields + 1 + if (solver%get_asString('damage', defaultVal = 'n/a') == 'spectral') nActiveFields = nActiveFields + 1 allocate(solres(nActiveFields)) allocate(ID(nActiveFields)) @@ -178,7 +178,7 @@ program DAMASK_grid field = field + 1 ID(field) = FIELD_THERMAL_ID endif thermalActive - damageActive: if (any(damage_type == DAMAGE_nonlocal_ID)) then + damageActive: if (solver%get_asString('damage',defaultVal = 'n/a') == 'spectral') then field = field + 1 ID(field) = FIELD_DAMAGE_ID endif damageActive diff --git a/src/homogenization.f90 b/src/homogenization.f90 index d5fdbd5cb..4c7200eed 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -37,7 +37,7 @@ module homogenization integer(kind(THERMAL_isothermal_ID)), dimension(:), allocatable :: & thermal_type !< thermal transport model - integer(kind(DAMAGE_none_ID)), dimension(:), allocatable, public, protected :: & + integer(kind(DAMAGE_none_ID)), dimension(:), allocatable :: & damage_type !< nonlocal damage model integer(kind(HOMOGENIZATION_undefined_ID)), dimension(:), allocatable :: & homogenization_type !< type of each homogenization @@ -582,9 +582,7 @@ subroutine material_parseHomogenization if(homog%contains('damage')) then homogDamage => homog%get('damage') select case (homogDamage%get_asString('type')) - case('none') - damage_type(h) = DAMAGE_none_ID - case('nonlocal') + case('pass') damage_type(h) = DAMAGE_nonlocal_ID case default call IO_error(500,ext_msg=homogDamage%get_asString('type')) diff --git a/src/material.f90 b/src/material.f90 index c7d24b6f0..aecfaa1dd 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -17,7 +17,7 @@ module material private integer, dimension(:), allocatable, public, protected :: & - homogenization_Nconstituents !< number of grains in each homogenization + homogenization_Nconstituents !< number of grains in each homogenization character(len=:), public, protected, allocatable, dimension(:) :: & material_name_phase, & !< name of each phase @@ -30,7 +30,7 @@ module material material_homogenizationAt, & !< homogenization ID of each element material_homogenizationAt2, & !< per cell material_homogenizationMemberAt2 !< cell - integer, dimension(:,:), allocatable, public, protected :: & ! (ip,elem) + integer, dimension(:,:), allocatable :: & ! (ip,elem) material_homogenizationMemberAt !< position of the element within its homogenization instance integer, dimension(:,:), allocatable, public, protected :: & ! (constituent,elem) material_phaseAt, & !< phase ID of each element diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 601618425..464e57339 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -1822,16 +1822,13 @@ subroutine storeGeometry(ph) integer, intent(in) :: ph integer :: ip, el, ce, co + real(pReal), dimension(:), allocatable :: V + - ce = 0 - do el = 1, size(material_homogenizationMemberAt,2) - do ip = 1, size(material_homogenizationMemberAt,1) - ce = ce + 1 - do co = 1, homogenization_maxNconstituents - if(material_phaseAt2(co,ce) == ph) then - geom(ph)%V_0(material_phaseMemberAt2(co,ce)) = IPvolume(ip,el) - endif - enddo + V = reshape(IPvolume,[product(shape(IPvolume))]) + do ce = 1, size(material_homogenizationMemberAt2,1) + do co = 1, homogenization_maxNconstituents + if(material_phaseAt2(co,ce) == ph) geom(ph)%V_0(material_phaseMemberAt2(co,ce)) = V(ce) enddo enddo From 25c556558065ac0d6508dcba52405afcceeecb70 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 1 Mar 2021 09:24:39 +0100 Subject: [PATCH 335/352] correct runtime test --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 08e226ec7..13dfa0ee9 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 08e226ec735589123dd67f3e0a5bc447c3dda812 +Subproject commit 13dfa0ee9d702782f0b7999f3f7fb2384f58d768 From 109ad378c204b83ecf00b43e9db89475f7511f76 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 2 Mar 2021 16:26:18 +0100 Subject: [PATCH 336/352] corrected help text of as_Rodrigues_vector --- python/damask/_rotation.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 86311546e..34a5f81b7 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -475,15 +475,17 @@ class Rotation: Parameters ---------- - vector : bool, optional - Return as actual Rodrigues-Frank vector, i.e. axis - and angle argument are not separated. + compact : bool, optional + Return as actual Rodrigues-Frank vector, + i.e. axis and angle argument are not separated. Returns ------- - rho : numpy.ndarray of shape (...,4) unless vector == True: - numpy.ndarray of shape (...,3) - Rodrigues-Frank vector: [n_1, n_2, n_3, tan(ω/2)], ǀnǀ = 1 and ω ∈ [0,π]. + rho : numpy.ndarray of shape (...,4) containing + [n_1, n_2, n_3, tan(ω/2)], ǀnǀ = 1 and ω ∈ [0,π] + unless compact == True: + numpy.ndarray of shape (...,3) containing + tan(ω/2) [n_1, n_2, n_3], ω ∈ [0,π]. """ ro = Rotation._qu2ro(self.quaternion) From 1861e9fe7f6cf91122dc2394364728ebc2ae6c13 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 2 Mar 2021 19:23:33 +0100 Subject: [PATCH 337/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-574-g109ad378c --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 4ebc52387..542cffb8f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-572-g7b89cb41f +v3.0.0-alpha2-574-g109ad378c From 438167804c90dd4ba364d59b79c7e58bb3734511 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 4 Mar 2021 15:11:39 -0500 Subject: [PATCH 338/352] if( polishing --- src/YAML_types.f90 | 116 ++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index b71261d9c..036d40755 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -72,7 +72,7 @@ module YAML_types getKey => tNode_getKey_byIndex procedure :: & contains => tNode_contains - + generic :: & get => tNode_get_byIndex, & tNode_get_byKey @@ -157,7 +157,7 @@ module YAML_types emptyDict type(tList), target, public :: & emptyList - + abstract interface recursive function asFormattedString(self,indent) @@ -179,7 +179,7 @@ module YAML_types public :: & YAML_types_init, & - output_asStrings, & !ToDo: Hack for GNU. Remove later + output_asStrings, & !ToDo: Hack for GNU. Remove later assignment(=) contains @@ -207,11 +207,11 @@ subroutine selfTest select type(s1) class is(tScalar) s1 = '1' - if(s1%asInt() /= 1) error stop 'tScalar_asInt' - if(dNeq(s1%asFloat(),1.0_pReal)) error stop 'tScalar_asFloat' + if (s1%asInt() /= 1) error stop 'tScalar_asInt' + if (dNeq(s1%asFloat(),1.0_pReal)) error stop 'tScalar_asFloat' s1 = 'true' - if(.not. s1%asBool()) error stop 'tScalar_asBool' - if(s1%asString() /= 'true') error stop 'tScalar_asString' + if (.not. s1%asBool()) error stop 'tScalar_asBool' + if (s1%asString() /= 'true') error stop 'tScalar_asString' end select block @@ -232,18 +232,18 @@ subroutine selfTest call l1%append(s1) call l1%append(s2) n => l1 - if(any(l1%asInts() /= [2,3])) error stop 'tList_asInts' - if(any(dNeq(l1%asFloats(),[2.0_pReal,3.0_pReal]))) error stop 'tList_asFloats' - if(n%get_asInt(1) /= 2) error stop 'byIndex_asInt' - if(dNeq(n%get_asFloat(2),3.0_pReal)) error stop 'byIndex_asFloat' + if (any(l1%asInts() /= [2,3])) error stop 'tList_asInts' + if (any(dNeq(l1%asFloats(),[2.0_pReal,3.0_pReal]))) error stop 'tList_asFloats' + if (n%get_asInt(1) /= 2) error stop 'byIndex_asInt' + if (dNeq(n%get_asFloat(2),3.0_pReal)) error stop 'byIndex_asFloat' endselect allocate(tList::l2) select type(l2) class is(tList) call l2%append(l1) - if(any(l2%get_asInts(1) /= [2,3])) error stop 'byIndex_asInts' - if(any(dNeq(l2%get_asFloats(1),[2.0_pReal,3.0_pReal]))) error stop 'byIndex_asFloats' + if (any(l2%get_asInts(1) /= [2,3])) error stop 'byIndex_asInts' + if (any(dNeq(l2%get_asFloats(1),[2.0_pReal,3.0_pReal]))) error stop 'byIndex_asFloats' n => l2 end select deallocate(n) @@ -265,10 +265,10 @@ subroutine selfTest call l1%append(s2) n => l1 - if(any(l1%asBools() .neqv. [.true., .false.])) error stop 'tList_asBools' - if(any(l1%asStrings() /= ['true ','False'])) error stop 'tList_asStrings' - if(n%get_asBool(2)) error stop 'byIndex_asBool' - if(n%get_asString(1) /= 'true') error stop 'byIndex_asString' + if (any(l1%asBools() .neqv. [.true., .false.])) error stop 'tList_asBools' + if (any(l1%asStrings() /= ['true ','False'])) error stop 'tList_asStrings' + if (n%get_asBool(2)) error stop 'byIndex_asBool' + if (n%get_asString(1) /= 'true') error stop 'byIndex_asString' end block end subroutine selfTest @@ -418,7 +418,7 @@ function tNode_get_byIndex(self,i) result(node) integer :: j self_ => self%asList() - if(i < 1 .or. i > self_%length) call IO_error(150,ext_msg='tNode_get_byIndex') + if (i < 1 .or. i > self_%length) call IO_error(150,ext_msg='tNode_get_byIndex') j = 1 item => self_%first @@ -599,7 +599,7 @@ function tNode_getKey_byIndex(self,i) result(key) dict => self%asDict() item => dict%first do j = 1, dict%length - if(j == i) then + if (j == i) then key = item%key exit else @@ -613,7 +613,7 @@ end function tNode_getKey_byIndex !------------------------------------------------------------------------------------------------- !> @brief Checks if a given key/item is present in the dict/list !------------------------------------------------------------------------------------------------- -function tNode_contains(self,k) result(exists) +function tNode_contains(self,k) result(exists) class(tNode), intent(in), target :: self character(len=*), intent(in) :: k @@ -624,18 +624,18 @@ function tNode_contains(self,k) result(exists) type(tDict), pointer :: dict exists = .false. - if(self%isDict()) then + if (self%isDict()) then dict => self%asDict() do j=1, dict%length - if(dict%getKey(j) == k) then + if (dict%getKey(j) == k) then exists = .true. return endif enddo - elseif(self%isList()) then + elseif (self%isList()) then list => self%asList() - do j =1, list%length - if(list%get_asString(j) == k) then + do j=1, list%length + if (list%get_asString(j) == k) then exists = .true. return endif @@ -663,8 +663,8 @@ function tNode_get_byKey(self,k,defaultVal) result(node) logical :: found found = present(defaultVal) - if(found) node => defaultVal - + if (found) node => defaultVal + self_ => self%asDict() j = 1 @@ -677,11 +677,11 @@ function tNode_get_byKey(self,k,defaultVal) result(node) item => item%next j = j + 1 enddo - + if (.not. found) then call IO_error(143,ext_msg=k) else - if(associated(item)) node => item%node + if (associated(item)) node => item%node endif end function tNode_get_byKey @@ -700,11 +700,11 @@ function tNode_get_byKey_asFloat(self,k,defaultVal) result(nodeAsFloat) class(tNode), pointer :: node type(tScalar), pointer :: scalar - if(self%contains(k)) then + if (self%contains(k)) then node => self%get(k) scalar => node%asScalar() nodeAsFloat = scalar%asFloat() - elseif(present(defaultVal)) then + elseif (present(defaultVal)) then nodeAsFloat = defaultVal else call IO_error(143,ext_msg=k) @@ -726,11 +726,11 @@ function tNode_get_byKey_asInt(self,k,defaultVal) result(nodeAsInt) class(tNode), pointer :: node type(tScalar), pointer :: scalar - if(self%contains(k)) then + if (self%contains(k)) then node => self%get(k) scalar => node%asScalar() nodeAsInt = scalar%asInt() - elseif(present(defaultVal)) then + elseif (present(defaultVal)) then nodeAsInt = defaultVal else call IO_error(143,ext_msg=k) @@ -752,11 +752,11 @@ function tNode_get_byKey_asBool(self,k,defaultVal) result(nodeAsBool) class(tNode), pointer :: node type(tScalar), pointer :: scalar - if(self%contains(k)) then + if (self%contains(k)) then node => self%get(k) scalar => node%asScalar() nodeAsBool = scalar%asBool() - elseif(present(defaultVal)) then + elseif (present(defaultVal)) then nodeAsBool = defaultVal else call IO_error(143,ext_msg=k) @@ -778,11 +778,11 @@ function tNode_get_byKey_asString(self,k,defaultVal) result(nodeAsString) class(tNode), pointer :: node type(tScalar), pointer :: scalar - if(self%contains(k)) then + if (self%contains(k)) then node => self%get(k) scalar => node%asScalar() nodeAsString = scalar%asString() - elseif(present(defaultVal)) then + elseif (present(defaultVal)) then nodeAsString = defaultVal else call IO_error(143,ext_msg=k) @@ -806,18 +806,18 @@ function tNode_get_byKey_asFloats(self,k,defaultVal,requiredSize) result(nodeAsF class(tNode), pointer :: node type(tList), pointer :: list - if(self%contains(k)) then + if (self%contains(k)) then node => self%get(k) list => node%asList() nodeAsFloats = list%asFloats() - elseif(present(defaultVal)) then + elseif (present(defaultVal)) then nodeAsFloats = defaultVal else call IO_error(143,ext_msg=k) endif - if(present(requiredSize)) then - if(requiredSize /= size(nodeAsFloats)) call IO_error(146,ext_msg=k) + if (present(requiredSize)) then + if (requiredSize /= size(nodeAsFloats)) call IO_error(146,ext_msg=k) endif end function tNode_get_byKey_asFloats @@ -837,18 +837,18 @@ function tNode_get_byKey_asInts(self,k,defaultVal,requiredSize) result(nodeAsInt class(tNode), pointer :: node type(tList), pointer :: list - if(self%contains(k)) then + if (self%contains(k)) then node => self%get(k) list => node%asList() nodeAsInts = list%asInts() - elseif(present(defaultVal)) then + elseif (present(defaultVal)) then nodeAsInts = defaultVal else call IO_error(143,ext_msg=k) endif - if(present(requiredSize)) then - if(requiredSize /= size(nodeAsInts)) call IO_error(146,ext_msg=k) + if (present(requiredSize)) then + if (requiredSize /= size(nodeAsInts)) call IO_error(146,ext_msg=k) endif end function tNode_get_byKey_asInts @@ -867,11 +867,11 @@ function tNode_get_byKey_asBools(self,k,defaultVal) result(nodeAsBools) class(tNode), pointer :: node type(tList), pointer :: list - if(self%contains(k)) then + if (self%contains(k)) then node => self%get(k) list => node%asList() nodeAsBools = list%asBools() - elseif(present(defaultVal)) then + elseif (present(defaultVal)) then nodeAsBools = defaultVal else call IO_error(143,ext_msg=k) @@ -893,11 +893,11 @@ function tNode_get_byKey_asStrings(self,k,defaultVal) result(nodeAsStrings) class(tNode), pointer :: node type(tList), pointer :: list - if(self%contains(k)) then + if (self%contains(k)) then node => self%get(k) list => node%asList() nodeAsStrings = list%asStrings() - elseif(present(defaultVal)) then + elseif (present(defaultVal)) then nodeAsStrings = defaultVal else call IO_error(143,ext_msg=k) @@ -925,7 +925,7 @@ function output_asStrings(self) result(output) !ToDo: SR: Rem end function output_asStrings - + !-------------------------------------------------------------------------------------------------- !> @brief Returns the index of a key in a dictionary @@ -944,7 +944,7 @@ function tNode_get_byKey_asIndex(self,key) result(keyIndex) item => dict%first keyIndex = -1 do i = 1, dict%length - if(key == item%key) then + if (key == item%key) then keyIndex = i exit else @@ -952,9 +952,9 @@ function tNode_get_byKey_asIndex(self,key) result(keyIndex) endif enddo - if(keyIndex == -1) call IO_error(140,ext_msg=key) + if (keyIndex == -1) call IO_error(140,ext_msg=key) + - end function tNode_get_byKey_asIndex @@ -985,7 +985,7 @@ recursive function tList_asFormattedString(self,indent) result(str) integer :: i, indent_ str = '' - if(present(indent)) then + if (present(indent)) then indent_ = indent else indent_ = 0 @@ -993,7 +993,7 @@ recursive function tList_asFormattedString(self,indent) result(str) item => self%first do i = 1, self%length - if(i /= 1) str = str//repeat(' ',indent_) + if (i /= 1) str = str//repeat(' ',indent_) str = str//'- '//item%node%asFormattedString(indent_+2) item => item%next end do @@ -1014,7 +1014,7 @@ recursive function tDict_asFormattedString(self,indent) result(str) integer :: i, indent_ str = '' - if(present(indent)) then + if (present(indent)) then indent_ = indent else indent_ = 0 @@ -1022,7 +1022,7 @@ recursive function tDict_asFormattedString(self,indent) result(str) item => self%first do i = 1, self%length - if(i /= 1) str = str//repeat(' ',indent_) + if (i /= 1) str = str//repeat(' ',indent_) select type(node_1 =>item%node) class is(tScalar) str = str//trim(item%key)//': '//item%node%asFormattedString(indent_+len_trim(item%key)+2) @@ -1270,7 +1270,7 @@ recursive subroutine tItem_finalize(self) type(tItem),intent(inout) :: self deallocate(self%node) - if(associated(self%next)) deallocate(self%next) + if (associated(self%next)) deallocate(self%next) end subroutine tItem_finalize From e4271537c5640f4ddb1645c6d2a2f20ede059337 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 4 Mar 2021 15:14:16 -0500 Subject: [PATCH 339/352] syntax polishing; use of YAML defaults to avoid if%contains --- src/grid/DAMASK_grid.f90 | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index fda9d7b9a..0aa462e7e 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -38,7 +38,7 @@ program DAMASK_grid f_restart !< frequency of restart writes logical :: estimate_rate !< follow trajectory of former loadcase end type tLoadCase - + integer(kind(FIELD_UNDEFINED_ID)), allocatable :: ID(:) !-------------------------------------------------------------------------------------------------- @@ -116,7 +116,7 @@ program DAMASK_grid ! init DAMASK (all modules) call CPFEM_initAll - print'(/,a)', ' <<<+- DAMASK_spectral init -+>>>'; flush(IO_STDOUT) + print'(/,a)', ' <<<+- DAMASK_grid init -+>>>'; flush(IO_STDOUT) print*, 'Shanthraj et al., Handbook of Mechanics of Materials, 2019' print*, 'https://doi.org/10.1007/978-981-10-6855-3_80' @@ -130,7 +130,7 @@ program DAMASK_grid if (stagItMax < 0) call IO_error(301,ext_msg='maxStaggeredIter') if (maxCutBack < 0) call IO_error(301,ext_msg='maxCutBack') - + config_load => YAML_parse_file(trim(interface_loadFile)) solver => config_load%get('solver') @@ -169,9 +169,10 @@ program DAMASK_grid ! initialize field solver information if (solver%get_asString('thermal',defaultVal = 'n/a') == 'spectral') nActiveFields = nActiveFields + 1 if (solver%get_asString('damage', defaultVal = 'n/a') == 'spectral') nActiveFields = nActiveFields + 1 + allocate(solres(nActiveFields)) - - allocate(ID(nActiveFields)) + allocate( ID(nActiveFields)) + field = 1 ID(field) = FIELD_MECH_ID ! mechanical active by default thermalActive: if (solver%get_asString('thermal',defaultVal = 'n/a') == 'spectral') then @@ -224,16 +225,15 @@ program DAMASK_grid if (.not. allocated(loadCases(l)%deformation%myType)) call IO_error(error_ID=837,ext_msg = 'L/dot_F/F missing') step_discretization => load_step%get('discretization') - if(.not. step_discretization%contains('t')) call IO_error(error_ID=837,ext_msg = 't missing') - if(.not. step_discretization%contains('N')) call IO_error(error_ID=837,ext_msg = 'N missing') + if (.not. step_discretization%contains('t')) call IO_error(error_ID=837,ext_msg = 't missing') + if (.not. step_discretization%contains('N')) call IO_error(error_ID=837,ext_msg = 'N missing') 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 = 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)) + loadCases(l)%estimate_rate = (load_step%get_asBool('estimate_rate',defaultVal=.true.) .and. l>1) reportAndCheck: if (worldrank == 0) then print'(/,a,i0)', ' load case: ', l @@ -289,11 +289,11 @@ program DAMASK_grid else print'(a,f0.3)', ' r: ', loadCases(l)%r endif - print'(a,f0.3)', ' t: ', loadCases(l)%t - print'(a,i0)', ' N: ', loadCases(l)%N - print'(a,i0)', ' f_out: ', loadCases(l)%f_out + print'(a,f0.3)', ' t: ', loadCases(l)%t + print'(a,i0)', ' N: ', loadCases(l)%N + print'(a,i0)', ' f_out: ', loadCases(l)%f_out if (loadCases(l)%f_restart < huge(0)) & - print'(a,i0)', ' f_restart: ', loadCases(l)%f_restart + print'(a,i0)', ' f_restart: ', loadCases(l)%f_restart if (errorID > 0) call IO_error(error_ID = errorID, el = l) @@ -309,14 +309,9 @@ program DAMASK_grid call mechanical_init case(FIELD_THERMAL_ID) - if (config_load%contains('initial_conditions')) then - initial_conditions => config_load%get('initial_conditions') - if (initial_conditions%contains('thermal')) then - thermal => initial_conditions%get('thermal') - T_0 = thermal%get_asFloat('T',defaultVal = T_0) - endif - endif - call grid_thermal_spectral_init(T_0) + initial_conditions => config_load%get('initial_conditions',defaultVal=emptyDict) + thermal => initial_conditions%get('thermal',defaultVal=emptyDict) + call grid_thermal_spectral_init(thermal%get_asFloat('T',defaultVal = T_0)) case(FIELD_DAMAGE_ID) call grid_damage_spectral_init From e1f0d2e0a3a99ad4488cee5a673ef3d13d5017b8 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 4 Mar 2021 15:15:40 -0500 Subject: [PATCH 340/352] polishing of indentation and whitespaces; thermal_homogenize only once after all constituents --- src/homogenization.f90 | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/src/homogenization.f90 b/src/homogenization.f90 index 4c7200eed..90654ee99 100644 --- a/src/homogenization.f90 +++ b/src/homogenization.f90 @@ -91,7 +91,7 @@ module homogenization real(pReal), intent(in), dimension(3,3) :: & subF integer, intent(in) :: & - ce + ce end subroutine mechanical_partition module subroutine thermal_partition(ce) @@ -129,10 +129,8 @@ module homogenization module function thermal_conduction_getConductivity(ce) result(K) - integer, intent(in) :: ce real(pReal), dimension(3,3) :: K - end function thermal_conduction_getConductivity module function thermal_conduction_getSpecificHeat(ce) result(c_P) @@ -167,13 +165,12 @@ module homogenization real(pReal), intent(out) :: Tdot end subroutine thermal_conduction_getSource - module function damage_nonlocal_getMobility(ce) result(M) - integer, intent(in) :: ce - real(pReal) :: M + module function damage_nonlocal_getMobility(ce) result(M) + integer, intent(in) :: ce + real(pReal) :: M end function damage_nonlocal_getMobility module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ce) - integer, intent(in) :: ce real(pReal), intent(in) :: & phi @@ -181,21 +178,17 @@ module homogenization phiDot, dPhiDot_dPhi end subroutine damage_nonlocal_getSourceAndItsTangent - module subroutine damage_nonlocal_putNonLocalDamage(phi,ce) - integer, intent(in) :: ce real(pReal), intent(in) :: & phi - end subroutine damage_nonlocal_putNonLocalDamage module subroutine damage_nonlocal_results(ho,group) - integer, intent(in) :: ho character(len=*), intent(in) :: group - end subroutine damage_nonlocal_results + end interface public :: & @@ -238,21 +231,18 @@ subroutine homogenization_init() allocate(homogState (size(material_name_homogenization))) allocate(damageState_h (size(material_name_homogenization))) - call material_parseHomogenization - + call material_parseHomogenization() num_homog => config_numerics%get('homogenization',defaultVal=emptyDict) num_homogGeneric => num_homog%get('generic',defaultVal=emptyDict) - num%nMPstate = num_homogGeneric%get_asInt ('nMPstate', defaultVal=10) - if (num%nMPstate < 1) call IO_error(301,ext_msg='nMPstate') - + num%nMPstate = num_homogGeneric%get_asInt('nMPstate',defaultVal=10) + if (num%nMPstate < 1) call IO_error(301,ext_msg='nMPstate') call mechanical_init(num_homog) call thermal_init() call damage_init() - - call damage_nonlocal_init + call damage_nonlocal_init() end subroutine homogenization_init @@ -322,7 +312,7 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE enddo !$OMP END DO - if (.not. terminallyIll ) then + if (.not. terminallyIll) then !$OMP DO PRIVATE(ho,ph,ce) do el = FEsolving_execElem(1),FEsolving_execElem(2) if (terminallyIll) continue @@ -336,9 +326,9 @@ subroutine materialpoint_stressAndItsTangent(dt,FEsolving_execIP,FEsolving_execE if (.not. terminallyIll) & ! so first signals terminally ill... print*, ' Integration point ', ip,' at element ', el, ' terminally ill' terminallyIll = .true. ! ...and kills all others - endif - call thermal_homogenize(ip,el) + endif enddo + call thermal_homogenize(ip,el) enddo enddo !$OMP END DO @@ -567,10 +557,8 @@ subroutine material_parseHomogenization call IO_error(500,ext_msg=homogMech%get_asString('type')) end select - - if(homog%contains('thermal')) then + if (homog%contains('thermal')) then homogThermal => homog%get('thermal') - select case (homogThermal%get_asString('type')) case('pass') thermal_type(h) = THERMAL_conduction_ID @@ -579,7 +567,7 @@ subroutine material_parseHomogenization end select endif - if(homog%contains('damage')) then + if (homog%contains('damage')) then homogDamage => homog%get('damage') select case (homogDamage%get_asString('type')) case('pass') @@ -590,7 +578,6 @@ subroutine material_parseHomogenization endif enddo - end subroutine material_parseHomogenization From a7e2ed40dd183444e7500a6899ddde33ee188d98 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 4 Mar 2021 15:16:36 -0500 Subject: [PATCH 341/352] rename Nconstituents --> Nmembers --- src/phase_damage.f90 | 10 ++-- src/phase_damage_anisobrittle.f90 | 6 +- src/phase_damage_anisoductile.f90 | 6 +- src/phase_damage_isobrittle.f90 | 6 +- src/phase_damage_isoductile.f90 | 6 +- src/phase_mechanical.f90 | 38 ++++++------- ...phase_mechanical_plastic_dislotungsten.f90 | 14 ++--- src/phase_mechanical_plastic_dislotwin.f90 | 30 +++++----- src/phase_mechanical_plastic_isotropic.f90 | 6 +- ...phase_mechanical_plastic_kinehardening.f90 | 8 +-- src/phase_mechanical_plastic_nonlocal.f90 | 54 +++++++++--------- ...phase_mechanical_plastic_phenopowerlaw.f90 | 10 ++-- src/phase_thermal.f90 | 56 ++++++++----------- src/phase_thermal_dissipation.f90 | 6 +- src/phase_thermal_externalheat.f90 | 6 +- 15 files changed, 127 insertions(+), 135 deletions(-) diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index c6fd7bfab..6ad25f1e9 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -133,7 +133,7 @@ module subroutine damage_init integer :: & ph, & !< counter in phase loop - Nconstituents + Nmembers class(tNode), pointer :: & phases, & phase, & @@ -151,10 +151,10 @@ module subroutine damage_init do ph = 1,phases%length - Nconstituents = count(material_phaseAt2 == ph) + Nmembers = count(material_phaseAt2 == ph) - allocate(current(ph)%phi(Nconstituents),source=1.0_pReal) - allocate(current(ph)%d_phi_d_dot_phi(Nconstituents),source=0.0_pReal) + allocate(current(ph)%phi(Nmembers),source=1.0_pReal) + allocate(current(ph)%d_phi_d_dot_phi(Nmembers),source=0.0_pReal) phase => phases%get(ph) sources => phase%get('damage',defaultVal=emptyList) @@ -199,7 +199,7 @@ module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, phiDot = 0.0_pReal dPhiDot_dPhi = 0.0_pReal - do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) + do co = 1, homogenization_Nmembers(material_homogenizationAt2(ce)) ph = material_phaseAt2(co,ce) me = material_phasememberAt2(co,ce) diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index fd82b74c4..096da6fb8 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -40,7 +40,7 @@ module function anisobrittle_init() result(mySources) phase, & sources, & src - integer :: Nconstituents,p + integer :: Nmembers,p integer, dimension(:), allocatable :: N_cl character(len=pStringLen) :: extmsg = '' @@ -92,8 +92,8 @@ module function anisobrittle_init() result(mySources) if (any(prm%g_crit < 0.0_pReal)) extmsg = trim(extmsg)//' g_crit' if (any(prm%s_crit < 0.0_pReal)) extmsg = trim(extmsg)//' s_crit' - Nconstituents = count(material_phaseAt==p) * discretization_nIPs - call phase_allocateState(damageState(p),Nconstituents,1,1,0) + Nmembers = count(material_phaseAt==p) * discretization_nIPs + call phase_allocateState(damageState(p),Nmembers,1,1,0) damageState(p)%atol = src%get_asFloat('anisobrittle_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisobrittle_atol' diff --git a/src/phase_damage_anisoductile.f90 b/src/phase_damage_anisoductile.f90 index f50c05f07..a687df594 100644 --- a/src/phase_damage_anisoductile.f90 +++ b/src/phase_damage_anisoductile.f90 @@ -35,7 +35,7 @@ module function anisoductile_init() result(mySources) pl, & sources, & src - integer :: Ninstances,Nconstituents,p + integer :: Ninstances,Nmembers,p integer, dimension(:), allocatable :: N_sl character(len=pStringLen) :: extmsg = '' @@ -78,8 +78,8 @@ module function anisoductile_init() result(mySources) if (prm%q <= 0.0_pReal) extmsg = trim(extmsg)//' q' if (any(prm%gamma_crit < 0.0_pReal)) extmsg = trim(extmsg)//' gamma_crit' - Nconstituents=count(material_phaseAt2==p) - call phase_allocateState(damageState(p),Nconstituents,1,1,0) + Nmembers=count(material_phaseAt2==p) + call phase_allocateState(damageState(p),Nmembers,1,1,0) damageState(p)%atol = src%get_asFloat('anisoDuctile_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' anisoductile_atol' diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 1cc0d7900..0cf85897a 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -31,7 +31,7 @@ module function isobrittle_init() result(mySources) phase, & sources, & src - integer :: Nconstituents,p + integer :: Nmembers,p character(len=pStringLen) :: extmsg = '' @@ -64,8 +64,8 @@ module function isobrittle_init() result(mySources) ! sanity checks if (prm%W_crit <= 0.0_pReal) extmsg = trim(extmsg)//' W_crit' - Nconstituents = count(material_phaseAt2==p) - call phase_allocateState(damageState(p),Nconstituents,1,1,1) + Nmembers = count(material_phaseAt2==p) + call phase_allocateState(damageState(p),Nmembers,1,1,1) damageState(p)%atol = src%get_asFloat('isoBrittle_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isobrittle_atol' diff --git a/src/phase_damage_isoductile.f90 b/src/phase_damage_isoductile.f90 index 247cd715a..9d00bb1a7 100644 --- a/src/phase_damage_isoductile.f90 +++ b/src/phase_damage_isoductile.f90 @@ -33,7 +33,7 @@ module function isoductile_init() result(mySources) phase, & sources, & src - integer :: Ninstances,Nconstituents,p + integer :: Ninstances,Nmembers,p character(len=pStringLen) :: extmsg = '' @@ -68,8 +68,8 @@ module function isoductile_init() result(mySources) if (prm%q <= 0.0_pReal) extmsg = trim(extmsg)//' q' if (prm%gamma_crit <= 0.0_pReal) extmsg = trim(extmsg)//' gamma_crit' - Nconstituents=count(material_phaseAt2==p) - call phase_allocateState(damageState(p),Nconstituents,1,1,0) + Nmembers=count(material_phaseAt2==p) + call phase_allocateState(damageState(p),Nmembers,1,1,0) damageState(p)%atol = src%get_asFloat('isoDuctile_atol',defaultVal=1.0e-3_pReal) if(any(damageState(p)%atol < 0.0_pReal)) extmsg = trim(extmsg)//' isoductile_atol' diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index c934fed72..d065fc74a 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -191,7 +191,7 @@ module subroutine mechanical_init(materials,phases) ph, & me, & stiffDegradationCtr, & - Nconstituents + Nmembers class(tNode), pointer :: & num_crystallite, & material, & @@ -229,22 +229,22 @@ module subroutine mechanical_init(materials,phases) allocate(material_orientation0(homogenization_maxNconstituents,phases%length,maxVal(material_phaseMemberAt))) do ph = 1, phases%length - Nconstituents = count(material_phaseAt == ph) * discretization_nIPs + Nmembers = count(material_phaseAt == ph) * discretization_nIPs - allocate(phase_mechanical_Fi(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_Fe(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_Fi0(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_Fp(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_Fp0(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_Li(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_Li0(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_Lp0(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_Lp(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_S(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(phase_mechanical_P(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(phase_mechanical_S0(ph)%data(3,3,Nconstituents),source=0.0_pReal) - allocate(phase_mechanical_F(ph)%data(3,3,Nconstituents)) - allocate(phase_mechanical_F0(ph)%data(3,3,Nconstituents)) + allocate(phase_mechanical_Fi(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_Fe(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_Fi0(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_Fp(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_Fp0(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_Li(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_Li0(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_Lp0(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_Lp(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_S(ph)%data(3,3,Nmembers),source=0.0_pReal) + allocate(phase_mechanical_P(ph)%data(3,3,Nmembers),source=0.0_pReal) + allocate(phase_mechanical_S0(ph)%data(3,3,Nmembers),source=0.0_pReal) + allocate(phase_mechanical_F(ph)%data(3,3,Nmembers)) + allocate(phase_mechanical_F0(ph)%data(3,3,Nmembers)) phase => phases%get(ph) mech => phase%get('mechanics') @@ -278,9 +278,9 @@ module subroutine mechanical_init(materials,phases) enddo endif - + do el = 1, size(material_phaseMemberAt,3); do ip = 1, size(material_phaseMemberAt,2) - do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) + do co = 1, homogenization_Nmembers(material_homogenizationAt(el)) material => materials%get(discretization_materialAt(el)) constituents => material%get('constituents') constituent => constituents%get(co) @@ -1238,7 +1238,7 @@ module subroutine mechanical_restore(ce,includeL) co, ph, me - do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce)) + do co = 1,homogenization_Nmembers(material_homogenizationAt2(ce)) ph = material_phaseAt2(co,ce) me = material_phaseMemberAt2(co,ce) if (includeL) then diff --git a/src/phase_mechanical_plastic_dislotungsten.f90 b/src/phase_mechanical_plastic_dislotungsten.f90 index 9c8baf0a5..1fda51a58 100644 --- a/src/phase_mechanical_plastic_dislotungsten.f90 +++ b/src/phase_mechanical_plastic_dislotungsten.f90 @@ -79,7 +79,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & ph, i, & - Nconstituents, & + Nmembers, & sizeState, sizeDotState, & startIndex, endIndex integer, dimension(:), allocatable :: & @@ -220,18 +220,18 @@ module function plastic_dislotungsten_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == ph) + Nmembers = count(material_phaseAt2 == ph) sizeDotState = size(['rho_mob ','rho_dip ','gamma_sl']) * prm%sum_N_sl sizeState = sizeDotState - call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(ph),Nmembers,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization startIndex = 1 endIndex = prm%sum_N_sl stt%rho_mob => plasticState(ph)%state(startIndex:endIndex,:) - stt%rho_mob = spread(rho_mob_0,2,Nconstituents) + stt%rho_mob = spread(rho_mob_0,2,Nmembers) dot%rho_mob => plasticState(ph)%dotState(startIndex:endIndex,:) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_rho' @@ -239,7 +239,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl stt%rho_dip => plasticState(ph)%state(startIndex:endIndex,:) - stt%rho_dip = spread(rho_dip_0,2,Nconstituents) + stt%rho_dip = spread(rho_dip_0,2,Nmembers) dot%rho_dip => plasticState(ph)%dotState(startIndex:endIndex,:) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) @@ -251,8 +251,8 @@ module function plastic_dislotungsten_init() result(myPlasticity) ! global alias plasticState(ph)%slipRate => plasticState(ph)%dotState(startIndex:endIndex,:) - allocate(dst%Lambda_sl(prm%sum_N_sl,Nconstituents), source=0.0_pReal) - allocate(dst%threshold_stress(prm%sum_N_sl,Nconstituents), source=0.0_pReal) + allocate(dst%Lambda_sl(prm%sum_N_sl,Nmembers), source=0.0_pReal) + allocate(dst%threshold_stress(prm%sum_N_sl,Nmembers), source=0.0_pReal) plasticState(ph)%state0 = plasticState(ph)%state ! ToDo: this could be done centrally diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index f479ba007..5500ae731 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -127,7 +127,7 @@ module function plastic_dislotwin_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & ph, i, & - Nconstituents, & + Nmembers, & sizeState, sizeDotState, & startIndex, endIndex integer, dimension(:), allocatable :: & @@ -406,21 +406,21 @@ module function plastic_dislotwin_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == ph) + Nmembers = count(material_phaseAt2 == ph) sizeDotState = size(['rho_mob ','rho_dip ','gamma_sl']) * prm%sum_N_sl & + size(['f_tw']) * prm%sum_N_tw & + size(['f_tr']) * prm%sum_N_tr sizeState = sizeDotState - call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(ph),Nmembers,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! locally defined state aliases and initialization of state0 and atol startIndex = 1 endIndex = prm%sum_N_sl stt%rho_mob=>plasticState(ph)%state(startIndex:endIndex,:) - stt%rho_mob= spread(rho_mob_0,2,Nconstituents) + stt%rho_mob= spread(rho_mob_0,2,Nmembers) dot%rho_mob=>plasticState(ph)%dotState(startIndex:endIndex,:) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_rho' @@ -428,7 +428,7 @@ module function plastic_dislotwin_init() result(myPlasticity) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_sl stt%rho_dip=>plasticState(ph)%state(startIndex:endIndex,:) - stt%rho_dip= spread(rho_dip_0,2,Nconstituents) + stt%rho_dip= spread(rho_dip_0,2,Nmembers) dot%rho_dip=>plasticState(ph)%dotState(startIndex:endIndex,:) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) @@ -454,18 +454,18 @@ module function plastic_dislotwin_init() result(myPlasticity) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_f_tr',defaultVal=1.0e-6_pReal) if (any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_f_tr' - allocate(dst%Lambda_sl (prm%sum_N_sl,Nconstituents),source=0.0_pReal) - allocate(dst%tau_pass (prm%sum_N_sl,Nconstituents),source=0.0_pReal) + allocate(dst%Lambda_sl (prm%sum_N_sl,Nmembers),source=0.0_pReal) + allocate(dst%tau_pass (prm%sum_N_sl,Nmembers),source=0.0_pReal) - allocate(dst%Lambda_tw (prm%sum_N_tw,Nconstituents),source=0.0_pReal) - allocate(dst%tau_hat_tw (prm%sum_N_tw,Nconstituents),source=0.0_pReal) - allocate(dst%tau_r_tw (prm%sum_N_tw,Nconstituents),source=0.0_pReal) - allocate(dst%V_tw (prm%sum_N_tw,Nconstituents),source=0.0_pReal) + allocate(dst%Lambda_tw (prm%sum_N_tw,Nmembers),source=0.0_pReal) + allocate(dst%tau_hat_tw (prm%sum_N_tw,Nmembers),source=0.0_pReal) + allocate(dst%tau_r_tw (prm%sum_N_tw,Nmembers),source=0.0_pReal) + allocate(dst%V_tw (prm%sum_N_tw,Nmembers),source=0.0_pReal) - allocate(dst%Lambda_tr (prm%sum_N_tr,Nconstituents),source=0.0_pReal) - allocate(dst%tau_hat_tr (prm%sum_N_tr,Nconstituents),source=0.0_pReal) - allocate(dst%tau_r_tr (prm%sum_N_tr,Nconstituents),source=0.0_pReal) - allocate(dst%V_tr (prm%sum_N_tr,Nconstituents),source=0.0_pReal) + allocate(dst%Lambda_tr (prm%sum_N_tr,Nmembers),source=0.0_pReal) + allocate(dst%tau_hat_tr (prm%sum_N_tr,Nmembers),source=0.0_pReal) + allocate(dst%tau_r_tr (prm%sum_N_tr,Nmembers),source=0.0_pReal) + allocate(dst%V_tr (prm%sum_N_tr,Nmembers),source=0.0_pReal) plasticState(ph)%state0 = plasticState(ph)%state ! ToDo: this could be done centrally diff --git a/src/phase_mechanical_plastic_isotropic.f90 b/src/phase_mechanical_plastic_isotropic.f90 index 245f4293a..d02436fba 100644 --- a/src/phase_mechanical_plastic_isotropic.f90 +++ b/src/phase_mechanical_plastic_isotropic.f90 @@ -52,7 +52,7 @@ module function plastic_isotropic_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & ph, & - Nconstituents, & + Nmembers, & sizeState, sizeDotState real(pReal) :: & xi_0 !< initial critical stress @@ -119,11 +119,11 @@ module function plastic_isotropic_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == ph) + Nmembers = count(material_phaseAt2 == ph) sizeDotState = size(['xi ','gamma']) sizeState = sizeDotState - call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(ph),Nmembers,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization diff --git a/src/phase_mechanical_plastic_kinehardening.f90 b/src/phase_mechanical_plastic_kinehardening.f90 index 8acf42710..75e8d9e59 100644 --- a/src/phase_mechanical_plastic_kinehardening.f90 +++ b/src/phase_mechanical_plastic_kinehardening.f90 @@ -62,7 +62,7 @@ module function plastic_kinehardening_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & ph, o, & - Nconstituents, & + Nmembers, & sizeState, sizeDeltaState, sizeDotState, & startIndex, endIndex integer, dimension(:), allocatable :: & @@ -165,19 +165,19 @@ module function plastic_kinehardening_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == ph) + Nmembers = count(material_phaseAt2 == ph) sizeDotState = size(['crss ','crss_back', 'accshear ']) * prm%sum_N_sl !ToDo: adjust names like in material.yaml sizeDeltaState = size(['sense ', 'chi0 ', 'gamma0' ]) * prm%sum_N_sl !ToDo: adjust names like in material.yaml sizeState = sizeDotState + sizeDeltaState - call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,sizeDeltaState) + call phase_allocateState(plasticState(ph),Nmembers,sizeState,sizeDotState,sizeDeltaState) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization startIndex = 1 endIndex = prm%sum_N_sl stt%crss => plasticState(ph)%state (startIndex:endIndex,:) - stt%crss = spread(xi_0, 2, Nconstituents) + stt%crss = spread(xi_0, 2, Nmembers) dot%crss => plasticState(ph)%dotState(startIndex:endIndex,:) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) if(any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_xi' diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 464e57339..d0007075b 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -177,7 +177,7 @@ module function plastic_nonlocal_init() result(myPlasticity) integer :: & Ninstances, & ph, & - Nconstituents, & + Nmembers, & sizeState, sizeDotState, sizeDependentState, sizeDeltaState, & s1, s2, & s, t, l @@ -398,7 +398,7 @@ module function plastic_nonlocal_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == ph) + Nmembers = count(material_phaseAt2 == ph) sizeDotState = size([ 'rhoSglEdgePosMobile ','rhoSglEdgeNegMobile ', & 'rhoSglScrewPosMobile ','rhoSglScrewNegMobile ', & 'rhoSglEdgePosImmobile ','rhoSglEdgeNegImmobile ', & @@ -412,9 +412,9 @@ module function plastic_nonlocal_init() result(myPlasticity) 'maxDipoleHeightEdge ','maxDipoleHeightScrew' ]) * prm%sum_N_sl !< other dependent state variables that are not updated by microstructure sizeDeltaState = sizeDotState - call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,sizeDeltaState) + call phase_allocateState(plasticState(ph),Nmembers,sizeState,sizeDotState,sizeDeltaState) - allocate(geom(ph)%V_0(Nconstituents)) + allocate(geom(ph)%V_0(Nmembers)) call storeGeometry(ph) plasticState(ph)%nonlocal = pl%get_asBool('nonlocal') @@ -486,26 +486,26 @@ module function plastic_nonlocal_init() result(myPlasticity) dot%rho_dip_scr => plasticState(ph)%dotState (9*prm%sum_N_sl+1:10*prm%sum_N_sl,:) del%rho_dip_scr => plasticState(ph)%deltaState (9*prm%sum_N_sl+1:10*prm%sum_N_sl,:) - stt%gamma => plasticState(ph)%state (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) - dot%gamma => plasticState(ph)%dotState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) - del%gamma => plasticState(ph)%deltaState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) + stt%gamma => plasticState(ph)%state (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nmembers) + dot%gamma => plasticState(ph)%dotState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nmembers) + del%gamma => plasticState(ph)%deltaState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nmembers) plasticState(ph)%atol(10*prm%sum_N_sl+1:11*prm%sum_N_sl ) = pl%get_asFloat('atol_gamma', defaultVal = 1.0e-2_pReal) if(any(plasticState(ph)%atol(10*prm%sum_N_sl+1:11*prm%sum_N_sl) < 0.0_pReal)) & extmsg = trim(extmsg)//' atol_gamma' - plasticState(ph)%slipRate => plasticState(ph)%dotState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nconstituents) + plasticState(ph)%slipRate => plasticState(ph)%dotState (10*prm%sum_N_sl + 1:11*prm%sum_N_sl,1:Nmembers) - stt%rho_forest => plasticState(ph)%state (11*prm%sum_N_sl + 1:12*prm%sum_N_sl,1:Nconstituents) - stt%v => plasticState(ph)%state (12*prm%sum_N_sl + 1:16*prm%sum_N_sl,1:Nconstituents) - stt%v_edg_pos => plasticState(ph)%state (12*prm%sum_N_sl + 1:13*prm%sum_N_sl,1:Nconstituents) - stt%v_edg_neg => plasticState(ph)%state (13*prm%sum_N_sl + 1:14*prm%sum_N_sl,1:Nconstituents) - stt%v_scr_pos => plasticState(ph)%state (14*prm%sum_N_sl + 1:15*prm%sum_N_sl,1:Nconstituents) - stt%v_scr_neg => plasticState(ph)%state (15*prm%sum_N_sl + 1:16*prm%sum_N_sl,1:Nconstituents) + stt%rho_forest => plasticState(ph)%state (11*prm%sum_N_sl + 1:12*prm%sum_N_sl,1:Nmembers) + stt%v => plasticState(ph)%state (12*prm%sum_N_sl + 1:16*prm%sum_N_sl,1:Nmembers) + stt%v_edg_pos => plasticState(ph)%state (12*prm%sum_N_sl + 1:13*prm%sum_N_sl,1:Nmembers) + stt%v_edg_neg => plasticState(ph)%state (13*prm%sum_N_sl + 1:14*prm%sum_N_sl,1:Nmembers) + stt%v_scr_pos => plasticState(ph)%state (14*prm%sum_N_sl + 1:15*prm%sum_N_sl,1:Nmembers) + stt%v_scr_neg => plasticState(ph)%state (15*prm%sum_N_sl + 1:16*prm%sum_N_sl,1:Nmembers) - allocate(dst%tau_pass(prm%sum_N_sl,Nconstituents),source=0.0_pReal) - allocate(dst%tau_back(prm%sum_N_sl,Nconstituents),source=0.0_pReal) + allocate(dst%tau_pass(prm%sum_N_sl,Nmembers),source=0.0_pReal) + allocate(dst%tau_back(prm%sum_N_sl,Nmembers),source=0.0_pReal) end associate - if (Nconstituents > 0) call stateInit(ini,ph,Nconstituents) + if (Nmembers > 0) call stateInit(ini,ph,Nmembers) plasticState(ph)%state0 = plasticState(ph)%state !-------------------------------------------------------------------------------------------------- @@ -527,7 +527,7 @@ module function plastic_nonlocal_init() result(myPlasticity) if(.not. myPlasticity(ph)) cycle phase => phases%get(ph) - Nconstituents = count(material_phaseAt2 == ph) + Nmembers = count(material_phaseAt2 == ph) l = 0 do t = 1,4 do s = 1,param(ph)%sum_N_sl @@ -1406,7 +1406,7 @@ module subroutine plastic_nonlocal_updateCompatibility(orientation,ph,i,e) me, & neighbor_e, & ! element index of my neighbor neighbor_i, & ! integration point index of my neighbor - neighbor_me, & + neighbor_me, & neighbor_phase, & ns, & ! number of active slip systems s1, & ! slip system index (me) @@ -1579,13 +1579,13 @@ end subroutine plastic_nonlocal_results !-------------------------------------------------------------------------------------------------- !> @brief populates the initial dislocation density !-------------------------------------------------------------------------------------------------- -subroutine stateInit(ini,phase,Nconstituents) +subroutine stateInit(ini,phase,Nmembers) type(tInitialParameters) :: & ini integer,intent(in) :: & phase, & - Nconstituents + Nmembers integer :: & i, & e, & @@ -1602,7 +1602,7 @@ subroutine stateInit(ini,phase,Nconstituents) totalVolume, & densityBinning, & minimumIpVolume - real(pReal), dimension(Nconstituents) :: & + real(pReal), dimension(Nmembers) :: & volume @@ -1622,13 +1622,13 @@ subroutine stateInit(ini,phase,Nconstituents) meanDensity = 0.0_pReal do while(meanDensity < ini%random_rho_u) call random_number(rnd) - phasemember = nint(rnd(1)*real(Nconstituents,pReal) + 0.5_pReal) + phasemember = nint(rnd(1)*real(Nmembers,pReal) + 0.5_pReal) s = nint(rnd(2)*real(sum(ini%N_sl),pReal)*4.0_pReal + 0.5_pReal) meanDensity = meanDensity + densityBinning * volume(phasemember) / totalVolume stt%rhoSglMobile(s,phasemember) = densityBinning enddo else ! homogeneous distribution with noise - do e = 1, Nconstituents + do e = 1, Nmembers do f = 1,size(ini%N_sl,1) from = 1 + sum(ini%N_sl(1:f-1)) upto = sum(ini%N_sl(1:f)) @@ -1809,7 +1809,7 @@ pure function getRho0(ph,me) getRho0(:,mob) = max(getRho0(:,mob),0.0_pReal) getRho0(:,dip) = max(getRho0(:,dip),0.0_pReal) - where(abs(getRho0) < max(prm%rho_min/geom(ph)%V_0(me)**(2.0_pReal/3.0_pReal),prm%rho_significant)) & + where (abs(getRho0) < max(prm%rho_min/geom(ph)%V_0(me)**(2.0_pReal/3.0_pReal),prm%rho_significant)) & getRho0 = 0.0_pReal end associate @@ -1823,12 +1823,12 @@ subroutine storeGeometry(ph) integer :: ip, el, ce, co real(pReal), dimension(:), allocatable :: V - + V = reshape(IPvolume,[product(shape(IPvolume))]) do ce = 1, size(material_homogenizationMemberAt2,1) do co = 1, homogenization_maxNconstituents - if(material_phaseAt2(co,ce) == ph) geom(ph)%V_0(material_phaseMemberAt2(co,ce)) = V(ce) + if (material_phaseAt2(co,ce) == ph) geom(ph)%V_0(material_phaseMemberAt2(co,ce)) = V(ce) enddo enddo diff --git a/src/phase_mechanical_plastic_phenopowerlaw.f90 b/src/phase_mechanical_plastic_phenopowerlaw.f90 index d769431b4..ae5926c0f 100644 --- a/src/phase_mechanical_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanical_plastic_phenopowerlaw.f90 @@ -71,7 +71,7 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) logical, dimension(:), allocatable :: myPlasticity integer :: & ph, i, & - Nconstituents, & + Nmembers, & sizeState, sizeDotState, & startIndex, endIndex integer, dimension(:), allocatable :: & @@ -223,20 +223,20 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) !-------------------------------------------------------------------------------------------------- ! allocate state arrays - Nconstituents = count(material_phaseAt2 == ph) + Nmembers = count(material_phaseAt2 == ph) sizeDotState = size(['xi_sl ','gamma_sl']) * prm%sum_N_sl & + size(['xi_tw ','gamma_tw']) * prm%sum_N_tw sizeState = sizeDotState - call phase_allocateState(plasticState(ph),Nconstituents,sizeState,sizeDotState,0) + call phase_allocateState(plasticState(ph),Nmembers,sizeState,sizeDotState,0) !-------------------------------------------------------------------------------------------------- ! state aliases and initialization startIndex = 1 endIndex = prm%sum_N_sl stt%xi_slip => plasticState(ph)%state (startIndex:endIndex,:) - stt%xi_slip = spread(xi_0_sl, 2, Nconstituents) + stt%xi_slip = spread(xi_0_sl, 2, Nmembers) dot%xi_slip => plasticState(ph)%dotState(startIndex:endIndex,:) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) if(any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_xi' @@ -244,7 +244,7 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) startIndex = endIndex + 1 endIndex = endIndex + prm%sum_N_tw stt%xi_twin => plasticState(ph)%state (startIndex:endIndex,:) - stt%xi_twin = spread(xi_0_tw, 2, Nconstituents) + stt%xi_twin = spread(xi_0_tw, 2, Nmembers) dot%xi_twin => plasticState(ph)%dotState(startIndex:endIndex,:) plasticState(ph)%atol(startIndex:endIndex) = pl%get_asFloat('atol_xi',defaultVal=1.0_pReal) if(any(plasticState(ph)%atol(startIndex:endIndex) < 0.0_pReal)) extmsg = trim(extmsg)//' atol_xi' diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 012554aef..21ec93c9c 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -15,13 +15,13 @@ submodule(phase) thermal THERMAL_EXTERNALHEAT_ID end enum - type :: tDataContainer + type :: tDataContainer ! ?? not very telling name. Better: "fieldQuantities" ?? real(pReal), dimension(:), allocatable :: T, dot_T end type tDataContainer integer(kind(THERMAL_UNDEFINED_ID)), dimension(:,:), allocatable :: & thermal_source - type(tDataContainer), dimension(:), allocatable :: current + type(tDataContainer), dimension(:), allocatable :: current ! ?? not very telling name. Better: "field" ?? integer :: thermal_source_maxSizeDotState @@ -78,41 +78,36 @@ module subroutine thermal_init(phases) integer :: & ph, so, & - Nconstituents + Nmembers print'(/,a)', ' <<<+- phase:thermal init -+>>>' allocate(current(phases%length)) - allocate(thermalState (phases%length)) + allocate(thermalState(phases%length)) allocate(thermal_Nsources(phases%length),source = 0) do ph = 1, phases%length - - Nconstituents = count(material_phaseAt2 == ph) - - allocate(current(ph)%T(Nconstituents),source=300.0_pReal) - allocate(current(ph)%dot_T(Nconstituents),source=0.0_pReal) + Nmembers = count(material_phaseAt2 == ph) + allocate(current(ph)%T(Nmembers),source=300.0_pReal) + allocate(current(ph)%dot_T(Nmembers),source=0.0_pReal) phase => phases%get(ph) - if(phase%contains('thermal')) then - thermal => phase%get('thermal') - sources => thermal%get('source',defaultVal=emptyList) - - thermal_Nsources(ph) = sources%length - endif + thermal => phase%get('thermal',defaultVal=emptyDict) + sources => thermal%get('source',defaultVal=emptyList) + thermal_Nsources(ph) = sources%length allocate(thermalstate(ph)%p(thermal_Nsources(ph))) enddo allocate(thermal_source(maxval(thermal_Nsources),phases%length), source = THERMAL_UNDEFINED_ID) - if(maxval(thermal_Nsources) /= 0) then + if (maxval(thermal_Nsources) /= 0) then where(dissipation_init (maxval(thermal_Nsources))) thermal_source = THERMAL_DISSIPATION_ID where(externalheat_init(maxval(thermal_Nsources))) thermal_source = THERMAL_EXTERNALHEAT_ID endif thermal_source_maxSizeDotState = 0 - PhaseLoop2:do ph = 1,phases%length + do ph = 1,phases%length do so = 1,thermal_Nsources(ph) thermalState(ph)%p(so)%state = thermalState(ph)%p(so)%state0 @@ -120,7 +115,7 @@ module subroutine thermal_init(phases) thermal_source_maxSizeDotState = max(thermal_source_maxSizeDotState, & maxval(thermalState(ph)%p%sizeDotState)) - enddo PhaseLoop2 + enddo end subroutine thermal_init @@ -145,18 +140,17 @@ module subroutine phase_thermal_getRate(TDot, ph,me) do so = 1, thermal_Nsources(ph) select case(thermal_source(so,ph)) case (THERMAL_DISSIPATION_ID) - call dissipation_getRate(my_Tdot, ph,me) + call dissipation_getRate(my_Tdot, ph,me) case (THERMAL_EXTERNALHEAT_ID) - call externalheat_getRate(my_Tdot, ph,me) + call externalheat_getRate(my_Tdot, ph,me) case default - my_Tdot = 0.0_pReal + my_Tdot = 0.0_pReal end select Tdot = Tdot + my_Tdot enddo - end subroutine phase_thermal_getRate @@ -185,7 +179,7 @@ function phase_thermal_collectDotState(ph,me) result(broken) end function phase_thermal_collectDotState -module function thermal_stress(Delta_t,ph,me) result(converged_) +module function thermal_stress(Delta_t,ph,me) result(converged_) ! ?? why is this called "stress" when it seems closer to "updateState" ?? real(pReal), intent(in) :: Delta_t integer, intent(in) :: ph, me @@ -212,7 +206,7 @@ function integrateThermalState(Delta_t, ph,me) result(broken) sizeDotState broken = phase_thermal_collectDotState(ph,me) - if(broken) return + if (broken) return do so = 1, thermal_Nsources(ph) sizeDotState = thermalState(ph)%p(so)%sizeDotState @@ -301,14 +295,12 @@ function thermal_active(source_label,src_length) result(active_source) allocate(active_source(src_length,phases%length), source = .false. ) do p = 1, phases%length phase => phases%get(p) - if (phase%contains('thermal')) then - thermal => phase%get('thermal',defaultVal=emptyList) - sources => thermal%get('source',defaultVal=emptyList) - do s = 1, sources%length - src => sources%get(s) - if(src%get_asString('type') == source_label) active_source(s,p) = .true. - enddo - endif + thermal => phase%get('thermal',defaultVal=emptyDict) + sources => thermal%get('source',defaultVal=emptyList) + do s = 1, sources%length + src => sources%get(s) + active_source(s,p) = src%get_asString('type') == source_label + enddo enddo diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index 9c75763dc..d3e7094a1 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -31,7 +31,7 @@ module function dissipation_init(source_length) result(mySources) phase, & sources, thermal, & src - integer :: so,Nconstituents,ph + integer :: so,Nmembers,ph mySources = thermal_active('dissipation',source_length) @@ -54,8 +54,8 @@ module function dissipation_init(source_length) result(mySources) src => sources%get(so) prm%kappa = src%get_asFloat('kappa') - Nconstituents = count(material_phaseAt2 == ph) - call phase_allocateState(thermalState(ph)%p(so),Nconstituents,0,0,0) + Nmembers = count(material_phaseAt2 == ph) + call phase_allocateState(thermalState(ph)%p(so),Nmembers,0,0,0) end associate endif diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index c7f894215..257b4e282 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -38,7 +38,7 @@ module function externalheat_init(source_length) result(mySources) phase, & sources, thermal, & src - integer :: so,Nconstituents,ph + integer :: so,Nmembers,ph mySources = thermal_active('externalheat',source_length) @@ -67,8 +67,8 @@ module function externalheat_init(source_length) result(mySources) prm%f_T = src%get_asFloats('f_T',requiredSize = size(prm%t_n)) - Nconstituents = count(material_phaseAt2 == ph) - call phase_allocateState(thermalState(ph)%p(so),Nconstituents,1,1,0) + Nmembers = count(material_phaseAt2 == ph) + call phase_allocateState(thermalState(ph)%p(so),Nmembers,1,1,0) end associate endif enddo From 5cd68dbddb85191664e3aa78a7b9472ce42bdcb6 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 4 Mar 2021 15:35:17 -0500 Subject: [PATCH 342/352] fixed stray homogenization_Nmembers --> _Nconstituents --- src/phase_damage.f90 | 2 +- src/phase_mechanical.f90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 6ad25f1e9..c85075288 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -199,7 +199,7 @@ module subroutine phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, phiDot = 0.0_pReal dPhiDot_dPhi = 0.0_pReal - do co = 1, homogenization_Nmembers(material_homogenizationAt2(ce)) + do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce)) ph = material_phaseAt2(co,ce) me = material_phasememberAt2(co,ce) diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index d065fc74a..e642b22ef 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -280,7 +280,7 @@ module subroutine mechanical_init(materials,phases) do el = 1, size(material_phaseMemberAt,3); do ip = 1, size(material_phaseMemberAt,2) - do co = 1, homogenization_Nmembers(material_homogenizationAt(el)) + do co = 1, homogenization_Nconstituents(material_homogenizationAt(el)) material => materials%get(discretization_materialAt(el)) constituents => material%get('constituents') constituent => constituents%get(co) @@ -1238,7 +1238,7 @@ module subroutine mechanical_restore(ce,includeL) co, ph, me - do co = 1,homogenization_Nmembers(material_homogenizationAt2(ce)) + do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce)) ph = material_phaseAt2(co,ce) me = material_phaseMemberAt2(co,ce) if (includeL) then From 94b10b0621d71b66f7547d54f33dfb390d58fe2b Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 5 Mar 2021 03:12:08 +0100 Subject: [PATCH 343/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-591-g9f1d53d8b --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 542cffb8f..55e524c1a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-574-g109ad378c +v3.0.0-alpha2-591-g9f1d53d8b From 1b4901b60df42327674cc264cf26d0dc79d65e17 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Sun, 7 Mar 2021 23:37:30 +0000 Subject: [PATCH 344/352] Phase name consistent with file name. --- examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml index 7931ec267..39d565585 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml @@ -1,6 +1,6 @@ # 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: +cpTi: lattice: hP c/a: 1.587 mechanics: From 0f7ec7c06e3f07723d274db0875001d317d0fc46 Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 8 Mar 2021 03:20:48 +0100 Subject: [PATCH 345/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-593-g1b4901b60 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 55e524c1a..67cadbda6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-591-g9f1d53d8b +v3.0.0-alpha2-593-g1b4901b60 From 7cbc69a4ca51a1ce159a3ee1c1a8f74a234c727e Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 8 Mar 2021 11:02:27 -0500 Subject: [PATCH 346/352] added "Returns" to help --- python/damask/_table.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/python/damask/_table.py b/python/damask/_table.py index 68d6f94bf..5203b0b61 100644 --- a/python/damask/_table.py +++ b/python/damask/_table.py @@ -189,6 +189,11 @@ class Table: label : str Column label. + Returns + ------- + data : numpy.ndarray + Array of column data. + """ if re.match(r'[0-9]*?_',label): idx,key = label.split('_',1) @@ -212,6 +217,11 @@ class Table: info : str, optional Human-readable information about the new data. + Returns + ------- + table : Table + Updated table. + """ dup = self.copy() dup._add_comment(label,data.shape[1:],info) @@ -238,6 +248,11 @@ class Table: info : str, optional Human-readable information about the modified data. + Returns + ------- + table : Table + Updated table. + """ dup = self.copy() dup._add_comment(label,data.shape[1:],info) @@ -261,6 +276,11 @@ class Table: label : str Column label. + Returns + ------- + table : Table + Updated table. + """ dup = self.copy() dup.data.drop(columns=label,inplace=True) @@ -279,6 +299,11 @@ class Table: label_new : str or iterable of str New column label(s). + Returns + ------- + table : Table + Updated table. + """ dup = self.copy() columns = dict(zip([old] if isinstance(old,str) else old, @@ -300,6 +325,11 @@ class Table: ascending : bool or list, optional Set sort order. + Returns + ------- + table : Table + Updated table. + """ dup = self.copy() dup._label_discrete() @@ -320,6 +350,11 @@ class Table: other : Table Table to append. + Returns + ------- + table : Table + Concatenated table. + """ if self.shapes != other.shapes or not self.data.columns.equals(other.data.columns): raise KeyError('Labels or shapes or order do not match') @@ -340,6 +375,10 @@ class Table: other : Table Table to join. + Returns + ------- + table : Table + Joined table. """ if set(self.shapes) & set(other.shapes) or self.data.shape[0] != other.data.shape[0]: raise KeyError('Dublicated keys or row count mismatch') From 4208c4e713234424cc47bc9163c6e155f4da55de Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 8 Mar 2021 11:03:18 -0500 Subject: [PATCH 347/352] adapted to Table.add being out-of-place --- python/damask/_result.py | 4 ++-- python/damask/_table.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index 50e2aa720..56924c533 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -391,12 +391,12 @@ class Result: path = (os.path.join(*([prop,name]+([cat] if cat else [])+([item] if item else []))) if split else path)+tag if split: try: - tbl[inc].add(path,data) + tbl[inc] = tbl[inc].add(path,data) except KeyError: tbl[inc] = Table(data.reshape(self.N_materialpoints,-1),{path:data.shape[1:]}) else: try: - tbl.add(path,data) + tbl = tbl.add(path,data) except AttributeError: tbl = Table(data.reshape(self.N_materialpoints,-1),{path:data.shape[1:]}) diff --git a/python/damask/_table.py b/python/damask/_table.py index 5203b0b61..ee64ba017 100644 --- a/python/damask/_table.py +++ b/python/damask/_table.py @@ -379,6 +379,7 @@ class Table: ------- table : Table Joined table. + """ if set(self.shapes) & set(other.shapes) or self.data.shape[0] != other.data.shape[0]: raise KeyError('Dublicated keys or row count mismatch') From 97dbf7c5b0e404e1a23cdc13b45faaa30587ef47 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 9 Mar 2021 00:50:01 +0100 Subject: [PATCH 348/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-597-g6b6f66a5b --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 67cadbda6..98ffcb459 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-593-g1b4901b60 +v3.0.0-alpha2-597-g6b6f66a5b From a26e586b144d8029bc7f19917a30fc817ef79d6c Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 9 Mar 2021 19:15:15 +0000 Subject: [PATCH 349/352] More general 'delete' (accepts iterables) and backports of '|' and '|=' for union/add. '|=' would work for python 3.9 without extra code, but '|' unfortunately casts 'damask.Config' (subclass of 'dict') to a 'dict'. --- python/damask/_config.py | 61 ++++++++++++++++++++++--------------- python/tests/test_Config.py | 11 ++++++- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/python/damask/_config.py b/python/damask/_config.py index edf3a5676..85f0c208c 100644 --- a/python/damask/_config.py +++ b/python/damask/_config.py @@ -1,5 +1,6 @@ import copy from io import StringIO +from collections.abc import Iterable import abc import numpy as np @@ -44,6 +45,42 @@ class Config(dict): copy = __copy__ + def __or__(self,other): + """ + Update configuration with contents of other. + + Parameters + ---------- + other : damask.Config or dict + Key-value pairs that update self. + + """ + duplicate = self.copy() + duplicate.update(other) + return duplicate + + + def __ior__(self,other): + """Update configuration with contents of other.""" + return self.__or__(other) + + + def delete(self,keys): + """ + Remove configuration keys. + + Parameters + ---------- + keys : iterable or scalar + Label of the key(s) to remove. + + """ + duplicate = self.copy() + for k in keys if isinstance(keys, Iterable) and not isinstance(keys, str) else [keys]: + del duplicate[k] + return duplicate + + @classmethod def load(cls,fname): """ @@ -99,30 +136,6 @@ class Config(dict): fhandle.write(yaml.dump(self,Dumper=NiceDumper,**kwargs)) - def add(self,d): - """ - Add dictionary. - - d : dict - Dictionary to append. - """ - duplicate = self.copy() - duplicate.update(d) - return duplicate - - - def delete(self,key): - """ - Delete item. - - key : str or scalar - Label of the key to remove. - """ - duplicate = self.copy() - del duplicate[key] - return duplicate - - @property @abc.abstractmethod def is_complete(self): diff --git a/python/tests/test_Config.py b/python/tests/test_Config.py index 0319fb6de..9324c28c5 100644 --- a/python/tests/test_Config.py +++ b/python/tests/test_Config.py @@ -23,8 +23,17 @@ class TestConfig: assert Config.load(f) == config def test_add_remove(self): + dummy = {'hello':'world','foo':'bar'} config = Config() - assert config.add({'hello':'world'}).delete('hello') == config + config |= dummy + assert config == Config() | dummy + config = config.delete(dummy) + assert config == Config() + assert (config | dummy ).delete( 'hello' ) == config | {'foo':'bar'} + assert (config | dummy ).delete([ 'hello', 'foo' ]) == config + assert (config | Config(dummy)).delete({ 'hello':1,'foo':2 }) == config + assert (config | Config(dummy)).delete(Config({'hello':1 })) == config | {'foo':'bar'} + def test_repr(self,tmp_path): config = Config() From 569e1c2067e2382f30617f8b3c21b875d6e203c1 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 9 Mar 2021 23:18:27 +0100 Subject: [PATCH 350/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-600-g1aaa658e3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 98ffcb459..5b2965883 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-597-g6b6f66a5b +v3.0.0-alpha2-600-g1aaa658e3 From e2d4ab427ec7319eaeceb9cba6c7e3fb4dcf842a Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 9 Mar 2021 22:02:49 -0500 Subject: [PATCH 351/352] explicit path joining with "/" in _result; updated cpTi CRSS --- examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml | 7 ++++--- python/damask/_result.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml index 39d565585..aa5262454 100644 --- a/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml +++ b/examples/ConfigFiles/Phase_Phenopowerlaw_cpTi.yaml @@ -1,5 +1,6 @@ # 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 +# Better use values from L. Wang, Z. Zheng, H. Phukan, P. Kenesei, J.-S. Park, J. Lind, R.M. Suter, T.R. Bieler, Direct measurement of critical resolved shear stress of prismatic and basal slip in polycrystalline Ti using high energy X-ray diffraction microscopy, Acta Mater 2017 cpTi: lattice: hP c/a: 1.587 @@ -7,7 +8,7 @@ cpTi: output: [F, P, F_e, F_p, L_p, O] 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, 0, 12] + N_sl: [3, 3, 0, 6, 12] a_sl: 2.0 dot_gamma_0_sl: 0.001 h_0_sl_sl: 200e6 @@ -15,5 +16,5 @@ cpTi: n_sl: 20 output: [gamma_sl] type: phenopowerlaw - xi_0_sl: [349e6, 150e6, 0, 0, 1107e6] - xi_inf_sl: [568e6, 1502e6, 0, 0, 3420e6] + xi_0_sl: [0.15e9, 0.09e9, 0, 0.20e9, 0.25e9] + xi_inf_sl: [0.24e9, 0.5e9, 0, 0.6e9, 0.8e9] diff --git a/python/damask/_result.py b/python/damask/_result.py index 56924c533..4ecd0ba51 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -371,7 +371,7 @@ class Result: with h5py.File(self.fname,'r') as f: for dataset in sets: for group in self.groups_with_datasets(dataset): - path = os.path.join(group,dataset) + path = '/'.join([group,dataset]) inc,prop,name,cat,item = (path.split('/') + ['']*5)[:5] key = '/'.join([prop,name+tag]) if key not in inGeom: @@ -388,7 +388,7 @@ class Result: np.nan, dtype=np.dtype(f[path])) data[inGeom[key]] = (f[path] if len(shape)>1 else np.expand_dims(f[path],1))[inData[key]] - path = (os.path.join(*([prop,name]+([cat] if cat else [])+([item] if item else []))) if split else path)+tag + path = ('/'.join([prop,name]+([cat] if cat else [])+([item] if item else [])) if split else path)+tag if split: try: tbl[inc] = tbl[inc].add(path,data) From 8daa8a965c774ef44b5865c1f030dc594974df12 Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 10 Mar 2021 05:37:26 +0100 Subject: [PATCH 352/352] [skip ci] updated version information after successful test of v3.0.0-alpha2-602-ge2d4ab427 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5b2965883..bbcfb4711 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-600-g1aaa658e3 +v3.0.0-alpha2-602-ge2d4ab427