mphowardlab / relentless

Computational materials design, with less code.
https://relentless.readthedocs.io
BSD 3-Clause "New" or "Revised" License
9 stars 1 forks source link

Composite pair potentials #27

Closed mphoward closed 3 years ago

mphoward commented 4 years ago

This is a proposal to allow the user to compose pair potentials from existing ones with coupling between parameters. This would be very useful for making interactions defined piecewise. An example would be a WCA core with fixed epsilon/sigma and a Lennard-Jones tail of varying attraction relative to epsilon, called lambda. Here, the beginning of the attractive tail is coupled to the WCA cutoff. All the functions could be reimplemented, but they could productively crib from the existing Lennard-Jones potential.

To support this, we should change the _energy, _force, and _derivative methods to be classmethods. This will allow the user to call them directly without needing to instantiate the class. The composite potential will define the parameters that it is expecting, and it can then forward them to the appropriate class method. This level of intentional control is good because the user can pick which parameters get coupled to each other, etc.

Here's what an energy function might look like (this is a scalar r, but can be generalized to an array)

@classmethod
def _energy(cls, r, epsilon, sigma, lambda):
    if r <= 2**(1./6.)*sigma:
        return LennardJones._energy(r, epsilon, sigma)
    else:
        return LennardJones._energy(r, epsilon*lambda, sigma)
mphoward commented 3 years ago

I don't think there is really a need for this anymore because DesignVariables can now be shared between potentials and used as cutoffs. Closing for now, can be reopened if someone thinks of a use-case we're missing.