forked from Plant-Root-Soil-Interactions-Modelling/CRootBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example2b.py
31 lines (25 loc) · 853 Bytes
/
example2b.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import py_rootbox as rb
name = "Zea_mays_4_Leitner_2014"
simtime = 120
N = 3 # number of columns and rows
dist = 40 # distance between the root systems [cm]
# Initializes N*N root systems
allRS = []
for i in range(0,N):
for j in range(0,N):
rs = rb.RootSystem()
rs.openFile(name)
rs.getRootSystemParameter().seedPos = rb.Vector3d(dist*i,dist*j,-3.) # cm
rs.initialize()
allRS.append(rs)
# Simulate
for rs in allRS:
rs.simulate(simtime, True)
# Export results as single vtp files (as polylines)
ana = rb.SegmentAnalyser() # see example 3b
for i,rs in enumerate(allRS):
vtpname = "results/example_2b_"+str(i)+".vtp"
rs.write(vtpname)
ana.addSegments(rs) # collect all
# Write all into single file (segments)
ana.write("results/example_2b_all.vtp")