LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Particle Simulator

Hi! I need to build a particle in a box simulator, but what I have right now is giving me some trouble. For some reason, the code is reproducing the same plot as I run it. I define 4 arrays: x,y position and x,y initial velocity. Anyone have any idea why the plot is stalling?

0 Kudos
Message 1 of 8
(3,475 Views)

LabVIEW programming is based entirely on dataflow and parallelism. This is incredibly powerful and has lead to its success over the years (coupled with the graphical programming), but is usually one of the first things that new developers stumble over. Here's a simple resource to become more familiar with how it works. The Highlight Execution feature is a great way to watch how your application utilizes dataflow.

 

Your inputs aren't inside your loop,  so they only get read in once. See comments below:

Projectile.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 2 of 8
(3,465 Views)

Hey James. Thanks for the feedback! I tried implementing both changes you suggested, but for some reason, the graph still doesn't update. Not sure if you had any more suggestions? Thanks a bunch!

0 Kudos
Message 3 of 8
(3,460 Views)

Can you please set whatever values you're using as default values and then share your most recent version of you VI again? Also include what exactly isn't changing. Are you changing the array inputs and expect the graph to change?

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 8
(3,453 Views)

Hey James,

 

I set the initial velocity array, and end up adding to position array values each iteration of the loop (atleast that's what I wanted to happen). The graph should be able to update with each addition to the position. Attached is the most recent vi, with example velocities setup. Thanks!

 

 

0 Kudos
Message 5 of 8
(3,448 Views)

Why are you iterating the number generator 5 times with shift registers? That 5 iteration For loop is doing nothing.

 

You're using Index Array on both your input arrays and the random number arrays. This will only be effective if they are the same size. It looks like you have everything set to 5, so if you use length 5 input arrays and Number of Points = 5, this should work just fine.

 

When i alter the array input values during runtime, one point moves around at a time depending on which index of the array I'm editing. Is this not what you want to happen? Do you want all points to move?

 

You seem to misunderstand how shift registers work. They're just a memory space from loop to loop. Some of your tunnels can be simplified to auto-indexing tunnels instead. This code below operates the same way as yours:

Projectile2.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 6 of 8
(3,442 Views)

Great, I'm not sure why there was a for loop around my RNG.

On the graph though, I want the plot to actively update, so that all the points move with time, without altering the input array. Is there an easy way (maybe just looping a section of my code), to make it continuous?

 

Thanks!

0 Kudos
Message 7 of 8
(3,429 Views)

You want the "particles" to change randomly through time? Move the random number generation loop inside the main loop just like the inputs.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 8 of 8
(3,426 Views)