PlantSimEngine.jl
A framework to build plant models at the scales that matter
Install / Use
/learn @VirtualPlantLab/PlantSimEngine.jlREADME
PlantSimEngine
Overview
PlantSimEngine is a comprehensive framework for building models of the soil-plant-atmosphere continuum. It includes everything you need to prototype, evaluate, test, and deploy plant/crop models at any scale, with a strong emphasis on performance and efficiency, so you can focus on building and refining your models.
Why choose PlantSimEngine?
- Simplicity: Write less code, focus on your model's logic, and let the framework handle the rest.
- Modularity: Each model component can be developed, tested, and improved independently. Assemble complex simulations by reusing pre-built, high-quality modules.
- Standardisation: Clear, enforceable guidelines ensure that all models adhere to best practices. This built-in consistency means that once you implement a model, it works seamlessly with others in the ecosystem.
- Optimised Performance: Don't re-invent the wheel. Delegating low-level tasks to PlantSimEngine guarantees that your model will benefit from every improvement in the framework. Enjoy faster prototyping, robust simulations, and efficient execution using Julia's high-performance capabilities.
Unique Features
Automatic Model Coupling
Seamless Integration: PlantSimEngine leverages Julia's multiple-dispatch capabilities to automatically compute the dependency graph between models. This allows researchers to effortlessly couple models without writing complex connection code or manually managing dependencies.
Intuitive Multi-Scale Support: The framework naturally handles models operating at different scales—from organelle to ecosystem—connecting them with minimal effort and maintaining consistency across scales.
Flexibility with Precision Control
Effortless Model Switching: Researchers can switch between different component models using a simple syntax without rewriting the underlying model code. This enables rapid comparison between different hypotheses and model versions, accelerating the scientific discovery process.
Multi-rate Execution
Mix model cadences in one simulation: PlantSimEngine can run models at different timesteps within the same MTG simulation. This makes it possible to combine, for example, hourly leaf processes with daily plant balances and weekly reporting models without writing custom scheduling glue.
Explicit bindings between rates: TimeStepModel, InputBindings, MeteoBindings, ScopeModel, and OutputRequest let you declare how model inputs, meteorology, and exported outputs should behave when rates differ.
Batteries included
- Automated Management: Seamlessly handle inputs, outputs, time-steps, objects, and dependency resolution.
- Iterative Development: Fast and interactive prototyping of models with built-in constraints to avoid errors and sensible defaults to streamline the model writing process.
- Control Your Degrees of Freedom: Fix variables to constant values or force to observations, use simpler models for specific processes to reduce complexity.
- Multi-Rate Scheduling: Combine hourly, daily, and coarser models in the same simulation, with explicit policies for input aggregation and meteorological sampling.
- High-Speed Computations: Achieve impressive performance with benchmarks showing operations in the 100th of nanoseconds range for complex models (see this benchmark script).
- Parallelize and Distribute Computing: Out-of-the-box support for sequential, multi-threaded, or distributed computations over objects, time-steps, and independent processes, thanks to Floops.jl.
- Scale Effortlessly: Methods for computing over objects, time-steps, and Multi-Scale Tree Graphs.
- Compose Freely: Use any types as inputs, including Unitful for unit propagation and MonteCarloMeasurements.jl for measurement error propagation.
Ask Questions
If you have any questions or feedback, open an issue or ask on discourse.
Installation
To install the package, enter the Julia package manager mode by pressing ] in the REPL, and execute the following command:
add PlantSimEngine
To use the package, execute this command from the Julia REPL:
using PlantSimEngine
Example usage
The package is designed to be easy to use, and to help users avoid errors when implementing, coupling and simulating models.
Simple example
Here's a simple example of a model that simulates the growth of a plant, using a simple exponential growth model:
# ] add PlantSimEngine
using PlantSimEngine
# Include the model definition from the examples sub-module:
using PlantSimEngine.Examples
# Define the model:
model = ModelMapping(
ToyLAIModel(),
status=(TT_cu=1.0:2000.0,), # Pass the cumulated degree-days as input to the model
)
run!(model) # run the model
status(model) # extract the status, i.e. the output of the model
Which gives:
TimeStepTable{Status{(:TT_cu, :LAI...}(1300 x 2):
╭─────┬────────────────┬────────────╮
│ Row │ TT_cu │ LAI │
│ │ Float64 │ Float64 │
├─────┼────────────────┼────────────┤
│ 1 │ 1.0 │ 0.00560052 │
│ 2 │ 2.0 │ 0.00565163 │
│ 3 │ 3.0 │ 0.00570321 │
│ 4 │ 4.0 │ 0.00575526 │
│ 5 │ 5.0 │ 0.00580778 │
│ ⋮ │ ⋮ │ ⋮ │
╰─────┴────────────────┴────────────╯
1295 rows omitted
Note
TheToyLAIModelis available from the examples folder, and is a simple exponential growth model. It is used here for the sake of simplicity, but you can use any model you want, as long as it followsPlantSimEngineinterface.
Of course you can plot the outputs quite easily:
# ] add CairoMakie
using CairoMakie
lines(model[:TT_cu], model[:LAI], color=:green, axis=(ylabel="LAI (m² m⁻²)", xlabel="Cumulated growing degree days since sowing (°C)"))

Model coupling
Model coupling is done automatically by the package, and is based on the dependency graph between the models. To couple models, we just have to add them to the ModelMapping. For example, let's couple the ToyLAIModel with a model for light interception based on Beer's law:
# ] add PlantSimEngine, PlantMeteo, Dates
using PlantSimEngine, PlantMeteo, Dates
# Include the model definition from the examples folder:
using PlantSimEngine.Examples
# Import the example meteorological data:
meteo_day = read_weather(joinpath(pkgdir(PlantSimEngine), "examples/meteo_day.csv"), duration=Dates.Day)
# Define the list of models for coupling:
model = ModelMapping(
ToyLAIModel(),
Beer(0.6),
status=(TT_cu=cumsum(meteo_day[:, :TT]),), # Pass the cumulated degree-days as input to `ToyLAIModel`, this could also be done using another model
)
The ModelMapping couples the models by automatically computing the dependency graph of the models. The resulting dependency graph is:
╭──── Dependency graph ──────────────────────────────────────────╮
│ ╭──── LAI_Dynamic ─────────────────────────────────────────╮ │
│ │ ╭──── Main model ────────╮ │ │
│ │ │ Process: LAI_Dynamic │ │ │
│ │ │ Model: ToyLAIModel │ │ │
│ │ │ Dep: │ │ │
│ │ ╰────────────────────────╯ │ │
│ │ │ ╭──── Soft-coupled model ─────────╮ │ │
│ │ │ │ Process: light_interception │ │
Related Skills
node-connect
341.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
