Skip to content

Commit

Permalink
Update stat_langevin.py
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfaria authored Jan 8, 2022
1 parent bdf0bdf commit 595061f
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions stat_langevin.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,13 @@

# coding: utf-8

# Source
#
# https://aip.scitation.org/doi/abs/10.1063/1.4802990
#
# http://hockygroup.hosting.nyu.edu/exercise/langevin-dynamics.html
Parameters to be used

ks = 2

#gamma**2 >> 4*k overdamped
gamma = 3 #10
kBT = 1.0

dt = 0.001
tMax = 50

# Sample conditions

N = 10**2 #int(argv[1])
x_init = 0.3
v_init = 0.
# In[1]:


import pylab as plt
import numpy as np
import time as tm
from sys import argv


# In[2]:


# Harmonic force

def force(x, *args):
Expand All @@ -42,7 +16,6 @@ def force(x, *args):
f = -ks*(x)
return f


# Return the time lenght

def Time_len(tMax, dt):
Expand All @@ -56,10 +29,8 @@ def Time_len(tMax, dt):

return len(L)


# In[3]:


# Stochastic evolution
# for further explanation, read: https://aip.scitation.org/doi/abs/10.1063/1.4802990

Expand All @@ -78,7 +49,6 @@ def random_velocity_update(v,gamma,kBT,dt):
v_dt = c1*v + c2*R
return v_dt


def BAOAB_method(x_init, v_init, tMax, dt, gamma, kBT, ks):

x = x_init
Expand Down Expand Up @@ -116,7 +86,6 @@ def BAOAB_method(x_init, v_init, tMax, dt, gamma, kBT, ks):

# In[4]:


###################### MAIN #############################

# Parameters and time
Expand Down Expand Up @@ -156,7 +125,6 @@ def BAOAB_method(x_init, v_init, tMax, dt, gamma, kBT, ks):

t = np.array(time)


### Statistics

# Mean
Expand All @@ -171,23 +139,8 @@ def BAOAB_method(x_init, v_init, tMax, dt, gamma, kBT, ks):
end = tm.time()
print(end-start)


# In[5]:


############ Printing data ################

#output = np.array([M_x2, M_x, t])

#data_path = "/home/fariaart/Dropbox/data_%s.txt" %N
#data_path = "/home/des01/mbonanca/fariaart/Resultados/Doutorado/Lutz/over_data_%s.txt" %N
#with open(data_path , "w+") as data:
#np.savetxt(data, output.T, fmt='%f')


# In[6]:


############ Plotting data ################

# Variance plot
Expand All @@ -198,10 +151,8 @@ def BAOAB_method(x_init, v_init, tMax, dt, gamma, kBT, ks):
plt.xlabel(r' $t$', fontsize = 12)

plt.legend(loc='lower center')
#plt.savefig('/home/fariaart/Dropbox/Pesquisa/Doutorado/Lutz/figuras/var_mean_over_kk/HO_brown/under_2_1.png', transparent=False)
plt.figure()


# Mean value plot

plt.plot(t, M_x, label= 'num' )
Expand All @@ -211,6 +162,4 @@ def BAOAB_method(x_init, v_init, tMax, dt, gamma, kBT, ks):
#plt.ylim(-0.07,0.07)

plt.legend(loc='upper center')
#plt.savefig('/home/fariaart/Dropbox/Pesquisa/Doutorado/Lutz/figuras/var_mean_over_kk/HO_brown/under_2_2.png', transparent=False)
plt.figure()

0 comments on commit 595061f

Please sign in to comment.