vmd教程 forces-tutorial
1TCLFORCES51TclForces
Inthisunit,youwilllearnaboutNAMD’sTclForcesfunctionality.AlthoughmanyuserneedswereanticipatedinthedevelopmentofNAMD,toanticipatethemallspeci callywouldbeimpossible.TclForcesallowsuserstoeasilysup-plementthebuilt-inconstraintandforcefunctionalitywithscript-basedforces.
1.1Introduction
ThebasicideaoftclForcesissimple:weprovideNAMDwithaTclscriptwhichtellsNAMDtoapplycertainforcestocertainatoms.Theonlyspecialrequirementofthisscriptisthatitde neacommandnamedcalcforces.ThiscommandiscalledbyNAMDeachtimestep.Withinthescript,wecanaccessatomicIDs,positionsandmasses.Inthisunit,wewillseehowtousetclForcesthroughfourexamplesofincreasingcomplexity.
1.2Example1:ConstantForces
Forour rstexposuretotclForces,wewilldosomethingverysimple:applyaconstantnetforcetoasystem.
1First,let’slookattheNAMDcon guration le.Gotothedirectoryforces-tutorial-files/tclForcesFiles/pushandopenthe lepush.namd.Everythingisstandardaboutituntiltheend,whereweseesomeunfa-miliarlines:
tclforceson
setlinaccel"3000"
tclforcesscriptpush.tcl
The rstlinesimplyturnstclForceson.Thesecondsetsaparameterfortheaccelerationthatwe’lluseinthescript,aswe’llsoonsee.Thelastlineisthenameofthescriptwhichactuallydoesthe
work.In-linescripts.Itisalsopossibletoincludethecontentsofyour
tclForcesscriptdirectlyinyourNAMDcon guration le.Instead
ofprovidingthenameofascript,wecouldinsteadwritethescript
contentswithincurlybraces:
tclforcesscript{
...contentsofscript...
}
Thisismostusefulforparticularlyshortscripts.
2Nowlet’slookatthescript.Openthe lepush.tcl,inthesamedirectory.