4.3. ORGANIZACIÓN
4.3.2. funciones y perfiles de puesto
The snippet of code below shows the average velocity calculation between each instantaneous velocity point and the filter for erroneous answers. Since the burn profile was flipped such that the array starts off at the highest instantaneous velocity, subtracting the burn position from the interpolated coast position row by row gives the displacement between equal velocity values starting at the maximum speed. Once the time spent has been found using the same principle, the average velocity between the two points can be found.
% Calculate average velocity between equal velocity points
data(:,1) = Interpol_coast(:,2)-BURN(:,2); % Distance Traveled [m]
data(:,2) = Interpol_coast(:,3)-BURN(:,3); % Time Spent [s]
data(:,3) = 2.23694.*data(:,1)./data(:,2); % Average Velocity [MPH] % Use while loop since # bad answers unknown
while true
avg_max = max(data(:,3)); % find maximum average velocity
m_idx = find(data(:,3) == avg_max); % index value of V_max_avg
% Account for bad answers due to polynomial interpolation
if data(m_idx,1) < 0 && data(m_idx,2) < 0
data(m_idx,:) = 0; % set row of bad answers to zero
else break end
end
Naturally, the average velocity is greater towards the top of the data array where the instantaneous velocity values are greater and gradually decreases as the velocity values approach zero. However, because the first few burn velocity values used in curve fitting the coast profile exist outside of the original coast profile, the calculated position or time can be less than that of their burn profile counterpart for some input combinations. This occasional mathematical error is further exacerbated by the limitations of the polynomial curve fitting (poor regression at the extremities) and when present, results in negative average speeds at the start of the data array as shown in Figure 52. This behavior is generally associated with “bad” or realistically infeasible input values.
- 63 -
For the error case shown in Figure 52, the find function used to index when the vehicle average speed dips below 15-mph would be triggered and report the wrong speed requirement index (SRI). This issue was initially resolved by taking advantage of the consistently decreasing trend after the maximum average speed. As shown in the seventh line of the section below, the program is set to artificially limit the search region to the rows following (below) the maximum average speed index, m_idx. On very rare occasions, however, both the displacement and time spent values can be negative and lead to a positive maximum, triggering the same issue with the find function. Hence, the while loop was added in the first section to set the bad data to zero as many times as needed before assigning m_idx to represent the position of the most positive average speed value found by the max function.
if avg_max < 15.000 % B&C cycle not capable of 15.0 MPH V_avg
flag(j,i,k) = 3; % set flag
MPG(j,i,k) = 0; % set MPG to zero
elseif avg_max >= 15.000 % B&C cycle capable of 15.0 MPH V_avg
% From top, find first 2 instances when V_avg is less than 15.0 MPH
% speed requirement index (SRI)
speed_req = find(data(m_idx:end,3)<15.000,2,'first') + m_idx - 2; TF = isempty(speed_req); % check to see if index array exists
if TF == 1 % V_avg < 15.0 regardless of V_min
speed_req = length(data); % set SRI (V_min = 0)
flag(j,i,k) = 1; % set flag
elseif TF == 0 % V_avg = 15.0 and V_min > 0
[r,~] = size(speed_req); % determine size of index array
if r == 1 % V_min very close to zero.
speed_req = speed_req(1);
else % account for irregularities
if speed_req(2)-speed_req(1) == 1 speed_req = speed_req(1); else speed_req = speed_req(2); end end
flag(j,i,k) = 2; % set flag
end end
If the maximum average speed of the cycle is less than 15-mph, the combination of parameters simply fails to meet the design criteria. Hence, the MPG is set to zero with the corresponding flag being raised. Otherwise, the program runs through the designated search area in the data array to determine the SRI: the first two instances at which the average speed dips below 15-mph. If the SRI does not exist, it indicates that the lowest possible average speed of the burn and coast cycle exceeds 15-mph. The program then sets Vmin = 0 mph and raises the corresponding flag. Further investigation is required to determine whether aiming for the average speed closest to 15-mph is the best strategy when it comes to this scenario. The SIMs’ current thought process is that with Vmin = 0 mph, the vehicle can utilize the coasting cycle to its fullest and decrease the overall burn time required to complete the race. Furthermore, it would make sense that maintaining a lower average kinetic energy corresponds to a lower fuel requirement.
If the SRI does exist, but there is only a single instance at which the average speed dips below 15-mph (when r = 1), then Vmin is either practically zero under flat track conditions or other irregularities caused by the track profile have influenced the result. If the SRI does exist and there are two instances which are consecutive (when speed_req(2) - speed_req(1) = 1), then the higher value is used as the reference index. In the rare case when the two instances are not consecutive despite being in the search area below the maximum possible average speed, the lower of the two values is used as the final speed requirement for the same reason of utilizing the coast cycle to the fullest.
- 64 -