Trajectory file with varying number of atoms

Issue #162 resolved
Andrea created an issue

Hello, We are three prospective AMP users and we were wondering if there was a way to load as trajectory files, snapshots composed of varying number of atoms, as it seems from ASE that this can be only done with a database module.

Thanks, G & A & R

Comments (3)

  1. andrew_peterson repo owner

    Yes, that's a bit of a limitation of the ASE trajectory format. The database is a good way to proceed. If you want to avoid that format, you can just feed Amp a list of images that you assemble in your script. E.g., something like

    images1 = ase.io.read('images1.traj', ':')
    images2 = ase.io.read('images2.traj', ':')
    images = images1 + images2
    

    (then pass images to Amp.train). Does that work?

    If you have suggestions for a better way, please let us know! We are trying to avoid creating yet another file format for atoms.

  2. Efrem Braun

    I don't think that ASE trajectory files have to have a constant number of atoms. Each of the "Atoms" objects in the trajectory is independent. My Amp script does the following (quite similar to what Andrew wrote above):

    # Make training set trajectory
    traj_train = Trajectory('training.traj', mode='w')
    training_set_1 = read('input_1.xyz', index=(':'), format='xyz')
    for atoms in training_set_1:
        traj_train.write(atoms)
    training_set_2 = read('input_2.xyz', index=(':'), format='xyz')
    for atoms in training_set_2:
        traj_train.write(atoms)
    calc.train(images='training.traj')
    

    I think the issue can be closed.

  3. andrew_peterson repo owner

    Yes, this was fixed upstream in ASE. The trajectory format now can take variable numbers of atoms.

  4. Log in to comment