Units and dimensional analysis are standard tools across the sciences for checking the correctness of your equation. However, most ODE solvers only allow for the equation to be in dimensionless form, leaving it up to the user to both convert the equation to a dimensionless form, punch in the equations, and hopefully not make an error along the way.

DifferentialEquations.jl allows for one to use Unitful.jl to have unit-checked arithmetic natively in the solvers. Given the dispatch implementation of the Unitful, this has little overhead.

To use SIUnits, you need to have the package installed. Then you can add units to your variables. For example:

In [1]:

```
using Unitful
t = 1.0u"s"
```

Out[1]:

Notice that `t`

is a variable with units in seconds. If we make another value with seconds, they can add

In [2]:

```
t2 = 1.02u"s"
t+t2
```

Out[2]:

and they can multiply:

In [3]:

```
t*t2
```

Out[3]:

You can even do rational roots:

In [4]:

```
sqrt(t)
```

Out[4]:

Many operations work.

These operations will check to make sure units are correct, and will throw an error for incorrect operations:

In [5]:

```
t + sqrt(t)
```

Just like with other number systems, you can choose the units for your numbers by simply specifying the units of the initial condition and the timestep. For example, to solve the linear ODE where the variable has units of Newton's and `t`

is in Seconds, we would use:

In [10]:

```
using DifferentialEquations
f = (t,y) -> 0.5*y
u0 = 1.5u"N"
prob = ODEProblem(f,u0,(0.0u"s",1.0u"s"))
sol = solve(prob,Tsit5())
```

Notice that we recieved a unit mismatch error. This is correctly so! Remember that for an ODE:

$$ \frac{dy}{dt} = f(t,y) $$we must have that `f`

is a rate, i.e. `f`

is a change in `y`

per unit time. So we need to fix the units of `f`

in our example to be `N/s`

. Notice that we then do not receive an error if we do the following:

In [11]:

```
f = (t,y) -> 0.5*y/3.0u"s"
prob = ODEProblem(f,u0,(0.0u"s",1.0u"s"))
sol = solve(prob,Tsit5())
```

Out[11]:

This gives a a normal solution object. Notice that the values are all with the correct units:

In [12]:

```
print(sol[:])
```

We can plot the solution using the plot recipe.

In [20]:

```
#Pkg.clone("https://github.com/ajkeller34/UnitfulPlots.jl")
using UnitfulPlots, Plots
gr()
plot(sol.t,sol[:],lw=3)
```

Out[20]:

Notice that here we pulled the units for the label directly from the solution. Thus if the units change, the labels will change automatically.

As of right now, the ODE solvers are the only solvers which are fully compatible with units. The SDE solvers will come shortly. For the FEM PDE solvers, the tooling is all compatible with units (i.e. you can make meshes with units, and most of the functions will work). However, the solver step is what's not compatible with units. The reason is because `\`

uses CHOLMOD which does not work with units, and sparse multiplication also is undefined for units. These facts are major stop gaps in development here. I believe it's not worth it to simply "turn off" units at that point because that is there area where one would wish to have units checked.