コード例 #1
0
def main():
    # Create EAMPotential
    eamPotentials = [EAMPotential("U", 92, 238.03, embed, density)]
    pairPotentials = [Potential('U', 'U', pair_UU)]

    cutoff = 8.0
    #nrho = 962 # n points density
    nrho = 5000  # n points density
    #drho = 0.00103950 # distance points density
    drho = 0.02  # distance points density

    #nr = 1462 # n points embed & Vpair
    nr = 5000  # n points embed & Vpair
    dr = cutoff / nr  # distance points embed & Vpair

    from atsim.potentials import writeFuncFL

    with open("U2.eam", 'wb') as outfile:
        writeSetFL(nrho,
                   drho,
                   nr,
                   dr,
                   eamPotentials,
                   pairPotentials,
                   out=outfile,
                   comments=['Spline Uranium as U.eam', '', ''])
コード例 #2
0
  def testWriteSetFL(self):
    """Test creation of DYNAMO setfl formatted file for use with lammps pair_style eam/alloy"""
    with open( os.path.join(_getResourceDirectory(), 'AlCu.eam.alloy'), 'r') as infile:
      expectEAMTable = _parseSetFL(infile)

    comments = [
    '##Al-Cu EAM potentials from J. Cai and Y.Y. Ye##',
    '##Phys. Rev. B 54, 8398-8410 (1996).############',
    '################################################']

    alEmbedFunc = TableReader(_openResource('setfl_AlEmbed.table'))
    alElectronDensity = TableReader(_openResource('setfl_AlDensity.table'))
    cuEmbedFunc = TableReader(_openResource('setfl_CuEmbed.table'))
    cuElectronDensity = TableReader(_openResource('setfl_CuDensity.table'))

    pairpot_Al_Al = TableReader(_openResource('setfl_AlAlPair.table'))
    pairpot_Cu_Al = TableReader(_openResource('setfl_CuAlPair.table'))
    pairpot_Cu_Cu = TableReader(_openResource('setfl_CuCuPair.table'))

    eampots = [
      potentials.EAMPotential('Al', 13, 26.982,  alEmbedFunc, alElectronDensity, latticeConstant = 4.05,  latticeType = 'FCC'),
      potentials.EAMPotential('Cu', 29, 63.546, cuEmbedFunc, cuElectronDensity, latticeConstant = 3.615, latticeType = 'FCC')]

    pairpots = [
      Potential('Al', 'Al', pairpot_Al_Al),
      Potential('Cu', 'Al', pairpot_Cu_Al),
      Potential('Cu', 'Cu', pairpot_Cu_Cu) ]

    nrho = 1000
    drho = 1.0396723078e+00

    nr = 3000
    dr = 2.2282427476e-03

    cutoff = 6.6825000000e+00

    actualEAMTable = StringIO()
    potentials.writeSetFL(
      nrho, drho,
      nr, dr,
      eampots,
      pairpots,
      comments = comments,
      out = actualEAMTable,
      cutoff = cutoff)
    actualEAMTable.seek(0)
    actualEAMTable = _parseSetFL(actualEAMTable)

    from . import testutil
    testutil.compareCollection(self,expectEAMTable, actualEAMTable, places = 3)
コード例 #3
0
    def createPot(self):
        eamPotentials = self.getEamPotentials()
        pairPotentials = self.getPairPotentials()

        with open(self.fileName, 'wb') as outfile:
            writeSetFL(
                self.nrho,
                self.drho,
                self.nr,
                self.dr,
                eamPotentials,
                pairPotentials,
                out=outfile,
                comments=[
                    self.comment, "", ""
                ])  # <-- Note: title lines given as list of three strings
コード例 #4
0
def main():
    eamPotentials, pairPotentials = makePotentialObjects()

    # Perform tabulation
    # Make tabulation
    nrho = 2000
    drho = 0.05

    nr = 2000
    dr = 0.003

    with open("Zhou_AlCu.eam.alloy", 'w') as outfile:
        writeSetFL(
            nrho, drho,
            nr, dr,
            eamPotentials,
            pairPotentials,
            out=outfile,
            comments=['Zhou Al Cu', "", ""])  # <-- Note: title lines given as list of three strings
コード例 #5
0
def main():
    # Create EAMPotential
    f_UU = buck(294.640000, 0.327022, 0.0)
    eamPotentials = [EAMPotential("U", 92, 238.03, embed, density)]
    pairPotentials = [Potential('U', 'U', f_UU)]

    nrho = 50000
    drho = 0.001

    nr = 12000
    dr = 0.001

    from atsim.potentials import writeFuncFL

    with open("U.eam", 'wb') as outfile:
        writeSetFL(nrho,
                   drho,
                   nr,
                   dr,
                   eamPotentials,
                   pairPotentials,
                   out=outfile,
                   comments=['Buckingham Uranium as U.eam', '', ''])
コード例 #6
0
  def testWriteSetFLFromParameters(self):
    """Test that lammps.potentials.writeSetFL() can generate the Al_zhou.eam.alloy file from LAMMPS distribution"""

    with open(os.path.join(_getResourceDirectory(), 'Al_zhou.eam.alloy'), 'r') as infile:
      expectEAMTable = _parseSetFL(infile)

    comments = [
      '#-> LAMMPS Potential File in DYNAMO 86 setfl Format <-#',
      '# Zhou Al Acta mater(2001)49:4005',
      '# Implemented by G. Ziegenhain (2007) [email protected]']

    #Density function
    def densityFunction(r):
      beta = 3.702623
      r_e  = 2.886166
      lamb = 0.790264
      f_e  = 1.392302
      num = f_e * math.exp( -beta * ( (r/r_e) - 1.0) )
      den = 1.0 + (( (r/r_e) - lamb )**20)
      return num/den

    #Embedding function
    def subembed(i, F_ni, rho_n, rho):
      return F_ni * ((rho/rho_n) - 1.0)**float(i)

    def embeddingFunction(rho):
      rho_e = 20.226537
      rho_n = 0.85 * rho_e
      rho_o = 1.15 * rho_e
      nu = 0.779208
      if rho < rho_n:
        return subembed(0, -2.806783, rho_n, rho) + \
               subembed(1, -0.276173, rho_n, rho) + \
               subembed(2,  0.893409, rho_n, rho) + \
               subembed(3, -1.637201, rho_n, rho)
      elif rho_n <= rho < rho_o:
        return subembed(0, -2.806783, rho_e, rho) + \
               subembed(1, -0.276173, rho_e, rho) + \
               subembed(2,  0.893409, rho_e, rho) + \
               subembed(3, -1.637201, rho_e, rho)
      else:
        return -2.829437 * ( 1.0 - math.log( (rho/rho_e)**nu)) * (rho/rho_e)**nu

    #Pair potential
    def ppotfunc(r):
      A = 0.251519
      alpha = 6.94219
      r_e = 2.886166
      kappa = 0.395132
      B =   0.313394
      beta = 3.702623
      lamb = 0.790264
      return ((A * math.exp( -alpha* ( (r/r_e) - 1.0) ))/ (1.0 + ( (r/r_e - kappa)**20))) - \
             ((B * math.exp( -beta * ( (r/r_e) - 1.0) ))/ (1.0 + ( (r/r_e - lamb)**20)))
    alpp = potentials.Potential('Al', 'Al', ppotfunc)

    nrho =  10001
    drho =  0.00559521603477821424
    nr   =  10001
    dr   =  0.00101014898510148996
    cutoff = 10.10250000000000092371
    eampots = [
      potentials.EAMPotential('Al', 1, 26.982,  embeddingFunction, densityFunction, latticeConstant = 4.05,  latticeType = 'FCC')]

    pairpots = [ alpp ]

    actualEAMTable = StringIO()
    potentials.writeSetFL(
      nrho, drho,
      nr, dr,
      eampots,
      pairpots,
      comments = comments,
      out = actualEAMTable,
      cutoff = cutoff )
    actualEAMTable.seek(0)
    actualEAMTable = _parseSetFL(actualEAMTable)

    from . import testutil
    testutil.compareCollection(self,expectEAMTable, actualEAMTable, places = 3, percenttolerance = 7.0)
コード例 #7
0
    def testExampleA_Density(self):
        """Test density functions correctly defined for EAM tabulation documentation example 2a"""
        exampleModule = _loadModule(self.test_nameA)

        shutil.copyfile(
            os.path.join(_getLAMMPSResourceDirectory(),
                         "setfl_pair.lmpstruct"),
            os.path.join(self.tempdir, "structure.lmpstruct"))
        shutil.copyfile(
            os.path.join(_getLAMMPSResourceDirectory(), "calc_energy.lmpin"),
            os.path.join(self.tempdir, "calc_energy.lmpin"))

        oldpwd = os.getcwd()
        os.chdir(self.tempdir)
        try:

            def nullfunc(r):
                return 0.0

            eamPotentials, pairPotentials = exampleModule.makePotentialObjects(
            )
            pairPotentials = None

            pairPotentials = [
                Potential("Cu", "Cu", nullfunc),
                Potential("Al", "Al", nullfunc),
                Potential("Al", "Cu", nullfunc)
            ]

            # Create EAMPotential
            def embed(rho):
                return rho

            for epot in eamPotentials:
                epot.embeddingFunction = embed

            nrho = 50000
            drho = 0.001

            nr = 12000
            dr = 0.001

            from atsim.potentials import writeSetFL

            with open("table.set", 'w') as outfile:
                writeSetFL(nrho,
                           drho,
                           nr,
                           dr,
                           eamPotentials,
                           pairPotentials,
                           comments=['Zhou Al Cu', "", ""],
                           out=outfile)

            inputExpect = [
                (2.0 * 1.218017211, "Cu Cu"),  # Cu Cu
                (2.0 * 1.716990097, "Al Al"),  # Al Al
                (1.218017211 + 1.716990097, "Al Cu")  # Al Cu
            ]

            for expect, potmap in inputExpect:
                with open("potentials.lmpinc", "w") as potfile:
                    potfile.write("pair_style eam/alloy\n")
                    potfile.write("pair_coeff * * table.set " + potmap + "\n")
                runLAMMPS()
                energy = extractLAMMPSEnergy()
                self.assertAlmostEqual(expect, energy, msg=potmap)

            # Now repeat for triplet of atoms
            shutil.copyfile(
                os.path.join(_getLAMMPSResourceDirectory(),
                             "setfl_triplet.lmpstruct"),
                os.path.join(self.tempdir, "structure.lmpstruct"))
            dens_Cu = [
                p.electronDensityFunction for p in eamPotentials
                if p.species == "Cu"
            ][0]
            dens_Al = [
                p.electronDensityFunction for p in eamPotentials
                if p.species == "Al"
            ][0]
            hyp = 3.818376618407357
            inputExpect = [
                (4 * dens_Cu(2.7) + 2 * dens_Cu(hyp), "Cu Cu"),  # Cu Cu
                (4 * dens_Al(2.7) + 2 * dens_Al(hyp), "Al Al"),  # Al Al
                (2 * dens_Cu(2.7) + 2 * dens_Cu(hyp) + \
                    2*dens_Al(2.7), "Al Cu"),  # Al Cu
                (2 * dens_Al(2.7) + 2 * dens_Al(hyp) + \
                    2*dens_Cu(2.7), "Cu Al")  # Cu Al
            ]
            for expect, potmap in inputExpect:
                with open("potentials.lmpinc", "w") as potfile:
                    potfile.write("pair_style eam/alloy\n")
                    potfile.write("pair_coeff * * table.set " + potmap + "\n")
                runLAMMPS()
                energy = extractLAMMPSEnergy()
                self.assertAlmostEqual(expect, energy, msg=potmap)

        finally:
            os.chdir(oldpwd)
コード例 #8
0
    def testExampleA_Pair(self):
        """Test pair-potentials correctly defined for EAM tabulation documentation example 2a"""
        exampleModule = _loadModule(self.test_nameA)

        shutil.copyfile(
            os.path.join(_getLAMMPSResourceDirectory(),
                         "setfl_pair.lmpstruct"),
            os.path.join(self.tempdir, "structure.lmpstruct"))
        shutil.copyfile(
            os.path.join(_getLAMMPSResourceDirectory(), "calc_energy.lmpin"),
            os.path.join(self.tempdir, "calc_energy.lmpin"))

        inputExpect = [
            (1.24246478E-02, "Al Al"),  # Al Al
            (-0.121863537, "Al Cu"),  # Al Cu
            (-0.179150283, "Cu Cu")  # Cu Cu
        ]

        oldpwd = os.getcwd()
        os.chdir(self.tempdir)
        try:
            _eampotentials, pairPotentials = exampleModule.makePotentialObjects(
            )
            eamPotentials = None

            # Create EAMPotential
            def density(r):
                return 0.0

            def embed(rho):
                return 0.0

            eamPotentials = [
                EAMPotential("Cu", 29, 63.55, embed, density),
                EAMPotential("Al", 13, 26.98, embed, density)
            ]

            nrho = 50000
            drho = 0.001

            nr = 12000
            dr = 0.001

            from atsim.potentials import writeSetFL
            with open("table.set", 'w') as outfile:
                writeSetFL(nrho,
                           drho,
                           nr,
                           dr,
                           eamPotentials,
                           pairPotentials,
                           comments=['Zhou Al Cu', "", ""],
                           out=outfile)

            for expect, potmap in inputExpect:
                with open("potentials.lmpinc", "w") as potfile:
                    potfile.write("pair_style eam/alloy\n")
                    potfile.write("pair_coeff * * table.set " + potmap + "\n")
                runLAMMPS()
                energy = extractLAMMPSEnergy()
                self.assertAlmostEqual(expect, energy, msg=potmap)
        finally:
            os.chdir(oldpwd)