Пример #1
0
    def test_cube(self):
        logging.debug("")
        logging.debug("test_cube")

        cube = create_cube((30, 20, 10), 5.0, 4.0, 3.0)

        # I face.
        surfaces = (("xyzzy", 2, 2, 0, -1, 0, -1),)
        variables = (("area", "inch**2"),)
        metrics = surface_probe(cube, surfaces, variables)
        area = metrics[0]
        logging.debug("area = %g (%g ft)", area, area / 144.0)
        self.assertEqual(area, 4.0 * 3.0 * 144.0)

        # J face.
        surfaces = (("xyzzy", 0, -1, 2, 2, 0, -1),)
        variables = (("area", "inch**2"),)
        metrics = surface_probe(cube, surfaces, variables)
        area = metrics[0]
        logging.debug("area = %g (%g ft)", area, area / 144.0)
        self.assertEqual(area, 5.0 * 3.0 * 144.0)

        # K face.
        surfaces = (("xyzzy", 0, -1, 0, -1, 2, 2),)
        variables = (("area", "inch**2"),)
        metrics = surface_probe(cube, surfaces, variables)
        area = metrics[0]
        logging.debug("area = %g (%g ft)", area, area / 144.0)
        self.assertEqual(area, 5.0 * 4.0 * 144.0)
Пример #2
0
    def test_adpac(self):
        # Verify correct metric values for data from real scenario.
        logging.debug("")
        logging.debug("test_adpac")

        domain = restart.read("lpc-test", logging.getLogger())
        surfaces = [("zone_1", 2, 2, 0, -1, 0, -1), ("zone_2", 2, 2, 0, -1, 0, -1)]
        variables = [
            ("area", "inch**2"),
            ("pressure_stagnation", "psi"),
            ("pressure", "psi"),
            ("temperature_stagnation", "degR"),
            ("temperature", "degR"),
            ("mass_flow", "lbm/s"),
            ("corrected_mass_flow", "lbm/s"),
        ]
        metrics = surface_probe(domain, surfaces, variables, "mass")
        logging.debug("lpc-test I face data:")
        for i, (name, units) in enumerate(variables):
            logging.debug("    %s = %g %s" % (name, metrics[i], units))

        # These values have been verified with ADSPIN.
        assert_rel_error(self, metrics[0], 830.494, 0.00001)
        assert_rel_error(self, metrics[1], 8.95658, 0.00001)
        assert_rel_error(self, metrics[2], 6.97191, 0.00001)
        assert_rel_error(self, metrics[3], 547.784, 0.00001)
        assert_rel_error(self, metrics[4], 509.909, 0.00001)
        assert_rel_error(self, metrics[5], 120.092, 0.00001)
        assert_rel_error(self, metrics[6], 202.573, 0.00001)

        surfaces = [("zone_1", 0, -1, 2, 2, 0, -1)]
        metrics = surface_probe(domain, surfaces, variables, "mass")
        logging.debug("lpc-test J face data:")
        for i, (name, units) in enumerate(variables):
            logging.debug("    %s = %g %s" % (name, metrics[i], units))

        assert_rel_error(self, metrics[0], 1089.77, 0.00001)
        assert_rel_error(self, metrics[1], 7.08859, 0.00001)
        assert_rel_error(self, metrics[2], 6.52045, 0.00001)
        assert_rel_error(self, metrics[3], 553.772, 0.00001)
        assert_rel_error(self, metrics[4], 540.711, 0.00001)
        assert_rel_error(self, metrics[5], 0.421583, 0.00001)
        assert_rel_error(self, metrics[6], 0.903318, 0.00001)

        surfaces = [("zone_1", 0, -1, 0, -1, 2, 2)]
        metrics = surface_probe(domain, surfaces, variables, "mass")
        logging.debug("lpc-test K face data:")
        for i, (name, units) in enumerate(variables):
            logging.debug("    %s = %g %s" % (name, metrics[i], units))

        assert_rel_error(self, metrics[0], 2870.64, 0.00001)
        assert_rel_error(self, metrics[1], 8.69595, 0.00001)
        assert_rel_error(self, metrics[2], 6.89906, 0.00001)
        assert_rel_error(self, metrics[3], 546.863, 0.00001)
        assert_rel_error(self, metrics[4], 511.839, 0.00001)
        assert_rel_error(self, metrics[5], -156.175, 0.00001)
        assert_rel_error(self, metrics[6], -271.477, 0.00001)
Пример #3
0
    def test_wedge(self):
        logging.debug("")
        logging.debug("test_wedge")

        wedge = create_wedge_3d((30, 20, 100), 5.0, 0.5, 2.0, 30.0)

        # I face.
        surfaces = (("xyzzy", 2, 2, 0, -1, 0, -1),)
        variables = (("area", "inch**2"),)
        metrics = surface_probe(wedge, surfaces, variables)
        area = metrics[0]
        expected = (((pi * 2.0 ** 2.0) - (pi * 0.5 ** 2.0)) * 30.0 / 360.0) * 144.0
        logging.debug("area = %g (%g ft), expected %g", area, area / 144.0, expected)
        assert_rel_error(self, area, expected, 0.00001)

        # J face.
        surfaces = (("xyzzy", 0, -1, 0, 0, 0, -1),)
        variables = (("area", "inch**2"),)
        metrics = surface_probe(wedge, surfaces, variables)
        area = metrics[0]
        expected = (2.0 * pi * 0.5 * 30.0 / 360.0) * 5.0 * 144.0
        logging.debug("area = %g (%g ft), expected %g", area, area / 144.0, expected)
        assert_rel_error(self, area, expected, 0.00001)

        surfaces = (("xyzzy", 0, -1, -1, -1, 0, -1),)
        variables = (("area", "inch**2"),)
        metrics = surface_probe(wedge, surfaces, variables)
        area = metrics[0]
        expected = (2.0 * pi * 2.0 * 30.0 / 360.0) * 5.0 * 144.0
        logging.debug("area = %g (%g ft), expected %g", area, area / 144.0, expected)
        assert_rel_error(self, area, expected, 0.00001)

        # K face.
        surfaces = (("xyzzy", 0, -1, 0, -1, 2, 2),)
        variables = (("area", "inch**2"),)
        metrics = surface_probe(wedge, surfaces, variables)
        area = metrics[0]
        expected = 5.0 * (2.0 - 0.5) * 144.0
        logging.debug("area = %g (%g ft), expected %g", area, area / 144.0, expected)
        assert_rel_error(self, area, expected, 0.000001)