Julia package to interact with the modeling framework Simplace
This package provides methods to interact with the modelling framework Simplace -
Scientific
Impact assessment and
Modelling
PLatform for
Advanced
Crop and
Ecosystem management.
See www.simplace.net for more information on Simplace. Simplace is written in Java (and some parts in Scala) so one can access it from Julia via JavaCall package. The purpose of this package is to simplify the interaction between Julia and Simplace, by providing functions to:
- initialize and configure Simplace
- load a simulation (solution and project)
- parameterize the simulation
- run the simulation
- get simulation output and convert it to formats suitable for Julia
For installing Simplace, please consult the webpage www.simplace.net. Notice that Simplace version 5.1, svn revision >=403 is required.
A brief guide to install Simplace:
- If you don't have installed Java, please install an appropriate version of the (JRE or JDK) from openjdk.org or adoptium.net (recommended).
- Get Simplace from www.simplace.net
- Install the
Simplacepackage in Julia:
julia> using Pkg; Pkg.add("Simplace")If you encounter errors, make sure to install the package JavaCall.
The usage of Simplace in Julia follows roughly this scheme:
- init Simplace by providing the path to your simplace installation directory, your working directory and your outputs
- open a Simplace project form a solution (and project) file
- create a list of simulation parameters you want to change
- create and run a Simulation
- get the result from the simulation
- convert the result to a Julia object (
Dict())
using Simplace
# directory where simplace is installed
installDir = "d:/simplace/"
# configure path and choose simulation setup (solution, project)
workDir = joinpath(installDir, "simplace_run/simulation/")
outputDir = joinpath(installDir, "simplace_run/output/")
sol = joinpath(workDir, "gk/solution/complete/Complete.sol.xml")
proj = joinpath(workDir, "gk/project/complete/CompleteSensitivity.proj.xml")
# initialise simplace
sh = initSimplace(installDir, workDir, outputDir)
sess = openProject(sh, sol, proj)
runProject(sh)
closeProject(sh)
using Simplace
# Directory where simplace is installed
installDir = "d:/simplace/"
workDir = joinpath(installDir, "simplace_run/simulation/")
outputDir = joinpath(installDir, "simplace_run/output/")
sol = joinpath(workDir, "gk/solution/complete/Complete.sol.xml")
# initialise simplace
sh = initSimplace(installDir, workDir, outputDir)
sess = openProject(sh, sol, "", Dict("enddate" => "1999-12-31"))
# create a simulation that starts in 1995 and set the light use efficiency parameter to 3.2
simid=createSimulation(sh, Dict("startdate" => "1995-01-01", "vBaseLUE" => 3.2))
setLogLevel("WARN")
runSimulations(sh)
setLogLevel("INFO")
closeProject(sh)
# fetch the result (java object) and convert it into a Julia Dict()
res = getResult(sh, "DIAGRAM_OUT", simid)
d = resultToDict(res)
print(d["AnthesisDate"])