本文整理汇总了Python中pymatgen.core.Lattice类的典型用法代码示例。如果您正苦于以下问题:Python Lattice类的具体用法?Python Lattice怎么用?Python Lattice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Lattice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_disordered_primitive_to_ordered_supercell
def test_disordered_primitive_to_ordered_supercell(self):
sm_atoms = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
primitive_cell=False, scale=True,
attempt_supercell=True,
allow_subset=True,
supercell_size = 'num_atoms',
comparator=OrderDisorderElementComparator())
sm_sites = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
primitive_cell=False, scale=True,
attempt_supercell=True,
allow_subset=True,
supercell_size = 'num_sites',
comparator=OrderDisorderElementComparator())
lp = Lattice.orthorhombic(10, 20, 30)
pcoords = [[0, 0, 0],
[0.5, 0.5, 0.5]]
ls = Lattice.orthorhombic(20,20,30)
scoords = [[0, 0, 0],
[0.75, 0.5, 0.5]]
prim = Structure(lp, [{'Na':0.5}, {'Cl':0.5}], pcoords)
supercell = Structure(ls, ['Na', 'Cl'], scoords)
supercell.make_supercell([[-1,1,0],[0,1,1],[1,0,0]])
self.assertFalse(sm_sites.fit(prim, supercell))
self.assertTrue(sm_atoms.fit(prim, supercell))
self.assertRaises(ValueError, sm_atoms.get_s2_like_s1, prim, supercell)
self.assertEqual(len(sm_atoms.get_s2_like_s1(supercell, prim)), 4)
开发者ID:eantono,项目名称:pymatgen,代码行数:28,代码来源:test_structure_matcher.py
示例2: test_ordered_primitive_to_disordered_supercell
def test_ordered_primitive_to_disordered_supercell(self):
sm_atoms = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
primitive_cell=False, scale=True,
attempt_supercell=True,
allow_subset=True,
supercell_size = 'num_atoms',
comparator=OrderDisorderElementComparator())
sm_sites = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
primitive_cell=False, scale=True,
attempt_supercell=True,
allow_subset=True,
supercell_size = 'num_sites',
comparator=OrderDisorderElementComparator())
lp = Lattice.orthorhombic(10, 20, 30)
pcoords = [[0, 0, 0],
[0.5, 0.5, 0.5]]
ls = Lattice.orthorhombic(20,20,30)
scoords = [[0, 0, 0],
[0.5, 0, 0],
[0.25, 0.5, 0.5],
[0.75, 0.5, 0.5]]
s1 = Structure(lp, ['Na', 'Cl'], pcoords)
s2 = Structure(ls, [{'Na':0.5}, {'Na':0.5}, {'Cl':0.5}, {'Cl':0.5}], scoords)
self.assertTrue(sm_sites.fit(s1, s2))
self.assertFalse(sm_atoms.fit(s1, s2))
开发者ID:eantono,项目名称:pymatgen,代码行数:26,代码来源:test_structure_matcher.py
示例3: test_get_supercell_size
def test_get_supercell_size(self):
l = Lattice.cubic(1)
l2 = Lattice.cubic(0.9)
s1 = Structure(l, ['Mg', 'Cu', 'Ag', 'Cu', 'Ag'], [[0]*3]*5)
s2 = Structure(l2, ['Cu', 'Cu', 'Ag'], [[0]*3]*3)
sm = StructureMatcher(supercell_size='volume')
self.assertEqual(sm._get_supercell_size(s1, s2),
(1, True))
self.assertEqual(sm._get_supercell_size(s2, s1),
(1, True))
sm = StructureMatcher(supercell_size='num_sites')
self.assertEqual(sm._get_supercell_size(s1, s2),
(2, False))
self.assertEqual(sm._get_supercell_size(s2, s1),
(2, True))
sm = StructureMatcher(supercell_size='Ag')
self.assertEqual(sm._get_supercell_size(s1, s2),
(2, False))
self.assertEqual(sm._get_supercell_size(s2, s1),
(2, True))
sm = StructureMatcher(supercell_size='wfieoh')
self.assertRaises(ValueError, sm._get_supercell_size, s1, s2)
开发者ID:Lightslayer,项目名称:pymatgen,代码行数:26,代码来源:test_structure_matcher.py
示例4: test_fit
def test_fit(self):
"""
Take two known matched structures
1) Ensure match
2) Ensure match after translation and rotations
3) Ensure no-match after large site translation
4) Ensure match after site shuffling
"""
sm = StructureMatcher()
self.assertTrue(sm.fit(self.struct_list[0], self.struct_list[1]))
# Test rotational/translational invariance
op = SymmOp.from_axis_angle_and_translation([0, 0, 1], 30, False,
np.array([0.4, 0.7, 0.9]))
self.struct_list[1].apply_operation(op)
self.assertTrue(sm.fit(self.struct_list[0], self.struct_list[1]))
#Test failure under large atomic translation
self.struct_list[1].translate_sites([0], [.4, .4, .2],
frac_coords=True)
self.assertFalse(sm.fit(self.struct_list[0], self.struct_list[1]))
self.struct_list[1].translate_sites([0], [-.4, -.4, -.2],
frac_coords=True)
# random.shuffle(editor._sites)
self.assertTrue(sm.fit(self.struct_list[0], self.struct_list[1]))
#Test FrameworkComporator
sm2 = StructureMatcher(comparator=FrameworkComparator())
lfp = self.get_structure("LiFePO4")
nfp = self.get_structure("NaFePO4")
self.assertTrue(sm2.fit(lfp, nfp))
self.assertFalse(sm.fit(lfp, nfp))
#Test anonymous fit.
self.assertEqual(sm.fit_anonymous(lfp, nfp), True)
self.assertAlmostEqual(sm.get_rms_anonymous(lfp, nfp)[0],
0.060895871160262717)
#Test partial occupancies.
s1 = Structure(Lattice.cubic(3),
[{"Fe": 0.5}, {"Fe": 0.5}, {"Fe": 0.5}, {"Fe": 0.5}],
[[0, 0, 0], [0.25, 0.25, 0.25],
[0.5, 0.5, 0.5], [0.75, 0.75, 0.75]])
s2 = Structure(Lattice.cubic(3),
[{"Fe": 0.25}, {"Fe": 0.5}, {"Fe": 0.5}, {"Fe": 0.75}],
[[0, 0, 0], [0.25, 0.25, 0.25],
[0.5, 0.5, 0.5], [0.75, 0.75, 0.75]])
self.assertFalse(sm.fit(s1, s2))
self.assertFalse(sm.fit(s2, s1))
s2 = Structure(Lattice.cubic(3),
[{"Mn": 0.5}, {"Mn": 0.5}, {"Mn": 0.5},
{"Mn": 0.5}],
[[0, 0, 0], [0.25, 0.25, 0.25],
[0.5, 0.5, 0.5], [0.75, 0.75, 0.75]])
self.assertEqual(sm.fit_anonymous(s1, s2), True)
self.assertAlmostEqual(sm.get_rms_anonymous(s1, s2)[0], 0)
开发者ID:eantono,项目名称:pymatgen,代码行数:58,代码来源:test_structure_matcher.py
示例5: setUp
def setUp(self):
c1 = [[0.5] * 3, [0.9] * 3]
c2 = [[0.5] * 3, [0.9, 0.1, 0.1]]
s1 = Structure(Lattice.cubic(5), ['Si', 'Si'], c1)
s2 = Structure(Lattice.cubic(5), ['Si', 'Si'], c2)
structs = []
for s in s1.interpolate(s2, 3, pbc=True):
structs.append(Structure.from_sites(s.sites, to_unit_cell=True))
self.structures = structs
self.vis = MITNEBSet(self.structures)
开发者ID:matk86,项目名称:pymatgen,代码行数:10,代码来源:test_sets.py
示例6: test_get_lattices
def test_get_lattices(self):
sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5, primitive_cell=True, scale=True, attempt_supercell=False)
l1 = Lattice.from_lengths_and_angles([1, 2.1, 1.9], [90, 89, 91])
l2 = Lattice.from_lengths_and_angles([1.1, 2, 2], [89, 91, 90])
s1 = Structure(l1, [], [])
s2 = Structure(l2, [], [])
lattices = list(sm._get_lattices(s=s1, target_lattice=s2.lattice))
self.assertEqual(len(lattices), 16)
l3 = Lattice.from_lengths_and_angles([1.1, 2, 20], [89, 91, 90])
s3 = Structure(l3, [], [])
lattices = list(sm._get_lattices(s=s1, target_lattice=s3.lattice))
self.assertEqual(len(lattices), 0)
开发者ID:dcossey014,项目名称:pymatgen,代码行数:15,代码来源:test_structure_matcher.py
示例7: test_subset
def test_subset(self):
sm = StructureMatcher(
ltol=0.2,
stol=0.3,
angle_tol=5,
primitive_cell=False,
scale=True,
attempt_supercell=False,
allow_subset=True,
)
l = Lattice.orthorhombic(10, 20, 30)
s1 = Structure(l, ["Si", "Si", "Ag"], [[0, 0, 0.1], [0, 0, 0.2], [0.7, 0.4, 0.5]])
s2 = Structure(l, ["Si", "Ag"], [[0, 0.1, 0], [-0.7, 0.5, 0.4]])
result = sm.get_s2_like_s1(s1, s2)
self.assertEqual(len(find_in_coord_list_pbc(result.frac_coords, [0, 0, 0.1])), 1)
self.assertEqual(len(find_in_coord_list_pbc(result.frac_coords, [0.7, 0.4, 0.5])), 1)
# test with fewer species in s2
s1 = Structure(l, ["Si", "Ag", "Si"], [[0, 0, 0.1], [0, 0, 0.2], [0.7, 0.4, 0.5]])
s2 = Structure(l, ["Si", "Si"], [[0, 0.1, 0], [-0.7, 0.5, 0.4]])
result = sm.get_s2_like_s1(s1, s2)
mindists = np.min(s1.lattice.get_all_distances(s1.frac_coords, result.frac_coords), axis=0)
self.assertLess(np.max(mindists), 1e-6)
self.assertEqual(len(find_in_coord_list_pbc(result.frac_coords, [0, 0, 0.1])), 1)
self.assertEqual(len(find_in_coord_list_pbc(result.frac_coords, [0.7, 0.4, 0.5])), 1)
# test with not enough sites in s1
# test with fewer species in s2
s1 = Structure(l, ["Si", "Ag", "Cl"], [[0, 0, 0.1], [0, 0, 0.2], [0.7, 0.4, 0.5]])
s2 = Structure(l, ["Si", "Si"], [[0, 0.1, 0], [-0.7, 0.5, 0.4]])
self.assertEqual(sm.get_s2_like_s1(s1, s2), None)
开发者ID:dcossey014,项目名称:pymatgen,代码行数:33,代码来源:test_structure_matcher.py
示例8: test_writestring
def test_writestring(self):
# Test for the string export of s atructure into the exciting input xml schema
input_string = (
'<input xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
'xsi:noNamespaceSchemaLocation="http://xml.exciting-code.org/excitinginput'
'.xsd">\n <title>Na4 Cl4</title>\n <structure speciespath="./">\n '
'<crystal scale="1.8897543768634038">\n <basevect> 5.62000000'
' 0.00000000 0.00000000</basevect>\n <basevect> '
'0.00000000 5.62000000 0.00000000</basevect>\n '
'<basevect> 0.00000000 0.00000000 5.62000000</basevect>'
'\n </crystal>\n <species speciesfile="Na.xml">\n <atom coord='
'" 0.00000000 0.00000000 0.00000000" />\n <atom coor'
'd=" 0.50000000 0.50000000 0.00000000" />\n <atom co'
'ord=" 0.50000000 0.00000000 0.50000000" />\n <atom '
'coord=" 0.00000000 0.50000000 0.50000000" />\n </spec'
'ies>\n <species speciesfile="Cl.xml">\n <atom coord=" 0.5000'
'0000 0.00000000 0.00000000" />\n <atom coord=" 0.00'
'000000 0.50000000 0.00000000" />\n <atom coord=" 0.'
'00000000 0.00000000 0.50000000" />\n <atom coord=" '
'0.50000000 0.50000000 0.50000000" />\n </species>\n </str'
'ucture>\n</input>\n')
lattice = Lattice.cubic('5.62')
structure = Structure(lattice, ['Na', 'Na', 'Na', 'Na',
'Cl', 'Cl', 'Cl', 'Cl'],
[[0, 0, 0], [0.5, 0.5, 0.0], [0.5, 0.0, 0.5],
[0.0, 0.5, 0.5],
[0.5, 0.0, 0.0], [0.0, 0.5, 0.0],
[0.0, 0.0, 0.5], [0.5, 0.5, 0.5]])
excin = ExcitingInput(structure)
for l1, l2 in zip(input_string.split("\n"),
excin.write_string('unchanged').split("\n")):
if not l1.strip().startswith("<crystal scale"):
self.assertEqual(l1, l2)
开发者ID:ExpHP,项目名称:pymatgen,代码行数:33,代码来源:test_exciting.py
示例9: pair
def pair(self, element_a, element_b, potential, separations):
max_r = np.max(separations)
lattice = Lattice.from_parameters(10*max_r, 10*max_r, 10*max_r, 90, 90, 90)
if self.calculator_type == 'lammps':
kwargs = {'lammps_set': load_lammps_set('static')}
elif self.calculator_type == 'lammps_cython':
kwargs = {'lammps_additional_commands': ['run 0']}
async def calculate():
futures = []
for sep in separations:
coord_a = (lattice.a*0.5-(sep/2), lattice.b*0.5, lattice.c*0.5)
coord_b = (lattice.a*0.5+(sep/2), lattice.b*0.5, lattice.c*0.5)
structure = Structure(
lattice,
[element_a, element_b],
[coord_a, coord_b], coords_are_cartesian=True)
futures.append(await self.calculator.submit(
structure, potential,
properties={'energy'},
**kwargs))
return await asyncio.gather(*futures)
results = self._run_async_func(calculate())
return np.array([r['results']['energy'] for r in results])
开发者ID:costrouc,项目名称:dftfit,代码行数:25,代码来源:base.py
示例10: test_get_supercell_matrix
def test_get_supercell_matrix(self):
sm = StructureMatcher(ltol=0.1, stol=0.3, angle_tol=2,
primitive_cell=False, scale=True,
attempt_supercell=True)
l = Lattice.orthorhombic(1, 2, 3)
s1 = Structure(l, ['Si', 'Si', 'Ag'],
[[0,0,0.1],[0,0,0.2],[.7,.4,.5]])
s1.make_supercell([2,1,1])
s2 = Structure(l, ['Si', 'Si', 'Ag'],
[[0,0.1,0],[0,0.1,-0.95],[-.7,.5,.375]])
result = sm.get_supercell_matrix(s1, s2)
self.assertTrue((result == [[-2,0,0],[0,1,0],[0,0,1]]).all())
s1 = Structure(l, ['Si', 'Si', 'Ag'],
[[0,0,0.1],[0,0,0.2],[.7,.4,.5]])
s1.make_supercell([[1, -1, 0],[0, 0, -1],[0, 1, 0]])
s2 = Structure(l, ['Si', 'Si', 'Ag'],
[[0,0.1,0],[0,0.1,-0.95],[-.7,.5,.375]])
result = sm.get_supercell_matrix(s1, s2)
self.assertTrue((result == [[-1,-1,0],[0,0,-1],[0,1,0]]).all())
#test when the supercell is a subset
sm = StructureMatcher(ltol=0.1, stol=0.3, angle_tol=2,
primitive_cell=False, scale=True,
attempt_supercell=True, allow_subset=True)
del s1[0]
result = sm.get_supercell_matrix(s1, s2)
self.assertTrue((result == [[-1,-1,0],[0,0,-1],[0,1,0]]).all())
开发者ID:eantono,项目名称:pymatgen,代码行数:31,代码来源:test_structure_matcher.py
示例11: test_get_mapping
def test_get_mapping(self):
sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
primitive_cell=False, scale=True,
attempt_supercell=False,
allow_subset = True)
l = Lattice.orthorhombic(1, 2, 3)
s1 = Structure(l, ['Ag', 'Si', 'Si'],
[[.7,.4,.5],[0,0,0.1],[0,0,0.2]])
s1.make_supercell([2,1,1])
s2 = Structure(l, ['Si', 'Si', 'Ag'],
[[0,0.1,-0.95],[0,0.1,0],[-.7,.5,.375]])
shuffle = [2,0,1,3,5,4]
s1 = Structure.from_sites([s1[i] for i in shuffle])
#test the mapping
s2.make_supercell([2,1,1])
#equal sizes
for i, x in enumerate(sm.get_mapping(s1, s2)):
self.assertEqual(s1[x].species_and_occu,
s2[i].species_and_occu)
del s1[0]
#s1 is subset of s2
for i, x in enumerate(sm.get_mapping(s2, s1)):
self.assertEqual(s1[i].species_and_occu,
s2[x].species_and_occu)
#s2 is smaller than s1
del s2[0]
del s2[1]
self.assertRaises(ValueError, sm.get_mapping, s2, s1)
开发者ID:eantono,项目名称:pymatgen,代码行数:30,代码来源:test_structure_matcher.py
示例12: test_out_of_cell_s2_like_s1
def test_out_of_cell_s2_like_s1(self):
l = Lattice.cubic(5)
s1 = Structure(l, ["Si", "Ag", "Si"], [[0, 0, -0.02], [0, 0, 0.001], [0.7, 0.4, 0.5]])
s2 = Structure(l, ["Si", "Ag", "Si"], [[0, 0, 0.98], [0, 0, 0.99], [0.7, 0.4, 0.5]])
new_s2 = StructureMatcher(primitive_cell=False).get_s2_like_s1(s1, s2)
dists = np.sum((s1.cart_coords - new_s2.cart_coords) ** 2, axis=-1) ** 0.5
self.assertLess(np.max(dists), 0.1)
开发者ID:dcossey014,项目名称:pymatgen,代码行数:7,代码来源:test_structure_matcher.py
示例13: test_get_s2_large_s2
def test_get_s2_large_s2(self):
sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
primitive_cell=False, scale=False,
attempt_supercell=True, allow_subset=False,
supercell_size='volume')
l = Lattice.orthorhombic(1, 2, 3)
s1 = Structure(l, ['Ag', 'Si', 'Si'],
[[.7,.4,.5],[0,0,0.1],[0,0,0.2]])
l2 = Lattice.orthorhombic(1.01, 2.01, 3.01)
s2 = Structure(l2, ['Si', 'Si', 'Ag'],
[[0,0.1,-0.95],[0,0.1,0],[-.7,.5,.375]])
s2.make_supercell([[0,-1,0],[1,0,0],[0,0,1]])
result = sm.get_s2_like_s1(s1, s2)
for x,y in zip(s1, result):
self.assertLess(x.distance(y), 0.08)
开发者ID:eantono,项目名称:pymatgen,代码行数:19,代码来源:test_structure_matcher.py
示例14: test_get_supercells
def test_get_supercells(self):
sm = StructureMatcher(comparator=ElementComparator())
l = Lattice.cubic(1)
l2 = Lattice.cubic(0.5)
s1 = Structure(l, ['Mg', 'Cu', 'Ag', 'Cu'], [[0]*3]*4)
s2 = Structure(l2, ['Cu', 'Cu', 'Ag'], [[0]*3]*3)
scs = list(sm._get_supercells(s1, s2, 8, False))
for x in scs:
self.assertAlmostEqual(abs(np.linalg.det(x[3])), 8)
self.assertEqual(len(x[0]), 4)
self.assertEqual(len(x[1]), 24)
self.assertEqual(len(scs), 48)
scs = list(sm._get_supercells(s2, s1, 8, True))
for x in scs:
self.assertAlmostEqual(abs(np.linalg.det(x[3])), 8)
self.assertEqual(len(x[0]), 24)
self.assertEqual(len(x[1]), 4)
self.assertEqual(len(scs), 48)
开发者ID:eantono,项目名称:pymatgen,代码行数:19,代码来源:test_structure_matcher.py
示例15: test_nelect
def test_nelect(self):
coords = [[0] * 3, [0.5] * 3, [0.75] * 3]
lattice = Lattice.cubic(4)
s = Structure(lattice, ['Si', 'Si', 'Fe'], coords)
self.assertAlmostEqual(MITRelaxSet(s).nelect, 16)
# Check that it works even when oxidation states are present. Was a bug
# previously.
s = Structure(lattice, ['Si4+', 'Si4+', 'Fe2+'], coords)
self.assertAlmostEqual(MITRelaxSet(s).nelect, 16)
self.assertAlmostEqual(MPRelaxSet(s).nelect, 22)
开发者ID:matk86,项目名称:pymatgen,代码行数:11,代码来源:test_sets.py
示例16: test_get_supercell_size
def test_get_supercell_size(self):
l = Lattice.cubic(1)
l2 = Lattice.cubic(0.9)
s1 = Structure(l, ["Mg", "Cu", "Ag", "Cu", "Ag"], [[0] * 3] * 5)
s2 = Structure(l2, ["Cu", "Cu", "Ag"], [[0] * 3] * 3)
sm = StructureMatcher(supercell_size="volume")
self.assertEqual(sm._get_supercell_size(s1, s2), (1, True))
self.assertEqual(sm._get_supercell_size(s2, s1), (1, True))
sm = StructureMatcher(supercell_size="num_sites")
self.assertEqual(sm._get_supercell_size(s1, s2), (2, False))
self.assertEqual(sm._get_supercell_size(s2, s1), (2, True))
sm = StructureMatcher(supercell_size="Ag")
self.assertEqual(sm._get_supercell_size(s1, s2), (2, False))
self.assertEqual(sm._get_supercell_size(s2, s1), (2, True))
sm = StructureMatcher(supercell_size="wfieoh")
self.assertRaises(ValueError, sm._get_supercell_size, s1, s2)
开发者ID:dcossey014,项目名称:pymatgen,代码行数:20,代码来源:test_structure_matcher.py
示例17: test_get_mask
def test_get_mask(self):
sm = StructureMatcher(comparator=ElementComparator())
l = Lattice.cubic(1)
s1 = Structure(l, ['Mg', 'Cu', 'Ag', 'Cu'], [[0]*3]*4)
s2 = Structure(l, ['Cu', 'Cu', 'Ag'], [[0]*3]*3)
result = [[True, False, True, False],
[True, False, True, False],
[True, True, False, True]]
m, inds, i = sm._get_mask(s1, s2, 1, True)
self.assertTrue(np.all(m == result))
self.assertTrue(i == 2)
self.assertEqual(inds, [2])
#test supercell with match
result = [[1, 1, 0, 0, 1, 1, 0, 0],
[1, 1, 0, 0, 1, 1, 0, 0],
[1, 1, 1, 1, 0, 0, 1, 1]]
m, inds, i = sm._get_mask(s1, s2, 2, True)
self.assertTrue(np.all(m == result))
self.assertTrue(i == 2)
self.assertTrue(np.allclose(inds, np.array([4])))
#test supercell without match
result = [[1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 1, 1],
[1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 1, 1]]
m, inds, i = sm._get_mask(s2, s1, 2, True)
self.assertTrue(np.all(m == result))
self.assertTrue(i == 0)
self.assertTrue(np.allclose(inds, np.array([])))
#test s2_supercell
result = [[1, 1, 1], [1, 1, 1],
[0, 0, 1], [0, 0, 1],
[1, 1, 0], [1, 1, 0],
[0, 0, 1], [0, 0, 1]]
m, inds, i = sm._get_mask(s2, s1, 2, False)
self.assertTrue(np.all(m == result))
self.assertTrue(i == 0)
self.assertTrue(np.allclose(inds, np.array([])))
#test for multiple translation indices
s1 = Structure(l, ['Cu', 'Ag', 'Cu', 'Ag', 'Ag'], [[0]*3]*5)
s2 = Structure(l, ['Ag', 'Cu', 'Ag'], [[0]*3]*3)
result = [[1, 0, 1, 0, 0],
[0, 1, 0, 1, 1],
[1, 0, 1, 0, 0]]
m, inds, i = sm._get_mask(s1, s2, 1, True)
self.assertTrue(np.all(m == result))
self.assertTrue(i == 1)
self.assertTrue(np.allclose(inds, [0, 2]))
开发者ID:eantono,项目名称:pymatgen,代码行数:54,代码来源:test_structure_matcher.py
示例18: test_metal_check
def test_metal_check(self):
structure = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3),
["Cu"], [[0, 0, 0]])
with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
# Trigger a warning.
vis = MITRelaxSet(structure)
incar = vis.incar
# Verify some things
self.assertIn("ISMEAR", str(w[-1].message))
开发者ID:blondegeek,项目名称:pymatgen,代码行数:12,代码来源:test_sets.py
示例19: test_get_supercell_size
def test_get_supercell_size(self):
l = Lattice.cubic(1)
l2 = Lattice.cubic(0.9)
s1 = Structure(l, ['Mg', 'Cu', 'Ag', 'Cu', 'Ag'], [[0]*3]*5)
s2 = Structure(l2, ['Cu', 'Cu', 'Ag'], [[0]*3]*3)
sm = StructureMatcher(supercell_size='volume')
result = sm._get_supercell_size(s1, s2)
self.assertEqual(result[0], 1)
self.assertEqual(result[1], True)
result = sm._get_supercell_size(s2, s1)
self.assertEqual(result[0], 1)
self.assertEqual(result[1], True)
sm = StructureMatcher(supercell_size='num_sites')
result = sm._get_supercell_size(s1, s2)
self.assertEqual(result[0], 2)
self.assertEqual(result[1], False)
result = sm._get_supercell_size(s2, s1)
self.assertEqual(result[0], 2)
self.assertEqual(result[1], True)
开发者ID:eantono,项目名称:pymatgen,代码行数:23,代码来源:test_structure_matcher.py
示例20: test_find_match2
def test_find_match2(self):
sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5, primitive_cell=True, scale=True, attempt_supercell=False)
l = Lattice.orthorhombic(1, 2, 3)
s1 = Structure(l, ["Si", "Si"], [[0, 0, 0.1], [0, 0, 0.2]])
s2 = Structure(l, ["Si", "Si"], [[0, 0.1, 0], [0, 0.1, -0.95]])
s1, s2, fu, s1_supercell = sm._preprocess(s1, s2, False)
match = sm._strict_match(s1, s2, fu, s1_supercell=False, use_rms=True, break_on_match=False)
scale_matrix = match[2]
s2.make_supercell(scale_matrix)
s2.translate_sites(range(len(s2)), match[3])
self.assertAlmostEqual(np.sum(s2.frac_coords), 0.3)
self.assertAlmostEqual(np.sum(s2.frac_coords[:, :2]), 0)
开发者ID:dcossey014,项目名称:pymatgen,代码行数:15,代码来源:test_structure_matcher.py
注:本文中的pymatgen.core.Lattice类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论