Skip to content

Refactor/vertical normal inputs - #128

Merged
JoshCederstrom merged 2 commits into
devfrom
refactor/vertical-normal-inputs
Aug 3, 2026
Merged

Refactor/vertical normal inputs#128
JoshCederstrom merged 2 commits into
devfrom
refactor/vertical-normal-inputs

Conversation

@JoshCederstrom

Copy link
Copy Markdown
Collaborator

This PR corrects the coordinate convention for depth inputs so that DEPTHTOBEDROCK, BEDROCKFILE, and GWATERFILE are 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)

  • Added tCNode::getCosSlope(), returning cos(atan(S)) for the node's flow edge, computed as 1/sqrt(1+S^2) to avoid two libm calls. Returns 1.0 when no flow edge is set and is floored at 1E-9.

Depth inputs (vertical → slope-normal at assignment)

  • Initial water table from GWATERFILE is multiplied by cn->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 to bedRock - 1, changing initial storage.
  • Depth to bedrock is multiplied by cn->getCosSlope() immediately after it is read, covering both the uniform DEPTHTOBEDROCK and the BEDROCKFILE grid. Applied before the initial Nwt clamp, setBedrockDepth(), the SoilCutoff / RootCutoff calculations, and the initial saturated storage, so all of them pick up the converted value.

Outputs

  • WriteIntegrVars() now divides getBedrockDepth() by the node's cos_slope for the Bedrock_Depth_mm column, so the value echoed back matches the vertical depth the user supplied rather than the internal slope-normal value.

@JoshCederstrom JoshCederstrom self-assigned this Aug 3, 2026
@JoshCederstrom
JoshCederstrom requested a review from a team as a code owner August 3, 2026 20:56
@JoshCederstrom JoshCederstrom added the enhancement New feature or request label Aug 3, 2026
@JoshCederstrom
JoshCederstrom merged commit 255e7d2 into dev Aug 3, 2026
3 checks passed
@JoshCederstrom
JoshCederstrom deleted the refactor/vertical-normal-inputs branch August 3, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant