Exemplo n.º 1
0
def ACMD_instance(rng, N, beads, dpotential, beta, T, deltat):

    swarmobject = MD_System.swarm(N)
    MD_System.system_definition(beta, beads, 1, MD_System.dpotential)
    #gamma = 1.0
    #w_arr = beads**0.5/(beta*gamma)*np.ones(beads)
    #MD_System.w_arr = MD_System.rearrange(w_arr)
    #MD_System.w_arr[0] = 0.0

    importlib.reload(Velocity_verlet)

    swarmobject.q = np.zeros(
        (swarmobject.N, MD_System.dimension, MD_System.n_beads))
    rand_boltz = np.random.RandomState(rng)
    swarmobject.p = rand_boltz.normal(0.0, swarmobject.m / (MD_System.beta),
                                      np.shape(swarmobject.q))

    pool = mp.Pool(mp.cpu_count())
    Matsubara = 0
    CMD = 0

    n_inst = 10
    func = partial(corr_function_upgrade, CMD, Matsubara, beads, swarmobject,
                   dpotential, MD_System.pos_op, MD_System.pos_op, T, deltat)
    results = pool.map(func, range(n_inst))

    pool.close()
    pool.join()
    return np.sum(results, 0) / n_inst
Exemplo n.º 2
0
def AQCMD_instance(rng, N, beads, dpotential, beta, T, deltat):
    swarmobject = MD_System.swarm(N)

    MD_System.system_definition(beta, beads, 2, MD_System.dpotential)
    importlib.reload(Velocity_verlet)

    rand_boltz = np.random.RandomState(2)
    print('beta', MD_System.beta, MD_System.beta_n)
    swarmobject.q = np.zeros(
        (swarmobject.N, MD_System.dimension, MD_System.n_beads)
    ) + 1.0  #np.random.rand(swarmobject.N,MD_System.dimension,MD_System.n_beads)
    swarmobject.p = rand_boltz.normal(0.0, swarmobject.m / (MD_System.beta_n),
                                      np.shape(swarmobject.q))

    # In the line above, 1.0 is should be replaced with beta, when required
    # Update: Done!!!
    QC_q = np.zeros((swarmobject.N, MD_System.dimension)) + 1.0
    QC_p = np.zeros_like(
        QC_q
    )  #rand_boltz.normal(0.0,swarmobject.m/(MD_System.beta),np.shape(QC_q))#np.zeros((swarmobject.N,MD_System.dimension))
    lambda_curr = np.zeros_like(swarmobject.q)

    pool = mp.Pool(mp.cpu_count())
    n_inst = 1
    func = partial(corr_function_QCMD, swarmobject, QC_q, QC_p, lambda_curr,
                   MD_System.pos_op, MD_System.pos_op, T, deltat, dpotential)
    results = pool.map(func, range(n_inst))
    #print('results',np.sum(results,0)/n_inst)
    pool.close()
    pool.join()
    return np.sum(results, 0) / n_inst
Exemplo n.º 3
0
def CMD_instance(beads, dpotential, beta):

    MD_System.system_definition(beta, beads, 1, dpotential)
    importlib.reload(Velocity_verlet)
    Centroid_mean_force.mean_force_calculation(dpotential)

    f = open(
        "/home/vgs23/Pickle_files/CMD_Force_Morse_B_{}_NB_{}_100_10.dat".
        format(MD_System.beta, MD_System.n_beads), 'rb')
    data = np.loadtxt(f)
    Q = data[:, 0]
    CMD_force = data[:, 1]

    xforce = scipy.interpolate.interp1d(Q, CMD_force, kind='cubic')
    return xforce
Exemplo n.º 4
0
def QCMD_instance(beads, dpotential, beta):
    MD_System.system_definition(beta, beads, 2, dpotential)
    importlib.reload(Velocity_verlet)
    N = 100
    n_sample = 1
    #QC_MF_calculation(dpotential,N,n_sample)

    f = open(
        "/home/vgs23/Pickle_files/QCMD_Force_B_{}_NB_{}_N_{}_nsample_{}_deltat_0.5_NQ_20.dat"
        .format(MD_System.beta, MD_System.n_beads, N, n_sample), 'rb')
    data = np.loadtxt(f)
    Q = data[:, 0]
    QCMD_force = data[:, 1]

    rforce = scipy.interpolate.interp1d(Q, QCMD_force, kind='cubic')
    plt.plot(Q, QCMD_force)
    plt.plot(Q, rforce(Q))
    plt.show()
    return rforce
Exemplo n.º 5
0
def Matsubara_instance(rng, N, M, dpotential, T, deltat):
    swarmobject = MD_System.swarm(N)
    MD_System.system_definition(8, M, 2, MD_System.dpotential)
    importlib.reload(Velocity_verlet)

    swarmobject.q = np.zeros(
        (swarmobject.N, MD_System.dimension, MD_System.n_beads))

    rand_boltz = np.random.RandomState(rng)
    swarmobject.p = rand_boltz.normal(0.0, swarmobject.m / MD_System.beta,
                                      np.shape(swarmobject.q))

    pool = mp.Pool(mp.cpu_count())
    Matsubara = 1
    CMD = 0

    n_inst = 10
    func = partial(corr_function_matsubara, CMD, Matsubara, M, swarmobject,
                   dpotential, MD_System.pos_op, MD_System.pos_op, T, deltat)
    results = pool.map(func, range(n_inst))
    pool.close()
    pool.join()
    return np.sum(results, 0) / n_inst
Exemplo n.º 6
0
            print(time.time() - start_time)
        Quan_arr /= (n_approx * swarmobj.N)

    for j in range(n_approx):
        traj_arr = Monodromy.ode_instance(swarmobj.q, swarmobj.p, tarr)
        Quan_arr += np.sum(Monodromy.detmqq(traj_arr), axis=1)
        thermalize(CMD, Matsubara, M, swarmobj, derpotential, deltat, 10, rng)

    return Quan_arr


N = 20
dim = 3
deltat = 1e-2
swarmobject = MD_System.swarm(N)
MD_System.system_definition(78943.7562025, 1, dim, MD_System.dpotential)
imp.reload(Velocity_verlet)
Monodromy.system_definition(N, dim)

rand_boltz = np.random.RandomState(1)
swarmobject.q = rand_boltz.rand(swarmobject.N, MD_System.dimension,
                                MD_System.n_beads)
swarmobject.p = rand_boltz.normal(0.0, swarmobject.m / (MD_System.beta),
                                  np.shape(swarmobject.q))

Matsubara = 0
CMD = 0
M = 0
T = 10.0
Marr = phase_space_average(CMD, Matsubara, M, swarmobject,
                           Monodromy.dpotential_He_aux, T, deltat, 1)
Exemplo n.º 7
0
        dsigma(q) * dsigma(q)
    )  #np.dot(dsigma(q[0],q[1]),p)/np.dot(dsigma(q[0],q[1]),dsigma(q[0],q[1]))
    p += myu * dsigma(q)


T = 4000  #5000*deltat#6.0
t = 0.0

rng = np.random.RandomState(2)
#p = rng.normal(0,1.0,(2,1))#np.array([[0.0],[1]])#np.random.randint(5,size=(2,1)) +1.0#np.array([0.0,1])
beads = 1
#((2,4))#np.array([[1.0],[0.0]])#np.random.randint(5,size=(2,1)) +0.0#np.array([1.0,0.0])
p = rng.normal(0, 1.0, (2, beads))
q = np.zeros_like(p) + 2.0

MD_System.system_definition(1.0, beads, 2, dpotential)
w_arr = MD_System.w_arr
w_arr = w_arr[1:]
print('w_arr', w_arr)

print('q', q)
print('p', p)

count = 0
qcx = []
qcy = []
if (1):
    while (abs(t - T) > 1e-4):
        constrained_vv(q, p, lambda_curr)
        t += deltat
Exemplo n.º 8
0
from numpy import linalg as LA
from numpy.fft import fft,ifft
from multiprocessing import Process
from Correlation_function import corr_function,corr_function_upgrade,corr_function_matsubara
#from MD_System import swarm,pos_op,beta,dimension,n_beads,w_n
import MD_System
import multiprocessing as mp
from functools import partial
import scipy
#from Langevin_thermostat import thermalize
#from Centroid_mean_force import CMF
#from External_potential import dpotential
#import Centroid_mean_force
import Velocity_verlet
import importlib
import time
import pickle
start_time = time.time()
from Matsubara_potential_hh import dpot_hh

deltat = 1e-2
M=3 
dimension = 2
MD_System.system_definition(8,M,dimension,MD_System.dpotential)
importlib.reload(Velocity_verlet)

swarmobject = MD_System.swarm(1)
swarmobject.q = np.zeros((swarmobject.N,MD_System.dimension,MD_System.n_beads))

print(np.shape(swarmobject.q))
#swarmobject.p = rand_boltz.normal(0.0,swarmobject.m/MD_System.beta,np.shape(swarmobject.q))
Exemplo n.º 9
0
        y = swarmobject.q[0,1,1]
        py = swarmobject.p[0,1,1]
        #curr =x
        if(count%1==0):
            #print(prev,curr)
            if( abs(x)<1e-3 and px<0.0 ):
                #print('herhe',count)
                Y.append(y)
                PY.append(py)
        #prev = curr
        t+=deltat
        count+=1


rand = np.random.RandomState(1)    
MD_System.system_definition(8,3,2,dpotential)
importlib.reload(Velocity_verlet)
swarmobject = MD_System.swarm(1)
#E = 0.08

def compute_P_section(E,Y,PY):
    for i in range(10):
        x0 = rand.uniform(-(0.5*E)**0.5,(0.5*E)**0.5)
        y0 = rand.uniform(-(0.5*E)**0.5,(0.5*E)**0.5)
        
        differ = E-potential(x0,y0)
        split = rand.uniform(0,2)
        px0 = (split*differ)**0.5
        py0 = ((2-split)*differ)**0.5
        swarmobject.q = np.array([[[x0],[y0]]]) 
        swarmobject.p = np.array([[[px0],[py0]]])