Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

10.0 7.5 t=0 5.0 2.5 0.0 -2.5 -5.0 -7.5 - 10.0 -10.0 -7.5 -5.0 -2.5 0.0 2.5 5.0 7.5 10.0 x # parameters NPART =

image text in transcribed

10.0 7.5 t=0 5.0 2.5 0.0 -2.5 -5.0 -7.5 - 10.0 -10.0 -7.5 -5.0 -2.5 0.0 2.5 5.0 7.5 10.0 x # parameters NPART = 1000 # number of particles to simulate L = 10 # box dimensions (LL) X (-L,L) SIGMA = 0.2 # sigma at start of the simulation # initialize the drop of particles: x = np. random.normal(size=NPART) *SIGMA y = np. random.normal(size NPART) SIGMA # plot a snapshot: plt.xlim(-L,L) plt.ylim(-L,L) plt.xlabel("x") plt.ylabel("/") plt.text(9,7,"t=0", ha="right") plt.plot(x,y, ".", ms=2) plt. savefig("diffstart.pdf", bbox_inches="tight") Snapshot of the simulation at the start, along with the code used to produce it. A python function which calculates the entropy in this manner: from scipy import stats def entropy(x,y,l,sbins): h,xbins,ybins=np.histogram2d (x,y,bins=sbins, range=[(-1,1],[-1,1]]) return stats. entropy (h. flatten() The function takes as input parameters the position arrays x and y, the boundary distance 1 (set it to L and the number of bins in each dimension sbins (set it to 20). The function returns the entropy of the current state of the system described by x and y. Jupyter Notebook Starting from the example code, implement a random walk to model the diffusion process, and plot four snap shops showing the evolution of the system. Calculate and record the entropy of the system as it evolves, and plot the entropy as a function of time. 10.0 7.5 t=0 5.0 2.5 0.0 -2.5 -5.0 -7.5 - 10.0 -10.0 -7.5 -5.0 -2.5 0.0 2.5 5.0 7.5 10.0 x # parameters NPART = 1000 # number of particles to simulate L = 10 # box dimensions (LL) X (-L,L) SIGMA = 0.2 # sigma at start of the simulation # initialize the drop of particles: x = np. random.normal(size=NPART) *SIGMA y = np. random.normal(size NPART) SIGMA # plot a snapshot: plt.xlim(-L,L) plt.ylim(-L,L) plt.xlabel("x") plt.ylabel("/") plt.text(9,7,"t=0", ha="right") plt.plot(x,y, ".", ms=2) plt. savefig("diffstart.pdf", bbox_inches="tight") Snapshot of the simulation at the start, along with the code used to produce it. A python function which calculates the entropy in this manner: from scipy import stats def entropy(x,y,l,sbins): h,xbins,ybins=np.histogram2d (x,y,bins=sbins, range=[(-1,1],[-1,1]]) return stats. entropy (h. flatten() The function takes as input parameters the position arrays x and y, the boundary distance 1 (set it to L and the number of bins in each dimension sbins (set it to 20). The function returns the entropy of the current state of the system described by x and y. Jupyter Notebook Starting from the example code, implement a random walk to model the diffusion process, and plot four snap shops showing the evolution of the system. Calculate and record the entropy of the system as it evolves, and plot the entropy as a function of time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

3rd Edition

0760049041, 978-0760049044

More Books

Students also viewed these Databases questions