vmd教程 forces-tutorial(17)

发布时间:2021-06-05

vmd教程 forces-tutorial

1TCLFORCES173Nowopenthescriptrot-c.tcl.The rstdi erencesstartatline58.We rstsetupaforceslist,whichisavariabletoholdthevaluesoftheforceswewillapplytotheatoms.Wealsosetupsomecountervariables:forcecountandprintcountarebothincrementedeachtimestep.WhenforcecountequalsforcesRecalcFreq,theforcesarerecalculated,andforcecountisresettozero,asseenbelow.

setforces{}

foreachindex$atoms{

lappendforces"0.00.00.0"

}

setforcecount$forcesRecalcFreq

setprintcount0

4Nowwebeginthecalcforcescommand.First,asusual,wedeclareourglobalvariables.Wethenapplytheforcesthataresavedintheforceslist.

proccalcforces{}{

globalatomsnumatomsforcemultmassesavgmassforces

globalforcesRecalcFreq

globalforcecountprintcount

foreachatom$atomsforce$forces{

addforce$atom$force

}

5Next,wetestwhethertheforceswillberecalculatednexttimestep,andifso,tellNAMDthatwewillwantatomiccoordinatesforthetargetatomsbycallingaddatom:

if{$forcecount==[expr$forcesRecalcFreq-1]}{

print"Addingatomspriortoreconfiguringforcesat\

$printcount"

foreachatom$atoms{

addatom$atom

}

}

Aswewillseeshortly,wecallclearconfigaftertheforcesarerecalcu-lated.Thiscallerasesalladdatomrecords;withoutit,thecoordinatesoftheatomsaddedwillbeavailableeverytimestep,independentlyofwhetherwecallloadcoords,andthereforemuchofthepotentialspeedgainwillbelost.However,thismeansthataddatommustbecalledagaineachtimewewanttorecalculateforces,andbecauseoftechnicaldetailsithastobedoneatleastonestepbeforethecoordinateswillbeused.

6Nextwehavethecodethatrecalculatestheforce.Asalludedtoabove,therecalculationhappenswhenforcecountequalsforcesRecalcFreq.

精彩图片

热门精选

大家正在看