Refactor/vertical normal inputs - #128
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR corrects the coordinate convention for depth inputs so that
DEPTHTOBEDROCK,BEDROCKFILE, andGWATERFILEare interpreted as vertical depths rather than slope-normal depths. Previously the outputs could report a depth to water table deeper than the specified depth to bedrock, e.g. a run with a constant 3 m bedrock depth ending with polygons reporting a water table below 3 m.Technical Changes (C++ / Inputs)
Slope conversion factor (
tCNode)tCNode::getCosSlope(), returningcos(atan(S))for the node's flow edge, computed as1/sqrt(1+S^2)to avoid two libm calls. Returns1.0when no flow edge is set and is floored at1E-9.Depth inputs (vertical → slope-normal at assignment)
GWATERFILEis multiplied bycn->getCosSlope()in the water table assignment loop. This covers both the gridded and Voronoi-file options, which share the assignment. Without it, an initial water table near bedrock on a steep node would fall below the converted bedrock depth and be silently clamped tobedRock - 1, changing initial storage.cn->getCosSlope()immediately after it is read, covering both the uniformDEPTHTOBEDROCKand theBEDROCKFILEgrid. Applied before the initialNwtclamp,setBedrockDepth(), theSoilCutoff/RootCutoffcalculations, and the initial saturated storage, so all of them pick up the converted value.Outputs
WriteIntegrVars()now dividesgetBedrockDepth()by the node'scos_slopefor theBedrock_Depth_mmcolumn, so the value echoed back matches the vertical depth the user supplied rather than the internal slope-normal value.