This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct DirichletBC{T} | |
l::T | |
r::T | |
end | |
struct BoundaryPaddedArray{T,T2 <: AbstractVector{T}} | |
l::T | |
r::T | |
u::T2 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |