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

added simulation for brownian motion #388

Merged
merged 11 commits into from Mar 11, 2021

Conversation

SunTzunami
Copy link
Member

@SunTzunami SunTzunami commented Feb 27, 2021

I made a small simulation of 4 particles exhitbiting brownian motion using FURY.

Preview-

FURY.0.6.1.post164.dev0+g102c618.2021-02-27.17-38-38.mp4

@SunTzunami
Copy link
Member Author

New color scheme-

viz_brownian_motion

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Thank you for this new demo @SunTzunami!

See below for some comments. Overall, it would be good if you could reduce the number of actors.

Comment on lines 97 to 102
for i in range(num_particles):
coor_e = coords[i]
coords[i] = np.array(generatepath(coords[i], delta, time_step))
coordinates = np.array([[coords[i], coor_e]])
path_actor = actor.line(coordinates, colors[i], linewidth=3)
scene.add(path_actor)
Copy link
Contributor

Choose a reason for hiding this comment

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

You create a lot of actors in this loop. This is memory-consuming and performance greedy. it would be better if you could create only 4 line actors and update the path of each actor. Can you update this point? thank you.

###############################################################################
# Creating a container (cube actor) inside which the particle(s) move around

center1 = np.array([[0, 0, 0]])
Copy link
Contributor

Choose a reason for hiding this comment

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

this variable is unnecessary, you can feed the point directly on your cube actor if you have only 1 center

delta = 1.8
num_particles = 4
common_origin = np.array([0, 0, 0])
coords = [common_origin for i in range(num_particles)]
Copy link
Contributor

Choose a reason for hiding this comment

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

np.zeros((num_particles, 3)) instead

num_particles = 4
common_origin = np.array([0, 0, 0])
coords = [common_origin for i in range(num_particles)]
colors = [window.colors.red, window.colors.blue, window.colors.yellow,
Copy link
Contributor

Choose a reason for hiding this comment

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

please, try to use NumPy array

# Function that generates the path of the particles


def generatepath(point, delta, time_step):
Copy link
Contributor

Choose a reason for hiding this comment

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

generate_path instead



def generatepath(point, delta, time_step):
x, y, z = (point[i] for i in range(3))
Copy link
Contributor

Choose a reason for hiding this comment

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

I did not check what is inside the point variable. Why not x, y, z = point?

@SunTzunami
Copy link
Member Author

SunTzunami commented Mar 1, 2021

Hi @skoudoro ! Thanks for the really insightful review! I made the requested changes. The animation is rendered much better now after using numpy arrays and after reducing the number of actors. PTAL.

@pep8speaks
Copy link

pep8speaks commented Mar 8, 2021

Hello @SunTzunami! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-03-10 10:15:23 UTC

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Hi @SunTzunami,

Thank you for this simulation and all the updates. I need to play a bit with this tutorial and I will come back to you.
Thank you !

self.colors = colors
self.delta = delta
self.num_total_steps = num_total_steps
self.time_step = total_time/num_total_steps
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add space around the operator

self.path_actor = actor.line([self.position], colors, linewidth=3)
self.vertices = utils.vertices_from_actor(self.path_actor)
self.vcolors = utils.colors_from_actor(self.path_actor, 'colors')
self.no_vertices_per_point = len(self.vertices)/num_total_steps
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add space around the operator

nvpp, axis=0)

def update_path(self, counter_step):
if(counter_step < self.num_total_steps):
Copy link
Contributor

Choose a reason for hiding this comment

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

parenthesis are not needed here

@SunTzunami
Copy link
Member Author

Hi @skoudoro ! Thanks for the review! I made the requested changes and tweaked the code a bit to add more functionality. PTAL.

@skoudoro skoudoro merged commit 844e6a5 into fury-gl:master Mar 11, 2021
@skoudoro
Copy link
Contributor

Thanks @SunTzunami! This is a nice Tutorial, merging

@skoudoro skoudoro added this to the v0.7.0 milestone Mar 11, 2021
@SunTzunami
Copy link
Member Author

Thanks @skoudoro ! Should I add a gif for the same to the communication assets?

@skoudoro
Copy link
Contributor

Should I add a gif for the same to the communication assets?

yes 👍🏾

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