2022-04-08 17:30:34 +02:00
|
|
|
#!/usr/bin/env julia
|
|
|
|
# -*- coding: UTF-8 -*-
|
2022-04-28 17:02:40 +02:00
|
|
|
# __author__ = "Max Kannenberg, Martin Scheidt"
|
2022-04-08 17:30:34 +02:00
|
|
|
# __copyright__ = "2020-2022"
|
|
|
|
# __license__ = "ISC"
|
2022-04-28 17:02:40 +02:00
|
|
|
__precompile__(true)
|
2022-04-08 17:30:34 +02:00
|
|
|
|
2022-05-04 16:53:58 +02:00
|
|
|
module TrainRuns
|
2021-10-13 16:49:42 +02:00
|
|
|
|
2022-05-04 16:34:17 +02:00
|
|
|
## loading standard library packages
|
2022-05-12 16:32:15 +02:00
|
|
|
using UUIDs, Dates, Statistics
|
2022-04-28 17:02:40 +02:00
|
|
|
## loading external packages
|
2022-05-12 16:50:27 +02:00
|
|
|
using YAML, JSONSchema, DataFrames
|
2022-05-04 16:34:17 +02:00
|
|
|
|
2022-06-02 12:32:00 +02:00
|
|
|
export
|
2022-05-04 16:34:17 +02:00
|
|
|
## Interface
|
2022-05-12 16:50:27 +02:00
|
|
|
trainrun, Train, Path, Settings
|
2022-05-12 16:32:15 +02:00
|
|
|
|
|
|
|
## global variables
|
|
|
|
global g = 9.80665 # acceleration due to gravity (in m/s^2)
|
2022-06-02 12:32:00 +02:00
|
|
|
global μ = 0.2 # friction as constant, TODO: implement as function
|
2022-05-12 16:32:15 +02:00
|
|
|
global Δv_air = 15.0/3.6 # coefficient for velocitiy difference between train and outdoor air (in m/s)
|
2022-01-18 13:39:51 +01:00
|
|
|
|
2022-04-28 17:02:40 +02:00
|
|
|
## include package files
|
|
|
|
include("types.jl")
|
2022-05-08 21:43:21 +02:00
|
|
|
include("constructors.jl")
|
2022-04-28 17:02:40 +02:00
|
|
|
include("formulary.jl")
|
2022-05-12 16:32:15 +02:00
|
|
|
include("calc.jl")
|
2022-04-28 17:02:40 +02:00
|
|
|
include("behavior.jl")
|
|
|
|
include("output.jl")
|
2022-01-19 01:40:48 +01:00
|
|
|
|
2022-05-04 16:34:17 +02:00
|
|
|
## main function
|
|
|
|
"""
|
2022-05-12 16:32:15 +02:00
|
|
|
trainrun(train::Train, path::Path, settings::Settings)
|
2022-05-04 16:34:17 +02:00
|
|
|
|
|
|
|
Calculate the running time of a `train` on a `path`.
|
|
|
|
The `settings` provides the choice of models for the calculation.
|
|
|
|
`settings` can be omitted. If so, a default is used.
|
|
|
|
The running time will be return in seconds.
|
|
|
|
|
|
|
|
# Examples
|
|
|
|
```julia-repl
|
2022-06-09 15:10:59 +02:00
|
|
|
julia> trainrun(train, path)[end,:t]
|
2022-05-04 16:34:17 +02:00
|
|
|
xxx.xx # in seconds
|
|
|
|
```
|
|
|
|
"""
|
2022-05-12 16:32:15 +02:00
|
|
|
function trainrun(train::Train, path::Path, settings=Settings()::Settings)
|
2022-05-04 16:34:17 +02:00
|
|
|
# prepare the input data
|
|
|
|
movingSection = determineCharacteristics(path, train, settings)
|
2022-06-02 12:32:00 +02:00
|
|
|
# settings.outputDetail == :verbose && println("The moving section has been prepared.")
|
2022-05-04 16:34:17 +02:00
|
|
|
|
|
|
|
# calculate the train run for oparation mode "minimum running time"
|
|
|
|
(movingSection, drivingCourse) = calculateMinimumRunningTime!(movingSection, settings, train)
|
2022-06-02 12:32:00 +02:00
|
|
|
# settings.outputDetail == :verbose && println("The driving course for the shortest running time has been calculated.")
|
2022-05-04 16:34:17 +02:00
|
|
|
|
|
|
|
# accumulate data and create an output dictionary
|
2022-06-03 18:11:28 +02:00
|
|
|
output = createOutput(settings, drivingCourse, movingSection[:pointsOfInterest])
|
2022-01-20 13:37:55 +01:00
|
|
|
|
2022-05-04 16:34:17 +02:00
|
|
|
return output
|
|
|
|
end # function trainrun
|
2021-10-13 16:49:42 +02:00
|
|
|
|
2022-05-04 16:53:58 +02:00
|
|
|
end # module TrainRuns
|