示例#1
0
def test_compute_torsion(trajectory):

    # 3. Compute the torsion between atoms 0, 1, 2, 3 for the trajectory
    #    Test if the first frame's dihedral angle is correct.

    ai.compute_torsion(trajectory, "T0123", 0, 1, 2, 3)
    assert trajectory.frames[0].properties["T0123"] == pt.approx(
        160.465152603, rel=1e-10)  # 32674
def test_major_trajectory_operations(tmp_path, trajectory):
    # 1. Plot Bond Distances (Spaghetti + Blur)
    # Compute the a bond distance property for all Frames in traj
    ai.compute_bond(trajectory, "R01", 0, 1)
    ai.plot_scalar(
        tmp_path / "R.pdf",
        trajectory,
        "R01",
        ylabel=r"$R_{CC} [\AA{}]$",
        time_units="fs",
        state_colors=["r", "b"],
        plot_average=True,
    )

    # Blur the bond distance (convolve)
    R = np.linspace(0.5, 3.0, 50)
    ai.blur_property(trajectory, "R01", "Rblur", R, alpha=8.0)
    #    Plot the heat map of blurred bond distance
    ai.plot_vector(
        tmp_path / "Rblur.pdf",
        trajectory,
        "Rblur",
        y=R,
        ylabel=r"$R [\AA{}]$",
        time_units="fs",
        nlevel=64,
    )

    # 2. Plot of Torsion Angle (Spaghetti + Blur)

    # Compute the a torsion angle property for all Frames in traj
    ai.compute_torsion(trajectory, "T0123", 0, 1, 2, 3)
    ai.unwrap_property(trajectory, "T0123", 360.0)
    ai.plot_scalar(
        tmp_path / "T.pdf",
        trajectory,
        "T0123",
        ylabel=r"$\Theta [^{\circ{}}]$",
        time_units="fs",
        state_colors=["r", "b"],
        plot_average=True,
    )

    # Blur the torsion
    T = np.linspace(-180.0, +180.0, 100)
    ai.blur_property(trajectory, "T0123", "Tblur", T, alpha=0.02)
    #    Plot the heat map of blurred torison
    ai.plot_vector(
        tmp_path / "Tblur.pdf",
        trajectory,
        "Tblur",
        y=T,
        ylabel=r"$Theta [^{\circ{}}]$",
        time_units="fs",
        nlevel=64,
    )

    # 3. UED Cross Section

    # Compute the "simple" form of the UED cross section in R
    R = np.linspace(1.0, 6.0, 50)
    ai.compute_ued_simple(trajectory, "UED", R=R, alpha=8.0)

    # Plot the heat map of the UED cross section detailed above
    ai.plot_vector(
        tmp_path / "UED.pdf",
        trajectory,
        "UED",
        y=R,
        ylabel=r"$R [\AA{}]$",
        time_units="fs",
        diff=True,
    )
示例#3
0
ai.plot_scalar(
    "R.pdf",
    traj,
    "R01",
    ylabel=r"$R_{CC} [\AA{}]$",
    time_units="fs",
    state_colors=["r", "b"],
    clf=False,
    plot_average=False,
)

# => Showoff Plot of Torsion Angle (Spaghetti + Blur) <= #

# Compute the a torsion angle property for all Frames in traj
# This particular torsion is the one the leads to cis-trans isomerization
ai.compute_torsion(traj, "T4019", 4, 0, 1, 9)
ai.unwrap_property(traj, "T4019", 360.0)

# Blur the torsion
T = np.linspace(-180.0, +180.0, 100)
ai.blur_property(traj, "T4019", "Tblur", T, alpha=0.02)

# Plot the heat map of blurred torison
ai.plot_vector(
    "T.pdf",
    traj,
    "Tblur",
    y=T,
    ylabel=r"$Theta [^{\circ{}}]$",
    time_units="fs",
    nlevel=64,