Skip to content

Commit

Permalink
docs: Add "How to make your data portable?"
Browse files Browse the repository at this point in the history
  • Loading branch information
singularitti committed Oct 15, 2019
1 parent bf20b6f commit feb83ea
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ makedocs(;
"Manual" => [
"Collections" => "Collections.md",
"Nonlinear fitting" => "NonlinearFitting.md",
"Find volume" => "Find.md"
"Find volume" => "Find.md",
"Portability" => "Portability.md",
]
],
repo="https://github.com/MineralsCloud/EquationsOfState.jl/blob/{commit}{path}#L{line}",
Expand Down
66 changes: 66 additions & 0 deletions docs/src/Portability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# How to make your data portable?

After an equation-of-state-fitting, for instance, you want to save the returned
`EquationOfState` to share with a colleague or for future use. Julia provides
several ways to do this. Below I will list one recommended way: saving it to
a JLD format by [`JLD2.jl`](https://github.com/JuliaIO/JLD2.jl) package.

> JLD is a specific "dialect" of HDF5, a cross-platform, multi-language data storage format most frequently used for scientific data.
1. Install [`JLD2.jl`](https://github.com/JuliaIO/JLD2.jl) and
[`FileIO.jl`](https://github.com/JuliaIO/FileIO.jl) packages.

```julia
julia> using Pkg

julia> Pkg.add("FileIO"); Pkg.add("JLD2")
```

2. Create some `EquationOfState`s:

```julia
julia> using EquationsOfState.Collections, Unitful, UnitfulAtomic

julia> m = Murnaghan(224.501825, 0.00060479524074699499, 3.723835, -323.417686)
Murnaghan{Float64}(224.501825, 0.000604795240746995, 3.723835, -323.417686)

julia> bm = BirchMurnaghan3rd(224.4445656763778u"bohr^3", 9.194980249913018u"GPa", 3.7403684211716297, -161.70885710742223u"hartree")
BirchMurnaghan3rd{Quantity{Float64,D,U} where U where D}(224.4445656763778 a₀^3, 9.194980249913018 GPa, 3.7403684211716297, -161.70885710742223 Eₕ)
```

3. Save them to file `"eos.jld2"`:

```julia
julia> using JLD2, FileIO

julia> @save "/some/path/eos.jld2" m bm
```

4. On another computer, or some days later, load them into REPL:

```julia
julia> using EquationsOfState.Collections, Unitful, UnitfulAtomic

julia> @load "/some/path/eos.jld2" m bm
```

Now variables `m` and `bm` represent the orginal `EquationOfState`s:

```julia
julia> m.b0
0.000604795240746995

julia> m.bp0
3.723835

julia> bm.v0
224.4445656763778 a₀^3

julia> bm.b0
9.194980249913018 GPa
```

For more details on the JLD format, please refer to
[`JLD.jl`'s doc](https://github.com/JuliaIO/JLD.jl/blob/master/doc/jld.md),
[`JLD2.jl`'s doc](https://github.com/JuliaIO/JLD2.jl/blob/master/README.md) or
[this discussion](https://discourse.julialang.org/t/jld-jl-vs-jld2-jl/15287).
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Pages = [
"Collections.md",
"NonlinearFitting.md",
"Find.md",
"Portability.md",
]
Depth = 3
```
Expand Down

0 comments on commit feb83ea

Please sign in to comment.