本文整理汇总了Python中pymatgen.Structure.from_str方法的典型用法代码示例。如果您正苦于以下问题:Python Structure.from_str方法的具体用法?Python Structure.from_str怎么用?Python Structure.from_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.Structure
的用法示例。
在下文中一共展示了Structure.from_str方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_specie_cifwriter
# 需要导入模块: from pymatgen import Structure [as 别名]
# 或者: from pymatgen.Structure import from_str [as 别名]
def test_specie_cifwriter(self):
si4 = Specie("Si", 4)
si3 = Specie("Si", 3)
n = DummySpecie("X", -3)
coords = list()
coords.append(np.array([0.5, 0.5, 0.5]))
coords.append(np.array([0.75, 0.5, 0.75]))
coords.append(np.array([0, 0, 0]))
lattice = Lattice(np.array([[3.8401979337, 0.00, 0.00],
[1.9200989668, 3.3257101909, 0.00],
[0.00, -2.2171384943, 3.1355090603]]))
struct = Structure(lattice, [n, {si3:0.5, n:0.5}, si4], coords)
writer = CifWriter(struct)
ans = """# generated using pymatgen
data_X1.5Si1.5
_symmetry_space_group_name_H-M 'P 1'
_cell_length_a 3.84019793
_cell_length_b 3.84019899
_cell_length_c 3.84019793
_cell_angle_alpha 119.99999086
_cell_angle_beta 90.00000000
_cell_angle_gamma 60.00000914
_symmetry_Int_Tables_number 1
_chemical_formula_structural X1.5Si1.5
_chemical_formula_sum 'X1.5 Si1.5'
_cell_volume 40.04479464
_cell_formula_units_Z 1
loop_
_symmetry_equiv_pos_site_id
_symmetry_equiv_pos_as_xyz
1 'x, y, z'
loop_
_atom_type_symbol
_atom_type_oxidation_number
X3- -3.0
Si3+ 3.0
Si4+ 4.0
loop_
_atom_site_type_symbol
_atom_site_label
_atom_site_symmetry_multiplicity
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy
X3- X0 1 0.500000 0.500000 0.500000 1
X3- X1 1 0.750000 0.500000 0.750000 0.5
Si3+ Si2 1 0.750000 0.500000 0.750000 0.5
Si4+ Si3 1 0.000000 0.000000 0.000000 1
"""
for l1, l2 in zip(str(writer).split("\n"), ans.split("\n")):
self.assertEqual(l1.strip(), l2.strip())
# test that mixed valence works properly
s2 = Structure.from_str(ans, "cif")
self.assertEqual(struct.composition, s2.composition)
示例2: get_debye_temp
# 需要导入模块: from pymatgen import Structure [as 别名]
# 或者: from pymatgen.Structure import from_str [as 别名]
def get_debye_temp(mpid):
"""
Calculates the debye temperature from eleastic tensors on the Materials Project
Credits: Joseph Montoya
"""
pd.np.seterr(over="ignore") # ignore overflow in double scalars
data = mpr.get_data(mpid)[0]
struct = Structure.from_str(data['cif'], fmt='cif')
c_ij = ElasticTensor.from_voigt(data['elasticity']['elastic_tensor'])
td = c_ij.debye_temperature(struct)
return td
示例3: setUp
# 需要导入模块: from pymatgen import Structure [as 别名]
# 或者: from pymatgen.Structure import from_str [as 别名]
def setUp(self):
struct = Structure.from_str("""FCC Al
1.0
2.473329 0.000000 1.427977
0.824443 2.331877 1.427977
0.000000 0.000000 2.855955
Al
1
direct
0.000000 0.000000 0.000000 Al""", fmt='POSCAR')
self.energies = [-3.69150886, -3.70788383, -3.71997361, -3.72522301,
-3.73569569, -3.73649743, -3.74054982]
self.volumes = [14.824542034870653, 18.118887714656875, 15.373596786943025,
17.569833126580278, 15.92265868064787, 17.02077912220064,
16.471717630914863]
self.eos = "vinet"
self.T = 500
self.qhda = QuasiharmonicDebyeApprox(self.energies, self.volumes, struct, t_min=self.T,
t_max=self.T, eos=self.eos, anharmonic_contribution=True)
self.opt_vol = 17.216094889116807