-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post equilibrium analysis #43
base: main
Are you sure you want to change the base?
Changes from all commits
778d917
b6860ac
7f6d5d9
0623171
2939e12
0a3be67
eff0f0d
b74534e
8af4ee9
25cc2fd
ef79380
45cbee4
c141637
2094721
efe2073
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,9 @@ def sampled(job): | |
def initialized(job): | ||
return job.isfile("trajectory.gsd") | ||
|
||
@MyProject.label | ||
def analyzed(job): | ||
return job.doc.get("analyzed") | ||
|
||
@directives(executable="python -u") | ||
@MyProject.operation | ||
|
@@ -131,6 +134,33 @@ def sample(job): | |
print("Simulation finished completed") | ||
print("-----------------------------") | ||
|
||
@MyProject.operation | ||
@MyProject.pre(sampled) | ||
@MyProject.post(analyzed) | ||
def analysis(job): | ||
from utils import avg_nn, rdf | ||
import numpy as np | ||
os.makedirs(os.path.join(job.ws, "analysis/rdf")) | ||
gsdfile = job.fn('trajectory_1.gsd') | ||
rdf = rdf(gsdfile, start=-30) | ||
x = rdf.bin_centers | ||
y = rdf.rdf | ||
peakx = max(x) | ||
peaky = max(y) | ||
Comment on lines
+148
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think first and second peaks are more information rich in rdf. The max of bin_centers is always going to be the last value in the list (largest distance) and max of rdf doesn't give us a correct estimation of the first peak. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. We should use some kind of peak finding algorithm or tool. RDFs often have more than 1 peak, so just finding the max y value may not provide enough information. |
||
logfile = job.fn('log.txt') | ||
energy = np.genfromtxt(logfile, delimiter=",") | ||
mean = np.mean(energy[:,0]) | ||
sd = np.std(energy[:,0]) | ||
save_path = os.path.join(job.ws, "analysis/rdf/rdf.txt") | ||
np.savetxt(save_path, np.transpose([x,y]), delimiter=',', header ="bin_centers, rdf") | ||
save_peak = os.path.join(job.ws, "analysis/rdf/peak.txt") | ||
np.savetxt(save_peak, np.transpose([peakx, peaky]), delimiter=',', header="max_x, max_y") | ||
job.doc['avg_PE'] = mean | ||
job.doc['sd_PE'] = sd | ||
nn = avg_nn(gsdfile, frame=-1) | ||
job.doc['average_nn'] = nn | ||
job.doc["analyzed"] = True | ||
|
||
|
||
if __name__ == "__main__": | ||
MyProject().main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
344.14088824424385,1.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add |
||
344.14088824424385,1.0 | ||
341.59388377626556,1.0 | ||
338.6685686445551,1.0 | ||
337.94650985867054,1.0 | ||
337.9376561616747,1.0 | ||
336.81233332171166,1.0 | ||
333.6200195542917,1.0 | ||
332.86849037229774,1.0 | ||
331.1718868176446,1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply this change to the rdf function in utils.py
rdf.compute((box,points), reset=False)
The default value for reset is True, which means if you are computing rdf from multiple snapshots, freud doesn't accumulate the computated values from different snapshots. When reset is True, the result rdf is only from last snapshot.