Class: SmoFlow::RationalMethod
- Inherits:
-
Object
- Object
- SmoFlow::RationalMethod
- Defined in:
- lib/smo_flow/rational_method.rb
Overview
Calculates surface runoff flow using the Rational Method. Supports flow from rainfall intensity, rainfall depth, and timestep-based calculations.
Instance Attribute Summary collapse
-
#area ⇒ Object
readonly
Returns the value of attribute area.
-
#coefficient ⇒ Object
readonly
Returns the value of attribute coefficient.
Instance Method Summary collapse
-
#depth_to_intensity(depth:, timestep:) ⇒ Object
Convert depth (mm) over a timestep (s) to intensity (mm/hr).
-
#flow_from_depth(depth:, timestep:) ⇒ Object
Q = 10 × C × A × d / Δt → returns m³/s.
-
#flow_from_intensity(intensity) ⇒ Object
Q = C × i × A / 360 → returns m³/s.
-
#flow_ls_from_intensity(intensity) ⇒ Object
Flow in L/s from intensity.
-
#initialize(coefficient:, area:) ⇒ RationalMethod
constructor
A new instance of RationalMethod.
-
#volume(depth:) ⇒ Object
Runoff volume for a timestep in m³.
Constructor Details
#initialize(coefficient:, area:) ⇒ RationalMethod
Returns a new instance of RationalMethod.
9 10 11 12 13 |
# File 'lib/smo_flow/rational_method.rb', line 9 def initialize(coefficient:, area:) validate!(coefficient, area) @coefficient = coefficient # C — runoff coefficient (0..1) @area = area # A — catchment area in hectares end |
Instance Attribute Details
#area ⇒ Object (readonly)
Returns the value of attribute area.
7 8 9 |
# File 'lib/smo_flow/rational_method.rb', line 7 def area @area end |
#coefficient ⇒ Object (readonly)
Returns the value of attribute coefficient.
7 8 9 |
# File 'lib/smo_flow/rational_method.rb', line 7 def coefficient @coefficient end |
Instance Method Details
#depth_to_intensity(depth:, timestep:) ⇒ Object
Convert depth (mm) over a timestep (s) to intensity (mm/hr)
31 32 33 34 35 36 |
# File 'lib/smo_flow/rational_method.rb', line 31 def depth_to_intensity(depth:, timestep:) raise InvalidInput, "Depth must be positive" unless depth.positive? raise InvalidInput, "Timestep must be positive" unless timestep.positive? (depth / timestep) * 3600.0 end |
#flow_from_depth(depth:, timestep:) ⇒ Object
Q = 10 × C × A × d / Δt → returns m³/s
23 24 25 26 27 28 |
# File 'lib/smo_flow/rational_method.rb', line 23 def flow_from_depth(depth:, timestep:) raise InvalidInput, "Depth must be positive" unless depth.positive? raise InvalidInput, "Timestep must be positive" unless timestep.positive? (10.0 * coefficient * area * depth) / timestep end |
#flow_from_intensity(intensity) ⇒ Object
Q = C × i × A / 360 → returns m³/s
16 17 18 19 20 |
# File 'lib/smo_flow/rational_method.rb', line 16 def flow_from_intensity(intensity) raise InvalidInput, "Intensity must be positive" unless intensity.positive? (coefficient * intensity * area) / 360.0 end |
#flow_ls_from_intensity(intensity) ⇒ Object
Flow in L/s from intensity
46 47 48 |
# File 'lib/smo_flow/rational_method.rb', line 46 def flow_ls_from_intensity(intensity) flow_from_intensity(intensity) * 1000.0 end |
#volume(depth:) ⇒ Object
Runoff volume for a timestep in m³
39 40 41 42 43 |
# File 'lib/smo_flow/rational_method.rb', line 39 def volume(depth:) raise InvalidInput, "Depth must be positive" unless depth.positive? 10.0 * coefficient * area * depth end |