import sys sys.path.append("../../..") from cmath import pi import plantbox as pb import numpy as np import matplotlib.pyplot as plt path = "../../modelparameter/rootsystem/" name = "wheat_zero_std" # "maize_p1_zero_std" #"wheat" rs = pb.RootSystem() rs.readParameters(path + name + ".xml") rs.setSeed(1) # Manually set scale elongation function scale_elongation = pb.EquidistantGrid1D( 0, -200, 100) # for root elongation from 0 cm to -100 cm, 100 layers scales = np.ones((99, )) * 1 # imedance scale_elongation.data = scales # set proportionality factors for p in rs.getRootRandomParameter(): p.f_se = scale_elongation # p.r = 1; ############################################################################ # Soil core analysis depth, layers = 100., 20 interrow = 1 # inter-row spacing row = 1 # row spacing layerVolume = depth / layers * interrow * row simtime = 200 dt = 0.5
"""Scale root elongation based on EquidistantGrid1D""" import sys; sys.path.append("../../..") import plantbox as pb import numpy as np import vtk_plot as vp rs = pb.RootSystem() path = "../../../modelparameter/rootsystem/" name = "Anagallis_femina_Leitner_2010" rs.readParameters(path + name + ".xml") 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])