def get_optima_wang(self, d_leaf=1.5, ca=40.0, t_leaf=25.0, par=1000.0):
     e_crit = self.get_e_crit()
     e_min = 0.0
     e_max = e_crit
     e_opt = 0.0
     a_opt = 0.0
     de = 1.0
     while True:
         e = 0.5 * (e_min + e_max)
         f = e * 0.0154321
         gh = f / self.laba / d_leaf * 100.0
         gc = gh / 1.6 / (1.0 + self.c_cons * gh**self.c_pows)
         g = gc * 10.0
         c, a = get_a_ci_seg(self.vmax, self.jmax, 2.5, g, ca, t_leaf, par)
         e_de = e + de
         f_de = e_de * 0.0154321
         gh = f_de / self.laba / d_leaf * 100.0
         gc = gh / 1.6 / (1.0 + self.c_cons * gh**self.c_pows)
         g_de = gc * 10.0
         c_de, a_de = get_a_ci_seg(self.vmax, self.jmax, 2.5, g_de, ca,
                                   t_leaf, par)
         optimizer = a_de * (e_crit - e_de) - a * (e_crit - e)
         if (e_max - e_min) < 1.0:
             e_opt = e
             a_opt = a
             p_opt = self.get_p_leaf(e)
             break
         if optimizer > 0:
             e_min = e
         else:
             e_max = e
     return a_opt, e_opt, p_opt
 def get_optima_dewar(self, d_leaf=1.5, ca=40.0, t_leaf=25.0, par=1000.0):
     e_crit = self.get_e_crit()
     p_crit = self.b_tree * log(1000.0) ** (1.0/self.c_tree)
     e_min  = 0.0
     e_max  = e_crit
     e_opt  = 0.0
     a_opt  = 0.0
     de     = 1.0
     while True:
         e   = 0.5 * (e_min+e_max)
         p   = self.get_p_leaf(e)
         f   = e * 0.0154321
         gh  = f / self.laba / d_leaf * 100.0
         gc  = gh / 1.6 / (1.0 + self.c_cons * gh**self.c_pows)
         g   = gc * 10.0
         c,a = get_a_ci_seg(self.vmax,
                            self.jmax,
                            2.5,
                            g,
                            ca,
                            t_leaf,
                            par)
         e_de = e + de
         p_de = self.get_p_leaf(e_de)
         f_de = e_de * 0.0154321
         gh   = f_de / self.laba / d_leaf * 100.0
         gc   = gh / 1.6 / (1.0 + self.c_cons * gh**self.c_pows)
         g_de = gc * 10.0
         c_de,a_de = get_a_ci_seg(self.vmax,
                                  self.jmax,
                                  2.5,
                                  g_de,
                                  ca,
                                  t_leaf,
                                  par)
         optimizer = a_de * (p_crit-p_de) - a * (p_crit-p)
         if (e_max-e_min)<1.0:
             e_opt = e
             p_opt = self.get_p_leaf(e)
             a_opt = a * p_opt / p_crit
             g_opt = g * 1.6
             break
         if optimizer>0:
             e_min = e
         else:
             e_max = e
     return a_opt,g_opt,p_opt