From d6419d756dbc96003ff14d6a1f754444227b49fc Mon Sep 17 00:00:00 2001
From: Stefano Serafin <serafin@jet02.img.univie.ac.at>
Date: Thu, 11 Jul 2024 08:17:51 +0200
Subject: [PATCH] added random perturbations to surface heat flux

---
 models.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/models.py b/models.py
index 1eba750..bf98baa 100644
--- a/models.py
+++ b/models.py
@@ -240,6 +240,8 @@ class CBL:
         z0 = self.z0
         theta_0 = self.theta_0
         Hmax = self.Hmax
+        H0_perturbation_ampl_init = self.H0_perturbation_ampl_init
+        H0_perturbation_ampl_time = self.H0_perturbation_ampl_time
         exct = self.exct
         ug = self.ug
         vg = self.vg
@@ -311,6 +313,9 @@ class CBL:
             else:
                 H0 = Hmax
             
+            # Add random perturbations to the initial value
+            H0 += np.random.normal(scale=H0_perturbation_ampl_init)
+
             # Set the surface momentum flux (ustar)
             ustar = 0
 
@@ -357,8 +362,9 @@ class CBL:
             # Inverse grid spacing
             rdz = 1./self.dz
 
-            # Compute sensible heat flux and integrate T equation
-            H[0,j]     = H0
+            # Add time-dependent surface perturbations
+            # Then compute sensible heat flux and integrate T equation
+            H[0,j]     = H0 + np.random.normal(scale=H0_perturbation_ampl_time)
             H[1:-1,j]  = -K[1:-1,j]*( (thetap[1:]-thetap[:-1])*rdz - gammac)
             H[nz,j]    = 2*H[nz-1,j]-H[nz-2,j]
             theta[:,j] = thetap[:]-dt*rdz*(H[1:,j]-H[:-1,j])
-- 
GitLab