Skip to content

Commit

Permalink
Merge pull request #1 from eth-vaw-glaciology/m3/up_2023
Browse files Browse the repository at this point in the history
Update for 2023
  • Loading branch information
mauro3 authored Nov 7, 2023
2 parents 367eb36 + 36e1afa commit 152ed1d
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 232 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: ['1.6']
julia-version: ['1.9']
julia-arch: [x64]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
16 changes: 3 additions & 13 deletions .github/workflows/Literate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,11 @@ jobs:

- uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'
arch: x64

- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest

- name: run Literate
run: QT_QPA_PLATFORM=offscreen julia --color=yes --project -e 'cd("scripts"); include("literate-script.jl")'
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ https://eth-vaw-glaciology.github.io/course-101-0250-00/

This builds on
https://github.com/eth-vaw-glaciology/course-101-0250-00-L6Testing.jl
which is as in [commit](https://github.com/eth-vaw-glaciology/course-101-0250-00-L8Documentation.jl/tree/as-course-101-0250-00-L6Testing.jl).

Then adds documentation via:
- doc-strings
- Literate.jl, see [literate-script.jl](scripts/literate-script.jl)
- Literate via Github Actions:
[Literate.yml](.github/workflows/Literate.yml)
- this auto generates the markdown-file (and figure)
[car_travels.md](scripts/md/car_travels.md) upon push to github
[car_travel.md](scripts/md/car_travel.md) upon push to github
23 changes: 8 additions & 15 deletions scripts/car_travels.jl → scripts/car_travel.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# # Car travel in 1D
#
# How a car travels back and forth between two locations.
#
# Note that a comment which is on a line by itself, will render as a markdown line and
# thus create a new "notebook block" after it.
# Thus many comments are preceded by `##` to avoid this.

using Plots

# On my computer GR, the default backend crashes Julia, thus this:
try
pyplot() # run with PyPlot.jl backend, if installed
catch
nothing # run with GR.jl backend
end

if !@isdefined plotyes
plotyes = true
end

"""
update_position(X, V, dir, dt, L)
Expand Down Expand Up @@ -45,7 +38,7 @@ Run the model.
"""
function car_travel_1D()
## Physical parameters
V = 43.0 # speed, km/h
V = 113.0 # speed, km/h
L = 200.0 # length of segment, km
dir = 1 # switch 1 = go right, -1 = go left
ttot = 16.0 # total time, h
Expand All @@ -58,16 +51,16 @@ function car_travel_1D()
## Time loop
for it = 2:nt
T[it] = T[it-1] + dt
X[it], dir = update_position(X[it-1], V, dir, dt, L)
X[it], dir = update_position(X[it - 1], V, dir, dt, L)
end
## Visualisation

return T, X
end

#-

## Only run this in an interactive session:
if plotyes
if isinteractive() # do not run this when including this script from other scripts
println("Running model")
T, X = car_travel_1D()
plot(T, X, markersize=5, xlabel="time, hrs", ylabel="distance, km", framestyle=:box, legend=:none)
Expand Down
2 changes: 1 addition & 1 deletion scripts/literate-script.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ using Literate

# directory where the markdown files are put
md_dir = joinpath(@__DIR__, "md")
Literate.markdown("car_travels.jl", md_dir, execute=true, documenter=false, credit=false)
Literate.markdown("car_travel.jl", md_dir, execute=true, documenter=false, credit=false)
Binary file removed scripts/md/2053175991.png
Binary file not shown.
109 changes: 0 additions & 109 deletions scripts/md/car_travels-5.svg

This file was deleted.

87 changes: 0 additions & 87 deletions scripts/md/car_travels.md

This file was deleted.

2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Test#, ReferenceTests, BSON

plotyes = false
include("../scripts/car_travels.jl")
include("../scripts/car_travel.jl")

## Unit tests
@testset "update_position" begin
Expand Down

0 comments on commit 152ed1d

Please sign in to comment.