Dear All,
I'm trying to calculate the coordination number of each frame of a .xtd document using Forcite RDF analysis. I try to use the following script from (Updated Link)
#!perl
use strict;
use Getopt::Long;
use warnings;
use MaterialsScript qw(:all);
# Coordination Number Evolution Analysis Tool
use constant PI => 3.14159265358979323846;
# User Input Section
my \\\$doc = \\\$Documents{"H2O.xtd"};
my \\\$CNStudyTable = Documents->New("Coordination_Number_Evolution.std");
my \\\$RDFSetA = "SetA";
my \\\$RDFSetB = "SetB";
my \\\$RDFBinWidth = 0.1;
my \\\$RDFCutoff = 10;
my \\\$CNcutoff = 4;
# Count atoms in the selected set
my \\\$Batoms = \\\$doc->UnitCell->Sets(\\\$RDFSetB)->Atoms;
my \\\$BAtomcounts = scalar(@\\\$Batoms);
my \\\$Aatoms = \\\$doc->UnitCell->Sets(\\\$RDFSetA)->Atoms;
my \\\$AAtomcounts = scalar(@\\\$Aatoms);
# Get volume
my \\\$Volume = \\\$doc->SymmetrySystem->Volume;
# Create a new study table document to hold the results
my \\\$IntegratedCNsheet = \\\$CNStudyTable->ActiveSheet;
\\\$IntegratedCNsheet->ColumnHeading(0) = "Frame";
\\\$IntegratedCNsheet->ColumnHeading(1) = "Coordination Number";
\\\$IntegratedCNsheet->ColumnHeading(2) = "Structure";
# Main loop
my \\\$numFrames = \\\$doc->Trajectory->NumFrames;
for (my \\\$counter = 1; \\\$counter <= 1; ++\\\$counter)
{
\\\$doc->Trajectory->CurrentFrame = \\\$counter;
my \\\$tmpdoc = Documents->New("tmp.xsd");
\\\$tmpdoc->CopyFrom(\\\$doc);
\\\$IntegratedCNsheet->Cell(\\\$counter-1, 0) = \\\$counter;
my \\\$Framedoc = Documents->New("Frame.xsd");
\\\$Framedoc->CopyFrom(\\\$doc);
\\\$IntegratedCNsheet->Cell(\\\$counter-1, 2) = \\\$Framedoc;
# Initialize Forcite RDF analysis
my \\\$results = Modules->Forcite->Analysis->RadialDistributionFunction(\\\$tmpdoc, Settings(
RDFBinWidth => \\\$RDFBinWidth,
RDFCutoff => \\\$RDFCutoff,
RDFSetA => \\\$RDFSetA,
RDFSetB => \\\$RDFSetB));
my \\\$outRDFChart = \\\$results->RDFChart;
my \\\$outRDFChartAsStudyTable = \\\$results->RDFChartAsStudyTable;
my \\\$columnCount = \\\$outRDFChartAsStudyTable->Sheets(2)->ColumnCount;
my \\\$rowCount = \\\$outRDFChartAsStudyTable->Sheets(2)->RowCount;
# COllect RDF data
# Generate a temp studytable
my \\\$tmpStudyTable = Documents->New("Coordination_Number_\\\$counter.std");
my \\\$calcSheet = \\\$tmpStudyTable->ActiveSheet;
\\\$calcSheet->ColumnHeading(0) = "r(Angstrom)";
\\\$calcSheet->ColumnHeading(1) = "g(r)";
\\\$calcSheet->ColumnHeading(2) = "IntegratedCN";
# Get r data from RDF studytable
for (my \\\$rownum = 0; \\\$rownum < \\\$rowCount; ++\\\$rownum)
{
my \\\$cell = \\\$outRDFChartAsStudyTable->Sheets(2)->Cell(\\\$rownum, 0);
\\\$calcSheet->Cell(\\\$rownum, 0) = \\\$cell;
}
# Get coordination number and integrated coordination number data from RDF studytable
my \\\$integratedRDF;
my \\\$CoordinateNumber;
my \\\$integratedCN;
for (my \\\$rownum = 0; \\\$rownum < \\\$rowCount; ++\\\$rownum)
{
my \\\$r = \\\$outRDFChartAsStudyTable->Sheets(2)->Cell(\\\$rownum, 0);
\\\$calcSheet->Cell(\\\$rownum, 0) = \\\$r;
my \\\$gr = \\\$outRDFChartAsStudyTable->Sheets(2)->Cell(\\\$rownum, 1);
\\\$calcSheet->Cell(\\\$rownum, 1) = \\\$gr;
\\\$integratedRDF = \\\$integratedRDF + \\\$gr;
\\\$CoordinateNumber = \\\$BAtomcounts * \\\$gr * 4 * PI * \\\$r * \\\$r * \\\$RDFBinWidth / \\\$Volume;
\\\$integratedCN = \\\$integratedCN + \\\$CoordinateNumber;
\\\$calcSheet->Cell(\\\$rownum, 2) = \\\$integratedCN;
if (\\\$r == \\\$CNcutoff)
{
\\\$IntegratedCNsheet->Cell(\\\$counter-1,1) = \\\$integratedCN if abs(\\\$r-\\\$CNcutoff) <= 1E-10;
}
}
# Some clean work
\\\$outRDFChart->Discard;
\\\$outRDFChartAsStudyTable->Discard;
\\\$tmpdoc->Discard;
\\\$Framedoc->Discard;
\\\$tmpStudyTable->Discard;
}
however, I got following error:
Use of uninitialized value in addition (+) at -e line 85.
which is:
\\\$integratedRDF = \\\$integratedRDF + \\\$gr;
Use of uninitialized value in addition (+) at -e line 87.
which is:
\\\$integratedCN = \\\$integratedCN + \\\$CoordinateNumber;
I highlighted those two lines in the script, I also attached a test file, could you please help me out of this, thank you.
Regards,
Jing
