Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force calculation suggestion #30

Open
BradenDKelly opened this issue Jan 24, 2021 · 5 comments
Open

Force calculation suggestion #30

BradenDKelly opened this issue Jan 24, 2021 · 5 comments

Comments

@BradenDKelly
Copy link

BradenDKelly commented Jan 24, 2021

I was just looking through the Lennard-Jones force calculations and noticed that every time you calculate the force between two atoms, you are calculating the mixing rules

σ = sqrt(atom_i.σ * atom_j.σ) 
ϵ = sqrt(atom_i.ϵ * atom_j.ϵ)

Given the simplicity of the force calculation, these two square roots likely are adding a considerable amount of flops to the simulation. Typically simulation codes will precalculate the mixing rules and then simply look up the necessary sigma and epsilon, i.e.,

σ = vdw_table.σ(atom_i.type,  atom_j.type) 
ϵ = vdw_table.ϵ(atom_i.type,  atom_j.type)

I do not know if type is available, but, incorporating it into the atom struct so that you can use this parameter lookup table, will likely speed up the calculation a reasonable amount. The type would be an integer, so it should be isbits true and so shouldn't interfere with CUDA/GPU. This will also make the structures lighter since only type needs to be saved per atom, and not epsilon and sigma (also, other force-fields, such as EXP-6, have more parameters so you save even more with them).

Also, usually the size parameters use the Lorenz mixing rule i.e., are

σ = (atom_i.σ + atom_j.σ) / 2

It would be good to add the feature allowing the user to select the mixing rules to use for each parameter type.

@jgreener64
Copy link
Collaborator

Thanks for the advice, I'll add it to the to-do list.

@BradenDKelly
Copy link
Author

It is probably worth noting that the degrees of freedom are only 3*N, where N is number of particles, for the Andersen thermostat. DF are different for stochastic or deterministic thermostats, and this rippled to kinetic energy. The difference is small, but nonetheless, worth accounting for.

@jgreener64
Copy link
Collaborator

Thanks, let me know as you see anything else, it's useful.

@ehsanirani
Copy link
Contributor

I think @BradenDKelly suggestion would enhance the performance and simplicity of the api. The suggested table can also have a r_cutoff field for each pair of particle types. Then something like negative values can be set to it to exclude that pair of particle types from force calculation (or neighbor searching). That's the method that HOOMD-Blue uses.

@jgreener64
Copy link
Collaborator

I think it's a good idea but will wait to see how the GPU kernel work (#60) progresses as this may require a refactor of other parts of the API too.

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

No branches or pull requests

3 participants