!! Computes the Salt fluxes caused by gravity drainage.
!!
!!
!!
!!
!! @author Philipp Griewank
!!
!!
!! COPYRIGHT
!!
!! This file is part of SAMSIM.
!!
!! SAMSIM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
!!
!! SAMSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
!!
!! You should have received a copy of the GNU General Public License along with SAMSIM. If not, see <http://www.gnu.org/licenses/>.
!!
!
!!
!!
!! @par Revision History
!! Injected with life by Philipp Griewank, IMPRS (<2010-08-27>)
!!
!!
MODULEmo_grav_drain
USEmo_parameters
USEmo_thermo_functions,ONLY:func_S_br
USEmo_mass
IMPLICITNONE
PUBLIC::fl_grav_drain,fl_grav_drain_simple
CONTAINS
!>
!! Calculates fluxes caused by gravity drainage.
!!
!! If the Rayleigh number of a layer is higher then the critical value, brine leaves the layer by a theoretical brine channel.
!! The discharged brine flows downward through all layers directly into the underlying ocean.
!! To preserve mass the same amount of water flows upwards through all lower layers.
!! In contrast to the downward flux the upward flux is assumed to be in thermal equilibrium thus moving salt and heat to each layer.
!! The upward flux is a standard upwind advection.
!! The downward flux of a layer over the timestep is = x*(Ray-Ray_crit)*dt*thick.
!! _____________________________________
!! | ->__|__<-
!! |______________| v |__________________
!! | ^ ->| |<- ^
!! |______________| |__________________
!! | ^ ^ ->|||||<- ^ ^
!! |______________|vvv|__________________
!! ^ ^ ^ ^ ^ ^
!! This superb ascii art is supposed to show how the assumed fluxes flow downward through a brine channel and upwards through the layer.
!! x and r are passed on to enable easy optimization.
!! The effect of the upward moving brine is calculated in mass_transfer.
!!
!! IMPORTANT: The height assumptions are special. The bottom of the ice edge is assumed to be at psi_s(N_active)/psi_s_min *thick_0
!!
!! The first approach assumed that brine drainage occurred between two layers but performed poorly.
!!
!! If grav_heat_flag is set to 2 the amount of heat transported out of the ice will be compensated in the lowest layer
!!
!! @par Revision History
!! created by Philipp Griewank, IMPRS (2010-08-27) \n
!! Completely revised to assume brine channels by Philipp Griewank , IMPRS (2010-11-05) \n
!! Mass_transfer is used to advect H and S by Philipp Griewank, IMPRS (2010-11-05) \n
!! Added condition S_br(k)>S_br(k+1) by Philipp Griewank. IMPRS (2011-04-29) \n
!! Added harmonic mean for permeability by Philipp Griewank (2014-01-05)