Пример #1
0
def mc_move(i, E_old, X_old, Xeq, forceMatrix, E_m_minus_1, E_m_minus_2, L, a1,
            a2, a3):
    import copy
    import harmonic as ha

    Xtemp = copy.deepcopy(X_old)
    X_temp = getNewConfig(i, Xtemp, L)
    X_new = copy.deepcopy(X_temp)
    E_new, energyPerParticle = getEnergyConfig(X_new, a1, a2, a3)
    P_old2new = getProbTransition(E_new, E_old, E_m_minus_1, E_m_minus_2)
    hasMoved = False

    if (P_old2new >= random()):
        hasMoved = True

        ########################################################################################
        import os
        c = counter()
        # if (c % 5 == 0):
        # if (c % 100 == 0):
        if (c % 1000 == 0):
            nAtoms = len(X_old)
            out = "/Users/chinchay/Documents/9_Git/reverseEnergyPartitioning/ovitoPlots/moves." + str(
                c) + ".xyz"
            pos = str(nAtoms) + "\n\n"
            for i in range(len(X_new)):
                pos += "H   " + str(X_new[i][0]) + "   " + str(
                    X_new[i][1]) + "   " + str(X_new[i][2]) + "\n"
            #
            pos += "\n"

            f = open(out, "w")
            f.write(pos)
            f.close()

            #######################################################
            rHyper, deltaEharmonic = ha.getHarmonicEnergy(
                X_new, Xeq, forceMatrix)
            out = "/Users/chinchay/Documents/9_Git/reverseEnergyPartitioning/ovitoPlots/rHyperEHarmonic" + str(
                c) + ".txt"
            s = str(rHyper) + " , " + str(deltaEharmonic) + " , " + str(
                E_new) + "\n"
            # s = str(rHyper) + " , " + str(deltaEharmonic) + "\n"
            f = open(out, "w")
            f.write(s)
            f.close()

        return E_new, X_new, hasMoved
    #
    X = copy.deepcopy(X_old)
    return E_old, X, hasMoved
def mc_move(i, E_old, structX_old, structXeq, forceMatrix, E_m_minus_1, E_m_minus_2, L, radio, dRneighborsFromEachSite):
    import copy
    import harmonic as ha

    structXtemp  = copy.deepcopy(structX_old)
    structX_temp = getNewConfig(i, structXtemp, L)
    structX_new  = copy.deepcopy(structX_temp)
    E_new  = getEnergyConfig(structX_new, radio, dRneighborsFromEachSite)
    P_old2new = getProbTransition(E_new, E_old, E_m_minus_1, E_m_minus_2)
    hasMoved = False

    if ( P_old2new >= random() ):
        hasMoved = True

        ########################################################################################
        import os
        c = counter()
        # if (c % 5 == 0):
        # if (c % 100 == 0):
        if (c % 1000 == 0):
            nAtoms = structX_old.num_sites
            out = "/Users/chinchay/Documents/9_Git/reverseEnergyPartitioning/ovitoPlots/moves." + str(c) + ".xyz"
            pos = str(nAtoms) + "\n\n"
            for i in range(nAtoms):
                pos += str(structX_new[i].specie) + str(structX_new[i].x) + "   " + str(structX_new[i].y) + "   " + str(structX_new[i].z) + "\n"
            #
            pos += "\n"

            f = open(out, "w")
            f.write(pos)
            f.close()

            #######################################################
            rHyper, deltaEharmonic = ha.getHarmonicEnergy(structX_new.cart_coords, structXeq.cart_coords, forceMatrix)
            out = "/Users/chinchay/Documents/9_Git/reverseEnergyPartitioning/ovitoPlots/rHyperEHarmonic" + str(c) + ".txt"
            s = str(rHyper) + " , " + str(deltaEharmonic) + " , " +  str(E_new) + "\n"
            # s = str(rHyper) + " , " + str(deltaEharmonic) + "\n"
            f = open(out, "w")
            f.write(s)
            f.close()


        return E_new, structX_new, hasMoved
    #
    structX = copy.deepcopy(structX_old)
    return E_old, structX, hasMoved
Пример #3
0
def move(i, X, Xeq, forceMatrix, L):
    X = mc.getNewConfig(i, X, L)
    rHyper, deltaEharmonic = ha.getHarmonicEnergy(X, Xeq, forceMatrix)
    return rHyper, deltaEharmonic