Quick start

If it's your first time using EcologicalNetworksDynamics, exploring this example might be useful to you so that you understand how the package works. Try pasting the following code blocks in a Julia terminal.

The first step is to create the structure of the trophic interactions.

using EcologicalNetworksDynamics, Plots
fw = Foodweb([1 => 2, 2 => 3]) # 1 eats 2, and 2 eats 3.
blueprint for Foodweb with 2 trophic links:
  A:
  1 eats 2
  2 eats 3

Then, you can generate the parameter of the model (mostly species traits) with:

m = default_model(fw)
Model (alias for EcologicalNetworksDynamics.Framework.System{<inner parms>}) with 17 components:
  - Species: 3 (:s1, :s2, :s3)
  - Foodweb: 2 links
  - Body masses: [100.0, 10.0, 1.0]
  - Metabolic classes: [:invertebrate, :invertebrate, :producer]
  - GrowthRate: [·, ·, 1.0]
  - Carrying capacity: [·, ·, 1.0]
  - ProducersCompetition: 1.0
  - LogisticGrowth
  - Efficiency: 0.45 to 0.85.
  - MaximumConsumption: [8.0, 8.0, ·]
  - Hill exponent: 2.0
  - Consumers preferences: 1.0
  - Intra-specific interference: [·, ·, ·]
  - Half-saturation density: [0.5, 0.5, ·]
  - BioenergeticResponse
  - Metabolism: [0.09929551852928711, 0.1765751761097696, 0.0]
  - Mortality: [0.0, 0.0, 0.0]

For instance, we can access the species metabolic rates with:

m.metabolism
3-element EcologicalNetworksDynamics.MetabolismRates:
 0.09929551852928711
 0.1765751761097696
 0.0

We see that while consumers (species 1 and 2) have a positive metabolic rate, producer species (species 3) have a null metabolic rate.

Use properties to list all properties of the model:

properties(m)
63-element Vector{Any}:
 :A
 :K
 :M
 :S
 :body_masses
 :carnivorous_links
 :carrying_capacity
 :consumers_dense_index
 :consumers_indices
 :consumers_mask
 ⋮
 :tops_dense_index
 :tops_indices
 :tops_mask
 :tops_sparse_index
 :trophic_levels
 :trophic_links
 :w
 :x
 :y

At this step we are ready to run simulations, we just need to provide initial conditions for species biomasses.

B0 = [0.1, 0.1, 0.1] # The 3 species start with a biomass of 0.1.
t = 100 # The simulation will run for 100 time units.
out = simulate(m, B0, t)
retcode: Success
Interpolation: 3rd order Hermite
t: 29-element Vector{Float64}:
   0.0
   0.11699364210598083
   0.48617833218898704
   1.0368468566268698
   1.7139556067464368
   2.551396324058539
   3.5330334049447143
   4.505265217848576
   5.8360739275683375
   6.967915642966041
   ⋮
  33.58086914720148
  38.07154253509167
  42.80330902911462
  52.63443501185273
  58.19052244040714
  70.83124657191073
  79.50124044283113
  96.8286296609048
 100.0
u: 29-element Vector{Vector{Float64}}:
 [0.1, 0.1, 0.1]
 [0.09919287669046291, 0.09822884333138167, 0.10943428041997874]
 [0.09662179885024248, 0.09376940942333956, 0.14338556932556454]
 [0.09279833833825743, 0.09092616702356371, 0.204977885720663]
 [0.08831859483504895, 0.0955005850161038, 0.2918974801362088]
 [0.08358086759376752, 0.11717295403615809, 0.39129687974032556]
 [0.08033574339252711, 0.1698979263318899, 0.44735045636388826]
 [0.08170432183037922, 0.24640046474471963, 0.413604026297541]
 [0.09414436920538245, 0.3352635385088793, 0.303924198953081]
 [0.11304463220968188, 0.35620385306732855, 0.24559294919372504]
 ⋮
 [0.4960452339407801, 0.2076164928953142, 0.3695578226246156]
 [0.5310024728068528, 0.20293534463793605, 0.3804086712091331]
 [0.5599454740811309, 0.19930598219434395, 0.3892843494957735]
 [0.6008353045620992, 0.19441029976728394, 0.4017765028749461]
 [0.6152562947931274, 0.19281709916817044, 0.40602195047089523]
 [0.6347834258616118, 0.19066148161449642, 0.41186939033364506]
 [0.6414488957526213, 0.18994831882724758, 0.4138287296562797]
 [0.6476688888244523, 0.1892859587459852, 0.41567750230182204]
 [0.6481900751201196, 0.18923075974907932, 0.41582899549547175]

Lastly, we can plot the biomass trajectories using the plot functions of Plots.

plot(out)

Quickstart plot