forked from Plant-Root-Soil-Interactions-Modelling/CRootBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark_copy.py
40 lines (33 loc) · 929 Bytes
/
benchmark_copy.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
32
33
34
35
36
37
38
39
40
import py_rootbox as rb
from rb_tools import *
import numpy as np
def test_copy():
# Parameter
simtime = 30. # days
dt = 1.
N = round(simtime/dt) # steps
name = "Anagallis_femina_Leitner_2010"
print("\n1 original")
rs = rb.RootSystem()
rs.openFile(name)
rs.setSeed(1) # before initialize to mimic
rs.initialize()
rs2 = rb.RootSystem(rs)
rs.simulate(simtime)
l1 = np.sum(v2a(rs.getScalar(rb.ScalarType.length)))
print("total length", l1)
print("\n2 copy")
rs2.simulate(simtime)
l2 = np.sum(v2a(rs2.getScalar(rb.ScalarType.length)))
print("total length", l2)
print("\n3 rebuild same")
rs3 = rb.RootSystem()
rs3.openFile(name)
rs3.setSeed(1)
rs3.initialize()
rs3.simulate(simtime)
l3 = np.sum(v2a(rs3.getScalar(rb.ScalarType.length)))
print("total length", l3)
return
if __name__ == '__main__':
test_copy()