From ebcead5e26e7cbaac29b006e36e308ddde065109 Mon Sep 17 00:00:00 2001 From: chowland Date: Tue, 2 Apr 2024 16:04:50 +0200 Subject: [PATCH 1/8] Add initial condition interpolation for humidity --- src/ReadFlowInterp.F90 | 4 +++- src/moisture.F90 | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/ReadFlowInterp.F90 b/src/ReadFlowInterp.F90 index b83a5b20..e32bc17a 100644 --- a/src/ReadFlowInterp.F90 +++ b/src/ReadFlowInterp.F90 @@ -6,7 +6,7 @@ subroutine ReadFlowInterp(prow,pcol) use input_grids use afid_salinity use afid_phasefield - use afid_moisture, only: humid + use afid_moisture, only: humid, InterpInputHum use AuxiliaryRoutines implicit none @@ -121,6 +121,8 @@ subroutine ReadFlowInterp(prow,pcol) call InterpInputVel + if (moist) call InterpInputHum + if (ismaster) write(*,*) "Velocity and T interpolated" if (multires) then diff --git a/src/moisture.F90 b/src/moisture.F90 index c40ed41e..b90d4566 100644 --- a/src/moisture.F90 +++ b/src/moisture.F90 @@ -534,4 +534,51 @@ subroutine CreateMoistH5Groups(filename) end subroutine CreateMoistH5Groups +!> Interpolate the humidity field provided by `continua_humid.h5` +!! from a previous grid onto the current grid specified by `bou.in` +subroutine InterpInputHum + use input_grids + use HermiteInterpolations, only: interpolate_xyz_old_to_new + real, allocatable, dimension(:,:,:) :: qold !< Humidity on the old grid + real :: qup !< Upper boundary condition for humidity + real :: qlo !< Lower boundary condition for humidity + integer :: ic, jc + + ! Read field from h5 file and store in qold + call AllocateReal3DArray(qold, -1, nxo+1, & + xstarto(2)-lvlhalo, xendo(2)+lvlhalo, & + xstarto(3)-lvlhalo, xendo(3)+lvlhalo) + qold(:,:,:) = 0.d0 + call HdfReadContinua(nzo, nyo, nxo, & + xstarto(2), xendo(2), xstarto(3), xendo(3), 8, & + qold(1:nxo,xstarto(2)-lvlhalo:xendo(2)+lvlhalo,xstarto(3)-lvlhalo:xendo(3)+lvlhalo)) + + ! Boundary conditions (called after SetHumidityBCs) + ! ASSUMES HUMTP, HUMBP ARE CONSTANT) + qup = humtp(1,xstart(2),xstart(3)) + qlo = humbp(1,xstart(2),xstart(3)) + + ! Apply boundary conditions in x-halo cells + do ic=xstarto(3),xendo(3) + do jc=xstarto(2),xendo(2) + if (qfixS==1) then + qold(0,jc,ic) = 2.0*qlo - qold(1,jc,ic) + else + qold(0,jc,ic) = qold(1,jc,ic) + end if + if (qfixN==1) then + qold(nxo,jc,ic) = 2.0*qup - qold(nxmo,jc,ic) + else + qold(nxo,jc,ic) = qold(nxmo,jc,ic) + end if + end do + end do + call update_halo(qold, lvlhalo) + + call interpolate_xyz_old_to_new(qold, humid(1:nxm,:,:)) + + call DestroyReal3DArray(qold) + +end subroutine InterpInputHum + end module afid_moisture \ No newline at end of file From c5f98ba823d81ba3303474fe4f5d9199df1f2ef9 Mon Sep 17 00:00:00 2001 From: chowland Date: Tue, 2 Apr 2024 16:05:09 +0200 Subject: [PATCH 2/8] add reading moisture params to afidtools --- tools/afidtools/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/afidtools/__init__.py b/tools/afidtools/__init__.py index 7f8fa61b..bc74eed9 100644 --- a/tools/afidtools/__init__.py +++ b/tools/afidtools/__init__.py @@ -1,3 +1,4 @@ from .afidtools import * from .xdmf import * -from .boundary_layers import * \ No newline at end of file +from .boundary_layers import * +from .moisture import * \ No newline at end of file From 072116b58759d3e3cc948ab7890916630ebc6bd8 Mon Sep 17 00:00:00 2001 From: chowland Date: Tue, 2 Apr 2024 16:05:40 +0200 Subject: [PATCH 3/8] use humid.in and correct unsat profile --- tools/drizzle.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tools/drizzle.py b/tools/drizzle.py index d45398f3..1d459025 100644 --- a/tools/drizzle.py +++ b/tools/drizzle.py @@ -1,22 +1,24 @@ import h5py from scipy.special import lambertw -import os import afidtools as afid import numpy as np -fld = os.environ['WORK']+'/RainyBenard/drizzle_IC' +fld = '../examples/RainyBenard' inputs = afid.InputParams(fld) nxm = inputs.nxm print(nxm) -saturated_top = False +mpar = afid.MoistParams(fld) +alpha = mpar.alpha +beta = mpar.beta +gamma = mpar.gamma -alpha = 3.0 -beta = 2.0 -if saturated_top: - gamma = beta/(1 - np.exp(-alpha)) -else: - gamma = beta +saturated_top = (mpar.qfixN==1) +if gamma < 0: + if saturated_top: + gamma = beta/(1 - np.exp(-alpha)) + else: + gamma = beta print(alpha, beta, gamma) def W(z): @@ -46,17 +48,18 @@ def W(z): if not saturated_top: # Calculate height above which humidity not at saturation - D = alpha*(beta + 1)*np.exp(1-alpha)/(1 + alpha*beta*np.exp(1-alpha)) - B = beta*D - 1 - zc = 1 + 1/alpha/(B-beta) + A = beta - (1 + gamma)/(1 + gamma*alpha*np.exp(1-alpha)) + B = alpha*np.exp(1-alpha)*(1 + gamma)/(1 + gamma*alpha*np.exp(1-alpha)) + zc = 1 - (1 + gamma*alpha*np.exp(1-alpha))/alpha/(1+gamma) # Prescribe linear profiles above this level - b[z > zc] = beta - 1 + B*(z[z > zc] - 1) - q[z > zc] = D*(1 - z[z > zc]) + b[z > zc] = beta - 1 + A*(z[z > zc] - 1) + q[z > zc] = B*(1 - z[z > zc]) import matplotlib.pyplot as plt fig, ax = plt.subplots(layout='constrained') ax.plot(b, z) ax.plot(q, z) +ax.grid(True) fig.savefig('drizzle.png') with h5py.File(fld+'/drizzle.h5','w') as f: From 63d8e43b671b96f0d8f8e8091c1dc4e54f7491a2 Mon Sep 17 00:00:00 2001 From: chowland Date: Wed, 3 Apr 2024 12:52:44 +0300 Subject: [PATCH 4/8] save midplane when using rainy --- src/h5tools/MakeMovieXCut.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/h5tools/MakeMovieXCut.F90 b/src/h5tools/MakeMovieXCut.F90 index ad5a5aa8..b6fdf85a 100644 --- a/src/h5tools/MakeMovieXCut.F90 +++ b/src/h5tools/MakeMovieXCut.F90 @@ -30,6 +30,7 @@ subroutine Mkmov_xcut ic = 1 if (RayS < 0 .and. RayT < 0) ic = nxm/2 if (IBM) ic = nxm/2 + if (moist) ic = nxm/2 ! Record filename as string filename = trim("outputdir/flowmov/movie_xcut.h5") From 4c80c3c66377b58c345c12babed888f1a7da0bd3 Mon Sep 17 00:00:00 2001 From: chowland Date: Wed, 3 Apr 2024 12:53:23 +0300 Subject: [PATCH 5/8] add O2 optimization explicitly to Disco --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6c5ae89c..d64e504f 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ ifeq ($(MACHINE),PC) endif ifeq ($(MACHINE),DISCOVERER) ifeq ($(FLAVOUR),GNU) - FC = h5pfc -cpp -fdefault-real-8 -fdefault-double-8 + FC = h5pfc -O2 -cpp -fdefault-real-8 -fdefault-double-8 LDFLAGS += -lfftw3 -llapack -ldl else LDFLAGS += -lfftw3 -qmkl=sequential From f100c72ab37754e38e3276435d2ee30626d55605 Mon Sep 17 00:00:00 2001 From: chowland Date: Wed, 3 Apr 2024 15:38:03 +0300 Subject: [PATCH 6/8] switch CI to openmpi --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 193fc1fc..037a6e96 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -26,7 +26,7 @@ jobs: run: sudo apt install libblas-dev liblapack-dev - name: Install Parallel HDF5 - run: sudo apt install libhdf5-mpich-dev + run: sudo apt install libhdf5-openmpi-dev - name: Install FFTW library run: sudo apt install libfftw3-dev From ab6cf17681daf939748dd5a138b19d60d4e8e14d Mon Sep 17 00:00:00 2001 From: chowland Date: Wed, 3 Apr 2024 15:46:30 +0300 Subject: [PATCH 7/8] use apt-get in CI --- .github/workflows/CI.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 037a6e96..e4677b9e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,16 +20,18 @@ jobs: # - name: Install GFortran # NB gfortran and build-essential already on VM # run: | - # sudo apt install build-essential gfortran + # sudo apt-get install build-essential gfortran - name: Install BLAS and LAPACK - run: sudo apt install libblas-dev liblapack-dev + run: | + sudo apt-get update + sudo apt-get install libblas-dev liblapack-dev - name: Install Parallel HDF5 - run: sudo apt install libhdf5-openmpi-dev + run: sudo apt-get install libhdf5-openmpi-dev - name: Install FFTW library - run: sudo apt install libfftw3-dev + run: sudo apt-get install libfftw3-dev - name: Build AFiD run: make \ No newline at end of file From 63edbfcca6b1fb6453e6a8abab0384fa30f531c7 Mon Sep 17 00:00:00 2001 From: chowland Date: Wed, 3 Apr 2024 16:02:02 +0300 Subject: [PATCH 8/8] update CI to v4 --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e4677b9e..feadebd5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 # - name: Install GFortran # NB gfortran and build-essential already on VM # run: |