Esempio n. 1
0
 def stem_example_rtp(self):
     """ an example used in the tests below, a main stem with laterals """
     self.plant = pb.Organism(
     )  # store organism (not owned by Organ, or OrganRandomParameter)
     p0 = pb.StemRandomParameter(self.plant)
     p0.name, p0.subType, p0.la, p0.lb, p0.lmax, p0.ln, p0.r, p0.dx = "main", 1, 1, 10, 100, (
         89. / 19.), 1, 0.5
     p0.successor = [3]
     p0.successorP = [1.]
     p1 = pb.StemRandomParameter(self.plant)
     p1.name, p1.subType, p1.la, p1.ln, p1.r, p1.dx = "lateral", 3, 25, 0, 2, 0.1
     self.p0, self.p1 = p0, p1  # needed at later point
     self.plant.setOrganRandomParameter(
         p0)  # the organism manages the type parameters and takes ownership
     self.plant.setOrganRandomParameter(p1)
     # TODO (first node is not set, if seed is used)
     self.plant.setOrganRandomParameter(pb.SeedRandomParameter(self.plant))
     self.seed = pb.Seed(
         self.plant)  # store parent (not owned by child Organ)
     #
     param0 = p0.realize()  # set up stem by hand (without a stem system)
     param0.la, param0.lb = 0, 0  # its important parent has zero length, otherwise creation times are messed up
     parentstem = pb.Stem(1, param0, True, True, 0., 0.,
                          pb.Vector3d(0, 0, -1), 0, 0, False,
                          0)  # takes ownership of param0
     parentstem.setOrganism(self.plant)
     parentstem.addNode(pb.Vector3d(0, 0, -3),
                        0)  # there is no nullptr in Python
     self.parentstem = parentstem  # store parent (not owned by child Organ)
     #
     self.stem = pb.Stem(self.plant, p0.subType, pb.Vector3d(0, 0, -1), 0,
                         self.parentstem, 0, 0)
     self.stem.setOrganism(self.plant)
 def test_parameter(self):
     """ tests getParameter() """
     plant = pb.Organism()
     srp = pb.SeedRandomParameter(plant)
     srp.firstB = 0.123
     srp.delaySBs = 12
     ot = srp.getParameter("organType")  # test defaults
     st = srp.getParameter("subType")
     nz = srp.getParameter("nz")
     firstB = srp.getParameter("firstB")
     delaySBs = srp.getParameter("delaySB_dev")
     firstB2 = srp.getParameter(
         "firstB_mean"
     )  # we can always add "_mean" to avoid naming conflicts
     self.assertEqual(ot, 1., "getParameter: value unexpected")
     self.assertEqual(st, 0, "getParameter: value unexpected")
     self.assertEqual(nz, 1., "getParameter: value unexpected")
     self.assertEqual(firstB, 0.123, "getParameter: value unexpected")
     self.assertEqual(firstB, firstB2, "getParameter: value unexpected")
     self.assertEqual(delaySBs, 12, "getParameter: value unexpected")
     srp.firstB = 123  # change values
     srp.delaySBs = 456
     firstB = srp.getParameter("firstB")
     delaySBs = srp.getParameter("delaySB_dev")
     self.assertEqual(firstB, 123, "getParameter: value unexpected")
     self.assertEqual(delaySBs, 456, "getParameter: value unexpected")
Esempio n. 3
0
    def root_example_rrp(self):
        """ an example used in the tests below, a main root with laterals """
        self.plant = pb.Organism(
        )  # store organism (not owned by Organ, or OrganRandomParameter)
        p0 = pb.RootRandomParameter(self.plant)
        p0.name, p0.subType, p0.la, p0.lb, p0.lmax, p0.ln, p0.r, p0.dx = "taproot", 1, 10., 1., 100., 1., 1.5, 0.5
        p0.successor = [2]
        p0.successorP = [1.]
        p1 = pb.RootRandomParameter(self.plant)
        p1.name, p1.subType, p1.lmax, p1.r, p1.dx = "lateral", 2, 25., 2., 0.1
        self.p0, self.p1 = p0, p1  # needed at later point
        self.plant.setOrganRandomParameter(
            p0)  # the organism manages the type parameters and takes ownership
        self.plant.setOrganRandomParameter(p1)
        srp = pb.SeedRandomParameter(self.plant)
        self.plant.setOrganRandomParameter(srp)

        param0 = p0.realize()  # set up root by hand (without a root system)
        param0.la, param0.lb = 0, 0  # its important parent has zero length, otherwise creation times are messed up
        parentroot = pb.Root(1, param0, True, True, 0., 0.,
                             pb.Vector3d(0, 0, -1), 0, 0, False,
                             0)  # takes ownership of param0
        parentroot.setOrganism(self.plant)
        parentroot.addNode(pb.Vector3d(0, 0, -3),
                           0)  # there is no nullptr in Python

        self.parentroot = parentroot  # store parent (not owned by child Organ)
        self.root = pb.Root(self.plant, p0.subType, pb.Vector3d(0, 0, -1), 0,
                            self.parentroot, 0, 0)
        self.root.setOrganism(self.plant)
Esempio n. 4
0
    def test_leaf(self):
        """ leaf without lateral leafs """
        ons = pb.Matrix3d(pb.Vector3d(0., 0., 1.), pb.Vector3d(0., 1., 0.), pb.Vector3d(1., 0., 0.))
        plant = pb.Plant()  # store organism (not owned by Organ, or OrganRandomParameter)
        p0 = pb.LeafRandomParameter(plant)
        p0.name, p0.subType, p0.la, p0.lb, p0.lmax, p0.ln, p0.r, p0.dx = "leaf", 1, 3.5, 1., 7.5, 3, 1, 0.1   
          
        phi = np.array([-90, -45, 0., 45, 90]) / 180. * np.pi
        l = np.array([3, 2.2, 1.7, 2, 3.5])
        N = 100  # N is rather high for testing
        p0.createLeafRadialGeometry(phi, l, N)            
#         y = np.array([-3, -3 * 0.7, 0., 3.5 * 0.7, 3.5])
#         l = np.array([0., 2.2 * 0.7, 1.7, 1.8 * 0.7, 0.])
#         N = 105  # N is rather high for testing
#         p0.createLeafGeometry(y, l, N)   
               
        plant.setOrganRandomParameter(p0)  # the organism manages the type parameters and takes ownership        
        plant.setOrganRandomParameter(pb.SeedRandomParameter(plant))       
        # because we cannot pass a nullptr to pb.Leaf(...) L48
        param0 = p0.realize()  # set up leaf by hand (without a leaf syleaf)
        param0.la, param0.lb = 0, 0  # its important parent has zero length, otherwise creation times are messed up
        parentleaf = pb.Leaf(1, param0, True, True, 0., 0., ons, 0, False, 0)  # takes ownership of param0
        parentleaf.setOrganism(plant)     
        parentleaf.addNode(pb.Vector3d(0, 0, -3), 0)  # there is no nullptr in Python   

        leaf = pb.Leaf(plant, p0.subType, ons, 0, parentleaf , 0)
        leaf.setOrganism(plant)
        leaf.simulate(7)
        vp.plot_leaf(leaf)
 def test_toString(self):
     """ tests __str__ output """
     self.srp = pb.SeedRandomParameter(pb.Organism())
     srp = self.srp  # rename
     srp.name = "the seed"
     # print(srp.__str__(False))
     # print(srp)
     self.assertEqual(srp.__str__(False),
                      "name: the seed, organType: 1, subType: 0.",
                      "toString: value unexpected")
 def shoot_example(self):
     """ example seed parameters used below """
     self.plant = pb.Organism()
     self.srp = pb.SeedRandomParameter(self.plant)
     self.srp.firstB = 10
     self.srp.delayB = 7
     self.srp.nC = 5
     self.srp.firstSB = 21
     self.srp.delaySB = 4
     self.srp.delayRC = 15
     self.srp.nz = 1.
     self.srp.subType = 0
Esempio n. 7
0
 def get_srp(self):
     self.plant = pb.Organism()  # need to store this
     srp = pb.SeedRandomParameter(self.plant)
     srp.seedPos = pb.Vector3d(0, 0, -2)
     srp.firstB = 3  # basal
     srp.delayB = 5
     srp.maxB = 7
     srp.nC = 7
     srp.firstSB = 30  # shoot borne
     srp.delaySB = 10
     srp.delayRC = 70
     srp.nz = 0.7
     srp.maxTil = 3  # stem
     srp.simtime = 10
     self.plant.setOrganRandomParameter(srp)
     return srp
Esempio n. 8
0
    def root_example_rrp2(self):
        """ an example used in the tests below, a main root with laterals """
        self.plant = pb.RootSystem(
        )  # store organism (not owned by Organ, or OrganRandomParameter)
        p0 = pb.RootRandomParameter(self.plant)
        p0.name, p0.subType, p0.la, p0.lb, p0.lmax, p0.ln, p0.lnk, p0.r, p0.dx, p0.dxMin = "taproot", 1, 0.95, 0.8, 10., 1.05, 0.01, 0.8, 0.25, 0.2
        p0.successor = [2]
        p0.successorP = [1.]
        p1 = pb.RootRandomParameter(self.plant)
        p1.name, p1.subType, p1.lmax, p1.r, p1.dx = "lateral", 2, 2., 2., 2.

        self.plant.setOrganRandomParameter(
            p0)  # the organism manages the type parameters and takes ownership
        self.plant.setOrganRandomParameter(p1)
        srp = pb.SeedRandomParameter(self.plant)
        self.plant.setOrganRandomParameter(srp)

        print("root p0, initial parameters: lmax = ", p0.lmax, ", lb = ",
              p0.lb, ", la = ", p0.la, ", ln = ", p0.ln)
        param0 = p0.realize()  # set up root by hand (without a root system)
        print("root p0, realized parameters: lmax = ",
              sum((sum(param0.ln), param0.lb, param0.la)), ", lb = ",
              param0.lb, ", la = ", param0.la, ", mean ln = ",
              np.mean(param0.ln))
        if ((param0.lb % p0.dx > 0) and (param0.lb % p0.dx < p0.dxMin * 0.99)):
            print("lb value does not fit with dx and dxMin")
            print(param0.lb % p0.dx)
        if ((param0.la % p0.dx > 0) and (param0.la % p0.dx < p0.dxMin * 0.99)):
            print("la value does not fit with dx and dxMin")
            print(param0.la % p0.dx)
        if (any([(lni % p0.dx > 0 and lni % p0.dx < p0.dxMin * 0.99)
                 for lni in param0.ln])):
            print("ln value does not fit with dx and dxMin")

        param0.la, param0.lb = 0, 0  # its important parent has zero length, otherwise creation times are messed up
        parentroot = pb.Root(1, param0, True, True, 0., 0.,
                             pb.Vector3d(0, 0, -1), 0, 0, False,
                             0)  # takes ownership of param0
        parentroot.setOrganism(self.plant)
        parentroot.addNode(pb.Vector3d(0, 0, -1),
                           0)  # there is no nullptr in Python

        self.parentroot = parentroot  # store parent (not owned by child Organ)
        self.root = pb.Root(self.plant, p0.subType, pb.Vector3d(0, 0, -1), 0,
                            self.parentroot, 0, 0)
        self.root.setOrganism(self.plant)
        self.p0 = p0
 def test_constructors(self):
     """ tests constructor and copy """
     plant = pb.Organism()
     srp = pb.SeedRandomParameter(plant)
     srp.firstB = 123
     srp.firstBs = 456
     srp.nz = 789
     srp2 = srp.copy(plant)
     self.assertIsNot(srp, srp2,
                      "copy: organ type parameter set is not copied")
     self.assertEqual(srp2.name, srp.name, "copy: value unexpected")
     self.assertEqual(srp2.organType, srp.organType,
                      "copy: value unexpected")
     self.assertEqual(srp2.subType, srp.subType, "copy: value unexpected")
     self.assertEqual(srp2.firstB, srp.firstB, "copy: value unexpected")
     self.assertEqual(srp2.firstBs, srp.firstBs, "copy: value unexpected")
     self.assertEqual(srp2.nz, srp.nz, "copy: value unexpected")
Esempio n. 10
0
 def rs_example_rtp(self):
     """ an example used in some of the tests below, 100 basals with laterals """
     self.rs = pb.RootSystem()
     srp = pb.SeedRandomParameter(self.rs)
     srp.subType = 0
     srp.seedPos = pb.Vector3d(0., 0., -3.)
     srp.maxB = 100
     srp.firstB = 10
     srp.delayB = 3
     self.rs.setRootSystemParameter(srp)
     p0 = pb.RootRandomParameter(self.rs)
     p0.name, p0.subType, p0.la, p0.lmax, p0.ln, p0.r, p0.dx = "taproot", 1, 10, 101, 89. / 19., 1, 0.5
     p0.lb = 2
     p0.successor = [2]
     p0.successorP = [1.]
     p1 = pb.RootRandomParameter(self.rs)
     p1.name, p1.subType, p1.la, p1.ln, p1.r, p1.dx = "lateral", 2, 25, 0, 2, 0.1
     self.p0, self.p1, self.srp = p0, p1, srp  # Python will garbage collect them away, if not stored
     self.rs.setOrganRandomParameter(p0)  # the organism manages the type parameters
     self.rs.setOrganRandomParameter(p1)
Esempio n. 11
0
 def test_xml(self):
     """ write the organ as xml, and rereads it """
     self.shoot_example()
     otp = self.srp  # rename
     otp.name = "best_seed"
     otp.subType = 0
     otp.writeXML("seed.xml")
     otp2 = pb.SeedRandomParameter(self.plant)
     otp2.readXML("seed.xml")
     self.assertEqual(otp2.name, otp.name, "xml: value unexpected")
     self.assertEqual(otp2.organType, otp.organType,
                      "xml: value unexpected")
     self.assertEqual(otp2.subType, otp.subType, "xml: value unexpected")
     self.assertEqual(otp2.firstB, otp.firstB,
                      "xml: value unexpected")  # value
     self.assertEqual(otp2.delayRC, otp.delayRC,
                      "xml: value unexpected")  # value
     self.assertEqual(otp2.firstBs, otp.firstBs,
                      "xml: value unexpected")  # dev
     self.assertEqual(otp2.delayRCs, otp.delayRCs,
                      "xml: value unexpected")  # dev
Esempio n. 12
0
    def stem_example_rtp(self, phytomereGrowth = "sequential"):
        """ an example used in the tests below, a main stem with laterals """
        self.plant = pb.Plant()  # store organism (not owned by Organ, or OrganRandomParameter)
        p0 = pb.StemRandomParameter(self.plant)
        p0.name, p0.subType, p0.la, p0.lb, p0.lmax, p0.ln, p0.r, p0.dx, p0.dxMin = "main", 1, 10., 10., 100., 1., 1.5, 1, 0.5
        p0.delayLat = 1.
        p0.delayNG = 2.
        p0.successor = [5]
        p0.successorP = [1.]

        if phytomereGrowth == "sequential":
            p0.nodalGrowth = 0
        if phytomereGrowth == "equal":
            p0.nodalGrowth = 1

        p1 = pb.StemRandomParameter(self.plant)
        p1.name, p1.subType, p1.lmax, p1.r, p1.dx, p1.dxMin = "lateral", 5, 5., 2., 1, 0.5
        self.p0, self.p1 = p0, p1  # needed at later point
        self.plant.setOrganRandomParameter(p0)  # the organism manages the type parameters and takes ownership
        self.plant.setOrganRandomParameter(p1)

        srp = pb.SeedRandomParameter(self.plant)
        self.plant.setOrganRandomParameter(srp)

        # creates seed organ (otherwise throws error in plant::simulate())
        # test == True => no need to give root parameter
        self.plant.initialize(verbose = False, test = True)

        param0 = p0.realize()  # set up stem by hand (without a stem system)
        param0.la, param0.lb = 0, 0  # its important parent has zero length, otherwise creation times are messed up
        self.ons = pb.Matrix3d(pb.Vector3d(0., 0., 1.), pb.Vector3d(0., 1., 0.), pb.Vector3d(1., 0., 0.))
        parentstem = pb.Stem(1, param0, True, True, 0., 0., self.ons, 0, False, 0)  # takes ownership of param0
        parentstem.setOrganism(self.plant)
        parentstem.addNode(pb.Vector3d(0, 0, -3), 0)  # there is no nullptr in Python
        self.parentstem = parentstem  # store parent (not owned by child Organ)
        self.stem = pb.Stem(self.plant, p0.subType, self.ons, 0, self.parentstem , 0)
        self.stem.setOrganism(self.plant)
Esempio n. 13
0
p2.dx = 0.25  # [cm] axial resolution
p2.a, p2.a_s = 0.0501, 0.0069  # [cm] radius TODO
p2.theta = (180. - 98.45) / 180. * np.pi  # [rad]
# p2.lmax, p2.lmaxs = 3.339, 0.2 * 3.339  # fit k and r
# p2.r, p2.rs = 3.745, 0.1 * 3.745  # fit k and r
p2.lmax, p2.lmaxs = 5, 0.5  # fit r
p2.r, p2.rs = 0.483, 0.1 * 0.483  # fit r
p2.r, p2.rs = 0.823, 0.1 * 0.823  # fit r (last measurement removed)
# by visual comparison
p2.tropismT, p2.tropismN, p2.tropismS = pb.TropismType.gravi, 1, 0.2

rs.setOrganRandomParameter(p0)
rs.setOrganRandomParameter(p1)
rs.setOrganRandomParameter(p2)
""" seed """
srp = pb.SeedRandomParameter(rs)  # with default values
srp.seedPos = pb.Vector3d(0., 0., -0.6)  # [cm] seed position TODO ?
srp.maxB = 0  # [-] number of basal roots (neglecting basal roots and shoot borne)
rs.setRootSystemParameter(srp)
""" container geometry """
length = 7.425  # cm
height = 14.31  # cm
rhizotron = pb.SDF_PlantBox(length, length, height)
rs.setGeometry(rhizotron)  # soilcore, or rhizotron

# elongation impedance at boundaries
layer = 0.5  # cm
smaller_rhizotron = pb.SDF_PlantBox(length - 2 * layer, length - 2 * layer,
                                    height - layer)
scale_elongation = Boundary_Elongation_Impedance(
    smaller_rhizotron, 0.1)  # 1 instead of 0.1 would disable the impedance
def create_basil():
	plant = pb.Plant()
	p0 = pb.RootRandomParameter(plant)  # with default values,
	p1 = pb.RootRandomParameter(plant)  # all standard deviations are 0
	s2 = pb.StemRandomParameter(plant)
	s3 = pb.StemRandomParameter(plant)
	l1 = pb.LeafRandomParameter(plant)

	p0.name = "taproot"
	p0.a = 0.2  # [cm] radius
	p0.subType = 1  # [-] index starts at 1
	p0.lb = 5  # [cm] basal zone
	p0.la = 10  # [cm] apical zone
	p0.lmax = 30  # [cm] maximal root length, number of lateral branching nodes = round((lmax-lb-la)/ln) + 1
	p0.ln = 1.  # [cm] inter-lateral distance (16 branching nodes)
	p0.theta = 0.  # [rad]
	p0.r = 1  # [cm/day] initial growth rate
	p0.dx = 10  # [cm] axial resolution
	p0.successor = [2]  # add successors
	p0.successorP = [1]  # probability that successor emerges
	p0.tropismT = pb.TropismType.gravi  #
	p0.tropismN = 1.8  # [-] strength of tropism
	p0.tropismS = 0.2  # [rad/cm] maximal bending

	p1.name = "lateral"
	p1.a = 0.1  # [cm] radius
	p1.subType = 2  # [1] index starts at 1
	p1.lmax = 15  # # [cm] apical zone
	p1.lmaxs = 0.15  # [cm] standard deviation of the apical zone
	p1.theta = 90. / 180. * np.pi  # [rad]
	p1.r = 2  # initial growth rate
	p1.dx = 1  # [cm] axial resolution
	p1.tropismT = pb.TropismType.gravi  # exo
	p1.tropismN = 2  # [-] strength of tropism
	p1.tropismS = 0.1  # [rad/cm] maximal bending

	s2.name = "mainstem"
	s2.subType = 1
	s2.lmax = 25
	# s2.lmaxs = 1
	s2.lb = 3
	s2.la = 0
	s2.ln = 3  # This value is normally the Inter-lateral distance [cm], but with decussate plant, this value is
	# multiplied by 2
	s2.lnf = 5  # This value means "successors in a decussate position"
	s2.RotBeta = 1
	s2.BetaDev = 0
	s2.InitBeta = 0
	s2.gf = 1
	s2.successor = [2]
	s2.successorP = [1]
	s2.tropismT = 4
	# s2.theta = 1/6
	s2.theta = 0
	s2.tropismN = 18
	s2.tropismS = 0.01

	s3.name = "invisible"  # The invisible stem representing the bud of the leaf
	s3.subType = 2
	s3.la = 0
	s3.ln = 0
	s3.lmax = 5
	s3.RotBeta = 1
	s3.BetaDev = 0
	s3.InitBeta = 0.5
	s3.tropismS = 0
	s3.lnf = 5

	l1.name = 'basil'
	l1.subType = 2
	l1.lb = 2
	l1.la = 0.2
	l1.lmax = 5
	l1.r = 0.5
	l1.RotBeta = 0.5
	l1.BetaDev = 0
	l1.InitBeta = 0.5
	l1.tropismT = 1
	l1.tropismN = 5
	l1.tropismS = 0.1
	l1.theta = 0.35
	l1.thetas = 0.05
	l1.gf = 1
	l1.lnf = 5  # If not precised, it will not be possible to do the opposite decussate arrangement

	plant.setOrganRandomParameter(p0)
	plant.setOrganRandomParameter(p1)
	plant.setOrganRandomParameter(s2)
	plant.setOrganRandomParameter(s3)
	plant.setOrganRandomParameter(l1)

	srp = pb.SeedRandomParameter(plant)  # with default values
	# srp.seedPos = pb.Vector3d(10, 10, -3.)  # [cm] seed position
	srp.seedPos = pb.Vector3d(0, 0, -3.)  # [cm] seed position
	srp.maxB = 0  # [-] number of basal roots (neglecting basal roots and shoot borne)
	srp.firstB = 10.  # [day] first emergence of a basal root
	srp.delayB = 3.  # [day] delay between the emergence of basal roots
	plant.setOrganRandomParameter(srp)

	return plant
def create_arabidopsis():
	plant = pb.Plant()
	p0 = pb.RootRandomParameter(plant)  # with default values,
	p1 = pb.RootRandomParameter(plant)  # all standard deviations are 0
	s1 = pb.StemRandomParameter(plant)
	s2 = pb.StemRandomParameter(plant)
	s3 = pb.StemRandomParameter(plant)
	s4 = pb.StemRandomParameter(plant)
	l1 = pb.LeafRandomParameter(plant)

	p0.name = "taproot"
	p0.a = 0.2  # [cm] radius
	p0.subType = 1  # [-] index starts at 1
	p0.lb = 5  # [cm] basal zone
	p0.la = 10  # [cm] apical zone
	p0.lmax = 30  # [cm] maximal root length, number of lateral branching nodes = round((lmax-lb-la)/ln) + 1
	p0.ln = 1.  # [cm] inter-lateral distance (16 branching nodes)
	p0.theta = 0.  # [rad]
	p0.r = 1  # [cm/day] initial growth rate
	p0.dx = 10  # [cm] axial resolution
	p0.successor = [2]  # add successors
	p0.successorP = [1]  # probability that successor emerges
	p0.tropismT = pb.TropismType.gravi  #
	p0.tropismN = 1.8  # [-] strength of tropism
	p0.tropismS = 0.2  # [rad/cm] maximal bending

	p1.name = "lateral"
	p1.a = 0.1  # [cm] radius
	p1.subType = 2  # [1] index starts at 1
	p1.lmax = 15  # # [cm] apical zone
	p1.lmaxs = 0.15  # [cm] standard deviation of the apical zone
	p1.theta = 90. / 180. * np.pi  # [rad]
	p1.r = 2  # initial growth rate
	p1.dx = 1  # [cm] axial resolution
	p1.tropismT = pb.TropismType.gravi  # exo
	p1.tropismN = 2  # [-] strength of tropism
	p1.tropismS = 0.1  # [rad/cm] maximal bending

	s1.name = "mainstem"
	s1.subType = 1
	s1.lmax = 25
	s1.lmaxs = 1
	s1.lb = 0
	s1.lbs = 0.1
	s1.la = 3
	s1.las = 0.1
	s1.ln = 3
	s1.lns = 0.2
	s1.lnf = 0  # 1 peut être cool
	s1.RotBeta = 0
	s1.BetaDev = 0
	s1.InitBeta = 0
	s1.gf = 1
	s1.successor = [3, 2]
	s1.successorP = [0.3, 0.7]
	# s1.successor = [3]
	# s1.successorP = [1]
	s1.tropismT = 1
	s1.theta = 0.
	s1.thetas = 0.05
	s1.tropismN = 2
	s1.tropismS = 0.005
	s1.r = 1
	s1.rs = 0.05

	s2.name = "secondary_stem"
	s2.subType = 3
	s2.lmax = 7
	s2.lmaxs = 0.2
	s2.lb = 0
	s2.la = 2
	s2.ln = 2
	s2.lns = 0.1
	s2.lnf = 0
	s2.RotBeta = 2 / 3
	s2.BetaDev = 0.1
	s2.InitBeta = 0
	s2.gf = 1
	s2.successor = [2]
	s2.successorP = [1]
	s2.tropismT = 4
	s2.theta = 0.3
	s2.thetas = 0.02
	s2.tropismN = 18
	s2.tropismS = 0.01
	s2.r = 0.5
	s2.rs = 0.02

	s3.name = "invisible stem"
	s3.subType = 2
	s3.lmax = 5
	s3.la = 0
	s3.ln = 0
	s3.RotBeta = 2/3
	s3.BetaDev = 0
	s3.InitBeta = 0.
	s3.lb = 0
	s3.la = 0
	s3.ln = 0
	s3.lnf = 0
	s3.RotBeta = 2 / 3
	s3.BetaDev = 0
	s3.InitBeta = 0
	s3.gf = 1
	s3.tropismT = 1
	s3.theta = 0.3
	s3.tropismN = 18
	s3.tropismS = 0.01
	s3.r = 1

	l1.name = 'leaf_under_second_stem'
	l1.subType = 2
	l1.lb = 2
	l1.la = 0.2
	l1.lmax = 5
	l1.lmaxs = 0.1
	l1.r = 0.5
	l1.rs = 0.02
	l1.RotBeta = 0.5
	l1.BetaDev = 0
	l1.InitBeta = 0.
	l1.tropismT = 1
	l1.tropismN = 5
	l1.tropismS = 0.15
	l1.theta = 0.35
	l1.gf = 1

	s4.name = "rosette"  # Cannot be a leaf organ because we can only create 1 leaf organ subType
	s4.subType = 4
	s4.lmax = 10
	s4.lmaxs = 0.2
	s4.lb = 1
	s4.la = 0
	s4.ln = 2
	s4.lnf = 0
	s4.RotBeta = 3 / 5
	s4.BetaDev = 0.02
	s4.InitBeta = 0
	s4.gf = 1
	s4.tropismT = 1
	s4.theta = 0.3
	s4.thetas = 0.02
	s4.tropismN = 18
	s4.tropismS = 0.01
	s4.r = 0.5
	s4.rs = 0.02

	plant.setOrganRandomParameter(p0)
	plant.setOrganRandomParameter(p1)
	plant.setOrganRandomParameter(s1)
	plant.setOrganRandomParameter(s2)
	plant.setOrganRandomParameter(s3)
	plant.setOrganRandomParameter(s4)
	plant.setOrganRandomParameter(l1)

	srp = pb.SeedRandomParameter(plant)  # with default values
	srp.seedPos = pb.Vector3d(0., 0., -3.)  # [cm] seed position
	srp.maxB = 0  # [-] number of basal roots (neglecting basal roots and shoot borne)
	srp.firstB = 10.  # [day] first emergence of a basal root
	srp.delayB = 3.  # [day] delay between the emergence of basal roots
	srp.maxTil = 10
	plant.setOrganRandomParameter(srp)

	return plant
Esempio n. 16
0
""" shows inter lateral spacing (ln) and how a linear slope (lnk) can modify them """
import sys
sys.path.append("../../..")
sys.path.append("../../../src/python_modules")
import plantbox as pb
import matplotlib.pyplot as plt
import numpy as np

fig, axes = plt.subplots(2, 3, figsize=(15, 7))

rs = pb.RootSystem()
srp = pb.SeedRandomParameter(rs)
srp.firstB, srp.delayB, srp.maxB = 1., 1., 0
rs.setRootSystemParameter(srp)

dx0, dx1 = 100, 1  # very large resolution for taproot
theta = 70 / 180 * np.pi

p0 = pb.RootRandomParameter(rs)
p0.name, p0.subType, p0.lmax, p0.r, p0.dx, p0.theta = "taproot", 1, 50., 2., dx0, 0.  # parameters as before
p0.tropismT, p0.tropismN, p0.tropismS = pb.TropismType.gravi, 2, 0.1
p0.successor, p0.successorP = [2], [1.]  # set up successors
p0.lns = 0.  # test with other values...
p0.lb, p0.la = 0., 0.
rs.setOrganRandomParameter(p0)

p1 = pb.RootRandomParameter(rs)
p1.name, p1.subType, p1.lmax, p1.r, p1.dx, p1.theta = "lateral", 2, 30., 1., dx1, theta
p1.tropismT, p1.tropismN, p1.tropismS = pb.TropismType.exo, 2, 0.2
rs.setOrganRandomParameter(p1)
Esempio n. 17
0
import sys; sys.path.append(".."); sys.path.append("../../src/python_modules"); sys.path.append("../../")
import numpy as np
import matplotlib.pyplot as plt

import plantbox as pb
import vtk_plot as vp

plant = pb.Plant()  

seed_rp = pb.SeedRandomParameter(plant)
seed_rp.subType = 0
plant.setOrganRandomParameter(seed_rp)

root_rp = pb.RootRandomParameter(plant)
root_rp.subType = 1
root_rp.lmax = 1
root_rp.r = 0.1
root_rp.theta = 0
plant.setOrganRandomParameter(root_rp)

stem_rp = pb.StemRandomParameter(plant)
stem_rp.subType = 1
stem_rp.la = 1.
stem_rp.lb = 5
stem_rp.lmax = 7.5
stem_rp.ln = 1
stem_rp.theta = 0
stem_rp.successor = [2]
stem_rp.successorP = [1]

plant.setOrganRandomParameter(stem_rp)