From 587905aeb5272d94667692204bc11fe2cfe292d3 Mon Sep 17 00:00:00 2001 From: Dogukan Teber Date: Tue, 14 May 2024 14:00:47 -0400 Subject: [PATCH 1/2] Simplify ParentLayer.cpp and SnowLayer.cpp --- src/ParentLayer.cpp | 15 +++++---------- src/SnowLayer.cpp | 25 +++---------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/ParentLayer.cpp b/src/ParentLayer.cpp index 9b4621a13..c039bdada 100644 --- a/src/ParentLayer.cpp +++ b/src/ParentLayer.cpp @@ -29,30 +29,25 @@ void ParentLayer::updateProperty() { // get frozen layer specific heat capcity double ParentLayer::getFrzVolHeatCapa() { - double vhc = vhcsolid ; - return vhc; + return vhcsolid; }; double ParentLayer::getUnfVolHeatCapa() { - double vhc= vhcsolid ; - return vhc; + return vhcsolid; }; double ParentLayer::getMixVolHeatCapa() { - double vhc= vhcsolid ; - return vhc; + return vhcsolid; }; // get frozen layer thermal conductivity double ParentLayer::getFrzThermCond() { - double tc=tcsolid; - return tc; + return tcsolid; }; // get unfrozen layer thermal conductivity double ParentLayer::getUnfThermCond() { - double tc=tcsolid; - return tc; + return tcsolid; }; // get albedo of visible radiation diff --git a/src/SnowLayer.cpp b/src/SnowLayer.cpp index bdddc738f..7924634fe 100644 --- a/src/SnowLayer.cpp +++ b/src/SnowLayer.cpp @@ -102,34 +102,15 @@ double SnowLayer::getThermCond() { return tc; } -// FIX THIS: THESE 3 functions see to be identical??? double SnowLayer::getFrzVolHeatCapa() { - if (dz != 0) { - // FIX THIS: divide by zero error when there is no thickness! - double vhc = SHCICE * ice/dz; - return vhc; - } else { - return 0; - } + return (dz != 0) ? (SHCICE * ice/dz) : 0; }; double SnowLayer::getUnfVolHeatCapa() { - if (dz != 0) { - // FIX THIS: divide by zero error when there is no thickness! - double vhc = SHCICE * ice/dz; - return vhc; - } else { - return 0; - } + return (dz != 0) ? (SHCICE * ice/dz) : 0; }; double SnowLayer::getMixVolHeatCapa() { - if (dz != 0) { - // FIX THIS: divide by zero error when there is no thickness! - double vhc = SHCICE * ice/dz; - return vhc; - } else { - return 0; - } + return (dz != 0) ? (SHCICE * ice/dz) : 0; }; From c103890d5ac058a32327b120ac3fe9720749f284 Mon Sep 17 00:00:00 2001 From: Dogukan Teber Date: Tue, 21 May 2024 10:53:07 -0400 Subject: [PATCH 2/2] Add comments --- src/ParentLayer.cpp | 10 +++++++++- src/SnowLayer.cpp | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ParentLayer.cpp b/src/ParentLayer.cpp index c039bdada..3718f5f27 100644 --- a/src/ParentLayer.cpp +++ b/src/ParentLayer.cpp @@ -27,15 +27,23 @@ void ParentLayer::updateProperty() { vhcsolid = 2700000; }; -// get frozen layer specific heat capcity +// Note: Though the following functions return the same value, +// they require different names to work inside TemperatureUpdator.cpp +// where these will be called by name and not by layer type. +// Hence they must match with the functions used in Layer.cpp +// and SoilLayer.cpp. + +// get frozen layer volumetric heat capacity double ParentLayer::getFrzVolHeatCapa() { return vhcsolid; }; +// get unfrozen layer volumetric heat capacity double ParentLayer::getUnfVolHeatCapa() { return vhcsolid; }; +// get mixed (partially frozen) layer volumetric heat capacity double ParentLayer::getMixVolHeatCapa() { return vhcsolid; }; diff --git a/src/SnowLayer.cpp b/src/SnowLayer.cpp index 7924634fe..af1c84429 100644 --- a/src/SnowLayer.cpp +++ b/src/SnowLayer.cpp @@ -102,6 +102,12 @@ double SnowLayer::getThermCond() { return tc; } +// Note: Though the following functions return the same value, +// they require different names to work inside TemperatureUpdator.cpp +// where these will be called by name and not by layer type. +// Hence they must match with the functions used in Layer.cpp +// and SoilLayer.cpp. + double SnowLayer::getFrzVolHeatCapa() { return (dz != 0) ? (SHCICE * ice/dz) : 0; };