39 lines
827 B
Nim
39 lines
827 B
Nim
import particle
|
|
import parsexyz
|
|
import forces
|
|
|
|
import strformat
|
|
import os
|
|
|
|
# what's the input file name?
|
|
if paramCount() != 2:
|
|
echo "Usage: ./main inputfile.xyz settingName"
|
|
quit 1
|
|
if not fileExists("ffs.toml"):
|
|
echo "Error: input.toml doesn't exist"
|
|
quit 2
|
|
let xyzPath = paramStr(1)
|
|
let ffName = paramStr(2)
|
|
echo &"Using {xyzPath} as input, {ffName} as calculation settings"
|
|
|
|
let ff = newForceField("ffs.toml", ffName)
|
|
|
|
var particles: seq[Particle] = parseXyz(xyzPath)
|
|
|
|
applyExtraVel(particles, ff) # TODO replace this
|
|
|
|
# open the output file
|
|
let f = open(xyzPath, fmAppend)
|
|
var saveCounter = 0
|
|
|
|
var t = 0.0
|
|
while t < ff.maxt:
|
|
iterate(particles, ff, t)
|
|
inc saveCounter
|
|
if saveCounter >= ff.saveInterval:
|
|
saveCounter = 0
|
|
appendXyz(f, particles, t)
|
|
t += ff.dt
|
|
|
|
# cleanup
|
|
f.close() |