Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with SIUnits.jl #34

Closed
ChrisRackauckas opened this issue Aug 2, 2016 · 3 comments
Closed

Compatibility with SIUnits.jl #34

ChrisRackauckas opened this issue Aug 2, 2016 · 3 comments

Comments

@ChrisRackauckas
Copy link
Member

Compatibility with SIUnits.jl is almost complete. This is on the units branch. For example, it works with ODEs and SDEs:

using DifferentialEquations

using SIUnits
α = 0.5
f(y,t) = α*y
u₀ = 1.5Newton
prob = ODEProblem(f,u₀)

sol =solve(prob::ODEProblem,[0,1],Δt=(1/2^4)Second,save_timeseries=true,alg=:Midpoint,adaptive=true)

Plots.plotly()
plot(map((x)->x.val,sol.t),map((x)->x.val,sol[:])) #plot(sol)
#plot(sol.t,sol[:]) # Doesn't work because no unit recipe
#plot(sol) #Doesn't work because the one above doesn't work

β = 0.6
σ(y,t) = β*y
prob = SDEProblem(f,σ,u₀)

sol =solve(prob::SDEProblem,[0,1],Δt=(1/2^4)Second,save_timeseries=true,alg=:EM)

Works. What doesn't work is if you use alg=:ExplicitRK. That's the only DifferentialEquation.jl alg solver that doesn't work, but there is an open issue to fix that: Keno/SIUnits.jl#85.

The other problem is the plotting. Currently you have to do:

plot(map((x)->x.val,sol[:]),map((x)->x.val,sol.t)) #plot(sol)

To make it simpler for users, plot recipes will need to be defined. The issue is open for that: Keno/SIUnits.jl#86.

Problems exist with UnitRanges, so meshgrid doesn't work:

Δx = (1//2^(3))Meter
fem_mesh = notime_squaremesh([0 1 0 1],Δx,:dirichlet) #Fails at meshgrid because unit ranges not supported

and Heat Equation needs more work (A needs units).

@ChrisRackauckas
Copy link
Member Author

Adaptive units now work.

@ChrisRackauckas
Copy link
Member Author

I got the plot recipes working. I'll be adding this to master soon.

@ChrisRackauckas
Copy link
Member Author

SIUnits now work with all ODE functions. Not with SDE because the natural timescale is sqrt(t) for Brownian motion, and SIUnits don't support rational units (or sqrt). PDEs don't work because sparse multiplication is borked with units, and \ uses CHOLMOD. See Keno/SIUnits.jl#89. However, the other parts of the FEM routines support units, so you can make meshes which have units etc.

I started discussions to support Unitful as well. Since only two functions (max and a meshing function) actually require the units package specifically, the ODEs should already be compatible with Unitful (samns maybe the max function for adaptivity). There will be more here: PainterQubits/Unitful.jl#12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant