MODULE diffusion_e_mod !------------------------------------------------------------------------------! ! Actual revisions: ! ----------------- ! Calculation extended for gridpoint nzt ! ! Former revisions: ! ----------------- ! $Id: diffusion_e.f90 19 2007-02-23 04:53:48Z raasch $ ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.18 2006/08/04 14:29:43 raasch ! dissipation is stored in extra array diss if needed later on for calculating ! the sgs particle velocities ! ! Revision 1.1 1997/09/19 07:40:24 raasch ! Initial revision ! ! ! Description: ! ------------ ! Diffusion- and dissipation terms for the TKE !------------------------------------------------------------------------------! PRIVATE PUBLIC diffusion_e INTERFACE diffusion_e MODULE PROCEDURE diffusion_e MODULE PROCEDURE diffusion_e_ij END INTERFACE diffusion_e CONTAINS !------------------------------------------------------------------------------! ! Call for all grid points !------------------------------------------------------------------------------! SUBROUTINE diffusion_e( ddzu, dd2zu, ddzw, diss, e, km, l_grid, theta, & rif, tend, zu ) USE control_parameters USE grid_variables USE indices USE particle_attributes IMPLICIT NONE INTEGER :: i, j, k REAL :: dpt_dz, l_stable, phi_m REAL :: ddzu(1:nzt+1), dd2zu(1:nzt), ddzw(1:nzt), & l_grid(1:nzt), zu(0:nzt+1) REAL, DIMENSION(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) :: diss, tend REAL, DIMENSION(:,:), POINTER :: rif REAL, DIMENSION(:,:,:), POINTER :: e, km, theta REAL, DIMENSION(nzb+1:nzt,nys:nyn) :: dissipation, l, ll DO i = nxl, nxr DO j = nys, nyn ! !-- First, calculate phi-function for eventually adjusting the & !-- mixing length to the prandtl mixing length IF ( adjust_mixing_length .AND. prandtl_layer ) THEN IF ( rif(j,i) >= 0.0 ) THEN phi_m = 1.0 + 5.0 * rif(j,i) ELSE phi_m = 1.0 / SQRT( SQRT( 1.0 - 16.0 * rif(j,i) ) ) ENDIF ENDIF DO k = nzb_s_inner(j,i)+1, nzt ! !-- Calculate the mixing length (for dissipation) dpt_dz = ( theta(k+1,j,i) - theta(k-1,j,i) ) * dd2zu(k) IF ( dpt_dz > 0.0 ) THEN l_stable = 0.76 * SQRT( e(k,j,i) ) / & SQRT( g / theta(k,j,i) * dpt_dz ) + 1E-5 ELSE l_stable = l_grid(k) ENDIF ! !-- Adjustment of the mixing length IF ( wall_adjustment ) THEN l(k,j) = MIN( wall_adjustment_factor * zu(k), l_grid(k), & l_stable ) ll(k,j) = MIN( wall_adjustment_factor * zu(k), l_grid(k) ) ELSE l(k,j) = MIN( l_grid(k), l_stable ) ll(k,j) = l_grid(k) ENDIF IF ( adjust_mixing_length .AND. prandtl_layer ) THEN l(k,j) = MIN( l(k,j), kappa * zu(k) / phi_m ) ll(k,j) = MIN( ll(k,j), kappa * zu(k) / phi_m ) ENDIF ENDDO ENDDO ! !-- Calculate the tendency terms DO j = nys, nyn DO k = nzb_s_inner(j,i)+1, nzt dissipation(k,j) = ( 0.19 + 0.74 * l(k,j) / ll(k,j) ) * & e(k,j,i) * SQRT( e(k,j,i) ) / l(k,j) tend(k,j,i) = tend(k,j,i) & + ( & ( km(k,j,i)+km(k,j,i+1) ) * ( e(k,j,i+1)-e(k,j,i) ) & - ( km(k,j,i)+km(k,j,i-1) ) * ( e(k,j,i)-e(k,j,i-1) ) & ) * ddx2 & + ( & ( km(k,j,i)+km(k,j+1,i) ) * ( e(k,j+1,i)-e(k,j,i) ) & - ( km(k,j,i)+km(k,j-1,i) ) * ( e(k,j,i)-e(k,j-1,i) ) & ) * ddy2 & + ( & ( km(k,j,i)+km(k+1,j,i) ) * ( e(k+1,j,i)-e(k,j,i) ) * ddzu(k+1) & - ( km(k,j,i)+km(k-1,j,i) ) * ( e(k,j,i)-e(k-1,j,i) ) * ddzu(k) & ) * ddzw(k) & - dissipation(k,j) ENDDO ENDDO ! !-- Store dissipation if needed for calculating the sgs particle !-- velocities IF ( use_sgs_for_particles ) THEN DO j = nys, nyn DO k = nzb_s_inner(j,i)+1, nzt diss(k,j,i) = dissipation(k,j) ENDDO ENDDO ENDIF ENDDO ! !-- Boundary condition for dissipation IF ( use_sgs_for_particles ) THEN DO i = nxl, nxr DO j = nys, nyn diss(nzb_s_inner(j,i),j,i) = diss(nzb_s_inner(j,i)+1,j,i) ENDDO ENDDO ENDIF END SUBROUTINE diffusion_e !------------------------------------------------------------------------------! ! Call for grid point i,j !------------------------------------------------------------------------------! SUBROUTINE diffusion_e_ij( i, j, ddzu, dd2zu, ddzw, diss, e, km, l_grid, & theta, rif, tend, zu ) USE control_parameters USE grid_variables USE indices USE particle_attributes IMPLICIT NONE INTEGER :: i, j, k REAL :: dpt_dz, l_stable, phi_m REAL :: ddzu(1:nzt+1), dd2zu(1:nzt), ddzw(1:nzt), & l_grid(1:nzt), zu(0:nzt+1) REAL, DIMENSION(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) :: diss, tend REAL, DIMENSION(:,:), POINTER :: rif REAL, DIMENSION(:,:,:), POINTER :: e, km, theta REAL, DIMENSION(nzb+1:nzt) :: dissipation, l, ll ! !-- First, calculate phi-function for eventually adjusting the mixing length !-- to the prandtl mixing length IF ( adjust_mixing_length .AND. prandtl_layer ) THEN IF ( rif(j,i) >= 0.0 ) THEN phi_m = 1.0 + 5.0 * rif(j,i) ELSE phi_m = 1.0 / SQRT( SQRT( 1.0 - 16.0 * rif(j,i) ) ) ENDIF ENDIF ! !-- Calculate the mixing length (for dissipation) DO k = nzb_s_inner(j,i)+1, nzt dpt_dz = ( theta(k+1,j,i) - theta(k-1,j,i) ) * dd2zu(k) IF ( dpt_dz > 0.0 ) THEN l_stable = 0.76 * SQRT( e(k,j,i) ) / & SQRT( g / theta(k,j,i) * dpt_dz ) + 1E-5 ELSE l_stable = l_grid(k) ENDIF ! !-- Adjustment of the mixing length IF ( wall_adjustment ) THEN l(k) = MIN( wall_adjustment_factor * zu(k), l_grid(k), l_stable ) ll(k) = MIN( wall_adjustment_factor * zu(k), l_grid(k) ) ELSE l(k) = MIN( l_grid(k), l_stable ) ll(k) = l_grid(k) ENDIF IF ( adjust_mixing_length .AND. prandtl_layer ) THEN l(k) = MIN( l(k), kappa * zu(k) / phi_m ) ll(k) = MIN( ll(k), kappa * zu(k) / phi_m ) ENDIF ! !-- Calculate the tendency term dissipation(k) = ( 0.19 + 0.74 * l(k) / ll(k) ) * e(k,j,i) * & SQRT( e(k,j,i) ) / l(k) tend(k,j,i) = tend(k,j,i) & + ( & ( km(k,j,i)+km(k,j,i+1) ) * ( e(k,j,i+1)-e(k,j,i) ) & - ( km(k,j,i)+km(k,j,i-1) ) * ( e(k,j,i)-e(k,j,i-1) ) & ) * ddx2 & + ( & ( km(k,j,i)+km(k,j+1,i) ) * ( e(k,j+1,i)-e(k,j,i) ) & - ( km(k,j,i)+km(k,j-1,i) ) * ( e(k,j,i)-e(k,j-1,i) ) & ) * ddy2 & + ( & ( km(k,j,i)+km(k+1,j,i) ) * ( e(k+1,j,i)-e(k,j,i) ) * ddzu(k+1) & - ( km(k,j,i)+km(k-1,j,i) ) * ( e(k,j,i)-e(k-1,j,i) ) * ddzu(k) & ) * ddzw(k) & - dissipation(k) ENDDO ! !-- Store dissipation if needed for calculating the sgs particle velocities IF ( use_sgs_for_particles ) THEN DO k = nzb_s_inner(j,i)+1, nzt diss(k,j,i) = dissipation(k) ENDDO ! !-- Boundary condition for dissipation diss(nzb_s_inner(j,i),j,i) = diss(nzb_s_inner(j,i)+1,j,i) ENDIF END SUBROUTINE diffusion_e_ij END MODULE diffusion_e_mod