Hello everone,
I would like to export my XYZ information of oxygen atom(s) in my periodic system.
First, thanks for Jingjing Bu's and stodd's script, together with jdejoannis's reponse for the correction of srcipt.I adopted your method to export the XYZ information for my periodic structure (FYI, I used the amorphous cell, and then conducted the dynamics run,50 frames were reported, and there are 4000 atoms in one frame).
Could you tell me the output file, i.e., the trj.txt, shows the XYZ coordinates of which atoms, or the whole atoms?
If I just want to study one atom(or more), like the oxygen atom(in fact there are ), in my system, how to set the script file?
Thanks.
Nice weekend
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
use strict;
use MaterialsScript qw(:all);
#open the multiframe trajectory structure file or die
my \$doc = \$Documents{"./Cs-0.5.xtd"};
if (!\$doc) {die "no document";}
my \$trajectory = \$doc->Trajectory;
if (\$trajectory->NumFrames>1) {
# Open new report file
my \$report=Documents->New("xtd2xmol.txt");
\$report->Append("Found ".\$trajectory->NumFrames." frames in the trajectory\n");
\$report->Close;
# Open new xmol trajectory file
my \$xmolFile=Documents->New("trj.txt");
#get atoms in the structure
my \$atoms = \$doc->Atoms;
my \$Natoms=@\$atoms;
# loops over the frames
for (my \$frame=1; \$frame<=\$trajectory->NumFrames; ++\$frame){
\$trajectory->CurrentFrame = \$frame;
#write header xyz
\$xmolFile->Append(sprintf "%i \n\n", \$Natoms);
foreach my \$atom (@\$atoms) {
# write atom symbol and x-y-z- coordinates
\$xmolFile->Append(sprintf "%s %f %f %f \n",\$atom->ElementSymbol, \$atom->X, \$atom->Y, \$atom->Z);
}
}
#close trajectory file
\$xmolFile->Close;
}
else {
print "The " . \$doc->Name . " is not a multiframe trajectory file \n";
}