예제 #1
0
    problem.bvp_solver = algorithms.MultipleShooting(derivative_method='fd', tolerance=1e-4, max_iterations=1000, verbose=True, cached=False, number_arcs=16)
    # problem.bvp_solver = algorithms.SingleShooting(derivative_method='fd',tolerance=1e-4, max_iterations=1000, verbose=True, cached=False)

    problem.scale.unit('m', 1)       \
                 .unit('s', 1)     \
                 .unit('kg', 1)   \
                 .unit('rad', 1)

    # Define quantity (not implemented at present)
    # Is this actually an Expression rather than a Value?
    # problem.quantity = [Value('tanAng','tan(theta)')]

    problem.guess.setup('auto', start=[80, 0, 50, -89*pi/180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], costate_guess=[0, 0, 0, 0, 0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], time_integrate=2.5) # costate_guess=[0, 0, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    # problem.guess.setup('auto',start=[80000,3.38575809e-21,5000,7.98617365e-02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],direction='forward',time_integrate=229.865209,costate_guess =[-1.37514494e+01,3.80852584e+06,-3.26290152e+03,-2.31984720e-14,0.00,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01])
    # Figure out nicer way of representing this. Done?


    problem.steps.add_step().num_cases(21) \
        .terminal('theta_n', 1*pi/180) \
        .terminal('h_n', 0)

    # problem.steps.add_step().num_cases(15) \
    #     .terminal('theta_n', 5)

    # problem.steps.add_step().num_cases(21)  \
    #                         .terminal('theta', 10*pi/180)

    Beluga.run(problem, display_level=logging.DEBUG)

예제 #2
0
    # alfaDot = np.append(np.arcsin(np.diff(sol.u)/(10*3.14/180)),0)
    # # Construct initial guess
    # sol.y = np.vstack((sol.y[:4,:], sol.u, sol.y[4:8,:], np.ones_like(sol.x)*100, sol.y[8,:]))
    # sol.u = np.vstack((alfaDot, sol.u))
    # problem.guess.setup('static', solinit=sol)

    problem.guess.setup('auto',
                        start=[80000, 0.01, 5000, -90 * pi / 180],
                        costate_guess=0.1,
                        time_integrate=0.01)
    # problem.guess.setup('auto',start=[80000,0.01,5000,-90*pi/180])
    problem.steps.add_step('bisection') \
                            .num_cases(101) \
                            .terminal('h', 0) \
                            .terminal('theta', 10*pi/180)
    # problem.steps.add_step('bisection') \
    #                         .num_cases(41) \
    #
    problem.steps.add_step('bisection') \
                            .num_cases(41) \
                            .const('eps_maxAltitude', 1e-4)
    #

    return problem


if __name__ == '__main__':
    import beluga.Beluga as Beluga
    problem = get_problem()
    sol = Beluga.run(problem)
예제 #3
0
    # TODO: implement an "initial guess" class subclassing Solution
    # problem.guess = bvpsol.bvpinit(np.linspace(0,1,2), [0,0,1,-0.1,-0.1,-0.1,0.1])
    # problem.guess.parameters = np.array([0.1,0.1,0.1,0.1,0.1])
    problem.guess.setup(
        'auto',
        start=[0, 0, 1],  # Starting values for states in order
        direction='forward',
        costate_guess=-0.1)

    # Figure out nicer way of representing this. Done?
    problem.steps.add_step('bisection') \
                    .num_cases(2) \
                    .terminal('x', 5) \
                    .terminal('y',-5)

    # (
    # problem.steps.add_step().num_cases(2)
    #                  .terminal('x', 30.0)
    #                  .terminal('y',-30.0),

    # problem.steps.add_step()
    #                 .num_cases(10)
    #                 .terminal('x', 1000.0)
    #                 .terminal('y',-1000.0)
    # )
    return problem


if __name__ == '__main__':
    Beluga.run(get_problem(), display_level=logging.DEBUG)
    # Define quantity (not implemented at present)
    # Is this actually an Expression rather than a Value?
    # problem.quantity = [Value('tanAng','tan(theta)')]

    problem.bvp_solver = algorithms.SingleShooting(derivative_method='fd',
                                                   tolerance=1e-4,
                                                   max_iterations=1000,
                                                   verbose=True,
                                                   cached=False)
    #problem.bvp_solver = algorithms.MultipleShooting(derivative_method='fd',tolerance=1e-4, max_iterations=4000, verbose = True, cached = False, number_arcs=4)

    problem.guess.setup('auto', start=[885, 0, 0, 0, 0, 0, 0, 0])

    problem.steps.add_step().num_cases(10)  \
                            .terminal('x',1)

    problem.steps.add_step().num_cases(10)           \
                            .terminal('x',4330.127018922193)
    #
    problem.steps.add_step().num_cases(10)          \
                            .initial('z',2500)

    return problem


if __name__ == '__main__':
    problem = get_problem()
    # Default solver is a forward-difference Single Shooting solver with 1e-4 tolerance
    Beluga.run(problem)
예제 #5
0
    )  # costate_guess=[0, 0, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    # problem.guess.setup('auto',start=[80000,3.38575809e-21,5000,7.98617365e-02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],direction='forward',time_integrate=229.865209,costate_guess =[-1.37514494e+01,3.80852584e+06,-3.26290152e+03,-2.31984720e-14,0.00,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01])
    # Figure out nicer way of representing this. Done?

    # problem.steps.add_step().num_cases(10) \
    #     .const('ep', 0.05) \

    problem.steps.add_step().num_cases(20) \
        .terminal('x', 2.05) \
        .terminal('y', 0) \

    problem.steps.add_step().num_cases(20) \
        .terminal('y', 2) \

    problem.steps.add_step().num_cases(5) \
        .const('ep', 0.3) \

    problem.steps.add_step().num_cases(5) \
        .const('ep', 0.1) \

    problem.steps.add_step().num_cases(5) \
        .const('ep', 0.08) \

    # problem.steps.add_step().num_cases(15) \
    #     .terminal('theta_n', 5)

    # problem.steps.add_step().num_cases(21)  \
    #                         .terminal('theta', 10*pi/180)

    Beluga.run(problem, display_level=logging.INFO)
예제 #6
0
                   .unit('kg',1)   \
                   .unit('rad',1)

    # problem.bvp_solver = algorithms.MultipleShooting(derivative_method='fd',tolerance=1e-4, max_iterations=1000, verbose = True, cached=False, number_arcs=4)
    problem.bvp_solver = algorithms.SingleShooting(derivative_method='fd',
                                                   tolerance=1e-4,
                                                   max_iterations=50,
                                                   verbose=True,
                                                   cached=False)
    # problem.bvp_solver = algorithms.BroydenShooting(tolerance=1e-4, max_iterations=1000)

    # Can be array or function handle
    # TODO: implement an "initial guess" class subclassing Solution
    # problem.guess = bvpsol.bvpinit(np.linspace(0,1,2), [0,0,1,-0.1,-0.1,-0.1,0.1])
    # problem.guess.parameters = np.array([0.1,0.1,0.1,0.1,0.1])
    problem.guess.setup(
        'auto',
        start=[0, 0, 1],  # Starting values for states in order
        direction='forward',
        costate_guess=-0.1)

    problem.steps.add_step('bisection', initial_num_cases=5) \
                    .terminal('x', 1000) \
                    .terminal('y',-1000)

    return problem


if __name__ == '__main__':
    Beluga.run(get_problem())