本文整理汇总了Python中magres.atoms.MagresAtoms类的典型用法代码示例。如果您正苦于以下问题:Python MagresAtoms类的具体用法?Python MagresAtoms怎么用?Python MagresAtoms使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MagresAtoms类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
def test(self):
from magres.atoms import MagresAtoms
atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, 'ethanol-all.magres'))
self.assertEqual(len(atoms), 9)
for atom in atoms:
"{} {}".format(atom, atom.ms.iso)
atoms.species('H').set_reference(10.0)
for atom in atoms.species('H'):
"{} {}".format(atom, atom.ms.cs)
for atom in atoms.within(atoms.C1, 2.0):
"{} {}".format(atom, atom.ms.iso, atom.ms.aniso)
self.assertEqual(len(atoms.species('H').ms.iso), 6)
self.assertAlmostEqual(mean(atoms.C1.bonded.species('H').ms.iso), 29.9838078506)
self.assertAlmostEqual(mean(atoms.C2.bonded.species('H').ms.iso), 28.7851386496)
self.assertAlmostEqual(mean(atoms.O1.bonded.species('H').ms.iso), 31.9849757497)
self.assertEqual(atoms.C1.ms.sigma.shape, (3, 3))
self.assertEqual(len(atoms.C1.ms.evecs), 3)
self.assertEqual(len(atoms.C1.ms.evals), 3)
示例2: test_angles
def test_angles(self):
atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "angles/angles1.magres"))
self.assertTrue(allclose(atoms.angle(atoms.C1, atoms.C2, atoms.C4, degrees=True), 45.0))
self.assertTrue(allclose(atoms.angle(atoms.C1, atoms.C2, atoms.C6, degrees=True), 90.0))
self.assertTrue(allclose(atoms.angle(atoms.C2, atoms.C1, atoms.C4), math.pi/2.0))
self.assertTrue(allclose(atoms.angle(atoms.C2, atoms.C1, atoms.C6), math.pi/4.0))
示例3: test_labels
def test_labels(self):
atoms = MagresAtoms.load_magres(self.species)
self.assertEquals(len(atoms), 3)
self.assertEquals(len(atoms.label('H')), 1)
self.assertEquals(len(atoms.label('C')), 0)
self.assertEquals(len(atoms.label('C1')), 1)
self.assertEquals(len(atoms.label('C2')), 1)
示例4: test_replace_isc
def test_replace_isc(self):
atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol-isc.magres"))
atoms.C2.isc[0].K
with self.assertRaises(Exception):
atoms.C2.isc[0].K = numpy.array([1,2,3])
orig_iso = atoms.C2.isc[0].K_iso
new_K = atoms.C2.isc[0].K * 2.0
atoms.C2.isc[0].K = new_K
self.assertEqual(atoms.C2.isc[0].K_iso, orig_iso * 2.0)
示例5: test_full_isc
def test_full_isc(self):
magres_files = [MagresFile(open(os.path.join(DATA_DIR, "ethanol", f))) for f in os.listdir(os.path.join(DATA_DIR, "ethanol")) if f.startswith('ethanol-jc')]
self.assertEqual(len(magres_files), 9)
atoms = MagresAtoms.load_magres(magres_files)
for atom in atoms:
self.assertTrue(hasattr(atom, "isc"))
self.assertEqual(len(atoms.isc), len(atoms) * (len(atoms) - 1))
# Check every atom has couplings to every other atom
for atom in atoms:
self.assertEqual(len(atom.isc), len(atoms)-1)
示例6: test_within_orthorhombic
def test_within_orthorhombic(self):
atoms = MagresAtoms.load_magres(self.orthorhombic)
self.assertEqual(len(atoms), 1)
p = atoms[0].position
self.assertEqual(len(atoms.within(p, 1.0)), 3)
num_within_3 = 0
for atom in atoms.within(p, 10.0):
if atom.dist(atoms[0]) <= 3.0:
num_within_3 += 1
self.assertEqual(len(atoms.within(p, 3.0)), num_within_3)
self.assertEqual(len(atoms.within(p, 5.0).within(p, 2.0)), len(atoms.within(p, 2.0).within(p, 5.0)))
示例7: test_replace_efg
def test_replace_efg(self):
"""
Check that we can replace the tensor on an atom.
"""
atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol/ethanol-nmr.magres"))
with self.assertRaises(Exception):
atoms.C1.efg.V = numpy.array([1,2,3])
orig_Cq = atoms.C1.efg.Cq
new_V = atoms.C1.efg.V * 2.0
atoms.C1.efg.V = new_V
self.assertEqual(atoms.C1.efg.Cq, orig_Cq * 2.0)
示例8: test_efg
def test_efg(self):
atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol/ethanol-nmr.magres"))
self.assertTrue(hasattr(atoms, "efg"))
self.assertEqual(len(atoms.efg), 9)
# Check that the EFGs are traceless
for efg in atoms.efg:
self.assertTrue(numpy.trace(efg.V)/3.0 < 1e-12)
# Check that the principal components are ordered by the Haeberlen convention
# |Vzz| >= |Vxx| >= |Vyy|
for efg in atoms.efg:
self.assertTrue(abs(efg.evals[2]) >= abs(efg.evals[0]))
self.assertTrue(abs(efg.evals[0]) >= abs(efg.evals[1]))
示例9: test_isc
def test_isc(self):
atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol-isc.magres"))
self.assertTrue(hasattr(atoms.C2, "isc"))
self.assertTrue(hasattr(atoms.C2, "isc_orbital_p"))
self.assertTrue(hasattr(atoms.C2, "isc_orbital_d"))
self.assertTrue(hasattr(atoms.C2, "isc_spin"))
self.assertTrue(hasattr(atoms.C2, "isc_fc"))
self.assertEqual(len(atoms.C2.isc), len(atoms)-1)
perturb_atom = atoms.get('C', 2)
for isc in atoms.C2.isc:
self.assertEqual(isc.atom1, perturb_atom)
self.assertEqual(isc.K_iso, numpy.trace(isc.K)/3.0)
# Check that the principal components are ordered by the Haeberlen convention
for isc in atoms.C2.isc:
self.assertTrue(abs(isc.K_evals[2] - isc.K_iso) >= abs(isc.K_evals[0] - isc.K_iso))
self.assertTrue(abs(isc.K_evals[0] - isc.K_iso) >= abs(isc.K_evals[1] - isc.K_iso))
示例10: test_efg
def test_efg(self):
atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol/ethanol-nmr.magres"))
self.assertTrue(hasattr(atoms, "efg"))
self.assertEqual(len(atoms.efg), 9)
# Check that the EFGs are traceless
for efg in atoms.efg:
self.assertTrue(numpy.trace(efg.V) / 3.0 < 1e-12)
# Check that the principal components are ordered by the Haeberlen convention
# |Vzz| >= |Vxx| >= |Vyy|
for efg in atoms.efg:
self.assertTrue(abs(efg.evals[2]) >= abs(efg.evals[0]))
self.assertTrue(abs(efg.evals[0]) >= abs(efg.evals[1]))
# Check that eta is positive and <=1 (Cq can be positive or negative)
# eta = (Vxx - Vyy)/Vzz, 0 <= eta <= 1
for efg in atoms.efg:
self.assertTrue((efg.evals[1] - efg.evals[0]) / efg.evals[2] >= 0)
self.assertTrue((efg.evals[1] - efg.evals[0]) / efg.evals[2] <= 1)
self.assertTrue(efg.eta >= 0)
self.assertTrue(efg.eta <= 1)
示例11: test_angles_boundary
def test_angles_boundary(self):
atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "angles/angles1.magres"))
self.assertTrue(allclose(atoms.angle(atoms.C2, atoms.C1, atoms.C3, degrees=True), 180.0))
self.assertTrue(allclose(atoms.angle(atoms.C6, atoms.C1, atoms.C9, degrees=True), 90.0))
示例12: print
from __future__ import print_function
import sys
import math
import numpy
from magres.atoms import MagresAtoms
# Load T1Si0.magres sample into an atoms structure
atoms = MagresAtoms.load_magres("../samples/T1Si0.magres")
atomAl15 = atoms.get("Al", 15)
for atom in atoms.species("Al"):
if atom == atomAl15:
continue
Vzz = atom.efg.evecs[2]
dr = atom.position - atomAl15.position
Vzz_dr_ang = math.acos(numpy.dot(Vzz, dr) / math.sqrt(numpy.dot(dr, dr) * numpy.dot(Vzz, Vzz)))
print(atom, atom.efg.Cq, Vzz_dr_ang)
示例13:
from magres.atoms import MagresAtoms
atoms = MagresAtoms.load_magres('samples/simple.magres')
print atoms[0].position
Catoms = atoms.species('C')
print "1"
for atom in Catoms.within(atoms[0], 1.0):
print atom, atom.position
print "5"
for atom in Catoms.within(atoms[0], 3.0):
print atom, atom.position
print "5-1"
for atom in Catoms.within(atoms[0], 3.0).within(atoms[0], 1.0):
print atom, atom.position
print "1-5"
for atom in Catoms.within(atoms[0], 1.0).within(atoms[0], 3.0):
print atom, atom.position
示例14: Copyright
# -*- coding: utf-8 -*-
# =============================================================================
# Copyright (C) 2015 Christian Fernandez
# Laboratoire Catalyse et Spectrochimie, Caen, France.
# [email protected]
#
# This software is governed by the CeCILL-B license under French law
# and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under
# the terms of the CeCILL-B license as circulated by CEA, CNRS and INRIA
# at the following URL "http://www.cecill.info".
#
# See Licence.txt in the main directory
# =============================================================================
"""Short description.
A longer description.
"""
from __future__ import print_function
from magres.atoms import MagresAtoms, MagresAtomsView
ethanol_atoms = MagresAtoms.load_magres('../samples/ethanol-all.magres')
ethanol_atoms.calculate_bonds()
示例15: parse_atom_list
atoms_filter_str = a.atoms
if atoms_filter_str:
atoms_filter = parse_atom_list(atoms_filter_str)
else:
atoms_filter = lambda x: True
tensors = ['ms']
lines = []
print "# Number\tAtom\tIso\tAniso\tAsym\tPath"
if os.path.isfile(a.source_dir):
magres_atoms = [MagresAtoms.load_magres(a.source_dir)]
else:
magres_atoms = load_all_magres(a.source_dir)
isos = {}
for iso_ in a.iso:
num = re.findall('([0-9]+)', iso_)[0]
sym = re.findall('([A-Za-z]+)', iso_)[0]
isos[sym] = int(num)
for i, atoms in enumerate(magres_atoms):
num = get_numeric(atoms.magres_file.path)
for s, iso in isos.items():