Dear All
I wanted to build a crystal from the coordinate and lattice information provided by litterature, I tried to use the following script
# Begin user editable settings
my \\\$studyTable = \\\$Documents{"11t.std"}; # Name of the study table
my \\\$coordinateType = "Fractional"; # Fractional or Cartesian coordinates
my \\\$doc = Documents->New("11t.xsd"); # Name of the output document
# End user editable settings
#########################################################################
# Build the lattice
buildMyLattice(\\\$studyTable->Sheets("Lattice"), \\\$doc);
# Add the atoms
addTheAtoms(\\\$studyTable->Sheets("Coordinates"), \\\$doc, \\\$coordinateType);
# Do an initial bond calculation
\\\$doc->CalculateBonds;
###################################################################
# Build the lattice, specifying the space group etc
sub buildMyLattice {
my \\\$latticeTab = shift;
my \\\$doc1 = shift;
my \\\$spaceGroup = \\\$latticeTab->Cell(0, "SpaceGroup");
Tools->CrystalBuilder->SetSpaceGroup("\\\$spaceGroup", "");
Tools->CrystalBuilder->SetCellParameters(\\\$latticeTab->Cell(0, "LengthA"), \\\$latticeTab->Cell(0, "LengthB"), \\\$latticeTab->Cell(0, "LengthC"), \\\$latticeTab->Cell(0, "AngleA"), \\\$latticeTab->Cell(0, "AngleB"), \\\$latticeTab->Cell(0, "AngleC"));
Tools->CrystalBuilder->ChangeSettings(Settings(UseSpecialPositions => "Yes", SpecialPositionTolerance => 0.05));
Tools->CrystalBuilder->Build(\\\$doc1);
}
######################################################################
# Now create the atoms from the study table
sub addTheAtoms {
my \\\$coordinateTab = shift;
my \\\$doc1 = shift;
my \\\$coordinateFramework = shift;
for (my \\\$row = 0; \\\$row < \\\$coordinateTab->RowCount; ++\\\$row) {
# Grab the elementType
my \\\$elementType = \\\$coordinateTab->Cell(\\\$row,"Atom");
# Grab the x, y , and z coordinates. Use removeBrackts to take the
# value before the brackets - it does not matter if no brackets
# are present in the number
my \\\$x = removeBrackets(\\\$coordinateTab->Cell(\\\$row,"X"));
my \\\$y = removeBrackets(\\\$coordinateTab->Cell(\\\$row,"Y"));
my \\\$z = removeBrackets(\\\$coordinateTab->Cell(\\\$row,"Z"));
# Depending on the coordinate frame, use fractional or cartesian coordinates
if (\\\$coordinateFramework eq "Fractional") {
my \\\$atom = \\\$doc->CreateAtom("\\\$elementType", \\\$doc1->FromFractionalPosition(Point(X => \\\$x, Y => \\\$y, Z => \\\$z)), [Name => \\\$coordinateTab->Cell(\\\$row, "Name")]);
} elsif (\\\$coordinateFramework eq "Cartesian") {
my \\\$atom = \\\$doc->CreateAtom("\\\$elementType", Point(X => \\\$x, Y => \\\$y, Z => \\\$z), [Name => \\\$coordinateTab->Cell(\\\$row, "Name")]);
} else { print "You have not specified your coordinateType.\\nValid values are Fractional or Cartesian.\\n";}
\\\$doc->UpdateViews;
}
}
#######################################################################
# Removes the brackets from the number ie 0.924(2) => 0.924 by creating
# an array where the first value in the array is the number
sub removeBrackets {
my \\\$tempValue = shift;
my @tempArray = split(/\\(/, \\\$tempValue);
return \\\$tempArray[0];
}
Then I got the following error:
Type mismatch (writing property "Z", parameter 1) at -e line 92.
Which is :
if (\\\$coordinateFramework eq "Fractional") {
I used this script to build other crystal strucutre before, it worked. This time I just changed the input and output name, then got an error. Does anyone have idea why this happened?
Thank you!
Regards,
Jingjing
