コード例 #1
0
ファイル: molecule.py プロジェクト: maxivanoff/fftoolbox-app
 def __init__(self, name=None, atoms=None, multipoles=('cartesian',2), sym=False):
     Multipole.__init__(self, name)
     self.sym = sym
     self.set_atoms(atoms)
     self.set_groups()
     self.set_sym_sites()
     self.set_multipole_matrix(multipoles)
コード例 #2
0
def macclaurin_test():

    # setup the grid
    g = Grid(128, 256, rlim=(0, 0.5), zlim=(-0.5, 0.5))

    # create a MacLaurin spheriod on the grid
    ms = MacLaurinSpheroid(g, 0.25, 0.1)

    # plot the density
    dens = ms.density()

    plt.clf()
    plt.imshow(np.transpose(dens),
               origin="lower",
               interpolation="nearest",
               extent=[g.rlim[0], g.rlim[1], g.zlim[0], g.zlim[1]])

    ax = plt.gca()
    ax.set_aspect("equal")
    plt.savefig("dens.png")

    # plot the analytic potential
    phi_analytic = ms.phi()

    plt.clf()
    plt.imshow(np.log10(np.abs(np.transpose(phi_analytic))),
               origin="lower",
               interpolation="nearest",
               extent=[g.rlim[0], g.rlim[1], g.zlim[0], g.zlim[1]])

    plt.colorbar()
    ax = plt.gca()
    ax.set_aspect("equal")
    plt.savefig("phi_analytic.png")

    # compute the multipole expansion and sample the potential
    center = (0.0, 0.0)
    m = Multipole(g, 12, 2 * g.dr, center=center)
    m.compute_expansion(dens)

    phi = g.scratch_array()

    for i in range(g.nr):
        for j in range(g.nz):
            phi[i, j] = m.phi(g.r[i], g.z[j])

    # plot the potential
    plt.clf()
    plt.imshow(np.log10(np.abs(np.transpose(phi))),
               origin="lower",
               interpolation="nearest",
               extent=[g.rlim[0], g.rlim[1], g.zlim[0], g.zlim[1]])

    plt.colorbar()
    ax = plt.gca()
    ax.set_aspect("equal")
    plt.savefig("phi.png")
コード例 #3
0
ファイル: groups.py プロジェクト: maxivanoff/fftoolbox-app
 def __init__(self, center, count, name=None, ff=None, sym=False):
     self.carbon = center
     self.oxygen = filter(lambda a: a.element=='O', center.neighbors)[0]
     self.hydrogens = filter(lambda a: a.element=='H', center.neighbors)
     Multipole.__init__(self, name, ff)
     self.atoms = [self.carbon, self.oxygen]
     self.name = 'CO_%i' % count
     self.carbon.name = 'C%i_CO' % count 
     self.oxygen.name = 'O%i_CO' % count 
     if len(self.hydrogens)==1:
         self.hydrogens[0].name='H%i_CO' % count
コード例 #4
0
ファイル: atom.py プロジェクト: maxivanoff/fftoolbox
 def __init__(self, element=None, coordinates=None, index=None, multipoles=None, representation=None, sym=False):
     if multipoles is None: multipoles = {}
     self.sym = sym
     Multipole.__init__(self, name=element, origin=coordinates, representation=representation)
     Atom.__init__(self, index=index, element=element, coordinates=coordinates)
     try:
         charge = multipoles['charge']
     except KeyError:
         charge = 0.
     center = FFSite(index=index, element=element, coordinates=coordinates, charge=charge, attachment=self)
     self.add_site(center)
     self.frame = None
コード例 #5
0
ファイル: groups.py プロジェクト: maxivanoff/fftoolbox-app
 def get_dipole_norm(self):
     dipole = Multipole.get_dipole(self)
     CX = np.zeros(3)
     for a in self.nonhydrogens:
         CX += a.coordinates - self.center.coordinates
     sign = np.sign(np.dot(dipole, CX))
     return sign*np.linalg.norm(dipole)
コード例 #6
0
ファイル: molecule.py プロジェクト: maxivanoff/fftoolbox
 def __init__(self, data):
     self.data = data
     try:
         name = data['name']
     except KeyError:
         name = None
     try:
         self.theory = data['theory']
     except KeyError:
         self.theory = None
     try:
         representation = data['representation']
     except KeyError:
         representation = None
     try:
         sym = data['symmetry']
     except KeyError:
         sym = False
     try:
         self.energy = data['energy']
     except KeyError:
         self.energy = None
     try:
         atoms = data['atoms']
     except KeyError:
         atoms = None
     try:
         self.hybrid_atoms = data['hybridizations']
     except KeyError:
         self.hybrid_atoms = {}
     logger.info('Start assembling %s Molecule\ntheory: %r\nsymmetry: %r\nrepresentation: %r' % (name, self.theory, sym, representation))
     Multipole.__init__(self, name=name, representation=representation)
     MoleculeWithFrames.__init__(self, name=name, atoms=atoms, sym=sym, framed_atoms=self.hybrid_atoms.keys())
     self.set_hybridizations()
     self.set_frames_from_sites() # in case extra points are loaded from the file
     self.set_sym_sites()
     if representation is not None:
         self.set_multipole_matrix()
     logger.info("Names of equivalent sites: %s" % self.sites_names_eq)
     logger.info("Names of non-equivalent sites: %s" % self.sites_names_noneq)
     logger.info('%s Molecule is created' % (self.name))
コード例 #7
0
ファイル: groups.py プロジェクト: maxivanoff/fftoolbox-app
 def __init__(self, center, count, name=None, ff=None, sym=False):
     self.center = center
     self.nonhydrogens = filter(lambda a: a.element!='H', center.neighbors)
     self.hydrogens = filter(lambda a: a.element=='H', center.neighbors)
     Multipole.__init__(self, name, origin=self.get_origin())
     self.atoms = [center] + self.hydrogens
     cname = self.center.element
     if self.hydrogens:
         neighbor_name = 'H'
         neighbors = self.hydrogens
     else:
         neighbor_name = self.nonhydrogens[0].element
         neighbors = self.nonhydrogens
     if [neighbor_name]*3==[a.element for a in neighbors]:
         self.name = cname + neighbor_name + '3_%i' % (count)
         self.type = cname + neighbor_name + '3'
         self.center.name = '%s%i_%s%s3' % (cname, count, cname, neighbor_name)
     elif [neighbor_name]*2==[a.element for a in neighbors]:
         self.name = cname + neighbor_name + '2_%i' % (count)
         self.type = cname + neighbor_name + '2'
         self.center.name = '%s%i_%s%s2'% (cname, count, cname, neighbor_name)
     elif [neighbor_name]*1==[a.element for a in neighbors]:
         self.name = cname + neighbor_name + '1_%i' % (count)
         self.type = cname + neighbor_name + '1'
         self.center.name = '%s%i_%s%s1'% (cname, count, cname, neighbor_name)
     elif [neighbor_name]*4 == [a.element for a in neighbors]:
         self.name = cname + neighbor_name+'4'
         self.type = cname + neighbor_name+'4'
         self.center.name = cname
     else:
         raise ValueError('Not a buired group')
     for i,a in enumerate(neighbors):
         if sym is True:
             a.name = neighbor_name + center.name[1:]
         else:
             a.name = neighbor_name + center.name[1:] + '_' + str(i)