Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
comp-sci-project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nguyed99
comp-sci-project
Commits
10299ae9
Commit
10299ae9
authored
1 year ago
by
JayM0826
Browse files
Options
Downloads
Patches
Plain Diff
implement visualize_trajectory_3d
parent
8b9cc599
Branches
Branches containing commit
No related tags found
1 merge request
!8
implement leapfrog and stormer_verlet
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jobs/src/visualization.py
+45
-0
45 additions, 0 deletions
jobs/src/visualization.py
with
45 additions
and
0 deletions
jobs/src/visualization.py
+
45
−
0
View file @
10299ae9
import
matplotlib.pyplot
as
plt
import
inspect
def
visualize_trajectory_3d
(
trajectory
):
'''
input:
trajectory should be 3D nparray:
first: the number of particles
second: 3, the coordinates of x,y,z
third: the nparray with the capacity of the number of steps
'''
print
(
f
"
visualize the trajectory_3d:--------------Running---------------------
"
)
# figure
plt
.
style
.
use
(
'
dark_background
'
)
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
projection
=
'
3d
'
)
# # choose a different color for each trajectory
# colors = plt.cm.jet(np.linspace(0, 1, N))
#
# # set up lines and points
# lines = sum([ax.plot([], [], [], '-', c=c)
# for c in colors], [])
# pts = sum([ax.plot([], [], [], 'o', c=c)
# for c in colors], [])
steps
=
len
(
trajectory
[
0
][
0
])
for
i
in
range
(
steps
):
# print (i)
# clear the current figure
plt
.
cla
()
xp
=
trajectory
[:,
0
,
max
(
i
-
50
,
0
):
i
+
1
]
yp
=
trajectory
[:,
1
,
max
(
i
-
50
,
0
):
i
+
1
]
zp
=
trajectory
[:,
2
,
max
(
i
-
50
,
0
):
i
+
1
]
# plotting the trails
ax
.
scatter
(
xp
,
yp
,
zp
,
s
=
1
,
color
=
'
red
'
)
ax
.
scatter
(
trajectory
[:,
0
,
i
],
trajectory
[:,
1
,
i
],
trajectory
[:,
2
,
i
],
s
=
10
,
color
=
'
white
'
)
ax
.
set_xlabel
(
'
X Label
'
)
ax
.
set_ylabel
(
'
Y Label
'
)
ax
.
set_zlabel
(
'
Z Label
'
)
ax
.
set_title
(
f
'
step:
{
i
}
, Total Step:
{
steps
}
'
)
plt
.
pause
(
0.001
)
plt
.
show
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment