Skip to content

Template for startup.jl

Andrea Neumayr edited this page Feb 2, 2023 · 10 revisions

Create your own startup file

This startup template defines how Julia is started. Each time you change something in your startup file, you need to restart Julia.

  1. Is Julia installed? If not, please read: Installing Julia.
    • Copy the template below
      • Whenever Julia is started, this startup.jl file is executed.
      • Store the template file under <path-to-julia-home>\.julia\config\startup.jl
    • Create your folder, where you'd like to work.
      • Adapt the juliaWorkingDir variable to your needs (line 5) and save it, (be aware of using /)
  2. Is a Modia plotting package installed? If not, please read: Choose between several plot packages. This template shows examples for GLMakie and PyPlot.
    • Valid options for ENV["SignalTablesPlotPackage"] are: "GLMakie", "WGLMakie", "CairoMakie", "PyPlot", "NoPlot", "SilentNoPlot"
    • Make sure you add at least one of the corresponding Modia packages: SignalTablesInterface_GLMakie, SignalTablesInterface_WGLMakie, SignalTablesInterface_CairoMakie, SignalTablesInterface_PyPlot
  3. Do you want to use Modia3D for 3D simulations and also visualize your results? If yes, please read: Choose a 3D renderer
    • Set an environment variable or add it to the startup.jl file (remove # in last line of template)
      • ENV["DLR_VISUALIZATION"] = "<path-to-library>/Visualization/Extras/SimVis"
      • remove # in last line of template, and adapt <path-to-library>
########################### Julia startup file ################################### 
### This file should contain site-specific commands to be executed on Julia startup;
### Users may store their own personal commands in `~/.julia/config/startup.jl`.

### set variable: juliaWorkingDir, be aware of using /
juliaWorkingDir = "D:/work/julia"

println("... executing startup file ", @__FILE__)
println("... Julia package directories: ", DEPOT_PATH)

### Change Directory of Julia package directory (default: in %USERPROFILE%\.julia)
cd(juliaWorkingDir)
println("... Starting Julia in " * pwd())

### Use Revise in order that code changes are automatically compiled
### make sure you ] add Revise and remove #= =#
### (https://timholy.github.io/Revise.jl/stable/config.html)
#=
atreplinit() do repl
    @async try
        sleep(0.1)
        @eval using Revise
    catch
        @warn("Could not load Revise.")
    end
end
=#

########################### Plotting #####################################
### Options are: GLMakie, WGLMakie, CairoMakie, PyPlot, NoPlot, SilentNoPlot
### Use GLMakie (remove #= =#)
#=
ENV["SignalTablesPlotPackage"] = "GLMakie"
println("... ENV[\"SignalTablesPlotPackage\"] = \"", ENV["SignalTablesPlotPackage"], "\"")
=#

### Use PyPlot, with Julia's Python (remove #= =#)
#=
ENV["PYTHON"] = ""
ENV["CONDA_JL_USE_MINIFORGE"] = "1"
ENV["SignalTablesPlotPackage"] = "PyPlot"
println("... ENV[\"SignalTablesPlotPackage\"] = \"", ENV["SignalTablesPlotPackage"], "\"")
=#

########################### DLR Visualization Library ################################### 
### Use the DLR Visualization Library for visualizing 3D models, adapt the path to SimVis installation and remove #
# ENV["DLR_VISUALIZATION"] = "<path-to-library>/Visualization/Extras/SimVis"