Esempio n. 1
0
    def _plot_all(self):
        """
        Will plot all the Qlk vs time lines for each replica and save all the
        line in a 2D list called
        """
        Qlk_t.all_rep_lines = [[] for i in range(self.num_active_atoms)]

        ax = self.axes['Qlk_t'][1]
        for Qlk_filename in self.all_Qlk_data:
            Qlk_data = self.all_Qlk_data[Qlk_filename]  # list of all qlk_data
            Qlk_timesteps = Qlk_data[1]  # grab timesteps from qlk_data list
            Qlk_data = Qlk_data[0]  # grab actual data from qlk_data list

            for iatom in self.atoms_to_plot:
                QMX = load_QM.find_in_Qlk(Qlk_data,
                                          params={
                                              'at_num': iatom,
                                              'lk': (1, 2),
                                              'cart_dim': 1
                                          })
                QMY = load_QM.find_in_Qlk(Qlk_data,
                                          params={
                                              'at_num': iatom,
                                              'lk': (1, 2),
                                              'cart_dim': 2
                                          })
                QMZ = load_QM.find_in_Qlk(Qlk_data,
                                          params={
                                              'at_num': iatom,
                                              'lk': (1, 2),
                                              'cart_dim': 3
                                          })
                QM_mag = np.sqrt(QMX**2 + QMY**2 + QMZ**2)

                ln, = ax.plot(
                    Qlk_timesteps,
                    QM_mag[:, 0],  # /np.max(QM_mag[:, 0]),
                    '-',
                    color=self.colors[iatom - 1],
                    alpha=self.alpha,
                    lw=0.7)
                Qlk_t.all_rep_lines[iatom - 1].append(ln)
            ax.set_ylabel(r"|Q$_{lk}^{(I)}$|$^2$")

        # Initialise the replica lines
        for atlist in Qlk_t.all_rep_lines:
            for line in atlist:
                line.set_visible(Qlk_t._show_all)
Esempio n. 2
0
    def _plot_avg_Qlk_t(self):
        """
        Will plot the Qlk vs time for the average replica
        """
        ax = Qlk_t.plot_ax
        Qlk_filename = "avg_Qlk"
        Qlk_data = self.avg_Qlk_data[Qlk_filename]
        Qlk_timesteps = Qlk_data[1]
        Qlk_data = Qlk_data[0]

        Qlk_t.Xlines = []
        Qlk_t.Ylines = []
        Qlk_t.Zlines = []
        Qlk_t.Maglines = []

        for iatom in self.atoms_to_plot:
            QMX = load_QM.find_in_Qlk(Qlk_data,
                                      params={
                                          'at_num': iatom,
                                          'lk': (1, 2),
                                          'cart_dim': 1
                                      })
            QMY = load_QM.find_in_Qlk(Qlk_data,
                                      params={
                                          'at_num': iatom,
                                          'lk': (1, 2),
                                          'cart_dim': 2
                                      })
            QMZ = load_QM.find_in_Qlk(Qlk_data,
                                      params={
                                          'at_num': iatom,
                                          'lk': (1, 2),
                                          'cart_dim': 3
                                      })
            QM_mag = np.sqrt(QMX**2 + QMY**2 + QMZ**2)

            # Plot Mag
            ln, = ax.plot(
                Qlk_timesteps,
                QM_mag[:, 0],  # /np.max(QM_mag[:, 0]),
                '--',
                color=self.colors[iatom - 1])
            ln.set_visible(Qlk_t.Mag and Qlk_t._show_avg)
            Qlk_t.Maglines.append(ln)
Esempio n. 3
0
    def _plot(self):
        """
        Will plot the Rlk vs time for the average replica
        """
        ax = Rlk.plot_ax
        Rlk_data = self.Rlk_data[0]
        Rlk_timesteps = self.Rlk_data[1]

        Rlk.Xlines = []
        Rlk.Ylines = []
        Rlk.Zlines = []
        Rlk.Maglines = []

        for iatom in self.atoms_to_plot:
            X = load_QM.find_in_Qlk(Rlk_data,
                                    params={
                                        'at_num': iatom,
                                        'lk': (1, 2),
                                        'cart_dim': 1
                                    })
            Y = load_QM.find_in_Qlk(Rlk_data,
                                    params={
                                        'at_num': iatom,
                                        'lk': (1, 2),
                                        'cart_dim': 2
                                    })
            Z = load_QM.find_in_Qlk(Rlk_data,
                                    params={
                                        'at_num': iatom,
                                        'lk': (1, 2),
                                        'cart_dim': 3
                                    })
            mag = np.sqrt(X**2 + Y**2 + Z**2)

            # Plot Mag
            ln, = ax.plot(
                Rlk_timesteps,
                mag[:, 0],  # /np.max(mag[:, 0]),
                '-',
                color=self.colors[iatom - 1],
                lw=1.5)
            ln.set_visible(Rlk.Mag)
            Rlk.Maglines.append(ln)
Esempio n. 4
0
    def _plot_qm_vs_pos_all_reps(self, istep):
        """
        Will plot the quantum momentum vs position.

        1) Use masks to select Qlk and pos data that share same timesteps
        2) Find the pos and Qlk data corresponding to atom v
        3) Plot the pos (xyz) data vs Qlk (xyz) for each state. 
        """

        # First get shared timesteps between Qlk and pos
        all_QM_data, all_pos = self._match_timesteps_Qlk_pos(
            self.all_Qlk_data, self.all_pos_data)

        Qkeys, Pkeys = list(all_QM_data.keys()), list(all_pos.keys())

        self.Qlk_ntimesteps = len(self.all_Qlk_data[Qkeys[0]][0][0])
        natom = np.max(self.all_Qlk_data[Qkeys[0]][0][1][0, :, 0])
        self.cart_lines = [[], [], []]
        self.at_lines = [[] for i in range(natom)]

        idim = 0
        iatom = 0
        for irep in range(len(all_QM_data)):
            for iatom in range(natom):
                rep_key = Qkeys[irep]
                Qlk_data = load_QM.find_in_Qlk(all_QM_data[rep_key][0], {
                    'at_num': iatom + 1,
                    'cart_dim': idim + 1,
                    'lk': (1, 2)
                })

                if self.run_inp_params['NUMBER_ATOMS_PER_SITE'] > 6:
                    print(
                        """The QM vs pos graph won't work properly for anything but 
                          Ethylene. This is because the code isn't matching the correct
                          active atoms position to the quantum momentum. This can be 
                          done using the AOM_COEFF.include file. It has been 
                          implemented in the movie maker. There will be some useful 
                          code there to help with this.""")
                    raise SystemExit("UNSUPPORTED MOLECULE TYPE")
                else:
                    act_atoms = self.run_inp_params['NUMBER_ATOMS_PER_SITE'] * \
                                self.run_inp_params['NUMBER_DIABATIC_STATES']

                single_rep_pos = all_pos[Pkeys[irep]][0][0]
                single_rep_pos = single_rep_pos[:, :act_atoms]

                ln, = QM_R.plot_ax.plot(single_rep_pos[istep, iatom, idim],
                                        Qlk_data[istep, 0],
                                        '.',
                                        color=self.colors[iatom])
                QM_R.lines.append(ln)

        QM_R.put_time_annotation(self)
Esempio n. 5
0
    def _set_qm_vs_pos_all_reps(self, istep):
        """
        Will reset the line ydata according to the timestep.
        """

        # First get shared timesteps between Qlk and pos
        all_QM_data, all_pos = self._match_timesteps_Qlk_pos(
            self.all_Qlk_data, self.all_pos_data)

        Qkeys, Pkeys = list(all_QM_data.keys()), list(all_pos.keys())

        self.Qlk_ntimesteps = len(self.all_Qlk_data[Qkeys[0]][0][0])
        natom = np.max(self.all_Qlk_data[Qkeys[0]][0][1][0, :, 0])
        self.cart_lines = [[], [], []]
        self.at_lines = [[] for i in range(natom)]

        idim = 0
        count = 0
        for irep in range(len(all_QM_data)):
            for iatom in range(natom):
                rep_key = Qkeys[irep]
                Qlk_data = load_QM.find_in_Qlk(all_QM_data[rep_key][0], {
                    'at_num': iatom + 1,
                    'cart_dim': idim + 1,
                    'lk': (1, 2)
                })

                if self.run_inp_params['NUMBER_ATOMS_PER_SITE'] > 6:
                    print(
                        """The QM vs pos graph won't work properly for anything but 
                          Ethylene. This is because the code isn't matching the correct
                          active atoms position to the quantum momentum. This can be 
                          done using the AOM_COEFF.include file. It has been 
                          implemented in the movie maker. There will be some useful 
                          code there to help with this.""")
                    raise SystemExit("UNSUPPORTED MOLECULE TYPE")
                else:
                    act_atoms = self.run_inp_params['NUMBER_ATOMS_PER_SITE'] * \
                                self.run_inp_params['NUMBER_DIABATIC_STATES']

                single_rep_pos = all_pos[Pkeys[irep]][0][0]
                single_rep_pos = single_rep_pos[:, :act_atoms]

                QM_R.lines[count].set_ydata(Qlk_data[istep, 0])
                QM_R.lines[count].set_xdata(single_rep_pos[istep, iatom, idim])
                count += 1
        plt.draw()
        QM_R.put_time_annotation(self)
Esempio n. 6
0
allAtRepData = []
allRepTimesteps = []
for iat in range(1, 12):

    allRepData = []
    for repNum in range(1, 201):
        if appendTime:
            allRepTimesteps.append(
                    AllData.all_Qlk_data['run-QM-%i.xyz' % repNum][1]
                                  )

        qlk_data = AllData.all_Qlk_data['run-QM-%i.xyz' % repNum][0]

        X = load_QM.find_in_Qlk(qlk_data, {'at_num': iat,
                                           'cart_dim': 1,
                                           'lk': (1, 2)
                                           }
                                )
        Y = load_QM.find_in_Qlk(qlk_data, {'at_num': iat,
                                           'cart_dim': 2,
                                           'lk': (1, 2)
                                           }
                                )
        Z = load_QM.find_in_Qlk(qlk_data, {'at_num': iat,
                                           'cart_dim': 3,
                                           'lk': (1, 2)
                                           }
                                )

        mag = np.sqrt(X**2 + Y**2 + Z**2)
        allRepData.append(mag)
Esempio n. 7
0
os.chdir('..')
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.collections import PatchCollection
from matplotlib.patches import Rectangle

import PLOT
from load import load_QM

folder = '/home/oem/Data/ToPlot/VarSigma/'

load = PLOT.LoadData(folder, [1], ['qm_t'])

qlk_data = load_QM.find_in_Qlk(load.all_Qlk_data['run-QM-1.xyz'][0], {
    'at_num': 2,
    'cart_dim': 3
})
qlk_data = qlk_data[:, 0]
qlk_timesteps = load.all_Qlk_data['run-QM-1.xyz'][1]

dt = np.mean(np.diff(qlk_timesteps))
grad_data = np.gradient(qlk_data, dt)
mean_val = np.abs(np.mean(qlk_data))
std_var = np.abs(np.std(qlk_data))

bad_times = []
for qlki in range(len(qlk_data)):
    if np.abs(qlk_data[qlki]) > mean_val + 2 * std_var:
        bad_times.append(qlk_timesteps[qlki])

rects = []