Dear All,
I have written a perl script to create a new xtd file, loop over each frame, copy the contents to a temporary document, delete the atoms that I don't want from the temporary document and append it to the new new trajectory and repeat for all frames, but when it debug, it has something wrong.
How to modify my script file?
Here are my script file:
#!perl
use strict;
use Getopt::Long;
use MaterialsScript qw(:all);
my \\\$xtd = "3D Atomistic"; # Name of the trajectory
my \\\$solvent = "Sketch 16"; # Set name given to the molecule
my \\\$start_frame = 1; # Starting frame
my \\\$interval = 1; # Extraction interval from the trajectory
#############################################################################
# Initialize
my \\\$doc = \\\$Documents{"./3D Atomistic.xtd"};
print "Document: \\\$3D Atomistic.xtdn";
my \\\$number_of_frames = \\\$doc->Trajectory->NumFrames;
print "Number of frames = \\\$number_of_frames n";
###########################################################################
# Go through frames as instructed, delete the molecule
for (my \\\$frame_counter = \\\$start_frame; \\\$frame_counter <=\\\$number_of_frames; \\\$frame_counter = \\\$frame_counter + \\\$interval) {
print "Deleting \\\$solvent from frame \\\$frame_countern";
# copy frame to new document
my \\\$frame = Documents->New("frame.xsd");
\\\$doc->Trajectory->CurrentFrame = \\\$frame_counter;
\\\$frame->CopyFrom(\\\$doc);
# delete molecules from that document
for my \\\$molecule (@{\\\$frame->UnitCell->Molecules}) {
if ((\\\$molecule->Name eq \\\$solvent)) { \\\$molecule->Delete;}
}
# append frame document to new trajectory
\\\$newdoc->Trajectory->AppendFramesFrom(\\\$frame);
# delete the temporary document holding the frame.
\\\$frame->Delete;
}
print "Deletion complete.n";
Thanks.
Best regards,
Yours
CHENG Xu
