Skip to content

Commit 19abe29

Browse files
Peter Andrew Bogenschutztcclevenger
authored andcommitted
update tests to remove specific length scale for 1p5 tke
1 parent 1ea27cd commit 19abe29

3 files changed

Lines changed: 17 additions & 147 deletions

File tree

components/eamxx/src/physics/shoc/shoc_functions.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,9 @@ template <typename ScalarT, typename DeviceT> struct Functions {
277277

278278
KOKKOS_FUNCTION
279279
static void compute_shoc_mix_shoc_length(
280-
const MemberType &team, const Int &nlev, const Scalar &length_fac, const bool &shoc_1p5tke,
280+
const MemberType &team, const Int &nlev, const bool &shoc_1p5tke,
281281
const uview_1d<const Pack> &tke, const uview_1d<const Pack> &brunt,
282-
const uview_1d<const Pack> &zt_grid, const uview_1d<const Pack> &dz_zt,
283-
const uview_1d<const Pack> &tk, const Scalar &l_inf, const uview_1d<Pack> &shoc_mix);
282+
const uview_1d<const Pack> &zt_grid, const Scalar &l_inf, const uview_1d<Pack> &shoc_mix);
284283

285284
KOKKOS_FUNCTION
286285
static void check_tke(const MemberType &team, const Int &nlev, const uview_1d<Pack> &tke);
@@ -414,20 +413,20 @@ template <typename ScalarT, typename DeviceT> struct Functions {
414413

415414
KOKKOS_FUNCTION
416415
static void shoc_length(const MemberType &team, const Int &nlev, const Int &nlevi,
417-
const Scalar &length_fac, const bool &shoc_1p5tke, const Scalar &dx,
416+
const Scalar &length_fac, const Scalar &dx,
418417
const Scalar &dy, const uview_1d<const Pack> &zt_grid,
419418
const uview_1d<const Pack> &zi_grid, const uview_1d<const Pack> &dz_zt,
420419
const uview_1d<const Pack> &tke, const uview_1d<const Pack> &thv,
421-
const uview_1d<const Pack> &tk, const Workspace &workspace,
422-
const uview_1d<Pack> &brunt, const uview_1d<Pack> &shoc_mix);
420+
const Workspace &workspace, const uview_1d<Pack> &brunt,
421+
const uview_1d<Pack> &shoc_mix);
423422
#ifdef SCREAM_SHOC_SMALL_KERNELS
424423
static void shoc_length_disp(const Int &shcol, const Int &nlev, const Int &nlevi,
425-
const Scalar &length_fac, const bool &tke_1p5_closure,
424+
const Scalar &length_fac,
426425
const view_1d<const Scalar> &dx, const view_1d<const Scalar> &dy,
427426
const view_2d<const Pack> &zt_grid,
428427
const view_2d<const Pack> &zi_grid,
429428
const view_2d<const Pack> &dz_zt, const view_2d<const Pack> &tke,
430-
const view_2d<const Pack> &thv, const view_2d<const Pack> &tk,
429+
const view_2d<const Pack> &thv,
431430
const WorkspaceMgr &workspace_mgr, const view_2d<Pack> &brunt,
432431
const view_2d<Pack> &shoc_mix);
433432
#endif

components/eamxx/src/physics/shoc/tests/shoc_length_tests.cpp

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ struct UnitWrap::UnitTest<D>::TestShocLength : public UnitWrap::UnitTest<D>::Bas
4848
static constexpr Real thv[nlev] = {315, 310, 305, 300, 295};
4949
// Turbulent kinetc energy [m2/s2]
5050
static constexpr Real tke[nlev] = {0.1, 0.15, 0.2, 0.25, 0.3};
51-
// Eddy viscosity [m2/s]
52-
static constexpr Real tk[nlev] = {0.1, 10.0, 12.0, 15.0, 20.0};
53-
54-
// Default SHOC formulation, not 1.5 TKE closure assumptions
55-
const bool shoc_1p5tke = false;
5651

5752
// compute geometric grid mesh
5853
const auto grid_mesh = sqrt(host_dx*host_dy);
@@ -67,7 +62,7 @@ struct UnitWrap::UnitTest<D>::TestShocLength : public UnitWrap::UnitTest<D>::Bas
6762
}
6863

6964
// Initialize data structure for bridging to F90
70-
ShocLengthData SDS(shcol, nlev, nlevi, shoc_1p5tke);
65+
ShocLengthData SDS(shcol, nlev, nlevi);
7166

7267
// Load up input data
7368
for(Int s = 0; s < shcol; ++s) {
@@ -83,8 +78,6 @@ struct UnitWrap::UnitTest<D>::TestShocLength : public UnitWrap::UnitTest<D>::Bas
8378
SDS.zt_grid[offset] = zt_grid[n];
8479
SDS.thv[offset] = thv[n];
8580
SDS.dz_zt[offset] = dz_zt[n];
86-
// eddy viscosity below not relevant for default SHOC
87-
SDS.tk[offset] = 0;
8881
}
8982

9083
// Fill in test data on zi_grid
@@ -154,50 +147,6 @@ struct UnitWrap::UnitTest<D>::TestShocLength : public UnitWrap::UnitTest<D>::Bas
154147
}
155148
}
156149

157-
// Repeat this test but for 1.5 TKE closure option activated
158-
159-
// Activate 1.5 TKE closure assumptions
160-
SDS.shoc_1p5tke = true;
161-
162-
// We will use the same input data as above but with the SGS buoyancy
163-
// flux set to zero, as will be the case with the 1.5 TKE option.
164-
// Additionally, we will fill the value of the brunt vaisala frequency.
165-
for(Int s = 0; s < shcol; ++s) {
166-
for(Int n = 0; n < nlev; ++n) {
167-
const auto offset = n + s * nlev;
168-
169-
SDS.tk[offset] = tk[n];
170-
}
171-
}
172-
173-
// Call the C++ implementation
174-
shoc_length(SDS);
175-
176-
// Verify output
177-
for(Int s = 0; s < shcol; ++s) {
178-
for(Int n = 0; n < nlev; ++n) {
179-
const auto offset = n + s * nlev;
180-
// Require mixing length is greater than zero and is
181-
// less than geometric grid mesh length + 1 m
182-
REQUIRE(SDS.shoc_mix[offset] >= minlen);
183-
REQUIRE(SDS.shoc_mix[offset] <= maxlen);
184-
REQUIRE(SDS.shoc_mix[offset] < 1.0+grid_mesh);
185-
186-
// Be sure brunt vaisalla frequency is reasonable
187-
REQUIRE(SDS.brunt[offset] < 1);
188-
189-
// Ensure length scale is equal to dz if brunt =< 0, else
190-
// length scale should be less then dz
191-
if (SDS.brunt[offset] <= 0){
192-
REQUIRE(SDS.shoc_mix[offset] == SDS.dz_zt[offset]);
193-
}
194-
else{
195-
REQUIRE(SDS.shoc_mix[offset] < SDS.dz_zt[offset]);
196-
}
197-
198-
}
199-
}
200-
201150
// TEST TWO
202151
// Small grid mesh test. Given a very small grid mesh, verify that
203152
// the length scale is confined to this value. Input from first
@@ -208,9 +157,6 @@ struct UnitWrap::UnitTest<D>::TestShocLength : public UnitWrap::UnitTest<D>::Bas
208157
// Defin the host grid box size y-direction [m]
209158
static constexpr Real host_dy_small = 5;
210159

211-
// Call default SHOC closure assumptions
212-
SDS.shoc_1p5tke = false;
213-
214160
// compute geometric grid mesh
215161
const auto grid_mesh_small = sqrt(host_dx_small*host_dy_small);
216162

@@ -235,26 +181,6 @@ struct UnitWrap::UnitTest<D>::TestShocLength : public UnitWrap::UnitTest<D>::Bas
235181
}
236182
}
237183

238-
// Repeat this test but for 1.5 TKE closure option activated
239-
240-
// Activate 1.5 TKE closure assumptions
241-
SDS.shoc_1p5tke = true;
242-
243-
// call C++ implementation
244-
shoc_length(SDS);
245-
246-
// Verify output
247-
for(Int s = 0; s < shcol; ++s) {
248-
for(Int n = 0; n < nlev; ++n) {
249-
const auto offset = n + s * nlev;
250-
// Require mixing length is greater than zero and is
251-
// less than geometric grid mesh length + 1 m
252-
REQUIRE(SDS.shoc_mix[offset] > 0);
253-
REQUIRE(SDS.shoc_mix[offset] <= maxlen);
254-
REQUIRE(SDS.shoc_mix[offset] < 1.0+grid_mesh_small);
255-
}
256-
}
257-
258184
}
259185

260186
void run_bfb()
@@ -263,10 +189,10 @@ struct UnitWrap::UnitTest<D>::TestShocLength : public UnitWrap::UnitTest<D>::Bas
263189

264190
ShocLengthData SDS_baseline[] = {
265191
// shcol, nlev, nlevi
266-
ShocLengthData(12, 71, 72, false),
267-
ShocLengthData(10, 12, 13, false),
268-
ShocLengthData(7, 16, 17, false),
269-
ShocLengthData(2, 7, 8, false),
192+
ShocLengthData(12, 71, 72),
193+
ShocLengthData(10, 12, 13),
194+
ShocLengthData(7, 16, 17),
195+
ShocLengthData(2, 7, 8),
270196
};
271197

272198
// Generate random input data

components/eamxx/src/physics/shoc/tests/shoc_mix_length_tests.cpp

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ struct UnitWrap::UnitTest<D>::TestCompShocMixLength : public UnitWrap::UnitTest<
4242
// Define the heights on the zt grid [m]
4343
static constexpr Real zt_grid[nlev] = {5000, 3000, 2000, 1000, 500};
4444

45-
// Default SHOC formulation, not 1.5 TKE closure assumptions
46-
const bool shoc_1p5tke = false;
47-
4845
// Initialize data structure for bridging to F90
49-
ComputeShocMixShocLengthData SDS(shcol, nlev, shoc_1p5tke);
46+
ComputeShocMixShocLengthData SDS(shcol, nlev);
5047

5148
// Test that the inputs are reasonable.
5249
// For this test shcol MUST be at least 2
@@ -64,9 +61,6 @@ struct UnitWrap::UnitTest<D>::TestCompShocMixLength : public UnitWrap::UnitTest<
6461
SDS.tke[offset] = (1.0+s)*tke_cons;
6562
SDS.brunt[offset] = brunt_cons;
6663
SDS.zt_grid[offset] = zt_grid[n];
67-
// do not consider below for default SHOC
68-
SDS.tk[offset] = 0;
69-
SDS.dz_zt[offset] = 0;
7064
}
7165
}
7266

@@ -116,55 +110,6 @@ struct UnitWrap::UnitTest<D>::TestCompShocMixLength : public UnitWrap::UnitTest<
116110
}
117111
}
118112

119-
// 1.5 TKE test
120-
// Verify that length scale behaves as expected when 1.5 TKE closure
121-
// assumptions are used. Will recycle all previous data, except we
122-
// need to define dz, brunt vaisalla frequency, and tk.
123-
124-
// Brunt Vaisalla frequency [s-1]
125-
static constexpr Real brunt_1p5[nlev] = {0.01,-0.01,0.01,-0.01,0.01};
126-
// Define the heights on the zt grid [m]
127-
static constexpr Real dz_zt_1p5[nlev] = {50, 100, 30, 20, 10};
128-
// Eddy viscocity [m2 s-1]
129-
static constexpr Real tk_cons_1p5 = 0.1;
130-
131-
// Activate 1.5 TKE closure
132-
SDS.shoc_1p5tke = true;
133-
134-
// Fill in test data on zt_grid.
135-
for(Int s = 0; s < shcol; ++s) {
136-
for(Int n = 0; n < nlev; ++n) {
137-
const auto offset = n + s * nlev;
138-
139-
// do not consider below for default SHOC
140-
SDS.tk[offset] = tk_cons_1p5;
141-
SDS.dz_zt[offset] = dz_zt_1p5[n];
142-
SDS.brunt[offset] = brunt_1p5[n];
143-
}
144-
}
145-
146-
// Call the C++ implementation
147-
compute_shoc_mix_shoc_length(SDS);
148-
149-
// Check the result
150-
151-
// Verify that if Brunt Vaisalla frequency is unstable that mixing length
152-
// is equal to vertical grid spacing. If brunt is stable, then verify that
153-
// mixing length is less than the vertical grid spacing.
154-
for(Int s = 0; s < shcol; ++s) {
155-
for(Int n = 0; n < nlev; ++n) {
156-
const auto offset = n + s * nlev;
157-
if (SDS.brunt[offset] <= 0){
158-
REQUIRE(SDS.shoc_mix[offset] == SDS.dz_zt[offset]);
159-
}
160-
else{
161-
REQUIRE(SDS.shoc_mix[offset] < SDS.dz_zt[offset]);
162-
REQUIRE(SDS.shoc_mix[offset] >= 0.1*SDS.dz_zt[offset]);
163-
}
164-
165-
}
166-
}
167-
168113
}
169114

170115
void run_bfb()
@@ -173,10 +118,10 @@ struct UnitWrap::UnitTest<D>::TestCompShocMixLength : public UnitWrap::UnitTest<
173118

174119
ComputeShocMixShocLengthData SDS_baseline[] = {
175120
// shcol, nlev
176-
ComputeShocMixShocLengthData(10, 71, false),
177-
ComputeShocMixShocLengthData(10, 12, false),
178-
ComputeShocMixShocLengthData(7, 16, false),
179-
ComputeShocMixShocLengthData(2, 7, false)
121+
ComputeShocMixShocLengthData(10, 71),
122+
ComputeShocMixShocLengthData(10, 12),
123+
ComputeShocMixShocLengthData(7, 16),
124+
ComputeShocMixShocLengthData(2, 7)
180125
};
181126

182127
// Generate random input data

0 commit comments

Comments
 (0)