Skip to content

Commit 30c5666

Browse files
katsmith133alicebarthel
authored andcommitted
adds lower bounds clamping test for temperature
1 parent 645f108 commit 30c5666

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

components/omega/test/ocn/EosTest.cpp

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const Real TeosClampValue2 =
4444
0.0009662964459162306; // Expected value for TEOS-10 eos clamping test 2
4545
const Real TeosClampValue3 =
4646
0.0010086299185825206; // Expected value for TEOS-10 eos clamping test 3
47+
const Real TeosClampValue4 =
48+
0.000970887661659709; // Expected value for TEOS-10 eos clamping test 4
4749
const Real LinearExpValue =
4850
0.0009784735812133072; // Expected value for Linear eos
4951

@@ -302,7 +304,9 @@ int testEosTeos10Clamping() {
302304
Array2DReal TArray = Array2DReal("TArray", Mesh->NCellsAll, NVertLevels);
303305
Array2DReal PArray = Array2DReal("PArray", Mesh->NCellsAll, NVertLevels);
304306
/// Use Kokkos::deep_copy to fill the entire view with the ref value
305-
/// Test with valid poly75t values first.
307+
/// -------------------------------------
308+
/// Test with valid poly75t values first (no clamping)
309+
/// -------------------------------------
306310
deepCopy(SArray, 35.0);
307311
deepCopy(TArray, 5.0);
308312
deepCopy(PArray, 400.0);
@@ -334,8 +338,10 @@ int testEosTeos10Clamping() {
334338
LOG_INFO("EosTest SpecVolClampingNone TEOS-10: PASS");
335339
}
336340

341+
/// -------------------------------------
337342
/// Test with an ivalid poly75t salinity value second
338-
deepCopy(SArray, 45.0);
343+
/// -------------------------------------
344+
deepCopy(SArray, 45.0); // Clamping happens at 42.0
339345
deepCopy(TArray, 5.0);
340346
deepCopy(PArray, 400.0);
341347
deepCopy(TestEos->SpecVol, 0.0);
@@ -366,9 +372,11 @@ int testEosTeos10Clamping() {
366372
LOG_INFO("EosTest SpecVolClampingSalt TEOS-10: PASS");
367373
}
368374

369-
/// Test with an ivalid poly75t temperature value third
375+
/// -------------------------------------
376+
/// Test with an ivalid high poly75t temperature value third
377+
/// -------------------------------------
370378
deepCopy(SArray, 35.0);
371-
deepCopy(TArray, 100.0);
379+
deepCopy(TArray, 100.0); // Clamping happens at 95.0
372380
deepCopy(PArray, 400.0);
373381
deepCopy(TestEos->SpecVol, 0.0);
374382

@@ -390,12 +398,46 @@ int testEosTeos10Clamping() {
390398
SpecVolH = createHostMirrorCopy(SpecVol);
391399
if (numMismatches != 0) {
392400
Err++;
393-
LOG_ERROR("EosTest: TEOS SpecVolClampingTemp isApprox FAIL, "
401+
LOG_ERROR("EosTest: TEOS SpecVolClampingTempHi isApprox FAIL, "
394402
"expected {}, got {} with {} mismatches",
395403
TeosClampValue3, SpecVolH(1, 1), numMismatches);
396404
}
397405
if (Err == 0) {
398-
LOG_INFO("EosTest SpecVolClampingTemp TEOS-10: PASS");
406+
LOG_INFO("EosTest SpecVolClampingTempHi TEOS-10: PASS");
407+
}
408+
409+
/// -------------------------------------
410+
/// Test with an ivalid low poly75t temperature value last
411+
/// -------------------------------------
412+
deepCopy(SArray, 35.0);
413+
deepCopy(TArray, -5.0); // Clamping happens at -2.2160968103069774
414+
deepCopy(PArray, 400.0);
415+
deepCopy(TestEos->SpecVol, 0.0);
416+
417+
/// Compute specific volume
418+
TestEos->computeSpecVol(TArray, SArray, PArray);
419+
420+
/// Check all array values against expected value
421+
numMismatches = 0;
422+
SpecVol = TestEos->SpecVol;
423+
parallelReduce(
424+
"CheckSpecVolMatrix-Teos", {Mesh->NCellsAll, NVertLevels},
425+
KOKKOS_LAMBDA(int i, int j, int &localCount) {
426+
if (!isApprox(SpecVol(i, j), TeosClampValue4, RTol)) {
427+
localCount++;
428+
}
429+
},
430+
numMismatches);
431+
432+
SpecVolH = createHostMirrorCopy(SpecVol);
433+
if (numMismatches != 0) {
434+
Err++;
435+
LOG_ERROR("EosTest: TEOS SpecVolClampingTempLo isApprox FAIL, "
436+
"expected {}, got {} with {} mismatches",
437+
TeosClampValue4, SpecVolH(1, 1), numMismatches);
438+
}
439+
if (Err == 0) {
440+
LOG_INFO("EosTest SpecVolClampingTempLo TEOS-10: PASS");
399441
}
400442

401443
return Err;

0 commit comments

Comments
 (0)