#NEWLINE# def test_pend( ) : #NEWLINE# #INDENT# ( q , u ) = dynamicsymbols ( 'q u' ) #NEWLINE# ( qd , ud ) = dynamicsymbols ( 'q u' , 1 ) #NEWLINE# ( m , l , g ) = symbols ( 'm l g' ) #NEWLINE# N = ReferenceFrame ( 'N' ) #NEWLINE# P = Point ( 'P' ) #NEWLINE# P . set_vel ( N , ( ( ( ( ( - l ) * u ) * sin ( q ) ) * N . x ) + ( ( ( l * u ) * cos ( q ) ) * N . y ) ) ) #NEWLINE# kd = [ ( qd - u ) ] #NEWLINE# FL = [ ( P , ( ( g * g ) * N . x ) ) ] #NEWLINE# pa = Particle ( 'pa' , P , m ) #NEWLINE# BL = [ pa ] #NEWLINE# KM = KanesMethod ( N , [ q ] , [ u ] , kd ) #NEWLINE# with warnings . catch_warnings ( ) : #NEWLINE# #INDENT# warnings . filterwarnings ( 'ignore' , category = SymPyDeprecationWarning ) #NEWLINE# KM . kanes_equations ( FL , BL ) #NEWLINE# #UNINDENT# MM = KM . mass_matrix #NEWLINE# forcing = KM . forcing #NEWLINE# rhs = ( MM . inv ( ) * forcing ) #NEWLINE# rhs . simplify ( ) #NEWLINE# assert ( expand ( rhs [ 0 ] ) == expand ( ( ( ( - g ) / l ) * sin ( q ) ) ) )