def read(self, filename='trajectory.vmol', position=0): """Read atom configurations of step position""" self.file = None f = open(filename) # find coordinates loa = Cluster([]) coords = False for l in f.readlines(): if coords: w = l.split() loa.append(Atom(w[3].replace ("\n", "" ), (float(w[0]), float(w[1]), float(w[2]))))
def read(self, filename='trajectory.vmol', position=0): """Read atom configurations of step position""" self.file = None f = open(filename) # find coordinates loa = Cluster([]) coords = False for l in f.readlines(): if coords: w = l.split() loa.append(Atom(w[3].replace("\n", ""), (float(w[0]), float(w[1]), float(w[2]))))
def read_viewmol(self, filename): f = open(filename) # read the definition first definition=False for line in f: w = line.split() if not definition: if w[0] == '$coord': definition=True self.scale = float(w[1]) loa = Cluster([]) else: if w[0] == '$grad': # definition ends here self.definition = loa break else: # we assume this is a coordinate entry coo = (float(w[0]), float(w[1]), float(w[2])) loa.append(Atom(w[3], coo)) # get the iterations cycle = False for line in f: w = line.split() if not cycle: # search for the cycle keyword if w[0] == 'cycle=': cycle=True n_coo=0 n_F=0 self.images.append(Cluster([])) else: if n_coo < len(self.definition): n_coo += 1 coo = (float(w[0]), float(w[1]), float(w[2])) self[-1].append(Atom(w[3], coo)) elif n_F < len(self.definition): F = (float(w[0]), float(w[1]), float(w[2])) self[-1][n_F].F = F n_F += 1 if n_F == len(self.definition): cycle=False
def read_viewmol(self, filename): f = open(filename) # read the definition first definition = False for line in f: w = line.split() if not definition: if w[0] == '$coord': definition = True self.scale = float(w[1]) loa = Cluster([]) else: if w[0] == '$grad': # definition ends here self.definition = loa break else: # we assume this is a coordinate entry coo = (float(w[0]), float(w[1]), float(w[2])) loa.append(Atom(w[3], coo)) # get the iterations cycle = False for line in f: w = line.split() if not cycle: # search for the cycle keyword if w[0] == 'cycle=': cycle = True n_coo = 0 n_F = 0 self.images.append(Cluster([])) else: if n_coo < len(self.definition): n_coo += 1 coo = (float(w[0]), float(w[1]), float(w[2])) self[-1].append(Atom(w[3], coo)) elif n_F < len(self.definition): F = (float(w[0]), float(w[1]), float(w[2])) self[-1][n_F].F = F n_F += 1 if n_F == len(self.definition): cycle = False
"""Test Hirshfeld for spin/no spin consitency""" from ase import Atom from gpaw import GPAW from ase.parallel import parprint from gpaw.analyse.hirshfeld import HirshfeldPartitioning from gpaw import FermiDirac from gpaw.cluster import Cluster from gpaw.test import equal h = 0.25 box = 3 atoms = Cluster() atoms.append(Atom('H')) atoms.minimal_box(box) volumes = [] for spinpol in [False, True]: calc = GPAW(h=h, occupations=FermiDirac(0.1, fixmagmom=True), experimental={'niter_fixdensity': 2}, spinpol=spinpol) calc.calculate(atoms) volumes.append(HirshfeldPartitioning(calc).get_effective_volume_ratios()) parprint(volumes) equal(volumes[0][0], volumes[1][0], 4e-9)