Skip to content

Instantly share code, notes, and snippets.

View jw3126's full-sized avatar

Jan Weidner jw3126

  • Freiburg, Germany
View GitHub Profile
@jw3126
jw3126 / install.sh
Created November 12, 2018 10:23
Install EGSnrc
#!/bin/bash
###### tweakable parameters
EGS_SRC=$HOME/EGSnrc
CONFIG=linux.conf
COMPILE_USER_CODES=1
###### script implemention
export HEN_HOUSE=$EGS_SRC/HEN_HOUSE
export EGS_CONFIG=$HEN_HOUSE/specs/linux.conf
@jw3126
jw3126 / egs_parallel.sh
Created November 30, 2018 12:13
egs parallel
# install egs
# make tutor2pp
sudo apt install at
exb tutor2pp test1 tutor_data p=42
@jw3126
jw3126 / MakieSphericalHarmonics.jl
Created January 12, 2019 22:36
MakieSphericalHarmonics
using GSL
using Makie
struct Y
l::Int
m::Int
function Y(l,m)
@assert -l <= m <= l
new(l,m)
end
@jw3126
jw3126 / DirichletAnnulusApproxFun.jl
Last active January 23, 2019 08:17
DirichletAnnulusApproxFun.jl
using ApproxFun
using LinearAlgebra
using Interact
using Plots
a = 1.; b=5.
Ω = a..b
# Ω = Chebyshev(a..b)
r = Fun(identity, Ω)
Δ_rad = 𝒟^2 + 1.0/r * 𝒟
@jw3126
jw3126 / LibGit2.jl
Created April 27, 2019 14:46
LibGit2
using LibGit2
repo_path = "LibGit2TestRepo"
repo_url = "git@github.com:jw3126/LibGit2TestRepo.git"
rm(repo_path, recursive=true, force=true)
mkpath(path)
# init
repo = try
@info "Cloning repo"
@jw3126
jw3126 / release.jl
Created April 28, 2019 19:56
Tag and release package to local registry.
using LibGit2
using ArgCheck
using Pkg: TOML
import Pkg
import Registrator
struct Release
package::Module
registry::String
check_master::Bool
@jw3126
jw3126 / advection.jl
Created August 5, 2019 19:28
advection problems
# ]add AbstractPlotting
# ]add Makie
using Makie
function step!(u_new, u, o)
# u_new[i] = u[i] + dt*v*(u[i] - u[i-1])/dx
#
for i in reverse(eachindex(u))
s = o.v*o.dt/o.dx
u_new[i] = u[i] + s * (u[i] - get(u, i-1, zero(eltype(u))))
using Makie
using JuAFEM, SparseArrays
using LinearAlgebra
#
# Poisson example from JuAFEM docs
#
grid = generate_grid(Triangle, (20, 20));
dim = 2
@jw3126
jw3126 / layered_array.jl
Created December 30, 2019 12:39
layered array
using Revise
using ArgCheck
struct LayeredArray{T, N, L} <: AbstractArray{T,N}
layers::L
function LayeredArray(layers)
@argcheck !isempty(layers)
@argcheck first(layers) isa AbstractArray
l = first(layers)
L = typeof(layers)
@jw3126
jw3126 / conv1d.jl
Created April 27, 2020 13:48
Julia CUDA 1d nn style large batch convolution
using CUDAnative, CuArrays
macro cushow(ex)
val = gensym("val")
s = string(ex)
quote
$val = $(esc(ex))
CUDAnative.@cuprintln($(Expr(:string, s, " = ", val)))
$val
end