def test_cecm(self):
        """ Integral regression test of integrator algorithm using CE/CM. """

        settings = opendeplete.Settings()
        settings.dt_vec = [0.75, 0.75]
        settings.output_dir = self.results

        op = dummy_geometry.DummyGeometry(settings)

        # Perform simulation using the MCNPX/MCNP6 algorithm
        opendeplete.cecm(op, print_out=False)

        # Load the files
        res = results.read_results(settings.output_dir + "/results.h5")

        _, y1 = utilities.evaluate_single_nuclide(res, "1", "1")
        _, y2 = utilities.evaluate_single_nuclide(res, "1", "2")

        # Mathematica solution
        s1 = [1.86872629872102, 1.395525772416039]
        s2 = [2.18097439443550, 2.69429754646747]

        tol = 1.0e-13

        self.assertLess(np.absolute(y1[1] - s1[0]), tol)
        self.assertLess(np.absolute(y2[1] - s1[1]), tol)

        self.assertLess(np.absolute(y1[2] - s2[0]), tol)
        self.assertLess(np.absolute(y2[2] - s2[1]), tol)
Beispiel #2
0
    def test_predictor(self):
        """ Integral regression test of integrator algorithm using CE/CM. """

        settings = opendeplete.Settings()
        settings.dt_vec = [0.75, 0.75]
        settings.output_dir = self.results

        op = dummy_geometry.DummyGeometry(settings)

        # Perform simulation using the predictor algorithm
        opendeplete.predictor(op, print_out=False)

        # Load the files
        res = results.read_results(settings.output_dir + "/results.h5")

        _, y1 = utilities.evaluate_single_nuclide(res, "1", "1")
        _, y2 = utilities.evaluate_single_nuclide(res, "1", "2")

        # Mathematica solution
        s1 = [2.46847546272295, 0.986431226850467]
        s2 = [4.11525874568034, -0.0581692232513460]

        tol = 1.0e-13

        self.assertLess(np.absolute(y1[1] - s1[0]), tol)
        self.assertLess(np.absolute(y2[1] - s1[1]), tol)

        self.assertLess(np.absolute(y1[2] - s2[0]), tol)
        self.assertLess(np.absolute(y2[2] - s2[1]), tol)
Beispiel #3
0
    def test_evaluate_single_nuclide(self):
        """ Tests evaluating single nuclide utility code.
        """

        # Load the reference
        res = results.read_results("test/test_reference.h5")

        x, y = utilities.evaluate_single_nuclide(res, "1", "Xe135")

        x_ref = [0.0, 1296000.0, 2592000.0, 3888000.0]
        y_ref = [
            6.6747328233649218e+08, 3.5519326338509556e+14,
            3.5965291907016744e+14, 3.3660528631036400e+14
        ]

        np.testing.assert_array_equal(x, x_ref)
        np.testing.assert_array_equal(y, y_ref)
Beispiel #4
0
    def test_evaluate_single_nuclide(self):
        """ Tests evaluating single nuclide utility code.
        """

        # Load the reference
        res = results.read_results("test/test_reference.h5")

        x, y = utilities.evaluate_single_nuclide(res, "1", "Xe135")

        x_ref = [0.0, 1296000.0, 2592000.0, 3888000.0]
        y_ref = [
            6.6747328233649218e+08, 3.5519299354458244e+14,
            3.4599104054580338e+14, 3.3821165110278112e+14
        ]

        np.testing.assert_array_equal(x, x_ref)
        np.testing.assert_array_equal(y, y_ref)
Beispiel #5
0
    def test_full(self):
        """
        This test runs a complete OpenMC simulation and tests the outputs.
        It will take a while.
        """

        n_rings = 2
        n_wedges = 4

        # Load geometry from example
        geometry, lower_left, upper_right = \
            example_geometry.generate_problem(n_rings=n_rings, n_wedges=n_wedges)

        # Create dt vector for 3 steps with 15 day timesteps
        dt1 = 15 * 24 * 60 * 60  # 15 days
        dt2 = 1.5 * 30 * 24 * 60 * 60  # 1.5 months
        N = np.floor(dt2 / dt1)

        dt = np.repeat([dt1], N)

        # Create settings variable
        settings = opendeplete.OpenMCSettings()

        settings.chain_file = "chains/chain_simple.xml"
        settings.openmc_call = "openmc"
        settings.openmc_npernode = 2
        settings.particles = 100
        settings.batches = 100
        settings.inactive = 40
        settings.lower_left = lower_left
        settings.upper_right = upper_right
        settings.entropy_dimension = [10, 10, 1]

        settings.round_number = True
        settings.constant_seed = 1

        joule_per_mev = 1.6021766208e-13
        settings.power = 2.337e15 * 4 * joule_per_mev  # MeV/second cm from CASMO
        settings.dt_vec = dt
        settings.output_dir = "test_full"

        op = opendeplete.OpenMCOperator(geometry, settings)

        # Perform simulation using the predictor algorithm
        opendeplete.integrator.predictor(op)

        # Load the files
        res_test = results.read_results(settings.output_dir + "/results.h5")

        # Load the reference
        res_old = results.read_results("test/test_reference.h5")

        # Assert same mats
        for mat in res_old[0].mat_to_ind:
            self.assertIn(mat,
                          res_test[0].mat_to_ind,
                          msg="Cell " + mat + " not in new results.")
        for nuc in res_old[0].nuc_to_ind:
            self.assertIn(nuc,
                          res_test[0].nuc_to_ind,
                          msg="Nuclide " + nuc + " not in new results.")

        for mat in res_test[0].mat_to_ind:
            self.assertIn(mat,
                          res_old[0].mat_to_ind,
                          msg="Cell " + mat + " not in old results.")
        for nuc in res_test[0].nuc_to_ind:
            self.assertIn(nuc,
                          res_old[0].nuc_to_ind,
                          msg="Nuclide " + nuc + " not in old results.")

        for mat in res_test[0].mat_to_ind:
            for nuc in res_test[0].nuc_to_ind:
                _, y_test = utilities.evaluate_single_nuclide(
                    res_test, mat, nuc)
                _, y_old = utilities.evaluate_single_nuclide(res_old, mat, nuc)

                # Test each point

                tol = 1.0e-6

                correct = True
                for i, ref in enumerate(y_old):
                    if ref != y_test[i]:
                        if ref != 0.0:
                            if np.abs(y_test[i] - ref) / ref > tol:
                                correct = False
                        else:
                            correct = False

                self.assertTrue(correct,
                                msg="Discrepancy in mat " + mat + " and nuc " +
                                nuc + "\n" + str(y_old) + "\n" + str(y_test))