Skip to content

Conversation

@jhprinz
Copy link
Contributor

@jhprinz jhprinz commented Aug 15, 2017

Update of the lammps example with py3 compatibility. Note though, that lammps python package requires still python2.7!!! afaik

Feel free to add to this!

content of the script variable

# 3d Lennard-Jones melt

units		lj
atom_style	atomic
atom_modify	map array

lattice		fcc 0.8442
region		box block 0 4 0 4 0 4
create_box	1 box
create_atoms	1 box
mass		1 1.0

velocity	all create 1.44 87287 loop geom

pair_style	lj/cut 2.5
pair_coeff	1 1 1.0 1.0 2.5

neighbor	0.3 bin
neigh_modify	delay 0 every 20 check no

fix		1 all nve

variable        fx atom fx

run 1
import openpathsampling as paths
import openpathsampling.engines.lammps as eng

engine = eng.Engine(
    inputs=script,
    options={'n_steps_per_frame': 100 })  # translates to run 100 per OPS stored step

snap = engine.current_snapshot

# run 1000 steps from the current
traj = engine.generate_n_frames(1000)

traj
>> Trajectory(1000)

@ocaisa
Copy link

ocaisa commented Feb 26, 2018

Looking at lammps/lammps#419 I think the most recent version of the Python interface is Python3 compatible.

@king-michael
Copy link

king-michael commented Oct 2, 2018

Hello everybody,

I wanted to use OPS for my research, therefore i need this LAMMPS implementation and are willing to work on it.
I have gained a bit insight on LAMMPS and the LAMMPS interface for python the last years, so i think i can help from this side.

Where should make my pull requests than?
Here? or at @jhprinz or @dwhswenson fork?

Cheers,
Micha

@dwhswenson
Copy link
Member

Hi @king-michael,

Glad to hear of your interest! I think the most advanced version of the LAMMPS support is currently in my fork, in the jhp_lammps branch. @jhprinz initiated the work on LAMMPS support; in June I cleaned up a bunch of stuff and also added support for using LAMMPS computes as CVs in OPS, all in that branch.

@jhprinz, do you mind if I officially take over the work on adding LAMMPS support? As of yesterday, ensuring that OPS supports LAMMPS is literally my job description, so it makes sense for me to take the lead on a PR.

@king-michael: We're currently finalizing for the 1.0 release, which will be tied to the final version of the papers (we've replied to reviewer comments on the papers and are hopeful that they will be published soon). New engines will only be added to the core after that.

It seems that you're comfortable working from an experimental branch, so I'd recommend starting out working from that jhp_lammps branch of my fork. If you need help checking that branch out, let me know either here or by email and I can provide more detailed instructions. We don't have any LAMMPS-experienced users, so some behavior might be counterintuitive. Please let us know about anything like that; if it is something in the engine, we'd appreciate input on how to make it feel more native to LAMMPS user.

I would recommend holding off on any contributions for the very short term. My suggestion is that @jhprinz and I merge the LAMMPS engine under an experimental subpackage (after the 1.0 release) This will make it so that you can make PRs directly to this repo. BTW, here's a gist with a simple example using my branch: https://gist.github.com/dwhswenson/9830820dbd45aa44c362d66d8c3b7a13 (obviously, that may become out of date as I update my branch further, but right now it should work).

If there's something that you think really needs to be changed immediately, make those PRs against my jhp_lammps branch (but making PRs against non-default branches is really easy to get mixed up on, which is why I recommend holding off until we get it merged into experimental.)

At least, those are my suggestions. @jhprinz, any other thoughts?

@king-michael
Copy link

@dwhswenson: I allready checked out jhp_lammps.

There are a few things i found which can be improved (adding gpu support, reducing API calls, some other minor things).

But i ran also in some bugs, as it is: this version do not support NPT, and is only suitable for non-bonded systems! (LAMMPS works internally with a wrapped coordinates and an image flag in each dimension. This means restoring only the wrapped position (e.g. for a new shoot) may lead after some times to bonds spanning over a whole box, and with it to PPPM errors, atoms shooting through the box due to high bond energies and so on.

I'm happy to discuss all these things in detail in some pull request (at the moment i started to find work arounds but i guess with some insights on the ops package and its storage objects, things can be resolved differently. Till then i will just keep a list of things i changed (with comments and reasons) together so i can create the pull request after the 1.0 release.

Thank you for the gist, i will have a look into it.
At the moment i'm using the alanine dipeptide example.
(OpenMM- AMBER vs OpenMM -CHARMM vs LAMMPS - CHARMM) to check the changes i did.
If you have some other faster test systems (but complexer then pure LJ beads) where i could check the implementations against i would be grateful.

@mayank-agr
Copy link

Hi everyone,

I was searching for ways to implement TPS with LAMMPS and found this. Can you please tell me the updates on the lammps compatibility? I am comfortable with LAMMPS and its python interface, so I can help as well. Please reply soon.

Thanks,
Mayank

@dwhswenson
Copy link
Member

Hi @mayank-agr,

I think @king-michael has the most advanced setup for LAMMPS with OPS so far. I took @jhprinz's work here and added to it in order to get a minimal working example going, but didn't have a real-world application for it. I think that @king-michael fixed important problems that would be essential for real-world use (like correctly reloading system with bonds when there are periodic boundary conditions).

@king-michael : Do you have a branch that could be made into a pull request? I would recommend closing this PR and building off of yours instead. If it needs more stress testing, we could put it in as "experimental" and continue from there.

@mayank-agr
Copy link

Thanks for the reply, David. I believe @king-michael has a pull request to your lammps branch here:
https://github.com/king-michael/openpathsampling/pulls

I would appreciate if if I could start with a merged experimental branch, I will keep a watch for pull requests to get resolved.

Thanks,
Mayank

@king-michael
Copy link

Sorry, i stopped working on this quite some time ago.

In short: I had problems with bonded systems and the image flag (i think i solved it but i wasn't sure). I just implemented everything i needed from LAMMPS into OpenMM and used OpenMM instead. This was faster for me than riddling around if every thing is correct (and it was faster in terms of calculations, as my system was small enough for a single GPU).

@dwhswenson I will just close the remaing pull request on my repo so there wont be any confusions.

@mayank-agr feel free to you use what i did, but the difference are quite small. If your LAMMPS engine is crashing check the bonds (fix local -> compute bonds or VMD) they were screwed up in my case after some resetting of the positions but not changing the image flags.

Notes on implementing LAMMPS forces into OpenMM

  • just load a trajectory with your favorite tool into python and set the positions in LAMMPS / OpenMM
  • compare forces of the individual contributions per frame
  • The constant in the coulomb term differs between LAMMPS and OpenMM in the 6th digit or so. This leads to so some differences in the coloumb energy. Just apply a correction term over all pair interactions and you are fine. (Use np.testing.assert_array_almost_equal to check if the force arrays are the same)
  • in general for testing its better to use a system without periodic boundaries, NO kspace and a very LARGE coulomb cutoff when reevaluating your systems to avoid artifacts from grid spacing etc in the long range solver

@mayank-agr
Copy link

Hi

@king-michael thanks for the updates and suggetions. I am quite new to this, so let's see how much I try to keep up with lammps.

@both: I see that there is no overlap between @dwhswenson jhp_lammps and @king-michael patch_jhp_lammps but the latter is the most recently updated. I am not highly familiar with git but if the pull requests are solved in a way that I can download the most recent version from @dwhswenson then it will be easier for me to change/work on it.

Thanks,
Mayank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants