コード例 #1
0
    def testConstructionAndQuery(self):
        """ Test the construction of the control parametes object """
        # Default construction.
        control_params = KMCControlParameters()

        # Check the default values.
        self.assertEqual(control_params.numberOfSteps(), 0)
        self.assertEqual(control_params.dumpInterval(), 1)
        self.assertEqual(control_params.seed(), 1)
        self.assertTrue(control_params.timeSeed())
        self.assertEqual(control_params.rngType(), Backend.MT)

        # Non-default construction.
        control_params = KMCControlParameters(number_of_steps=2000000,
                                              dump_interval=1000,
                                              analysis_interval=888,
                                              seed=2013,
                                              rng_type='DEVICE')

        # Check the values.
        self.assertEqual(control_params.numberOfSteps(), 2000000)
        self.assertEqual(control_params.dumpInterval(), 1000)
        self.assertEqual(control_params.analysisInterval(), 888)
        self.assertEqual(control_params.seed(), 2013)
        self.assertFalse(control_params.timeSeed())
        self.assertEqual(control_params.rngType(), Backend.DEVICE)
コード例 #2
0
    def testConstructionAndQuery(self):
        """ Test the construction of the control parametes object """
        # Default construction.
        control_params = KMCControlParameters()

        # Check the default values.
        self.assertEqual(control_params.numberOfSteps(), 0)
        self.assertEqual(control_params.dumpInterval(), 1)
        self.assertEqual(control_params.seed(), 1)
        self.assertTrue(control_params.timeSeed())
        self.assertEqual(control_params.rngType(), Backend.MT)

        # Non-default construction.
        control_params = KMCControlParameters(number_of_steps=2000000,
                                              dump_interval=1000,
                                              analysis_interval=888,
                                              seed=2013,
                                              rng_type='DEVICE')

        # Check the values.
        self.assertEqual(control_params.numberOfSteps(), 2000000)
        self.assertEqual(control_params.dumpInterval(), 1000)
        self.assertEqual(control_params.analysisInterval(), 888)
        self.assertEqual(control_params.seed(), 2013)
        self.assertFalse(control_params.timeSeed())
        self.assertEqual(control_params.rngType(), Backend.DEVICE)
コード例 #3
0
    def testConstructionAndQuery2(self):
        """ Test the construction of the control parametes object with a dump time interval """
        # Non-default construction.
        control_params = KMCControlParameters(number_of_steps=2000000,
                                              analysis_interval=888,
                                              seed=2013,
                                              dump_time_interval=1.23)

        # Check the values.
        self.assertEqual(control_params.numberOfSteps(), 2000000)
        self.assertEqual(control_params.analysisInterval(), 888)
        self.assertEqual(control_params.seed(), 2013)
        self.assertFalse(control_params.timeSeed())
        self.assertAlmostEqual(control_params.dumpTimeInterval(), 1.23, 10)
        self.assertTrue(control_params.dumpInterval() is None)

        # Check that we cannot construct with both dump interval and
        # dump time interval set.
        self.assertRaises(
            Error, lambda: KMCControlParameters(number_of_steps=1,
                                                dump_interval=1,
                                                analysis_interval=1,
                                                dump_time_interval=1.23))