s-ccs / summerschool_simtech_2023

SimTech Summer School 2023
https://www.simtech-summerschool.de/
MIT License
5 stars 6 forks source link

Which code examples do we use? #1

Open uekerman opened 1 year ago

uekerman commented 1 year ago

For the testing and the CI block of the summer school, we would need two example codes. One that we use twice in the lecture as demo what to do (add tests, add CI). One that the participants then us twice to work on themselves.

For the SSE lecture, we used Python codes for both:

In theory, we could just convert these to Julia. It would, however, be nice to use the same examples in more lectures and exercises, for example to showcase how Pluto works or similar. Opinions?

behinger commented 1 year ago

ha! I was thinking this morning to use our own definition of mean - to make it more fun we could define our own number-type, but maybe this is too nerdy ;)

The second example is a diffusion solver. I think we have to define whether they should come up with their implementation themselves (need a sweatspot in difficulty to allow for bugs) - or we provide a bit more complex example.

behinger commented 1 year ago

just leaving this here for tomorrow, a new numerical type called FlipFlopFloat64

using Markdown
using InteractiveUtils

# ╔═╡ 35a9692b-52a3-4506-bcde-7d73c9c672dc
import Base: show

# ╔═╡ 5f95cf32-2533-4b0f-9639-d5079368672f

# ╔═╡ 837cc28f-e7af-4586-bde9-4d235c315b35
struct FlipFlopFloat <: Real
    n::Float64
    function FlipFlopFloat(val) 
        iseven(Int(round(val))) ? new(val) : new(-val)
    end
end

# ╔═╡ c814243e-2abf-11ee-3869-6d412c54cbfb
begin
import Base: +
+(n::FlipFlopFloat,m::FlipFlopFloat) = FlipFlopFloat(n.n + m.n)
end

# ╔═╡ 6afa12cb-b9e8-4783-b2f2-606c5e945810
FlipFlopFloat(3.0) + FlipFlopFloat(4)

# ╔═╡ aeb0f1f8-c3cf-40e1-85dd-717e52a29749
FlipFlopFloat.([1,2])

# ╔═╡ 96856181-0ea5-4f29-a9c0-4f66d8b735ee
a = FlipFlopFloat.(1:10)

# ╔═╡ e261ae24-bd58-4e24-9783-57aac6c3431a
sum(a)