Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94915450
Step2.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Dec 11, 09:08
Size
1 KB
Mime Type
text/x-python
Expires
Fri, Dec 13, 09:08 (2 d)
Engine
blob
Format
Raw Data
Handle
22899178
Attached To
rMARAFFO Master-cycle
Step2.py
View Options
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
scipy
as
sp
from
MD
import
*
nsteps
=
2000
dt
=
0.0046
N
,
L
,
pos
,
vel
=
read_pos_vel
(
'sampleT94.4.dat'
)
# Run MD simulation
output
=
run_NVE
(
pos
,
vel
,
L
,
nsteps
,
N
,
dt
)
# Plot g(r)
plt
.
plot
(
output
[
'gofr'
][
'r'
],
output
[
'gofr'
][
'g'
])
plt
.
ylabel
(
r'$g(r)$'
)
plt
.
xlabel
(
r'$r$'
)
plt
.
show
()
# peak analysis
smoothed
=
sp
.
signal
.
savgol_filter
(
output
[
'gofr'
][
'g'
],
51
,
3
)
peaks_g
=
sp
.
signal
.
find_peaks
(
smoothed
)
for
p
in
peaks_g
:
print
(
"Peak g(r) found in: "
)
# Plot S(k)
plt
.
plot
(
output
[
'sofk'
][
'k'
],
output
[
'sofk'
][
's'
])
plt
.
ylabel
(
r'$S(k)$'
)
plt
.
xlabel
(
r'$k$'
)
plt
.
show
()
# Write g(k) into a file
np
.
savetxt
(
'gofr.dat'
,
np
.
column_stack
((
output
[
'gofr'
][
'r'
],
output
[
'gofr'
][
'g'
])))
# Write S(k) into a file
np
.
savetxt
(
'sofk.dat'
,
np
.
column_stack
((
output
[
'sofk'
][
'k'
],
output
[
'sofk'
][
's'
])))
###################
# Direct Sampling #
###################
N
,
L
,
pos
,
vel
=
read_pos_vel
(
'sampleT94.4.dat'
)
# Run MD simulation with direct sampling on
output
=
run_NVE
(
pos
,
vel
,
L
,
nsteps
,
N
,
dt
,
direct_sofk
=
True
)
# Plot S(k) direct
plt
.
plot
(
output
[
'sofk_direct'
][
'qvec'
],
output
[
'sofk_direct'
][
'sofk'
],
'o'
)
plt
.
ylabel
(
'S(k)'
)
plt
.
xlabel
(
'k'
)
plt
.
show
()
# Write S(k) direct into a file
np
.
savetxt
(
'sofk-direct.dat'
,
np
.
column_stack
((
output
[
'sofk_direct'
][
'qvec'
],
output
[
'sofk_direct'
][
'sofk'
])))
Event Timeline
Log In to Comment