Skip to content

Full Installation Guide for Julia, Modia3D, Modia

Andrea Neumayr edited this page Sep 28, 2021 · 19 revisions

Getting started with Julia, Modia, Modia3D.

The following installation guidelines are for Julia v1.6.3 under Windows 10. If it is possible use a portable version. For Linux or Mac users the installation steps should be quite similar.

These installation guidelines are a full version, it includes Modia3D and Modia Packages. Modia3D uses the DLR Visualization Library for 3D simulation. Further, two plotting packages, Makie and PyPlot are supported.

Julia might fill up your user profile so be aware by installing Julia under Windows. We'd recommend you creating a new environment variable JULIA_DEPOT_PATH = <path-to-julia-home>/.julia before installing Julia. How to set an environment variable under Windows 10 is explained here. A path should not contain a whitespace. Please read the following guidelines carefully.

There is a known issue , you'd might encounter problems during installation of Julia v1.6.3 under Windows 10. It might help setting JULIA_DEPOT_PATH = C:/Users/Neumayr/.julia. Here 'Neumayr' is my user name, or skip setting the environment variable. Hopefully, this bug will be fixed soon...

For further information about ModiaSim project visit https://github.com/ModiaSim .

Installation and Configuration of Julia, Modia, Modia3D

Setting an Environment Variable

You need to define where all Julia packages like Modia and Modia3D are stored.

  • Create an environment variable called JULIA_DEPOT_PATH
    • Set JULIA_DEPOT_PATH = <path-to-julia-home>/.julia (e.g. <path-to-julia-home>/.julia = D:/home/.julia)

Deciding between two plot packages

Decide between two plot packages.

Use Makie for plotting

NOTE: You have to choose ENV["MODIA_PLOT_PACKAGE"] = "Makie" in your startup.jl file afterwards.

Use PyPlot for plotting

NOTE: You have to choose ENV["MODIA_PLOT_PACKAGE"] = "PyPlot" in your startup.jl file afterwards. It might be a bit tricky running PyPlotthe first time. There are two ways of using PyPlot:

  1. Install/use your own Anacondy Python distribution.
    1. Check if Anaconda Python is already installed
      • Remark: Do not use the Anaconda installation from Visual Studio in C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64
    2. Download the latest stable version of Anaconda Python, based on the platform you are using
    3. Set an environment variable or add it to the startup.jl file afterwards
      • ENV["PYTHON"] = "<path-to-python-installation>/python.exe"
  2. Use the Python distribution delivered with Julia.
    1. Add the following environment variables to your startup.jl file.
      • ENV["PYTHON"] = ""
      • ENV["CONDA_JL_USE_MINIFORGE"] = "1"

Installing the DLR Visualization Library

Modia3D uses the DLR Visualization Library for 3D simulations. Download and install the free DLR SimVis Community Edition, e.g. with https://visualization.ltx.de/ . If you don't use the DLR Visualization Library result animation is switched of.

  1. Set an environment variable or add it to the startup.jl file afterwards
    • ENV["DLR_VISUALIZATION"] = "<path-to-library>/Visualization/Extras/SimVis"

Installing Julia

  1. Download the latest stable version of Julia, based on the platform you are using, if available use a portable version from the Julia homepage https://julialang.org/downloads/
  2. Unzip Julia (portable) in your Julia installation directory <path-to-julia-installation>
    • E.g. <path-to-julia-installation> = D:/software/julia-1.6.3
  3. Add the Julia installation directory to the PATH environment variable PATH = <path-to-julia-installation>\bin
  4. Test Julia
    • Open a command window (cmd), write down julia
      • This will open the Julia command window. The Julia command line is called REPL
    • If Julia starts: Congratulations!! 🥇 👍
    • Otherwise open <path-to-julia-installation>/bin/julia.exe, if this works go back to step 3
  5. Close Julia window, or type exit()

Installing Packages and Configuring Julia Modia3D/ Modia Packages

Downloading, installing and testing packages take some time, so be patient and drink a cup of coffee.

  1. Open a Julia REPL
    • Open a command window (cmd), write down julia. This opens a Julia REPL
  2. If you want to use PyPlot for plotting, you have to deal with the following instructions, otherwise skip this point and go to 3.
  3. Adding some packages, typing the following into the REPL
    • Do you want to use Modia3D with Modia?
      • ] add Revise, ModiaBase, ModiaLang, Modia, Modia3D
    • Do you want to use Modia3D without Modia?
      • ] add Revise, ModiaLang, Modia3D
    • Furthermore, one or more of the following packages should be installed in order to be able to generate plots:
      • ] add ModiaPlot_PyPlot --> if plotting with PyPlot desired
      • ] add ModiaPlot_GLMakie -- if plotting with GLMakie desired
      • ] add ModiaPlot_WGLMakie -- if plotting with WGLMakie desired
      • ] add ModiaPlot_CairoMakie -- if plotting with CairoMakie desired
    • It is recommended to also add the following packages, in order that all tests and examples can be executed in your standard environment:
      • ] add Measurements, MonteCarloMeasurements, Distributions
    • Further packages are needed (list might not be complete):
      • ] add Unitful, DifferentialEquations, StaticArrays, DoubleFloats
    • Do you want to develop your own package?
      • ] dev "path-to-my-package"
  4. Configure Julia with a startup.jl file
    • Create folder config under <path-to-julia-home>/.julia
    • Open startup.jl template, adapt it to your needs and save it under <path-to-julia-home>/.julia/config/startup.jl
  5. Test Modia3D and Modia packages
    • Open a Julia REPL
    • using Modia3D
    • include("$(Modia3D.path)/test/Tutorial/BouncingSphere.jl")
    • Further tests are available under
      • include("$(Modia3D.path)/test/runtests.jl")
    • using Modia
    • include("$(Modia.path)/examples/FilterCircuit.jl")
    • exit()

Installing an Editor - Configuration of VS Codium

I recommend you using a portable VS Codium or VS Code version as editor for Julia. VS Codium is a clone of VS Code. It’s identical to VS Code with the single biggest difference that unlike VS Code, VS Codium doesn’t track your usage data.

Installing VS Codium or VS Code

For further information see https://vscodium.com/

Installing the Julia extension for VS Codium

For further information see https://www.julia-vscode.org/docs/dev/gettingstarted/#Installation-and-Configuration-1

  • Start or open VS Codium <path-to-VSCodium>\vscodium-portable.exe
  • Select View and then click Extensions to open Extension View.
  • Enter the term julia in the marketplace search box. Click the green Install button to download the extension.

NOTE: It is recommended that you restart VS Codium after installation.

If you managed to start Julia from command window, which means you installed Julia into a standard location on Mac or Windows, or if the Julia binary is on your PATH environment, the Julia VS Codium extension automatically finds your Julia installation. You do not need to configure the extension. Otherwise you have to configure your extension: see https://www.julia-vscode.org/docs/dev/gettingstarted/#Installation-and-Configuration-1

Running Julia Code with VS Codium or VS Code

  • Select File and then click Open Folder... and browse to folder <path-to-julia-home>/.julia/packages/Modia3D
  • Open ~/test/Tutorial/BouncingSphere.jl
    • Select View and then click Command Palette... and choose Julia: Execute File
    • If more tabs are opened in your editor the actual file will be executed
    • You could create a shortcut for that
  • See also https://www.julia-vscode.org/docs/dev/userguide/runningcode/

Other editors and IDEs for Julia

VS Code, Jupyter, Juno, Pluto.jl, Vim, Emacs, SublimeText, NotePad++ (see listed editors: Julia Editors)

  • VS Code (see the above installation guide)
  • Jupyter (see https://github.com/JuliaLang/IJulia.jl)
    • If not already done, install Anaconda Python
    • Open a Julia REPL and write
      • using Pkg
      • Pkg.add("IJulia")
      • using("IJulia")
      • notebook() --> opens a Jupyter notebook
  • Juno/Atom
    • It is a handy editor, but there is no further development progress. Bug fixes are still done.

For further remarks or if you encounter problems, please feel free to contact Andrea Neumayr (andrea.neumayr[at]dlr.de).

Clone this wiki locally