Beispiel #1
0
    def test_temperature_comp(self):
        n = reference.shape[0]

        p = Problem(model=Group())

        ivc = p.model.add_subsystem('ivc', subsys=IndepVarComp(), promotes_outputs=['*'])
        ivc.add_output(name='alt_m', val=reference[:, 0], units='m')

        p.model.add_subsystem('atmos', subsys=USatm1976Comp(num_nodes=n))
        p.model.connect('alt_m', 'atmos.h')

        p.setup()
        p.run_model()

        var_map = ['alt_m', 'atmos.temp', 'atmos.pres', 'atmos.rho', 'atmos.sos']
        var_unit_map = ['m', 'K', 'Pa', 'kg/m**3', 'm/s']

        for i in range(1, 5):
            if SHOW_PLOTS:
                # print('i', i, var_map[i], var_unit_map[i])
                plt.plot(p['alt_m'], p.get_val(var_map[i], units=var_unit_map[i]))
                plt.title(var_map[i])
                plt.plot(reference[:, 0], reference[:, i], 'ro')
                plt.show()

        assert_rel_error(self, p.get_val('atmos.temp', units='K'),
                         reference[:, 1], tolerance=1.0E-2)
        assert_rel_error(self, p.get_val('atmos.pres', units='Pa'),
                         reference[:, 2], tolerance=1.0E-2)
        assert_rel_error(self, p.get_val('atmos.rho', units='kg/m**3'),
                         reference[:, 3], tolerance=1.0E-2)
        assert_rel_error(self, p.get_val('atmos.sos', units='m/s'),
                         reference[:, 4], tolerance=1.0E-2)
Beispiel #2
0
    def test_temperature_comp(self):
        n = reference.shape[0]

        p = om.Problem(model=om.Group())

        ivc = p.model.add_subsystem('ivc',
                                    subsys=om.IndepVarComp(),
                                    promotes_outputs=['*'])
        ivc.add_output(name='alt_m', val=reference[:, 0], units='m')

        p.model.add_subsystem('atmos', subsys=USatm1976Comp(num_nodes=n))
        p.model.connect('alt_m', 'atmos.h')

        p.setup()
        p.run_model()

        assert_rel_error(self,
                         p.get_val('atmos.temp', units='K'),
                         reference[:, 1],
                         tolerance=1.0E-2)
        assert_rel_error(self,
                         p.get_val('atmos.pres', units='Pa'),
                         reference[:, 2],
                         tolerance=1.0E-2)
        assert_rel_error(self,
                         p.get_val('atmos.rho', units='kg/m**3'),
                         reference[:, 3],
                         tolerance=1.0E-2)
        assert_rel_error(self,
                         p.get_val('atmos.sos', units='m/s'),
                         reference[:, 4],
                         tolerance=1.0E-2)
Beispiel #3
0
    def test_temperature_comp(self):
        n = reference.shape[0]

        p = om.Problem(model=om.Group())

        ivc = p.model.add_subsystem('ivc', subsys=om.IndepVarComp(), promotes_outputs=['*'])
        ivc.add_output(name='alt_m', val=reference[:, 0], units='m')

        p.model.add_subsystem('atmos', subsys=USatm1976Comp(num_nodes=n))
        p.model.connect('alt_m', 'atmos.h')

        p.setup(force_alloc_complex=True)
        p.run_model()

        assert_near_equal(p.get_val('atmos.temp', units='K'),
                          reference[:, 1], tolerance=1.0E-2)
        assert_near_equal(p.get_val('atmos.pres', units='Pa'),
                          reference[:, 2], tolerance=1.0E-2)
        assert_near_equal(p.get_val('atmos.rho', units='kg/m**3'),
                          reference[:, 3], tolerance=1.0E-2)
        assert_near_equal(p.get_val('atmos.sos', units='m/s'),
                          reference[:, 4], tolerance=1.0E-2)

        cpd = p.check_partials(method='cs', out_stream=None)
        assert_check_partials(cpd)
Beispiel #4
0
    def test_temperature_comp(self):
        n = USatm1976Data.alt.size

        p = om.Problem(model=om.Group())

        ivc = p.model.add_subsystem('ivc', subsys=om.IndepVarComp(), promotes_outputs=['*'])
        ivc.add_output(name='alt', val=USatm1976Data.alt, units='ft')

        p.model.add_subsystem('atmos', subsys=USatm1976Comp(num_nodes=n))
        p.model.connect('alt', 'atmos.h')

        p.setup(force_alloc_complex=True)
        p.run_model()

        T = p.get_val('atmos.temp', units='degR')
        P = p.get_val('atmos.pres', units='psi')
        rho = p.get_val('atmos.rho', units='slug/ft**3')
        sos = p.get_val('atmos.sos', units='ft/s')

        assert_near_equal(T, USatm1976Data.T, tolerance=1.0E-2)
        assert_near_equal(P, USatm1976Data.P, tolerance=1.0E-2)
        assert_near_equal(rho, USatm1976Data.rho, tolerance=1.0E-2)
        assert_near_equal(sos, USatm1976Data.a, tolerance=1.0E-2)

        cpd = p.check_partials(method='cs', out_stream=None)
        assert_check_partials(cpd)
Beispiel #5
0
    def test_atmos_comp_geodetic(self):
        n = USatm1976Data.alt.size

        p = om.Problem(model=om.Group())

        ivc = p.model.add_subsystem('ivc', subsys=om.IndepVarComp(), promotes_outputs=['*'])
        ivc.add_output(name='alt', val=USatm1976Data.alt, units='ft')

        p.model.add_subsystem('atmos', subsys=USatm1976Comp(num_nodes=n, h_def='geodetic'))
        p.model.connect('alt', 'atmos.h')

        p.setup(force_alloc_complex=True)

        h = USatm1976Data.alt * 0.3048  # altitude data in meters
        R0 = 6_356_766  # US 1976 std atm R0 in m
        p.set_val('alt', R0 / (R0 - h) * h, units='m')  # US 1976 std atm geopotential altitude to geodetic (m)

        p.run_model()

        T = p.get_val('atmos.temp', units='degR')
        P = p.get_val('atmos.pres', units='psi')
        rho = p.get_val('atmos.rho', units='slug/ft**3')
        sos = p.get_val('atmos.sos', units='ft/s')

        assert_near_equal(T, USatm1976Data.T, tolerance=1.0E-4)
        assert_near_equal(P, USatm1976Data.P, tolerance=1.0E-4)
        assert_near_equal(rho, USatm1976Data.rho, tolerance=1.0E-4)
        assert_near_equal(sos, USatm1976Data.a, tolerance=1.0E-4)

        with np.printoptions(linewidth=100000):
            cpd = p.check_partials(method='cs')
        assert_check_partials(cpd)