In [2]:
Pkg.add("DifferentialEquations")


INFO: Nothing to be done

In [3]:
using DifferentialEquations


INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\Reexport.ji for module Reexport.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\DiffEqBase.ji for module DiffEqBase.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\DiffEqPDEBase.ji for module DiffEqPDEBase.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\StochasticDiffEq.ji for module StochasticDiffEq.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\FiniteElementDiffEq.ji for module FiniteElementDiffEq.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\DiffEqDevTools.ji for module DiffEqDevTools.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\OrdinaryDiffEq.ji for module OrdinaryDiffEq.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\StokesDiffEq.ji for module StokesDiffEq.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\LossFunctions.ji for module LossFunctions.
INFO: Precompiling module Sundials.
INFO: Precompiling module SymEngine.

In [8]:
a = 1
u0 = 1/2
f(t,u) = a*u 
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)


Out[8]:
DiffEqBase.ODEProblem{Float64,Float64,false,#f}(f,0.5,(0.0,1.0))

In [10]:
@doc ODEProblem


Out[10]:

No documentation found.

Summary:

type DiffEqBase.ODEProblem{uType,tType,isinplace,F} <: DiffEqBase.AbstractODEProblem{uType,tType,isinplace,F}

Fields:

f     :: F
u0    :: uType
tspan :: Tuple{tType,tType}

In [11]:
peakflops()


Out[11]:
1.0567811825204554e10

In [12]:
sol = solve(prob)


Out[12]:
DiffEqBase.ODESolution{Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},DiffEqBase.ODEProblem{Float64,Float64,false,#f},OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.InterpolationData{#f,Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}}([0.5,0.552608,0.708178,0.990077,1.35914],[0.0,0.10004,0.348088,0.683175,1.0],Array{Float64,1}[[Inf],[0.5,0.508053,0.516627,0.547151,0.551587,0.552699,0.552608],[0.552608,0.574676,0.599267,0.691649,0.70619,0.709839,0.708178],[0.708178,0.746384,0.790071,0.960041,0.988208,0.995271,0.990077],[0.990077,1.04058,1.09802,1.31982,1.35618,1.3653,1.35914]],DiffEqBase.ODEProblem{Float64,Float64,false,#f}(f,0.5,(0.0,1.0)),OrdinaryDiffEq.Tsit5(),OrdinaryDiffEq.InterpolationData,true,0)

In [13]:
sol = solve(prob,Euler(),dt=1/2^4)


Out[13]:
DiffEqBase.ODESolution{Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},DiffEqBase.ODEProblem{Float64,Float64,false,#f},OrdinaryDiffEq.Euler,OrdinaryDiffEq.InterpolationData{#f,Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.EulerConstantCache}}([0.5,0.53125,0.564453,0.599731,0.637215,0.677041,0.719356,0.764315,0.812085,0.86284,0.916768,0.974066,1.03494,1.09963,1.16836,1.24138,1.31896],[0.0,0.0625,0.125,0.1875,0.25,0.3125,0.375,0.4375,0.5,0.5625,0.625,0.6875,0.75,0.8125,0.875,0.9375,1.0],Array{Float64,1}[[Inf],[0.5,0.53125],[0.53125,0.564453],[0.564453,0.599731],[0.599731,0.637215],[0.637215,0.677041],[0.677041,0.719356],[0.719356,0.764315],[0.764315,0.812085],[0.812085,0.86284],[0.86284,0.916768],[0.916768,0.974066],[0.974066,1.03494],[1.03494,1.09963],[1.09963,1.16836],[1.16836,1.24138],[1.24138,1.31896]],DiffEqBase.ODEProblem{Float64,Float64,false,#f}(f,0.5,(0.0,1.0)),OrdinaryDiffEq.Euler(),OrdinaryDiffEq.InterpolationData,true,0)

In [14]:
sol[5]


Out[14]:
0.6372146606445312

In [15]:
sol.t[8]


Out[15]:
0.4375

In [16]:
[t+u for (t,u) in tuples(sol)]


Out[16]:
17-element Array{Float64,1}:
 0.5     
 0.59375 
 0.689453
 0.787231
 0.887215
 0.989541
 1.09436 
 1.20182 
 1.31209 
 1.42534 
 1.54177 
 1.66157 
 1.78494 
 1.91213 
 2.04336 
 2.17888 
 2.31896 

In [17]:
[t+2u for (t,u) in zip(sol.t,sol.u)]


Out[17]:
17-element Array{Float64,1}:
 1.0    
 1.125  
 1.25391
 1.38696
 1.52443
 1.66658
 1.81371
 1.96613
 2.12417
 2.28818
 2.45854
 2.63563
 2.81989
 3.01176
 3.21171
 3.42026
 3.63793

In [18]:
sol(0.45)


Out[18]:
0.7737737411230338

In [19]:
using Plots


ArgumentError: Module Plots not found in current path.
Run `Pkg.add("Plots")` to install the Plots package.

 in require(::Symbol) at .\loading.jl:365

In [20]:
Pkg.add("Plots")


INFO: Cloning cache of PlotThemes from https://github.com/JuliaPlots/PlotThemes.jl.git
INFO: Cloning cache of PlotUtils from https://github.com/JuliaPlots/PlotUtils.jl.git
INFO: Cloning cache of Plots from https://github.com/JuliaPlots/Plots.jl.git
INFO: Downgrading LightGraphs: v0.7.5 => v0.7.3
INFO: Installing PlotThemes v0.1.1
INFO: Installing PlotUtils v0.3.0
INFO: Installing Plots v0.10.3
INFO: Building WinRPM
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_42.2/repodata/repomd.xml
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_42.2/repodata/repomd.xml
INFO: Building EzXML
INFO: Nothing to do
INFO: Building Rmath
INFO: Building Blosc
INFO: Building HDF5
INFO: Updating WinRPM package list
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_42.2/repodata/repomd.xml
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_42.2/repodata/repomd.xml
INFO: Building Plots
INFO: Cannot find deps/plotly-latest.min.js... downloading latest version.
INFO: Package database updated

In [21]:
using Plots
plot(sol)


INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\FixedSizeArrays.ji for module FixedSizeArrays.
INFO: Precompiling module PlotUtils.
INFO: Precompiling module PlotThemes.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\Showoff.ji for module Showoff.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\Measures.ji for module Measures.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\FileIO.ji for module FileIO.
INFO: Recompiling stale cache file C:\Users\miguel\AppData\Local\JuliaPro-0.5.1.1\pkgs-0.5.1.1\lib\v0.5\PyPlot.ji for module PyPlot.
INFO: Installing matplotlib via the Conda matplotlib package...
Out[21]:

In [22]:
gui()

In [23]:
sol = solve(prob,Vern7())
plot(sol,title="Solving using the Vern7 Method")


Out[23]:

In [24]:
sol = solve(prob,alg_hints=[:stiff])


Out[24]:
DiffEqBase.ODESolution{Array{Float64,1},Array{Float64,1},Array{Any,1},DiffEqBase.ODEProblem{Float64,Float64,false,#f},Sundials.CVODE_BDF{:Newton,:Dense},DiffEqBase.##7#9}([0.5,0.511448,0.523158,0.5651,0.610032,0.658414,0.710594,0.766897,0.907715,1.07426,1.2711,1.36445],[0.0,0.022383,0.0447661,0.12087,0.196974,0.273079,0.349183,0.425287,0.593273,0.761258,0.929244,1.0],Any[],DiffEqBase.ODEProblem{Float64,Float64,false,#f}(f,0.5,(0.0,1.0)),Sundials.CVODE_BDF{:Newton,:Dense}(0,0,0),DiffEqBase.#7,false,0)

In [26]:
A = [1. 0 0 -5
     4 -2 4 -3
     -4 0 0 1
     5 -2 2 3]
u0 = rand(4,2)
tspan = (0.0,1.0)
f(t,u) = A*u
prob = ODEProblem(f,u0,tspan)


WARNING: Method definition f
Out[26]:
DiffEqBase.ODEProblem{Array{Float64,2},Float64,false,#f}(f,[0.139452 0.316608; 0.304835 0.884851; 0.490892 0.127073; 0.0534897 0.241418],(0.0,1.0))
(Any, Any) in module Main at In[8]:3 overwritten at In[26]:7.

In [27]:
sol = solve(prob)
plot(sol)


Out[27]:

In [28]:
sol[4]


Out[28]:
4×2 Array{Float64,2}:
 -0.117171  -0.0765334
  0.466461   0.452957 
  0.494314   0.0575644
  0.294021   0.337519 

In [29]:
sol[3,5]


Out[29]:
0.12885808195714588

In [30]:
sol[:,2,1]


Out[30]:
8-element Array{Float64,1}:
 0.304835
 0.383154
 0.465411
 0.466461
 0.398767
 0.396738
 0.764606
 1.71388 

In [33]:
function lorentz(t,u,du)
    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


WARNING: Method definition 
Out[33]:
lorentz (generic function with 1 method)
lorentz(Any, Any, Any) in module Main at In[31]:2 overwritten at In[33]:2.

In [34]:
u0 = [1.0; 0.0; 0.0]
tspan = (0.0,1.0)
prob = ODEProblem(lorentz,u0,tspan)
sol = solve(prob)


Out[34]:
DiffEqBase.ODESolution{Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,#lorentz},OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.InterpolationData{#lorentz,Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}}}(Array{Float64,1}[[1.0,0.0,0.0],[0.999643,0.000998805,1.78143e-8],[0.996105,0.0109654,2.14696e-6],[0.969359,0.0897708,0.000143803],[0.924204,0.24229,0.00104617],[0.880045,0.438738,0.00342428],[0.848331,0.691565,0.00848767],[0.849504,1.01454,0.0182121],[0.913907,1.44256,0.0366937],[1.08886,2.05232,0.0740256]  …  [12.3624,-4.16707,44.2999],[5.77311,-8.75986,37.333],[-0.323357,-9.21956,31.4194],[-3.68415,-8.62591,28.4218],[-5.86989,-8.32987,26.4556],[-7.01449,-8.61442,25.6046],[-8.0235,-9.31729,25.5716],[-8.91896,-9.88551,26.5527],[-9.43121,-9.52447,28.1411],[-9.3954,-9.09342,28.5537]],[0.0,3.56786e-5,0.000392465,0.00326242,0.00905811,0.0169565,0.02769,0.0418564,0.0602403,0.0836853  …  0.463719,0.504944,0.55706,0.606837,0.669018,0.727662,0.798851,0.876318,0.96616,1.0],Array{Array{Float64,1},1}[Array{Float64,1}[[1.09167e-314,1.06098e-314,1.06098e-314]],Array{Float64,1}[[-10.0,28.0,0.0],[-9.99782,27.9982,0.00016083],[-9.99557,27.9964,0.000326609],[-9.9878,27.9901,0.000898616],[-9.98672,27.9892,0.000978473],[-9.98645,27.989,0.000998404],[-9.98645,27.989,0.000998401]],Array{Float64,1}[[-9.98645,27.989,0.000998401],[-9.96463,27.9713,0.00260394],[-9.94219,27.9532,0.0042548],[-9.86485,27.8908,0.0099306],[-9.85408,27.8821,0.0107203],[-9.85139,27.88,0.0109173],[-9.85139,27.88,0.010917]],Array{Float64,1}[[-9.85139,27.88,0.010917],[-9.67705,27.7396,0.023627],[-9.50032,27.5997,0.0364493],[-8.89841,27.1303,0.0794092],[-8.81532,27.0665,0.0852588],[-8.79466,27.0506,0.0867112],[-8.79588,27.0521,0.0866367]],Array{Float64,1}[[-8.79588,27.0521,0.0866367],[-8.46138,26.797,0.109946],[-8.12796,26.5526,0.133044],[-7.00384,25.7565,0.208843],[-6.84885,25.6502,0.219066],[-6.81047,25.6242,0.221592],[-6.81914,25.6345,0.221136]],Array{Float64,1}[[-6.81914,25.6345,0.221136],[-6.40645,25.3588,0.248129],[-5.99918,25.1059,0.274853],[-4.63104,24.3082,0.362795],[-4.44095,24.203,0.374807],[-4.39403,24.1776,0.377775],[-4.41307,24.1995,0.376978]],Array{Float64,1}[[-4.41307,24.1995,0.376978],[-3.91862,23.9436,0.408378],[-3.43583,23.7305,0.439919],[-1.81407,23.1091,0.546439],[-1.58401,23.0288,0.561521],[-1.52747,23.0101,0.565264],[-1.56766,23.0545,0.564042]],Array{Float64,1}[[-1.56766,23.0545,0.564042],[-1.00608,22.9007,0.602558],[-0.461059,22.8175,0.642903],[1.38573,22.6927,0.787645],[1.65807,22.6807,0.809379],[1.72476,22.6798,0.814827],[1.6504,22.7561,0.813293]],Array{Float64,1}[[1.6504,22.7561,0.813293],[2.27509,22.8234,0.869376],[2.8848,22.9998,0.931761],[4.99962,23.8436,1.17405],[5.3302,23.9691,1.21289],[5.41103,24.0033,1.22273],[5.28651,24.1133,1.22051]],Array{Float64,1}[[5.28651,24.1133,1.22051],[5.99716,24.576,1.32201],[6.71037,25.2047,1.44093],[9.28873,27.755,1.93757],[9.71886,28.1396,2.02246],[9.82434,28.2392,2.04412],[9.63461,28.3552,2.0373]]  …  Array{Float64,1}[[-94.2362,-383.55,37.4091],[-114.537,-372.094,-17.0984],[-130.825,-340.511,-65.6865],[-144.346,-230.838,-134.464],[-128.468,-220.039,-116.794],[-124.76,-216.786,-113.047],[-165.295,-197.339,-169.648]],Array{Float64,1}[[-165.295,-197.339,-169.648],[-167.422,-165.462,-176.829],[-164.912,-134.206,-176.303],[-153.486,-64.8066,-161.402],[-153.645,-64.9745,-161.779],[-153.533,-64.831,-161.718],[-145.33,-45.1206,-150.126]],Array{Float64,1}[[-145.33,-45.1206,-150.126],[-136.922,-27.6252,-137.809],[-126.663,-14.8464,-125.065],[-102.055,8.17647,-89.134],[-104.928,9.17531,-87.2299],[-105.515,9.39667,-86.7506],[-88.962,10.3252,-80.8038]],Array{Float64,1}[[-88.962,10.3252,-80.8038],[-81.0051,12.0092,-72.5897],[-73.8486,12.6958,-65.8586],[-52.2954,10.3514,-44.7364],[-49.6993,9.13894,-40.9787],[-49.0752,8.82287,-40.1025],[-49.4176,10.1798,-44.0122]],Array{Float64,1}[[-49.4176,10.1798,-44.0122],[-43.4512,8.44531,-38.9956],[-38.9059,6.77317,-35.0906],[-23.3663,-1.26789,-20.9707],[-19.5534,-3.71613,-17.52],[-18.6641,-4.31613,-16.7193],[-24.5999,-0.73531,-21.653]],Array{Float64,1}[[-24.5999,-0.73531,-21.653],[-22.3466,-2.33459,-19.1307],[-20.7814,-3.65215,-16.8308],[-14.8671,-8.31715,-8.38274],[-13.0077,-9.36325,-6.68584],[-12.5792,-9.61048,-6.27726],[-15.9993,-8.18834,-7.85304]],Array{Float64,1}[[-15.9993,-8.18834,-7.85304],[-15.104,-9.18162,-5.35782],[-14.632,-9.72253,-2.92151],[-11.4554,-10.8588,5.50365],[-9.76144,-11.1855,6.85936],[-9.36728,-11.2499,7.19597],[-12.9379,-10.1668,6.56633]],Array{Float64,1}[[-12.9379,-10.1668,6.56633],[-12.5923,-9.76155,8.88926],[-12.2205,-8.80263,10.9923],[-9.1143,-4.57117,16.1022],[-7.74878,-4.06962,16.1314],[-7.41867,-3.92221,16.1461],[-9.66548,-3.02333,17.3614]],Array{Float64,1}[[-9.66548,-3.02333,17.3614],[-8.70472,-0.907063,18.4699],[-7.36585,1.61833,18.6626],[-1.71789,7.95945,14.7723],[-0.494772,7.57391,12.8218],[-0.174786,7.52146,12.3364],[-0.93257,10.8554,14.7842]],Array{Float64,1}[[-0.93257,10.8554,14.7842],[-0.290328,11.5571,14.0598],[0.378604,12.1936,13.1903],[2.5696,13.9624,9.99172],[2.82146,14.0953,9.55078],[2.88577,14.128,9.43686],[3.01987,14.2952,9.29325]]],DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,#lorentz}(lorentz,[1.0,0.0,0.0],(0.0,1.0)),OrdinaryDiffEq.Tsit5(),OrdinaryDiffEq.InterpolationData,true,0)

In [35]:
plot(sol)


Out[35]:

In [36]:
using ParameterizedFunctions
g = @ode_def LorenzExample begin
    dx = σ*(y-x)
    dy = x*(ρ - z) - y
    dz = x*y - β*z
    end σ => 10.0 ρ=>28.0 β=(8/3)


WARNING: Hessian could not invert
Out[36]:
(::LorenzExample) (generic function with 14 methods)

In [38]:
h = LorenzExample(σ=11.0, ρ=25.0)


Out[38]:
(::LorenzExample) (generic function with 14 methods)

In [41]:
@doc solve


Out[41]:

solve(prob::StokesProblem,mesh::FDMMesh)

Solves the given stationary Stokes problem on the given finite difference mesh.

Keyword Arguments

  • converrors: Whether to calculate all of the errors along the convergence. Default is true.
  • maxiters: Maximum number of iterations before haulting. Default is 100.
  • alg: The solver algorithm. Default is "dgs". Other option is "multigrid".
  • level: The number of levels in the Multigrid. Default is 2.
  • smoothSteps: The number of Gauss-Seidel iterations to do at each smoothing step. Default is 10.
  • coarseSteps: The number of Gauss-Seidel iterations to do at the coarsegrid. Default is 40.
  • gsiters: The number of Gauss-Seidel iterations to do at each step. Default is 20.

In [42]:
using ODEInterfaceDiffEq


INFO: Precompiling module ODEInterface.

In [44]:
Pkg.add("LSODA")
using LSODA


unsatisfiable package requirements detected: no feasible version could be found for package: MultiScaleArrays
  (you may try increasing the value of the
   JULIA_PKGRESOLVE_ACCURACY environment variable)
 in resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}) at .\pkg\resolve.jl:37
 in resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Tuple{VersionNumber,Bool}}, ::Dict{String,Base.Pkg.Types.Fixed}, ::Dict{String,VersionNumber}, ::Set{String}) at .\pkg\entry.jl:495
 in edit(::Function, ::String, ::Base.Pkg.Types.VersionSet, ::Vararg{Base.Pkg.Types.VersionSet,N}) at .\pkg\entry.jl:30
 in (::Base.Pkg.Entry.##2#5{String,Base.Pkg.Types.VersionSet})() at .\task.jl:360

 in sync_end() at .\task.jl:311
 in macro expansion at .\task.jl:327 [inlined]
 in add(::String, ::Base.Pkg.Types.VersionSet) at .\pkg\entry.jl:51
 in (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}})() at .\pkg\dir.jl:31
 in cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}}, ::String) at .\file.jl:48
 in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N}) at .\pkg\dir.jl:31
 in add(::String) at .\pkg\pkg.jl:100

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: