Skip to content

Instantly share code, notes, and snippets.

View ufechner7's full-sized avatar

Uwe Fechner ufechner7

View GitHub Profile
@ufechner7
ufechner7 / data.tar.xz
Last active November 28, 2021 18:00
Data to reproduce a bug in Impute.jl
This file has been truncated, but you can view the full file.
@ufechner7
ufechner7 / viewer.jl
Created January 14, 2017 15:14
GLVisualize example
using GLVisualize, GeometryTypes, Colors
using Reactive, GLAbstraction
window = glscreen()
timesignal = loop(linspace(0f0, 1f0, 360))
large_sphere = HyperSphere(Point3f0(0), 1f0)
rotation_angle = const_lift(*, timesignal, 2f0*pi)
rotation = map(rotationmatrix_z, rotation_angle)
@ufechner7
ufechner7 / Radau_Tether_01.py
Created November 16, 2016 16:09
Simulation of a point mass - spring damper system
# -*- coding: utf-8 -*-
"""
Tutorial example showing how to use the implicit solver Radau5DAE.
It simulates a falling mass.
"""
import numpy as np
import pylab as plt
from assimulo.problem import Implicit_Problem #Imports the problem formulation from Assimulo
from assimulo.solvers import Radau5DAE #Imports the solver IDA from Assimulo
@ufechner7
ufechner7 / CustomType.jl
Created March 13, 2016 12:53
Custom type for scalars and vectors in julia
# Custom type, that can store scalars of vectors in Julia
NumberOrVector = Union{Number, Vector}
# input data
type Project
p_el_nom::NumberOrVector # electrical generator power in kW
rel_drum_diameter::NumberOrVector # ratio of the drum diameter and the tether diameter
rpm_generator::NumberOrVector # nominal speed of the electrical machine
z_ref::NumberOrVector # reference height for wind profile law
from datetime import datetime
import time
def check_sleep(amount):
start = datetime.now()
time.sleep(amount)
end = datetime.now()
delta = end-start
return delta.seconds + delta.microseconds/1000000.
function check_sleep(amount)
start = time()
sleep(amount)
final = time()
delta = final - start
return delta
end
sum = 0.0
abs(check_sleep(0.020)-0.020) # precompile check_sleep
@ufechner7
ufechner7 / RealTime.jl
Created August 23, 2015 17:47
Test script for the realtime performance of Julia
using Winston
const SIMUL_DUR = 10.0 # simulation time in seconds
const PeriodTime = 20e-3 # period time for the simulation in seconds
const workload = 20000 # workload in vector additions/ multiplications per simulation step
const vec_size = 3
const cpu_usage = zeros(round(Int, SIMUL_DUR / PeriodTime)) # data array to log the cpu usage
const vec = zeros(vec_size, workload) # preallocate data array of 3D vectors
@ufechner7
ufechner7 / KPS3_v3.py
Last active August 29, 2015 14:18
Demo code to show the speed problem with record arrays in numba 0.18.
# -*- coding: utf-8 -*-
"""
Demo code, showing the problem with using record arrays with Numba 0.18.
I replaced just three of the elements of vec3 with a record array with three elements. The execution time
increases from 22us to 45 us.
Model of a kite-power system in implicit form: residual = f(y, yd, sw)
This model implements a 3D mass-spring system with reel-out. It uses five tether segments (the number can be
configured in the file Settings.py). The kite is modelled as additional mass at the end of the tether.
@ufechner7
ufechner7 / bench_rec_array.py
Created April 1, 2015 12:37
Comparing the speed of accessing record arrays and two dimensional arrays using numba
# -*- coding: utf-8 -*-
""" Accessing record arrays with numba 0.17 is 10 times slower than using two dimensional arrays. """
from numba import jit
import numpy as np
import time
V_WIND = 8.0
V_wind = 0 # (westwind, downwind direction to the east)
V_wind_gnd = 1
@ufechner7
ufechner7 / FastKPS_01.py
Created April 1, 2015 12:10
Implementation of a fast simulation core for kite power systems using numba and 2d arrays
# constants for accessing the array of scalars
ParamCD = 0
ParamCL = 1
Length = 2 # length of one tether segment at zero force
C_spring = 3 # spring constant of one tether segment
Damping = 4 # damping constant of one tether segment
Depower = 5
Steering = 6
Alpha_depower = 7
Alpha_zero = 8