From a2fe86a41004f67f68d8848a55490d15ffbecd8b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 26 Jan 2021 11:45:39 +0100 Subject: [PATCH] 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