Hi, I am trying to get the tilt angle of surfactant strands on water surface over all frames in a trajectory, but the attached script does not loop through the frames. Could you tell me where I have gone wrong please?
the error message says
"The index value 0 is out of range (function/property "Item") at -e line 46."
Thanks Vinuthaa
***************************************
#!perl
use strict;
use MaterialsScript qw(:all);
use Math::Trig;
my \\\$doc = \\\$Documents{"LAPOA.xtd"};
#get the trajectory data
my \\\$trj = \\\$doc->Trajectory;
my \\\$numFrames = \\\$trj->NumFrames;
my \\\$std = Documents->New(\\\$doc->Name.".std");
\\\$std->ColumnHeading(0) = "Angle (deg)";
#run over all frames in the trajectory
my \\\$irow = 0;
for(my \\\$frame = 1; \\\$frame <= \\\$numFrames; \\\$frame++)
{
\\\$trj->CurrentFrame = \\\$frame;
my \\\$axes = \\\$doc->UnitCell->PrincipalAxess->Item(0);
# find the axis with the lowest eigenvalue
my \\\$moment1 = \\\$axes->PrincipalMoment1;
my \\\$moment2 = \\\$axes->PrincipalMoment2;
my \\\$moment3 = \\\$axes->PrincipalMoment3;
my \\\$axis;
if(\\\$moment2 < \\\$moment3)
{
\\\$axis = (\\\$moment1 < \\\$moment2) ?
\\\$axes->PrincipalAxis1 : \\\$axes->PrincipalAxis1;
}
else
{
\\\$axis = (\\\$moment1 < \\\$moment3) ?
\\\$axes->PrincipalAxis1 : \\\$axes->PrincipalAxis1;
}
my \\\$irow = 0;
foreach my \\\$molecule (@{\\\$doc->UnitCell->Molecules})
#my \\\$planes = \\\$doc->UnitCell->BestFitPlanes;
#foreach my \\\$plane (@\\\$planes)
{
my \\\$planes = \\\$molecule->BestFitPlanes;
my \\\$normal = \\\$planes->Item(0)->BestFitPlane->UnitNormalVector;
my \\\$angle = 180/pi*acos(InProduct(\\\$normal,\\\$axis));
\\\$std->Cell(\\\$irow++,0) = \\\$angle;
}
}
sub InProduct(){
my(\\\$a, \\\$b) = @_;
return \\\$a->X*\\\$b->X+\\\$a->Y*\\\$b->Y+\\\$a->Z*\\\$b->Z
}
