Vulcan
Aerospace Engineering Utilities Built on Janus
Loading...
Searching...
No Matches
WindShear.hpp
Go to the documentation of this file.
1// Wind Shear Profiles
2// Altitude-dependent wind profiles for boundary layer and low-level wind shear
3#pragma once
4
6
8
9// ============================================================================
10// Physical Constants
11// ============================================================================
12
14inline constexpr double VON_KARMAN_CONSTANT = 0.41;
15
16// ============================================================================
17// Linear Wind Shear
18// ============================================================================
19
32template <typename Scalar>
33Scalar linear(const Scalar &altitude, double base_wind, double base_altitude,
34 double shear_rate) {
35 return base_wind + shear_rate * (altitude - base_altitude);
36}
37
51template <typename Scalar>
53linear_vector(const Scalar &altitude, const wind::WindVector<double> &base_wind,
54 double base_altitude, double shear_rate) {
55 // Compute base wind speed (numeric)
56 double base_speed = std::sqrt(base_wind.north * base_wind.north +
57 base_wind.east * base_wind.east +
58 base_wind.down * base_wind.down);
59
60 // Avoid division by zero for calm conditions
61 if (base_speed < 1e-10) {
62 return wind::WindVector<Scalar>{.north = altitude * Scalar(0),
63 .east = altitude * Scalar(0),
64 .down = altitude * Scalar(0)};
65 }
66
67 // Scale factor based on altitude
68 Scalar new_speed = linear(altitude, base_speed, base_altitude, shear_rate);
69 Scalar scale = new_speed / base_speed;
70
71 return wind::WindVector<Scalar>{.north = scale * base_wind.north,
72 .east = scale * base_wind.east,
73 .down = scale * base_wind.down};
74}
75
76// ============================================================================
77// Power Law Wind Shear (Atmospheric Boundary Layer)
78// ============================================================================
79
97template <typename Scalar>
98Scalar power_law(const Scalar &altitude, double ref_wind,
99 double ref_altitude = 10.0, double exponent = 1.0 / 7.0) {
100 // V = V_ref * (h / h_ref)^alpha
101 // Use janus::pow for symbolic compatibility
102 return ref_wind * janus::pow(altitude / ref_altitude, exponent);
103}
104
115template <typename Scalar>
117power_law_vector(const Scalar &altitude,
118 const wind::WindVector<double> &base_wind,
119 double ref_altitude = 10.0, double exponent = 1.0 / 7.0) {
120 // Compute base wind speed (numeric)
121 double base_speed = std::sqrt(base_wind.north * base_wind.north +
122 base_wind.east * base_wind.east +
123 base_wind.down * base_wind.down);
124
125 if (base_speed < 1e-10) {
126 return wind::WindVector<Scalar>{.north = altitude * Scalar(0),
127 .east = altitude * Scalar(0),
128 .down = altitude * Scalar(0)};
129 }
130
131 // Scale factor from power law
132 Scalar scale = janus::pow(altitude / ref_altitude, exponent);
133
134 return wind::WindVector<Scalar>{.north = scale * base_wind.north,
135 .east = scale * base_wind.east,
136 .down = scale * base_wind.down};
137}
138
139// ============================================================================
140// Logarithmic Wind Profile
141// ============================================================================
142
161template <typename Scalar>
162Scalar logarithmic(const Scalar &altitude, double friction_velocity,
163 double roughness_length, double displacement = 0.0) {
164 // V = (u* / κ) * ln((h - d) / z_0)
165 Scalar effective_height = altitude - displacement;
166 return (friction_velocity / VON_KARMAN_CONSTANT) *
167 janus::log(effective_height / roughness_length);
168}
169
184inline double friction_velocity_from_ref(double ref_wind, double ref_altitude,
185 double roughness_length,
186 double displacement = 0.0) {
187 double effective_height = ref_altitude - displacement;
188 return VON_KARMAN_CONSTANT * ref_wind /
189 std::log(effective_height / roughness_length);
190}
191
192// ============================================================================
193// Common Roughness Lengths
194// ============================================================================
195
196namespace roughness {
197inline constexpr double OPEN_WATER = 0.0002; // [m]
198inline constexpr double OPEN_TERRAIN = 0.03; // [m] - grass, few trees
199inline constexpr double RURAL = 0.1; // [m] - scattered buildings
200inline constexpr double SUBURBAN = 0.5; // [m] - low-rise urban
201inline constexpr double URBAN = 1.0; // [m] - city center
202} // namespace roughness
203
204// ============================================================================
205// Common Power Law Exponents
206// ============================================================================
207
208namespace exponent {
209inline constexpr double UNSTABLE =
210 1.0 / 7.0; // ~0.143 - daytime, strong heating
211inline constexpr double NEUTRAL = 1.0 / 4.0; // 0.25 - overcast, moderate wind
212inline constexpr double STABLE = 1.0 / 3.0; // ~0.333 - nighttime, light wind
213} // namespace exponent
214
215} // namespace vulcan::wind_shear
Definition WindShear.hpp:208
constexpr double STABLE
Definition WindShear.hpp:212
constexpr double NEUTRAL
Definition WindShear.hpp:211
constexpr double UNSTABLE
Definition WindShear.hpp:209
Definition WindShear.hpp:196
constexpr double RURAL
Definition WindShear.hpp:199
constexpr double SUBURBAN
Definition WindShear.hpp:200
constexpr double OPEN_TERRAIN
Definition WindShear.hpp:198
constexpr double URBAN
Definition WindShear.hpp:201
constexpr double OPEN_WATER
Definition WindShear.hpp:197
Definition WindShear.hpp:7
Scalar logarithmic(const Scalar &altitude, double friction_velocity, double roughness_length, double displacement=0.0)
Logarithmic wind profile (neutral atmospheric boundary layer).
Definition WindShear.hpp:162
Scalar linear(const Scalar &altitude, double base_wind, double base_altitude, double shear_rate)
Linear wind shear profile.
Definition WindShear.hpp:33
constexpr double VON_KARMAN_CONSTANT
von Kármán constant for atmospheric boundary layer
Definition WindShear.hpp:14
wind::WindVector< Scalar > linear_vector(const Scalar &altitude, const wind::WindVector< double > &base_wind, double base_altitude, double shear_rate)
Linear wind shear returning full wind vector.
Definition WindShear.hpp:53
wind::WindVector< Scalar > power_law_vector(const Scalar &altitude, const wind::WindVector< double > &base_wind, double ref_altitude=10.0, double exponent=1.0/7.0)
Power-law wind profile returning full wind vector.
Definition WindShear.hpp:117
Scalar power_law(const Scalar &altitude, double ref_wind, double ref_altitude=10.0, double exponent=1.0/7.0)
Power-law wind profile (typical for atmospheric boundary layer).
Definition WindShear.hpp:98
double friction_velocity_from_ref(double ref_wind, double ref_altitude, double roughness_length, double displacement=0.0)
Compute friction velocity from reference wind.
Definition WindShear.hpp:184
3D wind velocity in NED frame
Definition WindTypes.hpp:21
Scalar north
North component [m/s].
Definition WindTypes.hpp:22
Scalar east
East component [m/s].
Definition WindTypes.hpp:23
Scalar down
Down component [m/s].
Definition WindTypes.hpp:24