예제 #1
0
    def _build_problem(self, designed_stream=1, complex=False):

        p = Problem()

        p.model.set_input_defaults('start1.P', 9.218, units='psi')
        p.model.set_input_defaults('start1.T', 1524.32, units='degR')
        p.model.set_input_defaults('start1.MN', 0.4463)
        p.model.set_input_defaults('start1.W', 161.49, units='lbm/s')

        p.model.set_input_defaults('start2.P', 8.68, units='psi')
        p.model.set_input_defaults('start2.T', 524., units='degR')
        p.model.set_input_defaults('start2.MN', 0.4463)
        p.model.set_input_defaults('start2.W', 158., units='lbm/s')

        p.model.add_subsystem('start1', FlowStart(elements=AIR_FUEL_MIX))
        p.model.add_subsystem('start2', FlowStart(elements=AIR_MIX))

        p.model.add_subsystem(
            'mixer',
            Mixer(design=True,
                  designed_stream=designed_stream,
                  Fl_I1_elements=AIR_FUEL_MIX,
                  Fl_I2_elements=AIR_MIX))

        connect_flow(p.model, 'start1.Fl_O', 'mixer.Fl_I1')
        connect_flow(p.model, 'start2.Fl_O', 'mixer.Fl_I2')

        p.setup(force_alloc_complex=complex)

        p.set_solver_print(level=-1)

        return p
예제 #2
0
    def __init__(self):
        super(SteadyStateVacuum, self).__init__()

        des_vars = (('ram_recovery', 0.99), ('effDes', 0.8), ('duct_MN', 0.0),
                    ('duct_dPqP', 0.), ('nozzle_Cfg', 1.0),
                    ('nozzle_dPqP', 0.), ('shaft_Nmech', 10000.), ('inlet_MN',
                                                                   0.0),
                    ('comp_MN', 0.5), ('vehicle_mach', 0.8), ('Pa', 101.3e3, {
                        'units': 'Pa'
                    }))

        self.add('input_vars', IndepVarComp(des_vars))

        self.add('fl_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        # internal flow
        self.add('comp', Compressor(thermo_data=janaf, elements=AIR_MIX))
        self.add('q', ExecComp('Prc = Pa/Ps'), promotes=['Prc', 'Pa'])
        self.add('q1',
                 ExecComp('m_dot = 3*(A_tube*L_pod)*(1/pod_period)'),
                 promotes=['m_dot', 'pod_period', 'A_tube', 'L_pod'])

        # connect components
        connect_flow(self, 'fl_start.Fl_O', 'comp.Fl_I')

        self.connect('input_vars.effDes', 'comp.map.effDes')
        self.connect('input_vars.comp_MN', 'comp.MN_target')
        self.connect('input_vars.shaft_Nmech', 'comp.Nmech')
        self.connect('input_vars.vehicle_mach', 'fl_start.MN_target')
        self.connect('input_vars.Pa', 'Pa')
        self.connect('Prc', 'comp.map.PRdes')
        self.connect('m_dot', 'fl_start.W')
        self.connect('fl_start.P', 'q.Ps')
예제 #3
0
    def setUp(self):

        thermo = Thermo(janaf, AIR_FUEL_MIX)

        self.prob = Problem()

        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem(
            'burner',
            Combustor(thermo_data=janaf,
                      inflow_elements=AIR_MIX,
                      air_fuel_elements=AIR_FUEL_MIX,
                      fuel_type="JP-7"))
        self.prob.model.add_subsystem(
            'turbine',
            Turbine(map_data=LPT2269, design=False, elements=AIR_FUEL_MIX))

        self.prob.model.set_input_defaults('burner.MN', .01, units=None)
        self.prob.model.set_input_defaults('burner.Fl_I:FAR', .01, units=None)
        self.prob.model.set_input_defaults('turbine.Nmech', 1000.,
                                           units='rpm'),
        self.prob.model.set_input_defaults('flow_start.P', 17., units='psi'),
        self.prob.model.set_input_defaults('flow_start.T', 500.0,
                                           units='degR'),
        self.prob.model.set_input_defaults('flow_start.W', 0., units='lbm/s'),
        self.prob.model.set_input_defaults('turbine.area',
                                           150.,
                                           units='inch**2')

        connect_flow(self.prob.model, "flow_start.Fl_O", "burner.Fl_I")
        connect_flow(self.prob.model, "burner.Fl_O", "turbine.Fl_I")

        self.prob.set_solver_print(level=-1)
        self.prob.setup(check=False)
예제 #4
0
    def setUp(self):

        self.prob = Problem()

        des_vars = self.prob.model.add_subsystem('des_vars', IndepVarComp(), promotes=['*'])
        des_vars.add_output('P', 17., units='psi')
        des_vars.add_output('T', 500., units='degR')
        des_vars.add_output('MN', 0.5)
        des_vars.add_output('W', 10., units='lbm/s')
        des_vars.add_output('PR', 6.)
        des_vars.add_output('eff', 0.9)
        self.prob.model.connect("P", "flow_start.P")
        self.prob.model.connect("T", "flow_start.T")
        self.prob.model.connect("W", "flow_start.W")
        self.prob.model.connect("MN", "compressor.MN")
        self.prob.model.connect('PR', 'compressor.PR')
        self.prob.model.connect('eff', 'compressor.eff')

        self.prob.model.add_subsystem('flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem('compressor', Compressor(design=True, elements=AIR_MIX))

        connect_flow(self.prob.model, "flow_start.Fl_O", "compressor.Fl_I")

        self.prob.set_solver_print(level=-1)
        self.prob.setup(check=False)
예제 #5
0
    def test_mix_diff(self):
        # mix two identical streams and make sure you get twice the area and the same total pressure

        thermo = Thermo(janaf, AIR_MIX)

        p = Problem()

        p.model.set_input_defaults('start1.P', 17., units='psi')
        p.model.set_input_defaults('start2.P', 15., units='psi')
        p.model.set_input_defaults('T', 500., units='degR')
        p.model.set_input_defaults('MN', 0.5)
        p.model.set_input_defaults('W', 100., units='lbm/s')

        p.model.add_subsystem('start1', FlowStart(), promotes=['MN', 'T', 'W'])
        p.model.add_subsystem('start2', FlowStart(), promotes=['MN', 'T', 'W'])

        p.model.add_subsystem(
            'mixer',
            Mixer(design=True, Fl_I1_elements=AIR_MIX, Fl_I2_elements=AIR_MIX))

        connect_flow(p.model, 'start1.Fl_O', 'mixer.Fl_I1')
        connect_flow(p.model, 'start2.Fl_O', 'mixer.Fl_I2')

        p.set_solver_print(level=-1)

        p.setup()
        p.run_model()
        tol = 2e-7
        assert_near_equal(p['mixer.Fl_O:stat:area'],
                          653.2652635,
                          tolerance=tol)
        assert_near_equal(p['mixer.Fl_O:tot:P'], 15.94216641, tolerance=tol)
        assert_near_equal(p['mixer.ER'], 1.1333333333, tolerance=tol)
예제 #6
0
    def test_case1(self):

        thermo = Thermo(janaf, constants.AIR_MIX)

        self.prob = Problem()
        self.prob.model = Group()
        self.prob.model.add_subsystem('flow_start',
                                      FlowStart(thermo_data=janaf,
                                                elements=AIR_MIX),
                                      promotes=['MN', 'P', 'T'])
        self.prob.model.add_subsystem('duct',
                                      Duct(elements=AIR_MIX),
                                      promotes=['MN'])

        connect_flow(self.prob.model, 'flow_start.Fl_O', 'duct.Fl_I')

        self.prob.model.set_input_defaults('MN', 0.5)
        self.prob.model.set_input_defaults('duct.dPqP', 0.0)
        self.prob.model.set_input_defaults('P', 17., units='psi')
        self.prob.model.set_input_defaults('T', 500., units='degR')
        self.prob.model.set_input_defaults('flow_start.W', 500., units='lbm/s')

        self.prob.setup(check=False)
        self.prob.set_solver_print(level=-1)

        # 6 cases to check against
        for i, data in enumerate(ref_data):

            self.prob['duct.dPqP'] = data[h_map['dPqP']]

            # input flowstation
            self.prob['P'] = data[h_map['Fl_I.Pt']]
            self.prob['T'] = data[h_map['Fl_I.Tt']]
            self.prob['MN'] = data[h_map['Fl_O.MN']]
            self.prob['flow_start.W'] = data[h_map['Fl_I.W']]
            self.prob['duct.Fl_I:stat:V'] = data[h_map['Fl_I.V']]

            # give a decent initial guess for Ps

            print(i, self.prob['P'], self.prob['T'], self.prob['MN'])

            self.prob.run_model()

            # check outputs
            pt, ht, ps, ts = data[h_map['Fl_O.Pt']], data[h_map[
                'Fl_O.ht']], data[h_map['Fl_O.Ps']], data[h_map['Fl_O.Ts']]
            pt_computed = self.prob['duct.Fl_O:tot:P']
            ht_computed = self.prob['duct.Fl_O:tot:h']
            ps_computed = self.prob['duct.Fl_O:stat:P']
            ts_computed = self.prob['duct.Fl_O:stat:T']

            tol = 2.0e-2
            assert_near_equal(pt_computed, pt, tol)
            assert_near_equal(ht_computed, ht, tol)
            assert_near_equal(ps_computed, ps, tol)
            assert_near_equal(ts_computed, ts, tol)

            check_element_partials(self, self.prob)
예제 #7
0
    def setUp(self):

        self.prob = Problem()

        des_vars = self.prob.model.add_subsystem('des_vars',
                                                 IndepVarComp(),
                                                 promotes=['*'])
        des_vars.add_output('P', 17., units='psi')
        des_vars.add_output('T', 500., units='degR')
        des_vars.add_output('W', 0., units='lbm/s')
        des_vars.add_output('Nmech', 0., units='rpm')
        des_vars.add_output('area_targ', 50., units='inch**2')

        des_vars.add_output('s_PR', val=1.)
        des_vars.add_output('s_eff', val=1.)
        des_vars.add_output('s_Wc', val=1.)
        des_vars.add_output('s_Nc', val=1.)
        des_vars.add_output('alphaMap', val=0.)

        self.prob.model.connect("P", "flow_start.P")
        self.prob.model.connect("T", "flow_start.T")
        self.prob.model.connect("W", "flow_start.W")
        self.prob.model.connect("Nmech", "compressor.Nmech")
        self.prob.model.connect("area_targ", "compressor.area")

        self.prob.model.connect("s_PR", "compressor.s_PR")
        self.prob.model.connect("s_eff", "compressor.s_eff")
        self.prob.model.connect("s_Wc", "compressor.s_Wc")
        self.prob.model.connect("s_Nc", "compressor.s_Nc")
        self.prob.model.connect('alphaMap', 'compressor.map.alphaMap')

        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem(
            'compressor',
            Compressor(map_data=AXI5,
                       design=False,
                       elements=AIR_MIX,
                       map_extrap=False))

        connect_flow(self.prob.model, "flow_start.Fl_O", "compressor.Fl_I")

        newton = self.prob.model.nonlinear_solver = NewtonSolver()
        newton.options['atol'] = 1e-8
        newton.options['rtol'] = 1e-8
        newton.options['iprint'] = 2
        newton.options['maxiter'] = 10
        newton.options['solve_subsystems'] = True
        newton.options['max_sub_solves'] = 10
        newton.linesearch = BoundsEnforceLS()
        newton.linesearch.options['bound_enforcement'] = 'scalar'
        newton.linesearch.options['iprint'] = -1

        self.prob.model.linear_solver = DirectSolver(assemble_jac=True)

        self.prob.set_solver_print(level=-1)
        self.prob.setup(check=False)
예제 #8
0
    def setup_helper(self, NozzType, LossType):

        self.prob = Problem()
        self.prob.model = Group()

        des_vars = self.prob.model.add_subsystem('des_vars',
                                                 IndepVarComp(),
                                                 promotes=['*'])
        des_vars.add_output('Pt', 17.0, units='psi')
        des_vars.add_output('Tt', 500.0, units='degR')
        des_vars.add_output('W', 0.0, units='lbm/s')
        des_vars.add_output('MN', 0.2)
        des_vars.add_output('Ps_exhaust', 17.0, units='psi')
        des_vars.add_output('Cv', 0.99)
        des_vars.add_output('Cfg', 0.99)

        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem(
            'nozzle',
            Nozzle(nozzType=NozzType,
                   lossCoef=LossType,
                   thermo_data=janaf,
                   elements=AIR_MIX,
                   internal_solver=True))

        connect_flow(self.prob.model, "flow_start.Fl_O", "nozzle.Fl_I")

        self.prob.model.connect("Pt", "flow_start.P")
        self.prob.model.connect("Tt", "flow_start.T")
        self.prob.model.connect("W", "flow_start.W")
        self.prob.model.connect("MN", "flow_start.MN")
        self.prob.model.connect("Ps_exhaust", "nozzle.Ps_exhaust")

        if LossType == 'Cv':
            self.prob.model.connect("Cv", "nozzle.Cv")
        elif LossType == 'Cfg':
            self.prob.model.connect("Cfg", "nozzle.Cfg")

        # self.prob.model.connect("area_targ", "compressor.area")

        self.prob.set_solver_print(level=2)
        self.prob.setup(check=False)

        header = [
            'Cfg', 'Cv', 'PsExh', 'Fl_I.W', 'Fl_I.MN', 'Fl_I.s', 'Fl_I.Pt',
            'Fl_I.Tt', 'Fl_I.ht', 'Fl_I.rhot', 'Fl_I.gamt', 'Fl_O.MN',
            'Fl_O.s', 'Fl_O.Pt', 'Fl_O.Tt', 'Fl_O.ht', 'Fl_O.rhot',
            'Fl_O.gamt', 'Fl_O.Ps', 'Fl_Th.MN', 'Fl_Th.s', 'Fl_Th.Pt',
            'Fl_Th.Tt', 'Fl_Th.ht', 'Fl_Th.rhot', 'Fl_Th.gamt', 'Fl_Th.Ps',
            'Fl_Th.Aphy', 'Fg', 'FgIdeal', 'Vactual', 'AthCold', 'AR', 'PR'
        ]

        self.h_map = dict(((v_name, i) for i, v_name in enumerate(header)))
        self.fpath = os.path.dirname(os.path.realpath(__file__))
예제 #9
0
    def setup_helper(self, NozzType, LossType):

        thermo = Thermo(janaf, AIR_MIX)

        self.prob = Problem()
        self.prob.model = Group()

        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem(
            'nozzle',
            Nozzle(nozzType=NozzType,
                   lossCoef=LossType,
                   thermo_data=janaf,
                   elements=AIR_MIX,
                   internal_solver=True))

        self.prob.model.set_input_defaults('flow_start.P', 17.0, units='psi')
        self.prob.model.set_input_defaults('flow_start.T', 500.0, units='degR')
        self.prob.model.set_input_defaults('flow_start.MN', 0.2)
        self.prob.model.set_input_defaults('nozzle.Ps_exhaust',
                                           17.0,
                                           units='psi')
        self.prob.model.set_input_defaults('flow_start.W', 0.0, units='lbm/s')

        connect_flow(self.prob.model, "flow_start.Fl_O", "nozzle.Fl_I")

        if LossType == 'Cv':
            self.prob.model.set_input_defaults('nozzle.Cv', 0.99)
        elif LossType == 'Cfg':
            self.prob.model.set_input_defaults('nozzle.Cfg', 0.99)

        self.prob.set_solver_print(level=2)
        self.prob.setup(check=False)

        header = [
            'Cfg', 'Cv', 'PsExh', 'Fl_I.W', 'Fl_I.MN', 'Fl_I.s', 'Fl_I.Pt',
            'Fl_I.Tt', 'Fl_I.ht', 'Fl_I.rhot', 'Fl_I.gamt', 'Fl_O.MN',
            'Fl_O.s', 'Fl_O.Pt', 'Fl_O.Tt', 'Fl_O.ht', 'Fl_O.rhot',
            'Fl_O.gamt', 'Fl_O.Ps', 'Fl_Th.MN', 'Fl_Th.s', 'Fl_Th.Pt',
            'Fl_Th.Tt', 'Fl_Th.ht', 'Fl_Th.rhot', 'Fl_Th.gamt', 'Fl_Th.Ps',
            'Fl_Th.Aphy', 'Fg', 'FgIdeal', 'Vactual', 'AthCold', 'AR', 'PR'
        ]

        self.h_map = dict(((v_name, i) for i, v_name in enumerate(header)))
        self.fpath = os.path.dirname(os.path.realpath(__file__))
예제 #10
0
    def setUp(self):

        thermo = Thermo(janaf, constants.AIR_MIX)

        self.prob = Problem()

        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem(
            'compressor',
            Compressor(map_data=AXI5,
                       design=False,
                       elements=AIR_MIX,
                       map_extrap=False))

        self.prob.model.set_input_defaults('compressor.s_PR', val=1.)
        self.prob.model.set_input_defaults('compressor.s_eff', val=1.)
        self.prob.model.set_input_defaults('compressor.s_Wc', val=1.)
        self.prob.model.set_input_defaults('compressor.s_Nc', val=1.)
        self.prob.model.set_input_defaults('compressor.map.alphaMap', val=0.)
        self.prob.model.set_input_defaults('compressor.Nmech', 0., units='rpm')
        self.prob.model.set_input_defaults('flow_start.P', 17., units='psi')
        self.prob.model.set_input_defaults('flow_start.T', 500., units='degR')
        self.prob.model.set_input_defaults('flow_start.W', 0., units='lbm/s')
        self.prob.model.set_input_defaults('compressor.area',
                                           50.,
                                           units='inch**2')

        connect_flow(self.prob.model, "flow_start.Fl_O", "compressor.Fl_I")

        newton = self.prob.model.nonlinear_solver = NewtonSolver()
        newton.options['atol'] = 1e-8
        newton.options['rtol'] = 1e-8
        newton.options['iprint'] = 2
        newton.options['maxiter'] = 10
        newton.options['solve_subsystems'] = True
        newton.options['max_sub_solves'] = 10
        newton.linesearch = BoundsEnforceLS()
        newton.linesearch.options['bound_enforcement'] = 'scalar'
        newton.linesearch.options['iprint'] = -1

        self.prob.model.linear_solver = DirectSolver(assemble_jac=True)

        self.prob.set_solver_print(level=-1)
        self.prob.setup(check=False)
예제 #11
0
    def _build_problem(self, designed_stream=1, complex=False):
        p = Problem()

        des_vars = p.model.add_subsystem('des_vars', IndepVarComp())
        des_vars.add_output('P1', 9.218, units='psi')
        des_vars.add_output('T1', 1524.32, units='degR')
        des_vars.add_output('W1', 161.49, units='lbm/s')
        des_vars.add_output('MN1', 0.4463)

        des_vars.add_output('P2', 8.68, units='psi')
        des_vars.add_output('T2', 524., units='degR')
        des_vars.add_output('W2', 158., units='lbm/s')
        des_vars.add_output('MN2', 0.4463)

        p.model.add_subsystem('start1', FlowStart(elements=AIR_FUEL_MIX))
        p.model.add_subsystem('start2', FlowStart(elements=AIR_MIX))

        p.model.connect('des_vars.P1', 'start1.P')
        p.model.connect('des_vars.T1', 'start1.T')
        p.model.connect('des_vars.W1', 'start1.W')
        p.model.connect('des_vars.MN1', 'start1.MN')

        p.model.connect('des_vars.P2', 'start2.P')
        p.model.connect('des_vars.T2', 'start2.T')
        p.model.connect('des_vars.W2', 'start2.W')
        p.model.connect('des_vars.MN2', 'start2.MN')

        p.model.add_subsystem(
            'mixer',
            Mixer(design=True,
                  designed_stream=designed_stream,
                  Fl_I1_elements=AIR_FUEL_MIX,
                  Fl_I2_elements=AIR_MIX))

        connect_flow(p.model, 'start1.Fl_O', 'mixer.Fl_I1')
        connect_flow(p.model, 'start2.Fl_O', 'mixer.Fl_I2')

        p.setup(force_alloc_complex=complex)

        p.set_solver_print(level=-1)

        return p
예제 #12
0
    def test_mix_diff(self):
        # mix two identical streams and make sure you get twice the area and the same total pressure

        p = Problem()

        des_vars = p.model.add_subsystem('des_vars', IndepVarComp())
        des_vars.add_output('P1', 17., units='psi')
        des_vars.add_output('P2', 15., units='psi')
        des_vars.add_output('T', 500., units='degR')
        des_vars.add_output('W', 100., units='lbm/s')
        des_vars.add_output('MN', 0.5)

        p.model.add_subsystem('start1', FlowStart())
        p.model.add_subsystem('start2', FlowStart())

        p.model.connect('des_vars.P1', 'start1.P')
        p.model.connect('des_vars.P2', 'start2.P')
        p.model.connect('des_vars.T', ['start1.T', 'start2.T'])
        p.model.connect('des_vars.W', ['start1.W', 'start2.W'])
        p.model.connect('des_vars.MN', ['start1.MN', 'start2.MN'])

        p.model.add_subsystem(
            'mixer',
            Mixer(design=True, Fl_I1_elements=AIR_MIX, Fl_I2_elements=AIR_MIX))

        connect_flow(p.model, 'start1.Fl_O', 'mixer.Fl_I1')
        connect_flow(p.model, 'start2.Fl_O', 'mixer.Fl_I2')

        p.set_solver_print(level=-1)

        p.setup()
        p.run_model()
        tol = 2e-7
        assert_rel_error(self,
                         p['mixer.Fl_O:stat:area'],
                         653.2652635,
                         tolerance=tol)
        assert_rel_error(self,
                         p['mixer.Fl_O:tot:P'],
                         15.94216641,
                         tolerance=tol)
        assert_rel_error(self, p['mixer.ER'], 1.1333333333, tolerance=tol)
예제 #13
0
    def setup(self):

        thermo_spec = species_data.janaf

        self.add_subsystem(
            'fc', FlightConditions(thermo_data=thermo_spec, elements=AIR_MIX))

        self.add_subsystem(
            'inlet',
            Inlet(design=True, thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem(
            'fan',
            Compressor(thermo_data=thermo_spec, elements=AIR_MIX, design=True))
        self.add_subsystem('nozz',
                           Nozzle(thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem('perf', Performance(num_nozzles=1, num_burners=0))

        self.add_subsystem('shaft', IndepVarComp('Nmech', 1., units='rpm'))

        self.add_subsystem('pwr_balance',
                           BalanceComp('W',
                                       units='lbm/s',
                                       eq_units='hp',
                                       val=50.,
                                       lower=1.,
                                       upper=500.),
                           promotes_inputs=[('rhs:W', 'pwr_target')])

        # self.set_order(['pwr_balance', 'pwr_target', 'fc', 'inlet', 'shaft', 'fan', 'nozz', 'perf'])

        connect_flow(self, 'fc.Fl_O', 'inlet.Fl_I')
        connect_flow(self, 'inlet.Fl_O', 'fan.Fl_I')
        connect_flow(self, 'fan.Fl_O', 'nozz.Fl_I')

        self.connect('shaft.Nmech', 'fan.Nmech')

        self.connect('fc.Fl_O:stat:P', 'nozz.Ps_exhaust')
        self.connect('inlet.Fl_O:tot:P', 'perf.Pt2')
        self.connect('fan.Fl_O:tot:P', 'perf.Pt3')
        self.connect('inlet.F_ram', 'perf.ram_drag')
        self.connect('nozz.Fg', 'perf.Fg_0')

        self.connect('pwr_balance.W', 'fc.W')
        self.connect('fan.power', 'pwr_balance.lhs:W')

        newton = self.nonlinear_solver = NewtonSolver()
        newton.options['atol'] = 1e-12
        newton.options['rtol'] = 1e-12
        newton.options['iprint'] = 2
        newton.options['maxiter'] = 10
        newton.options['solve_subsystems'] = True
        newton.options['max_sub_solves'] = 10
        #
        newton.linesearch = BoundsEnforceLS()
        newton.linesearch.options['bound_enforcement'] = 'scalar'
        # newton.linesearch.options['print_bound_enforce'] = True
        # newton.linesearch.options['iprint'] = -1
        #
        self.linear_solver = DirectSolver(assemble_jac=True)
예제 #14
0
    def setUp(self):
        self.prob = Problem()

        des_vars = self.prob.model.add_subsystem('des_vars',
                                                 IndepVarComp(),
                                                 promotes=['*'])
        des_vars.add_output('P', 17., units='psi'),
        des_vars.add_output('T', 500.0, units='degR'),
        des_vars.add_output('W', 0., units='lbm/s'),
        des_vars.add_output('Nmech', 1000., units='rpm'),
        des_vars.add_output('area_targ', 150., units='inch**2')
        des_vars.add_output('burner_MN', .01, units=None)
        des_vars.add_output('burner_FAR', .01, units=None)

        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem(
            'burner',
            Combustor(thermo_data=janaf,
                      inflow_elements=AIR_MIX,
                      air_fuel_elements=AIR_FUEL_MIX,
                      fuel_type="JP-7"))
        self.prob.model.add_subsystem(
            'turbine',
            Turbine(map_data=LPT2269, design=False, elements=AIR_FUEL_MIX))

        connect_flow(self.prob.model, "flow_start.Fl_O", "burner.Fl_I")
        connect_flow(self.prob.model, "burner.Fl_O", "turbine.Fl_I")

        self.prob.model.connect("P", "flow_start.P")
        self.prob.model.connect("T", "flow_start.T")
        self.prob.model.connect("W", "flow_start.W")
        self.prob.model.connect("Nmech", "turbine.Nmech")
        self.prob.model.connect("area_targ", "turbine.area")
        self.prob.model.connect("burner_MN", "burner.MN")
        self.prob.model.connect("burner_FAR", "burner.Fl_I:FAR")

        self.prob.set_solver_print(level=-1)
        self.prob.setup(check=False)
예제 #15
0
    def setUp(self):

        thermo = Thermo(janaf, constants.AIR_MIX)

        self.prob = Problem()

        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem(
            'compressor', Compressor(design=True, elements=AIR_MIX))

        self.prob.model.set_input_defaults('flow_start.P', 17., units='psi')
        self.prob.model.set_input_defaults('flow_start.T', 500., units='degR')
        self.prob.model.set_input_defaults('compressor.MN', 0.5)
        self.prob.model.set_input_defaults('flow_start.W', 10., units='lbm/s')
        self.prob.model.set_input_defaults('compressor.PR', 6.)
        self.prob.model.set_input_defaults('compressor.eff', 0.9)

        connect_flow(self.prob.model, "flow_start.Fl_O", "compressor.Fl_I")

        self.prob.set_solver_print(level=-1)
        self.prob.setup(check=False)
예제 #16
0
    def setUp(self):
        self.prob = Problem()
        self.prob.model = Group()

        des_vars = self.prob.model.add_subsystem('des_vars',
                                                 IndepVarComp(),
                                                 promotes=['*'])
        des_vars.add_output('P', 17.0, units='psi')
        des_vars.add_output('T', 500.0, units='degR')
        des_vars.add_output('W', 100.0, units='lbm/s')
        des_vars.add_output('PR', 4.0)
        des_vars.add_output('MN', 0.0)
        des_vars.add_output('Nmech', 1000.0, units='rpm')
        des_vars.add_output('flow_start_MN', 0.0)
        des_vars.add_output('eff', 0.9)

        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem(
            'turbine', Turbine(map_data=LPT2269, design=True,
                               elements=AIR_MIX))

        connect_flow(self.prob.model, 'flow_start.Fl_O', 'turbine.Fl_I')

        self.prob.model.connect("P", "flow_start.P")
        self.prob.model.connect("T", "flow_start.T")
        self.prob.model.connect("W", "flow_start.W")
        self.prob.model.connect("flow_start_MN", "flow_start.MN")

        self.prob.model.connect("PR", "turbine.PR")
        self.prob.model.connect("MN", "turbine.MN")
        self.prob.model.connect("Nmech", "turbine.Nmech")
        self.prob.model.connect('eff', 'turbine.eff')

        self.prob.setup(check=False)
        self.prob.set_solver_print(level=-1)
예제 #17
0
    def __init__(self):
        super(CompressionCycle, self).__init__()

        # initiate components
        #self.add('fc', FlightConditions())
        self.add('fl_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        # internal flow
        self.add('inlet', Inlet(thermo_data=janaf, elements=AIR_MIX))
        self.add('comp', Compressor(thermo_data=janaf, elements=AIR_MIX))
        self.add('duct', Duct(thermo_data=janaf, elements=AIR_MIX))
        self.add('nozzle', Nozzle(thermo_data=janaf, elements=AIR_MIX))
        self.add('shaft', Shaft(1))

        # connect components
        connect_flow(self, 'fl_start.Fl_O', 'inlet.Fl_I')
        connect_flow(self, 'inlet.Fl_O', 'comp.Fl_I')
        connect_flow(self, 'comp.Fl_O', 'duct.Fl_I')
        connect_flow(self, 'duct.Fl_O', 'nozzle.Fl_I')

        self.connect('comp.trq', 'shaft.trq_0')
        self.connect('shaft.Nmech', 'comp.Nmech')
예제 #18
0
    def __init__(self):
        super(CompressionCycle, self).__init__()

        # initiate components
        #self.add('fc', FlightConditions())
        self.add('fl_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        # internal flow
        self.add('inlet', Inlet(thermo_data=janaf, elements=AIR_MIX))
        self.add('comp', Compressor(thermo_data=janaf, elements=AIR_MIX))
        self.add('duct', Duct(thermo_data=janaf, elements=AIR_MIX))
        self.add('nozzle', Nozzle(thermo_data=janaf, elements=AIR_MIX))
        self.add('shaft', Shaft(1))

        # connect components
        connect_flow(self,'fl_start.Fl_O', 'inlet.Fl_I')
        connect_flow(self, 'inlet.Fl_O','comp.Fl_I')
        connect_flow(self,'comp.Fl_O', 'duct.Fl_I')
        connect_flow(self,'duct.Fl_O', 'nozzle.Fl_I')

        self.connect('comp.trq', 'shaft.trq_0')
        self.connect('shaft.Nmech', 'comp.Nmech')
예제 #19
0
    def __init__(self):
        super(FlowPath, self).__init__()

        des_vars = (('ram_recovery', 0.99), ('effDes', 0.9), ('duct_MN', 0.65),
                    ('duct_dPqP', 0.), ('nozzle_Cfg', 1.0),
                    ('nozzle_dPqP', 0.), ('shaft_Nmech', 10000.),
                    ('inlet_MN', 0.6), ('comp_MN', 0.65))

        self.add('input_vars', IndepVarComp(des_vars))

        self.add('fl_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        # internal flow
        self.add('inlet', Inlet(thermo_data=janaf, elements=AIR_MIX))
        self.add('comp', Compressor(thermo_data=janaf, elements=AIR_MIX))
        self.add('duct', Duct(thermo_data=janaf, elements=AIR_MIX))
        self.add('nozzle', Nozzle(thermo_data=janaf, elements=AIR_MIX))
        self.add('shaft', Shaft(1))

        # connect components
        connect_flow(self, 'fl_start.Fl_O', 'inlet.Fl_I')
        connect_flow(self, 'inlet.Fl_O', 'comp.Fl_I')
        connect_flow(self, 'comp.Fl_O', 'duct.Fl_I')
        connect_flow(self, 'duct.Fl_O', 'nozzle.Fl_I')

        self.connect('input_vars.ram_recovery', 'inlet.ram_recovery')
        self.connect('input_vars.effDes', 'comp.map.effDes')
        self.connect('input_vars.duct_MN', 'duct.MN_target')
        self.connect('input_vars.duct_dPqP', 'duct.dPqP')
        self.connect('input_vars.nozzle_Cfg', 'nozzle.Cfg')
        self.connect('input_vars.nozzle_dPqP', 'nozzle.dPqP')
        self.connect('input_vars.shaft_Nmech', 'shaft.Nmech')
        self.connect('input_vars.inlet_MN', 'inlet.MN_target')
        self.connect('input_vars.comp_MN', 'comp.MN_target')

        self.connect('comp.trq', 'shaft.trq_0')
        self.connect('shaft.Nmech', 'comp.Nmech')
예제 #20
0
파일: nozzle.py 프로젝트: friedenhe/pyCycle
    p.model.add_subsystem('des_var2',
                          IndepVarComp('Pt', 14.0, units='lbf/inch**2'))
    p.model.add_subsystem('des_var3', IndepVarComp('Tt', 1662.44,
                                                   units='degR'))
    p.model.add_subsystem('des_var4', IndepVarComp('dPqP', 0.0))
    p.model.add_subsystem(
        'des_var5', IndepVarComp('Ps_exhaust', 14.696, units='lbf/inch**2'))
    p.model.add_subsystem('des_var6', IndepVarComp('Cv', 0.99, units=None))

    p.model.add_subsystem(
        'flow_start',
        FlowStart(thermo_data=species_data.janaf, elements=AIR_MIX))
    p.model.add_subsystem(
        'nozz', Nozzle(nozzType="CD", lossCoef='Cv', elements=AIR_MIX))

    connect_flow(p.model, "flow_start.Fl_O", "nozz.Fl_I", connect_stat=False)

    p.model.connect('des_var1.W', 'flow_start.W')
    p.model.connect('des_var2.Pt', 'flow_start.P')
    p.model.connect('des_var3.Tt', 'flow_start.T')
    p.model.connect('des_var4.dPqP', 'nozz.dPqP')
    p.model.connect('des_var5.Ps_exhaust', 'nozz.Ps_exhaust')
    p.model.connect('des_var6.Cv', 'nozz.Cv')

    # p.model.add('pressure', IndepVarComp('Ps_exhaust', 3.457820249, units='lbf/inch**2'), promotes=["*"])

    p.setup(check=True)

    # p.model.Fl_I.W = 51.45
    # p.model.Fl_I.Pt = 9.262
    # p.model.Fl_I.Tt = 1443.35
    def setup(self):
        thermo_spec = species_data.janaf
        design = self.options['design']

        ##########################################
        # Elements
        ##########################################

        self.add_subsystem(
            'fc', FlightConditions(thermo_data=thermo_spec, elements=AIR_MIX))
        # Inlet Components
        self.add_subsystem('mil_spec', MilSpecRecovery())
        self.add_subsystem(
            'inlet',
            Inlet(design=design, thermo_data=thermo_spec, elements=AIR_MIX))

        # Fan Components - Split here for CFD integration Add a CFDStart Compomponent
        self.add_subsystem('fan',
                           Compressor(map_data=AXI5,
                                      design=design,
                                      thermo_data=thermo_spec,
                                      elements=AIR_MIX,
                                      map_extrap=True),
                           promotes_inputs=[('Nmech', 'LP_Nmech')])

        self.add_subsystem(
            'splitter',
            Splitter(design=design, thermo_data=thermo_spec, elements=AIR_MIX))

        # Bypass Stream
        ###################
        self.add_subsystem(
            'bypass_duct',
            Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX))

        # Core Stream
        ##############
        self.add_subsystem(
            'ic_duct',
            Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX))

        self.add_subsystem('hpc',
                           Compressor(map_data=HPCmap,
                                      design=design,
                                      thermo_data=thermo_spec,
                                      elements=AIR_MIX,
                                      bleed_names=['cool1', 'cool2'],
                                      map_extrap=True),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])

        self.add_subsystem(
            'duct_3',
            Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX))

        self.add_subsystem('bleed_3',
                           BleedOut(design=design, bleed_names=['cust_bleed']))

        self.add_subsystem(
            'burner',
            Combustor(design=design,
                      thermo_data=thermo_spec,
                      inflow_elements=AIR_MIX,
                      air_fuel_elements=AIR_FUEL_MIX,
                      fuel_type='Jet-A(g)'))
        self.add_subsystem('hpt',
                           Turbine(map_data=HPTmap,
                                   design=design,
                                   thermo_data=thermo_spec,
                                   elements=AIR_FUEL_MIX,
                                   bleed_names=['chargable', 'non_chargable'],
                                   map_extrap=True),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])

        self.add_subsystem(
            'it_duct',
            Duct(design=design, thermo_data=thermo_spec,
                 elements=AIR_FUEL_MIX))

        # uncooled lpt
        self.add_subsystem('lpt',
                           Turbine(map_data=LPTmap,
                                   design=design,
                                   thermo_data=thermo_spec,
                                   elements=AIR_FUEL_MIX,
                                   map_extrap=True),
                           promotes_inputs=[('Nmech', 'LP_Nmech')])

        if not design:
            self.add_subsystem(
                'vabi',
                ExecComp('Fl1_area = Fl1_area_des*fact',
                         Fl1_area_des={'units': 'inch**2'},
                         Fl1_area={
                             'units': 'inch**2',
                             'value': 164.
                         }))

        self.add_subsystem(
            'mixer',
            Mixer(design=design,
                  designed_stream=1,
                  Fl_I1_elements=AIR_FUEL_MIX,
                  Fl_I2_elements=AIR_MIX))

        # augmentor Components
        self.add_subsystem(
            'augmentor',
            Combustor(design=design,
                      thermo_data=thermo_spec,
                      inflow_elements=AIR_FUEL_MIX,
                      air_fuel_elements=AIR_FUEL_MIX,
                      fuel_type='Jet-A(g)'))
        # End CFD HERE
        # Nozzle
        self.add_subsystem(
            'nozzle',
            Nozzle(nozzType='CD',
                   lossCoef='Cfg',
                   thermo_data=thermo_spec,
                   elements=AIR_FUEL_MIX))

        # Mechanical components
        self.add_subsystem('lp_shaft',
                           Shaft(num_ports=2),
                           promotes_inputs=[('Nmech', 'LP_Nmech')])
        self.add_subsystem('hp_shaft',
                           Shaft(num_ports=2),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])

        # Aggregating component
        self.add_subsystem('perf', Performance(num_nozzles=1, num_burners=2))

        ##########################################
        #  Connecting the Flow Path
        ##########################################
        connect_flow(self, 'fc.Fl_O', 'inlet.Fl_I')
        connect_flow(self, 'inlet.Fl_O', 'fan.Fl_I')
        connect_flow(self, 'fan.Fl_O', 'splitter.Fl_I')

        # Bypass Connections
        connect_flow(self, 'splitter.Fl_O2', 'bypass_duct.Fl_I')
        connect_flow(self, 'bypass_duct.Fl_O', 'mixer.Fl_I2')

        # Core connections
        connect_flow(self, 'splitter.Fl_O1', 'ic_duct.Fl_I')
        connect_flow(self, 'ic_duct.Fl_O', 'hpc.Fl_I')
        connect_flow(self, 'hpc.Fl_O', 'duct_3.Fl_I')
        connect_flow(self, 'duct_3.Fl_O', 'bleed_3.Fl_I')
        connect_flow(self, 'bleed_3.Fl_O', 'burner.Fl_I')
        connect_flow(self, 'burner.Fl_O', 'hpt.Fl_I')
        connect_flow(self, 'hpt.Fl_O', 'it_duct.Fl_I')
        connect_flow(self, 'it_duct.Fl_O', 'lpt.Fl_I')
        connect_flow(self, 'lpt.Fl_O', 'mixer.Fl_I1')

        connect_flow(self, 'mixer.Fl_O', 'augmentor.Fl_I')
        connect_flow(self, 'augmentor.Fl_O', 'nozzle.Fl_I')

        # Connect cooling flows
        connect_flow(self,
                     'hpc.cool1',
                     'hpt.non_chargable',
                     connect_stat=False)
        connect_flow(self, 'hpc.cool2', 'hpt.chargable', connect_stat=False)

        ##########################################
        #  Additional Connections
        ##########################################
        # Make additional model connections
        self.connect('fc.Fl_O:stat:MN', 'mil_spec.MN')
        self.connect('mil_spec.ram_recovery', 'inlet.ram_recovery')
        self.connect('inlet.Fl_O:tot:P', 'perf.Pt2')
        self.connect('hpc.Fl_O:tot:P', 'perf.Pt3')
        self.connect('burner.Wfuel', 'perf.Wfuel_0')
        self.connect('augmentor.Wfuel', 'perf.Wfuel_1')
        self.connect('inlet.F_ram', 'perf.ram_drag')
        self.connect('nozzle.Fg', 'perf.Fg_0')

        self.connect('fan.trq', 'lp_shaft.trq_0')
        self.connect('lpt.trq', 'lp_shaft.trq_1')

        self.connect('hpc.trq', 'hp_shaft.trq_0')
        self.connect('hpt.trq', 'hp_shaft.trq_1')

        self.connect('fc.Fl_O:stat:P', 'nozzle.Ps_exhaust')

        if not design:
            self.connect('vabi.Fl1_area', 'mixer.Fl_I1_stat_calc.area')

        ##########################################
        #  Balances to define cycle convergence
        ##########################################
        balance = self.add_subsystem('balance', BalanceComp())
        if design:
            balance.add_balance('W',
                                lower=1e-3,
                                upper=200.,
                                units='lbm/s',
                                eq_units='lbf')
            self.connect('balance.W', 'fc.fs.W')
            self.connect('perf.Fn', 'balance.lhs:W')
            # self.add_subsystem('wDV',IndepVarComp('wDes',100,units='lbm/s'))
            # self.connect('wDV.wDes','fc.fs.W')

            balance.add_balance('BPR', eq_units=None, lower=0.25, val=5.0)
            self.connect('balance.BPR', 'splitter.BPR')
            self.connect('mixer.ER', 'balance.lhs:BPR')

            balance.add_balance('FAR_core',
                                eq_units='degR',
                                lower=1e-4,
                                val=.017)
            self.connect('balance.FAR_core', 'burner.Fl_I:FAR')
            self.connect('burner.Fl_O:tot:T', 'balance.lhs:FAR_core')

            balance.add_balance('FAR_ab',
                                eq_units='degR',
                                lower=1e-4,
                                val=.017)
            self.connect('balance.FAR_ab', 'augmentor.Fl_I:FAR')
            self.connect('augmentor.Fl_O:tot:T', 'balance.lhs:FAR_ab')

            balance.add_balance('lpt_PR',
                                val=1.5,
                                lower=1.001,
                                upper=8,
                                eq_units='hp',
                                use_mult=True,
                                mult_val=-1)
            self.connect('balance.lpt_PR', 'lpt.PR')
            self.connect('lp_shaft.pwr_in', 'balance.lhs:lpt_PR')
            self.connect('lp_shaft.pwr_out', 'balance.rhs:lpt_PR')

            balance.add_balance('hpt_PR',
                                val=1.5,
                                lower=1.001,
                                upper=8,
                                eq_units='hp',
                                use_mult=True,
                                mult_val=-1)
            self.connect('balance.hpt_PR', 'hpt.PR')
            self.connect('hp_shaft.pwr_in', 'balance.lhs:hpt_PR')
            self.connect('hp_shaft.pwr_out', 'balance.rhs:hpt_PR')

        else:  # off design
            balance.add_balance('W',
                                lower=1e-3,
                                upper=400.,
                                units='lbm/s',
                                eq_units='inch**2')
            self.connect('balance.W', 'fc.fs.W')
            self.connect('nozzle.Throat:stat:area', 'balance.lhs:W')

            balance.add_balance('BPR', lower=0.25, upper=3.0, eq_units='psi')
            self.connect('balance.BPR', 'splitter.BPR')
            self.connect('mixer.Fl_I1_calc:stat:P', 'balance.lhs:BPR')
            self.connect('bypass_duct.Fl_O:stat:P', 'balance.rhs:BPR')

            # balance.add_balance('FAR_core', eq_units='degR', lower=1e-4, upper=.045, val=.017)
            # self.connect('balance.FAR_core', 'burner.Fl_I:FAR')
            # self.connect('burner.Fl_O:tot:T', 'balance.lhs:FAR_core')

            balance.add_balance('FAR_ab',
                                eq_units='degR',
                                lower=1e-4,
                                upper=.045,
                                val=.017)
            self.connect('balance.FAR_ab', 'augmentor.Fl_I:FAR')
            self.connect('augmentor.Fl_O:tot:T', 'balance.lhs:FAR_ab')

            far_core_bal = ConstrainedTempBalance()
            self.add_subsystem('far_core_bal', far_core_bal)
            self.connect('far_core_bal.FAR', 'burner.Fl_I:FAR')
            self.connect('burner.Fl_O:tot:T', 'far_core_bal.T_computed')
            self.connect('fan.map.shaftNc.NcMap', 'far_core_bal.Nc_computed')

            balance.add_balance('LP_Nmech',
                                val=1.,
                                units='rpm',
                                lower=0.5,
                                upper=2.,
                                eq_units='hp',
                                use_mult=True,
                                mult_val=-1)
            self.connect('balance.LP_Nmech', 'LP_Nmech')
            self.connect('lp_shaft.pwr_in', 'balance.lhs:LP_Nmech')
            self.connect('lp_shaft.pwr_out', 'balance.rhs:LP_Nmech')

            balance.add_balance('HP_Nmech',
                                val=1.,
                                units='rpm',
                                lower=0.5,
                                upper=2.,
                                eq_units='hp',
                                use_mult=True,
                                mult_val=-1)
            self.connect('balance.HP_Nmech', 'HP_Nmech')
            self.connect('hp_shaft.pwr_in', 'balance.lhs:HP_Nmech')
            self.connect('hp_shaft.pwr_out', 'balance.rhs:HP_Nmech')

        newton = self.nonlinear_solver = NewtonSolver()
        newton.options['atol'] = 1e-6
        newton.options['rtol'] = 1e-10
        newton.options['iprint'] = 2
        newton.options['maxiter'] = 30
        newton.options['solve_subsystems'] = True
        newton.options['max_sub_solves'] = 10
        newton.linesearch = BoundsEnforceLS()
        newton.linesearch.options['bound_enforcement'] = 'scalar'
        # newton.linesearch.options['print_bound_enforce'] = True
        newton.linesearch.options['iprint'] = -1

        # newton.linesearch = ArmijoGoldsteinLS()
        # newton.linesearch.options['c'] = -.1

        self.linear_solver = DirectSolver(assemble_jac=True)

        # TODO: re-factor pycycle so this block isn't needed in default use case!!!
        if design:
            ##########################################
            #  Model Parameters
            ##########################################
            element_params = self.add_subsystem('element_params',
                                                IndepVarComp(),
                                                promotes=["*"])
            # element_params.add_output('inlet:ram_recovery', 0.9990)
            element_params.add_output('inlet:MN_out', 0.65)
            # self.connect('inlet:ram_recovery', 'inlet.ram_recovery')
            self.connect('inlet:MN_out', 'inlet.MN')

            element_params.add_output('fan:effDes', 0.8700)
            element_params.add_output('fan:MN_out', 0.4578)
            self.connect('fan:effDes', 'fan.map.effDes')
            self.connect('fan:MN_out', 'fan.MN')

            element_params.add_output('splitter:MN_out1', 0.3104)
            element_params.add_output('splitter:MN_out2', 0.4518)
            self.connect('splitter:MN_out1', 'splitter.MN1')
            self.connect('splitter:MN_out2', 'splitter.MN2')

            element_params.add_output('ic_duct:dPqP', 0.0048)
            element_params.add_output('ic_duct:MN_out', 0.3121)
            self.connect('ic_duct:dPqP', 'ic_duct.dPqP')
            self.connect('ic_duct:MN_out', 'ic_duct.MN')

            element_params.add_output('hpc:effDes', 0.8707)
            element_params.add_output('hpc:MN_out', 0.2442)
            self.connect('hpc:effDes', 'hpc.map.effDes')
            self.connect('hpc:MN_out', 'hpc.MN')

            element_params.add_output('hpc:cool1:frac_W', 0.09)
            element_params.add_output('hpc:cool1:frac_P', 1.0)
            element_params.add_output('hpc:cool1:frac_work', 1.0)
            self.connect('hpc:cool1:frac_W', 'hpc.cool1:frac_W')
            self.connect('hpc:cool1:frac_P', 'hpc.cool1:frac_P')
            self.connect('hpc:cool1:frac_work', 'hpc.cool1:frac_work')

            element_params.add_output('hpc:cool2:frac_W', 0.07)
            element_params.add_output('hpc:cool2:frac_P', 0.5)
            element_params.add_output('hpc:cool2:frac_work', 0.5)
            self.connect('hpc:cool2:frac_W', 'hpc.cool2:frac_W')
            self.connect('hpc:cool2:frac_P', 'hpc.cool2:frac_P')
            self.connect('hpc:cool2:frac_work', 'hpc.cool2:frac_work')

            element_params.add_output('duct_3:dPqP', 0.0048)
            element_params.add_output('duct_3:MN_out', 0.2)
            self.connect('duct_3:dPqP', 'duct_3.dPqP')
            self.connect('duct_3:MN_out', 'duct_3.MN')

            element_params.add_output('bleed_3:MN_out', 0.3000)
            element_params.add_output('bleed_3:cust_bleed:frac_W', 0.07)
            self.connect('bleed_3:MN_out', 'bleed_3.MN')
            self.connect('bleed_3:cust_bleed:frac_W',
                         'bleed_3.cust_bleed:frac_W')

            element_params.add_output('burner:dPqP', 0.0540)
            element_params.add_output('burner:MN_out', 0.1025)
            self.connect('burner:dPqP', 'burner.dPqP')
            self.connect('burner:MN_out', 'burner.MN')

            element_params.add_output('hpt:effDes', 0.8888)
            element_params.add_output('hpt:MN_out', 0.3650)
            element_params.add_output('hpt:chargable:frac_P', 0.0)
            element_params.add_output('hpt:non_chargable:frac_P', 1.0)
            self.connect('hpt:effDes', 'hpt.map.effDes')
            self.connect('hpt:MN_out', 'hpt.MN')
            self.connect('hpt:chargable:frac_P', 'hpt.chargable:frac_P')
            self.connect('hpt:non_chargable:frac_P',
                         'hpt.non_chargable:frac_P')

            element_params.add_output('it_duct:dPqP', 0.0051)
            element_params.add_output('it_duct:MN_out', 0.3063)
            self.connect('it_duct:dPqP', 'it_duct.dPqP')
            self.connect('it_duct:MN_out', 'it_duct.MN')

            element_params.add_output('lpt:effDes', 0.8996)
            element_params.add_output('lpt:MN_out', 0.4127)
            self.connect('lpt:effDes', 'lpt.map.effDes')
            self.connect('lpt:MN_out', 'lpt.MN')

            element_params.add_output('bypass_duct:dPqP', 0.0107)
            element_params.add_output('bypass_duct:MN_out', 0.4463)
            self.connect('bypass_duct:dPqP', 'bypass_duct.dPqP')
            self.connect('bypass_duct:MN_out', 'bypass_duct.MN')

            # No params for mixer

            element_params.add_output('augmentor:dPqP', 0.0540)
            element_params.add_output('augmentor:MN_out', 0.1025)
            self.connect('augmentor:dPqP', 'augmentor.dPqP')
            self.connect('augmentor:MN_out', 'augmentor.MN')

            element_params.add_output('nozzle:Cfg', 0.9933)
            self.connect('nozzle:Cfg', 'nozzle.Cfg')

            element_params.add_output('lp_shaft:Nmech', 1, units='rpm')
            element_params.add_output('hp_shaft:Nmech', 1, units='rpm')
            element_params.add_output('hp_shaft:HPX', 250.0, units='hp')
            self.connect('lp_shaft:Nmech', 'LP_Nmech')
            self.connect('hp_shaft:Nmech', 'HP_Nmech')
            self.connect('hp_shaft:HPX', 'hp_shaft.HPX')
예제 #22
0
    def test_case_with_dPqP_MN(self):

        self.prob = Problem()
        self.prob.model = Group()
        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem(
            'flow_start_OD', FlowStart(thermo_data=janaf, elements=AIR_MIX))

        expMN = 1.0
        self.prob.model.add_subsystem('duct_des',
                                      Duct(elements=AIR_MIX, expMN=expMN))
        self.prob.model.add_subsystem(
            'duct_OD', Duct(elements=AIR_MIX, expMN=expMN, design=False))

        connect_flow(self.prob.model, 'flow_start.Fl_O', 'duct_des.Fl_I')
        connect_flow(self.prob.model, 'flow_start_OD.Fl_O', 'duct_OD.Fl_I')

        des_vars = self.prob.model.add_subsystem('des_vars',
                                                 IndepVarComp(),
                                                 promotes=['*'])
        des_vars.add_output('P', 17., units='psi')
        des_vars.add_output('T', 500., units='degR')
        des_vars.add_output('W', 500., units='lbm/s')
        des_vars.add_output('MN', 0.5)
        des_vars.add_output('MN_OD', 0.25)
        des_vars.add_output('dPqP_des', 0.0)

        self.prob.model.connect("P", ["flow_start.P", 'flow_start_OD.P'])
        self.prob.model.connect("T", ["flow_start.T", 'flow_start_OD.T'])
        self.prob.model.connect("W", ["flow_start.W", 'flow_start_OD.W'])
        self.prob.model.connect("MN", ["duct_des.MN", "flow_start.MN"])
        self.prob.model.connect("MN_OD", "flow_start_OD.MN")
        self.prob.model.connect("duct_des.s_dPqP", "duct_OD.s_dPqP")
        self.prob.model.connect("duct_des.Fl_O:stat:area", "duct_OD.area")
        self.prob.model.connect("dPqP_des", "duct_des.dPqP")

        self.prob.setup(check=False)
        self.prob.set_solver_print(level=-1)

        data = ref_data[0]
        self.prob['dPqP_des'] = data[h_map['dPqP']]

        # input flowstation
        self.prob['P'] = data[h_map['Fl_I.Pt']]
        self.prob['T'] = data[h_map['Fl_I.Tt']]
        self.prob['MN'] = data[h_map['Fl_O.MN']]
        self.prob['W'] = data[h_map['Fl_I.W']]
        self.prob['duct_des.Fl_I:stat:V'] = data[h_map['Fl_I.V']]

        # give a decent initial guess for Ps

        print(self.prob['P'], self.prob['T'], self.prob['MN'])

        self.prob.run_model()

        # check outputs
        pt, ht, ps, ts = data[h_map['Fl_O.Pt']], data[h_map['Fl_O.ht']], data[
            h_map['Fl_O.Ps']], data[h_map['Fl_O.Ts']]
        pt_computed = self.prob['duct_OD.Fl_O:tot:P']
        ht_computed = self.prob['duct_OD.Fl_O:tot:h']
        ps_computed = self.prob['duct_OD.Fl_O:stat:P']
        ts_computed = self.prob['duct_OD.Fl_O:stat:T']

        tol = 1.0e-4
        assert_rel_error(self, pt_computed, 8.84073152, tol)
        assert_rel_error(self, ht_computed, ht, tol)
        assert_rel_error(self, ps_computed, 8.26348914, tol)
        assert_rel_error(self, ts_computed, ts, tol)

        check_element_partials(self, self.prob)
예제 #23
0
    def test_case1(self):

        self.prob = Problem()
        self.prob.model = Group()
        self.prob.model.add_subsystem(
            'flow_start', FlowStart(thermo_data=janaf, elements=AIR_MIX))
        self.prob.model.add_subsystem('duct', Duct(elements=AIR_MIX))

        connect_flow(self.prob.model, 'flow_start.Fl_O', 'duct.Fl_I')

        des_vars = self.prob.model.add_subsystem('des_vars',
                                                 IndepVarComp(),
                                                 promotes=['*'])
        des_vars.add_output('P', 17., units='psi')
        des_vars.add_output('T', 500., units='degR')
        des_vars.add_output('W', 500., units='lbm/s')
        des_vars.add_output('MN', 0.5)
        des_vars.add_output('dPqP_des', 0.0)

        self.prob.model.connect("P", "flow_start.P")
        self.prob.model.connect("T", "flow_start.T")
        self.prob.model.connect("W", "flow_start.W")
        self.prob.model.connect("MN", ["duct.MN", "flow_start.MN"])
        self.prob.model.connect("dPqP_des", "duct.dPqP")

        self.prob.setup(check=False)
        self.prob.set_solver_print(level=-1)

        # 6 cases to check against
        for i, data in enumerate(ref_data):

            self.prob['dPqP_des'] = data[h_map['dPqP']]

            # input flowstation
            self.prob['P'] = data[h_map['Fl_I.Pt']]
            self.prob['T'] = data[h_map['Fl_I.Tt']]
            self.prob['MN'] = data[h_map['Fl_O.MN']]
            self.prob['W'] = data[h_map['Fl_I.W']]
            self.prob['duct.Fl_I:stat:V'] = data[h_map['Fl_I.V']]

            # give a decent initial guess for Ps

            print(i, self.prob['P'], self.prob['T'], self.prob['MN'])

            self.prob.run_model()

            # check outputs
            pt, ht, ps, ts = data[h_map['Fl_O.Pt']], data[h_map[
                'Fl_O.ht']], data[h_map['Fl_O.Ps']], data[h_map['Fl_O.Ts']]
            pt_computed = self.prob['duct.Fl_O:tot:P']
            ht_computed = self.prob['duct.Fl_O:tot:h']
            ps_computed = self.prob['duct.Fl_O:stat:P']
            ts_computed = self.prob['duct.Fl_O:stat:T']

            tol = 2.0e-2
            assert_rel_error(self, pt_computed, pt, tol)
            assert_rel_error(self, ht_computed, ht, tol)
            assert_rel_error(self, ps_computed, ps, tol)
            assert_rel_error(self, ts_computed, ts, tol)

            check_element_partials(self, self.prob)
예제 #24
0
    def setup(self):

        thermo_spec = species_data.janaf
        design = self.options['design']
        statics = self.options['statics']

        self.add_subsystem(
            'fc', FlightConditions(thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem(
            'inlet',
            Inlet(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem(
            'duct1',
            Duct(design=design,
                 thermo_data=thermo_spec,
                 elements=AIR_MIX,
                 statics=statics))
        self.add_subsystem('lpc',
                           Compressor(map_data=LPCmap,
                                      design=design,
                                      thermo_data=thermo_spec,
                                      elements=AIR_MIX,
                                      statics=statics),
                           promotes_inputs=[('Nmech', 'IP_Nmech')])
        self.add_subsystem(
            'icduct',
            Duct(design=design,
                 thermo_data=thermo_spec,
                 elements=AIR_MIX,
                 statics=statics))
        self.add_subsystem('hpc_axi',
                           Compressor(map_data=HPCmap,
                                      design=design,
                                      thermo_data=thermo_spec,
                                      elements=AIR_MIX,
                                      statics=statics),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])
        self.add_subsystem(
            'bld25',
            BleedOut(design=design,
                     statics=statics,
                     bleed_names=['cool1', 'cool2']))
        self.add_subsystem('hpc_centri',
                           Compressor(map_data=HPCmap,
                                      design=design,
                                      thermo_data=thermo_spec,
                                      elements=AIR_MIX,
                                      statics=statics),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])
        self.add_subsystem(
            'bld3',
            BleedOut(design=design,
                     statics=statics,
                     bleed_names=['cool3', 'cool4']))
        self.add_subsystem(
            'duct6',
            Duct(design=design,
                 thermo_data=thermo_spec,
                 elements=AIR_MIX,
                 statics=statics))
        self.add_subsystem(
            'burner',
            Combustor(design=design,
                      thermo_data=thermo_spec,
                      inflow_elements=AIR_MIX,
                      air_fuel_elements=AIR_FUEL_MIX,
                      fuel_type='Jet-A(g)',
                      statics=statics))
        self.add_subsystem('hpt',
                           Turbine(map_data=HPTmap,
                                   design=design,
                                   thermo_data=thermo_spec,
                                   elements=AIR_FUEL_MIX,
                                   bleed_names=['cool3', 'cool4'],
                                   statics=statics),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])
        self.add_subsystem(
            'duct43',
            Duct(design=design,
                 thermo_data=thermo_spec,
                 elements=AIR_FUEL_MIX,
                 statics=statics))
        self.add_subsystem('lpt',
                           Turbine(map_data=LPTmap,
                                   design=design,
                                   thermo_data=thermo_spec,
                                   elements=AIR_FUEL_MIX,
                                   bleed_names=['cool1', 'cool2'],
                                   statics=statics),
                           promotes_inputs=[('Nmech', 'IP_Nmech')])
        self.add_subsystem(
            'itduct',
            Duct(design=design,
                 thermo_data=thermo_spec,
                 elements=AIR_FUEL_MIX,
                 statics=statics))
        self.add_subsystem('pt',
                           Turbine(map_data=LPTmap,
                                   design=design,
                                   thermo_data=thermo_spec,
                                   elements=AIR_FUEL_MIX,
                                   statics=statics),
                           promotes_inputs=[('Nmech', 'LP_Nmech')])
        self.add_subsystem(
            'duct12',
            Duct(design=design,
                 thermo_data=thermo_spec,
                 elements=AIR_FUEL_MIX,
                 statics=statics))
        self.add_subsystem(
            'nozzle',
            Nozzle(nozzType='CV',
                   lossCoef='Cv',
                   thermo_data=thermo_spec,
                   elements=AIR_FUEL_MIX))

        self.add_subsystem('lp_shaft',
                           Shaft(num_ports=1),
                           promotes_inputs=[('Nmech', 'LP_Nmech')])
        self.add_subsystem('ip_shaft',
                           Shaft(num_ports=2),
                           promotes_inputs=[('Nmech', 'IP_Nmech')])
        self.add_subsystem('hp_shaft',
                           Shaft(num_ports=3),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])
        self.add_subsystem('perf', Performance(num_nozzles=1, num_burners=1))

        self.connect('duct1.Fl_O:tot:P', 'perf.Pt2')
        self.connect('hpc_centri.Fl_O:tot:P', 'perf.Pt3')
        self.connect('burner.Wfuel', 'perf.Wfuel_0')
        self.connect('inlet.F_ram', 'perf.ram_drag')
        self.connect('nozzle.Fg', 'perf.Fg_0')
        self.connect('lp_shaft.pwr_in', 'perf.power')

        self.connect('pt.trq', 'lp_shaft.trq_0')
        self.connect('lpc.trq', 'ip_shaft.trq_0')
        self.connect('lpt.trq', 'ip_shaft.trq_1')
        self.connect('hpc_axi.trq', 'hp_shaft.trq_0')
        self.connect('hpc_centri.trq', 'hp_shaft.trq_1')
        self.connect('hpt.trq', 'hp_shaft.trq_2')
        self.connect('fc.Fl_O:stat:P', 'nozzle.Ps_exhaust')

        balance = self.add_subsystem('balance', BalanceComp())
        if design:

            balance.add_balance('W', units='lbm/s', eq_units=None)
            self.connect('balance.W', 'inlet.Fl_I:stat:W')
            self.connect('nozzle.PR', 'balance.lhs:W')

            balance.add_balance('FAR', eq_units='degR', lower=1e-4, val=.017)
            self.connect('balance.FAR', 'burner.Fl_I:FAR')
            self.connect('burner.Fl_O:tot:T', 'balance.lhs:FAR')

            balance.add_balance('lpt_PR',
                                val=1.5,
                                lower=1.001,
                                upper=8,
                                eq_units='hp',
                                rhs_val=0.)
            self.connect('balance.lpt_PR', 'lpt.PR')
            self.connect('ip_shaft.pwr_net', 'balance.lhs:lpt_PR')

            balance.add_balance('hpt_PR',
                                val=1.5,
                                lower=1.001,
                                upper=8,
                                eq_units='hp',
                                rhs_val=0.)
            self.connect('balance.hpt_PR', 'hpt.PR')
            self.connect('hp_shaft.pwr_net', 'balance.lhs:hpt_PR')

            balance.add_balance('pt_PR',
                                val=1.5,
                                lower=1.001,
                                upper=8,
                                eq_units='hp',
                                rhs_val=0.)
            self.connect('balance.pt_PR', 'pt.PR')
            self.connect('lp_shaft.pwr_net', 'balance.lhs:pt_PR')

            # self.set_order(['fc', 'inlet', 'duct1', 'comp', 'burner', 'turb', 'ab', 'nozz', 'shaft', 'perf', 'thrust_balance', 'temp_balance', 'shaft_balance'])
            # self.set_order(['balance', 'fc', 'inlet', 'duct1', 'comp', 'burner', 'turb', 'ab', 'nozz', 'shaft', 'perf'])

        else:

            # Need to check all these balances once power turbine map is updated
            balance.add_balance('FAR', eq_units='lbf', lower=1e-4, val=.017)
            self.connect('balance.FAR', 'burner.Fl_I:FAR')
            self.connect('perf.Fn', 'balance.lhs:FAR')

            balance.add_balance('W', units='lbm/s', eq_units=None)
            self.connect('balance.W', 'inlet.Fl_I:stat:W')
            self.connect('nozzle.Throat:stat:area', 'balance.lhs:W')

            balance.add_balance('IP_Nmech',
                                val=12000.0,
                                units='rpm',
                                lower=1.001,
                                eq_units='hp',
                                rhs_val=0.)
            self.connect('balance.IP_Nmech', 'IP_Nmech')
            self.connect('ip_shaft.pwr_net', 'balance.lhs:IP_Nmech')

            balance.add_balance('HP_Nmech',
                                val=14800.0,
                                units='rpm',
                                lower=1.001,
                                eq_units='hp',
                                rhs_val=0.)
            self.connect('balance.HP_Nmech', 'HP_Nmech')
            self.connect('hp_shaft.pwr_net', 'balance.lhs:HP_Nmech')

            balance.add_balance('LP_Nmech',
                                val=1800.0,
                                units='rpm',
                                lower=1.001,
                                eq_units='hp',
                                rhs_val=0.)
            self.connect('balance.LP_Nmech', 'LP_Nmech')
            self.connect('lp_shaft.pwr_net', 'balance.lhs:LP_Nmech')

            # self.set_order(['balance', 'fc', 'inlet', 'fan', 'splitter', 'duct4', 'lpc', 'duct6', 'hpc', 'bld3', 'burner', 'hpt', 'duct11',
            #                 'lpt', 'duct13', 'nozzle', 'byp_bld', 'duct15', 'lp_shaft', 'ip_shaft', 'hp_shaft', 'perf'])

        if statics:
            connect_flow(self, 'fc.Fl_O', 'inlet.Fl_I', connect_w=False)
            connect_flow(self, 'inlet.Fl_O', 'duct1.Fl_I')
            connect_flow(self, 'duct1.Fl_O', 'lpc.Fl_I')
            connect_flow(self, 'lpc.Fl_O', 'icduct.Fl_I')
            connect_flow(self, 'icduct.Fl_O', 'hpc_axi.Fl_I')
            connect_flow(self, 'hpc_axi.Fl_O', 'bld25.Fl_I')
            connect_flow(self, 'bld25.Fl_O', 'hpc_centri.Fl_I')
            connect_flow(self, 'hpc_centri.Fl_O', 'bld3.Fl_I')
            connect_flow(self, 'bld3.Fl_O', 'duct6.Fl_I')
            connect_flow(self, 'duct6.Fl_O', 'burner.Fl_I')
            connect_flow(self, 'burner.Fl_O', 'hpt.Fl_I')
            connect_flow(self, 'hpt.Fl_O', 'duct43.Fl_I')
            connect_flow(self, 'duct43.Fl_O', 'lpt.Fl_I')
            connect_flow(self, 'lpt.Fl_O', 'itduct.Fl_I')
            connect_flow(self, 'itduct.Fl_O', 'pt.Fl_I')
            connect_flow(self, 'pt.Fl_O', 'duct12.Fl_I')
            connect_flow(self, 'duct12.Fl_O', 'nozzle.Fl_I')
        else:
            connect_flow(self, 'fc.Fl_O', 'inlet.Fl_I', connect_w=False)
            connect_flow(self, 'inlet.Fl_O', 'duct1.Fl_I', connect_stat=False)
            connect_flow(self, 'duct1.Fl_O', 'lpc.Fl_I', connect_stat=False)
            connect_flow(self, 'lpc.Fl_O', 'icduct.Fl_I', connect_stat=False)
            connect_flow(self,
                         'icduct.Fl_O',
                         'hpc_axi.Fl_I',
                         connect_stat=False)
            connect_flow(self,
                         'hpc_axi.Fl_O',
                         'bld25.Fl_I',
                         connect_stat=False)
            connect_flow(self,
                         'bld25.Fl_O',
                         'hpc_centri.Fl_I',
                         connect_stat=False)
            connect_flow(self,
                         'hpc_centri.Fl_O',
                         'bld3.Fl_I',
                         connect_stat=False)
            connect_flow(self, 'bld3.Fl_O', 'duct6.Fl_I', connect_stat=False)
            connect_flow(self, 'duct6.Fl_O', 'burner.Fl_I', connect_stat=False)
            connect_flow(self, 'burner.Fl_O', 'hpt.Fl_I', connect_stat=False)
            connect_flow(self, 'hpt.Fl_O', 'duct43.Fl_I', connect_stat=False)
            connect_flow(self, 'duct43.Fl_O', 'lpt.Fl_I', connect_stat=False)
            connect_flow(self, 'lpt.Fl_O', 'itduct.Fl_I', connect_stat=False)
            connect_flow(self, 'itduct.Fl_O', 'pt.Fl_I', connect_stat=False)
            connect_flow(self, 'pt.Fl_O', 'duct12.Fl_I', connect_stat=False)
            connect_flow(self,
                         'duct12.Fl_O',
                         'nozzle.Fl_I',
                         connect_stat=False)

        connect_flow(self, 'bld25.cool1', 'lpt.cool1', connect_stat=False)
        connect_flow(self, 'bld25.cool2', 'lpt.cool2', connect_stat=False)
        connect_flow(self, 'bld3.cool3', 'hpt.cool3', connect_stat=False)
        connect_flow(self, 'bld3.cool4', 'hpt.cool4', connect_stat=False)

        newton = self.nonlinear_solver = NewtonSolver()
        newton.options['atol'] = 1e-6
        newton.options['rtol'] = 1e-6
        newton.options['iprint'] = 2
        newton.options['maxiter'] = 10
        newton.options['solve_subsystems'] = True
        newton.options['max_sub_solves'] = 100
        newton.linesearch = BoundsEnforceLS()
        # newton.linesearch = ArmijoGoldsteinLS()
        # newton.linesearch.options['c'] = .0001
        newton.linesearch.options['bound_enforcement'] = 'scalar'
        newton.linesearch.options['iprint'] = -1

        self.linear_solver = DirectSolver(assemble_jac=True)
예제 #25
0
파일: CFM56.py 프로젝트: friedenhe/pyCycle
    def setup(self):

        thermo_spec = species_data.janaf
        design = self.options['design']
        statics = self.options['statics']

        self.add_subsystem('fc', FlightConditions(thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem('inlet', Inlet(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem('fan', Compressor(map_data=FanMap, design=design, thermo_data=thermo_spec, elements=AIR_MIX,
                                        bleed_names=[], statics=statics, map_extrap=True), promotes_inputs=[('Nmech','LP_Nmech')])
        self.add_subsystem('splitter', Splitter(design=design, thermo_data=thermo_spec, elements=AIR_MIX, statics=statics))
        self.add_subsystem('duct4', Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX, statics=statics))
        self.add_subsystem('lpc', Compressor(map_data=LPCmap, design=design, thermo_data=thermo_spec, elements=AIR_MIX,
                                        statics=statics, map_extrap=True),promotes_inputs=[('Nmech','LP_Nmech')])
        self.add_subsystem('duct6', Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX, statics=statics))
        self.add_subsystem('hpc', Compressor(map_data=HPCmap, design=design, thermo_data=thermo_spec, elements=AIR_MIX,
                                        bleed_names=['cool1','cool2','cust'], statics=statics, map_extrap=True),promotes_inputs=[('Nmech','HP_Nmech')])
        self.add_subsystem('bld3', BleedOut(design=design, statics=statics, bleed_names=['cool3','cool4']))
        self.add_subsystem('burner', Combustor(design=design,thermo_data=thermo_spec,
                                        inflow_elements=AIR_MIX,
                                        air_fuel_elements=AIR_FUEL_MIX,
                                        fuel_type='Jet-A(g)', statics=statics))
        self.add_subsystem('hpt', Turbine(map_data=HPTmap, design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX,
                                        bleed_names=['cool3','cool4'], statics=statics, map_extrap=True),promotes_inputs=[('Nmech','HP_Nmech')])
        self.add_subsystem('duct11', Duct(design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX, statics=statics))
        self.add_subsystem('lpt', Turbine(map_data=LPTmap, design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX,
                                        bleed_names=['cool1','cool2'], statics=statics, map_extrap=True),promotes_inputs=[('Nmech','LP_Nmech')])
        self.add_subsystem('duct13', Duct(design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX, statics=statics))
        self.add_subsystem('core_nozz', Nozzle(nozzType='CV', lossCoef='Cv', thermo_data=thermo_spec, elements=AIR_FUEL_MIX))

        self.add_subsystem('byp_bld', BleedOut(design=design, statics=statics, bleed_names=['bypBld']))
        self.add_subsystem('duct15', Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX, statics=statics))
        self.add_subsystem('byp_nozz', Nozzle(nozzType='CV', lossCoef='Cv', thermo_data=thermo_spec, elements=AIR_MIX))

        self.add_subsystem('lp_shaft', Shaft(num_ports=3),promotes_inputs=[('Nmech','LP_Nmech')])
        self.add_subsystem('hp_shaft', Shaft(num_ports=2),promotes_inputs=[('Nmech','HP_Nmech')])
        self.add_subsystem('perf', Performance(num_nozzles=2, num_burners=1))

        self.connect('inlet.Fl_O:tot:P', 'perf.Pt2')
        self.connect('hpc.Fl_O:tot:P', 'perf.Pt3')
        self.connect('burner.Wfuel', 'perf.Wfuel_0')
        self.connect('inlet.F_ram', 'perf.ram_drag')
        self.connect('core_nozz.Fg', 'perf.Fg_0')
        self.connect('byp_nozz.Fg', 'perf.Fg_1')

        self.connect('fan.trq', 'lp_shaft.trq_0')
        self.connect('lpc.trq', 'lp_shaft.trq_1')
        self.connect('lpt.trq', 'lp_shaft.trq_2')
        self.connect('hpc.trq', 'hp_shaft.trq_0')
        self.connect('hpt.trq', 'hp_shaft.trq_1')
        self.connect('fc.Fl_O:stat:P', 'core_nozz.Ps_exhaust')
        self.connect('fc.Fl_O:stat:P', 'byp_nozz.Ps_exhaust')

        balance = self.add_subsystem('balance', BalanceComp())
        if design:
            balance.add_balance('W', units='lbm/s', eq_units='lbf')
            self.connect('balance.W', 'inlet.Fl_I:stat:W')
            self.connect('perf.Fn', 'balance.lhs:W')

            balance.add_balance('FAR', eq_units='degR', lower=1e-4, val=.017)
            self.connect('balance.FAR', 'burner.Fl_I:FAR')
            self.connect('burner.Fl_O:tot:T', 'balance.lhs:FAR')

            balance.add_balance('lpt_PR', val=1.5, lower=1.001, upper=8, 
                                eq_units='hp', use_mult=True, mult_val=-1)
            self.connect('balance.lpt_PR', 'lpt.PR')
            self.connect('lp_shaft.pwr_in_real', 'balance.lhs:lpt_PR')
            self.connect('lp_shaft.pwr_out_real', 'balance.rhs:lpt_PR')

            balance.add_balance('hpt_PR', val=1.5, lower=1.001, upper=8, 
                                eq_units='hp', use_mult=True, mult_val=-1)
            self.connect('balance.hpt_PR', 'hpt.PR')
            self.connect('hp_shaft.pwr_in_real', 'balance.lhs:hpt_PR')
            self.connect('hp_shaft.pwr_out_real', 'balance.rhs:hpt_PR')

        else:

            balance.add_balance('FAR', val=0.017, lower=1e-4, eq_units='lbf')
            self.connect('balance.FAR', 'burner.Fl_I:FAR')
            self.connect('perf.Fn', 'balance.lhs:FAR')

            balance.add_balance('W', units='lbm/s', lower=10., upper=1000., eq_units='inch**2')
            self.connect('balance.W', 'inlet.Fl_I:stat:W')
            self.connect('core_nozz.Throat:stat:area', 'balance.lhs:W')

            balance.add_balance('BPR', lower=2., upper=10., eq_units='inch**2')
            self.connect('balance.BPR', 'splitter.BPR')
            self.connect('byp_nozz.Throat:stat:area', 'balance.lhs:BPR')

            balance.add_balance('lp_Nmech', val=1.5, units='rpm', lower=500., eq_units='hp', use_mult=True, mult_val=-1)
            self.connect('balance.lp_Nmech', 'LP_Nmech')
            self.connect('lp_shaft.pwr_in_real', 'balance.lhs:lp_Nmech')
            self.connect('lp_shaft.pwr_out_real', 'balance.rhs:lp_Nmech')

            balance.add_balance('hp_Nmech', val=1.5, units='rpm', lower=500., eq_units='hp', use_mult=True, mult_val=-1)
            self.connect('balance.hp_Nmech', 'HP_Nmech')
            self.connect('hp_shaft.pwr_in_real', 'balance.lhs:hp_Nmech')
            self.connect('hp_shaft.pwr_out_real', 'balance.rhs:hp_Nmech')

            self.set_order(['balance', 'fc', 'inlet', 'fan', 'splitter', 'duct4', 'lpc', 'duct6', 'hpc', 'bld3', 'burner', 'hpt', 'duct11',
                            'lpt', 'duct13', 'core_nozz', 'byp_bld', 'duct15', 'byp_nozz', 'lp_shaft', 'hp_shaft', 'perf'])

        connect_flow(self, 'fc.Fl_O', 'inlet.Fl_I', connect_w=False)
        connect_flow(self, 'inlet.Fl_O', 'fan.Fl_I')
        connect_flow(self, 'fan.Fl_O', 'splitter.Fl_I')
        connect_flow(self, 'splitter.Fl_O1', 'duct4.Fl_I')
        connect_flow(self, 'duct4.Fl_O', 'lpc.Fl_I')
        connect_flow(self, 'lpc.Fl_O', 'duct6.Fl_I')
        connect_flow(self, 'duct6.Fl_O', 'hpc.Fl_I')
        connect_flow(self, 'hpc.Fl_O', 'bld3.Fl_I')
        connect_flow(self, 'bld3.Fl_O', 'burner.Fl_I')
        connect_flow(self, 'burner.Fl_O', 'hpt.Fl_I')
        connect_flow(self, 'hpt.Fl_O', 'duct11.Fl_I')
        connect_flow(self, 'duct11.Fl_O', 'lpt.Fl_I')
        connect_flow(self, 'lpt.Fl_O', 'duct13.Fl_I')
        connect_flow(self, 'duct13.Fl_O','core_nozz.Fl_I')
        connect_flow(self, 'splitter.Fl_O2', 'byp_bld.Fl_I')
        connect_flow(self, 'byp_bld.Fl_O', 'duct15.Fl_I')
        connect_flow(self, 'duct15.Fl_O', 'byp_nozz.Fl_I')
       

        connect_flow(self, 'hpc.cool1', 'lpt.cool1', connect_stat=False)
        connect_flow(self, 'hpc.cool2', 'lpt.cool2', connect_stat=False)
        connect_flow(self, 'bld3.cool3', 'hpt.cool3', connect_stat=False)
        connect_flow(self, 'bld3.cool4', 'hpt.cool4', connect_stat=False)

        newton = self.nonlinear_solver = NewtonSolver()
        newton.options['atol'] = 1e-8
        newton.options['rtol'] = 1e-8
        newton.options['iprint'] = 2
        newton.options['maxiter'] = 50
        newton.options['solve_subsystems'] = True
        newton.options['max_sub_solves'] = 100

        
        # ls = newton.linesearch = BoundsEnforceLS()
        ls = newton.linesearch = ArmijoGoldsteinLS()
        ls.options['maxiter'] = 3
        ls.options['bound_enforcement'] = 'scalar'
        # ls.options['print_bound_enforce'] = True

        self.linear_solver = DirectSolver(assemble_jac=True)
예제 #26
0
    def setup(self):
        thermo_spec = species_data.janaf
        design = self.options['design']

        self.add_subsystem('fc', FlightConditions(thermo_data=thermo_spec, elements=AIR_MIX))
        # Inlet Components
        self.add_subsystem('inlet', Inlet(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem('inlet_duct', Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        # Fan Components - Split here for CFD integration Add a CFDStart Compomponent
        self.add_subsystem('fan', Compressor(map_data=AXI5, design=design, thermo_data=thermo_spec, elements=AIR_MIX,
                                             map_extrap=True),promotes_inputs=[('Nmech','LP_Nmech')])
        self.add_subsystem('splitter', Splitter(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        # Core Stream components
        self.add_subsystem('splitter_core_duct', Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem('lpc', Compressor(map_data=LPCmap, design=design, thermo_data=thermo_spec, elements=AIR_MIX,map_extrap=True),
                                             promotes_inputs=[('Nmech','LP_Nmech')])
        self.add_subsystem('lpc_duct', Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem('hpc', Compressor(map_data=HPCmap, design=design, thermo_data=thermo_spec, elements=AIR_MIX,
                                        bleed_names=['cool1'],map_extrap=True),promotes_inputs=[('Nmech','HP_Nmech')])
        self.add_subsystem('bld3', BleedOut(design=design, bleed_names=['cool3']))
        self.add_subsystem('burner', Combustor(design=design,thermo_data=thermo_spec,
                                                inflow_elements=AIR_MIX,
                                                air_fuel_elements=AIR_FUEL_MIX,
                                                fuel_type='Jet-A(g)'))
        self.add_subsystem('hpt', Turbine(map_data=HPTmap, design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX,
                                          bleed_names=['cool3'],map_extrap=True),promotes_inputs=[('Nmech','HP_Nmech')])
        self.add_subsystem('hpt_duct', Duct(design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX))
        self.add_subsystem('lpt', Turbine(map_data=LPTmap, design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX,
                                        bleed_names=['cool1'],map_extrap=True), promotes_inputs=[('Nmech','LP_Nmech')])
        self.add_subsystem('lpt_duct', Duct(design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX))
        # Bypass Components
        self.add_subsystem('bypass_duct', Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        # Mixer component
        self.add_subsystem('mixer', Mixer(design=design, designed_stream=1, Fl_I1_elements=AIR_FUEL_MIX, Fl_I2_elements=AIR_MIX))
        self.add_subsystem('mixer_duct', Duct(design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX))
        # Afterburner Components
        self.add_subsystem('afterburner', Combustor(design=design,thermo_data=thermo_spec,
                                                inflow_elements=AIR_FUEL_MIX,
                                                air_fuel_elements=AIR_FUEL_MIX,
                                                fuel_type='Jet-A(g)'))
        # End CFD HERE
        # Nozzle
        self.add_subsystem('mixed_nozz', Nozzle(nozzType='CD', lossCoef='Cfg', thermo_data=thermo_spec, elements=AIR_FUEL_MIX))

        # Mechanical components
        self.add_subsystem('lp_shaft', Shaft(num_ports=3),promotes_inputs=[('Nmech','LP_Nmech')])
        self.add_subsystem('hp_shaft', Shaft(num_ports=2),promotes_inputs=[('Nmech','HP_Nmech')])

        # Aggregating component
        self.add_subsystem('perf', Performance(num_nozzles=1, num_burners=2))

        # Connnect flow path
        connect_flow(self, 'fc.Fl_O', 'inlet.Fl_I')
        connect_flow(self, 'inlet.Fl_O', 'inlet_duct.Fl_I')
        connect_flow(self, 'inlet_duct.Fl_O', 'fan.Fl_I')
        connect_flow(self, 'fan.Fl_O', 'splitter.Fl_I')
        # Core connections
        connect_flow(self, 'splitter.Fl_O1', 'splitter_core_duct.Fl_I')
        connect_flow(self, 'splitter_core_duct.Fl_O', 'lpc.Fl_I')
        connect_flow(self, 'lpc.Fl_O', 'lpc_duct.Fl_I')
        connect_flow(self, 'lpc_duct.Fl_O', 'hpc.Fl_I')
        connect_flow(self, 'hpc.Fl_O', 'bld3.Fl_I')
        connect_flow(self, 'bld3.Fl_O', 'burner.Fl_I')
        connect_flow(self, 'burner.Fl_O', 'hpt.Fl_I')
        connect_flow(self, 'hpt.Fl_O', 'hpt_duct.Fl_I')
        connect_flow(self, 'hpt_duct.Fl_O', 'lpt.Fl_I')
        connect_flow(self, 'lpt.Fl_O', 'lpt_duct.Fl_I')
        connect_flow(self, 'lpt_duct.Fl_O','mixer.Fl_I1')
        # Bypass Connections
        connect_flow(self, 'splitter.Fl_O2', 'bypass_duct.Fl_I')
        connect_flow(self, 'bypass_duct.Fl_O', 'mixer.Fl_I2')

        #Mixer Connections
        connect_flow(self, 'mixer.Fl_O', 'mixer_duct.Fl_I')
        # After Burner
        connect_flow(self,'mixer_duct.Fl_O','afterburner.Fl_I')

        # Nozzle
        connect_flow(self,'afterburner.Fl_O','mixed_nozz.Fl_I')

        # Connect cooling flows
        connect_flow(self, 'hpc.cool1', 'lpt.cool1', connect_stat=False)
        connect_flow(self, 'bld3.cool3', 'hpt.cool3', connect_stat=False)

        # Make additional model connections
        self.connect('inlet.Fl_O:tot:P', 'perf.Pt2')
        self.connect('hpc.Fl_O:tot:P', 'perf.Pt3')
        self.connect('burner.Wfuel', 'perf.Wfuel_0')
        self.connect('afterburner.Wfuel', 'perf.Wfuel_1')
        self.connect('inlet.F_ram', 'perf.ram_drag')
        self.connect('mixed_nozz.Fg', 'perf.Fg_0')

        self.connect('fan.trq', 'lp_shaft.trq_0')
        self.connect('lpc.trq', 'lp_shaft.trq_1')
        self.connect('lpt.trq', 'lp_shaft.trq_2')
        self.connect('hpc.trq', 'hp_shaft.trq_0')
        self.connect('hpt.trq', 'hp_shaft.trq_1')
        self.connect('fc.Fl_O:stat:P', 'mixed_nozz.Ps_exhaust')

        # Add balence components to close the implicit components
        balance = self.add_subsystem('balance', BalanceComp())
        if design:
            balance.add_balance('W', lower=1e-3, upper=200., units='lbm/s', eq_units='lbf')
            self.connect('balance.W', 'fc.W')
            self.connect('perf.Fn', 'balance.lhs:W')
            # self.add_subsystem('wDV',IndepVarComp('wDes',100,units='lbm/s'))
            # self.connect('wDV.wDes','fc.W')

            balance.add_balance('BPR', eq_units=None, lower=0.25, val=5.0)
            self.connect('balance.BPR', 'splitter.BPR')
            self.connect('mixer.ER', 'balance.lhs:BPR')

            balance.add_balance('FAR_core', eq_units='degR', lower=1e-4, val=.017)
            self.connect('balance.FAR_core', 'burner.Fl_I:FAR')
            self.connect('burner.Fl_O:tot:T', 'balance.lhs:FAR_core')

            balance.add_balance('FAR_ab', eq_units='degR', lower=1e-4, val=.017)
            self.connect('balance.FAR_ab', 'afterburner.Fl_I:FAR')
            self.connect('afterburner.Fl_O:tot:T', 'balance.lhs:FAR_ab')

            balance.add_balance('lpt_PR', val=1.5, lower=1.001, upper=8, eq_units='hp', use_mult=True, mult_val=-1)
            self.connect('balance.lpt_PR', 'lpt.PR')
            self.connect('lp_shaft.pwr_in', 'balance.lhs:lpt_PR')
            self.connect('lp_shaft.pwr_out', 'balance.rhs:lpt_PR')

            balance.add_balance('hpt_PR', val=1.5, lower=1.001, upper=8, eq_units='hp', use_mult=True, mult_val=-1)
            self.connect('balance.hpt_PR', 'hpt.PR')
            self.connect('hp_shaft.pwr_in', 'balance.lhs:hpt_PR')
            self.connect('hp_shaft.pwr_out', 'balance.rhs:hpt_PR')
        else:

            balance.add_balance('W', lower=1e-3, upper=200., units='lbm/s', eq_units='inch**2')
            self.connect('balance.W', 'fc.W')
            self.connect('mixed_nozz.Throat:stat:area', 'balance.lhs:W')

            balance.add_balance('BPR', lower=0.25, upper=5.0, eq_units='psi')
            self.connect('balance.BPR', 'splitter.BPR')
            self.connect('mixer.Fl_I1_calc:stat:P', 'balance.lhs:BPR')
            self.connect('bypass_duct.Fl_O:stat:P', 'balance.rhs:BPR')

            balance.add_balance('FAR_core', eq_units='degR', lower=1e-4, upper=.06, val=.017)
            self.connect('balance.FAR_core', 'burner.Fl_I:FAR')
            self.connect('burner.Fl_O:tot:T', 'balance.lhs:FAR_core')

            balance.add_balance('FAR_ab', eq_units='degR', lower=1e-4, upper=.06, val=.017)
            self.connect('balance.FAR_ab', 'afterburner.Fl_I:FAR')
            self.connect('afterburner.Fl_O:tot:T', 'balance.lhs:FAR_ab')

            balance.add_balance('LP_Nmech', val=1., units='rpm', lower=500., eq_units='hp', use_mult=True, mult_val=-1)
            self.connect('balance.LP_Nmech', 'LP_Nmech')
            self.connect('lp_shaft.pwr_in', 'balance.lhs:LP_Nmech')
            self.connect('lp_shaft.pwr_out', 'balance.rhs:LP_Nmech')

            balance.add_balance('HP_Nmech', val=1., units='rpm', lower=500., eq_units='hp', use_mult=True, mult_val=-1)
            self.connect('balance.HP_Nmech', 'HP_Nmech')
            self.connect('hp_shaft.pwr_in', 'balance.lhs:HP_Nmech')
            self.connect('hp_shaft.pwr_out', 'balance.rhs:HP_Nmech')

        # Off design
        newton = self.nonlinear_solver = NewtonSolver()
        newton.options['atol'] = 1e-6
        newton.options['rtol'] = 1e-10
        newton.options['iprint'] = 2
        newton.options['maxiter'] = 10
        newton.options['solve_subsystems'] = True
        newton.options['max_sub_solves'] = 100
        newton.linesearch = BoundsEnforceLS()
        newton.linesearch.options['bound_enforcement'] = 'scalar'
        newton.linesearch.options['iprint'] = -1


        self.linear_solver = DirectSolver(assemble_jac=True)
예제 #27
0
파일: J79.py 프로젝트: friedenhe/pyCycle
    def setup(self):

        thermo_spec = species_data.janaf
        design = self.options['design']
        statics = self.options['statics']

        self.add_subsystem('fc', FlightConditions(thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem('inlet', Inlet(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem('duct1', Duct(design=design, thermo_data=thermo_spec, elements=AIR_MIX, statics=statics))
        self.add_subsystem('comp', Compressor(map_data=AXI5, design=design, thermo_data=thermo_spec, elements=AIR_MIX,
                                        bleed_names=['cool1','cool2'], statics=statics, map_extrap=True),promotes_inputs=['Nmech'])
        self.add_subsystem('burner', Combustor(design=design,thermo_data=thermo_spec,
                                        inflow_elements=AIR_MIX,
                                        air_fuel_elements=AIR_FUEL_MIX,
                                        fuel_type='JP-7', statics=statics))
        self.add_subsystem('turb', Turbine(map_data=LPT2269, design=design, thermo_data=thermo_spec, elements=AIR_FUEL_MIX,
                                        bleed_names=['cool1','cool2'], statics=statics, map_extrap=True),promotes_inputs=['Nmech'])
        self.add_subsystem('ab', Combustor(design=design,thermo_data=thermo_spec,
                                        inflow_elements=AIR_FUEL_MIX,
                                        air_fuel_elements=AIR_FUEL_MIX,
                                        fuel_type='JP-7', statics=statics))
        self.add_subsystem('nozz', Nozzle(nozzType='CD', lossCoef='Cv', thermo_data=thermo_spec, elements=AIR_FUEL_MIX, internal_solver=True))
        self.add_subsystem('shaft', Shaft(num_ports=2),promotes_inputs=['Nmech'])
        self.add_subsystem('perf', Performance(num_nozzles=1, num_burners=2))

        self.connect('duct1.Fl_O:tot:P', 'perf.Pt2')
        self.connect('comp.Fl_O:tot:P', 'perf.Pt3')
        self.connect('burner.Wfuel', 'perf.Wfuel_0')
        self.connect('ab.Wfuel', 'perf.Wfuel_1')
        self.connect('inlet.F_ram', 'perf.ram_drag')
        self.connect('nozz.Fg', 'perf.Fg_0')

        self.connect('comp.trq', 'shaft.trq_0')
        self.connect('turb.trq', 'shaft.trq_1')
        # self.connect('shaft.Nmech', 'comp.Nmech')
        # self.connect('shaft.Nmech', 'turb.Nmech')
        self.connect('fc.Fl_O:stat:P', 'nozz.Ps_exhaust')

        balance = self.add_subsystem('balance', BalanceComp())
        if design:

            balance.add_balance('W', units='lbm/s', eq_units='lbf')
            self.connect('balance.W', 'inlet.Fl_I:stat:W')
            self.connect('perf.Fn', 'balance.lhs:W')

            balance.add_balance('FAR', eq_units='degR', lower=1e-4, val=.017)
            self.connect('balance.FAR', 'burner.Fl_I:FAR')
            self.connect('burner.Fl_O:tot:T', 'balance.lhs:FAR')

            balance.add_balance('turb_PR', val=1.5, lower=1.001, upper=8, eq_units='hp', rhs_val=0.)
            self.connect('balance.turb_PR', 'turb.PR')
            self.connect('shaft.pwr_net', 'balance.lhs:turb_PR')

            # self.set_order(['fc', 'inlet', 'duct1', 'comp', 'burner', 'turb', 'ab', 'nozz', 'shaft', 'perf', 'thrust_balance', 'temp_balance', 'shaft_balance'])
            self.set_order(['balance', 'fc', 'inlet', 'duct1', 'comp', 'burner', 'turb', 'ab', 'nozz', 'shaft', 'perf'])

        else:

            balance.add_balance('FAR', eq_units='degR', lower=1e-4, val=.017)
            self.connect('balance.FAR', 'burner.Fl_I:FAR')
            self.connect('burner.Fl_O:tot:T', 'balance.lhs:FAR')

            balance.add_balance('Nmech', val=8000., units='rpm', lower=500., eq_units='hp', rhs_val=0.)
            self.connect('balance.Nmech', 'Nmech')
            self.connect('shaft.pwr_net', 'balance.lhs:Nmech')

            balance.add_balance('W', val=100.0, units='lbm/s', eq_units=None, rhs_val=2.0)
            self.connect('balance.W', 'inlet.Fl_I:stat:W')
            self.connect('comp.map.RlineMap', 'balance.lhs:W')

            self.set_order(['balance', 'fc', 'inlet', 'duct1', 'comp', 'burner', 'turb', 'ab', 'nozz', 'shaft', 'perf'])

        if statics:
            connect_flow(self, 'fc.Fl_O', 'inlet.Fl_I', connect_w=False)
            connect_flow(self, 'inlet.Fl_O', 'duct1.Fl_I')
            connect_flow(self, 'duct1.Fl_O', 'comp.Fl_I')
            connect_flow(self, 'comp.Fl_O', 'burner.Fl_I')
            connect_flow(self, 'burner.Fl_O', 'turb.Fl_I')
            connect_flow(self, 'turb.Fl_O', 'ab.Fl_I')
            connect_flow(self, 'ab.Fl_O', 'nozz.Fl_I')
        else:
            connect_flow(self, 'fc.Fl_O', 'inlet.Fl_I', connect_w=False)
            connect_flow(self, 'inlet.Fl_O', 'duct1.Fl_I', connect_stat=False)
            connect_flow(self, 'duct1.Fl_O', 'comp.Fl_I', connect_stat=False)
            connect_flow(self, 'comp.Fl_O', 'burner.Fl_I', connect_stat=False)
            connect_flow(self, 'burner.Fl_O', 'turb.Fl_I', connect_stat=False)
            connect_flow(self, 'turb.Fl_O', 'ab.Fl_I', connect_stat=False)
            connect_flow(self, 'ab.Fl_O', 'nozz.Fl_I', connect_stat=False)

        connect_flow(self, 'comp.cool1', 'turb.cool1', connect_stat=False)
        connect_flow(self, 'comp.cool2', 'turb.cool2', connect_stat=False)

        newton = self.nonlinear_solver = NewtonSolver()
        newton.options['atol'] = 1e-6
        newton.options['rtol'] = 1e-6
        newton.options['iprint'] = 2
        newton.options['maxiter'] = 15
        newton.options['solve_subsystems'] = True
        newton.options['max_sub_solves'] = 100
        # newton.linesearch = BoundsEnforceLS()
        newton.linesearch = ArmijoGoldsteinLS()
        # newton.linesearch.options['c'] = .0001
        newton.linesearch.options['bound_enforcement'] = 'scalar'
        newton.linesearch.options['iprint'] = -1

        self.linear_solver = DirectSolver(assemble_jac=True)
예제 #28
0
    def setup(self):

        thermo_spec = species_data.janaf
        design = self.options['design']

        # Add engine elements
        self.add_subsystem(
            'fc', FlightConditions(thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem(
            'inlet',
            Inlet(design=design, thermo_data=thermo_spec, elements=AIR_MIX))
        self.add_subsystem('comp',
                           Compressor(
                               map_data=AXI5,
                               design=design,
                               thermo_data=thermo_spec,
                               elements=AIR_MIX,
                           ),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])
        self.add_subsystem(
            'burner',
            Combustor(design=design,
                      thermo_data=thermo_spec,
                      inflow_elements=AIR_MIX,
                      air_fuel_elements=AIR_FUEL_MIX,
                      fuel_type='JP-7'))
        self.add_subsystem('turb',
                           Turbine(
                               map_data=LPT2269,
                               design=design,
                               thermo_data=thermo_spec,
                               elements=AIR_FUEL_MIX,
                           ),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])
        self.add_subsystem('pt',
                           Turbine(
                               map_data=LPT2269,
                               design=design,
                               thermo_data=thermo_spec,
                               elements=AIR_FUEL_MIX,
                           ),
                           promotes_inputs=[('Nmech', 'LP_Nmech')])
        self.add_subsystem(
            'nozz',
            Nozzle(nozzType='CV',
                   lossCoef='Cv',
                   thermo_data=thermo_spec,
                   elements=AIR_FUEL_MIX))
        self.add_subsystem('HP_shaft',
                           Shaft(num_ports=2),
                           promotes_inputs=[('Nmech', 'HP_Nmech')])
        self.add_subsystem('LP_shaft',
                           Shaft(num_ports=1),
                           promotes_inputs=[('Nmech', 'LP_Nmech')])
        self.add_subsystem('perf', Performance(num_nozzles=1, num_burners=1))

        # Connect flow stations
        connect_flow(self, 'fc.Fl_O', 'inlet.Fl_I', connect_w=False)
        connect_flow(self, 'inlet.Fl_O', 'comp.Fl_I')
        connect_flow(self, 'comp.Fl_O', 'burner.Fl_I')
        connect_flow(self, 'burner.Fl_O', 'turb.Fl_I')
        connect_flow(self, 'turb.Fl_O', 'pt.Fl_I')
        connect_flow(self, 'pt.Fl_O', 'nozz.Fl_I')

        # Connect turbomachinery elements to shaft
        self.connect('comp.trq', 'HP_shaft.trq_0')
        self.connect('turb.trq', 'HP_shaft.trq_1')
        self.connect('pt.trq', 'LP_shaft.trq_0')

        # Connnect nozzle exhaust to freestream static conditions
        self.connect('fc.Fl_O:stat:P', 'nozz.Ps_exhaust')

        # Connect outputs to pefromance element
        self.connect('inlet.Fl_O:tot:P', 'perf.Pt2')
        self.connect('comp.Fl_O:tot:P', 'perf.Pt3')
        self.connect('burner.Wfuel', 'perf.Wfuel_0')
        self.connect('inlet.F_ram', 'perf.ram_drag')
        self.connect('nozz.Fg', 'perf.Fg_0')
        self.connect('LP_shaft.pwr_net', 'perf.power')

        # Add balances for design and off-design
        balance = self.add_subsystem('balance', BalanceComp())
        if design:

            balance.add_balance('W', val=27.0, units='lbm/s', eq_units=None)
            self.connect('balance.W', 'inlet.Fl_I:stat:W')
            self.connect('nozz.PR', 'balance.lhs:W')

            balance.add_balance('FAR', eq_units='degR', lower=1e-4, val=.017)
            self.connect('balance.FAR', 'burner.Fl_I:FAR')
            self.connect('burner.Fl_O:tot:T', 'balance.lhs:FAR')

            balance.add_balance('turb_PR',
                                val=3.0,
                                lower=1.001,
                                upper=8,
                                eq_units='hp',
                                rhs_val=0.)
            self.connect('balance.turb_PR', 'turb.PR')
            self.connect('HP_shaft.pwr_net', 'balance.lhs:turb_PR')

            balance.add_balance('pt_PR',
                                val=3.0,
                                lower=1.001,
                                upper=8,
                                eq_units='hp')
            self.connect('balance.pt_PR', 'pt.PR')
            self.connect('LP_shaft.pwr_net', 'balance.lhs:pt_PR')

        else:

            balance.add_balance('FAR', eq_units='hp', lower=1e-4, val=.3)
            self.connect('balance.FAR', 'burner.Fl_I:FAR')
            self.connect('LP_shaft.pwr_net', 'balance.lhs:FAR')

            balance.add_balance('HP_Nmech',
                                val=1.5,
                                units='rpm',
                                lower=500.,
                                eq_units='hp',
                                rhs_val=0.)
            self.connect('balance.HP_Nmech', 'HP_Nmech')
            self.connect('HP_shaft.pwr_net', 'balance.lhs:HP_Nmech')

            balance.add_balance('W',
                                val=27.0,
                                units='lbm/s',
                                eq_units='inch**2')
            self.connect('balance.W', 'inlet.Fl_I:stat:W')
            self.connect('nozz.Throat:stat:area', 'balance.lhs:W')

        # Setup solver to converge engine
        self.set_order([
            'balance', 'fc', 'inlet', 'comp', 'burner', 'turb', 'pt', 'nozz',
            'HP_shaft', 'LP_shaft', 'perf'
        ])

        newton = self.nonlinear_solver = NewtonSolver()
        newton.options['atol'] = 1e-6
        newton.options['rtol'] = 1e-6
        newton.options['iprint'] = 2
        newton.options['maxiter'] = 15
        newton.options['solve_subsystems'] = True
        newton.options['max_sub_solves'] = 100
        newton.linesearch = BoundsEnforceLS()
        # newton.linesearch = ArmijoGoldsteinLS()
        # newton.linesearch.options['c'] = .0001
        newton.linesearch.options['bound_enforcement'] = 'scalar'
        newton.linesearch.options['iprint'] = -1

        self.linear_solver = DirectSolver(assemble_jac=True)
예제 #29
0
    def test_case_with_dPqP_MN(self):

        thermo = Thermo(janaf, constants.AIR_MIX)

        self.prob = Problem()
        self.prob.model = Group()
        self.prob.model.add_subsystem('flow_start',
                                      FlowStart(thermo_data=janaf,
                                                elements=AIR_MIX),
                                      promotes=['P', 'T', 'MN', 'W'])
        self.prob.model.add_subsystem('flow_start_OD',
                                      FlowStart(thermo_data=janaf,
                                                elements=AIR_MIX),
                                      promotes=['P', 'T', 'W'])

        expMN = 1.0
        self.prob.model.add_subsystem('duct_des',
                                      Duct(elements=AIR_MIX, expMN=expMN),
                                      promotes=['MN'])
        self.prob.model.add_subsystem(
            'duct_OD', Duct(elements=AIR_MIX, expMN=expMN, design=False))

        connect_flow(self.prob.model, 'flow_start.Fl_O', 'duct_des.Fl_I')
        connect_flow(self.prob.model, 'flow_start_OD.Fl_O', 'duct_OD.Fl_I')

        self.prob.model.set_input_defaults('P', 17., units='psi')
        self.prob.model.set_input_defaults('T', 500., units='degR')
        self.prob.model.set_input_defaults('MN', 0.5)
        self.prob.model.set_input_defaults('flow_start_OD.MN', 0.25)
        self.prob.model.set_input_defaults('duct_des.dPqP', 0.0)
        self.prob.model.set_input_defaults('W', 500., units='lbm/s')

        self.prob.model.connect("duct_des.s_dPqP", "duct_OD.s_dPqP")
        self.prob.model.connect("duct_des.Fl_O:stat:area", "duct_OD.area")

        self.prob.setup(check=False)
        self.prob.set_solver_print(level=-1)

        data = ref_data[0]
        self.prob['duct_des.dPqP'] = data[h_map['dPqP']]

        # input flowstation
        self.prob['P'] = data[h_map['Fl_I.Pt']]
        self.prob['T'] = data[h_map['Fl_I.Tt']]
        self.prob['MN'] = data[h_map['Fl_O.MN']]
        self.prob['W'] = data[h_map['Fl_I.W']]
        self.prob['duct_des.Fl_I:stat:V'] = data[h_map['Fl_I.V']]

        # give a decent initial guess for Ps

        print(self.prob['P'], self.prob['T'], self.prob['MN'])

        self.prob.run_model()

        # check outputs
        pt, ht, ps, ts = data[h_map['Fl_O.Pt']], data[h_map['Fl_O.ht']], data[
            h_map['Fl_O.Ps']], data[h_map['Fl_O.Ts']]
        pt_computed = self.prob['duct_OD.Fl_O:tot:P']
        ht_computed = self.prob['duct_OD.Fl_O:tot:h']
        ps_computed = self.prob['duct_OD.Fl_O:stat:P']
        ts_computed = self.prob['duct_OD.Fl_O:stat:T']

        tol = 1.0e-4
        assert_near_equal(pt_computed, 8.84073152, tol)
        assert_near_equal(ht_computed, ht, tol)
        assert_near_equal(ps_computed, 8.26348914, tol)
        assert_near_equal(ts_computed, ts, tol)

        check_element_partials(self, self.prob)
예제 #30
0
    dv.add_output('frac_P', 0.5),

    prob.model.add_subsystem(
        'flow_start',
        FlowStart(thermo_data=species_data.janaf, elements=AIR_MIX))
    prob.model.add_subsystem(
        'bld_start', FlowStart(thermo_data=species_data.janaf,
                               elements=AIR_MIX))
    prob.model.add_subsystem(
        'turbine',
        Turbine(map_data=LPT2269,
                design=True,
                elements=AIR_MIX,
                bleed_names=['bld1']))

    connect_flow(prob.model, 'flow_start.Fl_O', 'turbine.Fl_I')
    connect_flow(prob.model,
                 'bld_start.Fl_O',
                 'turbine.bld1',
                 connect_stat=False)

    prob.model.connect("P", "flow_start.P")
    prob.model.connect("T", "flow_start.T")
    prob.model.connect("W", "flow_start.W")
    prob.model.connect("P_bld", "bld_start.P")
    prob.model.connect("T_bld", "bld_start.T")
    prob.model.connect("W_bld", "bld_start.W")
    prob.model.connect("PR", "turbine.PR")
    prob.model.connect('eff', 'turbine.eff')
    prob.model.connect("frac_P", "turbine.bld1:frac_P")