<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from sympy import diff , solve , simplify , symbols <EOL> from sympy . physics . mechanics import ReferenceFrame , Point <EOL> from sympy . physics . mechanics import dynamicsymbols <EOL> from util import partial_velocities , generalized_active_forces <EOL> q1 , q2 = dynamicsymbols ( '<STR_LIT>' ) <EOL> q1d , q2d = dynamicsymbols ( '<STR_LIT>' , level = <NUM_LIT:1> ) <EOL> u1 , u2 = dynamicsymbols ( '<STR_LIT>' ) <EOL> b , g , m , L , t = symbols ( '<STR_LIT>' ) <EOL> E , I = symbols ( '<STR_LIT>' ) <EOL> N = ReferenceFrame ( '<STR_LIT:N>' ) <EOL> B = N . orientnew ( '<STR_LIT:B>' , '<STR_LIT>' , [ - ( q2 - q1 ) / ( <NUM_LIT:2> * b ) , N . y ] ) <EOL> pO = Point ( '<STR_LIT:O>' ) <EOL> pO . set_vel ( N , <NUM_LIT:0> ) <EOL> pB_star = pO . locatenew ( '<STR_LIT>' , - ( q1 + q2 ) / <NUM_LIT:2> * N . x ) <EOL> pP1 = pO . locatenew ( '<STR_LIT>' , - q1 * N . x - b * N . z ) <EOL> pP2 = pO . locatenew ( '<STR_LIT>' , - q2 * N . x + b * N . z ) <EOL> for p in [ pB_star , pP1 , pP2 ] : <EOL> p . set_vel ( N , p . pos_from ( pO ) . diff ( t , N ) ) <EOL> kde = [ u1 - q1d , u2 - q2d ] <EOL> kde_map = solve ( kde , [ q1d , q2d ] ) <EOL> M = lambda qi , qj : <NUM_LIT:12> * E * I / ( L ** <NUM_LIT:2> ) * ( L / <NUM_LIT:3> * ( qj - qi ) / ( <NUM_LIT:2> * b ) - qi / <NUM_LIT:2> ) <EOL> V = lambda qi , qj : <NUM_LIT:12> * E * I / ( L ** <NUM_LIT:3> ) * ( qi - L / <NUM_LIT:2> * ( qj - qi ) / ( <NUM_LIT:2> * b ) ) <EOL> forces = [ ( pP1 , V ( q1 , q2 ) * N . x ) , <EOL> ( pB_star , - m * g * N . x ) , <EOL> ( pP2 , V ( q2 , q1 ) * N . x ) ] <EOL> torques = [ ( B , ( M ( q1 , q2 ) - M ( q2 , q1 ) ) * N . y ) ] <EOL> partials = partial_velocities ( [ pP1 , pP2 , pB_star , B ] , [ u1 , u2 ] , N , kde_map ) <EOL> Fr , _ = generalized_active_forces ( partials , forces + torques ) <EOL> print ( "<STR_LIT>" ) <EOL> for i , f in enumerate ( Fr , <NUM_LIT:1> ) : <EOL> alpha = <NUM_LIT:12> * E * I / ( L ** <NUM_LIT:3> ) <EOL> k_q1 = simplify ( diff ( f , q1 ) ) / alpha <EOL> k_q2 = simplify ( diff ( f , q2 ) ) / alpha <EOL> k_f = simplify ( f - alpha * ( k_q1 * q1 + k_q2 * q2 ) ) <EOL> print ( "<STR_LIT>" . format ( <EOL> i , alpha , k_q1 , k_q2 , k_f ) ) </s>
