本文整理汇总了Python中pymatgen.io.lammps.data.LammpsData.from_structure方法的典型用法代码示例。如果您正苦于以下问题:Python LammpsData.from_structure方法的具体用法?Python LammpsData.from_structure怎么用?Python LammpsData.from_structure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.io.lammps.data.LammpsData
的用法示例。
在下文中一共展示了LammpsData.from_structure方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_structure
# 需要导入模块: from pymatgen.io.lammps.data import LammpsData [as 别名]
# 或者: from pymatgen.io.lammps.data.LammpsData import from_structure [as 别名]
def test_structure(self):
quartz = self.quartz.structure
np.testing.assert_array_equal(quartz.lattice.matrix,
[[4.913400, 0, 0],
[-2.456700, 4.255129, 0],
[0, 0, 5.405200]])
self.assertEqual(quartz.formula, "Si3 O6")
self.assertNotIn("molecule-ID", self.quartz.atoms.columns)
ethane = self.ethane.structure
np.testing.assert_array_equal(ethane.lattice.matrix,
np.diag([10.0] * 3))
lbounds = np.array(self.ethane.box.bounds)[:, 0]
coords = self.ethane.atoms[["x", "y", "z"]].values - lbounds
np.testing.assert_array_equal(ethane.cart_coords, coords)
np.testing.assert_array_equal(ethane.site_properties["charge"],
self.ethane.atoms["q"])
tatb = self.tatb.structure
frac_coords = tatb.frac_coords[381]
real_frac_coords = frac_coords - np.floor(frac_coords)
np.testing.assert_array_almost_equal(real_frac_coords,
[0.01553397,
0.71487872,
0.14134139])
co = Structure.from_spacegroup(194,
Lattice.hexagonal(2.50078, 4.03333),
["Co"], [[1/3, 2/3, 1/4]])
ld_co = LammpsData.from_structure(co)
self.assertEqual(ld_co.structure.composition.reduced_formula, "Co")
ni = Structure.from_spacegroup(225, Lattice.cubic(3.50804),
["Ni"], [[0, 0, 0]])
ld_ni = LammpsData.from_structure(ni)
self.assertEqual(ld_ni.structure.composition.reduced_formula, "Ni")
示例2: setUpClass
# 需要导入模块: from pymatgen.io.lammps.data import LammpsData [as 别名]
# 或者: from pymatgen.io.lammps.data.LammpsData import from_structure [as 别名]
def setUpClass(cls):
h2o_coords = [[9.626, 6.787, 12.673],
[9.626, 8.420, 12.673],
[10.203, 7.604, 12.673]]
molecule = Molecule(["H", "H", "O"], h2o_coords)
box_size = [[0.0, 10.0], [0.0, 10.0], [0.0, 10.0]]
cls.lammps_data = LammpsData.from_structure(molecule, box_size)
示例3: test_md
# 需要导入模块: from pymatgen.io.lammps.data import LammpsData [as 别名]
# 或者: from pymatgen.io.lammps.data.LammpsData import from_structure [as 别名]
def test_md(self):
s = Structure.from_spacegroup(225, Lattice.cubic(3.62126),
["Cu"], [[0, 0, 0]])
ld = LammpsData.from_structure(s, atom_style="atomic")
ff = "\n".join(["pair_style eam", "pair_coeff * * Cu_u3.eam"])
md = LammpsRun.md(data=ld, force_field=ff, temperature=1600.0,
nsteps=10000)
md.write_inputs(output_dir="md")
with open(os.path.join("md", "in.md")) as f:
md_script = f.read()
script_string = """# Sample input script template for MD
# Initialization
units metal
atom_style atomic
# Atom definition
read_data md.data
#read_restart md.restart
# Force field settings (consult official document for detailed formats)
pair_style eam
pair_coeff * * Cu_u3.eam
# Create velocities
velocity all create 1600.0 142857 mom yes rot yes dist gaussian
# Ensemble constraints
#fix 1 all nve
fix 1 all nvt temp 1600.0 1600.0 0.1
#fix 1 all npt temp 1600.0 1600.0 0.1 iso $pressure $pressure 1.0
# Various operations within timestepping
#fix ...
#compute ...
# Output settings
#thermo_style custom ... # control the thermo data type to output
thermo 100 # output thermo data every N steps
#dump 1 all atom 100 traj.*.gz # dump a snapshot every 100 steps
# Actions
run 10000
"""
self.assertEqual(md_script, script_string)
self.assertTrue(os.path.exists(os.path.join("md", "md.data")))
示例4: test_from_structure
# 需要导入模块: from pymatgen.io.lammps.data import LammpsData [as 别名]
# 或者: from pymatgen.io.lammps.data.LammpsData import from_structure [as 别名]
def test_from_structure(self):
latt = Lattice.monoclinic(9.78746, 4.75058, 8.95892, 115.9693)
structure = Structure.from_spacegroup(15, latt, ["Os", "O", "O"],
[[0, 0.25583, 0.75],
[0.11146, 0.46611, 0.91631],
[0.11445, 0.04564, 0.69518]])
velocities = np.random.randn(20, 3) * 0.1
structure.add_site_property("velocities", velocities)
ld = LammpsData.from_structure(structure=structure,
ff_elements=["O", "Os", "Na"])
i = random.randint(0, 19)
a = latt.matrix[0]
va = velocities[i].dot(a) / np.linalg.norm(a)
self.assertAlmostEqual(va, ld.velocities.loc[i + 1, "vx"])
self.assertAlmostEqual(velocities[i, 1],
ld.velocities.loc[i + 1, "vy"])
np.testing.assert_array_almost_equal(ld.masses["mass"],
[22.989769, 190.23, 15.9994])
np.testing.assert_array_equal(ld.atoms["type"], [2] * 4 + [3] * 16)
示例5: from_structure
# 需要导入模块: from pymatgen.io.lammps.data import LammpsData [as 别名]
# 或者: from pymatgen.io.lammps.data.LammpsData import from_structure [as 别名]
def from_structure(cls, structure, input_template, user_settings,
data_filename="in.data", name="basic"):
"""
Returns inputset from structure
Args:
structure (Structure/Molecule):
input_template (string): path to the input template file.
user_settings (dict): User lammps settings, the keys must
correspond to the keys in the template.
data_filename (string): name of the the lammps data file.
Returns:
LammpsInputSet
"""
lammps_data = LammpsData.from_structure(structure)
return cls.from_file(name, input_template, user_settings,
lammps_data=lammps_data, data_filename=data_filename)
示例6: setUpClass
# 需要导入模块: from pymatgen.io.lammps.data import LammpsData [as 别名]
# 或者: from pymatgen.io.lammps.data.LammpsData import from_structure [as 别名]
def setUpClass(cls):
polymer_chain = Molecule.from_file(os.path.join(test_dir, "polymer_chain.xyz"))
box_size = [[0.0, 20.0], [0.0, 20.0], [0.0, 20.0]]
cls.lammps_data = LammpsData.from_structure(polymer_chain, box_size)