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

Abstract potential part of AtomType class into a new class #96

Merged
merged 15 commits into from
Mar 20, 2019

Conversation

mattwthompson
Copy link
Member

The idea behind this is that the part of the AtomType class that deals with the actual potential will be nearly identical to how other components (ConnectionType, etc.) deal with it, so we should abstract it to a higher level and let those components inherit from it.

@ahy3nz ahy3nz added the WIP work in progress - do not merge label Mar 16, 2019
@mattwthompson mattwthompson marked this pull request as ready for review March 16, 2019 18:00
@mattwthompson mattwthompson added ready for review and removed WIP work in progress - do not merge labels Mar 16, 2019
@ahy3nz ahy3nz mentioned this pull request Mar 16, 2019
Copy link
Collaborator

@ahy3nz ahy3nz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some documentation to AtomType and Potential? I got slipped up that independent_vars is a set of sympy.Symbol and not set of str

Would it be better for AtomType to have a property/attribute nb_potential, and this nb_potential is a subclass of Potential? Right now AtomType is a subclass of Potential, so expression, params, ind_vars are all properties

topology/core/potential.py Outdated Show resolved Hide resolved
topology/core/potential.py Outdated Show resolved Hide resolved
@ahy3nz
Copy link
Collaborator

ahy3nz commented Mar 16, 2019

What's your opinion on "independent variable" or "expression" checking? At some point we need to make sure all our Potential expressions are 'canonical' (if someone wants to make a BondType, make sure that r is the independent variable, or make sure theta is the independent variable for AngleType)?

@mattwthompson
Copy link
Member Author

mattwthompson commented Mar 16, 2019 via email

Copy link
Collaborator

@justinGilmer justinGilmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small changes and suggestions for the first go around.

topology/core/atom_type.py Outdated Show resolved Hide resolved
topology/core/atom_type.py Outdated Show resolved Hide resolved
topology/core/atom_type.py Outdated Show resolved Hide resolved
topology/core/atom_type.py Outdated Show resolved Hide resolved
topology/core/atom_type.py Show resolved Hide resolved
topology/core/atom_type.py Show resolved Hide resolved
topology/core/atom_type.py Outdated Show resolved Hide resolved
topology/core/atom_type.py Outdated Show resolved Hide resolved
topology/core/atom_type.py Show resolved Hide resolved
topology/core/potential.py Outdated Show resolved Hide resolved
@ahy3nz
Copy link
Collaborator

ahy3nz commented Mar 18, 2019

Would it be better for AtomType to have a property/attribute nb_potential, and this nb_potential is a subclass of Potential? Right now AtomType is a subclass of Potential, so expression, params, ind_vars are all properties

This is still a lingering question I'd like to hear other opinions about. So rather than AtomType(Potential) with all attributes of Potential,; it could be AtomType(object), with a property that is a Potential.

For example, AtomType.potential = LennardJonesPotential(Potential)

Co-Authored-By: mattwthompson <matt.thompson@vanderbilt.edu>
@mattwthompson
Copy link
Member Author

I like the inheritance as I currently have it in this PR - I think it makes sense for those attributes to be directly attributes of an AtomType instead of one layer deeper. All of the attributes we currently store in Potential make sense to me as attributes of AtomType (and further BondType, etc.). I grant that independent_variables as an attribute here feels clunky, but it's going to have to be stored somewhere anyway.

More than anything, to me, it's too deep to try and access a sigma value by doing topology.atoms[0].atom_type.potential.parameters['sigma']. The atom type exists only to separate the functional form from the specific atom, so I see this extra layer as unnecessary.

I also don't think that the approach AtomType.potential = LennardJonesPotential(Potential) works well either way we think about this storage, since we'd want to inherit .expression and .independent_variables from a library but not .parameters. I'm not sure how best to support this behavior (my first idea is a Potential.inhereit_potential() function that assigns .expression and .independent_variables from a library of known potentials set sets the parameters to be empty or something). But I don't see how my_new_atom_type.potential.inherit_potential() would be an improvement over my_new_atom_type.inherit_potential() for this feature.

@ahy3nz
Copy link
Collaborator

ahy3nz commented Mar 18, 2019

From discussion, we'll leave the inheritance as is, AtomType(Potential), which parallels BondType(Potential), etc. So AtomTypes will carry their potential expression, parameters, independent variables. Functionality regarding Potential.inherit_potential() was not discussed, and might be out of the scope of this PR.

From me, I think this PR is ready to merge

Copy link
Collaborator

@justinGilmer justinGilmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or two final comments/possible requests, then I am ready to approve.

topology/core/atom_type.py Show resolved Hide resolved
topology/core/potential.py Outdated Show resolved Hide resolved
topology/core/potential.py Outdated Show resolved Hide resolved
topology/core/potential.py Outdated Show resolved Hide resolved
@ahy3nz ahy3nz mentioned this pull request Mar 20, 2019
@justinGilmer justinGilmer merged commit 2d24a9d into master Mar 20, 2019
@mattwthompson mattwthompson deleted the abstract-potential branch February 28, 2020 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants