Exemple #1
0
def cms(s, sel):
    at = getAtomtypes()
    if at is None:
        msg().error(
            "Atom-types information not available, calculating average.")
    if s is None:
        return None
    s = Structure(s)
    s.setCarthesian()
    w = Vector(0.0, 0.0, 0.0)
    M = 0.0
    try:
        for i, nx, ny, nz in sel:
            if i < len(s) and i >= 0:
                try:
                    m = float(s.info.getRecordForAtom(i).mass)
                except:
                    m = float(
                        at.getRecordForElement(
                            s.info.getRecordForAtom(i).element).mass)
                w = w + m * (s[i] + nx * s.basis[0] + ny * s.basis[1] +
                             nz * s.basis[2])
                M = M + m
        w = (1.0 / M) * w
        return w
    except:
        msg().exception()
        msg().error("CMS not aplicable, calculating an average.")
        return average(s, sel)
Exemple #2
0
 def showStructureWindow(self):
     if self.swin is None:
         self.swin = StructureWindow(title="p4vasp Structure",
                                     atomtypes=getAtomtypes())
         self.swin.structure_drawer.setRadiusFactor(0.5 *
                                                    self.radius_factor)
     self.swin.show()
Exemple #3
0
    def __init__(self):
        Applet.__init__(self)
        self.win = None
        self.a = None
        self.dir = 2
        self.n = 0
        self.value = 0.0
        #    self.sigmax=0
        #    self.sigmay=0
        #    self.sigmaz=0
        self.sh = 0
        self.sv = 0
        self.n1 = 0
        self.n2 = 0
        self.n3 = 0
        self.chgname = "PARCHG"
        self.sd = None
        self.lo = 0
        self.hi = 1
        self.inv = 0
        self.navigator = None
        self.clamp_type = 0
        self.charge = None
        self.smooth_charge = None
        self.structure = None
        self.minimum = 0
        self.maximum = 0
        self.average = 0
        self.sigma = 0
        self.src = 0
        self.mode = 0
        self.interpolation = 0
        self.postinterpolation = 0
        self.postsigma = 0
        self.postn = 0
        self.atomtypes = getAtomtypes()
        self.structure_offset = 0.0
        self.brightness = 0.0
        self.contrast = 1.0
        self.multiple = (1, 1, 1)
        self.hide_atoms = []
        self.b1 = cmatrix.Vector(0, 0, 0)
        self.b2 = cmatrix.Vector(0, 0, 0)
        self.bz = cmatrix.Vector(0, 0, 0)

        #DUMMY ATTRIBUTES -for compatibility with StructureWindowControlApplet
        self.chgcar = None
        self.index = 0
        self.sequencetype = self.INITIAL_SEQUENCE
        self.arrowstype = 0
        self.cell_centering = 0
    def showStructureWindow(self):
        if self.swin is None:
            l = [(0, 0, 0, 0)]
            for a in applets():
                if isinstance(a, StructureWindowApplet):
                    if a.swin is not None:
                        w = a.swin.win
                        if w is not None:
                            l.append((w.x, w.y, w.w, w.h))
            xx = max(map(lambda x: x[0] + x[2], l))
            yy = max(map(lambda x: x[1] + x[3], l))
            if yy <= 600:
                xx = 0
            else:
                yy = 0
            self.swin = StructureWindow(x=xx,
                                        y=yy,
                                        w=500,
                                        h=400,
                                        title="p4vasp Structure",
                                        atomtypes=getAtomtypes())
            self.swin.setRadiusFactor(0.5 * self.radius_factor)
#      self.swin.setBackground(1,1,1)
        self.swin.show()
Exemple #5
0
 def __init__(self,name,file_extension,paintCreator):
     self._name=name
     self._file_extension=file_extension
     self.paint=[paintCreator]
     self.atomtypes=getAtomtypes()