コード例 #1
0
ファイル: thermostats.py プロジェクト: chaoxianhu/schnetpack
    def _init_gle_matrices(self, simulator):
        a_matrix, c_matrix = load_gle_matrices(self.gle_file)

        if a_matrix is None:
            raise ThermostatError('Error reading GLE matrices '
                                  'from {:s}'.format(self.gle_file))
        if a_matrix.shape[0] != self.n_replicas:

            raise ThermostatError('Expected {:d} beads but '
                                  'found {:d}.'.format(self.n_replicas,
                                                       a_matrix.shape[0]))

        if not type(simulator.integrator) is RingPolymer:
            raise ThermostatError('PIGLET thermostat should only be used with '
                                  'RPMD.')

        all_c1 = []
        all_c2 = []

        # Generate main matrices
        for b in range(self.n_replicas):
            c1, c2 = self._init_single_gle_matrix(a_matrix[b],
                                                  (c_matrix[b],
                                                   None)[c_matrix is None],
                                                  simulator)
            # Add extra dimension for use with torch.cat, correspond to normal
            # modes of ring polymer
            all_c1.append(c1[None, ...])
            all_c2.append(c2[None, ...])

        # Bring to correct shape for later matmul broadcasting
        c1 = torch.cat(all_c1)[:, None, None, :, :]
        c2 = torch.cat(all_c2)[:, None, None, :, :]
        return c1, c2
コード例 #2
0
ファイル: thermostats.py プロジェクト: FollowJack/schnetpack
    def _init_gle_matrices(self, simulator):
        a_matrix, c_matrix = load_gle_matrices(self.gle_file)

        if a_matrix is None:
            raise ThermostatError('Error reading GLE matrices from {:s}'.format(self.gle_file))
        elif a_matrix.shape[0] > 1:
            raise ThermostatError('More than one A matrix found. Could be PIGLET input.')
        else:
            # Remove leading dimension (for normal modes)
            a_matrix = a_matrix.squeeze()

        c1, c2 = self._init_single_gle_matrix(a_matrix, c_matrix, simulator)
        return c1, c2