Control angular velocity plus Rotating molecule in a vibration mode

Hi everyone,
You know, there’s a complete script in MaterialsScript-Complete scripts section in this forum contributed by Stephen Todd to rotate a molecule every certain angle around the centroid, i. e. “RotateMoleculeV2”.
Now I just added ”
Modules->Forcite->changeSettings([Ensemble3D=> "NVT", WriteForces=> "yes",TrajectoryRestart=> "yes",TrajectoryFrequency=> 1, NumberOfSteps=>1]);
my \\\$results= Modules->Forcite->Dynamics->Run(\\\$newDoc); “ to the loop. (Line 75)
After running, there’s an error message “There is no trajectory contained within your selection in Forcite.Dynamics (function/property "Run") at -e line 75.”

What should I do to correct this?
Thanks a lot in advance!

Best regards,
Weifu

The following is the slightly modified script.

#!perl
use strict;
use MaterialsScript qw(:all);
use Cwd;
##################################################################################
# Begin user editable settings
my \\\$xsdDoc = "pdms";
# Define the rotation vector:
my \\\$x = 0;
my \\\$y = 1;
my \\\$z = 0;
my \\\$numberSteps = 36; # The number of steps you want

# End user editable settings
##################################################################################
my \\\$doc = \\\$Documents{"\\\$xsdDoc.xsd"};

# Create a copy to work on - this will be discarded at the end
my \\\$newDoc = Documents->New("\\\$xsdDoc"."_temp.xsd");
\\\$newDoc->CopyFrom(\\\$doc);
\\\$doc->Close;
my \\\$trj = Documents->New("\\\$xsdDoc"."_rotate.xtd");
my \\\$traj=Documents->New("\\\$xsdDoc"."_temp.xtd")->Trajectory;

# Create a centroid to rotate around. Give it a name so you can delete it later
my \\\$centroid = \\\$newDoc->CreateCentroid(\\\$newDoc->AsymmetricUnit->Atoms);
\\\$centroid->Name ="temp";
my \\\$centroidX = \\\$centroid->CentroidXYZ->X;
my \\\$centroidY = \\\$centroid->CentroidXYZ->Y;
my \\\$centroidZ = \\\$centroid->CentroidXYZ->Z;

# Calculate the angle of rotation
my \\\$angle = 360/\\\$numberSteps;
print "Rotating by \\\$angle degrees\\n";

# Main loop to write out the trajectory
for (my \\\$counter = 0; \\\$counter < \\\$numberSteps; ++\\\$counter) {

Modules->Forcite->changeSettings([Ensemble3D=> "NVT", WriteForces=> "yes",TrajectoryRestart=> "yes",TrajectoryFrequency=> 1, NumberOfSteps=>1]);
my \\\$results= Modules->Forcite->Dynamics->Run(\\\$newDoc);

# Rotate the centroid (which also rotates underlying atoms)
\\\$centroid->RotateAboutPoint(\\\$angle, Point(X => \\\$x, Y => \\\$y, Z => \\\$z), Point(X =>\\\$centroidX,Y =>\\\$centroidY, Z =>\\\$centroidZ ));

# Append the XSD to the trajectory
\\\$trj->Trajectory->AppendFramesFrom(\\\$traj);
}

# Clean up the documents
\\\$newDoc->Discard;
\\\$trj->DisplayRange->Centroids("temp")->Delete;
print "Trajectory generation complete\\n";