Example #1
0
    # Plotting the results
    plt.figure('Pendulum')
    plt.title('Pendulum Phase')
    plt.plot(res[:, 0], res[:, :2])
    plt.xlabel('Position [rad]')
    plt.ylabel('Velocity [rad.s]')
    plt.grid()

    if DEFAULT["save_figures"] is False:
        plt.show()
    else:
        figures = plt.get_figlabels()
        pylog.debug("Saving figures:\n{}".format(figures))
        for fig in figures:
            plt.figure(fig)
            save_figure(fig)
            plt.close(fig)

    # To animate the model, use the SystemAnimation class
    # Pass the res(states) and systems you wish to animate
    simulation = SystemAnimation(res, sim.sys.pendulum_sys, sim.sys.muscle_sys,
                                 sim.sys.neural_sys)
    # To start the animation
    simulation.animate()


if __name__ == '__main__':
    from cmcpack import parse_args
    parse_args()
    exercise3()
Example #2
0
from cmcpack import integrate, integrate_multiple, parse_args

from ex4_hopf import (HopfParameters, CoupledHopfParameters, hopf_equation,
                      coupled_hopf_equation)


def hopf_ocillator():
    """ 4a - Hopf oscillator simulation """
    pylog.warning("Hopf oscillator must be implemented")
    # params = HopfParameters()


def coupled_hopf_ocillator():
    """ 4b - Coupled Hopf oscillator simulation """
    pylog.warning("Coupled Hopf oscillator must be implemented")
    # param = CoupledHopfParameters()


def exercise4(clargs):
    """ Exercise 4 """
    hopf_ocillator()
    coupled_hopf_ocillator()
    # Show plots of all results
    if not clargs.save_figures:
        plt.show()


if __name__ == "__main__":
    CLARGS = parse_args()
    exercise4(CLARGS)