<s> """<STR_LIT>""" <EOL> from math import log , pi , sqrt , e <EOL> from openmdao . main . api import Assembly , Component <EOL> from openmdao . lib . drivers . api import BroydenSolver <EOL> from openmdao . lib . datatypes . api import Float , Bool <EOL> from openmdao . main . api import convert_units as cu <EOL> from pycycle . api import FlowStationVar <EOL> class TubeWallTemp ( Component ) : <EOL> """<STR_LIT>""" <EOL> diameter_outer_tube = Float ( <NUM_LIT> , units = '<STR_LIT:m>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> length_tube = Float ( <NUM_LIT> , units = '<STR_LIT:m>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> num_pods = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> temp_boundary = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> temp_outside_ambient = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> nozzle_air = FlowStationVar ( iotype = "<STR_LIT>" , desc = "<STR_LIT>" , copy = None ) <EOL> bearing_air = FlowStationVar ( iotype = "<STR_LIT>" , desc = "<STR_LIT>" , copy = None ) <EOL> solar_insolation = Float ( <NUM_LIT> , iotype = "<STR_LIT>" , units = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> nn_incidence_factor = Float ( <NUM_LIT> , iotype = "<STR_LIT>" , desc = '<STR_LIT>' ) <EOL> surface_reflectance = Float ( <NUM_LIT:0.5> , desc = '<STR_LIT>' ) <EOL> q_per_area_solar = Float ( <NUM_LIT> , units = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> q_total_solar = Float ( <NUM_LIT> , iotype = "<STR_LIT>" , units = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> emissivity_tube = Float ( <NUM_LIT:0.5> , iotype = "<STR_LIT>" , units = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> sb_constant = Float ( <NUM_LIT> , iotype = "<STR_LIT>" , units = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> area_rad = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> GrDelTL3 = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> Pr = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> Gr = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> Ra = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> Nu = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> k = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> h = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> area_convection = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> q_per_area_nat_conv = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> total_q_nat_conv = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> heat_rate_pod = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> total_heat_rate_pods = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> q_rad_per_area = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> q_rad_tot = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> viewing_angle = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> q_total_out = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> q_total_in = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> ss_temp_residual = Float ( units = '<STR_LIT>' , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> bearing_q = cu ( self . bearing_air . W , '<STR_LIT>' , '<STR_LIT>' ) * cu ( self . bearing_air . Cp , '<STR_LIT>' , '<STR_LIT>' ) * ( cu ( self . bearing_air . Tt , '<STR_LIT>' , '<STR_LIT>' ) - self . temp_boundary ) <EOL> nozzle_q = cu ( self . nozzle_air . W , '<STR_LIT>' , '<STR_LIT>' ) * cu ( self . nozzle_air . Cp , '<STR_LIT>' , '<STR_LIT>' ) * ( cu ( self . nozzle_air . Tt , '<STR_LIT>' , '<STR_LIT>' ) - self . temp_boundary ) <EOL> self . heat_rate_pod = nozzle_q + bearing_q <EOL> self . total_heat_rate_pods = self . heat_rate_pod * self . num_pods <EOL> if ( self . temp_outside_ambient < <NUM_LIT> ) : <EOL> self . GrDelTL3 = <NUM_LIT> * ( ( self . temp_outside_ambient ) ** ( - <NUM_LIT> ) ) <EOL> else : <EOL> self . GrDelTL3 = <NUM_LIT> * ( ( self . temp_outside_ambient ) ** ( - <NUM_LIT> ) ) <EOL> if ( self . temp_outside_ambient < <NUM_LIT> ) : <EOL> self . Pr = <NUM_LIT> * ( self . temp_outside_ambient ** ( - <NUM_LIT> ) ) <EOL> else : <EOL> self . Pr = <NUM_LIT> * ( self . temp_outside_ambient ** ( <NUM_LIT> ) ) <EOL> self . Gr = self . GrDelTL3 * ( self . temp_boundary - self . temp_outside_ambient ) * ( self . diameter_outer_tube ** <NUM_LIT:3> ) <EOL> self . Ra = self . Pr * self . Gr <EOL> if ( self . Ra <= <NUM_LIT:10> ** <NUM_LIT:12> ) : <EOL> self . Nu = ( <NUM_LIT> + <NUM_LIT> * self . Ra ** ( <NUM_LIT:1.> / <NUM_LIT> ) / ( <NUM_LIT:1> + ( <NUM_LIT> / self . Pr ) ** ( <NUM_LIT> / <NUM_LIT> ) ) ** ( <NUM_LIT> / <NUM_LIT> ) ) ** <NUM_LIT:2> <EOL> if ( self . temp_outside_ambient < <NUM_LIT> ) : <EOL> self . k = <NUM_LIT> * ( self . temp_outside_ambient ** ( <NUM_LIT> ) ) <EOL> else : <EOL> self . k = <NUM_LIT> * ( self . temp_outside_ambient ** ( <NUM_LIT> ) ) <EOL> self . h = ( self . k * self . Nu ) / self . diameter_outer_tube <EOL> self . area_convection = pi * self . length_tube * self . diameter_outer_tube <EOL> self . q_per_area_nat_conv = self . h * ( self . temp_boundary - self . temp_outside_ambient ) <EOL> self . total_q_nat_conv = self . q_per_area_nat_conv * self . area_convection <EOL> self . area_viewing = self . length_tube * self . diameter_outer_tube <EOL> self . q_per_area_solar = ( <NUM_LIT:1> - self . surface_reflectance ) * self . nn_incidence_factor * self . solar_insolation <EOL> self . q_total_solar = self . q_per_area_solar * self . area_viewing <EOL> self . area_rad = self . area_convection <EOL> self . q_rad_per_area = self . sb_constant * self . emissivity_tube * ( ( self . temp_boundary ** <NUM_LIT:4> ) - ( self . temp_outside_ambient ** <NUM_LIT:4> ) ) <EOL> self . q_rad_tot = self . area_rad * self . q_rad_per_area <EOL> self . q_total_out = self . q_rad_tot + self . total_q_nat_conv <EOL> self . q_total_in = self . q_total_solar + self . total_heat_rate_pods <EOL> self . ss_temp_residual = ( self . q_total_out - self . q_total_in ) / <NUM_LIT> <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> from openmdao . main . api import set_as_top <EOL> class TubeHeatBalance ( Assembly ) : <EOL> def configure ( self ) : <EOL> tm = self . add ( '<STR_LIT>' , TubeWallTemp ( ) ) <EOL> driver = self . add ( '<STR_LIT>' , BroydenSolver ( ) ) <EOL> driver . add_parameter ( '<STR_LIT>' , low = <NUM_LIT:0.> , high = <NUM_LIT> ) <EOL> driver . add_constraint ( '<STR_LIT>' ) <EOL> driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> test = TubeHeatBalance ( ) <EOL> set_as_top ( test ) <EOL> test . tm . nozzle_air . setTotalTP ( <NUM_LIT> , <NUM_LIT> ) <EOL> test . tm . nozzle_air . W = <NUM_LIT> <EOL> test . tm . bearing_air . W = <NUM_LIT:0.> <EOL> test . tm . diameter_outer_tube = <NUM_LIT> <EOL> test . tm . length_tube = <NUM_LIT> <EOL> test . tm . num_pods = <NUM_LIT> <EOL> test . tm . temp_boundary = <NUM_LIT> <EOL> test . tm . temp_outside_ambient = <NUM_LIT> <EOL> test . run ( ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" . format ( test . tm . total_heat_rate_pods , test . tm . q_total_solar , test . tm . q_rad_tot , test . tm . total_q_nat_conv ) <EOL> print "<STR_LIT>" . format ( test . tm . temp_boundary , cu ( test . tm . temp_boundary , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print "<STR_LIT>" . format ( test . tm . temp_outside_ambient , cu ( test . tm . temp_outside_ambient , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print "<STR_LIT>" . format ( test . tm . q_total_out , test . tm . q_total_in , ( ( test . tm . q_total_out - test . tm . q_total_in ) / test . tm . q_total_out ) * <NUM_LIT:100> ) </s>
