本文整理匯總了Python中structure.Structure.recenter方法的典型用法代碼示例。如果您正苦於以下問題:Python Structure.recenter方法的具體用法?Python Structure.recenter怎麽用?Python Structure.recenter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類structure.Structure
的用法示例。
在下文中一共展示了Structure.recenter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: return_system
# 需要導入模塊: from structure import Structure [as 別名]
# 或者: from structure.Structure import recenter [as 別名]
def return_system(self):
ibrav = self.system.ibrav
if ibrav!=0:
self.error('ability to handle non-zero ibrav not yet implemented')
#end if
scale,axes,kaxes = self.get_common_vars('scale','axes','kaxes')
elem = list(self.atomic_positions.atoms)
ap = self.atomic_positions.copy()
ap.change_specifier('bohr',self)
pos = ap.positions
kp = self.k_points.copy()
kp.change_specifier('tpiba',self)
kpoints = kp.kpoints*(2*pi)/scale
center = axes.sum(0)/2
structure = Structure(
axes = axes,
elem = elem,
scale = scale,
pos = pos,
center = center,
kpoints = kpoints,
units = 'B',
rescale = False
)
structure.zero_corner()
structure.recenter()
ion_charge = 0
valency = dict()
atoms = list(self.atomic_positions.atoms)
for atom in self.atomic_species.atoms:
pseudo_file = self.atomic_species.pseudopotentials[atom]
if self.pseudopotentials!=None and pseudo_file in self.pseudopotentials:
pseudopot = self.pseudopotentials[pseudo_file]
element = pseudopot.element
valence = int(pseudopot.Z)
ion_charge += atoms.count(atom)*valence
valency[atom] = valence
else:
self.error('file '+pseudo_file+' was not listed in Pseudopotentials object\n please specify pseudopotentials with the settings function',trace=False)
#end if
#end for
if 'nelup' in self.system:
nup = self.system.nelup
ndn = self.system.neldw
net_charge = ion_charge - nup - ndn
net_spin = nup - ndn
elif 'tot_magnetization' in self.system:
net_spin = self.system.tot_magnetization
if 'nelec' in self.system:
net_charge = ion_charge - self.system.nelec
else:
net_charge = 0
#end if
else:
net_spin = 0
if 'nelec' in self.system:
net_charge = ion_charge - self.system.nelec
else:
net_charge = 0
#end if
#end if
system = PhysicalSystem(structure,net_charge,net_spin,**valency)
return system