You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/tutorials/from_tree_forest/raytracedforest.md
+21-16Lines changed: 21 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,19 @@
1
1
# Ray-traced forest
2
2
3
-
Alejandro Morales
3
+
Alejandro Morales and Ana Ernst
4
4
5
5
Centre for Crop Systems Analysis - Wageningen University
6
6
7
7
> ## TL;DR
8
8
> Now we want to forest growth model that PAR interception and introduces user to the ray-tracer.
9
-
> - Include material as a property for each object
10
-
> - Create sky for specific conditions and locations
9
+
> - Include [material](https://virtualplantlab.com/dev/manual/Raytracer/#Materials) as a property for each object
10
+
> - Create sky for specific conditions and locations using [SkyDomes](https://virtualplantlab.com/dev/VPLVerse/SkyDomes/)
11
11
> - Layer different types of radiation in sky domes (e.g., direct and diffuse)
12
12
> - Combine graph and sky with a ray-tracer
13
-
> - Compute growth and biomass production according to PAR interception and RUE
13
+
> - Compute growth and biomass production according to PAR interception and RUE
14
14
>
15
15
16
-
In this example we extend the forest growth model to include PAR interception and
17
-
radiation use efficiency to compute the daily growth rate.
16
+
In this example we extend the [Growth Forest](https://virtualplantlab.com/dev/tutorials/from_tree_forest/growthforest/) model to include PAR interception and radiation use efficiency to compute the daily growth rate.
18
17
19
18
The following packages are needed:
20
19
@@ -50,8 +49,8 @@ module TreeTypes
50
49
end
51
50
# Bud
52
51
struct Bud <:VirtualPlantLab.Nodeend
53
-
#Node
54
-
structNode<:VirtualPlantLab.Nodeend
52
+
#TreeNode
53
+
structTreeNode<:VirtualPlantLab.Nodeend
55
54
# BudNode
56
55
struct BudNode <:VirtualPlantLab.Nodeend
57
56
# Internode (needs to be mutable to allow for changes over time)
@@ -89,8 +88,8 @@ module TreeTypes
89
88
plastochron::Int64=5## Number of days between phytomer production
90
89
leaf_expansion::Float64=15.0## Number of days that a leaf expands
91
90
phyllotaxis::Float64=140.0
92
-
leaf_angle::Float64=30.0
93
-
branch_angle::Float64=45.0
91
+
leaf_angle::Float64=45.0
92
+
branch_angle::Float64=30.0
94
93
end
95
94
end
96
95
@@ -142,7 +141,7 @@ internodes and will only be triggered every X days, where X is the plastochron.
142
141
functioncreate_meristem_rule(vleaf, vint)
143
142
meristem_rule =Rule(TreeTypes.Meristem,
144
143
lhs = mer ->mod(data(mer).age, graph_data(mer).plastochron) ==0,
145
-
rhs = mer -> TreeTypes.Node() +
144
+
rhs = mer -> TreeTypes.TreeNode() +
146
145
(TreeTypes.Bud(),
147
146
TreeTypes.Leaf(biomass = vleaf.biomass,
148
147
length = vleaf.length,
@@ -175,11 +174,11 @@ function prob_break(bud)
175
174
child =children(child)[1]
176
175
data_child =data(child)
177
176
# If we encounter a node, extract the next internode
178
-
elseif data_child isa TreeTypes.Node
177
+
elseif data_child isa TreeTypes.TreeNode
179
178
child =filter(x ->data(x) isa TreeTypes.Internode, children(child))[1]
180
179
data_child =data(child)
181
180
else
182
-
error("Should be Internode, Node or Meristem")
181
+
error("Should be Internode, TreeNode or Meristem")
183
182
end
184
183
end
185
184
# Compute the probability of bud break as function of distance and
@@ -221,6 +220,7 @@ function create_soil()
221
220
VirtualPlantLab.translate!(soil, Vec(0.0, 10.5, 0.0)) ## Corner at (0,0,0)
222
221
return soil
223
222
end
223
+
224
224
functioncreate_scene(forest)
225
225
# These are the trees
226
226
scene =Scene(vec(forest))
@@ -251,10 +251,12 @@ function create_sky(;scene, lat = 52.0*π/180.0, DOY = 182)
251
251
dec =declination(DOY)
252
252
DL =day_length(lat, dec)*3600
253
253
# Compute solar irradiance
254
-
temp = [clear_sky(lat = lat, DOY = DOY, f = f) for f in fs] # W/m2
254
+
temp = [clear_sky(lat = lat, DOY = DOY, f = f) for f in fs] # Wm2
255
255
Ig =getindex.(temp, 1)
256
256
Idir =getindex.(temp, 2)
257
257
Idif =getindex.(temp, 3)
258
+
theta =getindex.(temp, 4)
259
+
phi =getindex.(temp, 5)
258
260
# Conversion factors to PAR for direct and diffuse irradiance
Copy file name to clipboardExpand all lines: docs/src/tutorials/from_tree_forest/tree.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Tree
2
2
3
-
Alejandro Morales
3
+
Alejandro Morales and Ana Ernst
4
4
5
5
Centre for Crop Systems Analysis - Wageningen University
6
6
@@ -14,17 +14,17 @@ In this example we build a 3D representation of a binary TreeTypes. Although thi
14
14
15
15
The model requires five types of nodes:
16
16
17
-
*Meristem*: These are the nodes responsible for growth of new organs in our binary TreeTypes. They contain no data or geometry (i.e. they are a point in the 3D structure).
17
+
-*Meristem*: These are the nodes responsible for growth of new organs in our binary TreeTypes. They contain no data or geometry (i.e. they are a point in the 3D structure).
18
18
19
-
*Internode*: The result of growth of a branch, between two nodes. Internodes are represented by cylinders with a fixed width but variable length.
19
+
-*Internode*: The result of growth of a branch, between two nodes. Internodes are represented by cylinders with a fixed width but variable length.
20
20
21
-
*Node*: What is left after a meristem produces a new organ (it separates internodes). They contain no data or geometry (so also a point) but are required to keep the branching structure of the tree as well as connecting leaves.
21
+
-*TreeNode*: What is left after a meristem produces a new organ (it separates internodes). They contain no data or geometry (so also a point) but are required to keep the branching structure of the tree as well as connecting leaves.
22
22
23
-
*Bud*: These are dormant meristems associated to tree nodes. When they are activated, they become an active meristem that produces a branch. They contain no data or geometry, but they change the orientation of the turtle.
23
+
-*Bud*: These are dormant meristems associated to tree nodes. When they are activated, they become an active meristem that produces a branch. They contain no data or geometry, but they change the orientation of the turtle.
24
24
25
-
*BudNode*: The node left by a bud after it has been activated. They contain no data or geometry, but they change the orientation of the turtle.
25
+
-*BudNode*: The node left by a bud after it has been activated. They contain no data or geometry, but they change the orientation of the turtle.
26
26
27
-
*Leaf*: These are the nodes associated to leaves in the TreeTypes. They are represented by ellipses with a particular orientation and insertion angle. The insertion angle is assumed constant, but the orientation angle varies according to an elliptical phyllotaxis rule.
27
+
-*Leaf*: These are the nodes associated to leaves in the TreeTypes. They are represented by ellipses with a particular orientation and insertion angle. The insertion angle is assumed constant, but the orientation angle varies according to an elliptical phyllotaxis rule.
28
28
29
29
In this first simple model, only internodes grow over time according to a relative growth rate, whereas leaves are assumed to be of fixed sized determined at their creation. For simplicity, all active meristems will produce a phytomer (combination of node, internode, leaves and buds) per time step. Bud break is assumed stochastic, with a probability that increases proportional to the number of phytomers from the apical meristem (up to 1). In the following tutorials, these assumptions are replaced by more realistic models of light interception, photosynthesis, etc.
30
30
@@ -41,8 +41,8 @@ module TreeTypes
41
41
struct Meristem <:VirtualPlantLab.Nodeend
42
42
# Bud
43
43
struct Bud <:VirtualPlantLab.Nodeend
44
-
#Node
45
-
structNode<:VirtualPlantLab.Nodeend
44
+
#TreeNode
45
+
structTreeNode<:VirtualPlantLab.Nodeend
46
46
# BudNode
47
47
struct BudNode <:VirtualPlantLab.Nodeend
48
48
# Internode (needs to be mutable to allow for changes over time)
@@ -59,8 +59,8 @@ module TreeTypes
59
59
growth::Float64=0.1
60
60
budbreak::Float64=0.25
61
61
phyllotaxis::Float64=140.0
62
-
leaf_angle::Float64=30.0
63
-
branch_angle::Float64=45.0
62
+
leaf_angle::Float64=45.0
63
+
branch_angle::Float64=30.0
64
64
end
65
65
end
66
66
````
@@ -99,9 +99,9 @@ end
99
99
The growth rule for a branch within a tree is simple: a phytomer (or basic unit of morphology) is composed of a node, a leaf, a bud node, an internode and an active meristem at the end. Each time step, the meristem is replaced by a new phytomer, allowing for the development within a branch.
100
100
101
101
````julia
102
-
meristem_rule =Rule(TreeTypes.Meristem, rhs = mer -> TreeTypes.Node() +
102
+
meristem_rule =Rule(TreeTypes.Meristem, rhs = mer -> TreeTypes.TreeNode() +
103
103
(TreeTypes.Bud(), TreeTypes.Leaf()) +
104
-
TreeTypes.Internode() + TreeTypes.Meristem())
104
+
TreeTypes.Internode() + TreeTypes.Meristem())
105
105
````
106
106
107
107
In addition, every step of the simulation, each bud may break, creating a new branch. The probability of bud break is proportional to the number of phytomers from the apical meristem (up to 1), which requires a relational rule to count the number of internodes in the graph up to reaching a meristem. When a bud breaks, it is replaced by a bud node, an internode and a new meristem. This new meristem becomes the apical meristem of the new branch, such that `meristem_rule` would apply. Note how we create an external function to compute whether a bud breaks or not. This is useful to keep the `branch_rule` rule simple and readable, while allow for a relatively complex bud break model. It also makes it easier to debug the bud break model, since it can be tested independently of the graph rewriting.
0 commit comments