Last active
August 29, 2015 14:21
-
-
Save moorepants/94d4256424298dc7388f to your computer and use it in GitHub Desktop.
Tracking down a bug in the PyDy code gen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sympy as sm | |
| import numpy as np | |
| from pydy.models import n_link_pendulum_on_cart | |
| from pydy.codegen.ode_function_generators import generate_ode_function | |
| sys = n_link_pendulum_on_cart(10, True, True) | |
| x = np.random.random(len(sys.coordinates) + len(sys.speeds)) | |
| t = 0.0 | |
| r = np.random.random(len(sys.specifieds_symbols)) | |
| p = np.random.random(len(sys.constants_symbols)) | |
| k_d_dict = sys.eom_method.kindiffdict() | |
| coord_derivs = sm.Matrix([k_d_dict[q.diff()] for q in sys.eom_method.q[:]]) | |
| rhs = generate_ode_function(sys.eom_method.forcing, | |
| sys.coordinates, | |
| sys.speeds, | |
| sys.constants_symbols, | |
| mass_matrix=sys.eom_method.mass_matrix, | |
| coordinate_derivatives=coord_derivs, | |
| specifieds=sys.specifieds_symbols, | |
| constants_arg_type='array', | |
| specifieds_arg_type='array', | |
| generator='cython') | |
| xd = rhs(x, t, r, p) | |
| print(xd) | |
| rhs = generate_ode_function(sys.eom_method.forcing_full, | |
| sys.coordinates, | |
| sys.speeds, | |
| sys.constants_symbols, | |
| mass_matrix=sys.eom_method.mass_matrix_full, | |
| specifieds=sys.specifieds_symbols, | |
| constants_arg_type='array', | |
| specifieds_arg_type='array', | |
| generator='cython') | |
| xd = rhs(x, t, r, p) | |
| print(xd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment