Example #1
0
File: html.py Project: Babyll/sage
 def wrapped(*args, **kwds):
     output = method(*args, **kwds)
     assert isinstance(output, HtmlFragment)
     if _old_and_deprecated_behavior:
         # workaround for the old SageNB interacts
         pretty_print(output)
         return WarnIfNotPrinted()
     else:
         return output
Example #2
0
 def wrapped(*args, **kwds):
     output = method(*args, **kwds)
     assert isinstance(output, HtmlFragment)
     if _old_and_deprecated_behavior:
         # workaround for the old SageNB interacts
         pretty_print(output)
         return WarnIfNotPrinted()
     else:
         return output
Example #3
0
 def __init__(self,
              parent,
              initial_point,
              pt0=None,
              pr0=None,
              pth0=None,
              pph0=None,
              mu=None,
              E=None,
              L=None,
              Q=None,
              r_increase=True,
              th_increase=True,
              chart=None,
              name=None,
              latex_name=None,
              a_num=None,
              m_num=None,
              verbose=False):
     r"""
     Initializes a geodesic in Kerr spacetime.
     """
     self._spacetime = parent.codomain()
     self._mu = mu
     self._E = E
     self._L = L
     self._Q = Q
     self._a = a_num
     if self._a is None:
         self._a = self._spacetime.spin()
     self._m = m_num
     if self._m is None:
         self._m = self._spacetime.mass()
     self._latest_solution = None  # to keep track of latest solution key
     self._init_vector = self._compute_init_vector(initial_point, pt0, pr0,
                                                   pth0, pph0, r_increase,
                                                   th_increase, verbose)
     if verbose:
         print("Initial tangent vector: ")
         pretty_print(self._init_vector.display())
     metric = self._spacetime.metric()
     lamb = SR.var('lamb', latex_name=r'\lambda')
     IntegratedGeodesic.__init__(self,
                                 parent,
                                 metric,
                                 lamb,
                                 self._init_vector,
                                 chart=chart,
                                 name=name,
                                 latex_name=latex_name,
                                 verbose=verbose)
Example #4
0
    def print_data():
        if show_seq.value:
            pretty_print(html("Mutation sequence: ${}$".format(seq)))

        if show_vars.value and kind == 'seed':
            pretty_print(html("Cluster variables:"))
            table = "$\\begin{align*}\n"
            for i in range(self._n):
                table += "\tv_{%s} &= " % i + latex(self.cluster_variable(i)) + "\\\\ \\\\\n"
            table += "\\end{align*}$"
            pretty_print(html(table))

        if show_matrix.value:
            pretty_print(html("B-Matrix:"))
            pretty_print(html(self._M))
Example #5
0
    def print_data():
        if show_seq.value:
            pretty_print(html("Mutation sequence: ${}$".format(seq)))

        if show_vars.value and kind == 'seed':
            pretty_print(html("Cluster variables:"))
            table = "$\\begin{align*}\n"
            for i in range(self._n):
                table += "\tv_{%s} &= " % i + latex(
                    self.cluster_variable(i)) + "\\\\ \\\\\n"
            table += "\\end{align*}$"
            pretty_print(html(table))

        if show_matrix.value:
            pretty_print(html("B-Matrix:"))
            pretty_print(html(self._M))
def zon_info(X, variant="central", data={}, spaces="IJPD"):
    data = data.copy()
    if 'varNames' not in data:
        rws = X.nrows()
        varstr = "xyzwabcd"
        if rws <= len(varstr):
            varstr = varstr[:rws]
        else:
            varstr = varstr[0]
        data['varNames'] = varstr
    Z = ZonotopalAlgebra(X, variant, data)
    tup = zon_spaces(Z, spaces)
    # print out central zonotopal spaces
    print "X = "
    pretty_print(Z.matrix())
    print ""
    print_zon_info(tup)
    return tup
def print_zon_info(tup):
    I, J, P, D = tup
    if I is not None:
        print "I(X) ="
        pretty_print(I)
        print
    if J is not None:
        print "J(X) ="
        pretty_print(J)
        print
    if P is not None:
        print "P(X) ="
        pretty_print(P)
        print
    if D is not None:
        print "D(X) ="
        pretty_print(D)
        print
Example #8
0
 def _compute_init_vector(self, point, pt0, pr0, pth0, pph0, r_increase,
                          th_increase, verbose):
     r"""
     Computes the initial 4-momentum vector `p` from the constants of motion
     """
     BLchart = self._spacetime.boyer_lindquist_coordinates()
     basis = BLchart.frame().at(point)
     r, th = BLchart(point)[1:3]
     a, m = self._a, self._m
     r2 = r**2
     a2 = a**2
     rho2 = r2 + (a * cos(th))**2
     Delta = r2 - 2 * m * r + a2
     if pt0 is None:
         if (self._mu is not None and pr0 is not None and pth0 is not None
                 and pph0 is not None):
             xxx = SR.var('xxx')
             v = self._spacetime.tangent_space(point)(
                 (xxx, pr0, pth0, pph0), basis=basis)
             muv2 = -self._spacetime.metric().at(point)(v, v)
             muv2 = muv2.substitute(self._numerical_substitutions())
             solutions = solve(muv2 == self._mu**2, xxx, solution_dict=True)
             if verbose:
                 print("Solutions for p^t:")
                 pretty_print(solutions)
             for sol in solutions:
                 if sol[xxx] > 0:
                     pt0 = sol[xxx]
                     break
             else:  # pt0 <= 0 might occur in the ergoregion
                 pt0 = solutions[0][xxx]
             try:
                 pt0 = RR(pt0)
             except TypeError:  # pt0 contains some symbolic expression
                 pass
         else:
             if self._E is None:
                 raise ValueError("the constant E must be provided")
             if self._L is None:
                 raise ValueError("the constant L must be provided")
             E, L = self._E, self._L
             pt0 = ((r2 + a2) / Delta * ((r2 + a2) * E - a * L) + a *
                    (L - a * E * sin(th)**2)) / rho2
     if pph0 is None:
         if self._E is None:
             raise ValueError("the constant E must be provided")
         if self._L is None:
             raise ValueError("the constant L must be provided")
         E, L = self._E, self._L
         pph0 = (L / sin(th)**2 - a * E + a / Delta *
                 ((r2 + a2) * E - a * L)) / rho2
     if pr0 is None:
         if self._E is None:
             raise ValueError("the constant E must be provided")
         if self._L is None:
             raise ValueError("the constant L must be provided")
         if self._mu is None:
             raise ValueError("the constant mu must be provided")
         if self._Q is None:
             raise ValueError("the constant Q must be provided")
         E, L, Q = self._E, self._L, self._Q
         mu2 = self._mu**2
         E2_mu2 = E**2 - mu2
         pr0 = sqrt((E2_mu2) * r**4 + 2 * m * mu2 * r**3 +
                    (a2 * E2_mu2 - L**2 - Q) * r**2 + 2 * m *
                    (Q + (L - a * E)**2) * r - a2 * Q) / rho2
         if not r_increase:
             pr0 = -pr0
     if pth0 is None:
         if self._E is None:
             raise ValueError("the constant E must be provided")
         if self._L is None:
             raise ValueError("the constant L must be provided")
         if self._mu is None:
             raise ValueError("the constant mu must be provided")
         if self._Q is None:
             raise ValueError("the constant Q must be provided")
         E2 = self._E**2
         L2 = self._L**2
         mu2 = self._mu**2
         Q = self._Q
         pth0 = sqrt(Q + cos(th)**2 * (a2 *
                                       (E2 - mu2) - L2 / sin(th)**2)) / rho2
         if not th_increase:
             pth0 = -pth0
     return self._spacetime.tangent_space(point)((pt0, pr0, pth0, pph0),
                                                 basis=basis,
                                                 name='p')