Ejemplo n.º 1
0
    def test_coord(self):
        pl = pb.MappedPlant()
        path = "../modelparameter/plant/"
        name = "test_relcoord"
        pl.readParameters(path + name + ".xml")
        #stochastic = False => thus rand() always give 0.5 for Tropism. => result only change according to sigma
        pl.initialize(stochastic=False)
        dt = 1
        steps = 100
        for step in range(steps):
            pl.simulate(1, False)
        pl.write("test_relcoord.vtp")
        params = pl.organParam
        seedPosx = params[1][0].seedPos.x
        seedPosy = params[1][0].seedPos.y
        seedPosz = params[1][0].seedPos.z
        #print(params[1][0].seedPos)
        roots = pl.getOrgans(2)
        leaves = pl.getOrgans(4)
        #stems = pl.getOrgans(3)

        rootSubtypes = [o.param().subType for o in roots]
        #stemSubtypes = [ o.param().subType for o in stems]

        #roots1 = np.array(roots)[np.where([st == 1 for st in rootSubtypes])[0]]
        #roots2 = np.array(roots)[np.where([st == 2 for st in rootSubtypes])[0]]
        roots3 = np.array(roots)[np.where([st == 3 for st in rootSubtypes])[0]]

        #stems1 = np.array(roots)[np.where([st == 1 for st in stemSubtypes])[0]]
        #stems3 = np.array(roots)[np.where([st == 3 for st in stemSubtypes])[0]]

        rootTipsX = [
            np.array(r.getNode(r.getNumberOfNodes() - 1))[0] for r in roots3
        ]
        rootTipsY = [
            np.array(r.getNode(r.getNumberOfNodes() - 1))[1] for r in roots3
        ]
        rootTipsZ = [
            np.array(r.getNode(r.getNumberOfNodes() - 1))[2] for r in roots3
        ]

        leafTipsX = [
            np.array(r.getNode(r.getNumberOfNodes() - 1))[0] for r in leaves
        ]
        leafTipsY = [
            np.array(r.getNode(r.getNumberOfNodes() - 1))[1] for r in leaves
        ]
        leafTipsZ = [
            np.array(r.getNode(r.getNumberOfNodes() - 1))[2] for r in leaves
        ]

        for i in range(0, len(rootTipsX)):
            #print(rootTipsX[i], leafTipsX[i])
            self.assertAlmostEqual(
                rootTipsX[i] - seedPosx, -(leafTipsX[i] - seedPosx), 10,
                "tip of 3rd lat root and leaf n°" + str(i) + " not symetric")
        for i in range(0, len(rootTipsY)):
            #print(rootTipsY[i]*10**16, leafTipsY[i]*10**16)
            self.assertAlmostEqual(
                rootTipsY[i] * 10**16, leafTipsY[i] * 10**16, 10,
                "tip of 3rd lat root and leaf n°" + str(i) + " not symetric")
        for i in range(0, len(rootTipsZ)):
            #print(rootTipsZ[i]-seedPosz, leafTipsZ[i]-seedPosz, seedPosz)
            self.assertAlmostEqual(
                rootTipsZ[i] - seedPosz, -(leafTipsZ[i] - seedPosz), 10,
                "tip of 3rd lat root and leaf n°" + str(i) + " not symetric")
Ejemplo n.º 2
0
#p_g = -2000 # water potential of the guard cell
RH = 0.5  # relative humidity
TairC = 20
p_a = -1000  #default outer water potential
simtime = 14.0  # [day] for task b
k_soil = []
Q = 900e-6  # mol quanta m-2 s-1 light, example from leuning1995
cs = 350e-6  #co2 paartial pressure at leaf surface (mol mol-1)
TairK = TairC + 273.15

es = 0.61078 * math.exp(17.27 * TairC / (TairC + 237.3))
ea = es * RH
VPD = es - ea

# root system
pl = pb.MappedPlant()  #pb.MappedRootSystem() #pb.MappedPlant()
path = "../../../modelparameter/plant/"  #"../../../modelparameter/rootsystem/"
name = "manyleaves"  #"Anagallis_femina_Leitner_2010"  # Zea_mays_1_Leitner_2010
pl.readParameters(path + name + ".xml")
""" soil """
min_ = np.array([-5, -5, -15])
max_ = np.array([9, 4, 0])
res_ = np.array([5, 5, 5])
pl.setRectangularGrid(pb.Vector3d(min_), pb.Vector3d(max_), pb.Vector3d(res_),
                      True)  # cut and map segments

pl.initialize()
pl.simulate(simtime, False)
#rs.simulate(simtime, False) #test to see if works in case of several simulate

r = Leuning(pl)
Ejemplo n.º 3
0
dir_name = "/results"
dir_name2 = home_dir + dir_name
test = os.listdir(dir_name2)
for item in test:
    if item.endswith("10.txt"):
        os.remove(os.path.join(dir_name2, item))
    if item.endswith("10.vtk"):
        os.remove(os.path.join(dir_name2, item))
    if item.endswith("10.vtp"):
        os.remove(os.path.join(dir_name2, item))

######################
#
# plant
#
#######################
pl = pb.MappedPlant(seednum=1)  #set seed
path = "../../../modelparameter/plant/"  #"../../../modelparameter/rootsystem/"
name = "4testrel"

pl.readParameters(path + name + ".xml")
dt = 1
steps = 35
pl.initialize(verbose=True)

for step in range(steps):
    print("\n\n\nstep n°", step)
    pl.simulate(dt, True)
    ana = pb.SegmentAnalyser(pl)
    ana.write("results/example_10_%s.vtp" % (step))