Skip to content

Commit

Permalink
Merge pull request #11 from JosueBock/master
Browse files Browse the repository at this point in the history
minor updates related to v_mean subroutine
  • Loading branch information
JosueBock authored Sep 22, 2020
2 parents 45cfdfa + 14bcb6d commit 4de9d60
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 7 deletions.
122 changes: 119 additions & 3 deletions src/kpp.f
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,9 @@ subroutine initc (box,n_bl)

c Init calc of v_mean and henry
c initialize all variables also for box run
! call v_mean_a (t,nf)
! call henry_a (t,p,nf) ! jjb second argument (p) not used
call henry_a (t,nf) ! jjb removed
call st_coeff_a
! call v_mean_t (t,nf)
! call henry_t (t,p,nf) ! jjb second argument (p) not used
call henry_t (t,nf) ! jjb removed
call st_coeff_t
Expand Down Expand Up @@ -495,7 +493,7 @@ subroutine liq_parm (xra,box,n_bl)
enddo
enddo


! Compute the mean molecular speed (depends only on the temperature)
call v_mean (t(:nmax_chem_aer))

! Call all subroutines needed for aerosols (bins 1 & 2) (aer mechanism)
Expand Down Expand Up @@ -879,6 +877,51 @@ end subroutine st_coeff_a

subroutine v_mean_init

! Description :
! -----------
! Compute the mean molecular speed from Maxwell-Boltzmann distribution:
! v_mean=sqrt(8*R_gas*T/(M*pi)) (M in kg/mol)

! Interface :
! ---------
! SR v_mean_init is called during initialisation:
! - by SR initc (no restart case)
! - by SR str=main (restart case)

! Input :
! -----
! - chemical species molar masses have been imported from the user defined files ('gas_species.csv')

! Output :
! ------
! - v_mean_init computes the constant factor in vmean: vmean_init=sqrt(8*R_gas /(M*pi))

! Externals :
! ---------
! none

! Method :
! ------
! Improve computing efficiency: split vmean calculation into a constant part, calculated here,
! and a variable term (sqrt(T)) computed only once in SR v_mean

! Author :
! ------
! Josue Bock


! Modifications :
! -------------
!
! 04-Jan-2017 Josue Bock First version
!

! == End of header =============================================================

! Declarations :
! ------------
! Modules used:

USE constants, ONLY :
! Imported Parameters:
& gas_const,
Expand All @@ -903,12 +946,16 @@ subroutine v_mean_init

implicit none

! Local scalars:
integer :: jtot
integer :: jspec
double precision :: const_fact

! Local arrays:
double precision :: sqrt_mass (j1 + j5 + j4)

! == End of declarations =======================================================

jtot = j1 + j5 + j4

allocate ( vmean_init(jtot) )
Expand Down Expand Up @@ -938,6 +985,69 @@ end subroutine v_mean_init

subroutine v_mean (temperature)

! Description :
! -----------
! Compute the mean molecular speed from Maxwell-Boltzmann distribution:
! v_mean=sqrt(8*R_gas*T/(M*pi)) (M in kg/mol)

! Interface :
! ---------
! SR v_mean is called:
! - during initialisation:
! - by SR initc (no restart case)
! - by SR str=main (restart case)
! - during the run
! - by SR liq_parm
! - by SR box_update (which is call during time integration, but actually calls v_mean only during initialisation)

! Input :
! -----
! - vmean_init has been computed by SR v_mean_init during initialisation

! Output :
! ------
! - v_mean computes the mean molecular speed, using constant factor in vmean: vmean_init=sqrt(8*R_gas /(M*pi))

! Externals :
! ---------
! none

! Method :
! ------
! Improve computing efficiency: split vmean calculation into a constant part, calculated here,
! and a variable term (sqrt(T)) computed only once in SR v_mean

! Author :
! ------
! Roland von Glasow


! Modifications :
! -------------
! 17-Jul-2015 Josue Bock Commented unused /cb40/ (found in the code that vmean had been computed only between
! lcl and lct, but this had been changed, now from 1 to nmaxf
!
! 05-Mar-2016 Josue Bock Forcheck errors 307E, 312E: commented lines related to CHBr2I, I2O, I2O3, I2O4, I2O5 and INO
! (undefined indexes)
!
! 17-Mar-2016 Josue Bock Reindexed vmean array for computing efficiency: innermost is leftmost
! vmean(nf,NSPEC) -> vmean(NSPEC,nf)
!
! 22-Mar-2016 Josue Bock Missing species added: SO3, H2SO2 and corrected values for HNO4 (63->79 g/mol), XOR (109->125 g/mol)
!
! 04-Jan-2017 Josue Bock Major change to the code structure: split v_mean_init and v_mean (no longer v_mean_a and v_mean_t)
! This is ready in my sub-version jjb6v1.0*
!
! 11-Feb-2017 Josue Bock Changed double-specific math function (dsqrt) into generic one (sqrt) in the whole file
! Also changed the exponent of hard-written mass values (e -> d) for a few species, for consistency

! == End of header =============================================================


! Declarations :
! ------------
! Modules used:

USE gas_common, ONLY :
! Imported Parameters:
& j1,
Expand All @@ -954,11 +1064,17 @@ subroutine v_mean (temperature)

implicit none

! Subroutine arguments
! Array arguments with intent(in):
double precision, intent(in) :: temperature (nmax_chem_aer)
! Local scalars:
integer :: jtot
integer :: j,k
! Local arrays:
double precision :: sqrtt(nmax_chem_aer)

! == End of declarations =======================================================

jtot = j1 + j5 + j4

sqrtt = sqrt(temperature)
Expand Down
8 changes: 4 additions & 4 deletions src/str.f
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
& nka,
& nkt,
& nphrxn,
& nmax_chem_aer,
& mbs

implicit double precision (a-h,o-z)
Expand Down Expand Up @@ -200,7 +201,7 @@
if (chem) call profc (dt,mic)
! allocate arrays and initialise vmean
if (chem) call v_mean_init
if (chem) call v_mean (t(:nf))
if (chem) call v_mean (t(:nmax_chem_aer))


! Continue the initialisation, both cases
Expand Down Expand Up @@ -4949,6 +4950,7 @@ subroutine box_update (box_switch,ij,nlevbox,nz_box,n_bl,
& n,
& nrlay,
& nkc,
& nmax_chem_aer,
& mbs
implicit double precision (a-h,o-z)
Expand Down Expand Up @@ -5013,8 +5015,7 @@ subroutine box_update (box_switch,ij,nlevbox,nz_box,n_bl,
! enddo
! enddo
stop 'jjb: box version has to be updated'
call v_mean (t(:nf))
!call v_mean_a (t,nf)
call v_mean (t(:nmax_chem_aer))
! call henry_a (t,p,nf) ! jjb second argument (p) not used
call henry_a (t,nf) ! jjb removed
! call fast_k_mt_a(freep,cw,fa_lse,nf) ! jjb cw now passed as a CB
Expand All @@ -5030,7 +5031,6 @@ subroutine box_update (box_switch,ij,nlevbox,nz_box,n_bl,
if (cm(3,n_bl).gt.0.) xph3 = 1.
if (cm(4,n_bl).gt.0.) xph4 = 1.
if (xph3.eq.1..or.xph4.eq.1.) then
!call v_mean_t (t,nf)
! call henry_t (t,p,nf) ! jjb second argument (p) not used
call henry_t (t,nf) ! jjb removed
! call fast_k_mt_t(freep,cw,fa_lse,nf) ! jjb cw now passed as a CB
Expand Down

0 comments on commit 4de9d60

Please sign in to comment.