# increase resolution for p in plant.getOrganRandomParameter(pb.root): p.dx = 0.2 # Initialize plant.initialize() dt = 0.1 N = 400 min_ = np.array([-20, -20, -50]) max_ = np.array([20, 20, 30.]) # test = plant.getOrgans(pb.leaf) # print("test") anim = vp.AnimateRoots(plant) anim.min = min_ anim.max = max_ anim.res = [1, 1, 1] anim.file = "results/example_plant" anim.avi_name = "results/example_" anim.plant = True anim.start() for i in range(0, N): plant.simulate(dt, False) anim.root_name = "organType" anim.update()
scale_elongation = pb.EquidistantGrid1D(0, -50, 100) soil_strength = np.ones((99,)) soil_strength[20:30] = 5 # data, with a very dense layer at -10 to -15 cm scales = np.exp(-0.4 * soil_strength) # equation (TODO) scale_elongation.data = scales # set proportionality factors print("-3 cm ", scale_elongation.getValue(pb.Vector3d(0, 0, -3))) print("-25 cm", scale_elongation.getValue(pb.Vector3d(0, 0, -25))) for p in rs.getRootRandomParameter(): p.f_se = scale_elongation # set scale elongation function rs.initialize() ana = pb.SegmentAnalyser(rs) anim = vp.AnimateRoots(ana) anim.root_name = "creationTime" anim.file = "example5b" anim.min = np.array([-10, -10, -50]) anim.max = np.array([10, 10, 0.]) anim.res = np.array([1, 1, 1]) anim.start() simtime = 60. dt = 0.1 # small, for animation for i in range(0, round(simtime / dt)): # Simulation # update soil model (e.g. soil_strength) # update scales (e.g. from water content, soil_strength) scales = np.exp(-0.4 * soil_strength) # (TODO)
rs.readParameters(path + name + ".xml") """ soil """ min_ = np.array([-5, -5, -15]) max_ = np.array([5, 5, 0.]) res_ = np.array([1, 3, 5]) if not periodic: sdf = pb.SDF_PlantBox(0.99 * (max_[0] - min_[0]), 0.99 * (max_[1] - min_[1]), 0.99 * (max_[2] - min_[2])) rs.setGeometry(sdf) rs.setRectangularGrid(pb.Vector3d(min_), pb.Vector3d(max_), pb.Vector3d(res_), False) # cut and map segments rs.initialize() rs.simulate(rs_age, False) N = round(sim_time / dt) anim = vp.AnimateRoots(rs) anim.min = min_ anim.max = max_ anim.res = res_ anim.file = "results/example7a" anim.start() for i in range(0, N): rs.simulate(dt, False) """ add segment indices """ segs = rs.segments x = np.zeros(len(segs)) for i, s in enumerate(segs): try: