<s> """<STR_LIT>""" <EOL> from openmdao . api import Problem , ScipyOptimizer , Component , IndepVarComp , Group <EOL> E = <NUM_LIT> <EOL> I = <NUM_LIT> <EOL> BEAM_WEIGHT_LBS_PER_IN = <NUM_LIT> / <NUM_LIT> <EOL> DEAD_LOAD_PSI = <NUM_LIT> / <NUM_LIT> <EOL> LIVE_LOAD_PSI = <NUM_LIT> / <NUM_LIT> <EOL> TOTAL_LOAD_PSI = DEAD_LOAD_PSI + LIVE_LOAD_PSI <EOL> BEAM_HEIGHT_IN = <NUM_LIT> <EOL> YIELD_STRENGTH_PSI = <NUM_LIT> <EOL> CROSS_SECTIONAL_AREA_SQIN = <NUM_LIT> <EOL> class NegativeArea ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( NegativeArea , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_output ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> unknowns [ '<STR_LIT>' ] = - ( room_length * room_width ) <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> J = { } <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = - room_length <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = - room_width <EOL> return J <EOL> class LengthMinusWidth ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( LengthMinusWidth , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_output ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> unknowns [ '<STR_LIT>' ] = room_length - room_width <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> J = { } <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = - <NUM_LIT:1.0> <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = <NUM_LIT:1.0> <EOL> return J <EOL> class Deflection ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( Deflection , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_output ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> unknowns [ '<STR_LIT>' ] = ( E * I * <NUM_LIT> ) / ( <NUM_LIT> * ( ( <NUM_LIT:0.5> * TOTAL_LOAD_PSI * room_width ) + BEAM_WEIGHT_LBS_PER_IN ) * room_length ** <NUM_LIT:3> ) <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> J = { } <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = ( - <NUM_LIT> * E * I * TOTAL_LOAD_PSI ) / ( ( <NUM_LIT> * room_length ** <NUM_LIT:3> ) * ( TOTAL_LOAD_PSI * room_width / <NUM_LIT> + BEAM_WEIGHT_LBS_PER_IN ) ** <NUM_LIT:2> ) <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = ( - <NUM_LIT> * E * I ) / ( <NUM_LIT> * ( ( TOTAL_LOAD_PSI * room_width ) / <NUM_LIT> + BEAM_WEIGHT_LBS_PER_IN ) * room_length ** <NUM_LIT:4> ) <EOL> return J <EOL> class BendingStress ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( BendingStress , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_output ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> unknowns [ '<STR_LIT>' ] = ( <NUM_LIT:0.5> * BEAM_HEIGHT_IN * ( ( <NUM_LIT:0.5> * TOTAL_LOAD_PSI * room_width ) + BEAM_WEIGHT_LBS_PER_IN ) * ( room_length ) ** <NUM_LIT:2> ) / ( <NUM_LIT> * YIELD_STRENGTH_PSI * I ) <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> J = { } <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = ( room_length ** <NUM_LIT:2> ) * BEAM_HEIGHT_IN * ( TOTAL_LOAD_PSI * room_width / <NUM_LIT> + BEAM_WEIGHT_LBS_PER_IN ) / ( <NUM_LIT> * I * YIELD_STRENGTH_PSI ) <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = ( BEAM_WEIGHT_LBS_PER_IN + ( TOTAL_LOAD_PSI * room_width / <NUM_LIT> ) ) * BEAM_HEIGHT_IN * room_length / ( <NUM_LIT> * I * YIELD_STRENGTH_PSI ) <EOL> return J <EOL> class ShearStress ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( ShearStress , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_param ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> self . add_output ( '<STR_LIT>' , val = <NUM_LIT:0.0> ) <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> unknowns [ '<STR_LIT>' ] = <NUM_LIT:0.5> * ( ( <NUM_LIT:0.5> * TOTAL_LOAD_PSI * room_width ) + BEAM_WEIGHT_LBS_PER_IN ) * ( room_length ) / ( CROSS_SECTIONAL_AREA_SQIN * YIELD_STRENGTH_PSI ) <EOL> def linearize ( self , params , unknowns , resids ) : <EOL> J = { } <EOL> room_width = params [ '<STR_LIT>' ] <EOL> room_length = params [ '<STR_LIT>' ] <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = TOTAL_LOAD_PSI * room_length / ( <NUM_LIT> * YIELD_STRENGTH_PSI * CROSS_SECTIONAL_AREA_SQIN ) <EOL> J [ '<STR_LIT>' , '<STR_LIT>' ] = ( BEAM_WEIGHT_LBS_PER_IN + ( TOTAL_LOAD_PSI * room_width / <NUM_LIT> ) ) / ( <NUM_LIT> * YIELD_STRENGTH_PSI * CROSS_SECTIONAL_AREA_SQIN ) <EOL> return J <EOL> class BeamTutorial ( Group ) : <EOL> def __init__ ( self ) : <EOL> super ( BeamTutorial , self ) . __init__ ( ) <EOL> self . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . add ( '<STR_LIT>' , LengthMinusWidth ( ) ) <EOL> self . add ( '<STR_LIT>' , Deflection ( ) ) <EOL> self . add ( '<STR_LIT>' , BendingStress ( ) ) <EOL> self . add ( '<STR_LIT>' , ShearStress ( ) ) <EOL> self . add ( '<STR_LIT>' , NegativeArea ( ) ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> top = Problem ( ) <EOL> top . root = BeamTutorial ( ) <EOL> top . driver = ScipyOptimizer ( ) <EOL> top . driver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> top . driver . options [ '<STR_LIT>' ] = <NUM_LIT> <EOL> top . driver . options [ '<STR_LIT>' ] = <NUM_LIT> <EOL> top . driver . add_desvar ( '<STR_LIT>' , lower = <NUM_LIT> * <NUM_LIT> , upper = <NUM_LIT> * <NUM_LIT> ) <EOL> top . driver . add_desvar ( '<STR_LIT>' , lower = <NUM_LIT> * <NUM_LIT> , upper = <NUM_LIT> * <NUM_LIT> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' , lower = <NUM_LIT:0.0> ) <EOL> top . driver . add_constraint ( '<STR_LIT>' , lower = <NUM_LIT> ) <EOL> top . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.5> ) <EOL> top . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:1.0> / <NUM_LIT> ) <EOL> top . setup ( ) <EOL> top . run ( ) <EOL> print ( "<STR_LIT:\n>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" % ( - top [ '<STR_LIT>' ] , - top [ '<STR_LIT>' ] / <NUM_LIT> ) ) <EOL> print ( "<STR_LIT>" % ( top [ '<STR_LIT>' ] , top [ '<STR_LIT>' ] / <NUM_LIT> ) ) <EOL> print ( "<STR_LIT>" % ( top [ '<STR_LIT>' ] , top [ '<STR_LIT>' ] / <NUM_LIT> ) ) <EOL> print ( "<STR_LIT>" % ( top [ '<STR_LIT>' ] ) ) <EOL> print ( "<STR_LIT>" % ( top [ '<STR_LIT>' ] ) ) <EOL> print ( "<STR_LIT>" % ( top [ '<STR_LIT>' ] ) ) <EOL> loadingPlusBeam = ( ( <NUM_LIT:0.5> * TOTAL_LOAD_PSI * top [ '<STR_LIT>' ] ) + BEAM_WEIGHT_LBS_PER_IN ) <EOL> loadingNoBeam = ( ( <NUM_LIT:0.5> * TOTAL_LOAD_PSI * top [ '<STR_LIT>' ] ) ) <EOL> print ( "<STR_LIT>" % ( loadingPlusBeam , loadingPlusBeam * <NUM_LIT> ) ) <EOL> print ( "<STR_LIT>" % ( loadingNoBeam , loadingNoBeam * <NUM_LIT> ) ) <EOL> print ( "<STR_LIT>" ) </s>
