#NEWLINE# def test_sellar_derivs_grouped( self ) : #NEWLINE# #INDENT# prob = Problem ( impl = impl ) #NEWLINE# prob . root = SellarDerivativesGrouped ( ) #NEWLINE# prob . root . ln_solver = PetscKSP ( ) #NEWLINE# prob . root . mda . nl_solver . options [ 'atol' ] = 1e-12 #NEWLINE# prob . setup ( check = False ) #NEWLINE# prob . run ( ) #NEWLINE# assert_rel_error ( self , prob [ 'y1' ] , 25.58830273 , 1e-05 ) #NEWLINE# assert_rel_error ( self , prob [ 'y2' ] , 12.05848819 , 1e-05 ) #NEWLINE# indep_list = [ 'x' , 'z' ] #NEWLINE# unknown_list = [ 'obj' , 'con1' , 'con2' ] #NEWLINE# Jbase = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# Jbase [ 'con1' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# Jbase [ 'con1' ] [ 'x' ] = ( - 0.98061433 ) #NEWLINE# Jbase [ 'con1' ] [ 'z' ] = np . array ( [ ( - 9.61002285 ) , ( - 0.78449158 ) ] ) #NEWLINE# Jbase [ 'con2' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# Jbase [ 'con2' ] [ 'x' ] = 0.09692762 #NEWLINE# Jbase [ 'con2' ] [ 'z' ] = np . array ( [ 1.94989079 , 1.0775421 ] ) #NEWLINE# Jbase [ 'obj' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# Jbase [ 'obj' ] [ 'x' ] = 2.98061392 #NEWLINE# Jbase [ 'obj' ] [ 'z' ] = np . array ( [ 9.61001155 , 1.78448534 ] ) #NEWLINE# J = prob . calc_gradient ( indep_list , unknown_list , mode = 'fwd' , return_format = 'dict' ) #NEWLINE# for ( key1 , val1 ) in Jbase . items ( ) : #NEWLINE# #INDENT# for ( key2 , val2 ) in val1 . items ( ) : #NEWLINE# #INDENT# assert_rel_error ( self , J [ key1 ] [ key2 ] , key1 , 1e-05 ) #NEWLINE# #UNINDENT# #UNINDENT# J = prob . calc_gradient ( indep_list , unknown_list , mode = 'rev' , return_format = 'dict' ) #NEWLINE# for ( key1 , val1 ) in Jbase . items ( ) : #NEWLINE# #INDENT# for ( key2 , val2 ) in val1 . items ( ) : #NEWLINE# #INDENT# assert_rel_error ( self , J [ key1 ] [ key2 ] , val2 , 1e-05 ) #NEWLINE# #UNINDENT# #UNINDENT# OptionsDictionary . locked = False #NEWLINE# prob . root . fd_options [ 'form' ] = 'central' #NEWLINE# J = prob . calc_gradient ( indep_list , unknown_list , mode = 'fd' , return_format = 'dict' ) #NEWLINE# for ( key1 , val1 ) in Jbase . items ( ) : #NEWLINE# #INDENT# for ( key2 , val2 ) in val1 . items ( ) : #NEWLINE# #INDENT# assert_rel_error ( self , J [ key1 ] [ key2 ] , val2 , 1e-05 )