Skip to content

Commit

Permalink
[#154] Added bond graphing (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
BraydenThompson authored Apr 9, 2024
1 parent e514744 commit 37af78f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 16 deletions.
48 changes: 35 additions & 13 deletions GoVizzy/GoVizzy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,39 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "c31b2aca",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "53607c596d444a7e970ddd843418c366",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"AppLayout(children=(HBox(children=(Output(layout=Layout(height='100%', width='70%')), VBox(children=(HBox(chil…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e07b178719f64af8ba8a442d37d4201e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Text(value='', description='File Name:'), Button(description='Submit', style=ButtonStyle())), l…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%run Main.py\n"
]
Expand All @@ -37,18 +66,11 @@
"cell_type": "code",
"execution_count": null,
"id": "c75f164c-2d9f-44b9-8875-82d7f34a7d4e",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"from gv_ui import meshes\n",
"import cube_viskit as cv\n",
"\n",
"new_cube = cv.Cube()\n",
"new_cube.load_cube(\"data/rhopol.cube\")\n",
"new_cube.get_bonds()\n",
"\n",
"meshes.plot_bonds(new_cube)"
]
"source": []
}
],
"metadata": {
Expand Down
1 change: 1 addition & 0 deletions GoVizzy/gv_ui/gv_ui/DisplayUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def display_cube(cube):
elif selected_option == 'Mesh Options':
visualizer.display_cell()
atom_meshes = meshes.plot_atoms(cube)
meshes.plot_bonds(cube)

# Additional View
elif selected_option == 'Color Options':
Expand Down
19 changes: 16 additions & 3 deletions GoVizzy/gv_ui/gv_ui/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,21 @@ def plot_bonds(cube: Cube):
Plots the bonds between atoms in the current Cube object, using the list of atom pairs,
and the positions of the atoms in the graph.
'''
cube.get_bonds()
num_pts = 1000
for bond in cube.bonds:
print("Atoms: ",bond," Real Pos: ", )
for atom in bond:
print(cube.atoms.get_scaled_positions()[atom])
atomPos1 = cube.atoms.get_scaled_positions()[bond[0]]
x1, y1, z1 = tuple(p * cube.data3D.shape[idx] / Bohr for idx, p in enumerate(atomPos1))
atomPos2 = cube.atoms.get_scaled_positions()[bond[1]]
x2, y2, z2 = tuple(p * cube.data3D.shape[idx] / Bohr for idx, p in enumerate(atomPos2))

# y = x1 -> x2
# y = y1 -> y2
# z = z1 -> z2
X = np.linspace(x1, x2, num_pts)
Y = np.linspace(y1, y2, num_pts)
Z = np.linspace(z1, z2, num_pts)
p = ipv.plot(X, Y, Z)
p.material.visible = True
p.size = 3.

0 comments on commit 37af78f

Please sign in to comment.