Skip to content

Instantly share code, notes, and snippets.

View Datseris's full-sized avatar
🐻
I am a bear.

George Datseris Datseris

🐻
I am a bear.
View GitHub Profile
using OrdinaryDiffEq, StaticArrays, BenchmarkTools
const σ, ρ, β = 10.0, 28.0, 8/3
mutable struct system1{T, F, J}
state::T
eom!::F
jacob::J
end
@Datseris
Datseris / double_pendulum_pyplot.py
Created October 3, 2017 13:37
DynamicalSystems.jl logo animation using Python
# -*- coding: utf-8 -*-
"""
===========================
The double pendulum problem
===========================
This animation illustrates the double pendulum problem.
"""
function f1(N::Int)
s = 0
for n = 1:N
n % 2 == 0 && (s += 2; continue)
s += 1
end
s
end
function f2(N::Int)
@Datseris
Datseris / pendulums.jl
Created May 7, 2018 09:31 — forked from cormullion/pendulums.jl
George's double pendulums
using DynamicalSystems, Luxor
function double_pendulum(u0=rand(4);
G=10.0, L1 = 1.0, L2 = 1.0, M1 = 1.0, M2 = 1.0)
@inline @inbounds function eom_dp!(du, state)
du[1] = state[2]
gm = 0.01
del_ = state[3] - state[1]
den1 = (M1 + M2)*L1 - M2*L1*cos(del_)*cos(del_)
du[2] = (M2*L1*state[2]*state[2]*sin(del_)*cos(del_) +
@Datseris
Datseris / helpful_figure_stuff.jl
Last active November 28, 2018 14:50
Various pieces of code that help me make nice figures.
# && Exporting to movie:
framerate = 5
anim = `ffmpeg -y -framerate $(framerate) -start_number 1 -i $(savename)_%d.png
-c:v libx264 -pix_fmt yuv420p -preset veryslow -profile:v baseline -level 3.0 $(savename).mp4`
run(anim)
# To reduce movie size, you can add the option:
`-b:v 2048k`
# lower number = lower size = lower quality
@Datseris
Datseris / windows_endline.jl
Created June 24, 2018 08:54
Change the end-line of all files from the "windows" one to the standard one.
cd(Pkg.dir("DynamicalBilliards"))
function rn(filename)
str = read(filename, String)
str = replace(str, "\r\n" => "\n")
write(filename, str)
end
function totalrn(path = pwd())
for f in readdir(path)
@Datseris
Datseris / axb_native.jl
Created July 7, 2018 16:43
code native for A*B with static arrays
Julia 0.7:
julia> @code_native A*B
.text
; Function * {
; Location: matrix_multiply.jl:9
pushq %rbp
movq %rsp, %rbp
; Function _mul; {
; Location: matrix_multiply.jl:75
@Datseris
Datseris / integrator_with_callback.jl
Created July 16, 2018 15:40
Integrator with callback
function dist(ds::CDS, d0, Ttr, T; diff_eq_kwargs=Dict(:abstol=>1e-14,
:reltol=>1e-14, :solver=>Vern9(), :maxiters=>1e9),
inittest=ChaosTools.inittest_default(dimension(ds)))
pinteg = parallel_integrator(ds,
@Datseris
Datseris / juno_color.jl
Last active July 25, 2018 09:58
Give default Juno color in types.
import TreeViews
struct DiffEqMock end
typecolor(x) = "<span class=\"syntax--support syntax--type syntax--julia\">$(x)</span>"
TreeViews.hastreeview(::DiffEqMock) = true
@Datseris
Datseris / old_vs_new_psos.jl
Created July 26, 2018 11:54
New poincare section using Roots and integrator stepping
const PSOS_ERROR =
"the Poincaré surface of section did not have any points!"
function poincaresos2(ds::CDS{IIP, S, D}, plane, tfinal = 1000.0;
direction = +1, Ttr::Real = 0.0, warning = true,
diffeq...) where {IIP, S, D}
integ = integrator(ds; diffeq...)
planecrossing = PlaneCrossing{D}(plane, direction > 0 )