### Exercise-9

parent aaec79ae
 %% Cell type:code id: tags:  python import numpy as np import matplotlib.pyplot as plt  %% Cell type:markdown id: tags: Compute correlation as: $$corr (t) = \int \dot{\mu}(\tau) \cdot \dot{\mu}(\tau + t) d \tau$$ $\tau$ will be an index that runs on all the simulation time. For every value of $\tau$ $t$ varies and we compute the single integrand elements and sum (~integrate) it to $corr(t - \tau)$ %% Cell type:code id: tags:  python # load file reading only the columns of the derivative and skipping the first 45 rows (~ thermalization) D_dipole = np.loadtxt('dipolemet.traj',usecols = (4,5,6),skiprows=45,comments=' DIPOLE [Non Periodic](') Nmax = 500 N = len(D_dipole) timestep = 0.5 #fs c_cm_s = 29979245800 corr_time = np.zeros(Nmax) for tau in range(N-Nmax): for t in range(tau,tau+Nmax): corr_time[t-tau] = corr_time[t-tau] + np.dot(D_dipole[tau], D_dipole[t]) for t in range(Nmax): corr_time[t] /= (N*(N-t))  %% Cell type:code id: tags:  python fig = plt.plot(timestep*np.arange(Nmax),corr_time/corr_time,color='crimson', lw=2) ax = plt.gca() ax.set_xlabel('time') ax.set_ylabel('correlation') plt.savefig('METtime_corr', dpi=300,transparent=True)  %% Cell type:code id: tags:  python #Fmax up to 4000 cm^-1 Fmax = int((2e-15*np.pi*timestep*c_cm_s)*N*(4000/(2*np.pi))) corr_freq = np.zeros([Fmax]) freq = np.zeros([Fmax]) for i in range(Fmax): omega = i*2*np.pi/N for j in range(Nmax): corr_freq[i] += np.cos(omega*j)*corr_time[j] freq[i] = omega/(2e-15*np.pi*timestep*c_cm_s) #corr_freq  %% Cell type:code id: tags:  python fig = plt.plot(freq,corr_freq,color='crimson', lw=2) ax = plt.gca() ax.set_xlabel('frequency') ax.set_ylabel('correlation') plt.savefig('METfreq_corr', dpi=300,transparent=True)  %% Cell type:code id: tags:  python  %% Cell type:code id: tags:  python 
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment