Exemple #1
0
# Manually set tropism to hydrotropism for the first ten root types
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.tropismT = rb.TropismType.hydro
    p.tropismN = 2 # strength of tropism
    p.tropismS = sigma[i] 
     
# Static soil property
maxS = 0.7 # maximal 
minS = 0.1 # minimal 
slope = 5 # linear gradient between min and max (cm)
box = rb.SDF_PlantBox(30,30,2) # cm
layer = rb.SDF_RotateTranslate(box, rb.Vector3d(0,0,-16))
soil_prop = rb.SoilLookUpSDF(layer, maxS, minS, slope)

# Set the soil properties before calling initialize
rs.setSoil(soil_prop)

# Initialize
rs.initialize()

# Simulate
simtime = 100 # e.g. 30 or 60 days
dt = 1
N = round(simtime/dt)
for _ in range(0,N):
    # in a dynamic soil setting you would need to update soil_prop        
    rs.simulate(dt)   
Exemple #2
0
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, 0, -1)
v2 = rb.Vector3d(1, 0, 0)
v3 = rb.Vector3d(0, 1, 0)
Exemple #3
0
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

#     # 2. Scale insertion angle
#     p.sa = soilprop
Exemple #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")