rhizotron2 = pb.SDF_PlantContainer(r, r, h, True) posA = pb.Vector3d(0, r, -h / 2) # origin before rotation A = pb.Matrix3d.rotX(alpha / 180. * math.pi) posA = A.times(posA) # origin after rotation rotatedRhizotron = pb.SDF_RotateTranslate(rhizotron2, alpha, 0, posA.times(-1)) # 2. A split pot experiment topBox = pb.SDF_PlantBox(22, 20, 5) sideBox = pb.SDF_PlantBox(10, 20, 35) left = pb.SDF_RotateTranslate(sideBox, pb.Vector3d(-6, 0, -5)) right = pb.SDF_RotateTranslate(sideBox, pb.Vector3d(6, 0, -5)) box_ = [] box_.append(topBox) box_.append(left) box_.append(right) splitBox = pb.SDF_Union(box_) # 3. Rhizotubes as obstacles box = pb.SDF_PlantBox(96, 126, 130) # box rhizotube = pb.SDF_PlantContainer(6.4, 6.4, 96, False) # a single rhizotube rhizoX = pb.SDF_RotateTranslate(rhizotube, 90, pb.SDF_Axis.yaxis, pb.Vector3d(96 / 2, 0, 0)) rhizotubes_ = [] y_ = (-30, -18, -6, 6, 18, 30) z_ = (-10, -20, -40, -60, -80, -120) tube = [] for i in range(0, len(y_)): v = pb.Vector3d(0, y_[i], z_[i]) tube.append(pb.SDF_RotateTranslate(rhizoX, v)) rhizotubes_.append(tube[i])
import sys sys.path.append("../../..") import numpy as np import plantbox as pb import vtk_plot as vp rs = pb.RootSystem() path = "../../../modelparameter/rootsystem/" name = "Anagallis_femina_Leitner_2010" rs.readParameters(path + name + ".xml") # box with a left and a right compartment for analysis sideBox = pb.SDF_PlantBox(10, 20, 50) left = pb.SDF_RotateTranslate(sideBox, pb.Vector3d(-4.99, 0, 0)) right = pb.SDF_RotateTranslate(sideBox, pb.Vector3d(4.99, 0, 0)) leftright = pb.SDF_Union(left, right) rs.setGeometry(leftright) # left compartment has a minimum of 0.01, 1 elsewhere maxS = 1. # maximal minS = 0.1 # minimal slope = 1. # [cm] linear gradient between min and max leftC = pb.SDF_Complement(left) soilprop = pb.SoilLookUpSDF(leftC, maxS, minS, slope) # Manually set scaling function and tropism parameters sigma = [0.4, 1., 1., 1., 1.] * 2 for p in rs.getRootRandomParameter(): if p.subType > 2: p.dx = 0.25 # adjust resolution p.f_sa = soilprop # Scale insertion angle
print("Analyse time", t) for j in range(0, len(cores)): core_analyser = get_result(allRS, t) core_analyser.crop(cores[i]) core_analyser.pack() tl = core_analyser.distribution("length", 0, -h, nol, True) # vertical length distribution tl = np.array(tl) / ( len(cores) * r * r * math.pi * dz ) # <<< TODO WHY len(cores), its croped to 1 cylinder result_matrix[i * len(cores) + j, :] = tl if exportVTP: vtp_name = name + "_core_cropped" + str(i) + ".vtp" # export cropped segments for vizualisaten core_analyser.write(vtp_name) np.savetxt(name + "_core_matrix.txt", result_matrix, delimiter=', ') if exportVTP: g_name = name + "_core.py" cores_union = pb.SDF_Union(cores) allRS[0].setGeometry(cores_union) # just for writing allRS[0].write(g_name) print("fin.")