-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
72 lines (52 loc) · 1.75 KB
/
run.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
"""
This script runs "brownian_bead" and records the positions
to one file and Rg & Ree to another file.
"""
import brownian_bead as bb
import numpy as np
import os
nbeads_lst = (90, 100)
k_ev = 200
configuration = "circular"
Δt = .0001
t = []
tt = 0
for i in range(bb.N):
t.append(tt)
tt += Δt
for nbeads in nbeads_lst:
print(f"[a] Simulating {configuration} chain: {nbeads} beads, N = {bb.N}, Δt = {Δt}, k_ev = {k_ev}")
sim = bb.Simulation(nbeads, conf=configuration)
sim.advance(Δt, κ_ev=k_ev)
###################### 'write (wb)' only, no sense to ave pos, disable for multiple...
print("[b] Saving coordinates")
array0 = np.array(bb.all_sim_pos)
with open(f'pos_data/data/circular/k_ev=200/nbeads{nbeads}-k_ev{k_ev}.npy', 'wb') as f:
np.save(f, array0)
array1 = np.load(f'pos_data/data/circular/k_ev=200/nbeads{nbeads}-k_ev{k_ev}.npy')
# make sure arrays are the same
comparison = (array0 == array1) # don't need parantheses
equal_arrays = comparison.all()
if equal_arrays != True:
print(equal_arrays)
######################
Ree = []
for xy in bb.end_to_end:
Ree.append(np.sqrt(xy[0]**2 + xy[1]**2))
print("[c] Writing Rg & Ree")
file = open(f"simulated_data/circular/k_ev=200/ave_rg_ree_n{nbeads}-k_ev{k_ev}.dat", "w") # "a" vs "w"
for i, s in enumerate(bb.Rg):
a = str( bb.Rg[i] )
b = str( Ree[i] )
c = a + " " + b
file.write(c + '\n')
file.close()
# resetting brownian_bead.py variables for loop
bb.all_pos_xy = []
bb.all_sim_pos = []
bb.end_to_end = []
bb.Rg = []
if nbeads != nbeads_lst[-1]:
print("=========")
#os.system('cmd.exe /c shutdown /s')