![]() |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The SaveXTC
command periodically saves a snapshot of a running simulation (consisting of atom positions only). These snapshots can be used to analyze a simulation or play it back quickly.
The XTC format has been optimized by the GROMACS team for minimum space requirements.
The format does not store atom velocities, use SaveSim
if you also want to save those to continue a simulation after power failures. Another option is to use both
SaveSim and SaveXTC
commands together, with a larger save interval for SaveSim
. An XTC trajectory is one big single file, which prohibits random access for writing. If you try to save a snapshot to an XTC file that already contains a snapshot with the same number,
the command is ignored. To avoid an unrecoverable mess of snapshots, it is also required that they are written with sequential numbers. Snapshot numbers are not specified explicitly but calculated internally from the current simulation
time. The simulation time
should therefore be set to 0 before the SaveXTC
command is run, otherwise YASARA complains if the trajectory does not yet contain snapshots
('premature end of file encountered'). In Windows, XTC files can currently not be handled correctly if they grow beyond the
size limit of 2 Gigabytes. If you want to load the XTC file in another program for analysis
, you will usually also need a PDB file with all the atoms taking part in the simulation,
appearing in the same order as their coordinates in the XTC file. To create such a PDB file,
load the starting scene (usually with _water extension), then join
the objects containing atoms (often solute and solvent are in different objects) to the first object and finally
save the resulting single object in PDB format
. While the XTC format in principle supports different
precisions for storing atom coordinates, technical reasons require YASARA to always store coordinates with its own internal precision,
i.e. 1e-6 (femtometers). To convert a list of PDB files to an XTC trajectory
, you can use the following macro:
# Convert PDB files to a SIM or XTC trajectory
# This example assumes that the PDB files are stored as 1crn_00.pdb, 1crn_01.pdb etc..
name='1crn_'
number=00
# Set the timestep between simulation snapshots in [fs], e.g. 5 picoseconds
steps=5000
# Set the trajectory format (SIM,XTC)
format='XTC'
# Load the first protein
Clear
LoadPDB (name)(number)
Clean
# Create a cell, force field does not matter, but TimeStep is important
Cell Auto,Extension=10
ForceField Amber99
TimeStep 1,1
TempCtrl SteepDes
# Start saving the trajectory
Save(format) (name)(number),Steps=(steps)
# Loop over the PDB files
Console Off
while 1
# Next PDB file present?
found = FileSize (name)(number).pdb
if not found
break
# Load it, and replace the previous one
ShowMessage 'Converting snapshot (number)...'
new = LoadPDB (name)(number)
CleanObj (new)
SupObj (new),1
SwapObj (new),1
DelObj (new)
# To save the snapshot, we start a simulation and set the simulation time
# to the point when the next trajectory snapshot will be saved automatically.
Sim On
Time (number*steps)
# Wait for one simulation cycle, so that the MD engine has the time to save.
Wait 1
Sim Off
# Next snapshot
number=number+1
Example 1:SaveXTC 1crn,2500 Save simulation snapshots every 5ps (if time step is 2*1fs) in file sim/1crn.xtc
(or just 1crn.xtc if subdirectory sim is not present). Example 2:SaveXTC Off Disable saving of snapshots in XTC format. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||