Ejemplo n.º 1
0
rhizotron2 = rb.SDF_PlantContainer(r,r,h,True)
posA = rb.Vector3d(0,r,-h/2) # origin before rotation
A = rb.Matrix3d.rotX(alpha/180.*math.pi)
posA = A.times(posA) # origin after rotation
rotatedRhizotron = rb.SDF_RotateTranslate(rhizotron2,alpha,0,posA.times(-1))

# 2. A split pot experiment
topBox = rb.SDF_PlantBox(22,20,5)
sideBox = rb.SDF_PlantBox(10,20,35)
left = rb.SDF_RotateTranslate(sideBox, rb.Vector3d(-6,0,-5))
right = rb.SDF_RotateTranslate(sideBox, rb.Vector3d(6,0,-5))
box_ = rb.std_vector_SDF_()
box_.append(topBox)
box_.append(left)
box_.append(right)
splitBox = rb.SDF_Union(box_)

# 3. Rhizotubes as obstacles 
box = rb.SDF_PlantBox(96,126,130) # box
rhizotube = rb.SDF_PlantContainer(6.4,6.4,96,False) # a single rhizotube
rhizoX = rb.SDF_RotateTranslate(rhizotube, 90, rb.SDF_Axis.yaxis, rb.Vector3d(96/2,0,0))

rhizotubes_ = rb.std_vector_SDF_()
y_ = ( -30, -18, -6, 6, 18, 30 )
z_ = ( -10, -20, -40, -60, -80, -120 )
tube = [] 
for i in range(0,len(y_)):
    v = rb.Vector3d(0,y_[i],z_[i])
    tube.append(rb.SDF_RotateTranslate(rhizoX, v))
    rhizotubes_.append(tube[i])    
    
Ejemplo n.º 2
0
name = "Zea_mays_1_Leitner_2010"
rs.openFile(name)

# Pore Geometry
x_ = (-10, -5, 1, 15)  # not 0, otherwise we start in crack
y_ = (0, 0, 0, 0)
crack = rb.SDF_PlantBox(0.25, 100, 160)  # cm
cracks_ = rb.std_vector_SDF_()
py_cracks = []

for i in range(0, len(y_)):
    v = rb.Vector3d(x_[i], y_[i], 0)
    py_cracks.append(rb.SDF_RotateTranslate(crack, v))
    cracks_.append(py_cracks[-1])

cracks = rb.SDF_Union(cracks_)
rs.setPoreGeometry(cracks)

# Increased elongation within the pores
maxS = 2  # twice the elongation rate within the pore
minS = 1  # normal elongation rate
slope = 0
soil_prop = rb.SoilLookUpSDF(cracks, maxS, minS, slope)

# Adjust Tropism
sigma = [0.4] * 10
for i in range(0, 10):
    p = rs.getRootTypeParameter(i + 1)
    p.dx = 0.25  # adjust resolution
    p.tropismT = rb.TropismType.gravi
    p.tropismN = 1  # strength of tropism
Ejemplo n.º 3
0
import py_rootbox as rb
import math

rs = rb.RootSystem()
name = "Anagallis_femina_Leitner_2010"
rs.openFile(name)

# box with a left and a right compartment for analysis
sideBox = rb.SDF_PlantBox(10, 20, 50)
left = rb.SDF_RotateTranslate(sideBox, rb.Vector3d(-4.99, 0, 0))
right = rb.SDF_RotateTranslate(sideBox, rb.Vector3d(4.99, 0, 0))
leftright = rb.SDF_Union(left, right)
rs.setGeometry(leftright)

# left compartment has a minimum of 0.01, 1 elsewhere
maxS = 1.  # maximal
minS = 0.01  # minimal
slope = 1.  # [cm] linear gradient between min and max
leftC = rb.SDF_Complement(left)
soilprop = rb.SoilLookUpSDF(leftC, maxS, minS, slope)  # for root elongation
soilprop2 = rb.SoilLookUpSDF(left, 1., 0.002, slope)  # for branching

# Manually set scaling function and tropism parameters
sigma = [0.4, 1., 1., 1., 1.] * 2
for i in range(0, 10):
    p = rs.getRootTypeParameter(i + 1)
    p.dx = 0.25  # adjust resolution
    p.tropismS = sigma[i]

    # 1. Scale elongation
    p.se = soilprop
Ejemplo n.º 4
0
def call(cc):

    rs = rb.RootSystem()
    #name = "Triticum_aestivum_a_Bingham_2011" # is this the same as your wheat, Shehan?
    name = "wheat"
    rs.openFile(name)

    # Pore Geometry
    x_ = (-10, -5, 5, 15)  # not 0, otherwise we start in crack
    y_ = (0, 0, 0, 0)
    #x_=(-10, -5)
    #y_=(0,0)
    crack = rb.SDF_PlantBox(1.0, 100, 160)  # cm
    cracks_ = rb.std_vector_SDF_()
    py_cracks = []

    for i in range(0, len(y_)):
        v = rb.Vector3d(x_[i], y_[i], 0)
        py_cracks.append(rb.SDF_RotateTranslate(crack, v))
        cracks_.append(py_cracks[-1])

    cracks = rb.SDF_Union(cracks_)
    rs.setPoreGeometry(cracks)

    # Increased elongation within the pores
    maxS = 2  # twice the elongation rate within the pore
    minS = 1  # normal elongation rate
    slope = 0
    soil_prop = rb.SoilLookUpSDF(cracks, maxS, minS, slope)

    # Adjust Tropism
    sigma = [0.4] * 10
    for i in range(0, 10):
        p = rs.getRootTypeParameter(i + 1)
        p.dx = 0.25  # adjust resolution
        p.tropismT = rb.TropismType.gravi
        p.tropismN = 1  # strength of tropism
        p.tropismS = sigma[i]
        p.se = soil_prop

    # Pore Local Axes
    v1 = rb.Vector3d(0.67, 0, 0)
    v2 = rb.Vector3d(0, 0.67, 0)
    v3 = rb.Vector3d(0, 0, 0.67)
    rs.setPoreLocalAxes(rb.Matrix3d(v1, v2, v3))

    # Pore Conductivity Tensor
    t1 = rb.Vector3d(1.33, 0, 0)
    t2 = rb.Vector3d(0, 50.33, 0)
    t3 = rb.Vector3d(0, 0, 50.33)
    rs.setPoreConductivity(rb.Matrix3d(t1, t2, t3))

    # Set up depth dependent elongation scaling function
    scale_elongation = rb.EquidistantGrid1D(
        0, -160, 17)  # todo: replace this by reading in data from CSV file
    scales = np.zeros(
        len(scale_elongation.grid)
    ) + 0.1  # scales from some equation (scale = function(soil_strength) ), where scale in (0,1)
    scale_elongation.data = a2v(scales)  # set proportionality factors

    # Proportionally scale this function
    se2 = rb.ProportionalElongation()
    se2.setBaseLookUp(scale_elongation)

    # multiply the scale elongation functions
    se3 = rb.MultiplySoilLookUps(se2, soil_prop)

    # Manually set scaling function
    for i in range(0, 10):
        p = rs.getRootTypeParameter(i + 1)
        p.se = se3

    # Initialize
    rs.initialize()

    # Simulate
    simtime = 30 * 8  # e.g. 30 or 60 days
    dt = 1  #0.5 * 1./24.
    N = round(simtime / dt)

    for i in range(0, N):

        # time-dependent and depth-dependent scaling function
        scales = np.loadtxt('W2.csv', delimiter=';',
                            usecols=i)  # reading in ith column from CSV file
        scale_elongation.data = a2v(scales *
                                    1.00)  # set the data of scale elongation
        rs.simulate(dt)

    # Export results (as vtp)
    #rs.write("../results/crack.vtp")

    # Export cracks
    #rs.setGeometry(cracks)  # just for vizualisation
    #rs.write("../results/crack.py")

    z_ = np.linspace(0, -1 * 160, 160)

    # Make a root length distribution
    ana = rb.SegmentAnalyser(rs)
    rl_ = ana.distribution(rb.ScalarType.length, 0, 160, 160, True)
    np.set_printoptions(precision=4)
    np.savetxt("cw_" + str(cc) + ".txt", rl_, fmt="%.2f")