# YASARA MACRO # TOPIC: 3. Molecular Dynamics # TITLE: Play back a molecular dynamics trajectory # REQUIRES: Dynamics # AUTHOR: Elmar Krieger # LICENSE: GPL # DESCRIPTION: This macro plays back a molecular dynamics simulation, looping back to the start. # You can either set the target structure by clicking on Options > Macro > Set target, # or by uncommenting the line below and specifying it directly. #MacroTarget = 'c:\MyProject\1crn' # Set playback waittime (1 is maximum playback speed) waittime=12 # Choose trajectory format, sim or xtc format='sim' # Forcefield to use (these is a YASARA commands, so no '=' used) ForceField AMBER03 # In case the simulation was run without 'CorrectDrift on' and the solute diffused # through a periodic boundary, you can keep it centered here by specifying the number # of an atom close to the core of the solute, which will be kept at the cell center. central=0 # No changes required below this point! # Speed up playback using short dummy cutoff and no longrange forces Cutoff 2.62 Longrange None # Do we have a target? if MacroTarget=='' RaiseError "This macro requires a target. Either edit the macro file or click Options > Macro > Set target to choose a target structure" # Do we have a scene with water? scene = FileSize (MacroTarget)_water.sce if not scene RaiseError 'Could not find initial scene file (MacroTarget)_water.sce. Click Options > Macro > Set target and choose the target structure for which a simulation has been run before' # Load the scene LoadSce (MacroTarget)_water # Pick a nice style Style Backbone=Ribbon,Sidechain=Stick Console off i=00000 filename = '(MacroTarget)(i).(format)' while 1 if format=='sim' # See if next snapshot is present sim = FileSize (MacroTarget)(i).sim if not sim # Loop back to start i=00000 # Load the snapshot LoadSim (MacroTarget)(i) i=i+1 else i=i+1 last = LoadXTC (filename),(i) if last # Loop back to start i=00000 # Show the simulation time simtime=Time ShowMessage 'Current simulation time is (0+simtime/1000) picoseconds.' if central # Keep a chosen atom at the center of the cell (Cell returns center as values 7-9) _,_,_,_,_,_,cen() = Cell pos() = PosAtom (central) MoveAtom all,(cen-pos) # Make sure that the simulation does not continue while we wait Sim Pause # Wait a bit Wait (waittime)