diff --git a/src/EnergySaving.jl b/src/EnergySaving.jl index caf813c..4da4248 100644 --- a/src/EnergySaving.jl +++ b/src/EnergySaving.jl @@ -7,6 +7,7 @@ export calculateRecoveryTime, increaseCoastingSection, decreaseMaximumVelocity, function calculateRecoveryTime(s_MS::AbstractFloat, t_MS::AbstractFloat, train::Train) # function for calculating the recovery time that can be used for energy saving + # MS: Moving Section if train.trainType=="motor coach train" if s_MS<= 30000 c_s=0.0 diff --git a/src/MovingPhases.jl b/src/MovingPhases.jl index 4361660..2f1a98d 100644 --- a/src/MovingPhases.jl +++ b/src/MovingPhases.jl @@ -6,6 +6,9 @@ export addAccelerationPhase!, addAccelerationPhaseUntilBraking!, addCruisingPhas v00=100/3.6 # velocity constant (in m/s) g=9.81 # acceleration due to gravity (in m/s^2) # TODO: should more digits of g be used? g=9,80665 m/s^2 +approximationLevel = 6 # value for approximation to intersections TODO further explanation (e.g. approximationLevel = 3 -> with stepSize 10 m the approximation will be calculated accurate on 10 mm ; 1s -> 1 ms; 1 km/h -> 3.6 mm/s) + # TODO: define it in TrainRun and give it to each function? + ## functions for calculating tractive effort and resisting forces """ calculate the trains tractive effort dependend on the velocity @@ -95,6 +98,140 @@ return waypoint end #function calculateForces +""" +TODO +""" +function moveAStep(previousPoint::Waypoint, stepVariable::String, stepSize::AbstractFloat, csId::Integer) + # stepSize is the currentStepSize depending on the accessing function + # TODO: csId is only for error messages. Should it be removed? + + # creating the next waypoint + newPoint=Waypoint() + newPoint.i=previousPoint.i+1 # identifier + + # calculate s, t, v, E + if stepVariable=="s in m" # distance step method + newPoint.Δs=stepSize # step size (in m) + # TODO: is this if correct and necessary? + #if ((previousPoint.v/previousPoint.a)^2+2*newPoint.Δs/previousPoint.a)<0.0 || (previousPoint.v^2+2*newPoint.Δs*previousPoint.a)<0.0 # checking if the parts of the following square roots will be <0.0 + # error("ERROR: The train stops during the acceleration phase 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, F_Rt=",previousPoint.F_Rt," N, F_Rw=",previousPoint.F_Rw," N, F_Rp=",previousPoint.F_Rp," N.") + #end + #= 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. + =# + newPoint.Δt=sign(previousPoint.a)*sqrt((previousPoint.v/previousPoint.a)^2+2*newPoint.Δs/previousPoint.a)-previousPoint.v/previousPoint.a # step size (in s) + newPoint.Δv=sqrt(previousPoint.v^2+2*newPoint.Δs*previousPoint.a)-previousPoint.v # step size (in m/s) + elseif stepVariable=="t in s" # time step method + newPoint.Δt=stepSize # step size (in s) + newPoint.Δs=newPoint.Δt*(2*previousPoint.v+newPoint.Δt*previousPoint.a)/2 # step size (in m) + newPoint.Δv=newPoint.Δt*previousPoint.a # step size (in m/s) + elseif stepVariable=="v in m/s" # velocity step method + newPoint.Δv=stepSize*sign(previousPoint.a) # step size (in m/s) + newPoint.Δs=((previousPoint.v+newPoint.Δv)^2-previousPoint.v^2)/2/previousPoint.a # step size (in m) + newPoint.Δt=newPoint.Δv/previousPoint.a # step size (in s) + 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) + # 08/23 the following will be checked later + #if newPoint.v<=0.0 + # error("ERROR: The train stops during the acceleration phase in CS",csId," m because the tractive effort is lower than the resistant forces.", + # " Before the stop the last point has the values s=",previousPoint.s," v=",previousPoint.v," m/s a=",previousPoint.a," m/s^2", + # " F_T=",previousPoint.F_T," N F_Rt=",previousPoint.F_Rt," N F_Rw=",previousPoint.F_Rw," N F_Rp=",previousPoint.F_Rp," N.") + #end + newPoint.ΔW_T=previousPoint.F_T*newPoint.Δs # mechanical work in this step (in Ws) + newPoint.W_T=previousPoint.W_T+newPoint.ΔW_T # mechanical work (in Ws) + newPoint.ΔE=newPoint.ΔW_T # energy consumption in this step (in Ws) + newPoint.E=previousPoint.E+newPoint.ΔE # energy consumption (in Ws) + + return newPoint +end #function moveAStep + + +""" +# if the tail of the train is still located in a former characteristic section it has to be checked if its speed limit can be kept +""" +function detectFormerSpeedLimits(allCs::Vector{CharacteristicSection}, csWithTrainHeadId::Integer, currentPoint::Waypoint, l_union::AbstractFloat) + formerSpeedLimits=[] + if csWithTrainHeadId > 1 && currentPoint.s - l_union < allCs[csWithTrainHeadId].s_start + # if abs(allCs[csWithTrainHeadId-1].v_limit-currentPoint.v)<0.000001 # if the train runs already at the previous sections limit + # s_braking=max(0.0, ceil((allCs[csWithTrainHeadId].v_exit^2-currentPoint.v^2)/2/train.a_braking, digits=approximationLevel)) + # s_cruisingBeforeAcceleration=min(l_union, allCs[csWithTrainHeadId].s_end-currentPoint.s-s_braking) + + # return [], s_cruisingBeforeAcceleration + # else # if the train runs slower than allowed in the previous section the lower speed limits of the other sections will be detected + # formerSpeedLimits=[] + formerCsId=csWithTrainHeadId-1 + while formerCsId > 0 && currentPoint.s - l_union < allCs[formerCsId].s_end + if allCs[formerCsId].v_limit < allCs[csWithTrainHeadId].v_limit # TODO: is the position of trains tail < movingSection.s_start, v_limit of the first CS is used + push!(formerSpeedLimits, [allCs[formerCsId].s_end, allCs[formerCsId].v_limit]) + for i in 1:length(formerSpeedLimits)-1 + if formerSpeedLimits[i][2]<=formerSpeedLimits[end][2] + pop!(formerSpeedLimits) + break + end + end + end + formerCsId=formerCsId-1 + end + # return (formerSpeedLimits, 0.0) + + # end + end + #return ([], 0.0) + return formerSpeedLimits +end # function detectFormerSpeedLimits + +function considerFormerSpeedLimits!(characteristicSection::CharacteristicSection, drivingCourse::Vector{Waypoint}, settings::Settings, train::Train, allCs::Vector{CharacteristicSection}, formerSpeedLimits, accelerationSection::BehaviorSection) + # TODO: What is the type of formerSpeedLimits? function considerFormerSpeedLimits!(characteristicSection::CharacteristicSection, drivingCourse::Vector{Waypoint}, settings::Settings, train::Train, allCs::Vector{CharacteristicSection}, formerSpeedLimits::Array{Array{AbstractFloat,1},1}, accelerationSection::BehaviorSection) + # would work: function considerFormerSpeedLimits!(characteristicSection::CharacteristicSection, drivingCourse::Vector{Waypoint}, settings::Settings, train::Train, allCs::Vector{CharacteristicSection}, formerSpeedLimits::Array{Any,1}, accelerationSection::BehaviorSection) + if length(formerSpeedLimits) > 0 + # if a former speed limit has been exceeded the acceleration steps of this CS will be removed and a cruising phase will be inserted before acceleration + if drivingCourse[end].v > formerSpeedLimits[end][2] + + while drivingCourse[end].s > get(characteristicSection.behaviorSections, "cruisingBeforeAcceleration", accelerationSection).s_start + pop!(drivingCourse) + end + + if haskey(characteristicSection.behaviorSections, "cruisingBeforeAcceleration") + characteristicSection.t_total=characteristicSection.t_total-get(characteristicSection.behaviorSections, "cruisingBeforeAcceleration", BehaviorSection()).t_total # reducing the total running time (in s) + characteristicSection.E_total=characteristicSection.E_total-get(characteristicSection.behaviorSections, "cruisingBeforeAcceleration", BehaviorSection()).E_total # reducing the total energy consumption (in Ws) + delete!(characteristicSection.behaviorSections, "cruisingBeforeAcceleration") + end + + # create a (new and longer) cruisingBeforeAcceleration section + s_braking=max(0.0, ceil((characteristicSection.v_exit^2-drivingCourse[end].v^2)/2/train.a_braking, digits=approximationLevel)) + s_cruisingBeforeAcceleration=min(characteristicSection.s_end-drivingCourse[end].s-s_braking, formerSpeedLimits[end][1]-(drivingCourse[end].s-train.l_union)) + + if s_cruisingBeforeAcceleration>0.0 + (characteristicSection, drivingCourse)=addCruisingPhase!(characteristicSection, drivingCourse, s_cruisingBeforeAcceleration, settings, train, allCs, "cruisingBeforeAcceleration") + else + error("ERROR: cruisingBeforeAcceleration <=0.0 although it has to be >0.0 in CS ",characteristicSection.id) + end + + if drivingCourse[end].s < characteristicSection.s_end + # reset the accelerationSection + accelerationSection=BehaviorSection() + accelerationSection.type="acceleration" # type of behavior section + accelerationSection.s_start=drivingCourse[end].s # first position (in m) + accelerationSection.v_entry=drivingCourse[end].v # entry speed (in m/s) + + currentStepSize=settings.stepSize # initializing the step size that can be reduced near intersections + else + return (characteristicSection, drivingCourse, formerSpeedLimits, accelerationSection, true) + end + end + + # remove former speed limits of characteristic sections the train has left during the last step from the list + while length(formerSpeedLimits) > 0 && drivingCourse[end].s - train.l_union >= formerSpeedLimits[end][1] + pop!(formerSpeedLimits) + end + end + return (characteristicSection, drivingCourse, formerSpeedLimits, accelerationSection, false) +end # function considerFormerSpeedLimits! + ## This function calculates the waypoints of the starting phase. # Therefore it gets its first waypoint and the characteristic section and returns the characteristic section including the behavior section for starting if needed. # Info: currently the values of the starting phase will be calculated like in the acceleration phase @@ -106,16 +243,8 @@ function addStartingPhase!(characteristicSection::CharacteristicSection, driving startingSection.v_entry=drivingCourse[end].v # entry speed (in m/s) push!(startingSection.waypoints, drivingCourse[end].i) # list of containing waypoints - - # traction effort and resisting forces (in N): drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, settings.massModel, allCs, "acceleration")) # currently the tractive effort is calculated like in the acceleration phase - #07/16 drivingCourse[end].F_T=calculateTractiveEffort(drivingCourse[end].v, train.tractiveEffortArray) - #07/16 drivingCourse[end].F_Rt=calculateTractionUnitResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Rw=calculateWagonsResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Runion=drivingCourse[end].F_Rt+drivingCourse[end].F_Rw - #07/16 drivingCourse[end].F_Rp=calculatePathResistance(drivingCourse[end].s, settings.massModel, train, allCs) - #07/16 drivingCourse[end].F_R=drivingCourse[end].F_Runion+drivingCourse[end].F_Rp # acceleration (in m/s^2): drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train.m_union/train.ξ_union @@ -126,37 +255,38 @@ function addStartingPhase!(characteristicSection::CharacteristicSection, driving end # creating the next waypoint - push!(drivingCourse, Waypoint()) - drivingCourse[end].i=drivingCourse[end-1].i+1 # incrementing the number of the waypoint + push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, settings.stepSize, characteristicSection.id)) + #= 07/30 TODO: the calculation is easier with these lines because the values that are 0 in the first step are not used in calculation but all in all the code gets easier without these lines: + push!(drivingCourse, Waypoint()) + drivingCourse[end].i=drivingCourse[end-1].i+1 # incrementing the number of the waypoint - # calculate s, t, v, E - if settings.stepVariable=="s in m" # distance step method - drivingCourse[end].Δs=settings.stepSize # step size (in m) - drivingCourse[end].Δt=sqrt(2*drivingCourse[end].Δs/drivingCourse[end-1].a) # step size (in s) (in this formula drivingCourse[end-1].v is missing because it is 0.0) - drivingCourse[end].Δv=sqrt(2*drivingCourse[end].Δs*drivingCourse[end-1].a) # step size (in m/s) (in this formula drivingCourse[end-1].v is missing because it is 0.0) - elseif settings.stepVariable=="t in s" # time step method - drivingCourse[end].Δt=settings.stepSize # step size (in s) - drivingCourse[end].Δs=drivingCourse[end].Δt*(drivingCourse[end].Δt*drivingCourse[end-1].a)/2 # step size (in m) - drivingCourse[end].Δv=drivingCourse[end].Δt*drivingCourse[end-1].a # step size (in m/s) - elseif settings.stepVariable=="v in m/s" # velocity step method - drivingCourse[end].Δv=settings.stepSize*sign(drivingCourse[end-1].a) # step size (in m/s) - drivingCourse[end].Δs=drivingCourse[end].Δv^2/2/drivingCourse[end-1].a # step size (in m) - drivingCourse[end].Δt=drivingCourse[end].Δv/drivingCourse[end-1].a # step size (in s) - end #if - - #drivingCourse[end].s=ceil(drivingCourse[end-1].s+drivingCourse[end].Δs, digits=10) # position (in m) # rounded -> exact to 1 nm - drivingCourse[end].s=drivingCourse[end-1].s+drivingCourse[end].Δs # position (in m) - drivingCourse[end].t=drivingCourse[end-1].t+drivingCourse[end].Δt # point in time (in s) - drivingCourse[end].v=drivingCourse[end-1].v+drivingCourse[end].Δv # velocity (in m/s) - drivingCourse[end].ΔW_T=drivingCourse[end-1].F_T*drivingCourse[end].Δs # mechanical work in this step (in Ws) - drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) - drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) - drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) + # calculate s, t, v, E + if settings.stepVariable=="s in m" # distance step method + drivingCourse[end].Δs=settings.stepSize # step size (in m) + drivingCourse[end].Δt=sqrt(2*drivingCourse[end].Δs/drivingCourse[end-1].a) # step size (in s) (in this formula drivingCourse[end-1].v is missing because it is 0.0) + drivingCourse[end].Δv=sqrt(2*drivingCourse[end].Δs*drivingCourse[end-1].a) # step size (in m/s) (in this formula drivingCourse[end-1].v is missing because it is 0.0) + elseif settings.stepVariable=="t in s" # time step method + drivingCourse[end].Δt=settings.stepSize # step size (in s) + drivingCourse[end].Δs=drivingCourse[end].Δt*(drivingCourse[end].Δt*drivingCourse[end-1].a)/2 # step size (in m) + drivingCourse[end].Δv=drivingCourse[end].Δt*drivingCourse[end-1].a # step size (in m/s) + elseif settings.stepVariable=="v in m/s" # velocity step method + drivingCourse[end].Δv=settings.stepSize*sign(drivingCourse[end-1].a) # step size (in m/s) + drivingCourse[end].Δs=drivingCourse[end].Δv^2/2/drivingCourse[end-1].a # step size (in m) + drivingCourse[end].Δt=drivingCourse[end].Δv/drivingCourse[end-1].a # step size (in s) + end #if + #drivingCourse[end].s=ceil(drivingCourse[end-1].s+drivingCourse[end].Δs, digits=approximationLevel) # position (in m) # rounded -> exact to 1 nm + drivingCourse[end].s=drivingCourse[end-1].s+drivingCourse[end].Δs # position (in m) + drivingCourse[end].t=drivingCourse[end-1].t+drivingCourse[end].Δt # point in time (in s) + drivingCourse[end].v=drivingCourse[end-1].v+drivingCourse[end].Δv # velocity (in m/s) + drivingCourse[end].ΔW_T=drivingCourse[end-1].F_T*drivingCourse[end].Δs # mechanical work in this step (in Ws) + drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) + drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) + drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) + =# push!(startingSection.waypoints, drivingCourse[end].i) - - # calculation the accumulated starting ection information + # calculate the accumulated starting section information startingSection.s_end=drivingCourse[end].s # last position (in m) startingSection.s_total=startingSection.s_end-startingSection.s_start # total length (in m) startingSection.v_exit=drivingCourse[end].v # exit speed (in m/s) @@ -179,55 +309,33 @@ function addAccelerationPhase!(characteristicSection::CharacteristicSection, dri (characteristicSection, drivingCourse)=addStartingPhase!(characteristicSection, drivingCourse, settings, train, allCs) end #if - # if the tail of the train is still in a former characteristic section it has to be checked if its speed limit can be kept - formerSpeedLimits=[] - if characteristicSection.id>1 && drivingCourse[end].s-train.l_union 0.0 + # (characteristicSection, drivingCourse)=addCruisingPhase!(characteristicSection, drivingCourse, s_cruisingBeforeAcceleration, settings, train, allCs, "cruisingBeforeAcceleration") + #else + # error("ERROR: cruisingBeforeAcceleration <=0.0 although it has to be >0.0 in CS ",csWithTrainHeadId) + # end - if s_cruisingBeforeAcceleration>0.0 - (characteristicSection, drivingCourse)=addCruisingPhase!(characteristicSection, drivingCourse, s_cruisingBeforeAcceleration, settings, train, allCs, "cruisingBeforeAcceleration") - else - error("ERROR: cruisingBeforeAcceleration <=0.0 although it has to be >0.0 in CS ",characteristicSection.id) - end - else # detecting the lower speed limits of former sections - csId=characteristicSection.id-1 - while csId>0 && drivingCourse[end].s-train.l_union0 && drivingCourse[end].v0.0 - push!(accelerationSection.waypoints, drivingCourse[end].i) + =# + for cycle in 1:approximationLevel+1 # first cycle with normal step size followed by cycles with reduced step size depending on the level of approximation + # while characteristicSection.v_reach - drivingCourse[end].v > 0.000001 && drivingCourse[end].s0.0 + while drivingCourse[end].v0.0 + # traction effort and resisting forces (in N) drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, settings.massModel, allCs, accelerationSection.type)) - #07/16 drivingCourse[end].F_T=calculateTractiveEffort(drivingCourse[end].v, train.tractiveEffortArray) - #07/16 drivingCourse[end].F_Rt=calculateTractionUnitResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Rw=calculateWagonsResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Runion=drivingCourse[end].F_Rt+drivingCourse[end].F_Rw - #07/16 drivingCourse[end].F_Rp=calculatePathResistance(drivingCourse[end].s, settings.massModel, train, allCs) - #07/16 drivingCourse[end].F_R=drivingCourse[end].F_Runion+drivingCourse[end].F_Rp - # acceleration (in m/s^2): drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train.m_union/train.ξ_union @@ -235,132 +343,130 @@ function addAccelerationPhase!(characteristicSection::CharacteristicSection, dri error("ERROR: a=0 m/s^2 in the acceleration phase ! with F_T=",drivingCourse[end].F_T," F_Rt=",drivingCourse[end].F_Rt," F_Rw=",drivingCourse[end].F_Rw," F_Rp=",drivingCourse[end].F_Rp) end - # creating the next waypoint - push!(drivingCourse, Waypoint()) - drivingCourse[end].i=drivingCourse[end-1].i+1 # identifier + # create the next waypoint + push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, characteristicSection.id)) + push!(accelerationSection.waypoints, drivingCourse[end].i) - # calculate s, t, v, E - if settings.stepVariable=="s in m" # distance step method - drivingCourse[end].Δs=currentStepSize # step size (in m) - if ((drivingCourse[end-1].v/drivingCourse[end-1].a)^2+2*drivingCourse[end].Δs/drivingCourse[end-1].a)<0.0 || (drivingCourse[end-1].v^2+2*drivingCourse[end].Δs*drivingCourse[end-1].a)<0.0 # checking if the parts of the following square roots will be <0.0 - error("ERROR: The train stops during the acceleration phase in CS",characteristicSection.id," m because the tractive effort is lower than the resistant forces.", - " Before the stop the last point has the values s=",drivingCourse[end-1].s," v=",drivingCourse[end-1].v," m/s a=",drivingCourse[end-1].a," m/s^2", - " F_T=",drivingCourse[end-1].F_T," N F_Rt=",drivingCourse[end-1].F_Rt," N F_Rw=",drivingCourse[end-1].F_Rw," N F_Rp=",drivingCourse[end-1].F_Rp," N.") - end - drivingCourse[end].Δt=sign(drivingCourse[end-1].a)*sqrt((drivingCourse[end-1].v/drivingCourse[end-1].a)^2+2*drivingCourse[end].Δs/drivingCourse[end-1].a)-drivingCourse[end-1].v/drivingCourse[end-1].a # step size (in s) - drivingCourse[end].Δv=sqrt(drivingCourse[end-1].v^2+2*drivingCourse[end].Δs*drivingCourse[end-1].a)-drivingCourse[end-1].v # step size (in m/s) - elseif settings.stepVariable=="t in s" # time step method - drivingCourse[end].Δt=currentStepSize # step size (in s) - drivingCourse[end].Δs=drivingCourse[end].Δt*(2*drivingCourse[end-1].v+drivingCourse[end].Δt*drivingCourse[end-1].a)/2 # step size (in m) - drivingCourse[end].Δv=drivingCourse[end].Δt*drivingCourse[end-1].a # step size (in m/s) - elseif settings.stepVariable=="v in m/s" # velocity step method - drivingCourse[end].Δv=currentStepSize*sign(drivingCourse[end-1].a) # step size (in m/s) - drivingCourse[end].Δs=((drivingCourse[end-1].v+drivingCourse[end].Δv)^2-drivingCourse[end-1].v^2)/2/drivingCourse[end-1].a # step size (in m) - drivingCourse[end].Δt=drivingCourse[end].Δv/drivingCourse[end-1].a # step size (in s) - end #if + if length(formerSpeedLimits) > 0 # If the tail of the train is located in a former characteristic section with lower speed limit check if is is possible to accelerate as normal + (characteristicSection, drivingCourse, formerSpeedLimits, accelerationSection, endOfCsReached) = considerFormerSpeedLimits!(characteristicSection, drivingCourse, settings, train, allCs, formerSpeedLimits, accelerationSection) - drivingCourse[end].s=drivingCourse[end-1].s+drivingCourse[end].Δs # position (in m) - drivingCourse[end].t=drivingCourse[end-1].t+drivingCourse[end].Δt # point in time (in s) - drivingCourse[end].v=drivingCourse[end-1].v+drivingCourse[end].Δv # velocity (in m/s) - drivingCourse[end].ΔW_T=drivingCourse[end-1].F_T*drivingCourse[end].Δs # mechanical work in this step (in Ws) - drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) - drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) - drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) - - while length(formerSpeedLimits)>0 && drivingCourse[end].s-train.l_union>=formerSpeedLimits[end][1] - pop!(formerSpeedLimits) - end - - if length(formerSpeedLimits)>0 && drivingCourse[end].v>formerSpeedLimits[end][2] - while (drivingCourse[end].s>get(characteristicSection.behaviorSections, "cruisingBeforeAcceleration", accelerationSection).s_start) - pop!(drivingCourse) - end - - if haskey(characteristicSection.behaviorSections, "cruisingBeforeAcceleration") - characteristicSection.t_total=characteristicSection.t_total-get(characteristicSection.behaviorSections, "cruisingBeforeAcceleration", BehaviorSection()).t_total # reducing the total running time (in s) - characteristicSection.E_total=characteristicSection.E_total-get(characteristicSection.behaviorSections, "cruisingBeforeAcceleration", BehaviorSection()).E_total # reducing the total energy consumption (in Ws) - delete!(characteristicSection.behaviorSections, "cruisingBeforeAcceleration") - end - - # creating a cruisingBeforeAcceleration section - s_braking=max(0.0, ceil((characteristicSection.v_exit^2-drivingCourse[end].v^2)/2/train.a_braking, digits=10)) - s_cruisingBeforeAcceleration=min(characteristicSection.s_end-drivingCourse[end].s-s_braking, formerSpeedLimits[end][1]-(drivingCourse[end].s-train.l_union)) - - if s_cruisingBeforeAcceleration>0.0 - (characteristicSection, drivingCourse)=addCruisingPhase!(characteristicSection, drivingCourse, s_cruisingBeforeAcceleration, settings, train, allCs, "cruisingBeforeAcceleration") - else - error("ERROR: cruisingBeforeAcceleration <=0.0 although it has to be >0.0 in CS ",characteristicSection.id) - end - - if drivingCourse[end].scharacteristicSection.s_end + if settings.stepVariable == "s in m" + currentStepSize=characteristicSection.s_end-drivingCourse[end-1].s + else + currentStepSize = settings.stepSize / 10.0^cycle end + + elseif drivingCourse[end].v>characteristicSection.v_reach + if settings.stepVariable=="v in m/s" + currentStepSize=characteristicSection.v_reach-drivingCourse[end-1].v + else + currentStepSize = settings.stepSize / 10.0^cycle + end + + elseif drivingCourse[end].s==characteristicSection.s_end + break + + elseif drivingCourse[end].v==characteristicSection.v_reach + break + + else + error("ERROR at acceleration phase: With the step variable ",settings.stepVariable," the while loop will be left although vcharacteristicSection.v_reach + pop!(drivingCourse) + pop!(accelerationSection.waypoints) + elseif drivingCourse[end].s>characteristicSection.s_end + drivingCourse[end].s=characteristicSection.s_end # rounding s down to s_end + + else + end end - # from here on the head and tail of the train are located in the current characteristic section + #= 08/23 new, sorted by step variable: + if drivingCourse[end].v<=0.0 + currentStepSize=currentStepSize/10.0 + pop!(drivingCourse) + pop!(accelerationSection.waypoints) - # acceleration with all parts of the train inside the current characteristic section - while drivingCourse[end].v0.0 - push!(accelerationSection.waypoints, drivingCourse[end].i) - - # traction effort and resisting forces (in N): - drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, settings.massModel, allCs, accelerationSection.type)) - #07/16 drivingCourse[end].F_T=calculateTractiveEffort(drivingCourse[end].v, train.tractiveEffortArray) - #07/16 drivingCourse[end].F_Rt=calculateTractionUnitResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Rw=calculateWagonsResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Runion=drivingCourse[end].F_Rt+drivingCourse[end].F_Rw - #07/16 drivingCourse[end].F_Rp=calculatePathResistance(drivingCourse[end].s, settings.massModel, train, allCs) - #07/16 drivingCourse[end].F_R=drivingCourse[end].F_Runion+drivingCourse[end].F_Rp - - # acceleration (in m/s^2): - drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train.m_union/train.ξ_union - if drivingCourse[end].a==0.0 - error("ERROR: a=0.0 m/s^2 in the acceleration phase ! with F_T=",drivingCourse[end].F_T," F_Rt=",drivingCourse[end].F_Rt," F_Rw=",drivingCourse[end].F_Rw," F_Rp=",drivingCourse[end].F_Rp) - end - - # creating the next waypoint - push!(drivingCourse, Waypoint()) - drivingCourse[end].i=drivingCourse[end-1].i+1 # identifier - - # calculate s, t, v, E - if settings.stepVariable=="s in m" # distance step method - drivingCourse[end].Δs=currentStepSize # step size (in m) - if ((drivingCourse[end-1].v/drivingCourse[end-1].a)^2+2*drivingCourse[end].Δs/drivingCourse[end-1].a)<0.0 || (drivingCourse[end-1].v^2+2*drivingCourse[end].Δs*drivingCourse[end-1].a)<0.0 # checking if the parts of the following square roots will be <0.0 - error("ERROR: The train stops during the acceleration phase in CS",characteristicSection.id," m because the tractive effort is lower than the resistant forces.", - " Before the stop the last point has the values s=",drivingCourse[end-1].s," v=",drivingCourse[end-1].v," m/s a=",drivingCourse[end-1].a," m/s^2", - " F_T=",drivingCourse[end-1].F_T," N F_Rt=",drivingCourse[end-1].F_Rt," N F_Rw=",drivingCourse[end-1].F_Rw," N F_Rp=",drivingCourse[end-1].F_Rp," N.") - end - - drivingCourse[end].Δt=sign(drivingCourse[end-1].a)*sqrt((drivingCourse[end-1].v/drivingCourse[end-1].a)^2+2*drivingCourse[end].Δs/drivingCourse[end-1].a)-drivingCourse[end-1].v/drivingCourse[end-1].a # step size (in s) - drivingCourse[end].Δv=sqrt(drivingCourse[end-1].v^2+2*drivingCourse[end].Δs*drivingCourse[end-1].a)-drivingCourse[end-1].v # step size (in m/s) - elseif settings.stepVariable=="t in s" # time step method - drivingCourse[end].Δt=currentStepSize # step size (in s) - drivingCourse[end].Δs=drivingCourse[end].Δt*(2*drivingCourse[end-1].v+drivingCourse[end].Δt*drivingCourse[end-1].a)/2 # step size (in m) - drivingCourse[end].Δv=drivingCourse[end].Δt*drivingCourse[end-1].a # step size (in m/s) - elseif settings.stepVariable=="v in m/s" # velocity step method - drivingCourse[end].Δv=currentStepSize*sign(drivingCourse[end-1].a) # step size (in m/s) - drivingCourse[end].Δs=((drivingCourse[end-1].v+drivingCourse[end].Δv)^2-drivingCourse[end-1].v^2)/2/drivingCourse[end-1].a # step size (in m) - drivingCourse[end].Δt=drivingCourse[end].Δv/drivingCourse[end-1].a # step size (in s) + elseif settings.stepVariable == "s in m" + if drivingCourse[end].s > characteristicSection.s_end + currentStepSize=characteristicSection.s_end-drivingCourse[end-1].s + pop!(drivingCourse) + pop!(accelerationSection.waypoints) + elseif drivingCourse[end].v > characteristicSection.v_reach + currentStepSize = settings.stepSize / 10.0^cycle + pop!(drivingCourse) + pop!(accelerationSection.waypoints) + elseif drivingCourse[end].s==characteristicSection.s_end + break + elseif drivingCourse[end].v==characteristicSection.v_reach + break + else + error("ERROR at acceleration phase: With the distance step method the while loop will be left although vcharacteristicSection.s_end + currentStepSize=currentStepSize/10.0 + pop!(drivingCourse) + pop!(accelerationSection.waypoints) + elseif drivingCourse[end].v>characteristicSection.v_reach + currentStepSize=currentStepSize/10.0 + pop!(drivingCourse) + pop!(accelerationSection.waypoints) + elseif drivingCourse[end].s==characteristicSection.s_end + break + elseif drivingCourse[end].v==characteristicSection.v_reach + break + else + error("ERROR at acceleration phase: With the time step method the while loop will be left although v characteristicSection.v_reach + currentStepSize=characteristicSection.v_reach-drivingCourse[end-1].v + pop!(drivingCourse) + pop!(accelerationSection.waypoints) + elseif drivingCourse[end].s>characteristicSection.s_end + currentStepSize = settings.stepSize / 10.0^cycle + pop!(drivingCourse) + pop!(accelerationSection.waypoints) + elseif drivingCourse[end].v==characteristicSection.v_reach + break + elseif drivingCourse[end].s==characteristicSection.s_end + break + else + error("ERROR at acceleration phase: With the velocity step method the while loop will be left although v v_reach=",characteristicSection.v_reach) end @@ -484,11 +591,21 @@ function addAccelerationPhaseUntilBraking!(characteristicSection::Characteristic (characteristicSection, drivingCourse)=addStartingPhase!(characteristicSection, drivingCourse, settings, train, allCs) end #if + # if the tail of the train is still located in a former characteristic section it has to be checked if its speed limit can be kept + formerSpeedLimits = detectFormerSpeedLimits(allCs, characteristicSection.id, drivingCourse[end], train.l_union) + #(formerSpeedLimits, s_cruisingBeforeAcceleration) = detectFormerSpeedLimits(allCs, characteristicSection.id, drivingCourse[end], train.l_union) + #if s_cruisingBeforeAcceleration > 0.0 + # (characteristicSection, drivingCourse)=addCruisingPhase!(characteristicSection, drivingCourse, s_cruisingBeforeAcceleration, settings, train, allCs, "cruisingBeforeAcceleration") + #else + # error("ERROR: cruisingBeforeAcceleration <=0.0 although it has to be >0.0 in CS ",csWithTrainHeadId) + #end + + #= 07/30 *** TODO # if the tail of the train is still in a former characteristic section it has to be checked if its speed limit can be kept formerSpeedLimits=[] if characteristicSection.id>1 && drivingCourse[end].s-train.l_union0.0 @@ -512,165 +629,92 @@ function addAccelerationPhaseUntilBraking!(characteristicSection::Characteristic end end end + =# if drivingCourse[end].v0.0 # as long as s_i + s_braking < s_CSend - while length(formerSpeedLimits)>0 && drivingCourse[end].v0.0 - push!(accelerationSection.waypoints, drivingCourse[end].i) - # traction effort and resisting forces (in N): drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, settings.massModel, allCs, accelerationSection.type)) - #07/16 drivingCourse[end].F_T=calculateTractiveEffort(drivingCourse[end].v, train.tractiveEffortArray) - #07/16 drivingCourse[end].F_Rt=calculateTractionUnitResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Rw=calculateWagonsResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Runion=drivingCourse[end].F_Rt+drivingCourse[end].F_Rw - #07/16 drivingCourse[end].F_Rp=calculatePathResistance(drivingCourse[end].s, settings.massModel, train, allCs) - #07/16 drivingCourse[end].F_R=drivingCourse[end].F_Runion+drivingCourse[end].F_Rp # acceleration (in m/s^2): drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train.m_union/train.ξ_union if drivingCourse[end].a==0.0 - error("ERROR: a=0.0 m/s^2 in the acceleration phase ! with F_T=",drivingCourse[end].F_T," F_Rt=",drivingCourse[end].F_Rt," F_Rw=",drivingCourse[end].F_Rw," F_Rp=",drivingCourse[end].F_Rp) + error("ERROR: a=0 m/s^2 in the acceleration phase ! with F_T=",drivingCourse[end].F_T," F_Rt=",drivingCourse[end].F_Rt," F_Rw=",drivingCourse[end].F_Rw," F_Rp=",drivingCourse[end].F_Rp) end - # creating the next waypoint - push!(drivingCourse, Waypoint()) - drivingCourse[end].i=drivingCourse[end-1].i+1 # identifier + # create the next waypoint + push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, characteristicSection.id)) + push!(accelerationSection.waypoints, drivingCourse[end].i) - # calculate s, t, v, E - if settings.stepVariable=="s in m" # distance step method - drivingCourse[end].Δs=currentStepSize # step size (in m) - if ((drivingCourse[end-1].v/drivingCourse[end-1].a)^2+2*drivingCourse[end].Δs/drivingCourse[end-1].a)<0.0 || (drivingCourse[end-1].v^2+2*drivingCourse[end].Δs*drivingCourse[end-1].a)<0.0 # checking if the parts of the following square roots will be <0.0 - error("ERROR: The train stops during the acceleration phase in CS",characteristicSection.id," m because the tractive effort is lower than the resistant forces.", - " Before the stop the last point has the values s=",drivingCourse[end-1].s," v=",drivingCourse[end-1].v," m/s a=",drivingCourse[end-1].a," m/s^2", - " F_T=",drivingCourse[end-1].F_T," N F_Rt=",drivingCourse[end-1].F_Rt," N F_Rw=",drivingCourse[end-1].F_Rw," N F_Rp=",drivingCourse[end-1].F_Rp," N.") - end - drivingCourse[end].Δt=sign(drivingCourse[end-1].a)*sqrt((drivingCourse[end-1].v/drivingCourse[end-1].a)^2+2*drivingCourse[end].Δs/drivingCourse[end-1].a)-drivingCourse[end-1].v/drivingCourse[end-1].a # step size (in s) - drivingCourse[end].Δv=sqrt(drivingCourse[end-1].v^2+2*drivingCourse[end].Δs*drivingCourse[end-1].a)-drivingCourse[end-1].v # step size (in m/s) - elseif settings.stepVariable=="t in s" # time step method - drivingCourse[end].Δt=currentStepSize # step size (in s) - drivingCourse[end].Δs=drivingCourse[end].Δt*(2*drivingCourse[end-1].v+drivingCourse[end].Δt*drivingCourse[end-1].a)/2 # step size (in m) - drivingCourse[end].Δv=drivingCourse[end].Δt*drivingCourse[end-1].a # step size (in m/s) - elseif settings.stepVariable=="v in m/s" # velocity step method - drivingCourse[end].Δv=currentStepSize*sign(drivingCourse[end-1].a) # step size (in m/s) - drivingCourse[end].Δs=((drivingCourse[end-1].v+drivingCourse[end].Δv)^2-drivingCourse[end-1].v^2)/2/drivingCourse[end-1].a # step size (in m) - drivingCourse[end].Δt=drivingCourse[end].Δv/drivingCourse[end-1].a # step size (in s) - end #if - - drivingCourse[end].s=drivingCourse[end-1].s+drivingCourse[end].Δs # position (in m) - drivingCourse[end].t=drivingCourse[end-1].t+drivingCourse[end].Δt # point in time (in s) - drivingCourse[end].v=drivingCourse[end-1].v+drivingCourse[end].Δv # velocity (in m/s) - if drivingCourse[end].v<=0.0 - error("ERROR: The train stops during the acceleration phase in CS",characteristicSection.id," m because the tractive effort is lower than the resistant forces.", - " Before the stop the last point has the values s=",drivingCourse[end-1].s," v=",drivingCourse[end-1].v," m/s a=",drivingCourse[end-1].a," m/s^2", - " F_T=",drivingCourse[end-1].F_T," N F_Rt=",drivingCourse[end-1].F_Rt," N F_Rw=",drivingCourse[end-1].F_Rw," N F_Rp=",drivingCourse[end-1].F_Rp," N.") - end - drivingCourse[end].ΔW_T=drivingCourse[end-1].F_T*drivingCourse[end].Δs # mechanical work in this step (in Ws) - drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) - drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) - drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) - - while length(formerSpeedLimits)>0 && drivingCourse[end].s-train.l_union>=formerSpeedLimits[end][1] - pop!(formerSpeedLimits) - end - if length(formerSpeedLimits)>0 && drivingCourse[end].v>formerSpeedLimits[end][2] - while (drivingCourse[end].s>get(characteristicSection.behaviorSections, "cruisingBeforeAcceleration", accelerationSection).s_start) - pop!(drivingCourse) - end - if haskey(characteristicSection.behaviorSections, "cruisingBeforeAcceleration") - characteristicSection.t_total=characteristicSection.t_total-get(characteristicSection.behaviorSections, "cruisingBeforeAcceleration", BehaviorSection()).t_total # reducing the total running time (in s) - characteristicSection.E_total=characteristicSection.E_total-get(characteristicSection.behaviorSections, "cruisingBeforeAcceleration", BehaviorSection()).E_total # reducing the total energy consumption (in Ws) - delete!(characteristicSection.behaviorSections, "cruisingBeforeAcceleration") - end - - s_braking=max(0.0, ceil((characteristicSection.v_exit^2-drivingCourse[end].v^2)/2/train.a_braking, digits=10)) - s_cruisingBeforeAcceleration=min(characteristicSection.s_end-drivingCourse[end].s-s_braking, formerSpeedLimits[end][1]-(drivingCourse[end].s-train.l_union)) - - if s_cruisingBeforeAcceleration>0.0 - (characteristicSection, drivingCourse)=addCruisingPhase!(characteristicSection, drivingCourse, s_cruisingBeforeAcceleration, settings, train, allCs, "cruisingBeforeAcceleration") - else - println("Error: cruisingBeforeAcceleration <=0.0 ") - end - - if drivingCourse[end].s 0 # If the tail of the train is located in a former characteristic section with lower speed limit check if is is possible to accelerate as normal + (characteristicSection, drivingCourse, formerSpeedLimits, accelerationSection, endOfCsReached) = considerFormerSpeedLimits!(characteristicSection, drivingCourse, settings, train, allCs, formerSpeedLimits, accelerationSection) + if endOfCsReached return (characteristicSection, drivingCourse) end end - s_braking=max(0.0, ceil((characteristicSection.v_exit^2-drivingCourse[end].v^2)/2/train.a_braking, digits=10)) - end - # from here on the head and tail of the train are located in the current characteristic section - - # acceleration with all parts of the train in the current characteristic section - while drivingCourse[end].v0.0 # as long as s_i + s_braking < s_CSend - push!(accelerationSection.waypoints, drivingCourse[end].i) - - # traction effort and resisting forces (in N): - drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, settings.massModel, allCs, accelerationSection.type)) - #07/16 drivingCourse[end].F_T=calculateTractiveEffort(drivingCourse[end].v, train.tractiveEffortArray) - #07/16 drivingCourse[end].F_Rt=calculateTractionUnitResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Rw=calculateWagonsResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Runion=drivingCourse[end].F_Rt+drivingCourse[end].F_Rw - #07/16 drivingCourse[end].F_Rp=calculatePathResistance(drivingCourse[end].s, settings.massModel, train, allCs) - #07/16 drivingCourse[end].F_R=drivingCourse[end].F_Runion+drivingCourse[end].F_Rp - - # acceleration (in m/s^2): - drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train.m_union/train.ξ_union - if drivingCourse[end].a==0.0 - error("ERROR: a=0.0 m/s^2 in the acceleration phase ! with F_T=",drivingCourse[end].F_T," F_Rt=",drivingCourse[end].F_Rt," F_Rw=",drivingCourse[end].F_Rw," F_Rp=",drivingCourse[end].F_Rp) - end - - # creating the next waypoint - push!(drivingCourse, Waypoint()) - drivingCourse[end].i=drivingCourse[end-1].i+1 # identifier - - # calculate s, t, v, E - if settings.stepVariable=="s in m" # distance step method - drivingCourse[end].Δs=currentStepSize # step size (in m) - if ((drivingCourse[end-1].v/drivingCourse[end-1].a)^2+2*drivingCourse[end].Δs/drivingCourse[end-1].a)<0.0 || (drivingCourse[end-1].v^2+2*drivingCourse[end].Δs*drivingCourse[end-1].a)<0.0 # checking if the parts of the following square roots will be <0.0 - error("ERROR: The train stops during the acceleration phase in CS",characteristicSection.id," m because the tractive effort is lower than the resistant forces.", - " Before the stop the last point has the values s=",drivingCourse[end-1].s," v=",drivingCourse[end-1].v," m/s a=",drivingCourse[end-1].a," m/s^2", - " F_T=",drivingCourse[end-1].F_T," N F_Rt=",drivingCourse[end-1].F_Rt," N F_Rw=",drivingCourse[end-1].F_Rw," N F_Rp=",drivingCourse[end-1].F_Rp," N.") - end - drivingCourse[end].Δt=sign(drivingCourse[end-1].a)*sqrt((drivingCourse[end-1].v/drivingCourse[end-1].a)^2+2*drivingCourse[end].Δs/drivingCourse[end-1].a)-drivingCourse[end-1].v/drivingCourse[end-1].a # step size (in s) - drivingCourse[end].Δv=sqrt(drivingCourse[end-1].v^2+2*drivingCourse[end].Δs*drivingCourse[end-1].a)-drivingCourse[end-1].v # step size (in m/s) - elseif settings.stepVariable=="t in s" # time step method - drivingCourse[end].Δt=currentStepSize # step size (in s) - drivingCourse[end].Δs=drivingCourse[end].Δt*(2*drivingCourse[end-1].v+drivingCourse[end].Δt*drivingCourse[end-1].a)/2 # step size (in m) - drivingCourse[end].Δv=drivingCourse[end].Δt*drivingCourse[end-1].a # step size (in m/s) - elseif settings.stepVariable=="v in m/s" # velocity step method - drivingCourse[end].Δv=currentStepSize*sign(drivingCourse[end-1].a) # step size (in m/s) - drivingCourse[end].Δs=((drivingCourse[end-1].v+drivingCourse[end].Δv)^2-drivingCourse[end-1].v^2)/2/drivingCourse[end-1].a # step size (in m) - drivingCourse[end].Δt=drivingCourse[end].Δv/drivingCourse[end-1].a # step size (in s) - end #if - - drivingCourse[end].s=drivingCourse[end-1].s+drivingCourse[end].Δs # position (in m) - drivingCourse[end].t=drivingCourse[end-1].t+drivingCourse[end].Δt # point in time (in s) - drivingCourse[end].v=drivingCourse[end-1].v+drivingCourse[end].Δv # velocity (in m/s) - drivingCourse[end].ΔW_T=drivingCourse[end-1].F_T*drivingCourse[end].Δs # mechanical work in this step (in Ws) - drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) - drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) - drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) - - s_braking=max(0.0, ceil((characteristicSection.v_exit^2-drivingCourse[end].v^2)/2/train.a_braking, digits=10)) + s_braking=max(0.0, ceil((characteristicSection.v_exit^2-drivingCourse[end].v^2)/2/train.a_braking, digits=approximationLevel)) end #while - # checking which limit was reached and adjusting the currentStepSize for the next cycle + # check which limit was reached and adjust the currentStepSize for the next cycle + if cycle < approximationLevel+1 + if drivingCourse[end].v<=0.0 + currentStepSize = settings.stepSize / 10.0^cycle + + elseif drivingCourse[end].s +s_braking > characteristicSection.s_end + currentStepSize = settings.stepSize / 10.0^cycle + + elseif drivingCourse[end].v>characteristicSection.v_reach + if settings.stepVariable=="v in m/s" + currentStepSize= characteristicSection.v_reach-drivingCourse[end-1].v + else + currentStepSize = settings.stepSize / 10.0^cycle + end + + elseif drivingCourse[end].s==characteristicSection.s_end + break + + elseif drivingCourse[end].v==characteristicSection.v_reach + break + + else + error("ERROR at acceleration until braking phase: With the step variable ",settings.stepVariable," the while loop will be left although vcharacteristicSection.v_reach + pop!(drivingCourse) + pop!(accelerationSection.waypoints) + elseif drivingCourse[end].s + s_braking > characteristicSection.s_end + pop!(drivingCourse) + pop!(accelerationSection.waypoints) + else + + end + end + + #= 08/23 +++ old + # check which limit was reached and adjust the currentStepSize for the next cycle if drivingCourse[end].v<=0.0 if cycle<3 currentStepSize=currentStepSize/10.0 @@ -749,10 +793,12 @@ function addAccelerationPhaseUntilBraking!(characteristicSection::Characteristic else println("FEHLER: Beim Beschleunigungs-Brems-Abschnitt!") end #if + =# end #for - push!(accelerationSection.waypoints, drivingCourse[end].i) + # 08/23 +++ old push!(accelerationSection.waypoints, drivingCourse[end].i) + # calculation the accumulated acceleration section information accelerationSection.v_exit=drivingCourse[end].v # exit speed (in m/s) @@ -780,51 +826,126 @@ function addCruisingPhase!(characteristicSection::CharacteristicSection, driving cruisingSection.s_start=drivingCourse[end].s # first position (in m) cruisingSection.s_end=min(drivingCourse[end].s+s_cruising, characteristicSection.s_end) # last position (in m) cruisingSection.v_entry=drivingCourse[end].v # entry speed (in m/s) + push!(cruisingSection.waypoints, drivingCourse[end].i) - if settings.stepVariable=="v in m/s" # instead of velocity steps distance steps are used because phase there should not be velocity steps in the cruising - currentStepSize=10 # in m - else - currentStepSize=settings.stepSize - end - while drivingCourse[end].s0.0 + # traction effort and resisting forces (in N) + drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, settings.massModel, allCs, "cruising")) # TODO: or give cruisingSection.type instead of "cruising"? + + if drivingCourse[end].F_T>=drivingCourse[end].F_R + drivingCourse[end].a=0.0 # acceleration (in m/s^2) + + push!(drivingCourse, Waypoint()) + drivingCourse[end].i=drivingCourse[end-1].i+1 # incrementing the number of the waypoint push!(cruisingSection.waypoints, drivingCourse[end].i) - # traction effort and resisting forces (in N) - drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, settings.massModel, allCs, "cruising")) # TODO: or give cruisingSection.type instead of "cruising"? - #07/16 drivingCourse[end].F_Rt=calculateTractionUnitResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Rw=calculateWagonsResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Runion=drivingCourse[end].F_Rt+drivingCourse[end].F_Rw - #07/16 drivingCourse[end].F_Rp=calculatePathResistance(drivingCourse[end].s, settings.massModel, train, allCs) - #07/16 drivingCourse[end].F_R=drivingCourse[end].F_Runion+drivingCourse[end].F_Rp - #07/16 drivingCourse[end].F_T=min(max(0.0, drivingCourse[end].F_R), calculateTractiveEffort(drivingCourse[end].v, train.tractiveEffortArray)) + # calculate s, t, v, E + drivingCourse[end].Δs=min(s_cruising, characteristicSection.s_end-drivingCourse[end-1].s) # step size (in m) + drivingCourse[end].Δt=drivingCourse[end].Δs/drivingCourse[end-1].v # step size (in s) + drivingCourse[end].Δv=0.0 # step size (in m/s) + # TODO moveAStep can not be used at the moment because of 1/a in the formulars. It has to be changed and then used with stepVariable="s in m", stepSize=min(s_cruising, characteristicSection.s_end-drivingCourse[end-1].s) -> see the three lines above + + drivingCourse[end].s=drivingCourse[end-1].s+drivingCourse[end].Δs # position (in m) + drivingCourse[end].t=drivingCourse[end-1].t+drivingCourse[end].Δt # point in time (in s) + drivingCourse[end].v=drivingCourse[end-1].v # velocity (in m/s) + + drivingCourse[end].ΔW_T=drivingCourse[end-1].F_T*drivingCourse[end].Δs # mechanical work in this step (in Ws) + drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) + drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) + drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) - if drivingCourse[end].F_T>=drivingCourse[end].F_R - drivingCourse[end].a=0.0 # acceleration (in m/s^2) + else # the tractive effort is lower than the resisiting forces and the train has use the highest possible effort to try to stay at v_reach + currentStepSize=settings.stepSize - push!(drivingCourse, Waypoint()) - drivingCourse[end].i=drivingCourse[end-1].i+1 # incrementing the number of the waypoint + for cycle in 1:approximationLevel+1 # first cycle with normal step size followed by cycles with reduced step size depending on the level of approximation + while drivingCourse[end].v<=characteristicSection.v_reach && drivingCourse[end].s0.0 # TODO: <= v_reach was inserted -> probably needed for homogeneous strip - # calculate s, t, v, E - drivingCourse[end].Δs=min(s_cruising, characteristicSection.s_end-drivingCourse[end-1].s) # step size (in m) - drivingCourse[end].Δt=drivingCourse[end].Δs/drivingCourse[end-1].v # step size (in s) - drivingCourse[end].Δv=0.0 # step size (in m/s) + # traction effort and resisting forces (in N) + drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, settings.massModel, allCs, "cruising")) - drivingCourse[end].s=drivingCourse[end-1].s+drivingCourse[end].Δs # position (in m) - drivingCourse[end].t=drivingCourse[end-1].t+drivingCourse[end].Δt # point in time (in s) - drivingCourse[end].v=drivingCourse[end-1].v # velocity (in m/s) + # acceleration (in m/s^2): + drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train.m_union/train.ξ_union + if drivingCourse[end].a==0.0 + # TODO: this part is important for mass stip + end - drivingCourse[end].ΔW_T=drivingCourse[end-1].F_T*drivingCourse[end].Δs # mechanical work in this step (in Ws) - drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) - drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) - drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) - else + # create the next waypoint + push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, characteristicSection.id)) + push!(cruisingSection.waypoints, drivingCourse[end].i) + + #= TODO: the following has probably to be considered with homogeneous strip: + if length(formerSpeedLimits) > 0 # If the tail of the train is located in a former characteristic section with lower speed limit check if is is possible to accelerate as normal + (characteristicSection, drivingCourse, formerSpeedLimits, cruisingSection, endOfCsReached) = considerFormerSpeedLimits!(characteristicSection, drivingCourse, settings, train, allCs, formerSpeedLimits, accelerationSection) + + if endOfCsReached + return (characteristicSection, drivingCourse) + end #if + end #if + =# + end #while + + # check which limit was reached and adjust the currentStepSize for the next cycle + if cycle < approximationLevel+1 + if drivingCourse[end].v<=0.0 + currentStepSize = settings.stepSize / 10.0^cycle + + elseif drivingCourse[end].s>characteristicSection.s_end + if settings.stepVariable == "s in m" + currentStepSize=characteristicSection.s_end-drivingCourse[end-1].s + else + currentStepSize = settings.stepSize / 10.0^cycle + end + + elseif drivingCourse[end].v>characteristicSection.v_reach # copied from addAccelerationPhase. TODO is it necessary for homogeneous strip? + if settings.stepVariable=="v in m/s" + currentStepSize=characteristicSection.v_reach-drivingCourse[end-1].v + else + currentStepSize = settings.stepSize / 10.0^cycle + end + + elseif drivingCourse[end].s==characteristicSection.s_end + break + + #elseif drivingCourse[end].v==characteristicSection.v_reach # copied from addAccelerationPhase. TODO should it be used otherwise for homogeneous strip? + # break + + else # TODO copied from addAccelerationPhase -> probably not needed here !? + error("ERROR at cruising phase: With the step variable ",settings.stepVariable," the while loop will be left although vcharacteristicSection.v_reach # copied from addAccelerationPhase. TODO is it necessary for homogeneous strip? + pop!(drivingCourse) + pop!(cruisingSection.waypoints) + elseif drivingCourse[end].s>characteristicSection.s_end + drivingCourse[end].s=characteristicSection.s_end # rounding s down to s_end + else + + end + end + end #for + + #= + while drivingCourse[end].s0.0 drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train.m_union/train.ξ_union + # create the next waypoint + push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, characteristicSection.id)) + push!(cruisingSection.waypoints, drivingCourse[end].i) + + #= # creating the next waypoint push!(drivingCourse, Waypoint()) drivingCourse[end].i=drivingCourse[end-1].i+1 # identifier + push!(cruisingSection.waypoints, drivingCourse[end].i) # calculate s, t, v, E if settings.stepVariable=="s in m" ||settings.stepVariable=="v in m/s" # instead of velocity steps distance steps are used because phase there should not be velocity steps in the cruising @@ -846,6 +967,10 @@ function addCruisingPhase!(characteristicSection::CharacteristicSection, driving drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) + =# + + + # 08/31 +++ TODO: hier lassen oder lieber hinter die Schleife? if drivingCourse[end].s>cruisingSection.s_end if settings.stepVariable=="s in m" || settings.stepVariable=="v in m/s" # instead of velocity steps distance steps are used because phase there should not be velocity steps in the cruising currentStepSize=cruisingSection.s_end-drivingCourse[end-1].s @@ -858,21 +983,23 @@ function addCruisingPhase!(characteristicSection::CharacteristicSection, driving break else if drivingCourse[end].v<=0.0 - if currentStepSize>settings.stepSize/100.0 - currentStepSize=currentStepSize/10.0 + if currentStepSize > settings.stepSize/10^approximationLevel + currentStepSize = currentStepSize/10.0 else - error("ERROR: The train stops during the acceleration phase in CS",characteristicSection.id," m because the tractive effort is lower than the resistant forces.", + + error("ERROR: The train stops during the cruising phase in CS",characteristicSection.id," m because the tractive effort is lower than the resistant forces.", " Before the stop the last point has the values s=",drivingCourse[end-1].s," v=",drivingCourse[end-1].v," m/s a=",drivingCourse[end-1].a," m/s^2", " F_T=",drivingCourse[end-1].F_T," N F_Rt=",drivingCourse[end-1].F_Rt," N F_Rw=",drivingCourse[end-1].F_Rw," N F_Rp=",drivingCourse[end-1].F_Rp," N.") end pop!(drivingCourse) - pop!(accelerationSection.waypoints) + pop!(cruisingSection.waypoints) end end - end - end #while + end #while + =# + end - push!(cruisingSection.waypoints, drivingCourse[end].i) + # 08/24 old push!(cruisingSection.waypoints, drivingCourse[end].i) # calculation the accumulated cruising section information cruisingSection.v_exit=drivingCourse[end].v # exit speed (in m/s) @@ -898,25 +1025,24 @@ function addCoastingPhaseUntilBraking!(characteristicSection::CharacteristicSect coastingSection.type="coasting" # type of behavior section coastingSection.s_start=drivingCourse[end].s # first position (in m) coastingSection.v_entry=drivingCourse[end].v # entry speed (in m/s) + push!(coastingSection.waypoints, drivingCourse[end].i) currentStepSize=settings.stepSize # initializing the step size that can be reduced near intersections - for cycle in 1:3 # first cycle with normal step size, second cycle with reduced step size, third cycle with more reduced step size - s_braking=ceil((characteristicSection.v_exit^2-drivingCourse[end].v^2)/2/train.a_braking, digits=10) - while drivingCourse[end].v>characteristicSection.v_exit && drivingCourse[end].v<=characteristicSection.v_reach && (drivingCourse[end].s+s_braking)characteristicSection.v_exit && drivingCourse[end].v<=characteristicSection.v_reach && drivingCourse[end].s + s_braking < characteristicSection.s_end # as long as s_i + s_braking < s_CSend # traction effort and resisting forces (in N): drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, settings.massModel, allCs, coastingSection.type)) - #07/16 drivingCourse[end].F_T=0 - #07/16 drivingCourse[end].F_Rt=calculateTractionUnitResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Rw=calculateWagonsResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Runion=drivingCourse[end].F_Rt+drivingCourse[end].F_Rw - #07/16 drivingCourse[end].F_Rp=calculatePathResistance(drivingCourse[end].s, settings.massModel, train, allCs) - #07/16 drivingCourse[end].F_R=drivingCourse[end].F_Runion+drivingCourse[end].F_Rp # acceleration (in m/s^2): drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train.m_union/train.ξ_union + # creating the next waypoint + push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, settings.stepSize, characteristicSection.id)) + push!(coastingSection.waypoints, drivingCourse[end].i) + + #= 08/24 old: # creating the next waypoint push!(drivingCourse, Waypoint()) drivingCourse[end].i=drivingCourse[end-1].i+1 # identifier @@ -961,11 +1087,81 @@ function addCoastingPhaseUntilBraking!(characteristicSection::CharacteristicSect drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) + =# s_braking=ceil((characteristicSection.v_exit^2-drivingCourse[end].v^2)/2/train.a_braking) - end # while + end # while - # checking which limit was reached and adjusting the currentStepSize for the next cycle + # check which limit was reached and adjust the currentStepSize for the next cycle + if cycle < approximationLevel+1 + if drivingCourse[end].s + s_braking > characteristicSection.s_end + currentStepSize = settings.stepSize / 10.0^cycle + + elseif drivingCourse[end].v < characteristicSection.v_exit # TODO: if accelereation and coasting functions will be combined this case is only for coasting + currentStepSize = settings.stepSize / 10.0^cycle + + elseif drivingCourse[end].v > characteristicSection.v_reach + if settings.stepVariable=="v in m/s" + currentStepSize = characteristicSection.v_reach-drivingCourse[end-1].v + else + currentStepSize = settings.stepSize / 10.0^cycle + end + elseif drivingCourse[end].s + s_braking == characteristicSection.s_end + break + + elseif drivingCourse[end].v == characteristicSection.v_exit + break + + else + # TODO: not needed. just for testing + error("ERROR at coasting until braking phase: With the step variable ",settings.stepVariable," the while loop will be left although v characteristicSection.s_end + # delete last waypoint becaus it went to far + pop!(drivingCourse) + pop!(coastingSection.waypoints) + + elseif drivingCourse[end].v > characteristicSection.v_reach # 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 + # while coasting the train brakes to hold v_reach (only one waypoint in the end of coasting is calculated like cruising at v_reach) + drivingCourse[end-1].a=0.0 + s_braking=ceil((characteristicSection.v_exit^2-drivingCourse[end-1].v^2)/2/train.a_braking) + + # recalculate s, t, v, E + #drivingCourse[end].Δs= characteristicSection.s_end-drivingCourse[end-1].s - s_braking # step size (in m) # TODO: the coasting section is currently realised with using distance steps. For example t_braking could also be used + drivingCourse[end].Δs=min(currentStepSize, characteristicSection.s_end-(drivingCourse[end-1].s+s_braking)) # TODO: if settings.stepVariable=="s in m" + drivingCourse[end].Δt=drivingCourse[end].Δs/drivingCourse[end-1].v # step size (in s) + drivingCourse[end].Δv=0.0 # step size (in m/s) + + drivingCourse[end].s=drivingCourse[end-1].s+drivingCourse[end].Δs # position (in m) + drivingCourse[end].t=drivingCourse[end-1].t+drivingCourse[end].Δt # point in time (in s) + drivingCourse[end].v=drivingCourse[end-1].v # velocity (in m/s) + + drivingCourse[end].ΔW_T=drivingCourse[end-1].F_T*drivingCourse[end].Δs # mechanical work in this step (in Ws) + # =0.0 + drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) + # =drivingCourse[end-1].W_T + drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) + # =0.0 + drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) + # =drivingCourse[end-1].E + + else + + end + end + + #= 08/24 old and new + # check which limit was reached and adjust the currentStepSize for the next cycle if (drivingCourse[end].s+s_braking)>characteristicSection.s_end if cycle<3 currentStepSize=currentStepSize/10.0 @@ -1003,7 +1199,40 @@ function addCoastingPhaseUntilBraking!(characteristicSection::CharacteristicSect pop!(coastingSection.waypoints) end elseif drivingCourse[end].v>characteristicSection.v_reach - println("WARNING: in the coasting phase v=",drivingCourse[end].v," gets higher than v_reach=",characteristicSection.v_reach," . That should not happen!") + if drivingCourse[end].v > characteristicSection.v_reach # if the train gets to fast it has to brake + if settings.stepVariable=="s in m" # distance step method + # TODO + elseif settings.stepVariable=="t in s" # time step method + # TODO + elseif settings.stepVariable=="v in m/s" # velocity step method + drivingCourse[end].v=characteristicSection.v_reach + drivingCourse[end].Δv=characteristicSection.v_reach-drivingCourse[end-1].v # step size (in m/s) + if drivingCourse[end].Δv==0.0 + drivingCourse[end-1].a=0.0 + if settings.stepVariable=="s in m" # || settings.stepVariable=="v in m/s" || settings.stepVariable=="t in s" + drivingCourse[end].Δs=min(currentStepSize, characteristicSection.s_end-(drivingCourse[end-1].s+s_braking)) + drivingCourse[end].Δt=drivingCourse[end].Δs/drivingCourse[end-1].v + elseif settings.stepVariable=="v in m/s" || settings.stepVariable=="t in s" # TODO: the coasting section is currently done with using distance steps. For example t_braking could also be used + drivingCourse[end].Δs=min(10, characteristicSection.s_end-(drivingCourse[end-1].s+s_braking)) + drivingCourse[end].Δt=drivingCourse[end].Δs/drivingCourse[end-1].v + end + else + drivingCourse[end].Δs=((drivingCourse[end-1].v+drivingCourse[end].Δv)^2-drivingCourse[end-1].v^2)/2/drivingCourse[end-1].a # step size (in m) + drivingCourse[end].Δt=drivingCourse[end].Δv/drivingCourse[end-1].a + end + end #if + + + drivingCourse[end].s=drivingCourse[end-1].s+drivingCourse[end].Δs # position (in m) + drivingCourse[end].t=drivingCourse[end-1].t+drivingCourse[end].Δt # point in time (in s) + drivingCourse[end].ΔW_T=drivingCourse[end-1].F_T*drivingCourse[end].Δs # mechanical work in this step (in Ws) + drivingCourse[end].W_T=drivingCourse[end-1].W_T+drivingCourse[end].ΔW_T # mechanical work (in Ws) + drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) + drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) + end + + + # 08/24 old println("WARNING: in the coasting phase v=",drivingCourse[end].v," gets higher than v_reach=",characteristicSection.v_reach," . That should not happen!") elseif (drivingCourse[end].s+s_braking)==characteristicSection.s_end # there is a combination of coasting and braking for reaching characteristicSection.s_end. Coasting will stop here an braking will follow. break @@ -1022,9 +1251,11 @@ function addCoastingPhaseUntilBraking!(characteristicSection::CharacteristicSect pop!(coastingSection.waypoints) end end #if + =# + end #for - push!(coastingSection.waypoints, drivingCourse[end].i) + # 08/24 old push!(coastingSection.waypoints, drivingCourse[end].i) # calculation the accumulated coasting section information coastingSection.v_exit=drivingCourse[end].v # exit speed (in m/s) @@ -1054,15 +1285,10 @@ function addBrakingPhase!(characteristicSection::CharacteristicSection, drivingC # traction effort and resisting forces (in N) drivingCourse[end]=Waypoint(calculateForces!(drivingCourse[end], train, massModel, allCs, brakingSection.type)) - #07/16 drivingCourse[end].F_Rt=calculateTractionUnitResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Rw=calculateWagonsResistance(drivingCourse[end].v, train) - #07/16 drivingCourse[end].F_Runion=drivingCourse[end].F_Rt+drivingCourse[end].F_Rw - #07/16 drivingCourse[end].F_Rp=calculatePathResistance(drivingCourse[end].s, massModel, train, allCs) - #07/16 drivingCourse[end].F_R=drivingCourse[end].F_Runion+drivingCourse[end].F_Rp - #07/16 drivingCourse[end].F_T=0.0 push!(drivingCourse, Waypoint()) drivingCourse[end].i=drivingCourse[end-1].i+1 # incrementing the number of the waypoint + push!(brakingSection.waypoints, drivingCourse[end].i) # refering from the breaking section to the last of its waypoints # calculate s, t, v drivingCourse[end].s=brakingSection.s_end # position (in m) @@ -1070,7 +1296,7 @@ function addBrakingPhase!(characteristicSection::CharacteristicSection, drivingC drivingCourse[end].Δs=drivingCourse[end].s-drivingCourse[end-1].s # step size (in m) drivingCourse[end].Δv=drivingCourse[end].v-drivingCourse[end-1].v # step size (in m/s) - drivingCourse[end-1].a=round((drivingCourse[end].v^2-drivingCourse[end-1].v^2)/2/drivingCourse[end].Δs, digits=10) # acceleration (in m/s^2) (rounding because it should not be less than a_braking + drivingCourse[end-1].a=round((drivingCourse[end].v^2-drivingCourse[end-1].v^2)/2/drivingCourse[end].Δs, digits=approximationLevel) # acceleration (in m/s^2) (rounding because it should not be less than a_braking) if drivingCourse[end-1].a=0.0 println("Warning: a_braking gets to high in CS ",characteristicSection.id, " with a=",drivingCourse[end-1].a ," > ",train.a_braking) end @@ -1082,7 +1308,6 @@ function addBrakingPhase!(characteristicSection::CharacteristicSection, drivingC drivingCourse[end].ΔE=drivingCourse[end].ΔW_T # energy consumption in this step (in Ws) drivingCourse[end].E=drivingCourse[end-1].E+drivingCourse[end].ΔE # energy consumption (in Ws) - push!(brakingSection.waypoints, drivingCourse[end].i) # refering from the breaking section to the last of its waypoints brakingSection.v_exit=drivingCourse[end].v # exit speed (in m/s) brakingSection.s_total=drivingCourse[end].Δs # total length (in m) brakingSection.t_total=drivingCourse[end].Δt # total running time (in s) diff --git a/src/OperationModes.jl b/src/OperationModes.jl index 0fc6538..c8bf3a0 100644 --- a/src/OperationModes.jl +++ b/src/OperationModes.jl @@ -35,7 +35,8 @@ function simulateMinimumRunningTime!(movingSection::MovingSection, settings::Set movingSection.characteristicSections[csId].t_total=0.0 if s_cruisingBeforeAcceleration == movingSection.characteristicSections[csId].s_total - (movingSection.characteristicSections[csId], drivingCourse)=addCruisingPhase!(movingSection.characteristicSections[csId], drivingCourse, s_cruisingBeforeAcceleration, settings, train, movingSection.characteristicSections, "cruisingBeforeAcceleration") + (movingSection.characteristicSections[csId], drivingCourse)=addCruisingPhase!(movingSection.characteristicSections[csId], drivingCourse, s_cruisingBeforeAcceleration, settings, train, movingSection.characteristicSections, "cruising") + # 09/06 "cruising" is used in EnergySaving and not cruisingBeforeAcceleration (movingSection.characteristicSections[csId], drivingCourse)=addCruisingPhase!(movingSection.characteristicSections[csId], drivingCourse, s_cruisingBeforeAcceleration, settings, train, movingSection.characteristicSections, "cruisingBeforeAcceleration") elseif s_cruising == movingSection.characteristicSections[csId].s_total (movingSection.characteristicSections[csId], drivingCourse)=addCruisingPhase!(movingSection.characteristicSections[csId], drivingCourse, s_cruising, settings, train, movingSection.characteristicSections, "cruising") elseif s_cruising > 0.01 # if the cruising section is longer than 1 cm (because of rounding issues not >0.0) @@ -91,6 +92,7 @@ function simulateMinimumEnergyConsumption(movingSectionMinimumRunningTime::Movin doMethod1=true doMethod2=true doCombinationOfMethods=true + #doCombinationOfMethods=false #create a new moving section for the minimum energy consumption movingSectionOriginal=MovingSection(movingSectionMinimumRunningTime) diff --git a/src/Preparation.jl b/src/Preparation.jl index 42368ac..846734a 100644 --- a/src/Preparation.jl +++ b/src/Preparation.jl @@ -102,8 +102,9 @@ function secureAccelerationBehavior!(movingSection::MovingSection, settings::Set if movingSection.characteristicSections[csId].v_entry