def prepare_handler(cfg):
"""
Load all files into single object.
"""
positions, velocities, box = None, None, None
_path = cfg['_path']
forcefield = cfg.pop('forcefield', None)
topology = sanitize_path_for_file(cfg.pop('topology'), _path)
if 'checkpoint' in cfg:
restart_path = sanitize_path_for_file(cfg['checkpoint'], _path)
restart = Restart.load(restart_path)
positions = restart.positions
velocities = restart.velocities
box = restart.box
if 'positions' in cfg:
positions_path = sanitize_path_for_file(cfg.pop('positions'), _path)
positions = Positions.load(positions_path)
box = BoxVectors.load(positions_path)
if 'velocities' in cfg:
velocities_path = sanitize_path_for_file(cfg.pop('velocities'), _path)
velocities = Velocities.load(velocities_path)
if 'box' in cfg:
box_path = sanitize_path_for_file(cfg.pop('box'), _path)
box = BoxVectors.load(box_path)
options = {}
for key in 'positions velocities box forcefield'.split():
value = locals()[key]
if value is not None:
options[key] = value
return SystemHandler.load(topology, **options)
评论列表
文章目录