Skip to content

Lightweight Installation Guide: Julia Modia3D

Andrea Neumayr edited this page May 30, 2023 · 9 revisions

Getting started with Julia and Modia.

The following installation guidelines are for Julia v1.9.0 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 lightweight version. Therefore, we use package Makie for plotting, and there is no 3D simulation. Thus, we can skip installing Python (Anaconda Python) for PyPlot and the DLR Visualization Library for 3D simulation. If you're interested see the extensive installation guide.

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.

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

Installation and Configuration of Julia and Modia3D

Setting an Environment Variable

You need to define where all Julia packages like Modia3D and Modia 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)

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.9.0
  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 Modia / Modia3D 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. Adding some packages, typing the following into the REPL (list might not be complete)
    • ] add Revise, Modia, Modia3D
    • Choose between several plot packages: one or more of the following packages should be installed.
      • ] add SignalTablesInterface_GLMakie
        • NOTE: Set: ENV["SignalTablesPlotPackage"] = "GLMakie" in your startup.jl file
      • ] add SignalTablesInterface_WGLMakie
        • NOTE: Set: ENV["SignalTablesPlotPackage"] = "WGLMakie" in your startup.jl file
      • ] add SignalTablesInterface_CairoMakie
        • NOTE: Set: ENV["SignalTablesPlotPackage"] = "CairoMakie" in your startup.jl file
  3. Update all installed packages
    • ] update
  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")
    • exit()
  6. Congratulations!! 🥇 👍

Installation and Configuration of VS Codium/VS Code

We recommend you using a portable VS Codium 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/VS Code

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

Installing the Julia extension for VS Codium/VS Code

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/VS Code

  • Select File and then click Open Folder... and browse to folder <path-to-julia-home>/.julia/packages/Modia3D
  • Open ~/examples/Simulate_Pendulum.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

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

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