-
Notifications
You must be signed in to change notification settings - Fork 0
/
quantity.py
53 lines (40 loc) · 1.1 KB
/
quantity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import numpy as np
m = 39.948E-23 / 6.02 # particle mass(SI)
kB = 1.38E-23 # Boltzmann constant(SI)
def potential(r1,r2):
epsilon = -0.0077 * (1.602E-19) # ε in L-J potential(SI)
sigma = 4.5 # σ in L-J potential(SI)
r12 = np.sqrt(np.dot(r2 - r1,r2-r1))
return 4*epsilon*((sigma/r12)**12-(sigma/r12)**6)
# The Kinetic energy
def K_E(map,m):
time = len(map)
K=[]
for t in range(time):
k_e=[]
a = map[t]
num = len(a)
for n in range(num):
P = a[n]
PP = np.array(P)
k_e.append((m*np.dot(PP,PP))/(2))
K.append(sum(k_e))
return K
# The potential energy
def pot(map):
time = len(map)
P=[]
for t in range(time):
p_e=[]
a = map[t]
num = len(a)
for i in range(num):
r1=a[i]
for j in range(num):
if j == i:
continue
else:
r2 = a[j]
p_e.append(potential(r1,r2))
P.append(sum(p_e))
return P