source: trunk/LMDZ.COMMON/libf/evolution/adsorption_mod.F90 @ 2885

Last change on this file since 2885 was 2863, checked in by llange, 3 years ago

PEM
H2O adsorption is now computed. Total mass of H2o adsorbded is written in the restart_PEM.
+Minor fixes and edit
LL & RV

File size: 17.3 KB
Line 
1  module adsorption_mod 
2  implicit none
3  contains
4
5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6!!!
7!!! Purpose: Compute CO2 and H2O adsorption, following the methods from Zent & Quinn 1995, Jackosky et al., 1997
8!!!
9!!! Author: LL, 01/2023
10!!!
11!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12
13  subroutine regolith_adsorption(ngrid,nslope,nsoil_PEM,timelen,tend_h2oglaciers,tend_co2glaciers,waterice,co2ice,tsoil_PEM,TI_PEM,ps,q_co2,q_h2o, &
14                                m_h2o_completesoil,delta_mh2oreg, m_co2_completesoil,delta_mco2reg)
15#ifndef CPP_STD
16! inputs
17 INTEGER,INTENT(IN) :: ngrid, nslope, nsoil_PEM,timelen ! size dimension: physics x subslope x soil x timeseries
18 REAL,INTENT(IN) :: tend_h2oglaciers(ngrid,nslope),tend_co2glaciers(ngrid,nslope) !tendancies on the glaciers [1]
19 REAL,INTENT(IN) :: waterice(ngrid,nslope)              ! water ice at the surface [kg/m^2]
20 REAL,INTENT(IN) :: co2ice(ngrid,nslope)                ! co2 ice at the surface [kg/m^2]
21 REAL,INTENT(IN) :: TI_PEM(ngrid,nsoil_PEM,nslope)      ! Soil Thermal inertia (J/K/^2/s^1/2)
22 REAL,INTENT(IN) :: tsoil_PEM(ngrid,nsoil_PEM,nslope)   ! Soil temperature (K)
23 REAL,INTENT(IN) :: ps(ngrid,timelen)                   ! Average surface pressure [Pa]
24 REAL,INTENT(IN) :: q_co2(ngrid,timelen)                ! Mass mixing ratio of co2 in the first layer (kg/kg)
25 REAL,INTENT(IN) :: q_h2o(ngrid,timelen)                ! Mass mixing ratio of H2o in the first layer (kg/kg)
26
27! outputs
28 REAL,INTENT(INOUT) :: m_h2o_completesoil(ngrid,nsoil_PEM,nslope) ! Density of h2o adsorbed (kg/m^3)(ngrid,nsoil_PEM,nslope)     
29 REAL,INTENT(OUT) :: delta_mh2oreg(ngrid)                         ! Difference density of h2o adsorbed (kg/m^3)
30
31 REAL,INTENT(INOUT) :: m_co2_completesoil(ngrid,nsoil_PEM,nslope)   ! Density of co2 adsorbed (kg/m^3)
32 REAL,INTENT(OUT) :: delta_mco2reg(ngrid)                            ! Difference density of co2 adsorbed (kg/m^3)
33 
34! local variables
35 REAL :: theta_h2o_adsorbded(ngrid,nsoil_PEM,nslope) ! Fraction of the pores occupied by H2O molecules
36! -------------
37
38! Compute H2O adsorption, then CO2 adsorption
39
40  call regolith_h2oadsorption(ngrid,nslope,nsoil_PEM,timelen,tend_h2oglaciers,tend_co2glaciers,waterice,co2ice,ps,q_co2,q_h2o,tsoil_PEM,TI_PEM, &
41                                   theta_h2o_adsorbded,m_h2o_completesoil,delta_mh2oreg)
42
43
44  call regolith_co2adsorption(ngrid,nslope,nsoil_PEM,timelen,tend_h2oglaciers,tend_co2glaciers,waterice,co2ice,ps,q_co2,q_h2o, &
45                                                          tsoil_PEM,TI_PEM,m_co2_completesoil,delta_mco2reg)
46
47#endif
48   RETURN
49  end subroutine
50
51!------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
52
53  subroutine regolith_h2oadsorption(ngrid,nslope,nsoil_PEM,timelen,tend_h2oglaciers,tend_co2glaciers,waterice,co2ice,ps,q_co2,q_h2o,tsoil_PEM,TI_PEM, &
54                                   theta_h2o_adsorbded,m_h2o_completesoil,delta_mreg)
55
56!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
57!!!
58!!! Purpose: Compute H2O adsorption, following the methods from Jackosky et al., 1997
59!!!
60!!! Author: LL, 01/2023
61!!!
62!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
63
64#ifndef CPP_STD
65      use comsoil_h_PEM, only: layer_PEM, mlayer_PEM,n_1km
66      USE comcstfi_h, only:  pi
67      use comslope_mod, only : subslope_dist,def_slope_mean
68      use vertical_layers_mod, ONLY: ap,bp
69#endif
70
71 implicit none
72! inputs
73 INTEGER,INTENT(IN) :: ngrid, nslope, nsoil_PEM,timelen ! size dimension
74 REAL,INTENT(IN) :: tend_h2oglaciers(ngrid,nslope),tend_co2glaciers(ngrid,nslope) !tendancies on the glaciers ()
75 REAL,INTENT(IN) :: waterice(ngrid,nslope)              ! water ice at the surface [kg/m^2]
76 REAL,INTENT(IN) :: co2ice(ngrid,nslope)                ! co2 ice at the surface [kg/m^2]
77 REAL,INTENT(IN) :: ps(ngrid,timelen)                   ! surface pressure (Pa)         
78 REAL,INTENT(IN) :: q_co2(ngrid,timelen)                ! Mass mixing ratio of co2 in the first layer (kg/kg)
79 REAL,INTENT(IN) :: q_h2o(ngrid,timelen)                ! Mass mixing ratio of H2o in the first layer (kg/kg)
80 REAL,INTENT(IN) :: TI_PEM(ngrid,nsoil_PEM,nslope)      ! Soil Thermal inertia (J/K/^2/s^1/2)
81 REAL,INTENT(IN) :: tsoil_PEM(ngrid,nsoil_PEM,nslope)   ! Soil temperature (K)
82
83! outputs
84 REAL,INTENT(INOUT) :: m_h2o_completesoil(ngrid,nsoil_PEM,nslope) ! Density of h2o adsorbed (kg/m^3)(ngrid,nsoil_PEM,nslope)     
85 REAL,INTENT(OUT) :: theta_h2o_adsorbded(ngrid,nsoil_PEM,nslope) ! Fraction of the pores occupied by H2O molecules
86 REAL,INTENT(OUT) :: delta_mreg(ngrid)                         ! Difference density of h2o adsorbed (kg/m^3)
87
88! constants
89 REAL :: Ko =  1.57e-8            ! Jackosky et al. 1997
90 REAL :: e = 2573.9               ! Jackosky et al. 1997
91 REAL :: mu = 0.48                ! Jackosky et al. 1997
92 real :: m_theta = 2.84e-7        ! Mass of h2o per m^2 absorbed Jackosky et al. 1997
93 real :: as = 18.9e3              ! Specific area, Buhler & Piqueux 2021
94 real ::  inertie_thresold = 800. ! TI > 800 means cementation
95 real :: m_h2o = 18.01528E-3      ! Molecular weight of h2o (kg/mol)
96 real :: m_co2 = 44.01E-3         ! Molecular weight of co2 (kg/mol)
97 real :: m_noco2 = 33.37E-3       ! Molecular weight of non co2 (kg/mol)
98 real ::  rho_regolith = 1500.    ! density of the regolith (2000 for buhler & piqueux 2021)
99 real :: alpha_clapeyron = -6143.7! eq. (2) in Murphy & Koop 2005
100 real :: beta_clapeyron = 28.9074 ! eq. (2) in Murphy & Koop 2005
101! local variables
102#ifndef CPP_STD
103 REAL :: deltam_reg_complete(ngrid,n_1km,nslope)         ! Difference in the mass per slope and soil layer (kg/m^3)
104#endif
105 real :: K                        ! Used to compute theta
106 integer ig,iloop, islope,isoil,it   ! for loops
107 INTEGER :: ispermanent_co2glaciers(ngrid,nslope)        ! Check if the co2 glacier is permanent
108 INTEGER :: ispermanent_h2oglaciers(ngrid,nslope)        ! Check if the h2o glacier is permanent
109 REAL :: deltam_reg_slope(ngrid,nslope)  ! Difference density of h2o adsorbed per slope (kg/m^3)
110 REAL :: dm_h2o_regolith_slope(ngrid,nsoil_PEM,nslope)   ! elementary h2o mass adsorded per mesh per slope
111 real :: A,B                                                   ! Used to compute the mean mass above the surface
112 real :: p_sat                                                 ! saturated vapor pressure of ice
113 real,allocatable :: mass_mean(:,:)                            ! mean mass above the surface
114 real,allocatable :: zplev_mean(:,:)                           ! pressure above the surface
115 real,allocatable :: pvapor(:,:)                               ! partial pressure above the surface
116 real, allocatable :: pvapor_avg(:)                            ! yearly
117
118! 0. Some initializations
119#ifndef CPP_STD
120
121     allocate(mass_mean(ngrid,timelen))
122     allocate(zplev_mean(ngrid,timelen))
123     allocate(pvapor(ngrid,timelen))
124     allocate(pvapor_avg(ngrid))
125     A =(1/m_co2 - 1/m_noco2)
126     B=1/m_noco2
127     theta_h2o_adsorbded(:,:,:) = 0.
128     dm_h2o_regolith_slope(:,:,:) = 0.
129
130!0.1 Look at perenial ice
131  do ig = 1,ngrid
132    do islope = 1,nslope
133     if((abs(tend_h2oglaciers(ig,islope)).gt.1e-5).and.(abs(waterice(ig,islope)).gt.0)) then
134        ispermanent_h2oglaciers(ig,islope) = 1
135     else
136        ispermanent_h2oglaciers(ig,islope) = 0
137     endif
138
139     if((abs(tend_co2glaciers(ig,islope)).gt.1e-5).and.(abs(co2ice(ig,islope)).gt.0)) then
140        ispermanent_co2glaciers(ig,islope) = 1
141     else
142        ispermanent_co2glaciers(ig,islope) = 0
143     endif
144    enddo
145   enddo
146
147!   0.2 Compute the partial pressure of vapor
148!a. the molecular mass into the column
149     do ig = 1,ngrid
150       mass_mean(ig,:) = 1/(A*q_co2(ig,:) +B)
151     enddo
152
153
154! b. pressure level
155     do it = 1,timelen
156       do ig = 1,ngrid
157         zplev_mean(ig,it) = ap(1) + bp(1)*ps(ig,it)
158       enddo
159     enddo
160! c. Vapor pressure
161     pvapor(:,:) = mass_mean(:,:)/m_h2o*q_h2o(:,:)*zplev_mean(:,:)
162     pvapor_avg(:) = sum(pvapor(:,:),2)/timelen
163     deallocate(pvapor)
164     deallocate(zplev_mean)
165     deallocate(mass_mean)
166
167! 1. we compute the mass of H2O adsorded in each layer of the meshes 
168
169 do ig = 1,ngrid
170  do islope = 1,nslope
171    do iloop = 1,n_1km
172      K = Ko*exp(e/tsoil_PEM(ig,iloop,islope))
173      if(TI_PEM(ig,iloop,islope).lt.inertie_thresold)  then
174        theta_h2o_adsorbded(ig,iloop,islope) = (K*pvapor_avg(ig)/(1+K*pvapor_avg(ig)))**mu
175      else
176        p_sat =exp(alpha_clapeyron/tsoil_PEM(ig,iloop,islope) +beta_clapeyron) ! we assume fixed temperature in the ice ... not really:q good but ...
177        theta_h2o_adsorbded(ig,iloop,islope) = (K*p_sat/(1+K*p_sat))**mu
178      endif
179      dm_h2o_regolith_slope(ig,iloop,islope) = as*theta_h2o_adsorbded(ig,iloop,islope)*m_theta*rho_regolith
180   enddo
181  enddo
182 enddo
183
184! 2. Check the exchange between the atmosphere and the regolith
185
186  do ig = 1,ngrid
187   delta_mreg(ig) = 0.
188   do islope = 1,nslope
189    deltam_reg_slope(ig,islope) = 0.
190    do iloop = 1,n_1km
191       if((TI_PEM(ig,iloop,islope).lt.inertie_thresold).and.(ispermanent_h2oglaciers(ig,islope).eq.0).and.(ispermanent_co2glaciers(ig,islope).eq.0)) then
192             deltam_reg_complete(ig,iloop,islope) = (dm_h2o_regolith_slope(ig,iloop,islope) - m_h2o_completesoil(ig,iloop,islope)) &
193                                                   *(layer_PEM(iloop+1) - layer_PEM(iloop))
194       else ! NO EXCHANGE AS ICE BLOCK THE DYNAMIC!
195             deltam_reg_complete(ig,iloop,islope) = 0.
196       endif
197       deltam_reg_slope(ig,islope) = deltam_reg_slope(ig,islope) + deltam_reg_complete(ig,iloop,islope)
198    enddo
199   delta_mreg(ig) = delta_mreg(ig) + deltam_reg_slope(ig,islope)*subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)
200   enddo
201  enddo
202   m_h2o_completesoil(:,:,:) = dm_h2o_regolith_slope(:,:,:)
203
204
205 RETURN
206#endif
207  end subroutine
208
209!------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
210!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
211!!!
212!!! Purpose: Compute CO2  following the methods from Zent & Quinn 1995
213!!!
214!!! Author: LL, 01/2023
215!!!
216!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
217
218  SUBROUTINE regolith_co2adsorption(ngrid,nslope,nsoil_PEM,timelen,tend_h2oglaciers,tend_co2glaciers,waterice,co2ice,ps,q_co2,q_h2o,&
219                                   tsoil_PEM,TI_PEM,m_co2_completesoil,delta_mreg)
220#ifndef CPP_STD
221      use comsoil_h_PEM, only: layer_PEM, mlayer_PEM,n_1km
222      USE comcstfi_h, only: pi
223      use comslope_mod, only : subslope_dist,def_slope_mean
224      use vertical_layers_mod, ONLY: ap,bp
225#endif
226
227      IMPLICIT NONE
228! Inputs: 
229 INTEGER,INTENT(IN) :: ngrid, nslope, nsoil_PEM,timelen             ! size dimension
230 REAL,INTENT(IN) :: ps(ngrid,timelen)                               ! Average surface pressure [Pa]
231 REAL,INTENT(IN) :: tsoil_PEM(ngrid,nsoil_PEM,nslope)               ! Mean Soil Temperature [K]
232 REAL,INTENT(IN) :: TI_PEM(ngrid,nsoil_PEM,nslope)                  ! Mean Thermal Inertia [USI]
233 REAL,INTENT(IN) :: tend_h2oglaciers(ngrid,nslope),tend_co2glaciers(ngrid,nslope) !tendancies on the glaciers ()
234 REAL,INTENT(IN) :: q_co2(ngrid,timelen),q_h2o(ngrid,timelen)       ! Mass mixing ratio of co2 and h2o in the first layer (kg/kg)
235 REAL,INTENT(IN) :: waterice(ngrid,nslope)                          ! water ice at the surface [kg/m^2]
236 REAL,INTENT(IN) :: co2ice(ngrid,nslope)                            ! co2 ice at the surface [kg/m^2]
237
238! Outputs:
239 REAL,INTENT(INOUT) :: m_co2_completesoil(ngrid,nsoil_PEM,nslope)   ! Density of co2 adsorbed (kg/m^3)
240 REAL,INTENT(OUT) :: delta_mreg(ngrid)                              ! Difference density of co2 adsorbed (kg/m^3)
241 
242! Constants:
243
244 REAL :: alpha = 7.512e-6 ! Zent & Quinn 1995
245 REAL :: beta =  -1541.5  ! Zent & Quinn 1995
246 REAL ::  inertie_thresold = 800. ! TI > 800 means cementation
247 REAL ::  rho_regolith = 1500. ! density of the reoglith, buhler & piqueux 2021
248 real :: m_co2 = 44.01E-3      ! Molecular weight of co2 (kg/mol)
249 real :: m_noco2 = 33.37E-3    ! Molecular weight of h2o (kg/mol)
250 real :: m_theta = 4.27e-7     ! Mass of co2 per m^2 absorbed
251 real :: as = 18.9e3              ! Specific area, Buhler & Piqueux 2021
252
253! Local         
254 real :: A,B                                             ! Used to compute the mean mass above the surface
255 INTEGER :: ig,islope,iloop,it                           ! for loops
256 REAL :: dm_co2_regolith_slope(ngrid,nsoil_PEM,nslope)   ! elementary mass adsorded per mesh per slope
257 INTEGER :: ispermanent_co2glaciers(ngrid,nslope)        ! Check if the co2 glacier is permanent
258 INTEGER :: ispermanent_h2oglaciers(ngrid,nslope)        ! Check if the h2o glacier is permanent
259#ifndef CPP_STD
260 REAL :: deltam_reg_complete(ngrid,n_1km,nslope)         ! Difference in the mass per slope and soil layer (kg/m^3)
261#endif
262 REAL :: deltam_reg_slope(ngrid,nslope)                  ! Difference in the mass per slope  (kg/m^3)
263 REAL :: m_h2o_adsorbed(ngrid,nsoil_PEM,nslope)          ! Density of CO2 adsorbed (kg/m^3)
264 REAL :: theta_h2o_adsorbed(ngrid,nsoil_PEM,nslope)     ! Fraction of the pores occupied by H2O molecules
265 REAL :: delta_mh2o(ngrid)                              ! Difference density of h2o adsorbed (kg/m^3)
266!timelen array are allocated because heavy ...
267 real,allocatable :: mass_mean(:,:)                            ! mean mass above the surface
268 real,allocatable :: zplev_mean(:,:)                           ! pressure above the surface
269 real,allocatable :: pco2(:,:)                                  ! partial pressure above the surface
270 real, allocatable :: pco2_avg(:)                              ! yearly averaged
271
272! 0. Some initializations
273
274     allocate(mass_mean(ngrid,timelen))
275     allocate(zplev_mean(ngrid,timelen))
276     allocate(pco2(ngrid,timelen))
277     allocate(pco2_avg(ngrid))
278
279#ifndef CPP_STD
280 
281      m_h2o_adsorbed(:,:,:) = 0.
282      A =(1/m_co2 - 1/m_noco2)
283      B=1/m_noco2
284
285     dm_co2_regolith_slope(:,:,:) = 0
286     delta_mreg(:) = 0.
287
288!0.1 Look at perenial ice
289  do ig = 1,ngrid
290    do islope = 1,nslope
291     if((abs(tend_h2oglaciers(ig,islope)).gt.1e-5).and.(abs(waterice(ig,islope)).gt.0)) then
292        ispermanent_h2oglaciers(ig,islope) = 1
293     else
294        ispermanent_h2oglaciers(ig,islope) = 0
295     endif
296
297     if((abs(tend_co2glaciers(ig,islope)).gt.1e-5).and.(abs(co2ice(ig,islope)).gt.0)) then
298        ispermanent_co2glaciers(ig,islope) = 1
299     else
300        ispermanent_co2glaciers(ig,islope) = 0
301     endif
302    enddo
303   enddo
304
305!   0.2  Compute the partial pressure of CO2
306!a. the molecular mass into the column
307     do ig = 1,ngrid
308       mass_mean(ig,:) = 1./(A*q_co2(ig,:) +B)
309     enddo
310
311! b. pressure level
312     do it = 1,timelen
313       do ig = 1,ngrid
314         zplev_mean(ig,it) = ap(1) + bp(1)*ps(ig,it)
315       enddo
316     enddo
317
318! c. Vapor pressure
319     pco2(:,:) = mass_mean(:,:)/m_co2*q_co2(:,:)*zplev_mean(:,:)
320     pco2_avg(:) = sum(pco2(:,:),2)/timelen
321
322     deallocate(zplev_mean)
323     deallocate(mass_mean)
324     deallocate(pco2)
325
326
327! 1. Compute the fraction of the pores occupied by H2O
328
329 call regolith_h2oadsorption(ngrid,nslope,nsoil_PEM,timelen,tend_h2oglaciers,tend_co2glaciers,waterice,co2ice,ps,q_co2,q_h2o,tsoil_PEM,TI_PEM, &
330                                   theta_h2o_adsorbed, m_h2o_adsorbed,delta_mh2o)
331
332
333
334! 2.  we compute the mass of co2 adsorded in each layer of the meshes 
335
336 do ig = 1,ngrid
337  do islope = 1,nslope
338    do iloop = 1,n_1km
339     if((TI_PEM(ig,iloop,islope).lt.inertie_thresold).and.(ispermanent_h2oglaciers(ig,islope).eq.0).and.(ispermanent_co2glaciers(ig,islope).eq.0)) then
340     dm_co2_regolith_slope(ig,iloop,islope) = as*rho_regolith*m_theta*(1-theta_h2o_adsorbed(ig,iloop,islope))*alpha*pco2_avg(ig)/ &
341                                             (alpha*pco2_avg(ig)+sqrt(tsoil_PEM(ig,iloop,islope))*exp(beta/tsoil_PEM(ig,iloop,islope)))
342     else
343        if(abs(m_co2_completesoil(ig,iloop,islope)).lt.(1e-10)) then !!! we are at first call
344          dm_co2_regolith_slope(ig,iloop,islope) = as*rho_regolith*m_theta*(1-theta_h2o_adsorbed(ig,iloop,islope))*alpha*pco2_avg(ig) &
345                                                 /(alpha*pco2_avg(ig)+sqrt(tsoil_PEM(ig,iloop,islope))*exp(beta/tsoil_PEM(ig,iloop,islope)))
346        else ! no change: permanent ice stick the atoms of CO2
347          dm_co2_regolith_slope(ig,iloop,islope) = m_co2_completesoil(ig,iloop,islope)
348        endif
349     endif
350  enddo
351 enddo
352enddo
353
354! 3. Check the exchange between the atmosphere and the regolith
355
356  do ig = 1,ngrid
357   delta_mreg(ig) = 0.
358   do islope = 1,nslope
359    deltam_reg_slope(ig,islope) = 0.
360    do iloop = 1,n_1km
361       if((TI_PEM(ig,iloop,islope).lt.inertie_thresold).and.(ispermanent_h2oglaciers(ig,islope).eq.0).and.(ispermanent_co2glaciers(ig,islope).eq.0)) then
362             deltam_reg_complete(ig,iloop,islope) = (dm_co2_regolith_slope(ig,iloop,islope) - m_co2_completesoil(ig,iloop,islope)) &
363                                                   *(layer_PEM(iloop+1) - layer_PEM(iloop))
364       else ! NO EXCHANGE AS ICE BLOCK THE DYNAMIC!
365             deltam_reg_complete(ig,iloop,islope) = 0.
366       endif
367       deltam_reg_slope(ig,islope) = deltam_reg_slope(ig,islope) + deltam_reg_complete(ig,iloop,islope)
368    enddo
369   delta_mreg(ig) = delta_mreg(ig) + deltam_reg_slope(ig,islope)*subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)
370   enddo
371  enddo
372  m_co2_completesoil(:,:,:) = dm_co2_regolith_slope(:,:,:)
373
374!=======================================================================
375      RETURN
376#endif
377      END
378
379
380   end module
Note: See TracBrowser for help on using the repository browser.