Skip to content

Commit

Permalink
fixing a few legacy networkx commands. Fixes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
peteboyd committed Dec 13, 2019
1 parent 51af69c commit 1065ff3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions lammps_interface/lammps_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ def unique_atoms(self, g):
if data['force_field_type'] is None:
if data['h_bond_donor']:
# add neighbors to signify type of hbond donor
label = (data['element'], data['h_bond_donor'], molid, tuple(sorted([g.node[j]['element'] for j in g.neighbors(node)])))
label = (data['element'], data['h_bond_donor'], molid, tuple(sorted([g.nodes[j]['element'] for j in g.neighbors(node)])))
else:
label = (data['element'], data['h_bond_donor'], molid)
else:
if data['h_bond_donor']:
# add neighbors to signify type of hbond donor
label = (data['force_field_type'], data['h_bond_donor'], molid, tuple(sorted([g.node[j]['element'] for j in g.neighbors(node)])))
label = (data['force_field_type'], data['h_bond_donor'], molid, tuple(sorted([g.nodes[j]['element'] for j in g.neighbors(node)])))
else:
label = (data['force_field_type'], data['h_bond_donor'], molid)

Expand Down Expand Up @@ -447,7 +447,7 @@ def assign_force_fields(self):
# prompt for ForceField?
rep = self.subgraphs[self.molecule_types[mtype][0]]
#response = input("Would you like to apply a new force field to molecule type %i with atoms (%s)? [y/n]: "%
# (mtype, ", ".join([rep.node[j]['element'] for j in rep.nodes()])))
# (mtype, ", ".join([rep.nodes[j]['element'] for j in rep.nodes()])))
#ff = self.options.force_field
#if response.lower() in ['y','yes']:
# ff = input("Please enter the name of the force field: ")
Expand All @@ -459,7 +459,7 @@ def assign_force_fields(self):
ff = self.options.mol_ff
if ff is None:
ff = self.options.force_field
atoms = ", ".join([rep.node[j]['element'] for j in rep.nodes()])
atoms = ", ".join([rep.nodes[j]['element'] for j in rep.nodes()])
print("WARNING: Molecule %s with atoms (%s) will be using the %s force field as no "%(mtype,atoms,ff)+
" value was set for molecules. To prevent this warning "+
"set --molecule-ff=[some force field] on the command line.")
Expand Down Expand Up @@ -531,7 +531,7 @@ def compute_simulation_size(self):
# prompt for replication of this molecule in the supercell.
rep = self.subgraphs[self.molecule_types[mtype][0]]
response = input("Would you like to replicate molceule %i with atoms (%s) in the supercell? [y/n]: "%
(mtype, ", ".join([rep.node[j]['element'] for j in rep.nodes()])))
(mtype, ", ".join([rep.nodes[j]['element'] for j in rep.nodes()])))
if response in ['y', 'Y', 'yes']:
for m in self.molecule_types[mtype]:
self.subgraphs[m].build_supercell(supercell, self.cell, track_molecule=True, molecule_len=molcount)
Expand Down
24 changes: 12 additions & 12 deletions lammps_interface/structure_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ def detect_clusters(self, num_neighbors, tol, type='Inorganic', general_metal=Fa
# found cluster
# update the 'hybridization' data
for i,j in clique:
self.nodes[i]['special_flag'] = cluster.node[j]['special_flag']
self.nodes[i]['special_flag'] = cluster.nodes[j]['special_flag']
cluster_found = True
print("Found %s"%(name))
store_sbus.setdefault(name, []).append([i for (i,j) in clique])
Expand Down Expand Up @@ -1281,13 +1281,13 @@ def build_supercell(self, sc, lattice, track_molecule=False, molecule_len=0, red

# keep track of original index value from the unit cell.
for i in range(1, totatomlen+1):
graph_image.node[unit_node_ids[i-1]+offset]['image'] = unit_node_ids[i-1]
graph_image.nodes[unit_node_ids[i-1]+offset]['image'] = unit_node_ids[i-1]
if track_molecule:
self.molecule_images.append(graph_image.nodes())
graph_image.molecule_id = orig_copy.molecule_id + mol_offset
# update cartesian coordinates for each node in the image
for node in graph_image.nodes():
data = graph_image.node[node]
data = graph_image.nodes[node]
n_orig = data['image']
if track_molecule:
data['molid'] = graph_image.molecule_id
Expand Down Expand Up @@ -1353,8 +1353,8 @@ def build_supercell(self, sc, lattice, track_molecule=False, molecule_len=0, red
n1,n2 = graph_image.sorted_edge_dict[(v1,v2)]
# flag boundary crossings, and determine updated nodes.
# check symmetry flags if they need to be updated,
n1_data = graph_image.node[n1]
n2_data = graph_image.node[n2]
n1_data = graph_image.nodes[n1]
n2_data = graph_image.nodes[n2]
try:
n1_orig = n1_data['image']
n2_orig = n2_data['image']
Expand Down Expand Up @@ -1454,7 +1454,7 @@ def build_supercell(self, sc, lattice, track_molecule=False, molecule_len=0, red
union_graphs.append(graph_image)
for G in union_graphs:
for node in G.nodes():
data = G.node[node]
data = G.nodes[node]
self.add_node(node, **data)
#once nodes are added, add edges.
for G in union_graphs:
Expand Down Expand Up @@ -1649,8 +1649,8 @@ def write_CIF(graph, cell):
sym = data['symflag']


label1 = "%s%i"%(graph.node[n1]['element'], n1)
label2 = "%s%i"%(graph.node[n2]['element'], n2)
label1 = "%s%i"%(graph.nodes[n1]['element'], n1)
label2 = "%s%i"%(graph.nodes[n2]['element'], n2)
c.add_data("bonds", _geom_bond_atom_site_label_1=
CIF.geom_bond_atom_site_label_1(label1))
c.add_data("bonds", _geom_bond_atom_site_label_2=
Expand Down Expand Up @@ -1831,8 +1831,8 @@ def write_RASPA_CIF(graph, cell,classifier=0):
# sym = data['symflag']


# label1 = "%s%i"%(graph.node[n1]['element'], n1)
# label2 = "%s%i"%(graph.node[n2]['element'], n2)
# label1 = "%s%i"%(graph.nodes[n1]['element'], n1)
# label2 = "%s%i"%(graph.nodes[n2]['element'], n2)
# c.add_data("bonds", _geom_bond_atom_site_label_1=
# CIF.geom_bond_atom_site_label_1(label1))
# c.add_data("bonds", _geom_bond_atom_site_label_2=
Expand Down Expand Up @@ -1879,7 +1879,7 @@ def write_RASPA_sim_files(lammps_sim,classifier=0):

if(int(data['image']) > max_image):
max_image = int(data['image'])
#keys.append(lammps_sim.graph.node[n]['force_field_type'])
#keys.append(lammps_sim.graph.nodes[n]['force_field_type'])

elif(classifier == 1):
for node, data in sorted(lammps_sim.graph.nodes_iter2(data=True)):
Expand All @@ -1890,7 +1890,7 @@ def write_RASPA_sim_files(lammps_sim,classifier=0):

if(int(data['image']) > max_image):
max_image = int(data['image'])
#keys.append(lammps_sim.graph.node[n]['force_field_type'])
#keys.append(lammps_sim.graph.nodes[n]['force_field_type'])

print(max_image)
for i in range(len(data_list)):
Expand Down

0 comments on commit 1065ff3

Please sign in to comment.