Commit e2b2a7a5 by dmar

### Exercise-9

parent aaec79ae
 { "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compute correlation as:\n", "$$corr (t) = \\int \\dot{\\mu}(\\tau) \\cdot \\dot{\\mu}(\\tau + t) d \\tau$$\n", " $\\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", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# load file reading only the columns of the derivative and skipping the first 45 rows (~ thermalization)\n", "\n", "D_dipole = np.loadtxt('dipolemet.traj',usecols = (4,5,6),skiprows=45,comments=' DIPOLE [Non Periodic](')\n", "Nmax = 500\n", "N = len(D_dipole)\n", "timestep = 0.5 #fs\n", "c_cm_s = 29979245800\n", "corr_time = np.zeros(Nmax)\n", "\n", "for tau in range(N-Nmax):\n", " for t in range(tau,tau+Nmax):\n", " corr_time[t-tau] = corr_time[t-tau] + np.dot(D_dipole[tau], D_dipole[t])\n", "\n", "for t in range(Nmax):\n", " corr_time[t] /= (N*(N-t))\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig = plt.plot(timestep*np.arange(Nmax),corr_time/corr_time[0],color='crimson', lw=2)\n", "ax = plt.gca()\n", "ax.set_xlabel('time')\n", "ax.set_ylabel('correlation')\n", "plt.savefig('METtime_corr', dpi=300,transparent=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Fmax up to 4000 cm^-1\n", "Fmax = int((2e-15*np.pi*timestep*c_cm_s)*N*(4000/(2*np.pi)))\n", "corr_freq = np.zeros([Fmax])\n", "freq = np.zeros([Fmax])\n", "\n", "for i in range(Fmax):\n", " omega = i*2*np.pi/N\n", " for j in range(Nmax):\n", " corr_freq[i] += np.cos(omega*j)*corr_time[j] \n", " freq[i] = omega/(2e-15*np.pi*timestep*c_cm_s)\n", "#corr_freq" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "fig = plt.plot(freq,corr_freq,color='crimson', lw=2)\n", "ax = plt.gca()\n", "ax.set_xlabel('frequency')\n", "ax.set_ylabel('correlation')\n", "plt.savefig('METfreq_corr', dpi=300,transparent=True)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.0" } }, "nbformat": 4, "nbformat_minor": 2 }
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.
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.
This diff is collapsed.
 C C cc.spl C H ch.spl C N cn.spl C O co.spl C P cp.spl C S cs.spl C Zn czn.spl H C hc.spl H H hh.spl H N hn.spl H O ho.spl H P hp.spl H S hs.spl H Zn hzn.spl N C nc.spl N H nh.spl N N nn.spl N O no.spl N P np.spl N S ns.spl N Zn nzn.spl O C oc.spl O H oh.spl O N on.spl O O oo.spl O P op.spl O S os.spl O Zn ozn.spl P C pc.spl P H ph.spl P N pn.spl P O po.spl P P pp.spl P S ps.spl S C sc.spl S H sh.spl S N sn.spl S O so.spl S P sp.spl S S ss.spl S Zn szn.spl Zn C znc.spl Zn H znh.spl Zn N znn.spl Zn O zno.spl Zn S zns.spl Zn Zn znzn.spl
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.
 C C cc.spl C H ch.spl C N cn.spl C O co.spl C P cp.spl C S cs.spl C Zn czn.spl H C hc.spl H H hh.spl H N hn.spl H O ho.spl H P hp.spl H S hs.spl H Zn hzn.spl N C nc.spl N H nh.spl N N nn.spl N O no.spl N P np.spl N S ns.spl N Zn nzn.spl O C oc.spl O H oh.spl O N on.spl O O oo.spl O P op.spl O S os.spl O Zn ozn.spl P C pc.spl P H ph.spl P N pn.spl P O po.spl P P pp.spl P S ps.spl S C sc.spl S H sh.spl S N sn.spl S O so.spl S P sp.spl S S ss.spl S Zn szn.spl Zn C znc.spl Zn H znh.spl Zn N znn.spl Zn O zno.spl Zn S zns.spl Zn Zn znzn.spl
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
 12 i = 6, E = -37.5020871543 C -0.0000167242 1.4241047795 0.0000000000 H 0.0000117730 2.4812054687 0.0000000000 C -1.2229203865 0.7083450062 0.0000000000 H -2.1515061336 1.2169258310 0.0000000000 C -1.2228578464 -0.7083475940 0.0000000000 H -2.1514706966 -1.2168780517 0.0000000000 C 0.0000162811 -1.4241567274 0.0000000000 H -0.0000143972 -2.4812584194 0.0000000000 C 1.2228735927 -0.7083177365 0.0000000000 H 2.1514569212 -1.2168987582 0.0000000000 C 1.2229035665 0.7083746665 0.0000000000 H 2.1515177018 1.2169053411 0.0000000000
 6 i = 12, E = -23.9877697187 C -0.0435479100 0.6769040440 -0.0000044633 O 0.0048786826 -0.8714625537 0.0000589557 H -1.0794527472 0.9055802370 0.0000008389 H 0.9770514937 -1.1299177207 -0.0000003842 H 0.4213440524 1.0545040817 0.8763085668 H 0.4213460908 1.0545154729 -0.8763108797
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.
Markdown is supported
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