Skip to content

Template for startup.jl

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

Create your own startup file

  1. 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
  2. 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 /)
  3. Do you want to use Modia3D for 3D simulations and also visualize your results? Skip this point if you're doing the lightweight installation guide!
    • Download and install the free DLR SimVis Community Edition, e.g. with https://visualization.ltx.de/
    • 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())

# Support revise() in order that code changes are automatically compiled
# (https://timholy.github.io/Revise.jl/stable/config.html)
#=
atreplinit() do repl
    @async try
        sleep(0.1)
        @eval using Revise
        @async Revise.wait_steal_repl_backend()
    catch
        @warn("Could not load Revise.")
    end
end
=#
### Plotting ###
# Options are PyPlot/Makie/Nothing
# Choose Makie
#=
ENV["MODIA_PLOT_PACKAGE"] = "Makie"
ENV["MODIA_PLOT"] = ENV["MODIA_PLOT_PACKAGE"]
println("... ENV[\"MODIA_PLOT_PACKAGE\"] = \"", ENV["MODIA_PLOT_PACKAGE"], "\"")
=#

# Choose PyPlot
#=
ENV["PYTHON"] = ""
ENV["CONDA_JL_USE_MINIFORGE"] = "1"
ENV["MODIA_PLOT_PACKAGE"] = "PyPlot"
ENV["MODIA_PLOT"] = ENV["MODIA_PLOT_PACKAGE"]
println("... ENV[\"MODIA_PLOT_PACKAGE\"] = \"", ENV["MODIA_PLOT_PACKAGE"], "\"")
=#

# If you want to use the DLR Visualization Library for visualizing 3D models you need adapt the path to SimVis installation
# ENV["DLR_VISUALIZATION"] = "<path-to-library>/Visualization/Extras/SimVis"
Clone this wiki locally