Rename 'data points' to 'support points'

master
Max Kannenberg 2022-06-22 11:11:44 +02:00
parent ef4d4bcae2
commit 892b84251a
5 changed files with 107 additions and 107 deletions

View File

@ -4,8 +4,8 @@
# __copyright__ = "2020-2022"
# __license__ = "ISC"
## This function calculates the data points of the breakFree section.
# Therefore it gets its first data point and the characteristic section and returns the characteristic section including the behavior section for breakFree if needed.
## This function calculates the support points of the breakFree section.
# Therefore it gets its first support point and the characteristic section and returns the characteristic section including the behavior section for breakFree if needed.
# Info: currently the values of the breakFree section will be calculated like in the accelerating section
function addBreakFreeSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::Dict, settings::Settings, train::Train, CSs::Vector{Dict})
# conditions for the break free section
@ -26,15 +26,15 @@ function addBreakFreeSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags:
rethrow(acceleratingError)
end
# delete every dataPoint except the first two
while drivingCourse[end][:i] > drivingCourse[BS[:dataPoints][1]][:i] +1
# delete every supportPoint except the first two
while drivingCourse[end][:i] > drivingCourse[BS[:supportPoints][1]][:i] +1
pop!(drivingCourse)
end
# change the accelerating data to break free
drivingCourse[end-1][:behavior] = BS[:type]
drivingCourse[end][:behavior] = BS[:type]
push!(BS[:dataPoints], drivingCourse[end][:i])
push!(BS[:supportPoints], drivingCourse[end][:i])
# remove the accelerating section from the CS
CS[:t] = CS[:t] - get(CS[:behaviorSections], :accelerating, Dict(:t=>0.0))[:t] # total running time (in s)
@ -43,7 +43,7 @@ function addBreakFreeSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags:
# calculate the accumulated breakFree section information
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
:s_exit => drivingCourse[end][:s], # last position (in m)
:t => drivingCourse[end][:t] - drivingCourse[BS[:dataPoints][1]][:t], # total running time (in s)
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
@ -71,7 +71,7 @@ function addBreakFreeSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags:
return (CS, drivingCourse, stateFlags)
end #function addBreakFreeSection!
## This function calculates the data points of the clearing section.
## This function calculates the support points of the clearing section.
# Therefore it gets its previous driving course and the characteristic section and returns the characteristic section and driving course including the clearing section.
function addClearingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::Dict, settings::Settings, train::Train, CSs::Vector{Dict})
if stateFlags[:previousSpeedLimitReached]
@ -104,7 +104,7 @@ function addClearingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
return (CS, drivingCourse, stateFlags)
end #function addClearingSection
## This function calculates the data points of the accelerating section.
## This function calculates the support points of the accelerating section.
# Therefore it gets its previous driving course and the characteristic section and returns the characteristic section and driving course including the accelerating section
function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::Dict, settings::Settings, train::Train, CSs::Vector{Dict})
#function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, settings::Settings, train::Train, CSs::Vector{Dict}, ignoreBraking::Bool)
@ -153,17 +153,17 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
while !targetSpeedReached && !speedLimitReached && !brakingStartReached && !pointOfInterestReached && tractionSurplus && !previousSpeedLimitReached
# 03/08 old: while drivingCourse[end][:v] < CS[:v_peak] && drivingCourse[end][:v] <= currentSpeedLimit[:v] && !brakingStartReached && drivingCourse[end][:s] < nextPointOfInterest[1] && drivingCourse[end][:F_T] > drivingCourse[end][:F_R] # as long as s_i + s_braking < s_CSexit
if drivingCourse[end][:s] >= currentSpeedLimit[:s_end]
# could be asked after creating an data point. This way here prevents even a minimal exceedance of speed limit will be noticed. On the other hand the train cruises possibly a little to long
# could be asked after creating an support point. This way here prevents even a minimal exceedance of speed limit will be noticed. On the other hand the train cruises possibly a little to long
currentSpeedLimit = getCurrentSpeedLimit(CSs, CS[:id], drivingCourse[end][:s], train.length)
end
# acceleration (in m/s^2):
drivingCourse[end][:a] = acceleration(drivingCourse[end][:F_T], drivingCourse[end][:F_R], train.m_train_full, train.ξ_train)
# create the next data point
# create the next support point
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
drivingCourse[end][:behavior] = BS[:type]
push!(BS[:dataPoints], drivingCourse[end][:i])
push!(BS[:supportPoints], drivingCourse[end][:i])
calculateForces!(drivingCourse[end], CSs, CS[:id], BS[:type], train, settings.massModel)
@ -250,9 +250,9 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
error("ERROR at accelerating section: With the step variable ",settings.stepVariable," the while loop will be left although v<v_peak and s<s_exit in CS",CS[:id]," with s=" ,drivingCourse[end][:s]," m and v=",drivingCourse[end][:v]," m/s")
end
# delete last data point for recalculating the last step with reduced step size
# delete last support point for recalculating the last step with reduced step size
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
# conditions for the next for cycle
brakingStartReached = false
@ -267,7 +267,7 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
if drivingCourse[end][:v] > CS[:v_peak]
testFlag && println("in CS",CS[:id]," accelerating cycle",cycle," case: v=", drivingCourse[end][:v]," > v_peak=",CS[:v_peak]) # for testing
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
# conditions for the next section
brakingStartReached = false
@ -276,7 +276,7 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
testFlag && println("in CS",CS[:id]," accelerating cycle",cycle," case: s +s_braking=", drivingCourse[end][:s],",+",s_braking," = ",drivingCourse[end][:s] +s_braking," > s_exit=",CS[:s_exit]) # for testing
if s_braking > 0.0
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
else
drivingCourse[end][:s] = CS[:s_exit] # round s down to CS[:s_exit]
@ -296,7 +296,7 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
previousSpeedLimitReached = true
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
else
if drivingCourse[end][:s] + s_braking == CS[:s_exit]
@ -324,14 +324,14 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
end #while
if length(BS[:dataPoints]) > 1
if length(BS[:supportPoints]) > 1
# calculate the accumulated accelerating section information
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
:s_exit => drivingCourse[end][:s], # last position (in m)
:t => drivingCourse[end][:t] - drivingCourse[BS[:dataPoints][1]][:t], # total running time (in s)
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
# 03/10 old: CS[:v_peak] = max(drivingCourse[end][:v], CS[:v_entry]) # setting v_peak to the last data points velocity which is the highest reachable value in this characteristic section or to v_entry in case it is higher when running on a path with high resistances
# 03/10 old: CS[:v_peak] = max(drivingCourse[end][:v], CS[:v_entry]) # setting v_peak to the last support points velocity which is the highest reachable value in this characteristic section or to v_entry in case it is higher when running on a path with high resistances
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
mergeBehaviorSection!(CS[:behaviorSections], BS)
@ -351,8 +351,8 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
end #function addAcceleratingSection!
## This function calculates the data points of the cruising section.
# Therefore it gets its first data point and the characteristic section and returns the characteristic section including the behavior section for cruising if needed.
## This function calculates the support points of the cruising section.
# Therefore it gets its first support point and the characteristic section and returns the characteristic section including the behavior section for cruising if needed.
function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::Dict, s_cruising::Real, settings::Settings, train::Train, CSs::Vector{Dict}, cruisingType::String)
trainIsClearing = cruisingType == "clearing"
trainIsBrakingDownhill = cruisingType == "downhillBraking"
@ -427,14 +427,14 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
# acceleration (in m/s^2):
drivingCourse[end][:a] = 0.0
# create the next data point
# create the next support point
if settings.stepVariable == :distance || settings.stepVariable == time
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
else
push!(drivingCourse, moveAStep(drivingCourse[end], position, train.length/(10.0^cycle), CS[:id])) # TODO which step size should be used?
end
drivingCourse[end][:behavior] = BS[:type]
push!(BS[:dataPoints], drivingCourse[end][:i])
push!(BS[:supportPoints], drivingCourse[end][:i])
# traction effort and resisting forces (in N)
calculateForces!(drivingCourse[end], CSs, CS[:id], "default", train, settings.massModel)
@ -494,9 +494,9 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
error("ERROR at cruising section: With the step variable ",settings.stepVariable," the while loop will be left although the if cases don't apply in CS",CS[:id]," with s=" ,drivingCourse[end][:s]," m and v=",drivingCourse[end][:v]," m/s")
end
# delete last data point for recalculating the last step with reduced step size
# delete last support point for recalculating the last step with reduced step size
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
# conditions for the next for cycle
pointOfInterestReached = false
@ -512,7 +512,7 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
elseif drivingCourse[end][:s] > BS[:s_entry]+s_cruising
if BS[:type] != "clearing"
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
end
elseif drivingCourse[end][:s] == BS[:s_entry]+s_cruising
break
@ -566,13 +566,13 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
#s_cruisingRemaining=BS[:s_entry] + s_cruising-drivingCourse[end][:s]
s_cruisingRemaining = min(nextPointOfInterest[1] -drivingCourse[end][:s], BS[:s_entry] +s_cruising -drivingCourse[end][:s])
# create the next data point
# create the next support point
push!(drivingCourse, moveAStep(drivingCourse[end], :distance, s_cruisingRemaining, CS[:id]))
drivingCourse[end][:behavior] = BS[:type]
if drivingCourse[end][:s] == nextPointOfInterest[1]
drivingCourse[end][:label] = nextPointOfInterest[2]
end
push!(BS[:dataPoints], drivingCourse[end][:i])
push!(BS[:supportPoints], drivingCourse[end][:i])
calculateForces!(drivingCourse[end], CSs, CS[:id], "default", train, settings.massModel)
# calculateForces!(drivingCourse[end], CSs, CS[:id], "cruising", train, settings.massModel)
@ -594,7 +594,7 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
# calculate the accumulated cruising section information
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
:s_exit => drivingCourse[end][:s], # last position (in m)
:t => drivingCourse[end][:t] - drivingCourse[BS[:dataPoints][1]][:t], # total running time (in s)
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
@ -618,7 +618,7 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
end #function addCruisingSection!
## This function calculates the data points for diminishing run when using maximum tractive effort and still getting slower
## This function calculates the support points for diminishing run when using maximum tractive effort and still getting slower
function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::Dict, settings::Settings, train::Train, CSs::Vector{Dict})
calculateForces!(drivingCourse[end], CSs, CS[:id], "diminishing", train, settings.massModel)
@ -653,10 +653,10 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
# acceleration (in m/s^2):
drivingCourse[end][:a] = acceleration(drivingCourse[end][:F_T], drivingCourse[end][:F_R], train.m_train_full, train.ξ_train)
# create the next data point
# create the next support point
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
drivingCourse[end][:behavior] = BS[:type]
push!(BS[:dataPoints], drivingCourse[end][:i])
push!(BS[:supportPoints], drivingCourse[end][:i])
calculateForces!(drivingCourse[end], CSs, CS[:id], BS[:type], train, settings.massModel)
@ -721,9 +721,9 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
else
error("ERROR during diminishing run: With the step variable ",settings.stepVariable," the while loop will be left although s+s_braking<s_exit && v>0.0 in CS",CS[:id]," with s=" ,drivingCourse[end][:s]," m and v=",drivingCourse[end][:v]," m/s")
end
# delete last data point for recalculating the last step with reduced step size
# delete last support point for recalculating the last step with reduced step size
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
# conditions for the next for cycle
brakingStartReached = false
@ -735,7 +735,7 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
else # if the level of approximation is reached
if drivingCourse[end][:v] <= 0.0
testFlag && println("in CS",CS[:id]," diminishing cycle",cycle," case: v=", drivingCourse[end][:v]," <= 0.0") # for testing
# push!(BS[:dataPoints], drivingCourse[end][:i])
# push!(BS[:supportPoints], drivingCourse[end][:i])
error("ERROR: The train stops during diminishing run in CS",CS[:id]," because the maximum tractive effort is lower than the resistant forces.",
" Before the stop the last point has the values s=",drivingCourse[end-1][:s]," m v=",drivingCourse[end-1][:v]," m/s a=",drivingCourse[end-1][:a]," m/s^2",
" F_T=",drivingCourse[end-1][:F_T]," N R_traction=",drivingCourse[end-1][:R_traction]," N R_wagons=",drivingCourse[end-1][:R_wagons]," N R_path=",drivingCourse[end-1][:R_path]," N.")
@ -743,7 +743,7 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
elseif s_braking > 0.0 && drivingCourse[end][:s] + s_braking > CS[:s_exit]
testFlag && println("in CS",CS[:id]," diminishing cycle",cycle," case: s +s_braking=", drivingCourse[end][:s],"+",s_braking," = ",drivingCourse[end][:s] +s_braking," > s_exit=",CS[:s_exit]) # for testing
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
pointOfInterestReached = false
targetSpeedReached = false
@ -781,11 +781,11 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
end
end #while
if length(BS[:dataPoints]) > 1 # TODO: necessary? May it be possible that there is no diminishing because braking has to start?
if length(BS[:supportPoints]) > 1 # TODO: necessary? May it be possible that there is no diminishing because braking has to start?
# calculate the accumulated diminishing section information
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
:s_exit => drivingCourse[end][:s], # last position (in m)
:t => drivingCourse[end][:t] - drivingCourse[BS[:dataPoints][1]][:t], # total running time (in s)
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
@ -806,7 +806,7 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
end #function addDiminishingSection!
## This function calculates the data points of the coasting section.
## This function calculates the support points of the coasting section.
# Therefore it gets its previous driving course and the characteristic section and returns the characteristic section and driving course including the coasting section
function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::Dict, settings::Settings, train::Train, CSs::Vector{Dict})
# TODO: if the rear of the train is still located in a former characteristic section it has to be checked if its speed limit can be kept
@ -838,10 +838,10 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
# acceleration (in m/s^2):
drivingCourse[end][:a] = acceleration(drivingCourse[end][:F_T], drivingCourse[end][:F_R], train.m_train_full, train.ξ_train)
# create the next data point
# create the next support point
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
drivingCourse[end][:behavior] = BS[:type]
push!(BS[:dataPoints], drivingCourse[end][:i])
push!(BS[:supportPoints], drivingCourse[end][:i])
# conditions for the next while cycle
s_braking = brakingDistance(drivingCourse[end][:v], CS[:v_exit], train.a_braking, settings.approxLevel)
@ -897,9 +897,9 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
# TODO: not needed. just for testing
error("ERROR at coasting until braking section: With the step variable ",settings.stepVariable," the while loop will be left although v<v_peak and s+s_braking<s_exit in CS",CS[:id]," with s=" ,drivingCourse[end][:s]," m and v=",drivingCourse[end][:v]," m/s")
end
# delete last data point for recalculating the last step with reduced step size
# delete last support point for recalculating the last step with reduced step size
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
# conditions for the next for cycle
brakingStartReached = false
@ -914,9 +914,9 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
" F_T=",drivingCourse[end-1][:F_T]," N R_traction=",drivingCourse[end-1][:R_traction]," N R_wagons=",drivingCourse[end-1][:R_wagons]," N R_path=",drivingCourse[end-1][:R_path]," N and s_braking=",s_braking,"m.")
elseif drivingCourse[end][:s] + s_braking > CS[:s_exit]
# delete last data point because it went to far
# delete last support point because it went to far
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
# conditions for the next for cycle
# brakingStartReached = true
@ -924,9 +924,9 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
targetSpeedReached = false
elseif drivingCourse[end][:v] > CS[:v_peak] # if the train gets to fast it has to brake # TODO: if accelereation and coasting functions will be combined this case is different for coasting and also the order of if cases is different
# delete last data point because it went to far
# delete last support point because it went to far
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
# conditions for the next for cycle
brakingStartReached = false
@ -953,7 +953,7 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
# calculate the accumulated coasting section information
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
:s_exit => drivingCourse[end][:s], # last position (in m)
:t => drivingCourse[end][:t] - drivingCourse[BS[:dataPoints][1]][:t], # total running time (in s)
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
@ -972,8 +972,8 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
end #function addCoastingSection!
## This function calculates the data points of the braking section.
# Therefore it gets its first data point and the characteristic section and returns the characteristic section including the behavior section for braking if needed.
## This function calculates the support points of the braking section.
# Therefore it gets its first support point and the characteristic section and returns the characteristic section including the behavior section for braking if needed.
function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::Dict, settings::Settings, train::Train, CSs::Vector{Dict})
# conditions for braking section
targetSpeedReached = drivingCourse[end][:v] <= CS[:v_exit]
@ -1000,17 +1000,17 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
# TODO or: drivingCourse[end][:a] = brakingAcceleration(drivingCourse[end][:v], CS[:v_exit], CS[:s_exit]-drivingCourse[end][:s])
if settings.stepVariable == :distance && ((drivingCourse[end][:v]/drivingCourse[end][:a])^2+2*currentStepSize/drivingCourse[end][:a])<0.0 || (drivingCourse[end][:v]^2+2*currentStepSize*drivingCourse[end][:a])<0.0
# create empty data point and set it for the values of s_exit and v_exit
push!(drivingCourse, DataPoint())
# create empty support point and set it for the values of s_exit and v_exit
push!(drivingCourse, SupportPoint())
drivingCourse[end][:i] = drivingCourse[end-1][:i]+1
drivingCourse[end][:behavior] = BS[:type]
push!(BS[:dataPoints], drivingCourse[end][:i])
push!(BS[:supportPoints], drivingCourse[end][:i])
recalculateLastBrakingPoint!(drivingCourse, CS[:s_exit], CS[:v_exit])
else
# create the next data point
# create the next support point
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
drivingCourse[end][:behavior] = BS[:type]
push!(BS[:dataPoints], drivingCourse[end][:i])
push!(BS[:supportPoints], drivingCourse[end][:i])
end
#println(drivingCourse[end][:i],". s=",drivingCourse[end][:s]," s_exit=", CS[:s_exit]," v_exit=", CS[:v_exit]," v=",drivingCourse[end][:v])
@ -1052,9 +1052,9 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
break
end
# delete last data point for recalculating the last step with reduced step size
# delete last support point for recalculating the last step with reduced step size
pop!(drivingCourse)
pop!(BS[:dataPoints])
pop!(BS[:supportPoints])
# conditions for the next for cycle
pointOfInterestReached = false
@ -1111,7 +1111,7 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
# calculate the accumulated coasting section information
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
:s_exit => drivingCourse[end][:s], # last position (in m)
:t => drivingCourse[end][:t] - drivingCourse[BS[:dataPoints][1]][:t], # total running time (in s)
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
@ -1132,8 +1132,8 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
end #function addBrakingSection!
## This function calculates the data point of the halt.
# Therefore it gets its first data point and the characteristic section and returns the characteristic section including the halt if needed.
## This function calculates the support point of the halt.
# Therefore it gets its first support point and the characteristic section and returns the characteristic section including the halt if needed.
function addHalt!(CS::Dict, drivingCourse::Vector{Dict}, settings::Settings, train::Train, CSs::Vector{Dict})
if drivingCourse[end][:v] == 0.0
BS = BehaviorSection("standstill", drivingCourse[end][:s], drivingCourse[end][:v], drivingCourse[end][:i])
@ -1218,7 +1218,7 @@ function secureAcceleratingBehavior!(movingSection::Dict, settings::Settings, tr
CSs = movingSection[:characteristicSections]
CSs[1][:v_entry] = 0.0 # the entry velocity of the first characteristic section is 0.0 m/s
startingPoint = DataPoint()
startingPoint = SupportPoint()
startingPoint[:i] = 1
previousCSv_exit = CSs[1][:v_entry]
@ -1227,7 +1227,7 @@ function secureAcceleratingBehavior!(movingSection::Dict, settings::Settings, tr
startingPoint[:s] = CS[:s_entry]
startingPoint[:v] = CS[:v_entry]
calculateForces!(startingPoint, CSs, CS[:id], "accelerating", train, settings.massModel) # traction effort and resisting forces (in N)
acceleratingCourse::Vector{Dict} = [startingPoint] # List of data points
acceleratingCourse::Vector{Dict} = [startingPoint] # List of support points
if CS[:v_entry] < CS[:v_peak]
# conditions for entering the accelerating phase

View File

@ -14,11 +14,11 @@ function calculateMinimumRunningTime!(movingSection::Dict, settings::Settings, t
println("WARNING: ! ! ! TrainRuns.jl doesn't work reliably for the mass model homogeneous strip with step size v in m/s. The calculation time can be extremely high when calcutlating paths with steep gradients ! ! !")
end
startingPoint=DataPoint()
startingPoint[:i]=1
startingPoint[:s]=CSs[1][:s_entry]
startingPoint = SupportPoint()
startingPoint[:i] = 1
startingPoint[:s] = CSs[1][:s_entry]
calculateForces!(startingPoint, CSs, 1, "default", train, settings.massModel) # traction effort and resisting forces (in N)
drivingCourse::Vector{Dict} = [startingPoint] # List of data points
drivingCourse::Vector{Dict} = [startingPoint] # List of support points
for csId in 1:length(CSs)
CS = CSs[csId]
@ -30,7 +30,7 @@ function calculateMinimumRunningTime!(movingSection::Dict, settings::Settings, t
println("ERROR: In CS", csId," the train run ends with v=",drivingCourse[end][:v]," and not with v_entry=",CS[:v_entry])
end
# determine the different flags for switching between the states for creatinge moving phases
# determine the different flags for switching between the states for creating moving phases
s_braking = brakingDistance(drivingCourse[end][:v], CS[:v_exit], train.a_braking, settings.approxLevel)
calculateForces!(drivingCourse[end], CSs, CS[:id], "default", train, settings.massModel) # tractive effort and resisting forces (in N)
@ -191,30 +191,30 @@ end #function calculatePathResistance
"""
calculate and return tractive and resisting forces for a data point
calculate and return tractive and resisting forces for a support point
"""
function calculateForces!(dataPoint::Dict, CSs::Vector{Dict}, csId::Integer, bsType::String, train::Train, massModel)
function calculateForces!(supportPoint::Dict, CSs::Vector{Dict}, csId::Integer, bsType::String, train::Train, massModel)
# calculate resisting forces
dataPoint[:R_traction] = tractionUnitResistance(dataPoint[:v], train)
supportPoint[:R_traction] = tractionUnitResistance(supportPoint[:v], train)
if train.transportType == :freight
dataPoint[:R_wagons] = freightWagonsResistance(dataPoint[:v], train)
supportPoint[:R_wagons] = freightWagonsResistance(supportPoint[:v], train)
elseif train.transportType == :passenger
dataPoint[:R_wagons] = passengerWagonsResistance(dataPoint[:v], train)
supportPoint[:R_wagons] = passengerWagonsResistance(supportPoint[:v], train)
end
dataPoint[:R_train] = dataPoint[:R_traction] + dataPoint[:R_wagons]
dataPoint[:R_path] = calculatePathResistance(CSs, csId, dataPoint[:s], massModel, train)
dataPoint[:F_R] = dataPoint[:R_train] + dataPoint[:R_path]
supportPoint[:R_train] = supportPoint[:R_traction] + supportPoint[:R_wagons]
supportPoint[:R_path] = calculatePathResistance(CSs, csId, supportPoint[:s], massModel, train)
supportPoint[:F_R] = supportPoint[:R_train] + supportPoint[:R_path]
# calculate tractive effort
if bsType == "braking" || bsType == "coasting" || bsType == "halt"
dataPoint[:F_T] = 0.0
supportPoint[:F_T] = 0.0
elseif bsType == "cruising"
dataPoint[:F_T] = min(max(0.0, dataPoint[:F_R]), calculateTractiveEffort(dataPoint[:v], train.tractiveEffort))
supportPoint[:F_T] = min(max(0.0, supportPoint[:F_R]), calculateTractiveEffort(supportPoint[:v], train.tractiveEffort))
else # bsType == "accelerating" || bsType == "diminishing" || 'default'
dataPoint[:F_T] = calculateTractiveEffort(dataPoint[:v], train.tractiveEffort)
supportPoint[:F_T] = calculateTractiveEffort(supportPoint[:v], train.tractiveEffort)
end
return dataPoint
return supportPoint
end #function calculateForces!
@ -226,8 +226,8 @@ function moveAStep(previousPoint::Dict, stepVariable::Symbol, stepSize::Real, cs
# TODO: csId is only for error messages. Should it be removed?
#= 08/31 TODO: How to check if the train stopps during this step? I should throw an error myself that I catch in higher hierarchies. =#
# create the next data point
newPoint = DataPoint()
# create the next support point
newPoint = SupportPoint()
newPoint[:i] = previousPoint[:i]+1 # identifier
# calculate s, t, v, E

View File

@ -677,7 +677,7 @@ function CharacteristicSection(id::Integer, s_entry::Real, section::Dict, v_limi
:v_entry => v_limit, # maximum entry speed (in m/s)
:v_exit => v_limit) # maximum exit speed (in m/s)
# list of positions of every point of interest (POI) in this charateristic section for which data points should be calculated
# list of positions of every point of interest (POI) in this charateristic section for which support points should be calculated
s_exit = characteristicSection[:s_exit]
##TODO: use a tuple with naming
@ -711,19 +711,19 @@ function BehaviorSection(type::String, s_entry::Real, v_entry::Real, startingPoi
:E => 0.0, # total energy consumption (in Ws)
:v_entry => v_entry, # entry speed (in m/s)
:v_exit => 0.0, # exit speed (in m/s)
:dataPoints => [startingPoint] # list of identifiers of the containing data points starting with the initial point
:supportPoints => [startingPoint] # list of identifiers of the containing support points starting with the initial point
)
return BS
end #function BehaviorSection
"""
a DataPoint is the smallest element of the driving course. One step of the step approach is between two data points
a SupportPoint is the smallest element of the driving course. One step of the step approach is between two support points
"""
function DataPoint()
dataPoint = Dict(
function SupportPoint()
supportPoint = Dict(
:i => 0, # identifier and counter variable of the driving course
:behavior => "", # type of behavior section the data point is part of - see BehaviorSection()
# a data point which is the last point of one behavior section and the first point of the next behavior section will be attached to the latter
:behavior => "", # type of behavior section the support point is part of - see BehaviorSection()
# a support point which is the last point of one behavior section and the first point of the next behavior section will be attached to the latter
:s => 0.0, # position (in m)
:Δs => 0.0, # step size (in m)
:t => 0.0, # point in time (in s)
@ -743,5 +743,5 @@ function DataPoint()
:R_wagons => 0.0, # set of wagons resistance (in N)
:label => "" # a label for important points
)
return dataPoint
end #function DataPoint
return supportPoint
end #function SupportPoint

View File

@ -124,8 +124,8 @@ function Δs_with_Δt(Δt::Real, a_prev::Real, v_prev::Real)
# equation is based on [Wende:2003, page 37]
# Δt: time step (in s)
# a_prev: acceleration from previous data point
# v_prev: velocitiy from previous data point
# a_prev: acceleration from previous support point
# v_prev: velocitiy from previous support point
Δs = Δt * (2*v_prev + Δt*a_prev) /2 # step size (in m)
return Δs
end #function Δs_with_Δt
@ -134,8 +134,8 @@ function Δs_with_Δv(Δv::Real, a_prev::Real, v_prev::Real)
# equation is based on [Wende:2003, page 37]
# Δv: velocity step (in m/s)
# a_prev: acceleration from previous data point
# v_prev: velocitiy from previous data point
# a_prev: acceleration from previous support point
# v_prev: velocitiy from previous support point
Δs = ((v_prev + Δv)^2 - v_prev^2)/2/a_prev # step size (in m)
return Δs
end #function Δs_with_Δv
@ -144,8 +144,8 @@ function Δt_with_Δs(Δs::Real, a_prev::Real, v_prev::Real)
# equation is based on [Wende:2003, page 37]
# Δs: distance step (in m)
# a_prev: acceleration from previous data point
# v_prev: velocitiy from previous data point
# a_prev: acceleration from previous support point
# v_prev: velocitiy from previous support point
Δt = sign(a_prev) *sqrt((v_prev /a_prev)^2 + 2 *Δs /a_prev) - v_prev /a_prev # step size (in m/s)
return Δt
@ -155,7 +155,7 @@ function Δt_with_Δv(Δv::Real, a_prev::Real)
# equation is based on [Wende:2003, page 37]
# Δv: velocity step (in m/s)
# a_prev: acceleration from previous data point
# a_prev: acceleration from previous support point
Δt = Δv /a_prev # step size (in s)
return Δt
end #function Δt_with_Δv
@ -173,8 +173,8 @@ function Δv_with_Δs(Δs::Real, a_prev::Real, v_prev::Real)
# equation is based on [Wende:2003, page 37]
# Δs: distance step (in m)
# a_prev: acceleration from previous data point
# v_prev: velocitiy from previous data point
# a_prev: acceleration from previous support point
# v_prev: velocitiy from previous support point
Δv = sqrt(v_prev^2 + 2*Δs*a_prev) - v_prev # step size (in m/s)
return Δv
end #function Δv_with_Δs
@ -183,7 +183,7 @@ function Δv_with_Δt(Δt::Real, a_prev::Real)
# equation is based on [Wende:2003, page 37]
# Δt: time step (in s)
# a_prev: acceleration from previous data point
# a_prev: acceleration from previous support point
Δv = Δt * a_prev # step size (in m/s)
return Δv
end #function Δv_with_Δt

View File

@ -9,16 +9,16 @@ function createOutput(settings::Settings, drivingCourse::Vector{Dict}, pointsOfI
output::Vector{Dict} = [Dict(:t => drivingCourse[end][:t])]
elseif settings.outputDetail == :points_of_interest && !isempty(pointsOfInterest)
# get only the driving course's data points with POI labels
# get only the driving course's support points with POI labels
output = Dict[]
dataPoint = 1
supportPoint = 1
for POI in 1:length(pointsOfInterest)
while dataPoint <= length(drivingCourse)
if pointsOfInterest[POI][1] == drivingCourse[dataPoint][:s]
push!(output, drivingCourse[dataPoint])
while supportPoint <= length(drivingCourse)
if pointsOfInterest[POI][1] == drivingCourse[supportPoint][:s]
push!(output, drivingCourse[supportPoint])
break
end
dataPoint += 1
supportPoint += 1
end
end
@ -63,4 +63,4 @@ function createDataFrame(output_vector::Vector{Dict}, outputDetail)
end
return dataFrame
end #createDataFrameForDrivingCourse
end #createDataFrame