Skip to content

Instantly share code, notes, and snippets.

View ChrisRackauckas's full-sized avatar
🎯
Focusing

Christopher Rackauckas ChrisRackauckas

🎯
Focusing
View GitHub Profile
using ApproxFun, OrdinaryDiffEq, Sundials, BenchmarkTools
using Plots; gr()
S = Fourier()
n = 100 # n = 1000 takes forever
T = ApproxFun.plan_transform(S, n)
Ti = ApproxFun.plan_itransform(S, n)
x = points(S, n)
# Atom:
Version: 1.44.0
Dev Mode: false
Official Release: true
{
"http_parser": "2.8.0",
"node": "10.11.0",
"v8": "6.9.427.31-electron.0",
"uv": "1.23.0",
"zlib": "1.2.11",
@ChrisRackauckas
ChrisRackauckas / systems_pharmacology.html
Created December 15, 2019 14:52
How Inexact Models Can Guide Decision Making in Systems Pharmacology
<!DOCTYPE html>
<HTML lang = "en">
<HEAD>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>How Inexact Models Can Guide Decision Making in Systems Pharmacology</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
@ChrisRackauckas
ChrisRackauckas / neural_ode_animation.jl
Created November 25, 2019 00:29
Animation of neural ordinary differential equations with DiffEqFlux.jl
using DiffEqFlux, OrdinaryDiffEq, Flux, Plots
# Generate data from a real ODE
u0 = Float32[2.; 0.]; datasize = 30
tspan = (0.0f0,1.5f0)
function trueODEfunc(du,u,p,t)
true_A = [-0.1 2.0; -2.0 -0.1]
du .= ((u.^3)'true_A)'
end
t = range(tspan[1],tspan[2],length=datasize)
struct DirichletBC{T}
l::T
r::T
end
struct BoundaryPaddedArray{T,T2 <: AbstractVector{T}}
l::T
r::T
u::T2
end
# Pkg.add("SpecialMatrices") # Only need to run the first time
using SpecialMatrices, DiffEqBase
A = Strang(11)
function g(t,u)
for i in eachindex(u)
2 - u[i]
end
u
end
u0 = zeros(11); u0[6] = 10
macro test_allowed_failure(ex, kws...)
test_expr!("@test_allowed_failure", ex, kws...)
orig_ex = Expr(:inert, ex)
result = Test.get_test_result(ex, __source__)
# code to call do_test with execution result and original expr
:(do_allowedfailure_test($result, $orig_ex))
end
function do_allowedfailure_test(result::Test.ExecutionResult, orig_expr)
@ChrisRackauckas
ChrisRackauckas / diffeqflux_blog_examples.jl
Created January 19, 2019 04:25
Example code from the DiffEqFlux.jl blog post
using DifferentialEquations, Flux, DiffEqFlux, Plots
####################################################
## Solve an ODE
####################################################
function lotka_volterra(du,u,p,t)
x, y = u
α, β, δ, γ = p
du[1] = dx = α*x - β*x*y
using DifferentialEquations, Flux, DiffEqFlux, Plots
####################################################
## Solve an ODE
####################################################
function lotka_volterra(du,u,p,t)
x, y = u
α, β, δ, γ = p
du[1] = dx = α*x - β*x*y
using Sundials, DiffEqBase
function lorenz(du,u,p,t)
du[1] = 10.0*(u[2]-u[1])
du[2] = u[1]*(28.0-u[3]) - u[2]
du[3] = u[1]*u[2] - (8/3)*u[3]
end
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(lorenz,u0,tspan)
sol = solve(prob,CVODE_Adams(),reltol=1e-12,abstol=1e-12)