#NEWLINE# def test_input_format( ) : #NEWLINE# #INDENT# ( q , u ) = dynamicsymbols ( 'q u' ) #NEWLINE# ( qd , ud ) = dynamicsymbols ( 'q u' , 1 ) #NEWLINE# ( m , c , k ) = symbols ( 'm c k' ) #NEWLINE# N = ReferenceFrame ( 'N' ) #NEWLINE# P = Point ( 'P' ) #NEWLINE# P . set_vel ( N , ( u * N . x ) ) #NEWLINE# kd = [ ( qd - u ) ] #NEWLINE# FL = [ ( P , ( ( ( ( - k ) * q ) - ( c * u ) ) * N . x ) ) ] #NEWLINE# pa = Particle ( 'pa' , P , m ) #NEWLINE# BL = [ pa ] #NEWLINE# KM = KanesMethod ( N , [ q ] , [ u ] , kd ) #NEWLINE# assert ( KM . kanes_equations ( BL ) [ 0 ] == Matrix ( [ 0 ] ) ) #NEWLINE# assert ( KM . kanes_equations ( bodies = BL , loads = None ) [ 0 ] == Matrix ( [ 0 ] ) ) #NEWLINE# assert ( KM . kanes_equations ( BL , loads = None ) [ 0 ] == Matrix ( [ 0 ] ) ) #NEWLINE# assert ( KM . kanes_equations ( BL ) [ 0 ] == Matrix ( [ 0 ] ) ) #NEWLINE# from sympy.utilities.pytest import raises #NEWLINE# raises ( ValueError , ( lambda : KM . _form_fr ( 'bad input' ) ) ) #NEWLINE# ( q1 , q2 , u1 , u2 ) = dynamicsymbols ( 'q1 q2 u1 u2' ) #NEWLINE# ( q1d , q2d , u1d , u2d ) = dynamicsymbols ( 'q1 q2 u1 u2' , 1 ) #NEWLINE# ( m , c1 , c2 , k1 , k2 ) = symbols ( 'm c1 c2 k1 k2' ) #NEWLINE# N = ReferenceFrame ( 'N' ) #NEWLINE# P1 = Point ( 'P1' ) #NEWLINE# P2 = Point ( 'P2' ) #NEWLINE# P1 . set_vel ( N , ( u1 * N . x ) ) #NEWLINE# P2 . set_vel ( N , ( ( u1 + u2 ) * N . x ) ) #NEWLINE# kd = [ ( q1d - u1 ) , ( q2d - u2 ) ] #NEWLINE# FL = ( ( P1 , ( ( ( ( ( ( - k1 ) * q1 ) - ( c1 * u1 ) ) + ( k2 * q2 ) ) + ( c2 * u2 ) ) * N . x ) ) , ( P2 , ( ( ( ( - k2 ) * q2 ) - ( c2 * u2 ) ) * N . x ) ) ) #NEWLINE# pa1 = Particle ( 'pa1' , P1 , m ) #NEWLINE# pa2 = Particle ( 'pa2' , P2 , m ) #NEWLINE# BL = ( pa1 , pa2 ) #NEWLINE# KM = KanesMethod ( N , q_ind = [ q1 , q2 ] , u_ind = [ u1 , u2 ] , kd_eqs = kd ) #NEWLINE# KM . kanes_equations ( BL , FL ) #NEWLINE# MM = KM . mass_matrix #NEWLINE# forcing = KM . forcing #NEWLINE# rhs = ( MM . inv ( ) * forcing ) #NEWLINE# assert ( expand ( rhs [ 0 ] ) == expand ( ( ( ( ( ( ( - k1 ) * q1 ) - ( c1 * u1 ) ) + ( k2 * q2 ) ) + ( c2 * u2 ) ) / m ) ) ) #NEWLINE# assert ( expand ( rhs [ 1 ] ) == expand ( ( ( ( ( ( k1 * q1 ) + ( c1 * u1 ) ) - ( ( 2 * k2 ) * q2 ) ) - ( ( 2 * c2 ) * u2 ) ) / m ) ) )