#NEWLINE# def test_fan_out_grouped( self ) : #NEWLINE# #INDENT# prob = Problem ( impl = impl ) #NEWLINE# prob . root = root = Group ( ) #NEWLINE# root . add ( 'p' , IndepVarComp ( 'x' , 1.0 ) ) #NEWLINE# root . add ( 'comp1' , ExecComp ( [ 'y=3.0*x' ] ) ) #NEWLINE# sub = root . add ( 'sub' , ParallelGroup ( ) ) #NEWLINE# sub . add ( 'comp2' , ExecComp ( [ 'y=-2.0*x' ] ) ) #NEWLINE# sub . add ( 'comp3' , ExecComp ( [ 'y=5.0*x' ] ) ) #NEWLINE# root . add ( 'c2' , ExecComp ( [ 'y=-x' ] ) ) #NEWLINE# root . add ( 'c3' , ExecComp ( [ 'y=3.0*x' ] ) ) #NEWLINE# root . connect ( 'sub.comp2.y' , 'c2.x' ) #NEWLINE# root . connect ( 'sub.comp3.y' , 'c3.x' ) #NEWLINE# root . connect ( 'comp1.y' , 'sub.comp2.x' ) #NEWLINE# root . connect ( 'comp1.y' , 'sub.comp3.x' ) #NEWLINE# root . connect ( 'p.x' , 'comp1.x' ) #NEWLINE# prob . root . ln_solver = LinearGaussSeidel ( ) #NEWLINE# prob . root . sub . ln_solver = LinearGaussSeidel ( ) #NEWLINE# prob . setup ( check = False ) #NEWLINE# prob . run ( ) #NEWLINE# param = 'p.x' #NEWLINE# unknown_list = [ 'sub.comp2.y' , 'sub.comp3.y' ] #NEWLINE# J = prob . calc_gradient ( [ param ] , unknown_list , mode = 'fwd' , return_format = 'dict' ) #NEWLINE# assert_rel_error ( self , J [ unknown_list [ 0 ] ] [ param ] [ 0 ] [ 0 ] , ( - 6.0 ) , 1e-06 ) #NEWLINE# assert_rel_error ( self , J [ unknown_list [ 1 ] ] [ param ] [ 0 ] [ 0 ] , 15.0 , 1e-06 ) #NEWLINE# J = prob . calc_gradient ( [ param ] , unknown_list , mode = 'rev' , return_format = 'dict' ) #NEWLINE# assert_rel_error ( self , J [ unknown_list [ 0 ] ] [ param ] [ 0 ] [ 0 ] , ( - 6.0 ) , 1e-06 ) #NEWLINE# assert_rel_error ( self , J [ unknown_list [ 1 ] ] [ param ] [ 0 ] [ 0 ] , 15.0 , 1e-06 ) #NEWLINE# unknown_list = [ 'c2.y' , 'c3.y' ] #NEWLINE# J = prob . calc_gradient ( [ param ] , unknown_list , mode = 'fwd' , return_format = 'dict' ) #NEWLINE# assert_rel_error ( self , J [ unknown_list [ 0 ] ] [ param ] [ 0 ] [ 0 ] , 6.0 , 1e-06 ) #NEWLINE# assert_rel_error ( self , J [ unknown_list [ 1 ] ] [ param ] [ 0 ] [ 0 ] , 45.0 , 1e-06 ) #NEWLINE# J = prob . calc_gradient ( [ param ] , unknown_list , mode = 'rev' , return_format = 'dict' ) #NEWLINE# assert_rel_error ( self , J [ unknown_list [ 0 ] ] [ param ] [ 0 ] [ 0 ] , 6.0 , 1e-06 ) #NEWLINE# assert_rel_error ( self , J [ unknown_list [ 1 ] ] [ param ] [ 0 ] [ 0 ] , 45.0 , 1e-06 )