OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
Radiation.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
40
41#ifndef OPENSWMM_ENGINE_HYDROLOGY_RADIATION_HPP
42#define OPENSWMM_ENGINE_HYDROLOGY_RADIATION_HPP
43#include <string>
44#include "surface/UebSnow.hpp"
45
46namespace openswmm {
48struct SolarConfig;
49struct CloudConfig;
50}
51
52namespace openswmm::climate {
53
56 double shortwave = 0, longwave = 0; // W/m², horizontal
57 double cosine = 0, horizontal = 0, transmittance = 0, cloud = 0;
58 double temperature = 0, humidity = .5, wind = 0; // °C, fraction, m/s
59 double pressure = 101325;
60 double declination = 0, hour_angle = 0, latitude = 0;
61 double date = 0, seconds = 0;
64 bool shared_heat_forcing = false;
65};
66
84std::string resolveRadiation(SimulationContext& ctx, double date, double seconds,
85 RadiationState& output);
114std::string resolveUebForcing(SimulationContext& ctx, double date, double seconds, double slope,
115 double aspect, surface::ueb::Forcing& forcing, double& pressure);
116
118inline constexpr double kSolarConstant = 1367.0;
119
121inline constexpr double kStdPressureMb = 1013.25;
122
132 double declination_deg = 0.0;
133 double eq_time_min = 0.0;
134 double hour_angle_deg = 0.0;
135 double zenith_deg = 90.0;
136 double cos_zenith = 0.0;
137 double elevation_deg = 0.0;
139 double eccentricity = 1.0;
140};
141
152SolarPosition solarPosition(int day_of_year, double hour_local, double lat_deg, double lon_deg,
153 double tz_hours) noexcept;
154
159double airMass(double zenith_deg) noexcept;
160
165double pressureFromElevation(double elevation_m) noexcept;
166
176double birdClearSkyGHI(const SolarPosition& pos, double pressure_mb,
177 const SolarConfig& cfg) noexcept;
178
186double cloudShortwaveFactor(double cloud_fraction, double k, double n) noexcept;
187
194double cloudLongwaveFactor(double cloud_fraction, double k_lw) noexcept;
195
203void updateSolarForcing(SimulationContext& ctx, double seconds = 1);
217void updateSolarForcing(SimulationContext& ctx, double seconds, bool mesh_enabled);
218
219} // namespace openswmm::climate
220
221#endif // OPENSWMM_ENGINE_HYDROLOGY_RADIATION_HPP
Utah Energy Balance snow accumulation and energy integration.
Definition Rk2RuntimeSources.hpp:19
std::string resolveUebForcing(SimulationContext &ctx, double date, double seconds, double slope, double aspect, surface::ueb::Forcing &forcing, double &pressure)
Merge resolved interval weather and slope-adjusted radiation into a UEB forcing.
Definition UebForcing.cpp:437
double cloudShortwaveFactor(double cloud_fraction, double k, double n) noexcept
Compute the cloud attenuation multiplier max(0,1-k*C^n).
Definition Radiation.cpp:206
std::string initializeRadiation(SimulationContext &ctx)
Validate snow parameters and prepare site and weather input caches.
Definition UebForcing.cpp:156
void updateSolarForcing(SimulationContext &ctx, double seconds)
Update shared heat shortwave/cloud forcing with mesh radiation disabled.
Definition Radiation.cpp:230
double airMass(double zenith_deg) noexcept
Compute Kasten-Young relative optical air mass.
Definition Radiation.cpp:122
double pressureFromElevation(double elevation_m) noexcept
Estimate standard-atmosphere station pressure from elevation.
Definition Radiation.cpp:135
std::string resolveRadiation(SimulationContext &ctx, double date, double seconds, RadiationState &output)
Resolve mean weather/radiation for one interval without advancing climate time.
Definition UebForcing.cpp:254
double birdClearSkyGHI(const SolarPosition &pos, double pressure_mb, const SolarConfig &cfg) noexcept
Estimate clear-sky global horizontal irradiance with Bird-Hulstrom terms.
Definition Radiation.cpp:140
SolarPosition solarPosition(int day_of_year, double hour_local, double lat_deg, double lon_deg, double tz_hours) noexcept
Compute Spencer/NOAA sun geometry at a local civil-clock instant.
Definition Radiation.cpp:57
RadiationOrigin
Definition Radiation.hpp:54
@ MetFile
Definition Radiation.hpp:54
@ Computed
Definition Radiation.hpp:54
@ Timeseries
Definition Radiation.hpp:54
@ LegacyHeat
Definition Radiation.hpp:54
constexpr double kStdPressureMb
Sea-level standard pressure, millibars — Bird's pressure reference.
Definition Radiation.hpp:121
double cloudLongwaveFactor(double cloud_fraction, double k_lw) noexcept
Compute the cloud atmospheric-emissivity multiplier 1+k_lw*C^2.
Definition Radiation.cpp:215
constexpr double kSolarConstant
Solar constant, W/m² (Bird & Hulstrom 1981; WMO 1982).
Definition Radiation.hpp:118
Definition ExchangeLaw.hpp:60
[CLOUD_COVER] — one fraction driving two modules (H6a, D-H6a-2).
Definition HeatData.hpp:217
Central, reentrant simulation context.
Definition SimulationContext.hpp:390
[SOLAR_RADIATION] — site geometry and Bird atmosphere (H6a).
Definition HeatData.hpp:168
Definition Radiation.hpp:55
RadiationOrigin longwave_source
Definition Radiation.hpp:63
bool shared_heat_forcing
Definition Radiation.hpp:64
double humidity
Definition Radiation.hpp:58
double latitude
Definition Radiation.hpp:60
double hour_angle
Definition Radiation.hpp:60
double horizontal
Definition Radiation.hpp:57
RadiationOrigin shortwave_source
Definition Radiation.hpp:62
double cloud
Definition Radiation.hpp:57
double date
Definition Radiation.hpp:61
double seconds
Definition Radiation.hpp:61
double transmittance
Definition Radiation.hpp:57
double shortwave
Definition Radiation.hpp:56
double wind
Definition Radiation.hpp:58
double pressure
Definition Radiation.hpp:59
double declination
Definition Radiation.hpp:60
double temperature
Definition Radiation.hpp:58
double longwave
Definition Radiation.hpp:56
double cosine
Definition Radiation.hpp:57
Sun geometry at one instant. The SPA swap point's return type.
Definition Radiation.hpp:131
double declination_deg
Solar declination, +N.
Definition Radiation.hpp:132
double eq_time_min
Equation of time, minutes.
Definition Radiation.hpp:133
double elevation_deg
Definition Radiation.hpp:137
double zenith_deg
Solar zenith angle.
Definition Radiation.hpp:135
double cos_zenith
Clamped at 0 below the horizon.
Definition Radiation.hpp:136
double hour_angle_deg
Solar hour angle, 0 at solar noon.
Definition Radiation.hpp:134
double eccentricity
Earth–sun distance correction E0 = (r0/r)², dimensionless.
Definition Radiation.hpp:139
Held point meteorology over one requested interval. seconds is duration, precipitation integrated liq...
Definition UebSnow.hpp:56