コード例 #1
0
ファイル: test_states.py プロジェクト: yimingchen-eng/veidt
 def test_chain(self):
     spin_state = IsingState([0, 1, 0])
     atom_state = AtomNumberState(10)
     state_dict = StateDict([spin_state, atom_state])
     chain = Chain()
     chain.append(state_dict)
     chain.append(StateDict([AtomNumberState(20), IsingState([1, 1, 1])]))
     self.assertListEqual(chain.chain['ising'][0], [0, 1, 0])
     self.assertListEqual(chain.chain['ising'][1], [1, 1, 1])
     self.assertListEqual(chain.chain['atom_number'], [10, 20])
     self.assertIs(spin_state._chain, chain)
     self.assertEqual(spin_state._chain.length, 2)
コード例 #2
0
    def test_uVT(self):
        model = SimpleLinearModel(NaCount())
        uvt = uVT(model)
        state_dict = StateDict([
            StaticState(300, 'temperature'),
            StaticState(10, 'volume'),
            StaticState(23, 'm'),
            StaticState(-3, 'mu'),
            StaticState(-1, 'pressure'),
            AtomNumberState(10),
            IsingState([0, 1] * 12)
        ])
        spin_struct = SpinStructure(structure=self.structure,
                                    species_map={
                                        1: "Na",
                                        0: "K"
                                    },
                                    state_dict=state_dict)
        energy1 = uvt.exponential(spin_struct)
        #self.assertAlmostEqual(energy1, 1469.6704985, 4)

        spin_struct2 = spin_struct.copy()
        spin_struct2.change()
        print(sum(spin_struct.state_dict['ising'].state),
              sum(spin_struct2.state_dict['ising'].state))
        print(uvt.d_exponential(spin_struct, spin_struct2))
コード例 #3
0
ファイル: test_states.py プロジェクト: yimingchen-eng/veidt
    def test_spin_structure(self):
        species_map = {0: 'K', 1: 'Na'}
        structure = Structure.from_file(
            os.path.join(file_path, 'test_NaCoO2.cif'))
        state_dict = StateDict([
            StaticState(100, 'temperature'),
            AtomNumberState(10),
            IsingState([0] * 22 + [1, 1])
        ])
        spin_struct = SpinStructure(structure, state_dict, species_map)
        self.assertListEqual(spin_struct.state_dict['ising'].state,
                             [0] * 22 + [1, 1])

        orig_specie_list = spin_struct.to_specie_list()

        # test move method
        spin_struct = SpinStructure(structure, state_dict, species_map)
        spin_struct.change()
        self.assertEqual(
            unequal_site_number(spin_struct.state_dict['ising'].state,
                                [0] * 22 + [1, 1]), 1)
        specie_list = spin_struct.to_specie_list()
        self.assertEqual(unequal_site_number(orig_specie_list, specie_list), 1)

        # test from_states
        spin_struct.from_states(
            StateDict([
                StaticState(1000, 'temperature'),
                AtomNumberState(10),
                IsingState([0] * 20 + [1, 1] + [0, 0])
            ]))
        self.assertEqual(
            unequal_site_number(spin_struct.to_specie_list(),
                                orig_specie_list), 4)
        self.assertEqual(
            unequal_site_number(spin_struct.to_states()['ising'].state,
                                [0] * 22 + [1, 1]), 4)
        # test structure to states
        self.assertListEqual(
            spin_struct.structure_to_states(structure)['ising'].state,
            [0] * 22 + [1, 1])
コード例 #4
0
ファイル: test_ensemble.py プロジェクト: usccolumbia/veidt
 def test_nvt(self):
     model = SimpleLinearModel(NaCount())
     nvt = NVT(model)
     state_dict = StateDict([StaticState(100, 'temperature'),
                             AtomNumberState(10),
                             IsingState([0]*22+[1, 1])])
     spin_struct = SpinStructure(structure=self.structure, species_map={1: "Na", 0: "K"},
                                 state_dict=state_dict)
     energy1 = nvt.exponential(spin_struct)
     self.assertEqual(energy1, 2440)
     spin_struct.change()
     energy2 = nvt.exponential(spin_struct)
     self.assertIn(energy2, (2250, 2650))
コード例 #5
0
ファイル: test_ensemble.py プロジェクト: usccolumbia/veidt
 def test_npt(self):
     model = SimpleLinearModel(NaCount())
     npt = NPT(model)
     state_dict = StateDict([StaticState(100, 'temperature'),
                             Volume(10, 'volume'),
                             StaticState(-1, 'pressure'),
                             AtomNumberState(10),
                             IsingState([0, 1]*12)])
     spin_struct = SpinStructure(structure=self.structure, species_map={1: "Na", 0: "K"},
                                 state_dict=state_dict)
     energy1 = npt.exponential(spin_struct)
     self.assertAlmostEqual(energy1, 1429.80157, 4)
     spin_struct.change()
     energy2 = npt.exponential(spin_struct)
     self.assertLessEqual(energy2, 1429.80157 + 10 + 5)
     self.assertLessEqual(1429.80157 + 10 - 5, energy2)
コード例 #6
0
ファイル: test_states.py プロジェクト: yimingchen-eng/veidt
 def test_ising_state(self):
     ising_state = IsingState([0, 1, 0, 1])
     new_ising_state = ising_state.copy()
     self.assertListEqual(ising_state.state, new_ising_state.state)
     self.assertEqual(ising_state, IsingState([0, 1, 0, 1], 'ising2'))
     self.assertEqual(ising_state.n, 4)
     self.assertListEqual(ising_state.state, [0, 1, 0, 1])
     self.assertEqual(ising_state.name, 'ising')
     ising_state.change()
     self.assertEqual(unequal_site_number(ising_state.state, [0, 1, 0, 1]),
                      1)
コード例 #7
0
ファイル: test_metropolis.py プロジェクト: usccolumbia/veidt
 def setUp(self):
     self.structure = Structure.from_file(os.path.join(file_path, '../../tests/test_NaCoO2.cif'))
     self.state_dict = StateDict([
         ConstantTemperature(3000, 'temperature'), IsingState([0] * 22 + [1, 1])])
     self.spin_struct = SpinStructure(structure=self.structure, species_map={1: "Na", 0: "K"},
                                      state_dict=self.state_dict)