- Timestamp:
- Nov 10, 2015, 2:36:29 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/libf/aeronomars/photochemistry_asis.F90
r1495 r1496 99 99 real (kind = 8), dimension(nesp) :: cnew ! number densities at next timestep (molecule.cm-3) 100 100 101 !real (kind = 8), dimension(ngridmx,nlayer,nesp), save :: cold3d ! cold saved from previous timestep102 !real (kind = 8), dimension(ngridmx,nlayer), save :: dt3d ! saved timestep103 104 101 ! reaction rates 105 102 … … 111 108 ! matrix 112 109 113 real (kind = 8), dimension(nesp,nesp) :: mat 110 real (kind = 8), dimension(nesp,nesp) :: mat, mat1 114 111 integer, dimension(nesp) :: indx 115 112 integer :: code 113 114 ! production and loss terms (for first-guess solution only) 115 116 real (kind = 8), dimension(nesp) :: prod, loss 116 117 117 118 ! curvatures … … 128 129 i_h2, i_oh, i_ho2, i_h2o2, i_h2o, & 129 130 i_n, i_n2d, i_no, i_no2, i_n2) 130 ! dt3d(:,:) = 600.131 131 firstcall = .false. 132 132 end if … … 199 199 dt_guess = ctimestep 200 200 cold(:) = c(ilev,:) 201 ! dt_guess = dt3d(ig,ilev)202 ! cold(:) = cold3d(ig,ilev,:)203 201 204 202 ! internal loop for the chemistry … … 206 204 do while (time < ptimestep) 207 205 208 iter(ilev) = iter(ilev) + 1 206 iter(ilev) = iter(ilev) + 1 ! iteration counter 209 207 210 208 ! first-guess: fill matrix 211 209 212 call fill_matrix(ilev, nesp, c, nlayer, v_phot, v_3, v_4, dt_guess, mat) 210 call fill_matrix(ilev, mat1, prod, loss, c, nesp, nlayer, v_phot, v_3, v_4) 211 212 ! first guess : form the matrix identity + mat*dt_guess 213 214 mat(:,:) = mat1(:,:)*dt_guess 215 do iesp = 1,nesp 216 mat(iesp,iesp) = 1. + mat(iesp,iesp) 217 end do 213 218 214 219 ! first-guess: solve linear system … … 266 271 267 272 if (time + dt_corrected > ptimestep) then 268 ! dt3d(ig,ilev) = dt_corrected269 273 dt_corrected = ptimestep - time 270 274 end if … … 272 276 if (dt_corrected /= dt_guess) then ! the timestep has been modified 273 277 274 ! fill matrix 275 276 call fill_matrix(ilev, nesp, c, nlayer, v_phot, v_3, v_4, dt_corrected, mat) 278 ! form the matrix identity + mat*dt_guess 279 280 mat(:,:) = mat1(:,:)*dt_corrected 281 do iesp = 1,nesp 282 mat(iesp,iesp) = 1. + mat(iesp,iesp) 283 end do 277 284 278 285 ! solve linear system … … 956 963 !====================================================================== 957 964 958 subroutine fill_matrix(ilev, nesp, c, nlayer, v_phot, v_3, v_4, & 959 dtx, mat) 965 subroutine fill_matrix(ilev, mat, prod, loss, c, nesp, nlayer, v_phot, v_3, v_4) 960 966 961 967 !====================================================================== … … 974 980 integer :: nesp ! number of species in the chemistry 975 981 integer, intent(in) :: nlayer ! number of atmospheric layers 976 977 real :: dtx ! timestep (s)978 real(kind = jprb) :: eps, eps_4 ! implicit/explicit coefficient979 982 980 983 real (kind = 8), dimension(nlayer,nesp) :: c ! number densities … … 985 988 ! output 986 989 987 real (kind = 8), dimension(nesp,nesp) :: mat ! matrix 990 real (kind = 8), dimension(nesp,nesp), intent(out) :: mat ! matrix 991 real (kind = 8), dimension(nesp), intent(out) :: prod, loss 988 992 989 993 ! local … … 995 999 integer :: iphot,i3,i4 996 1000 997 ! initialisation 1001 real(kind = jprb) :: eps, eps_4 ! implicit/explicit coefficient 1002 1003 ! initialisations 998 1004 999 1005 mat(:,:) = 0. 1000 do iesp = 1,nesp 1001 mat(iesp,iesp) = 1. 1002 end do 1006 prod(:) = 0. 1007 loss(:) = 0. 1003 1008 1004 1009 ! photodissociations … … 1012 1017 ind_phot_6 = indice_phot(iphot)%z6 1013 1018 1014 mat(ind_phot_2,ind_phot_2) = mat(ind_phot_2,ind_phot_2) + indice_phot(iphot)%z1*v_phot(ilev,iphot)*dtx 1015 mat(ind_phot_4,ind_phot_2) = mat(ind_phot_4,ind_phot_2) - indice_phot(iphot)%z3*v_phot(ilev,iphot)*dtx 1016 mat(ind_phot_6,ind_phot_2) = mat(ind_phot_6,ind_phot_2) - indice_phot(iphot)%z5*v_phot(ilev,iphot)*dtx 1019 mat(ind_phot_2,ind_phot_2) = mat(ind_phot_2,ind_phot_2) + indice_phot(iphot)%z1*v_phot(ilev,iphot) 1020 mat(ind_phot_4,ind_phot_2) = mat(ind_phot_4,ind_phot_2) - indice_phot(iphot)%z3*v_phot(ilev,iphot) 1021 mat(ind_phot_6,ind_phot_2) = mat(ind_phot_6,ind_phot_2) - indice_phot(iphot)%z5*v_phot(ilev,iphot) 1022 1023 loss(ind_phot_2) = loss(ind_phot_2) + indice_phot(iphot)%z1*v_phot(ilev,iphot) 1024 prod(ind_phot_4) = prod(ind_phot_4) + indice_phot(iphot)%z3*v_phot(ilev,iphot)*c(ilev,ind_phot_2) 1025 prod(ind_phot_6) = prod(ind_phot_6) + indice_phot(iphot)%z5*v_phot(ilev,iphot)*c(ilev,ind_phot_2) 1017 1026 1018 1027 end do … … 1026 1035 ind_3_6 = indice_3(i3)%z6 1027 1036 1028 mat(ind_3_2,ind_3_2) = mat(ind_3_2,ind_3_2) + indice_3(i3)%z1*v_3(ilev,i3)*c(ilev,ind_3_2)*dtx 1029 mat(ind_3_4,ind_3_2) = mat(ind_3_4,ind_3_2) - indice_3(i3)%z3*v_3(ilev,i3)*c(ilev,ind_3_2)*dtx 1030 mat(ind_3_6,ind_3_2) = mat(ind_3_6,ind_3_2) - indice_3(i3)%z5*v_3(ilev,i3)*c(ilev,ind_3_2)*dtx 1037 mat(ind_3_2,ind_3_2) = mat(ind_3_2,ind_3_2) + indice_3(i3)%z1*v_3(ilev,i3)*c(ilev,ind_3_2) 1038 mat(ind_3_4,ind_3_2) = mat(ind_3_4,ind_3_2) - indice_3(i3)%z3*v_3(ilev,i3)*c(ilev,ind_3_2) 1039 mat(ind_3_6,ind_3_2) = mat(ind_3_6,ind_3_2) - indice_3(i3)%z5*v_3(ilev,i3)*c(ilev,ind_3_2) 1040 1041 loss(ind_3_2) = loss(ind_3_2) + indice_3(i3)%z1*v_3(ilev,i3)*c(ilev,ind_3_2) 1042 prod(ind_3_4) = prod(ind_3_4) + indice_3(i3)%z3*v_3(ilev,i3)*c(ilev,ind_3_2)*c(ilev,ind_3_2) 1043 prod(ind_3_6) = prod(ind_3_6) + indice_3(i3)%z5*v_3(ilev,i3)*c(ilev,ind_3_2)*c(ilev,ind_3_2) 1031 1044 1032 1045 end do … … 1046 1059 eps_4 = min(eps_4,1.0_jprb) 1047 1060 1048 mat(ind_4_2,ind_4_2) = mat(ind_4_2,ind_4_2) + indice_4(i4)%z1*v_4(ilev,i4)*dtx*(1. - eps_4)*c(ilev,ind_4_4) 1049 mat(ind_4_2,ind_4_4) = mat(ind_4_2,ind_4_4) + indice_4(i4)%z1*v_4(ilev,i4)*dtx*eps_4*c(ilev,ind_4_2) 1050 mat(ind_4_4,ind_4_2) = mat(ind_4_4,ind_4_2) + indice_4(i4)%z3*v_4(ilev,i4)*dtx*(1. - eps_4)*c(ilev,ind_4_4) 1051 mat(ind_4_4,ind_4_4) = mat(ind_4_4,ind_4_4) + indice_4(i4)%z3*v_4(ilev,i4)*dtx*eps_4*c(ilev,ind_4_2) 1052 mat(ind_4_6,ind_4_2) = mat(ind_4_6,ind_4_2) - indice_4(i4)%z5*v_4(ilev,i4)*dtx*(1. - eps_4)*c(ilev,ind_4_4) 1053 mat(ind_4_6,ind_4_4) = mat(ind_4_6,ind_4_4) - indice_4(i4)%z5*v_4(ilev,i4)*dtx*eps_4*c(ilev,ind_4_2) 1054 mat(ind_4_8,ind_4_2) = mat(ind_4_8,ind_4_2) - indice_4(i4)%z7*v_4(ilev,i4)*dtx*(1. - eps_4)*c(ilev,ind_4_4) 1055 mat(ind_4_8,ind_4_4) = mat(ind_4_8,ind_4_4) - indice_4(i4)%z7*v_4(ilev,i4)*dtx*eps_4*c(ilev,ind_4_2) 1061 mat(ind_4_2,ind_4_2) = mat(ind_4_2,ind_4_2) + indice_4(i4)%z1*v_4(ilev,i4)*(1. - eps_4)*c(ilev,ind_4_4) 1062 mat(ind_4_2,ind_4_4) = mat(ind_4_2,ind_4_4) + indice_4(i4)%z1*v_4(ilev,i4)*eps_4*c(ilev,ind_4_2) 1063 mat(ind_4_4,ind_4_2) = mat(ind_4_4,ind_4_2) + indice_4(i4)%z3*v_4(ilev,i4)*(1. - eps_4)*c(ilev,ind_4_4) 1064 mat(ind_4_4,ind_4_4) = mat(ind_4_4,ind_4_4) + indice_4(i4)%z3*v_4(ilev,i4)*eps_4*c(ilev,ind_4_2) 1065 mat(ind_4_6,ind_4_2) = mat(ind_4_6,ind_4_2) - indice_4(i4)%z5*v_4(ilev,i4)*(1. - eps_4)*c(ilev,ind_4_4) 1066 mat(ind_4_6,ind_4_4) = mat(ind_4_6,ind_4_4) - indice_4(i4)%z5*v_4(ilev,i4)*eps_4*c(ilev,ind_4_2) 1067 mat(ind_4_8,ind_4_2) = mat(ind_4_8,ind_4_2) - indice_4(i4)%z7*v_4(ilev,i4)*(1. - eps_4)*c(ilev,ind_4_4) 1068 mat(ind_4_8,ind_4_4) = mat(ind_4_8,ind_4_4) - indice_4(i4)%z7*v_4(ilev,i4)*eps_4*c(ilev,ind_4_2) 1069 1070 loss(ind_4_2) = loss(ind_4_2) + indice_4(i4)%z1*v_4(ilev,i4)*c(ilev,ind_4_4) 1071 loss(ind_4_4) = loss(ind_4_4) + indice_4(i4)%z3*v_4(ilev,i4)*c(ilev,ind_4_2) 1072 prod(ind_4_6) = prod(ind_4_6) + indice_4(i4)%z5*v_4(ilev,i4)*c(ilev,ind_4_2)*c(ilev,ind_4_4) 1073 prod(ind_4_8) = prod(ind_4_8) + indice_4(i4)%z7*v_4(ilev,i4)*c(ilev,ind_4_2)*c(ilev,ind_4_4) 1056 1074 1057 1075 end do
Note: See TracChangeset
for help on using the changeset viewer.