Path: blob/devel/elmerice/UserFunctions/CaffeFlow.F90
3196 views
!/*****************************************************************************/1! *2! * Elmer/Ice, a glaciological add-on to Elmer3! * http://elmerice.elmerfem.org4! *5! *6! * This program is free software; you can redistribute it and/or7! * modify it under the terms of the GNU General Public License8! * as published by the Free Software Foundation; either version 29! * of the License, or (at your option) any later version.10! *11! * This program is distributed in the hope that it will be useful,12! * but WITHOUT ANY WARRANTY; without even the implied warranty of13! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14! * GNU General Public License for more details.15! *16! * You should have received a copy of the GNU General Public License17! * along with this program (in file fem/GPL-2); if not, write to the18! * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,19! * Boston, MA 02110-1301, USA.20! *21! *****************************************************************************/22! ******************************************************************************23! *24! * Authors: Juha Ruokolainen, Hakime Seddik25! * Email: [email protected]26! * Address: Institute of Low Temperature Science27! * Hokkaido University28! * Sapporo-shi Kita-ku, Kita 19, nishi 629! * Hokkaido ; Japan30! * EMail: [email protected]31! * Web: http://elmerice.elmerfem.org32! *33! * Original Date: 9 July 199734! * Modification Date:35! *36! *****************************************************************************37!> CaffeFlow.f90 anisotropic model for ice flow38!> Caffe model: viscosity factor as a function of ice anisotropy and temperature39FUNCTION caffeGetViscosity ( Model, nodenumber, temperature ) RESULT(anisoVisFact)40USE types41USE DefUtils42USE CoordinateSystems43USE SolverUtils44USE ElementDescription45!-----------------------------------------------------------46IMPLICIT NONE47!------------ external variables ---------------------------48TYPE(Model_t) :: Model49INTEGER :: nodenumber50REAL(KIND=dp) :: temperature, anisoVisFact51!------------ internal variables----------------------------52TYPE(Element_t), POINTER :: CurrentElement53TYPE(Nodes_t) :: ElementNodes54TYPE(Variable_t), POINTER :: FlowVariable, FabricVariable, TempVariable55TYPE(ValueList_t), POINTER :: Material56REAL(KIND=dp), POINTER :: Hwrk(:,:,:)57REAL(KIND=dp) :: LocalVelo(3, Model % MaxElementNodes)58REAL(KIND=dp), DIMENSION(Model % MaxElementNodes) :: Expo59REAL(KIND=dp) ::&60rateFactor, aToMinusOneThird, gasconst, temphom61REAL (KIND=dp), ALLOCATABLE :: activationEnergy(:,:), arrheniusFactor(:,:),&62aniEnhancementFact(:), viscosityExponent(:), PressureMeltingPoint(:),&63LimitTemp(:)64REAL(KIND=dp), POINTER :: FlowValues(:), FabricValues(:), TempValues(:)65REAL(KIND=dp) :: Basis( Model % MaxElementNodes ), ddBasisddx(1,1,1), dBasisdx( Model % MaxElementNodes , 3 )66REAL(KIND=dp) :: u, v, w, detJ, LGrad(3,3), Dij(3,3)67REAL (KIND=dp) :: a1133, a2233, a3333, a3331, a3332, a331268REAL (KIND=dp) :: AfirstArg,AsecondArg, Aconst, Eps69REAL (KIND=dp) :: Emin, MinGamma70REAL(KIND=dp) :: a2(6), a4(9), A, E, m, Temp71INTEGER, POINTER :: FlowPerm(:), FabricPerm(:), TempPerm(:), NodeIndexes(:)72INTEGER :: DIM, nMax, t, i, j, k, STDOFs, n73INTEGER :: material_id, body_id, elementNbNodes, nodeInElement, istat74LOGICAL :: stat, FirstTime=.TRUE., GotIt75CHARACTER(LEN=MAX_NAME_LEN) :: TempName7677!------------ remember this -------------------------------78SAVE ElementNodes, DIM, FirstTime, gasconst, activationEnergy, arrheniusFactor,&79aniEnhancementFact, viscosityExponent, Hwrk, PressureMeltingPoint, &80LimitTemp8182!-----------------------------------------------------------83! Read in constants from SIF file and do some allocations84!-----------------------------------------------------------85IF (FirstTime) THEN86! inquire coordinate system dimensions and degrees of freedom from NS-Solver87! ---------------------------------------------------------------------------8889ALLOCATE( ElementNodes % x ( Model % MaxElementNodes ), &90ElementNodes % y ( Model % MaxElementNodes ), &91ElementNodes % z ( Model % MaxElementNodes ) )9293DIM = CoordinateSystemDimension()9495gasconst = ListGetConstReal( Model % Constants,'Gas Constant',GotIt)96IF (.NOT. GotIt) THEN97gasconst = 8.314D00 ! m-k-s98WRITE(Message,'(a,e10.4,a)') 'No entry for Gas Constant (Constants) in input file found. Setting to ',&99gasconst,' (J/mol)'100CALL INFO('CAFFE (CAFFEViscosity)', Message, level=4)101END IF102nMax = Model % MaxElementNodes103ALLOCATE(activationEnergy(2,nMax),&104arrheniusFactor(2,nMax),&105LimitTemp( nMax),&106aniEnhancementFact(nMax),&107PressureMeltingPoint( nMax ),&108viscosityExponent(nMax),&109STAT=istat)110IF ( istat /= 0 ) THEN111CALL Fatal('CAFFE (CAFFEViscosity)','Memory allocation error, Aborting.')112END IF113NULLIFY( Hwrk )114FirstTime = .FALSE.115CALL Info('CAFFE (CAFFEViscosity)','Memory allocations done', Level=3)116END IF117118!---------------------------------------------119! get element properties and solver variables120!---------------------------------------------121FlowVariable => VariableGet( Model % Solver % Mesh % Variables, "flow solution" )122IF ( ASSOCIATED( FlowVariable ) ) THEN123FlowPerm => FlowVariable % Perm124FlowValues => FlowVariable % Values125ELSE126CALL Info('CAFFE', &127& 'No variable for velocity associated.', Level=4)128END IF129130STDOFs = FlowVariable % DOFs131132FabricVariable => VariableGet( Model % Solver % Mesh % Variables, "fabric" )133IF ( ASSOCIATED( FabricVariable ) ) THEN134FabricPerm => FabricVariable % Perm135FabricValues => FabricVariable % Values136ELSE137CALL Info('CAFFE', &138& 'No variable for fabric associated.', Level=4)139END IF140141142! TempVariable => VariableGet( Model % Solver % Mesh % Variables, 'Temperature' )143! IF ( ASSOCIATED( TempVariable) ) THEN144! TempPerm => TempVariable % Perm145! TempValues => TempVariable % Values146! END IF147148body_id = Model % CurrentElement % BodyId149150material_id = ListGetInteger(Model % Bodies(body_id) % Values, 'Material', GotIt)151IF (.NOT.GotIt) CALL FATAL('CAFFE (CAFFEViscosity)','No Material ID found')152153CurrentElement => Model % CurrentElement154elementNbNodes = GetElementNOFNodes()155IF (.NOT. GotIt) THEN156WRITE(Message,'(a,I2,a,I2,a)') 'No material id for current element of node ',nodenumber,', body ',body_id,' found'157CALL FATAL('CAFFE (CAFFEViscosity)', Message)158END IF159NodeIndexes => CurrentElement % NodeIndexes160161162Material => Model % Materials(material_id) % Values163IF (.NOT.ASSOCIATED(Material)) THEN164WRITE(Message,'(a,I2,a,I2,a)') 'No Material for current element of node ',nodenumber,', body ',body_id,' found'165CALL FATAL('CAFFE (CAFFEViscosity)',Message)166END IF167168ElementNodes % x(1:elementNbNodes) = Model % Nodes % x(NodeIndexes(1:elementNbNodes))169ElementNodes % y(1:elementNbNodes) = Model % Nodes % y(NodeIndexes(1:elementNbNodes))170ElementNodes % z(1:elementNbNodes) = Model % Nodes % z(NodeIndexes(1:elementNbNodes))171172! 2D U,V,p STDOFs=3173! 3D U,V,W,p STDOFs=4174LocalVelo = 0.0_dp175DO i = 1, STDOFs - 1176LocalVelo(i,1:elementNbNodes) = FlowValues( STDOFs*(FlowPerm(NodeIndexes(1:elementNbNodes))-1) + i)177END DO178179! Locala11(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 1 )180! Locala22(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 2 )181! Locala12(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 3 )182! Locala23(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 4 )183! Locala31(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 5 )184185186DO i=1,elementNbNodes187IF (nodenumber == NodeIndexes( i )) THEN188189!-------------------------------------------190! get material properties191!-------------------------------------------192! activation energies193!--------------------194CALL ListGetRealArray( Material,'Activation Energies',Hwrk, elementNbNodes, &195Model % CurrentElement % NodeIndexes, GotIt )196IF (.NOT. GotIt) THEN197WRITE(Message,'(a,I2,a,I2)') 'No Value for Activation Energy found in Material ', material_id,' for node ', nodenumber198CALL FATAL(' CAFFE (CAFFEViscosity)',Message)199END IF200IF ( SIZE(Hwrk,2) == 1 ) THEN201DO j=1,MIN(3,SIZE(Hwrk,1))202activationEnergy(j,1:elementNbNodes) = Hwrk(j,1,1:elementNbNodes)203END DO204ELSE205WRITE(Message,'(a,I2,a,I2)') 'Incorrect array size for Activation Energy in Material ', material_id,' for node ', nodenumber206CALL FATAL('CAFFE (CAFFEViscosity)',Message)207END IF208209! Arrhenius Factors210! ------------------211CALL ListGetRealArray( Material,'Arrhenius Factors',Hwrk,elementNbNodes, &212Model % CurrentElement % NodeIndexes, GotIt )213IF (.NOT. GotIt) THEN214WRITE(Message,'(a,I2,a,I2)') 'No Value for Arrhenius Factors found in Material ', material_id,' for node ', nodenumber215CALL FATAL('CAFFE (CAFFEViscosity)',Message)216END IF217IF ( SIZE(Hwrk,2) == 1 ) THEN218DO j=1,MIN(3,SIZE(Hwrk,1))219arrheniusFactor(j,1:elementNbNodes) = Hwrk(j,1,1:elementNbNodes)220END DO221ELSE222WRITE(Message,'(a,I2,a,I2)') 'Incorrect array size for Arrhenius Factors in Material ', material_id,' for node ', nodenumber223CALL FATAL('CAFFE (CAFFEViscosity)',Message)224END IF225226! Threshold temperature for switching activation energies and Arrhenius factors227!------------------------------------------------------------------------------228LimitTemp(1:elementNbNodes) = ListGetReal( Material,'Limit Temperature', elementNbNodes,&229Model % CurrentElement % NodeIndexes, GotIt )230IF (.NOT. GotIt) THEN231LimitTemp(1:elementNbNodes) = -1.0D01232WRITE(Message,'(a,I2,a,I2,a)') 'No keyword >Limit Temperature< found in Material ',&233material_id,' for node ', nodenumber, '.setting to -10'234CALL INFO('CAFFE (CAFFEViscosity)', Message, level=4)235END IF236237! Viscosity Exponent238!-------------------239viscosityExponent(1:elementNbNodes) = ListGetReal( Material,'Viscosity Exponent', elementNbNodes, &240Model % CurrentElement % NodeIndexes, GotIt )241IF (.NOT. GotIt) THEN242viscosityExponent(1:elementNbNodes) = 1.0D00/3.0D00243WRITE(Message,'(a,I2,a,I2,a)') 'No Viscosity Exponent found in Material ', material_id,&244' for node ', nodenumber, '.setting k=1/3'245CALL INFO('CAFFE (CAFFEViscosity)', Message, level=4)246END IF247248! Enhancement factor for anisotropic flow law249! -------------------------------------------250aniEnhancementFact(1:elementNbNodes) = ListGetReal( Material,'Anisotropic Enhancement Factor', &251elementNbNodes, Model % CurrentElement % NodeIndexes, GotIt )252IF (.NOT. GotIt) THEN253WRITE(Message,'(a,I2,a,I2,a)') 'Value for Maximum Enhancement factor not found in Matrial', &254material_id,' for node ', nodenumber255CALL Fatal('CAFFE (CAFFEViscosity)', Message)256END IF257258! Critical Enhancement factor to avoid singularities in anisotropic flow law259! --------------------------------------------------------------------------260Emin = GetConstReal(Material, 'Critical Enhancement factor', GotIt)261IF(.NOT. GotIt) THEN262Emin=0.0001263WRITE(Message,'(a,I2,a,I2,a)') 'Value for Critical Enhancement factor not found in Matrial', &264material_id,' for node ', nodenumber, '.setting Emin=1.Oe-4'265CALL INFO('CAFFE (CAFFEViscosity)', Message, level=3)266END IF267268! Critical parameter to avoid singulairties in computing the polycrystall deformability269! -------------------------------------------------------------------------------------270MinGamma = GetConstReal(Material, 'Critical Strain Rate', GotIt)271IF(.NOT. GotIt) THEN272MinGamma=1.0e-15273WRITE(Message,'(a,I2,a,I2,a)') 'Critical Strain rate not found in Matrial', material_id, &274' for node ', nodenumber, '.setting MinGamma=1.0e-15'275Call INFO('CAFFE (CAFFEViscosity)', Message, level=3)276END IF277278! Pressure Melting Point and homologous temperature279! --------------------------------------------------280TempName = GetString(Material ,'Temperature Name', GotIt)281IF (.NOT.GotIt) CALL FATAL('CAFFE (CAFFEViscosity)','No Temperature Name found')282PressureMeltingPoint(1:elementNbNodes) =&283ListGetReal( Material, TRIM(TempName) // ' Upper Limit',&284elementNbNodes, Model % CurrentElement % NodeIndexes, GotIt)285IF (.NOT.GotIt) THEN286temphom = 0.0d00287WRITE(Message,'(A,A,A,i3,A)') 'No entry for ',TRIM(TempName) // ' Upper Limit',&288' found in material no. ', material_id,'. Using 273.16 K.'289CALL WARN('iceproperties (getViscosityFactor)',Message)290ELSE291temphom = MIN(temperature - PressureMeltingPoint(i), 0.0d00)292END IF293!----------------------------------------------------294! homologous Temperature is below -10 degrees celsius295!----------------------------------------------------296IF (temphom < LimitTemp(i)) THEN297k=1298!----------------------------------------------------299! homologous Temperature is above -10 degrees celsius300!----------------------------------------------------301ELSE302k=2303END IF304!----------------------------------------------305! Comput the rate factor306!----------------------------------------------307rateFactor =&308arrheniusFactor(k,i)*exp(-1.0D00*activationEnergy(k,i)/(gasconst*(2.7315D02 + temphom)))309310! u, v, w local coord of node i311u = CurrentElement % TYPE % NodeU(i)312v = CurrentElement % TYPE % NodeV(i)313w = CurrentElement % TYPE % NodeW(i)314315stat = ElementInfo(CurrentElement, ElementNodes, u, v, w, detJ, &316Basis, dBasisdx, ddBasisddx, .FALSE., .FALSE.)317318LGrad = MATMUL( LocalVelo(:,1:elementNbNodes), dBasisdx(1:elementNbNodes,:))319320Dij = 0.5_dp * ( LGrad + TRANSPOSE(LGrad) )321322! Temp = TempValues( TempPerm( NodeIndexes(i) ) )323! m = Expo( i )324325IF ( ASSOCIATED( FabricVariable ) ) THEN326a2(1) = FabricValues( 5 * (FabricPerm(NodeIndexes(i))-1) + 1 )327a2(2) = FabricValues( 5 * (FabricPerm(NodeIndexes(i))-1) + 2 )328a2(3) = 1.0_dp - a2(1) - a2(2)329a2(4) = FabricValues( 5 * (FabricPerm(NodeIndexes(i))-1) + 3 )330a2(5) = FabricValues( 5 * (FabricPerm(NodeIndexes(i))-1) + 4 )331a2(6) = FabricValues( 5 * (FabricPerm(NodeIndexes(i))-1) + 5 )332! a2(1) = SUM( Locala11(1:n) * Basis(1:n) )333ELSE334a2(4:6) = 0.0335a2(1:3) = 1.0/3.0_dp336END IF337338CALL IBOF( a2, a4 )339340!Compute the rest of the components of the a4 orientation tensor341342! a1133 = -a1111+a11-a1122343a1133 = -a4(1)+a2(1)-a4(3)344345! a2233 = -a2222+a22-a1122346a2233 = -a4(2)+a2(2)-a4(3)347348! a3333 = a33-a1133-a2233349a3333 = a2(3)-a1133-a2233350351! a3331=a1333=a13-a1311-a1322=a13-a1131-a2231352a3331 = a2(6)-a4(6)-a4(5)353354! a3332=a2333=a23-a2311-a2322=a23-a1123-a2223355a3332 = a2(5)-a4(4)-a4(8)356357! a3312=a1233=a12-a1211-a1222=a12-a1112-a2212358a3312 = a2(4)-a4(7)-a4(9)359360!If necessary correct D11, D22, D33 to preserve incompressibility361Eps = Dij(1,1)+Dij(2,2)+Dij(3,3)362IF (Eps > 0 .OR. Eps < 0 ) THEN363Eps = Eps/3.0D00364365Dij(1,1)= Dij(1,1)-Eps366Dij(2,2)= Dij(2,2)-Eps367Dij(3,3)= Dij(3,3)-Eps368END IF369370! Computes the arguments of the equation of A371AfirstArg = a2(1)*((Dij(1,1))**2.0+(Dij(1,2))**2.0+(Dij(1,3))**2.0) &372+a2(2)*((Dij(1,2))**2.0+(Dij(2,2))**2.0+(Dij(2,3))**2.0) &373+a2(3)*((Dij(1,3))**2.0+(Dij(2,3))**2.0+(Dij(3,3))**2.0) &374+a2(4)*(2.0*Dij(1,1)*Dij(1,2)+2.0*Dij(2,2)*Dij(1,2)+2.0*Dij(2,3)*Dij(1,3)) &375+a2(5)*(2.0*Dij(1,3)*Dij(1,2)+2.0*Dij(2,2)*Dij(2,3)+2.0*Dij(3,3)*Dij(2,3)) &376+a2(6)*(2.0*Dij(1,1)*Dij(1,3)+2.0*Dij(2,3)*Dij(1,2)+2.0*Dij(3,3)*Dij(1,3))377378AsecondArg = a4(1)*(Dij(1,1))**2.0+a4(2)*(Dij(2,2))**2.0+a3333*(Dij(3,3))**2.0 &379+a4(3)*(2*Dij(1,1)*Dij(2,2)+4.0*(Dij(1,2))**2.0) &380+a1133*(2*Dij(1,1)*Dij(3,3)+4.0*(Dij(1,3))**2.0) &381+a2233*(2*Dij(2,2)*Dij(3,3)+4.0*(Dij(2,3))**2.0) &382+4.0*a4(4)*Dij(1,1)*Dij(2,3)+8.0*a4(4)*Dij(1,2)*Dij(1,3) &383+4.0*a4(5)*Dij(2,2)*Dij(1,3)+8.0*a4(5)*Dij(1,2)*Dij(2,3) &384+4.0*a3312*Dij(3,3)*Dij(1,2)+8.0*a3312*Dij(1,3)*Dij(2,3) &385+4.0*a4(7)*Dij(1,1)*Dij(1,2)+4.0*a4(6)*Dij(1,1)*Dij(1,3) &386+4.0*a4(9)*Dij(2,2)*Dij(2,1)+4.0*a4(8)*Dij(2,2)*Dij(2,3) &387+4.0*a3331*Dij(3,3)*Dij(1,3)+4.0*a3332*Dij(3,3)*Dij(2,3)388389390! Compute the 5/tr(D)^2391Aconst = (Dij(1,1))**2.0+(Dij(2,2))**2.0+(Dij(3,3))**2.0+2.0*(Dij(1,2))**2.0+ &3922.0*(Dij(3,1))**2.0+2.0*(Dij(2,3))**2.0393394IF (Aconst < MinGamma) Aconst = MinGamma395396! IF (sqrt(2.0*Aconst) < MinGamma) THEN397! A = 1.0_dp398! ELSE399400! Compute the value of A=(5/tr(D)^2)*(D.a2.D-(a4:D):D)401A = 5.0_dp * (AfirstArg-AsecondArg) / Aconst402! END IF403404! Compute the Enhancement factor function405IF (A >= 1.0 ) THEN406E = (4.0*A**2.0*(aniEnhancementFact(i)-1.0)+25.0-4.0*aniEnhancementFact(i))/21.0407ELSE408E = (1.0-Emin)*A**((8.0/21.0)*((aniEnhancementFact(i)-1.0)/(1.0-Emin)))+Emin409END IF410411! Compute the viscosity412anisoVisFact = 1.0D00 / (( 2.0D00 * E * rateFactor )**viscosityExponent(i))413414EXIT415END IF416END DO417! write(*,*)A,E,anisoVisFact418419CONTAINS420421!!! Compute fourth order tensor a4 from a2 with closure function IBOF (Chung, 2002)422!!! a2 enters in the order : 11, 22, 33, 12, 23 ,13423!!! Output for a4 is in the order : 1111, 2222, 1122, 1123, 2231, 1131, 1112, 2223, 2212424!!! Code modified from Gillet-Chaullet source425!------------------------------------------------------------------------------426SUBROUTINE IBOF(a2,a4)427428USE Types429430implicit none431Real(dp),dimension(6),intent(in):: a2432Real(dp),dimension(9),intent(out):: a4433Real(dp):: a_11,a_22,a_33,a_12,a_13,a_23434Real(dp):: b_11,b_22,b_12,b_13,b_23435Real(dp):: aPlusa436437Real(dp),dimension(21) :: vec438Real(dp),dimension(3,21) :: Mat439Real(dp),dimension(6) :: beta440Real(dp) :: Inv2,Inv3441integer :: i,j442443444a_11=a2(1)445a_22=a2(2)446a_33=a2(3)447a_12=a2(4)448a_23=a2(5)449a_13=a2(6)450451452!Coefficiants453454Mat(1,1)=0.217774509809788e+02_dp455Mat(1,2)=-.297570854171128e+03_dp456Mat(1,3)=0.188686077307885e+04_dp457Mat(1,4)=-.272941724578513e+03_dp458Mat(1,5)=0.417148493642195e+03_dp459Mat(1,6)=0.152038182241196e+04_dp460Mat(1,7)=-.137643852992708e+04_dp461Mat(1,8)=-.628895857556395e+03_dp462Mat(1,9)=-.526081007711996e+04_dp463Mat(1,10)=-.266096234984017e+03_dp464Mat(1,11)=-.196278098216953e+04_dp465Mat(1,12)=-.505266963449819e+03_dp466Mat(1,13)=-.110483041928547e+03_dp467Mat(1,14)=0.430488193758786e+04_dp468Mat(1,15)=-.139197970442470e+02_dp469Mat(1,16)=-.144351781922013e+04_dp470Mat(1,17)=-.265701301773249e+03_dp471Mat(1,18)=-.428821699139210e+02_dp472Mat(1,19)=-.443236656693991e+01_dp473Mat(1,20)=0.309742340203200e+04_dp474Mat(1,21)=0.386473912295113e+00_dp475Mat(2,1)=-.514850598717222e+00_dp476Mat(2,2)=0.213316362570669e+02_dp477Mat(2,3)=-.302865564916568e+03_dp478Mat(2,4)=-.198569416607029e+02_dp479Mat(2,5)=-.460306750911640e+02_dp480Mat(2,6)=0.270825710321281e+01_dp481Mat(2,7)=0.184510695601404e+03_dp482Mat(2,8)=0.156537424620061e+03_dp483Mat(2,9)=0.190613131168980e+04_dp484Mat(2,10)=0.277006550460850e+03_dp485Mat(2,11)=-.568117055198608e+02_dp486Mat(2,12)=0.428921546783467e+03_dp487Mat(2,13)=0.142494945404341e+03_dp488Mat(2,14)=-.541945228489881e+04_dp489Mat(2,15)=0.233351898912768e+02_dp490Mat(2,16)=0.104183218654671e+04_dp491Mat(2,17)=0.331489412844667e+03_dp492Mat(2,18)=0.660002154209991e+02_dp493Mat(2,19)=0.997500770521877e+01_dp494Mat(2,20)=0.560508628472486e+04_dp495Mat(2,21)=0.209909225990756e+01_dp496Mat(3,1)=0.203814051719994e+02_dp497Mat(3,2)=-.283958093739548e+03_dp498Mat(3,3)=0.173908241235198e+04_dp499Mat(3,4)=-.195566197110461e+03_dp500Mat(3,5)=-.138012943339611e+03_dp501Mat(3,6)=0.523629892715050e+03_dp502Mat(3,7)=0.859266451736379e+03_dp503Mat(3,8)=-.805606471979730e+02_dp504Mat(3,9)=-.468711180560599e+04_dp505Mat(3,10)=0.889580760829066e+01_dp506Mat(3,11)=-.782994158054881e+02_dp507Mat(3,12)=-.437214580089117e+02_dp508Mat(3,13)=0.112996386047623e+01_dp509Mat(3,14)=0.401746416262936e+04_dp510Mat(3,15)=0.104927789918320e+01_dp511Mat(3,16)=-.139340154288711e+03_dp512Mat(3,17)=-.170995948015951e+02_dp513Mat(3,18)=0.545784716783902e+00_dp514Mat(3,19)=0.971126767581517e+00_dp515Mat(3,20)=0.141909512967882e+04_dp516Mat(3,21)=0.994142892628410e+00_dp517518519! Compute the invariants520Inv2=0.5_dp*(1._dp-(a_11*a_11+a_22*a_22+a_33*a_33+ &5212._dp*(a_12*a_12+a_13*a_13+a_23*a_23)))522523Inv3=a_11*(a_22*a_33-a_23*a_23)+a_12*(a_23*a_13-a_12*a_33)+ &524a_13*(a_12*a_23-a_22*a_13)525526! complete polynome of degree 5 for the 2 invariants.527vec(1)=1._dp528vec(2)=Inv2529vec(3)=vec(2)*vec(2)530vec(4)=Inv3531vec(5)=vec(4)*vec(4)532vec(6)=vec(2)*vec(4)533vec(7)=vec(3)*vec(4)534vec(8)=vec(2)*vec(5)535vec(9)=vec(2)*vec(3)536vec(10)=vec(5)*vec(4)537vec(11)=vec(9)*vec(4)538vec(12)=vec(3)*vec(5)539vec(13)=vec(2)*vec(10)540vec(14)=vec(3)*vec(3)541vec(15)=vec(5)*vec(5)542vec(16)=vec(14)*vec(4)543vec(17)=vec(12)*vec(2)544vec(18)=vec(12)*vec(4)545vec(19)=vec(2)*vec(15)546vec(20)=vec(14)*vec(2)547vec(21)=vec(15)*vec(4)548549! Compites beta_bar (cf annexe C Chung)550! Warning: beta(1)=beta_bar_3 (Chung); beta(2)=beta_bar_4; beta(3)=beta_bar_6551! beta(4)=beta_bar_1 ; beta(5)=beta_bar_2; beta(6)=beta_bar_5552553! calcul the three betas in terms of the polynomes554beta(:)=0._dp555Do i=1,3556Do j=1,21557beta(i)=beta(i)+Mat(i,j)*vec(j)558End do559End do560561! calcul the other 3 to get the normalisation562beta(4)=3._dp*(-1._dp/7._dp+beta(1)*(1._dp/7._dp+4._dp*Inv2/7._dp+8._dp*Inv3/3._dp)/5._dp- &563beta(2)*(0.2_dp-8._dp*Inv2/15._dp-14._dp*Inv3/15._dp)- &564beta(3)*(1._dp/35._dp-24._dp*Inv3/105._dp-4._dp*Inv2/35._dp+ &56516._dp*Inv2*Inv3/15._dp+8._dp*Inv2*Inv2/35._dp))/5._dp566567beta(5)=6._dp*(1._dp-0.2_dp*beta(1)*(1._dp+4._dp*Inv2)+ &5687._dp*beta(2)*(1._dp/6._dp-Inv2)/5._dp- &569beta(3)*(-0.2_dp+2._dp*Inv3/3._dp+4._dp*Inv2/5._dp- &5708._dp*Inv2*Inv2/5._dp))/7._dp571572beta(6)=-4._dp*beta(1)/5._dp-7._dp*beta(2)/5._dp- &5736._dp*beta(3)*(1._dp-4._dp*Inv2/3._dp)/5._dp574575!beta_bar576Do i=1,6577beta(i)=beta(i)/3._dp578End do579beta(2)=beta(2)/2._dp580beta(5)=beta(5)/2._dp581beta(6)=beta(6)/2._dp582583!! Compute 5 b=a.a584b_11=a_11*a_11+a_12*a_12+a_13*a_13585b_22=a_22*a_22+a_12*a_12+a_23*a_23586b_12=a_11*a_12+a_12*a_22+a_13*a_23587b_13=a_11*a_13+a_12*a_23+a_13*a_33588b_23=a_12*a_13+a_22*a_23+a_23*a_33589590!Compute the 9 terms of a4591592a4(1)=3._dp*beta(4)+6._dp*beta(5)*a_11+3._dp*beta(1)*a_11*a_11+&5936._dp*beta(2)*b_11+6._dp*beta(6)*a_11*b_11+3._dp*beta(3)*b_11*b_11594a4(2)=3._dp*beta(4)+6._dp*beta(5)*a_22+3._dp*beta(1)*a_22*a_22+&5956._dp*beta(2)*b_22+6._dp*beta(6)*a_22*b_22+3._dp*beta(3)*b_22*b_22596597a4(3)=beta(4)+beta(5)*(a_22+a_11)+beta(1)*(a_11*a_22+2._dp*a_12*a_12)+&598beta(2)*(b_22+b_11)+beta(6)*(a_11*b_22+a_22*b_11+4._dp*a_12*b_12)+&599beta(3)*(b_11*b_22+2._dp*b_12*b_12)600601602a4(4)=beta(5)*a_23+beta(1)*(a_11*a_23+2._dp*a_12*a_13)+beta(2)*b_23+&603beta(6)*(a_11*b_23+a_23*b_11+2._dp*(a_12*b_13+a_13*b_12))+beta(3)*&604(b_11*b_23+2._dp*b_12*b_13)605a4(5)=beta(5)*a_13+beta(1)*(a_22*a_13+2._dp*a_12*a_23)+beta(2)*b_13+&606beta(6)*(a_22*b_13+a_13*b_22+2._dp*(a_12*b_23+a_23*b_12))+beta(3)*&607(b_22*b_13+2._dp*b_12*b_23)608609610a4(6)=3._dp*beta(5)*a_13+3._dp*beta(1)*a_11*a_13+3._dp*beta(2)*b_13+&6113._dp*beta(6)*(a_11*b_13+a_13*b_11)+3._dp*beta(3)*b_11*b_13612a4(7)=3._dp*beta(5)*a_12+3._dp*beta(1)*a_11*a_12+3._dp*beta(2)*b_12+&6133._dp*beta(6)*(a_11*b_12+a_12*b_11)+3._dp*beta(3)*b_11*b_12614a4(8)=3._dp*beta(5)*a_23+3._dp*beta(1)*a_22*a_23+3._dp*beta(2)*b_23+&6153._dp*beta(6)*(a_22*b_23+a_23*b_22)+3._dp*beta(3)*b_22*b_23616a4(9)=3._dp*beta(5)*a_12+3._dp*beta(1)*a_22*a_12+3._dp*beta(2)*b_12+&6173._dp*beta(6)*(a_22*b_12+a_12*b_22)+3._dp*beta(3)*b_22*b_12618619END SUBROUTINE IBOF620!**************************************************************************************621622END FUNCTION caffeGetViscosity623624625