diff --git a/classes/components/WindCustom.m b/classes/components/WindCustom.m index 99d26ba500d01891a7ca153c383c10281282ed64..3343cf180feae522512a0f83a5a26d9ab6e36e4b 100644 --- a/classes/components/WindCustom.m +++ b/classes/components/WindCustom.m @@ -16,12 +16,16 @@ classdef WindCustom < Component {mustBeMember(magnitudeDistribution, {'u', 'g'})} = 'u' % [-] Magnitude distrubution: uniform, gaussian azimuthDistribution (1, :) ... {mustBeMember(azimuthDistribution, {'u', 'g'})} = 'u' % [-] Azimuth distrubution: uniform, gaussian + elevationDistribution (1, :) ... + {mustBeMember(elevationDistribution, {'u', 'g'})} = 'u' % [-] Elevation distrubution: uniform, gaussian magnitudeParameters (2, :) % [m/s] Distribution parameters: [min; max], [mu; sigma] azimuthParameters (2, :) % [deg] Distribution parameters: [min; max], [mu; sigma] + elevationParameters (2, :) % [deg] Distribution parameters: [min; max], [mu; sigma] end properties(SetAccess = private) azimuth + elevation magnitude end @@ -44,25 +48,30 @@ classdef WindCustom < Component function [uw, vw, ww] = getVels(obj, z) s = length(obj.altitudes); % reference vectors length if s==1 - uw = round( - obj.magnitude * cos(obj.azimuth), 6); - vw = round( - obj.magnitude * sin(obj.azimuth), 6); - ww = 0; + uw = round( - obj.magnitude * cos(obj.azimuth) * cos(obj.elevation), 6); + vw = round( - obj.magnitude * sin(obj.azimuth) * cos(obj.elevation), 6); + ww = round( - obj.magnitude * (-sin(obj.elevation)), 6); else mag = interpLinear(obj.altitudes, obj.magnitude, z, true); az = interpLinear(obj.altitudes, obj.azimuth, z, true); + el = interpLinear(obj.altitudes, obj.elevation, z, true); - uw = round( - mag * cos(az), 6); - vw = round( - mag * sin(az), 6); - ww = 0; + uw = round( - mag * cos(az) * cos(el), 6); + vw = round( - mag * sin(az) * cos(el), 6); + ww = round( - mag * (-sin(el)), 6); end end function updateAll(obj) + obj.checkElevation(); + s = length(obj.altitudes); magVector = nan(1,s); azVector = nan(1,s); + elVector = nan(1,s); isUniformMag = strcmp(obj.magnitudeDistribution, "u"); isUniformAz = strcmp(obj.azimuthDistribution, "u"); + isUniformEl = strcmp(obj.elevationDistribution, "u"); uniformDist = @(val1, val2) rand(1)*(val2 - val1) + val1; gaussianDist = @(mean, sigma) normrnd(mean, sigma, 1); @@ -83,10 +92,28 @@ classdef WindCustom < Component azVector(i) = gaussianDist(obj.azimuthParameters(1,i), ... obj.azimuthParameters(2,i)); end + + if isUniformEl(i) + elVector(i) = uniformDist(obj.elevationParameters(1,i), ... + obj.elevationParameters(2,i)); + else + elVector(i) = gaussianDist(obj.elevationParameters(1,i), ... + obj.elevationParameters(2,i)); + end end obj.magnitude = magVector; obj.azimuth = azVector; + obj.elevation = elVector; + end + + function checkElevation(obj) + if any(size(obj.elevationDistribution) ~= size(obj.azimuthDistribution)) + obj.elevationDistribution = repmat("u", size(obj.azimuthDistribution)); + end + if isempty(obj.elevationParameters) + obj.elevationParameters = zeros(size(obj.azimuthParameters)); + end end end end