예제 #1
0
    def calculate_H_matrix(self):
        """ unimodular completion of P(d/dt) with H = P1i * ... * P11 * P10
        """
        pc.print_line()
        print("Exit condition satisfied\n")

        H_relevant_matrices, H_tilde_relevant_matrices = self._myStack.get_H_relevant_matrices(
        )

        H1 = self.multiply_matrices_in_list(H_relevant_matrices)

        if not len(H_tilde_relevant_matrices) == 0:
            H2 = self.multiply_matrices_in_list(H_tilde_relevant_matrices)
        else:
            H2 = sp.Matrix([])

        H = st.concat_rows(H1, H2)

        m, n = H.shape
        assert n == len(
            self._myStack.vec_x), "Dimensions of H-Matrix do not fit."

        print("H-matrix = ")
        pc.print_nicely(H)
        print("\n")

        self.H = H
예제 #2
0
    def calculate_H_matrix(self):
        """ unimodular completion of P(d/dt) with H = P1i * ... * P11 * P10
        """
        pc.print_line()
        print("Exit condition satisfied\n")

        H_relevant_matrices, H_tilde_relevant_matrices = self._myStack.get_H_relevant_matrices()

        H1 = self.multiply_matrices_in_list( H_relevant_matrices )

        if not len(H_tilde_relevant_matrices)==0:
            H2 = self.multiply_matrices_in_list( H_tilde_relevant_matrices )
        else:
            H2 = sp.Matrix([])

        H = st.concat_rows(H1, H2)

        m, n = H.shape
        assert n==len(self._myStack.vec_x), "Dimensions of H-Matrix do not fit."

        print "H-matrix = "
        pc.print_nicely(H)
        print "\n"

        self.H = H
예제 #3
0
    def w(self, value):
        self._w = value

        # print when set
        pc.print_equation_from_list(self.w, "w", sympy=False)
        pc.print_line()
예제 #4
0
def main():
    P1i, P0i = tangent_system()

    global mode
    mode = raw_input("Enter \"manual\" for manual mode or hit enter:\n")
    #####################################################################

    i = 0

    while 1:
        # new iteration_stack
        myIteration = mc.IterationStack(i, P1i, P0i)

        assert al.has_full_row_rank(P1i), "P10 does not have full row rank. There \
                                        must be algebraic equations."

        Bi = reduction(myIteration)

        assert not al.is_zero_matrix(Bi), "System ist not flat!"

        if is_special_case(Bi):
            # special case
           Bi = fourseven(myIteration)

        if end_condition(Bi):
            # flag
            myIteration.last_iter_step = True

            # add to system stack + print
            myStack.add_iteration(myIteration)
            break

        P1i, P0i = elimination(myIteration)

        if mode=="manual": pc.print_line()

        # add to system stack + print iteration
        myStack.add_iteration(myIteration)

        i += 1

    # create transformation and calculate H and G(d/dt)
    myStack.transformation = tr.Transformation(myStack)


    # store results of the algorithm in pickled data container
    data = st.Container()
    data.F_eq = nct.make_all_symbols_noncommutative(example.F_eq, "")[0]
    data.vec_x = nct.make_all_symbols_noncommutative(example.vec_x, "")[0]
    data.vec_xdot = nct.make_all_symbols_noncommutative(example.vec_xdot, "")[0]

    if hasattr(example, 'diff_symbols'):
        data.diff_symbols = nct.make_all_symbols_noncommutative(example.diff_symbols, "")[0]
    
    if hasattr(example, 'user_data'):
        data.user_data = example.user_data

    # add data to be stored here:
    # make symbols in P10 and P00 noncommutative
    P1 = nct.make_all_symbols_noncommutative(myStack.transformation.P10, "")[0]
    P0 = nct.make_all_symbols_noncommutative(myStack.transformation.P00, "")[0]
    s  = sp.Symbol('s', commutative=False)
    data.P = P1*s+P0
    data.P1 = P1
    data.P0 = P0
    data.H = nct.make_all_symbols_noncommutative(myStack.transformation.H, "")[0]

    fname = path.replace(".py",".pcl")
    st.pickle_full_dump(data, fname)

    # for testing
    try:
        import pycartan as ct
        global w
        myIntegrabilityCheck = ic.IntegrabilityCheck(myStack)
        w = myStack.transformation.w
    except Exception as exc:
        print exc

    print "Data saved to ", fname, "\n"
    pc.print_line()
예제 #5
0
def main():
    P1i, P0i = tangent_system()

    global mode

    # raw_input was removed in python3
    if sys.version_info[0] == 2:
        mode = raw_input("Enter \"manual\" for manual mode or hit enter:\n")
    elif sys.version_info[0] == 3:
        mode = input("Enter \"manual\" for manual mode or hit enter:\n")
    #####################################################################

    i = 0

    while 1:
        # new iteration_stack
        myIteration = mc.IterationStack(i, P1i, P0i)

        assert al.has_full_row_rank(
            P1i), "P10 does not have full row rank. There \
                                        must be algebraic equations."

        Bi = reduction(myIteration)

        assert not al.is_zero_matrix(Bi), "System ist not flat!"

        if is_special_case(Bi):
            # special case
            Bi = fourseven(myIteration)

        if end_condition(Bi):
            # flag
            myIteration.last_iter_step = True

            # add to system stack + print
            myStack.add_iteration(myIteration)
            break

        P1i, P0i = elimination(myIteration)

        if mode == "manual": pc.print_line()

        # add to system stack + print iteration
        myStack.add_iteration(myIteration)

        i += 1

    # create transformation and calculate H and G(d/dt)
    myStack.transformation = tr.Transformation(myStack)

    # store results of the algorithm in pickled data container
    data = st.Container()
    data.F_eq = nct.make_all_symbols_noncommutative(example.F_eq, "")[0]
    data.vec_x = nct.make_all_symbols_noncommutative(example.vec_x, "")[0]
    data.vec_xdot = nct.make_all_symbols_noncommutative(example.vec_xdot,
                                                        "")[0]

    if hasattr(example, 'diff_symbols'):
        data.diff_symbols = nct.make_all_symbols_noncommutative(
            example.diff_symbols, "")[0]

    if hasattr(example, 'user_data'):
        data.user_data = example.user_data

    # add data to be stored here:
    # make symbols in P10 and P00 noncommutative
    P1 = nct.make_all_symbols_noncommutative(myStack.transformation.P10, "")[0]
    P0 = nct.make_all_symbols_noncommutative(myStack.transformation.P00, "")[0]
    s = sp.Symbol('s', commutative=False)
    data.P = P1 * s + P0
    data.P1 = P1
    data.P0 = P0
    data.H = nct.make_all_symbols_noncommutative(myStack.transformation.H,
                                                 "")[0]

    fname = path.replace(".py", ".pcl")
    st.pickle_full_dump(data, fname)

    # for testing
    try:
        import pycartan as ct
        import core.integrability as ic
        global w
        myIntegrabilityCheck = ic.IntegrabilityCheck(myStack)
        w = myStack.transformation.w
    except Exception as exc:
        print(exc)

    print("Data saved to ", fname, "\n")
    pc.print_line()
예제 #6
0
    def w(self, value):
        self._w = value

        # print when set
        pc.print_equation_from_list(self.w, "w", sympy=False)
        pc.print_line()