Remove step sizes from 'SupportPoint'

master
Max Kannenberg 2022-06-30 18:42:35 +02:00
parent a3a68e5553
commit b7e0f21ffb
3 changed files with 20 additions and 37 deletions

View File

@ -280,13 +280,11 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
else
drivingCourse[end][:s] = CS[:s_exit] # round s down to CS[:s_exit]
drivingCourse[end][:Δs] = drivingCourse[end][:s] - drivingCourse[end-1][:s]
end
elseif drivingCourse[end][:s] > nextPointOfInterest[1]
testFlag && println("in CS",CS[:id]," accelerating cycle",cycle," case: s=", drivingCourse[end][:s]," > nextPointOfInterest[1]=",nextPointOfInterest[1]) # for testing
drivingCourse[end][:s] = nextPointOfInterest[1] # round s down to nextPointOfInterest
drivingCourse[end][:Δs] = drivingCourse[end][:s] - drivingCourse[end-1][:s]
elseif drivingCourse[end][:F_T] <= drivingCourse[end][:F_R]
testFlag && println("in CS",CS[:id]," accelerating cycle",cycle," case: F_T=", drivingCourse[end][:F_T]," <= F_R=",drivingCourse[end][:F_R]) # for testing
@ -508,7 +506,6 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
else # if the level of approximation is reached
if drivingCourse[end][:s] > nextPointOfInterest[1]
drivingCourse[end][:s] = nextPointOfInterest[1] # round s down to nextPointOfInterest
drivingCourse[end][:Δs] = drivingCourse[end][:s] - drivingCourse[end-1][:s]
elseif drivingCourse[end][:s] > BS[:s_entry]+s_cruising
if BS[:type] != "clearing"
pop!(drivingCourse)
@ -753,7 +750,6 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
elseif drivingCourse[end][:s] > nextPointOfInterest[1]
testFlag && println("in CS",CS[:id]," diminishing cycle",cycle," case: s=", drivingCourse[end][:s]," > nextPointOfInterest[1]=",nextPointOfInterest[1]) # for testing
drivingCourse[end][:s] = nextPointOfInterest[1] # round s down to nextPointOfInterest
drivingCourse[end][:Δs] = drivingCourse[end][:s] - drivingCourse[end-1][:s]
elseif drivingCourse[end][:F_T] >= drivingCourse[end][:F_R]
testFlag && println("in CS",CS[:id]," diminishing cycle",cycle," case: F_T=", drivingCourse[end][:F_T]," >= F_R=", drivingCourse[end][:F_R]) # for testing
@ -935,7 +931,6 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
elseif drivingCourse[end][:s] > nextPointOfInterest[1]
drivingCourse[end][:s] = nextPointOfInterest[1] # round s down to nextPointOfInterest
drivingCourse[end][:Δs] = drivingCourse[end][:s] - drivingCourse[end-1][:s]
else
# do nothing for example for drivingCourse[end][:s] + s_braking == CS[:s_exit]
end
@ -1076,7 +1071,6 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
break
elseif drivingCourse[end][:s] > nextPointOfInterest[1]
drivingCourse[end][:s] = nextPointOfInterest[1] # round s down to nextPointOfInterest
drivingCourse[end][:Δs] = drivingCourse[end][:s] - drivingCourse[end-1][:s]
break
elseif drivingCourse[end][:v] == CS[:v_exit] && drivingCourse[end][:s] == CS[:s_exit]
break
@ -1171,17 +1165,14 @@ function recalculateLastBrakingPoint!(drivingCourse, s_target, v_target)
# set s and v
currentPoint[:s] = s_target # position (in m)
currentPoint[:v] = v_target # velocity (in m/s)
currentPoint[:Δs] = currentPoint[:s] - previousPoint[:s] # step size (in m)
currentPoint[:Δv] = currentPoint[:v] - previousPoint[:v] # step size (in m/s)
# calculate other values
previousPoint[:a] = brakingAcceleration(previousPoint[:v], currentPoint[:v], currentPoint[:Δs])
previousPoint[:a] = brakingAcceleration(previousPoint[:v], currentPoint[:v], currentPoint[:s]-previousPoint[:s])
# # TODO: just for testing
# if previousPoint[:a]<train.a_braking || previousPoint[:a]>=0.0
# println("Warning: a_braking gets to high in CS ",CS[:id], " with a=",previousPoint[:a] ," > ",train.a_braking)
# end
currentPoint[:Δt] = Δt_with_Δv(currentPoint[:Δv], previousPoint[:a]) # step size (in s)
currentPoint[:t] = previousPoint[:t] + currentPoint[:Δt] # point in time (in s)
currentPoint[:t] = previousPoint[:t] + Δt_with_Δv(currentPoint[:v]-previousPoint[:v], previousPoint[:a]) # point in time (in s)
end #function recalculateLastBrakingPoint
## define the intersection velocities between the characterisitc sections to secure braking behavior

View File

@ -232,49 +232,49 @@ function moveAStep(previousPoint::Dict, stepVariable::Symbol, stepSize::Real, cs
# calculate s, t, v, E
if stepVariable == :distance # distance step method
newPoint[:Δs] = stepSize # step size (in m)
Δs = stepSize # step size (in m)
if previousPoint[:a] == 0.0
if previousPoint[:v] == 0.0
error("ERROR: The train tries to cruise at v=0.0 m/s at s=",previousPoint[:s]," in CS",csId,".")
end
newPoint[:Δt] = Δt_with_constant_v(newPoint[:Δs], previousPoint[:v]) # step size (in s)
newPoint[:Δv] = 0.0 # step size (in m/s)
Δt = Δt_with_constant_v(Δs, previousPoint[:v]) # step size (in s)
Δv = 0.0 # step size (in m/s)
else
# check if the parts of the following square roots will be <0.0 in the functions Δt_with_Δs and Δv_with_Δs
squareRootPartIsNegative = (previousPoint[:v]/previousPoint[:a])^2+2*newPoint[:Δs]/previousPoint[:a] < 0.0 || previousPoint[:v]^2+2*newPoint[:Δs]*previousPoint[:a] < 0.0
squareRootPartIsNegative = (previousPoint[:v]/previousPoint[:a])^2+2*Δs/previousPoint[:a] < 0.0 || previousPoint[:v]^2+2*Δs*previousPoint[:a] < 0.0
if previousPoint[:a] < 0.0 && squareRootPartIsNegative
error("ERROR: The train stops during the accelerating section in CS",csId," because the tractive effort is lower than the resistant forces.",
" Before the stop the last point has the values s=",previousPoint[:s]," m, v=",previousPoint[:v]," m/s, a=",previousPoint[:a]," m/s^2,",
" F_T=",previousPoint[:F_T]," N, R_traction=",previousPoint[:R_traction]," N, R_wagons=",previousPoint[:R_wagons]," N, R_path=",previousPoint[:R_path]," N.")
end
newPoint[:Δt] = Δt_with_Δs(newPoint[:Δs], previousPoint[:a], previousPoint[:v]) # step size (in s)
newPoint[:Δv] = Δv_with_Δs(newPoint[:Δs], previousPoint[:a], previousPoint[:v]) # step size (in m/s)
Δt = Δt_with_Δs(Δs, previousPoint[:a], previousPoint[:v]) # step size (in s)
Δv = Δv_with_Δs(Δs, previousPoint[:a], previousPoint[:v]) # step size (in m/s)
end
elseif stepVariable == :time # time step method
newPoint[:Δt] = stepSize # step size (in s)
newPoint[:Δs] = Δs_with_Δt(newPoint[:Δt], previousPoint[:a], previousPoint[:v]) # step size (in m)
newPoint[:Δv] = Δv_with_Δt(newPoint[:Δt], previousPoint[:a]) # step size (in m/s)
Δt = stepSize # step size (in s)
Δs = Δs_with_Δt(Δt, previousPoint[:a], previousPoint[:v]) # step size (in m)
Δv = Δv_with_Δt(Δt, previousPoint[:a]) # step size (in m/s)
elseif stepVariable == :velocity # velocity step method
if previousPoint[:a] == 0.0
if previousPoint[:v] == 0.0
error("ERROR: The train tries to cruise at v=0.0 m/s at s=",previousPoint[:s]," in CS",csId,".")
end
newPoint[:Δs] = stepSize # step size (in m)
Δs = stepSize # step size (in m)
# TODO what is the best default step size for constant v? define Δs or Δt?
newPoint[:Δt] = Δt_with_constant_v(newPoint[:Δs], previousPoint[:v]) # step size (in s)
newPoint[:Δv] = 0.0 # step size (in m/s)
Δt = Δt_with_constant_v(Δs, previousPoint[:v]) # step size (in s)
Δv = 0.0 # step size (in m/s)
else
newPoint[:Δv] = stepSize * sign(previousPoint[:a]) # step size (in m/s)
newPoint[:Δs] = Δs_with_Δv(newPoint[:Δv], previousPoint[:a], previousPoint[:v]) # step size (in m)
newPoint[:Δt] = Δt_with_Δv(newPoint[:Δv], previousPoint[:a]) # step size (in s)
Δv = stepSize * sign(previousPoint[:a]) # step size (in m/s)
Δs = Δs_with_Δv(Δv, previousPoint[:a], previousPoint[:v]) # step size (in m)
Δt = Δt_with_Δv(Δv, previousPoint[:a]) # step size (in s)
end
end #if
newPoint[:s] = previousPoint[:s] + newPoint[:Δs] # position (in m)
newPoint[:t] = previousPoint[:t] + newPoint[:Δt] # point in time (in s)
newPoint[:v] = previousPoint[:v] + newPoint[:Δv] # velocity (in m/s)
newPoint[:s] = previousPoint[:s] + Δs # position (in m)
newPoint[:t] = previousPoint[:t] + Δt # point in time (in s)
newPoint[:v] = previousPoint[:v] + Δv # velocity (in m/s)
return newPoint
end #function moveAStep

View File

@ -708,7 +708,6 @@ function BehaviorSection(type::String, s_entry::Real, v_entry::Real, startingPoi
:s_entry => s_entry, # first position (in m)
:s_exit => 0.0, # last position (in m)
:t => 0.0, # total running time (in s)
: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)
:supportPoints => [startingPoint] # list of identifiers of the containing support points starting with the initial point
@ -725,16 +724,9 @@ function SupportPoint()
: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)
:Δt => 0.0, # step size (in s)
:v => 0.0, # velocity (in m/s)
:Δv => 0.0, # step size (in m/s)
:a => 0.0, # acceleration (in m/s^2)
:W => 0.0, # mechanical work (in Ws)
:ΔW => 0.0, # mechanical work in this step (in Ws)
:E => 0.0, # energy consumption (in Ws)
:ΔE => 0.0, # energy consumption in this step (in Ws)
:F_T => 0.0, # tractive effort (in N)
:F_R => 0.0, # resisting force (in N)
:R_path => 0.0, # path resistance (in N)