-
Notifications
You must be signed in to change notification settings - Fork 33
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
Topology update calls #85
Changes from 8 commits
8ef760b
c1053c4
c0bfef3
b9bc4c4
8808d92
493a73d
35d1e00
ec80852
259dfa9
beaa8c6
4a6112f
34b7a5b
8946968
72d818c
6ab7250
fbe8ae8
f25ee75
ed2baed
8da8035
21540c3
13d205c
5b1320c
5861c62
bd0256c
c6b1a80
6bcc68d
7a31da9
2680000
4f81407
af31c96
bb67ac0
9b9e448
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,12 @@ def __init__(self, name="Topology", box=None): | |
self._site_list = list() | ||
self._connection_list = list() | ||
|
||
self._atom_types = list() | ||
self._connection_types = list() | ||
|
||
self._atom_type_functionals = list() | ||
self._connection_type_functionals = list() | ||
|
||
def add_site(self, site): | ||
self._site_list.append(site) | ||
|
||
|
@@ -42,6 +48,22 @@ def box(self, box): | |
def n_sites(self): | ||
return len(self._site_list) | ||
|
||
@property | ||
def atom_types(self): | ||
return self._atom_types | ||
|
||
@property | ||
def connection_types(self): | ||
return self._connection_types | ||
|
||
@property | ||
def atom_type_functionals(self): | ||
return [atype.nb_function for atype in self.atom_types] | ||
|
||
@property | ||
def connection_type_functionals(self): | ||
return [ctype.potential_function for ctype in self.connection_types] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
might be better to call this |
||
|
||
def positions(self): | ||
xyz = np.empty(shape=(self.n_sites, 3)) * u.nm | ||
for i, site in enumerate(self.site_list): | ||
|
@@ -63,13 +85,36 @@ def n_connections(self): | |
def add_connection(self, connection): | ||
self._connection_list.append(connection) | ||
|
||
def update_top(self): | ||
""" Update the entire topology's unique types | ||
|
||
Notes | ||
----- | ||
Will update: atom_types, connnection_types | ||
""" | ||
self.update_atom_types() | ||
self.update_connection_list() | ||
self.update_connection_types() | ||
|
||
def update_atom_types(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fine for right now, but I can see this being an issue with a large system and you only change one atom type. |
||
self._atom_types = [] | ||
for site in self.site_list: | ||
if site.atom_type not in self._atom_types: | ||
self._atom_types.append(site.atom_type) | ||
|
||
def update_connection_list(self): | ||
for site in self.site_list: | ||
for neighbor in site.connections: | ||
temp_connection = Connection(site, neighbor, update=False) | ||
if temp_connection not in self.connection_list: | ||
self.add_connection(Connection(site, neighbor, update=True)) | ||
|
||
def update_connection_types(self): | ||
self._connection_types = [] | ||
for connection in self.connection_list: | ||
if connection.connection_type not in self._connection_types: | ||
self._connection_types.append(connection.connection_type) | ||
|
||
def __repr__(self): | ||
descr = list('<') | ||
descr.append(self.name + ' ') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. this could get confusing since site and top have the same method name.
What would be the difference if someone used
top.add_connection
but the connectionType was justNone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ties into #86 , but should hopefully be resolved when #98 gets merged