示例#1
0
 def test_ric_add_ic(self):
     with path("saddle.test.data", "water.xyz") as mol_path:
         mol = Utils.load_file(mol_path)
     ri_mol = Internal(mol.coordinates, mol.numbers, 0, 1)
     ri_mol = ReducedInternal.update_to_reduced_internal(ri_mol)
     ri_mol.add_bond(1, 0)
     ri_mol.add_bond(1, 2)
     ri_mol.add_bond(0, 2)
     ri_mol.vspace
     ri_mol.add_angle(0, 1, 2)
     ri_mol.add_angle(1, 0, 2)
     ri_mol.select_key_ic(0, 2)
     vp_ref = np.array(
         [
             [4.40930006e-01, -7.79280781e-01, 6.12072474e-17],
             [-5.61408260e-01, -6.12047068e-01, -3.33066907e-16],
             [-4.57920570e-01, -3.28254718e-02, -7.16200549e-01],
             [-5.22760813e-01, 4.87258745e-02, 5.58315734e-01],
             [8.62054537e-02, 1.21112047e-01, -4.18736570e-01],
         ]
     )
     for i in range(vp_ref.shape[1]):
         assert np.allclose(ri_mol.vspace[:, i], vp_ref[:, i]) or np.allclose(
             ri_mol.vspace[:, i], -1 * vp_ref[:, i]
         )
     ri_mol.set_key_ic_number(1)
     assert ri_mol._red_space is None
     assert ri_mol._non_red_space is None
示例#2
0
    def create_ts_state(self, start_with, ratio=0.5, task="ts", flex_sin=True):
        """Create transition state guess structure.

        The selection process is based on the linear combination of
        internal structure of both reactant and product.

        Arguments
        ---------
        start_with : string
            The initial structure of transition state to optimize from.
            choices:
                "reactant" : optimize ts structure from reactant
                "product" : optimize ts structure from product
        ratio : float, default is 0.5
            The ratio of linear combination of ic for reactant and product.
            ts = ratio * reactant + (1 - ratio) * product
        """
        if start_with == "reactant":
            model = self.reactant
        elif start_with == "product":
            model = self.product
        else:
            raise InvalidArgumentError(
                "The input of start_with is not supported")
        if ratio > 1.0 or ratio < 0:
            raise InvalidArgumentError("The input of ratio is not supported")
        ts_internal = deepcopy(model)
        target_ic = (ratio * self.reactant.ic_values +
                     (1.0 - ratio) * self.product.ic_values)
        ts_internal.set_target_ic(target_ic)
        # ts_internal.list_ic
        ts_internal.converge_to_target_ic(ignore_dihed=False,
                                          flex_sin=flex_sin)
        # ts_internal.optimize_to_target_ic(dihed_weight=0, hess_check=False)
        # ts_internal.optimize_to_target_ic(method='BFGS')
        # dihed_weight=0, hess=True, method="Newton-CG", hess_check=False, max_iter=500
        # )
        if task == "ts":
            ts_internal = ReducedInternal.update_to_reduced_internal(
                ts_internal)
        elif task == "path":
            path_vector = self.product.ic_values - self.reactant.ic_values
            ts_internal = PathRI.update_to_path_ri(ts_internal, path_vector)
        # change the ts_internal to Class ReducedInternal
        self._ts = ts_internal  # set _ts attribute
示例#3
0
 def test_ic_ric_transform(self):
     with path("saddle.test.data", "water.xyz") as mol_path:
         mol = Utils.load_file(mol_path)
     ri_mol = Internal(mol.coordinates, mol.numbers, 0, 1)
     ri_mol.add_bond(1, 0)
     ri_mol.add_bond(1, 2)
     ri_mol.add_bond(0, 2)
     ri_mol.add_angle(0, 1, 2)
     ri_mol.add_angle(1, 0, 2)
     vc_ref = np.array([1.81413724, 1.81413724, 2.96247453, 1.91063401, 0.61547931])
     assert np.allclose(ri_mol.ic_values, vc_ref)
     ri_mol = ReducedInternal.update_to_reduced_internal(ri_mol)
     assert isinstance(ri_mol, ReducedInternal)
     ri_mol.set_key_ic_number(2)
     ri_mol.select_key_ic(0, 2)
     print(ri_mol.vspace)
     vp_ref = np.array(
         [
             [4.40930006e-01, -7.79280781e-01, 6.12072474e-17],
             [-5.61408260e-01, -6.12047068e-01, -3.33066907e-16],
             [-4.57920570e-01, -3.28254718e-02, -7.16200549e-01],
             [-5.22760813e-01, 4.87258745e-02, 5.58315734e-01],
             [8.62054537e-02, 1.21112047e-01, -4.18736570e-01],
         ]
     )
     for i in range(vp_ref.shape[1]):
         assert np.allclose(ri_mol.vspace[:, i], vp_ref[:, i]) or np.allclose(
             ri_mol.vspace[:, i], -1 * vp_ref[:, i]
         )
     ri_mol.set_key_ic_number(1)
     assert ri_mol._red_space is None
     assert ri_mol._non_red_space is None
     ri_mol.set_key_ic_number(2)
     for i in range(vp_ref.shape[1]):
         assert np.allclose(ri_mol.vspace[:, i], vp_ref[:, i]) or np.allclose(
             ri_mol.vspace[:, i], -1 * vp_ref[:, i]
         )
     new_coor = np.array(
         [
             [1.40, -0.93019123, -0.0],
             [-0.0, 0.11720081, -0.0],
             [-1.40, -0.93019123, -0.0],
         ]
     )
     ri_mol.set_new_coordinates(new_coor)
     ref_ic = [
         1.7484364736491811,
         2.8,
         1.7484364736491811,
         1.8569769819,
         0.6423078258,
     ]
     assert np.allclose(ri_mol.ic_values, ref_ic)
     ri_mol.vspace
     assert ri_mol._red_space is not None
     assert ri_mol._non_red_space is not None
     print(ri_mol._red_space)
     ri_mol.add_angle(0, 2, 1)
     print(ri_mol._red_space)
     assert ri_mol._red_space is None
     assert ri_mol._non_red_space is None