From 4b6700612d035d6def1c5909485c67bb515bfad1 Mon Sep 17 00:00:00 2001 From: Max Kannenberg <95709892+MaxKannenberg@users.noreply.github.com> Date: Thu, 16 Dec 2021 16:54:27 +0100 Subject: [PATCH] Add an attribute to DataPoint to record the corresponding driving behavior --- Project.toml | 2 +- README.md | 11 ++++++++ src/MovingPhases.jl | 58 +++++++++++++++++++++++++++---------------- src/OperationModes.jl | 10 ++++++-- src/Output.jl | 18 +++++++------- src/types.jl | 6 +++-- 6 files changed, 70 insertions(+), 35 deletions(-) diff --git a/Project.toml b/Project.toml index 15c0270..c4da043 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TrainRun" uuid = "e4541106-d44c-4e00-b50b-ecdf479fcf92" authors = ["Max Kannenberg"] -version = "0.6.0" +version = "0.6.1" [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" diff --git a/README.md b/README.md index d7e36a5..1f8abc6 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,18 @@ train_run = calculateDrivingDynamics(train, running_path, settings) # History +## Version 0.6.1 + +Add an attribute to DataPoint to record the corresponding driving behavior + +- Add the attribute behavior to Datapoint in types.jl +- Attach the corresponding behavior to data points in MovingPhases.jl +- Attach the behavior "standStill" to the last data point of the driving course in OperationModes.jl +- Rework Output.jl for outputting the data points' behavior + + ## Version 0.6 + Refactor some of the mutable structs from types.jl as Dictionaries - Remove the mutable structs Train, Path, PathSection, Settings and MovingSection diff --git a/src/MovingPhases.jl b/src/MovingPhases.jl index 1648a41..92afcbb 100644 --- a/src/MovingPhases.jl +++ b/src/MovingPhases.jl @@ -268,8 +268,9 @@ function addStartingPhase!(CS::CharacteristicSection, drivingCourse::Vector{Data breakFreeSection.v_entry=drivingCourse[end].v # entry speed (in m/s) push!(breakFreeSection.dataPoints, drivingCourse[end].i) # list of containing data points + drivingCourse[end].behavior = breakFreeSection.type # traction effort and resisting forces (in N): - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "acceleration")) # currently the tractive effort is calculated like in the acceleration phase + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "acceleration") # currently the tractive effort is calculated like in the acceleration phase # acceleration (in m/s^2): drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train[:m_train]/train[:ξ_train] @@ -281,6 +282,7 @@ function addStartingPhase!(CS::CharacteristicSection, drivingCourse::Vector{Data # creating the next data point push!(drivingCourse, moveAStep(drivingCourse[end], settings[:stepVariable], settings[:stepSize], CS.id)) + drivingCourse[end].behavior = breakFreeSection.type #= 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, DataPoint()) drivingCourse[end].i=drivingCourse[end-1].i+1 # incrementing the number of the data point @@ -337,7 +339,7 @@ function addAccelerationPhase!(CS::CharacteristicSection, drivingCourse::Vector{ calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "acceleration") if drivingCourse[end].F_T < drivingCourse[end].F_R (CS, drivingCourse)=addDiminishingPhase!(CS, drivingCourse, settings, train, CSs) - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "acceleration")) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "acceleration") end # 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 @@ -356,20 +358,22 @@ function addAccelerationPhase!(CS::CharacteristicSection, drivingCourse::Vector{ accelerationSection.s_entry=drivingCourse[end].s # first position (in m) accelerationSection.v_entry=drivingCourse[end].v # entry speed (in m/s) push!(accelerationSection.dataPoints, drivingCourse[end].i) + drivingCourse[end].behavior = accelerationSection.type currentStepSize=settings[:stepSize] # initializing the step size that can be reduced near intersections 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 drivingCourse[end].F_R # traction effort and resisting forces (in N) - # 11/22 drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type)) + # 11/22 calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type) # acceleration (in m/s^2): drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train[:m_train]/train[:ξ_train] # create the next data point push!(drivingCourse, moveAStep(drivingCourse[end], settings[:stepVariable], currentStepSize, CS.id)) + drivingCourse[end].behavior = accelerationSection.type push!(accelerationSection.dataPoints, drivingCourse[end].i) - # drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type)) + # calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type) 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 @@ -379,7 +383,7 @@ function addAccelerationPhase!(CS::CharacteristicSection, drivingCourse::Vector{ end #if currentStepSize=settings[:stepSize] # initializing the step size that can be reduced near intersections end #if - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type)) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type) end #while # check which limit was reached and adjust the currentStepSize for the next cycle @@ -431,7 +435,7 @@ function addAccelerationPhase!(CS::CharacteristicSection, drivingCourse::Vector{ elseif drivingCourse[end].F_T <= drivingCourse[end].F_R (CS, drivingCourse)=addDiminishingPhase!(CS, drivingCourse, settings, train, CSs) - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type)) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type) else @@ -471,7 +475,7 @@ function addAccelerationPhaseUntilBraking!(CS::CharacteristicSection, drivingCou calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "acceleration") if drivingCourse[end].F_T < drivingCourse[end].F_R (CS, drivingCourse)=addDiminishingPhase!(CS, drivingCourse, settings, train, CSs) - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "acceleration")) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "acceleration") end # 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 @@ -485,6 +489,7 @@ function addAccelerationPhaseUntilBraking!(CS::CharacteristicSection, drivingCou accelerationSection.s_entry=drivingCourse[end].s # first position (in m) accelerationSection.v_entry=drivingCourse[end].v # entry speed (in m/s) push!(accelerationSection.dataPoints, drivingCourse[end].i) + drivingCourse[end].behavior = accelerationSection.type currentStepSize=settings[:stepSize] # initializing the step size that can be reduced near intersections 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 @@ -492,7 +497,7 @@ function addAccelerationPhaseUntilBraking!(CS::CharacteristicSection, drivingCou while drivingCourse[end].v < CS.v_target && drivingCourse[end].s+s_braking drivingCourse[end].F_R # as long as s_i + s_braking < s_CSend # 12/03 old with v>0 while drivingCourse[end].v < CS.v_target && drivingCourse[end].s+s_braking0.0 && drivingCourse[end].F_T > drivingCourse[end].F_R # as long as s_i + s_braking < s_CSend - #11/22 drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type)) + #11/22 calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type) # acceleration (in m/s^2): drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train[:m_train]/train[:ξ_train] @@ -502,8 +507,9 @@ function addAccelerationPhaseUntilBraking!(CS::CharacteristicSection, drivingCou # create the next data point push!(drivingCourse, moveAStep(drivingCourse[end], settings[:stepVariable], currentStepSize, CS.id)) + drivingCourse[end].behavior = accelerationSection.type push!(accelerationSection.dataPoints, drivingCourse[end].i) - # 12/03: was moved behind considerFormerSpeedLimits: drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type)) + # 12/03: was moved behind considerFormerSpeedLimits: calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type) 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 (CS, drivingCourse, formerSpeedLimits, accelerationSection, endOfCsReached) = considerFormerSpeedLimits!(CS, drivingCourse, settings, train, CSs, formerSpeedLimits, accelerationSection) @@ -511,7 +517,7 @@ function addAccelerationPhaseUntilBraking!(CS::CharacteristicSection, drivingCou return (CS, drivingCourse) end end - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type)) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type) s_braking=max(0.0, ceil((CS.v_exit^2-drivingCourse[end].v^2)/2/train[:a_braking], digits=approximationLevel)) end #while @@ -562,7 +568,7 @@ function addAccelerationPhaseUntilBraking!(CS::CharacteristicSection, drivingCou elseif drivingCourse[end].F_T <= drivingCourse[end].F_R (CS, drivingCourse)=addDiminishingPhase!(CS, drivingCourse, settings, train, CSs) - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type)) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, accelerationSection.type) else @@ -608,13 +614,14 @@ function addCruisingPhase!(CS::CharacteristicSection, drivingCourse::Vector{Data # 11/22: now it is at the end of the BS: cruisingSection.s_exit=min(drivingCourse[end].s+s_cruising, CS.s_exit) # last position (in m) cruisingSection.v_entry=drivingCourse[end].v # entry speed (in m/s) push!(cruisingSection.dataPoints, drivingCourse[end].i) + drivingCourse[end].behavior = cruisingSection.type # TODO: necessary? s_cruising=min(s_cruising, CS.s_exit-cruisingSection.s_entry) # traction effort and resisting forces (in N) calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "cruising") # TODO: or give cruisingSection.type instead of "cruising"? - # 11/05 old: drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "cruising")) # TODO: or give cruisingSection.type instead of "cruising"? + # 11/05 old: drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "cruising")) if settings[:massModel]=="homogeneous strip" && CS.id > 1 currentStepSize=settings[:stepSize] @@ -634,6 +641,7 @@ function addCruisingPhase!(CS::CharacteristicSection, drivingCourse::Vector{Data else push!(drivingCourse, moveAStep(drivingCourse[end], "s_cruising in m", train[:l_train]/(10.0^cycle), CS.id)) # TODO which step size should be used? end + drivingCourse[end].behavior = cruisingSection.type push!(cruisingSection.dataPoints, drivingCourse[end].i) # for testing @@ -686,7 +694,7 @@ function addCruisingPhase!(CS::CharacteristicSection, drivingCourse::Vector{Data elseif drivingCourse[end].F_T < drivingCourse[end].F_R (CS, drivingCourse)=addDiminishingPhase!(CS, drivingCourse, settings, train, CSs) - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "cruising")) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "cruising") # s_cruising=max(0.0, s_cruising-get(CS.behaviorSections, :diminishing, BehaviorSection()).length) @@ -707,6 +715,7 @@ function addCruisingPhase!(CS::CharacteristicSection, drivingCourse::Vector{Data # create the next data point push!(drivingCourse, moveAStep(drivingCourse[end], "s_cruising in m", s_cruisingRemaining, CS.id)) + drivingCourse[end].behavior = cruisingSection.type push!(cruisingSection.dataPoints, drivingCourse[end].i) end @@ -739,6 +748,7 @@ function addCoastingPhaseUntilBraking!(CS::CharacteristicSection, drivingCourse: coastingSection.s_entry=drivingCourse[end].s # first position (in m) coastingSection.v_entry=drivingCourse[end].v # entry speed (in m/s) push!(coastingSection.dataPoints, drivingCourse[end].i) + drivingCourse[end].behavior = coastingSection.type currentStepSize=settings[:stepSize] # initializing the step size that can be reduced near intersections # 08/24 old for cycle in 1:3 # first cycle with normal step size, second cycle with reduced step size, third cycle with more reduced step size @@ -746,13 +756,14 @@ function addCoastingPhaseUntilBraking!(CS::CharacteristicSection, drivingCourse: s_braking=ceil((CS.v_exit^2-drivingCourse[end].v^2)/2/train[:a_braking], digits=approximationLevel) while drivingCourse[end].v>CS.v_exit && drivingCourse[end].v<=CS.v_target && drivingCourse[end].s + s_braking < CS.s_exit # as long as s_i + s_braking < s_CSend # traction effort and resisting forces (in N): - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, coastingSection.type)) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, coastingSection.type) # acceleration (in m/s^2): drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train[:m_train]/train[:ξ_train] # creating the next data point push!(drivingCourse, moveAStep(drivingCourse[end], settings[:stepVariable], currentStepSize, CS.id)) + drivingCourse[end].behavior = coastingSection.type push!(coastingSection.dataPoints, drivingCourse[end].i) s_braking=ceil((CS.v_exit^2-drivingCourse[end].v^2)/2/train[:a_braking]) @@ -856,12 +867,14 @@ function addBrakingPhase!(CS::CharacteristicSection, drivingCourse::Vector{DataP brakingSection.s_exit=CS.s_exit # last position (in m) brakingSection.v_entry=drivingCourse[end].v # entry speed (in m/s) push!(brakingSection.dataPoints, drivingCourse[end].i) # refering from the breaking section to the first of its data points + drivingCourse[end].behavior = brakingSection.type # traction effort and resisting forces (in N) - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, brakingSection.type)) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, brakingSection.type) push!(drivingCourse, DataPoint()) - drivingCourse[end].i=drivingCourse[end-1].i+1 # incrementing the number of the data point + drivingCourse[end].i = drivingCourse[end-1].i+1 # incrementing the number of the data point + drivingCourse[end].behavior = brakingSection.type push!(brakingSection.dataPoints, drivingCourse[end].i) # refering from the breaking section to the last of its data points # calculate s, t, v @@ -911,12 +924,13 @@ function addBrakingPhaseStepwise!(CS::CharacteristicSection, drivingCourse::Vect brakingSection.s_entry=drivingCourse[end].s # first position (in m) brakingSection.v_entry=drivingCourse[end].v # entry speed (in m/s) push!(brakingSection.dataPoints, drivingCourse[end].i) # refering from the breaking section to the first of its data points + drivingCourse[end].behavior = brakingSection.type currentStepSize=settings[:stepSize] # initializing the step size that can be reduced near intersections velocityIsPositive=true while drivingCourse[end].v > CS.v_exit && drivingCourse[end].s < CS.s_exit && velocityIsPositive # traction effort and resisting forces (in N): - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, brakingSection.type)) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, brakingSection.type) # acceleration (in m/s^2): drivingCourse[end].a=train[:a_braking] @@ -932,6 +946,7 @@ function addBrakingPhaseStepwise!(CS::CharacteristicSection, drivingCourse::Vect end end push!(drivingCourse, moveAStep(drivingCourse[end], settings[:stepVariable], currentStepSize, CS.id)) + drivingCourse[end].behavior = brakingSection.type push!(brakingSection.dataPoints, drivingCourse[end].i) # s_braking=ceil((CS.v_exit^2-drivingCourse[end].v^2)/2/train[:a_braking]) @@ -982,7 +997,7 @@ end #function addBrakingPhaseStepwise! ## This function calculates the data points for diminishing run when using maximum tractive effort and still getting slower function addDiminishingPhase!(CS::CharacteristicSection, drivingCourse::Vector{DataPoint}, settings::Dict, train::Dict, CSs::Vector{CharacteristicSection}) - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "diminishing")) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "diminishing") if drivingCourse[end].F_T <= drivingCourse[end].F_R && drivingCourse[end].v > 0.0 && drivingCourse[end].s0.0 && drivingCourse[end].v<=CS.v_target && drivingCourse[end].s0.0 # as long as s_i + s_braking < s_CSend # 11/22 old without F_T<=F_R while drivingCourse[end].s+s_braking0.0 # as long as s_i + s_braking < s_CSend - #11/22 drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, diminishingSection.type)) + #11/22 calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, diminishingSection.type) # acceleration (in m/s^2): drivingCourse[end].a=(drivingCourse[end].F_T-drivingCourse[end].F_R)/train[:m_train]/train[:ξ_train] @@ -1010,10 +1025,11 @@ function addDiminishingPhase!(CS::CharacteristicSection, drivingCourse::Vector{D # create the next data point push!(drivingCourse, moveAStep(drivingCourse[end], settings[:stepVariable], currentStepSize, CS.id)) + drivingCourse[end].behavior = diminishingSection.type push!(diminishingSection.dataPoints, drivingCourse[end].i) s_braking=max(0.0, ceil((CS.v_exit^2-drivingCourse[end].v^2)/2/train[:a_braking], digits=approximationLevel)) - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, diminishingSection.type)) + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, diminishingSection.type) end #while # check which limit was reached and adjust the currentStepSize for the next cycle diff --git a/src/OperationModes.jl b/src/OperationModes.jl index 596ab14..de3f386 100644 --- a/src/OperationModes.jl +++ b/src/OperationModes.jl @@ -91,8 +91,11 @@ function calculateMinimumRunningTime!(movingSection::Dict, settings::Dict, train end =# end #for - # calculate the last data points resiting forces - drivingCourse[end]=DataPoint(calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "braking")) + # calculate the last data points resisting forces + calculateForces!(drivingCourse[end], train, settings[:massModel], CSs, "braking") + if drivingCourse[end].v == 0.0 + drivingCourse[end].behavior = "standStill" + end movingSection[:t] = drivingCourse[end].t # total running time (in s) movingSection[:E] = drivingCourse[end].E # total energy consumption (in Ws) @@ -274,6 +277,9 @@ function calculateMinimumEnergyConsumption(movingSectionMinimumRunningTime::Dict end #if doCombinationOfMethods end # while + if drivingCourseOriginal[end].v == 0.0 + drivingCourseOriginal[end].behavior = "standStill" + end println("t_recoveryAvailable=",movingSectionOriginal[:t_recoveryAvailable]) return (movingSectionOriginal, drivingCourseOriginal) diff --git a/src/Output.jl b/src/Output.jl index 3d03458..23c5ea9 100644 --- a/src/Output.jl +++ b/src/Output.jl @@ -56,9 +56,9 @@ function createOutputDict(settings::Dict, pathName::String, trainName::String, d row=[movingSection[:length], movingSection[:t], movingSection[:E]] push!(outputArray, row) # push row to outputArray elseif settings[:detailOfOutput]=="driving course" - push!(outputArray, ["i", "Δs (in m)", "s (in m)", "Δt (in s)","t (in s)","Δv (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)", "ΔW (in Ws)","W (in Ws)","ΔE (in Ws)","E (in Ws)","a (in m/s^2)"]) # push header to outputArray + push!(outputArray, ["i", "behavior", "Δs (in m)", "s (in m)", "Δt (in s)","t (in s)","Δv (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)", "ΔW (in Ws)","W (in Ws)","ΔE (in Ws)","E (in Ws)","a (in m/s^2)"]) # push header to outputArray for point in drivingCourse - row=[point.i, point.Δs, point.s, point.Δt, point.t, point.Δv, point.v, point.F_T, point.F_R, point.R_path, point.R_train, point.R_traction, point.R_consist, point.ΔW, point.W, point.ΔE, point.E, point.a] + row=[point.i, point.behavior, point.Δs, point.s, point.Δt, point.t, point.Δv, point.v, point.F_T, point.F_R, point.R_path, point.R_train, point.R_traction, point.R_consist, point.ΔW, point.W, point.ΔE, point.E, point.a] push!(outputArray, row) # push row to outputArray end end @@ -86,9 +86,9 @@ function createOutputDict(settings::Dict, pathName::String, trainName::String, d row=[movingSectionMinimumEnergyConsumption[:length], movingSectionMinimumEnergyConsumption[:t], movingSectionMinimumEnergyConsumption[:E]] push!(outputArrayMinimumEnergyConsumption, row) # push row to outputArrayMinimumEnergyConsumption elseif settings[:detailOfOutput]=="driving course" - push!(outputArrayMinimumEnergyConsumption, ["i", "Δs (in m)", "s (in m)", "Δt (in s)","t (in s)","Δv (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)", "ΔW (in Ws)","W (in Ws)","ΔE (in Ws)","E (in Ws)","a (in m/s^2)"]) # push header to outputArrayMinimumEnergyConsumption + push!(outputArrayMinimumEnergyConsumption, ["i", "behavior", "Δs (in m)", "s (in m)", "Δt (in s)","t (in s)","Δv (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)", "ΔW (in Ws)","W (in Ws)","ΔE (in Ws)","E (in Ws)","a (in m/s^2)"]) # push header to outputArrayMinimumEnergyConsumption for point in drivingCourseMinimumEnergyConsumption - row=[point.i, point.Δs, point.s, point.Δt, point.t, point.Δv, point.v, point.F_T, point.F_R, point.R_path, point.R_train, point.R_traction, point.R_consist, point.ΔW, point.W, point.ΔE, point.E, point.a] + row=[point.i, point.behavior, point.Δs, point.s, point.Δt, point.t, point.Δv, point.v, point.F_T, point.F_R, point.R_path, point.R_train, point.R_traction, point.R_consist, point.ΔW, point.W, point.ΔE, point.E, point.a] push!(outputArrayMinimumEnergyConsumption, row) # push row to outputArrayMinimumEnergyConsumption end end @@ -134,7 +134,7 @@ function createOutputCsv(settings::Dict, pathName::String, trainName::String, dr if settings[:detailOfOutput]=="minimal" header=outputDict[:outputArrayMinimumRunningTime][1] elseif settings[:detailOfOutput]=="driving course" - header=["i", "Delta s (in m)", "s (in m)", "Delta t (in s)","t (in s)","Delta v (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)"," Delta W (in Ws)","W (in Ws)","Delta E (in Ws)","E (in Ws)","a (in m/s^2)"] + header=["i", "behavior", "Delta s (in m)", "s (in m)", "Delta t (in s)","t (in s)","Delta v (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)"," Delta W (in Ws)","W (in Ws)","Delta E (in Ws)","E (in Ws)","a (in m/s^2)"] end for column in 1:length(outputDict[outputArray][1]) push!(infoColumns[column], header[column]) @@ -177,7 +177,7 @@ function createOutputCsv(settings::Dict, pathName::String, trainName::String, dr if settings[:detailOfOutput]=="minimal" header=outputDict[:outputArrayMinimumRunningTime][1] elseif settings[:detailOfOutput]=="driving course" - header=["i", "Delta s (in m)", "s (in m)", "Delta t (in s)","t (in s)","Delta v (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)"," Delta W (in Ws)","W (in Ws)","Delta E (in Ws)","E (in Ws)","a (in m/s^2)"] + header=["i", "behavior", "Delta s (in m)", "s (in m)", "Delta t (in s)","t (in s)","Delta v (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)"," Delta W (in Ws)","W (in Ws)","Delta E (in Ws)","E (in Ws)","a (in m/s^2)"] end for column in 1:length(outputDict[:outputArrayMinimumRunningTime][1]) @@ -215,7 +215,7 @@ function createOutputCsv(settings::Dict, pathName::String, trainName::String, dr if settings[:detailOfOutput]=="minimal" header=outputDict[:outputArrayMinimumRunningTime][1] elseif settings[:detailOfOutput]=="driving course" - header=["i", "Delta s (in m)", "s (in m)", "Delta t (in s)","t (in s)","Delta v (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)"," Delta W (in Ws)","W (in Ws)","Delta E (in Ws)","E (in Ws)","a (in m/s^2)"] + header=["i", "behavior", "Delta s (in m)", "s (in m)", "Delta t (in s)","t (in s)","Delta v (in m/s)","v (in m/s)","F_T (in N)","F_R (in N)","R_path (in N)","R_train (in N)","R_traction (in N)","R_consist (in N)"," Delta W (in Ws)","W (in Ws)","Delta E (in Ws)","E (in Ws)","a (in m/s^2)"] end for column in 1:length(outputDict[:outputArrayMinimumEnergyConsumption][1]) @@ -247,11 +247,11 @@ end #function createOutputCsv function printImportantValues(drivingCourse::Vector{DataPoint}) - println("i s in m v in km/h t in min a in m/s^2 F_R in k N F_T in k N E in k Wh") + println("i behavior s in m v in km/h t in min a in m/s^2 F_R in k N F_T in k N E in k Wh") for i in 1:length(drivingCourse) println(drivingCourse[i].i,". ",drivingCourse[i].s," ",drivingCourse[i].v*3.6," ",drivingCourse[i].t/60," ",drivingCourse[i].a," ",drivingCourse[i].F_R/1000," ",drivingCourse[i].F_T/1000," ",drivingCourse[i].E/3600/1000) end #for - println("i s in m v in km/h t in min a in m/s^2 F_R in k N F_T in k N E in k Wh") + println("i behavior s in m v in km/h t in min a in m/s^2 F_R in k N F_T in k N E in k Wh") end #function printImportantValues function printSectionInformation(movingSection::Dict) diff --git a/src/types.jl b/src/types.jl index 9d919c5..81476c9 100644 --- a/src/types.jl +++ b/src/types.jl @@ -6,6 +6,8 @@ export DataPoint, BehaviorSection, CharacteristicSection, EnergySavingModificati ## a data point is the smallest element of the driving course. One step of the step approach is between two data points mutable struct DataPoint i::Integer # identifier and counter variable of the dricing course + behavior::String # type of BehaviorSection the DataPoint ist part of ("breakFree", "clearing", "acceleration", "cruising", "diminishing", "coasting", "cruisingAfterCoasting","braking" or "standStill") + # a data point which is the last point of one BehaviorSection and the first point of the next BehaviorSection will be attached to the latter s::AbstractFloat # position (in m) Δs::AbstractFloat # step size (in m) t::AbstractFloat # point in time (in s) @@ -24,9 +26,9 @@ mutable struct DataPoint R_traction::AbstractFloat # traction unit resistance (in N) R_consist::AbstractFloat # set of wagons resistance (in N) end # mutable struct DataPoint -DataPoint()=DataPoint(0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) +DataPoint()=DataPoint(0, "", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) # tried to insert copy on 15.07.2021 copy(original::DataPoint)=DataPoint(original.i, original.s, original.Δs, original.t, original.Δt, original.v, original.Δv, original.a, original.W, original.ΔW, original.E, original.ΔE, original.F_T, original.F_R, original.R_path, original.R_train, original.R_traction, original.R_consist) -DataPoint(original::DataPoint)=DataPoint(original.i, original.s, original.Δs, original.t, original.Δt, original.v, original.Δv, original.a, original.W, original.ΔW, original.E, original.ΔE, original.F_T, original.F_R, original.R_path, original.R_train, original.R_traction, original.R_consist) +DataPoint(original::DataPoint)=DataPoint(original.i, original.behavior, original.s, original.Δs, original.t, original.Δt, original.v, original.Δv, original.a, original.W, original.ΔW, original.E, original.ΔE, original.F_T, original.F_R, original.R_path, original.R_train, original.R_traction, original.R_consist)