## Example 7.3 – Line and Vector Forces combined with Point Charges

The previous vector field examples looked at patterns with Point Charges and with Spin Forces. In this next example, I will look at two additional basic forces in the Grasshopper Field Components set. These are Line Charges, which act similar to point charges, but act along an entire line instead, and the Vector Force, which gives an overall directionality to all of the elements in the field. This last force is a bit different than the rest in that it has very few parameters, and that just a little bit of force goes a long way. We will see this in a minute.

For this example, we are going to imagine the wind is blowing, or the water is flowing, and there are several obstacles in the way. These obstacles will create turbulent conditions behind them. Note, this is a pseudo-scientific simulation, but could be sufficient for basic fluid dynamic sketch studies, but you should not mistake this, again, for real, computational fluid dynamics, which uses much more complicated equations.

**Step One – Basic Setup**

To start, you should draw (in Rhino) a few circular “Obstacles” that will deflect the “wind” – or water, however you want to think about it – in your field. You will also draw a boundary for your field. Now we want to start setting up our first force, the overall “wind” direction and intensity. The vector force component will need a “Line” as an input. It uses this lines starting and endpoint as well as length to determine the overall Vector and the Strength of the vector (the length of the line). Note that a line of even a little bit of length will have a pretty extreme effect and can overwhelm other forces, for example, point charges, if you are not careful. The position of this force doesn’t matter…I just put it in the center of my rectangle for ease of reference, but the only things that matter are the line start, end, and length. I also set it up here so I could rotate the line around a full circle, thus changing the “wind direction” and also so that I could change the line length, thus changing the “wind intensity.”

**Step Two – Set Up the Basic Field **

The next step is to set up my basic field. I will use a “Vector Force” field component, and I plug the line I drew in step one into this. I will also use the Boundary I drew in Rhino to limit my field lines so they won’t grow off of my canvas (this is optional). I only have one force for now, but will add more in a bit, so I will plug the results of the “Vector Force” component into a “Merge Field”, into which I will plug the additional forces later.

To see what is going on, I will start some basic field lines. This will be fine tuned in one of the last steps, but for now, I want to start my field lines at all the edges and have them cross the field. For this, I will take the edge curve, offset a very small amount, and will divide this with a slider to generate start points. I will change this later as well to increase the number of field lines as “wind intensity” increases. Note that if I divide the edge curve itself, my field lines won’t generate since objects exactly on the project boundary are considered outside the field. This is the reason for the tiny offset.

**Step Three – Setup Basic Point Charges**

Now I want to get my obstacles into play. I drew four circles of varying sizes in Rhino. For now, I am only using the center point of each circle to set the various point charges. These charges will also use the project boundary as a field boundary. I then plug them into the Merge Field component along with my previous vector force.

If your vector force is too strong, this will overwhelm these little point charges. You will probably have to reduce your vector force now significantly before the point charges show up. In fact, I have found limiting the Vector force to a range between 0 and 1.0 to be the most effective, but this also depends on how the various forces are balanced against each other. You will see, however, the overall strength of the “Vector Force” represented by the tiny, short arrow in the center.

**Step Four – Fine Tuning**

Here I take the overall dimensions of my obstacles using the “Dimensions” component, and also using the “Maximum” component to get the larger of the two (in case I decided to use non-circular obstacles). Through trial and error, I decided using this dimension divided by two gave me the results I wanted. This I plug into the Point Charges to change their effect. You will notice that smaller obstacles have less effect on deflecting the field than larger obstacles.

I also want to have the number of field lines dependent on intensity, so when intensity is higher, there are more lines. I made a formula multiplying the “Wind Intensity” by a factor (in this case 1000) to determine the number of edge divisions.

One last fine tune. You may notice at very low intensities, the Field lines get too short. To fix this, I made a simple formula that will determine the number of Iterations for the field lines based also on the “Wind Intensity” variable.

**Step Five – Line Charges**

Now I want to introduce one more set of influences for my field using a “Line Charge” component. Before I do this, I am drawing a series of lines in the same direction as the “wind”, with a length based on the dimension of the obstacle object associated with it, and a factor I will call the “Vector Wake Multiplier” for now.

I plug these lines into a “Line Charge” component. For the charge, I will use the dimensions of my obstacles, multiplied by a scalable factor (called here the “Wake Line Charge Multiplier”) and will make this negative, since I want to pull my lines back in towards the line. The resulting force is also plugged into the “Merge Field” component along with my previous forces.

This sets up the basic system, where the vectors are split by the obstacles, and where the flow lines are gradually drawn back inside in the “wake” of the object. You can now play with changing the direction and intensity of the field…as well as the relative strengths of the charges. I will show briefly two more refinements I used with this script.

**Step Six – (Optional) Combining Positive and Negative Forces **

I wasn’t sure if my wakes should have a positive or negative charge. it turns out, In a fluid system, there turns out to be a little of both of these! You can make two separate fields, both with the exact same setup except where the second field uses positive charges on the line force at the end, while the first continues to use the negative. The result is a moiré which while not scientifically accurate, does begin to approach the actually behavior of fluid systems with object disturbance.

**Step Seven – (Optional) Improving the starting field lines**

You may notice at angles between 30° – 60° the field lines look pretty good, But as you approach angles around 80-90° you will get too many lines at the edges (see image above). This is because of how we started our lines, since they are starting at an even increment along the edge.

A better solution is to to do something like the script above. What I did was draw a long line *outside* my project bounds, that rotates around the center based on my Force vector. It will always be perpendicular to the flow direction. This line is divided instead of the edge curve with a number of divisions proportional to my field intensity. I won’t show a script for how this was set up but by now it should be easy to do yourself.

These division points are then *projected *using the “Project Point” component onto the offset version of my edge curve (the same curve that I had been dividing previously). After projecting the points, I use the “Clean Tree” component to get rid of the “null” points that were projected off into infinity. I then use the projected points to start my vector lines, instead of the regular distribution along the edge as previously done. This ensures a uniform field with a uniform dimension between field lines regardless of the angle. Hope that makes sense!

**Variations**

Now that its all setup, I can play with variables to change the field. In the first row, I changed the “Wind Intensity” (Low, Medium, High). In the second line, I changed the directional angle. In the third row, I moved my obstacles around, and in some cases added some or took some away.

So great work! I just followed your steps, and tried to create it.

Your explanation is so clear.

LikeLike

Great! Thanks for your comment!

LikeLike

awesome stuff – however, my fline component continually fails to compute the vector line, any thoughts on why this may be the case?

LikeLike

I’ve had this happen before and I am not 100% sure what the best solution is, but sometimes it has to do with the Merge Field component. After you set up all your fields, try merging all the fields together again with Merge Field all at once and see if that works!

LikeLike

Thanks for this great tutorial! I am having an issue with the final part of step 5. As soon as I try and plug the LCharge with the MergeF component, it causes Rhino and Grasshopper to not respond for hours. I’ve tried it on several different computers, with the same outcome. Is there anyway to prevent this from happening?

LikeLike

I often have this problem with the merge field component. I haven’t looked into the issue enough to know why it sometimes doesn’t work. Always save before merging them. Sometimes it is also good to “Disable” the component, plug in all the wires, and then “Enable” it again.

LikeLike

Hi, thank you for this tutorial! I don’t know if my previous comment was posted. But i’m having trouble connecting the LCharge to the MergeF components. It causes the program to crash, and the same thing happens on multiple computers. Is there anyway to fix this?

LikeLike

I’m trying to redo this example but in 3D, I’ve succeeded in doing 3d field of lines with Brep boundraies, that it react to the (push/ pull/ spin forces) however it doesn’t detect 3d obstacles(Box, sphere, ..etc), any help will be appreciated. Thank you for the clear illustrated examples.

LikeLike

I haven’t tried it in 3D but the “obstacles” in this example don’t really exist…it is more just a distance falloff for the force. So theoretically you could take the centerpoint of a sphere or box together with its overall dimensions to control the falloff of a push/pull force. That’s all I can think of right now…

LikeLike