System creation

PlantModules.generate_systemFunction
generate_system(plantstructure::PlantStructure, plantparams::PlantParameters,
	plantcoupling::PlantCoupling)

Create a ModelingToolkit.System that describes the functional behaviour of the input graph structure.

Arguments

  • plantstructure: A graph specifying how the structural modules are connected.
  • plantparams: Additional functional information about the connections between structural modules. See PlantParameters.
  • plantcoupling: Coupling between functional and structural modules. See PlantCoupling.
source
PlantModules.PlantStructureType
PlantStructure{T} <: AbstractGraph{T}

The internal graph implementation used for generate_system.

Constructor

PlantStructure(graphs::Vector, intergraph_connections::Vector; return_id_conversions::Bool = false)

Connect graphs together into a single PlantStructure graph.

Warning: This function defines its own node ids to simplify the integration with the rest of the Graphs.jl ecosystem.

Inputs:

  • graphs::Vector: A vector of graphs representing the plants and their environment.
  • intergraph_connections::Vector: A vector of pairs between 2 indexes of above graphs and how they are linked.
  • return_id_conversions::Bool: Should the function return a dictionary mapping the newly defined node ids to the original nodes?

Alternatives

Other graph implementations can also be used by extending the following functions:

source
PlantModules.PlantCouplingType
PlantCoupling

A container for the coupling of plant structure and function. Used in generate_system.

Fields

  • module_coupling::Dict: Coupling between functional and structural modules.
  • connecting_modules::Dict{Tuple{Symbol, Symbol}, Function}: The System to use for edges between specified nodes.
  • connecting_eqs::Function: A function returning a vector of equations linking a node and all its edges.
source
PlantModules.PlantParametersType
PlantParameters

A container for functional parameters. Used in generate_system.

Fields

  • default_values::Dict{Symbol, <:Any}: The model-wide default values of parameters and initial values.
  • module_defaults::Dict{Symbol, Dict}: Module-specific default values of parameters and initial values.
  • connection_values::Dict{Tuple{Symbol, Symbol}, Dict}: Connection-specific values of parameters and initial values.
source

Shapes

PlantModules.ModuleShapeType
ModuleShape

An abstract type representing the physical shape of a structural module, used by the hydraulic functional module.

Functions

The functional modules implemented in this package expect the following functions to be defined for the shape MyShape with dimensions the vector D:

  • getdimensionality(m::MyShape): Return how many dimensions define the shape.
  • volume(m::MyShape, D): Calculate the volume of the shape.
  • cross_area(m::MyShape, D): Calculate the cross-sectional area of the shape.
  • surface_area(m::MyShape, D): Calculate the surface area of the shape.
source
PlantModules.SphereType
Sphere <: ModuleShape

A spherical compartment shape, defined by a single dimension: the radius.

source
PlantModules.CylinderType
Cylinder <: ModuleShape

A cylindrical compartment shape, defined by two dimensions: the radius and the length.

source
PlantModules.CuboidType
Cuboid <: ModuleShape

A cuboidal compartment shape, defined by three dimensions: the length, the width and the thickness.

source

Graph functions

PlantModules.getvariablesFunction
getvariables(sol::ODESolution, graph; varname = missing, structmod = missing)

Return the Numeric representation of one or more variables from a graph, optionally filtered by structural module.

source

Shape functions

PlantModules.correctdimensionalityFunction
correctdimensionality(s::ModuleShape, var)

Correct the dimensions of a variable var to match the number of dimensions of shape s.

If var is a scalar, return a vector of the length matching s with the value of var used for every dimension. If var is an array, either return the same vector if the dimensions match or throw an error if they do not.

source
PlantModules.volumeFunction
volume(s::ModuleShape, ::AbstractArray)

Calculate the volume of a given shape.

source
volume(::Sphere, D::AbstractArray)

Calculate the volume of a sphere.

source
volume(::Cylinder, D::AbstractArray)

Calculate the volume of a cylinder. Dimensions are assumed to be in the order: radius, length.

source
volume(::Cuboid, D::AbstractArray)

Calculate the volume of a cuboid.

source
PlantModules.cross_areaFunction
cross_area(s::ModuleShape, ::AbstractArray)

Calculate the cross-sectional area of a given shape.

source
cross_area(::Sphere, D::AbstractArray)

Calculate the cross-sectional area of a sphere, defined as the area of a circle with the same radius.

source
cross_area(::Cylinder, D::AbstractArray)

Calculate the cross-sectional area of a cylinder, defined as its base area. Dimensions are assumed to be in the order: radius, length.

source
cross_area(::Cuboid, D::AbstractArray)

Calculate the cross-sectional area of a cuboid, defined as the product of its first two dimensions.

source
PlantModules.surface_areaFunction
surface_area(s::ModuleShape, ::AbstractArray)

Calculate the surface area of a given shape.

source
surface_area(::Sphere, D::AbstractArray)

Calculate the surface area of a sphere.

source
surface_area(::Cylinder, D::AbstractArray)

Calculate the surface area of a cylinder. Dimensions are assumed to be in the order: radius, length.

source
surface_area(::Cuboid, D::AbstractArray)

Calculate the surface area of a cuboid.

source

Smooth functions

PlantModules.logsumexpFunction
logsumexp(xs::AbstractArray; α = 1.0)

Return the smoothed maximum of an array, where α controls the steepness of the smoothing.

source
logsumexp(x; α = 1.0)

Return the smoothed maximum of the argument and zero.

source
PlantModules.smooth_daynightFunction
smooth_daynight(t, t_sunrise, t_sunset, ymin = 0, ymax = 1)

Return a value that smoothly switches between ymax at day and ymin at night.

source

Node modules

PlantModules.hydraulic_moduleFunction
hydraulic_module(; name, shape, ϕ_D, E_D, Γ, T, D, Ψ, M)

Return a ModelingToolkit System describing the turgor-driven growth of a plant compartment.

This module still requires a module describing the osmotically active metabolite content M.

Inputs

Parameters

  • shape: The shape, defined as an instance of PlantModules.ModuleShape.
  • ϕ_D: The dimensional extensibility [1 / MPa / h], must be a vector with a value for every dimension of the compartment's shape.
  • E_D: The dimensional elastic modulus [MPa], must be a vector with a value for every dimension of the compartment's shape.
  • Γ: The yield turgor pressure [MPa].
  • T: The temperature [K].

Initial values

  • D: The dimensions [cm], must be a vector with a value for every dimension of the compartment's shape.
  • Ψ: The total water potential [MPa].
  • M: The osmotically active metabolite concentration [mol/cm^3].
  • h: The height above a chosen reference level [cm].
source
PlantModules.environmental_moduleFunction
environmental_module(; name, T, W_max, W_r)

Return a ModelingToolkit System describing a non-growing water reservoir.

This module still requires a module describing the total water potential Ψ.

Inputs

Parameters

  • T: The temperature [K].
  • W_max: The water capacity of the compartment [g].

Initial values

  • W_r: The relative water content, equal to the ratio of the current water content W over the water capacity W_max [g/g].
source
PlantModules.constant_carbon_moduleFunction
constant_carbon_module(; name, M)

Return a ModelingToolkit System describing a constant concentration of osmotically active metabolite content.

Inputs

Initial values

  • M: The osmotically active metabolite concentration [mol/cm^3].
source
PlantModules.simple_photosynthesis_moduleFunction
simple_photosynthesis_module(; name, M, shape)

Return a ModelingToolkit System describing a concentration of osmotically active metabolite content increasing during day and decreasing in function of the current concentration.

Inputs

Parameters

  • shape: The shape, defined as an instance of PlantModules.ModuleShape.
  • t_sunrise: The time of sunrise [h].
  • t_sunset: The time of sunset [h].
  • A_max: The maximum carbon assimilation rate [mol / cm^2 / h].
  • M_c: The rate of carbon consumption [1 / h].

Initial values

  • M: The osmotically active metabolite concentration [mol/cm^3].
source
PlantModules.Ψ_soil_moduleFunction
Ψ_soil_module(; name)

Return a ModelingToolkit System describing an empirical relationship between the total water potential of the soil and its relative water content.

Inputs

None.

source
PlantModules.Ψ_air_moduleFunction
Ψ_air_module(; name, T)

Return a ModelingToolkit System describing the relationship between the total water potential of the air and its relative water content.

Inputs

Parameters

  • T: The temperature [K].
source
PlantModules.K_moduleFunction
K_module(; name, K_s, shape::ModuleShape)

Return a ModelingToolkit System describing the hydraulic conductance of a compartment as the product of its specific hydraulic conductance and an area of the compartment.

Inputs

Parameters

  • shape: The shape, defined as an instance of PlantModules.ModuleShape.
  • K_s: The specific hydraulic conductivity, defined per unit area of the cross section [g / h / MPa / cm^2].
source
PlantModules.constant_K_moduleFunction
constant_K_module(; name, K_s, shape::ModuleShape)

Return a ModelingToolkit System describing the hydraulic conductance of a compartment as a constant.

Inputs

Parameters

  • K: The hydraulic conductivity [g / h / MPa].
source

Edge modules

PlantModules.hydraulic_connectionFunction
hydraulic_connection(; name)

Returns a ModelingToolkit System describing a water flow connection between two hydraulics-based compartments.

This module assumes the compartments have a specified hydraulic conductivities.

Inputs

None.

source
PlantModules.constant_hydraulic_connectionFunction
constant_hydraulic_connection(; name, K)

Returns a ModelingToolkit System describing a water flow connection between two hydraulics-based functional modules.

This module specifies a constant hydraulic conductivity between the compartments.

Inputs

Parameters

  • K: The hydraulic conductivity [g / h / MPa].
source
PlantModules.daynight_hydraulic_connectionFunction
daynight_hydraulic_connection(; name, t_sunrise, t_sunset, η_night)

Returns a ModelingToolkit System describing a water flow connection between two hydraulics-based compartments that decreases at night.

This module assumes the compartments have a specified hydraulic conductivities.

Inputs

Parameters

  • t_sunrise: The time of sunrise [h].
  • t_sunset: The time of sunset [h].
  • η_night: The ratio of the hydraulic conductivity at night over the default hydraulic conducivity.
source

Graph reading and converting

PlantModules.convert_to_MTGFunction
convert_to_MTG(graph)

Convert a graph to MultiScaleTreeGraph.jl format. Requires definition of standard graph functions and tree graph functions (see graph_functions.jl)

source
PlantModules.convert_to_PGFunction
convert_to_PG(graph)

Convert a graph to PlantGraphs.jl format. Requires definition of standard graph functions and tree graph functions (see graph_functions.jl)

source

System remaking

PlantModules.remake_graphsystemFunction
remake_graphsystem(prob::AbstractSciMLProblem, sys::System, structure, varnames, subsystem_types, value)

Remake the given prob, changing the values of subsystem variables to a specified value. Only variables of given names and subsystem types are changed.

Inputs

  • prob::AbstractSciMLProblem: A SciML problem.
  • sys::System: The ModelingToolkit.jl system corresponding to the given problem.
  • structure: A graph representing the subsystem structure of the system. PlantModules' graph functions must be extended for the graph type. See also PlantStructure.
  • varnames: The name(s) of the desired variable.
  • subsystem_types: The desired type(s) of subsystem. For node modules, this corresponds to a node or a structural module. For edge modules (or connection modules), this corresponds to a connection, being a 2-tuple of node(s) and structural module(s).
  • value: The new variable value.
source
PlantModules.get_subsystem_variablesFunction
get_subsystem_variables(sys::System, structure, varname::Symbol, subsystem_type)

Get the Symbolics representation of all variables (unknowns or parameters) of a system with a given subsystem structure, filtered by variable name and type of subsystem. See remake_graphsystem for more information about the inputs.

source

Plotting

PlantModules.plotstructureFunction
plotstructure(plantstructure::PlantStructure)

Visualise the structure of a plant system.

This function is a thin wrapper around Plots.graphplot with some keyword arguments specified for plant structures.

source
PlantModules.plotgraphFunction
plotgraph(sol::ODESolution, graph; structmod, varname, kwargs...)

Return a plot for every functional variable for every node of the given graph for the given solution sol. Optionally, the user can give the name of a functional variable to only return a plot of this variable, give the name of a structural module to limit considered nodes to those of this type, or both.

source
PlantModules.plotnodeFunction
plotnode(sol::ODESolution, node; varname::Symbol)

Return a plot for every functional variable of the given node for the given solution sol. Optionally, the user can give the name of a functional variable to only return a plot of this variable.

source