File: plot_pulse.py

package info (click to toggle)
gpaw 21.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,492 kB
  • sloc: python: 121,997; ansic: 14,138; sh: 1,125; csh: 139; makefile: 43
file content (29 lines) | stat: -rw-r--r-- 872 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Creates: pulse.png
import numpy as np
import matplotlib.pyplot as plt
from gpaw.tddft.units import au_to_fs

plt.figure(figsize=(8, 4))
ax = plt.subplot(1, 1, 1)

data_ti = np.loadtxt('dmpulse.dat')
ax.plot(data_ti[:, 0] * au_to_fs, data_ti[:, 2], 'k')
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
plt.ylabel('Dipole moment (atomic units)')
plt.ylim(np.array([-1, 1]) * np.max(np.abs(plt.ylim())))
plt.xlabel('Time (fs)')
plt.xlim(0, 30)

ax = ax.twinx()
data_ti = np.loadtxt('pulse.dat')
ax.plot(data_ti[:, 0] * au_to_fs, data_ti[:, 1], 'g')
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('right')
ax.tick_params(axis='y', labelcolor='g')
plt.ylabel('Pulse (atomic units)', color='g')
plt.ylim(np.array([-1, 1]) * np.max(np.abs(plt.ylim())))

plt.tight_layout()
plt.savefig('pulse.png')