# Modeling a Spinning Sprinkler

Subtitle: “You don’t really understand something until you model it”

Here is the video. It’s great. Watch it.

The basic idea is to predict the path of water that is shot from a spinning sprinkler. In the first case, the water is shot straight out of the spinning pipe. The second case is a little bit trickier with the water shot towards the center of the sprinkler. OK, it’s not actually a sprinkler.

Of course, once a drop of water leaves the sprinkler, it will only have the gravitational force acting on it. So, if you view this from the top—a drop of water should travel in a straight line with a constant velocity. But there is a problem that makes this difficult to predict. It’s that we don’t see the path of one drop of water, we see the path of a water stream.

A water stream is a collection of water drops. Even though one drop might travel in a straight line, the next drop will be “launched” at a different location with a different velocity. This makes it look weird.

OK, so let’s get to a model. I’m going to go over the steps to build this model in VPython.

Build a bar

Don’t try to do everything at once. Let’s just make a spinning bar—I’ll add water balls later. Here is what that spinning bar looks like.

And here is the code (along with a link to the code – https://trinket.io/glowscript/d6545ddfca

Let me go over some of the important parts of this code.

• The bar is an object of type “box”—this is a prebuilt object in VPython. It has two important attributes. The position (pos) is the location of the center of the box. The size is the vector with length, width, and height.
• I added a ball so you can see the center (it’s not needed).
• The variable “omega” is the angular velocity of the rotation. You can change this if you like.
• The variable “theta” is the angular position of the bar—this is used for something later.
• In the loop, the rate(100) tells the code to not do any more than 100 loops per second. Since I have a time step of 0.01 seconds, this means 100 loop would take one second—it would run in “real time”.
• Don’t worry about line 16 (update theta)—at least not for now.
• Line 18 is the important part. There is a rotate function in Vpython. You need to pick the angle (in this case it’s dtheta which is the angular velocity times the time step), the axis of rotation (the z-axis) and the origin of rotation (the origin).

But it works.

The next step is to add a single ball of water to the end of the sprinkler bar. It’s not going to do anything except to “ride around”. Here’s what that looks like. It’s really the same thing except with that ball of water.

Here is the code—https://trinket.io/glowscript/14e1ecbb7d. Let me just point out the important parts.

If I know the angular position of the sprinkler, I can find the vector from the center of the sprinkler to the end of the sprinkler. It looks like this: $\vec{r} = \left(\frac{L}{2}\right) <\cos\theta,\sin\theta,0>$

For each iteration of the loop, I can calculate theta and then use that to calculate “r”. This r is now the new vector position of the ball.

List of balls

Now for the magic. Lists are your friend. I feel like I could write a whole post on just lists—but I want to get right to the good stuff.

In short, a list is a group of things in python. Let me start with an example program.

balls=[]
x=-5
dx=1

while x<3:
balls=balls+[x]
x=x+dx

print("balls = ",balls)
print("balls 3 = ",balls)

Here are some notes on this code.

• balls = [] makes an empty list. The name of this list is balls.
• In the loop, I add a new x value to the list and then update x.
• At the end, I print the list of balls and the 3rd item in the list (the first item would be balls).

Here’s the output.

But wait! You don’t just have to make a list of numbers. I can make a list with objects too. Check out this version of the code.

balls=[]
x=-5
dx=1

while x<3:
x=x+dx

print("balls 3 position = ",balls.pos)

Here is the output.

Boom. Check that out. It’s 8 balls—but in just one list. You can even print out the position of one of the balls (you can’t print the whole list because a sphere() isn’t printable).

Water balls in a list

OK, I think we are ready. Oh, you might not be ready—maybe you need some more practice with lists. Just start playing around and see what happens. Anyway, here is the plan.

• Make a list of water balls (actually two lists—one for each side).
• Start the time (t = 0) and a time step of dt.
• Set a ball time counter. If the time gets to some specified value, then create a ball and add it to the list (both lists).
• When you create a water ball, set its properties: mass, size, add a trail…oh, and initial velocity. Yup. You can do that.
• Now let stuff run. I will need to go through each ball list and update the water ball positions, but that’s not too difficult.

Let’s just get to the code. Here it is (also on trinket.io)

GlowScript 2.9 VPython

#Length of sprinkler - just leave this
L=0.1
stick=box(pos=vector(0,0,0), size=vector(L,.05*L,.05*L),color=color.yellow)

#CHANGE THIS - rotation rate of sprinkler
omega=2*pi/2

theta=0

#CHANGE THIS to -1 to make balls shoot IN
a=1

t=0
dt=0.01

#this is just a spacer to make the scene look nice

#water stuff
water=[]
water2=[]
vwater=.3
tint=0 #this is the "clock" for shooting water

#CHANGE THIS - this is the water ball production rate
f=15 #water per second rate that balls are made

while t<10:
rate(100)
r=(L/2)*vector(cos(theta),sin(theta),0)
r2=-r

if tint>=1/f:

make_trail=False)]
make_trail=False)]
tint=0
for ball in water:
ball.pos=ball.pos+ball.v*dt
if ball.pos.mag>3*L:
ball.v=vector(0,0,0)
ball.visible=False
del ball
for ball2 in water2:
ball2.pos=ball2.pos+ball2.v*dt
if ball2.pos.mag>3*L:
ball2.v=vector(0,0,0)
ball2.visible=False
del ball2

theta=theta+omega*dt

stick.rotate(angle=dt*omega,axis=vector(0,0,1), origin=vector(0,0,0))
t=t+dt
tint=tint+dt

This is what the output looks like. Actually, this is an animation for the case of the water shooting inward (since I already had the gif).

Now for some comments on the code.

• When the water ball gets a certain distance away (I think I set it to 3*L), I change the water ball velocity to vector(0,0,0) and then I make it invisible. Otherwise the view would just keep expanding and it would look weird.
• I don’t have any other important comments, but I can’t have a one bullet list.

I think that’s good enough. Hope that helps.

# Angular Size Lab

Enough was enough. I couldn’t handle going through the chapters in the introductory astronomy course. It was too much material and it was too fast. But I’ve already complained about this in a previous post.

I didn’t have much time to prepare, but I decided to do a lab activity in class. My idea was to have the students build something to measure angular sizes. They could then use this device to measure the size (or distance) of various objects outside. I figured it would be fun to have them actually build things.

So, here is the plan. Step one is to go over the math of angular size. That includes the relationship between the circumference and radius for a circle. $C = 2\pi R$

Another important idea is the relationship between the angle in degrees and radians. We need to measure angles in radians, so I also explained this relationship with 360 degrees equal to 2*Pi radians.

The next part was to build an angle measuring device. I’ve done the before in a physics lab, but I wanted something a little simpler. Here’s what I suggested to the students—make some small “flag” that you can hold at arm’s length (so that the distance from eye to flag is constant) and use this to measure angles.

I gave them popsicle sticks and sticky notes and a bunch of other stuff (with the hope that they would come up with their own design). In the end, they had something like this.

This is just a sticky note on a pencil.

The next step is to “calibrate” this instrument. Put your eye a known distance (say 5 meters) from a known length. I had the students use bricks in the wall or put tape on the wall a set distance apart. From this, they can calculate the angular size of the object and make markings on their device. Oh, this diagram might help.

The distance from the eye to the object is R and the length of the object is L. If the object is small compared to the distance, then this length is approximately the same as the arc length of that part of a circle. The value for theta can be determined by dividing L by R.

Now repeat this for another object so that you can turn the angle measuring device into something useful with multiple markings on it. Now we are ready to collect some data.

Here is a large light for the football stadium, you can see it right outside the classroom.

I used Google maps to get the distance to this object (it’s 240 meters) and then had them measure the angular size and calculate the width.

Here are some other questions:

• What is the angular size of your thumb at arms length?
• What is the size of a sign on a building across the street?
• There is a doorway down the hallway. The width of the frame is 0.91 meters. How far is it?
• What is the angular field of view of your phone’s camera?

Overall, the lab went fairly well. Students have a bunch of trouble with that first step—where they build something. You can tell they don’t feel comfortable without explicit instructions.

# Let’s talk about carbon dioxide

OK. Here’s the deal. I have lots of emails about my recent post. The post was a back of the envelope type estimation to see what would happen to the carbon dioxide in the atmosphere if everyone planted a tree.

It’s just a rough approximation. Here’s the post.

https://www.wired.com/story/plant-a-tree-for-climate-change/

Basically, I estimated the size of a typical tree and then figured out how much carbon dioxide you would need to make that tree. After that, I estimated the number of particles per million (ppm) of carbon dioxide.

Here’s the code for my calculations – https://trinket.io/glowscript/f7edb65694

Now for the rest of this. Lot’s of people have sent me comments. If you want to talk about this – here is your chance. Comment on this post. Another option: comment on twitter. Here is a good thread.

If you email me, there’s a good chance I won’t reply. These two options are your best bet.

# Intro Astronomy Update

I picked up this introductory astronomy course just a week before classes started. One of my other classes didn’t have enough students in it, so I got this instead. It’s a gen-ed science course for non-science majors. Since it was added late, there are only 12 students in the class.

I’ll be honest—there are some super awesome topics in this intro astronomy course. The historical stories and the “how do we know” stuff is great. HOWEVER, it’s also a really tough class.

I didn’t have time to build something from scratch, so I just went with the order and presentation of topics according to the textbook. This class uses Explorations – an Introduction to Astronomy, 9th ed (Arny, Schneider) McGraw Hill. It’s an OK, text with only a few areas that I don’t agree with. But let’s look at the first 4 chapters:

• Chapter 1: The sky. Celestial sphere, motions of the sky, seasons, phases of the moon.
• Chapter 2: Historical astronomy stuff. Mostly, this is the geocentric vs. heliocentric model of the solar system.
• Chapter 3: Gravity and Motion. BAM. Forces and motion, gravity, escape velocity.
• Chapter 4: Light and atoms. DOUBLE BAM.

Chapter 3 is bad. I mean, I have other classes that spend about 1/3rd of the semester on forces and motion and they don’t even get to the 1 over r squared version of gravity at any point. I think it’s possible to get students to understand most of the ideas in chapter 3, but not in a chapter-length amount of class time.

Oh sure. You could just tell the students everything they need to know about forces and motion. You could TELL them that a constant force makes an object have a constant acceleration. But research shows that this doesn’t really work. No, this is a tough concept and it’s going to take time to get it figured out.

Chapter 4 is even worse. The interaction between light and matter could be its own separate course. It’s not just a chapter. Oh, on top of that – there are these instructor power point slides. Here are three in a row that go something like this.

• Light is an electromagnetic wave.
• Light is also a particle.
• Which way light manifests itself depends on the situation.

That’s bad. Of course you know I don’t like the whole “light is a particle” thing.

OK, but there are some good things about this course. I have a small enough class that I can put in some extra stuff. We did some of the NextGEN PET units in class, and that went over fairly well. I have also been doing some of the great online labs from University of Nebraska-Lincoln (https://astro.unl.edu/naap/). Those are nice.

One other quick note. I think I am going to skip over all the planet stuff. It seems like it would just turn into a “memorize the density of Saturn” stuff. I really want to get to stars. There are some great stories about how we know stuff about stars.

I’ll keep you updated on the progress of the course.

# Blogging Update

Hello there.

Yes, I haven’t posted here in a while. But to make it up to you, I’m going to show you a picture from my drone.

This is a canal in New Orleans. My older son had a soccer game right next to this, so during warm-ups I did a little bit of photography. Actually, these are really weird. You are on ground level and you see a big long hill (there really aren’t many hills in New Orleans). When you walk up the “hill” you see water that could be at a higher level than the ground.

Yes, it’s not a hill. It’s a levee.

It’s definitely odd.

Now for some other random updates.

• I have been busy as usual. I picked up a couple of freelance posts for a UK magazine. In the edits, all my “meters” were changed to “metres”. I thought that was fun.
• Blogging on WIRED went pretty well this week. I had two posts – one on a rough estimation of the amount of carbon dioxide capture from planting trees. The other was an estimation of Death Star pieces on the surface of a planet.
• Another thing I have been working on: making better youtube videos. I have made some modest gains, but I still need more work.
• I was thinking about doing a youtube live stream event, but I’m afraid no one would show up.
• Finally, my oldest daughter moved to Japan. I’m glad she made it there.

# Finding the Electric Field from the Electric Potential (difference)

I’m way behind on this one. My plan was to write up something when this question came up in the summer section of algebra-based physics. It was a great question and deserved a full answer. Also, I wanted to make this a tutorial on trinket.io—but maybe I will do that after I write about it here.

So, here’s how it goes. We start off the semester calculating the electric field due to a point charge and then due to multiple point charges (you know—like 2). After that we get into the electric potential difference. Both the potential and the field follow the superposition principle. If you calculate the value due to two charges individually, you can add these together to get the total field or potential.

But there is a big difference. The electric potential difference is a scalar value where as the electric field is a vector. That means that when using the superposition with electric fields, you have to add vectors. Students would prefer to just add scalars—I’m mean, that seems obvious. Does that means that you could just find the electric potential difference for some set of point charges and then use that potential to find the electric field? Yup. You can. And we will.

Let me start with the definition of the electric potential difference. Since it’s really just based on the work done by a conservative force (the electric field), this looks a lot like the definition of work. $\Delta V = -\int_a^b \vec{E}\cdot d\vec{r}$

Yes, that’s an integral. Yes, I know I said this was for an algebra-based course. But you can’t deny the truth. The “a” and “b” on the limits of integration are the starting and ending points—because remember, it’s really an integral. Also, the “dr” is in the direction of the path from a to b. It doesn’t technically have to be a straight line.

What about an algebra-based course? Really, there are only two options. The most common approach gives the following two equations for electric potential. $V = k\frac{q}{r}$ $\Delta V = -E\Delta r \cos \theta$

The first expression is the electric potential of a point charge with respect to infinity (so the starting point for the integral is an infinite distance away). The second expression is the change in electric potential due to a constant electric field when there is an angle between the field and the displacement.

Oh wait! I forgot to list the value of k. This is the Coulomb constant. $k = 9\times 10^9\text{ N*m}^2\text{/C}^2$

Students can understand the second expression because it’s pretty much the same as the definition of work (for a constant force). The first equation is mostly magic. The one way you can show students where it comes from is to do a numerical calculation of the electric potential difference since they can’t integrate. Did I write about that before? I feel like I did.

Ok, that’s a good start. Now for a problem.

Electric potential due to two point charges

Suppose I have two charges that are both located on the x-axis. Charge 1 is at the origin with a charge of 6 nC. Charge 2 is at x = 0.02 meters with a charge of -2 nC. Here’s a diagram—just for fun.

Let’s start off with the electric potential—as a warm up. What is the value of the electric potential (with respect to infinity) at the location of x = 0.02 meters? Using the equation above for the electric potential due to a point charge, I need to find the potential due to point 1 and then the potential due to point 2—then just add them together (superposition).

First for point 1. $r_1 = 0.02\text{ m} - 0\text{ m} = 0.02$ $V_1 = k\frac{q_1}{r_1}$

Now for point 2. $r_2 = 0.02\text{ m} - 0.01\text{ m} = 0.01$ $V_2 = k\frac{q_2}{r_2}$

This gives a total electric potential: $V = V_1 + V_2 = k\left(\frac{q_1}{r_1} + \frac{q_2}{r_2}\right) = 175.3\text{ Volts}$

Finding the Electric Field

Now to find the electric field at that same point. I don’t know how to say this in a nice way, so I will just say it. Since the electric potential is calculated based on an integral of the electric field, the electric field would be an anti-integral. Yes, this means it’s a derivative. But wait! The electric field is a vector and the electric potential is a scalar? How do you get a vector from a scalar? Well, in short—it looks like this. $\vec{E} =-\nabla V$

That upside delta symbol is the del operator. It also looks like this: $\nabla V = \frac{\partial V}{\partial x}\hat{x} + \frac{\partial V}{\partial y}\hat{y} + \frac{\partial V}{\partial z}\hat{z}$

Yes, those are partial derivatives. Sorry about that. But you do get a vector in the end. But how can we do this without taking a derivative? The answer is a numerical derivative. Here’s how it works.

Suppose I find the electric potential at three points on the x-axis. The first point is where I want to calculate the electric field. I will call this $x_0$. The next point is going to be a little bit higher on the x-axis at a location of $x_0+dx$. The final point will be a little bit lower on the x-axis at $x_0-dx$. Maybe this diagram will help.

When I take these two end points (not the middle one), I can find the slope. That means the x-component of the electric field will be: $E_x(x_0) = -\frac{V(x_0+dx)-V(x_0-dx)}{2dx}$

Let’s do this. I’m going to find the x-component of the electric field at that same location (x = 0.02 meters). I don’t want to write it out, so I’m going to do it in python. Here is the link (I wish I could just embed the trinket right into this blog post).

Umm..wow. It worked. Notice that I printed the electric field twice. The first one is from the slope and the second one is by just using the superposition for the electric field. Yes, I knew it SHOULD work—but it actually worked. I’m excited.

Also, just for fun—here is a plot of the electric potential as a function of x. The negative of this slope should give you the x-component of the electric field.

Here you can see something useful. Where on this plot is the electric field (the x-component) equal to zero? Answer: it’s where the slope of this plot is zero (yes, it’s there). Remember, just because the electric field is zero that doesn’t mean the electric potential is zero.

Homework

How about this? See if you can find the electric field due to these two charges at a location y = 0.01 and x = 0.0 meters. This is right on the y-axis, but now the electric field clearly has both an x and a y-component. That means you are going to have to do this twice.

# MacGyver Season 3 Episode 18 Science Notes: Murdoc + Helman + Hit

I honestly don’t know how I skipped over this episode with my MacGyver science notes. Oh well, let’s finish this up. There aren’t too many hacks in this episode, so this won’t be too long.

One Way Mirror

Murdoc makes a great point. Is it a one way mirror or a two way mirror? The main idea is that Murdoc can’t see through the glass, but the other people can see through to view what Murdoc is doing.

These things aren’t magic. At the most basic level, a “one way mirror” is just a plane of glass. When light hits glass, some of it is reflected and some of it is transmitted. If you are on one side of the glass and there is WAY more reflected light coming back at you than the light transmitted from the other side, then you can’t see that transmitted light. The glass would look like a mirror.

This is exactly what happens when you are inside a house at night with the lights on. The lights reflect too much and there isn’t much light from outside coming in, so you just see a reflection. It would look like this.

If you are outside on a dark night, the opposite is true. You can see INTO the house.

So, for the one way mirror, you need a glass separating two rooms. The dark room is the room with the observers and the light room is where the prisoner sits.

Here is an older post with more details about seeing through windows.

Pulley Skateboard Battering Ram

This is a classic simple machine. The key to all simple machines is that you can make a system that pulls over a greater distance and produces a greater force (or you can do it the opposite of this).

In this case, MacGyver makes a compound pulley. You need two pulleys. If you run the string through these two pulleys, you can make two different distances. The distance one side is pulled is twice the distance of the other side. Here is a diagram.

Yes, that’s a rather crude sketch—I did it fairly quickly. Here is a video that walks through the setup. I mention that there are two ways to set up this skateboard battering ram, this only covers one method.

Here is a much more detailed post on pulleys.

Stopping a Truck with a Truck

MacGyver uses a winch cable to connect their truck to Murdoc’s truck. They then slam on the breaks. So, would this work? Yeah, probably.

Assuming the two vehicles have the same material for the tires, then they would have the same coefficient of friction. A basic model for friction says that the frictional force is proportional to the force the ground pushes up on the object (we call this the normal force). $F_f = \mu N$

Since both cars are on flat ground, the normal force is equal to the car’s weight. That means the heavier car would have a greater frictional force. Yes, I’m making some other assumptions about the tires “locking up”—but still, this is plausible.

Even if the frictional force wasn’t enough to stop the truck, the cable is attached to the side of Murdoc’s truck. This side force would rotate the truck and also prevent it from driving straight.

# MacGyver Season 2 Episode 23 Science Notes: MacGyver + MacGyver

It’s funny how the title is sort of a spoiler for the episode. Right?

DIY Safe Cracker

This is technically a MacGyver-hack since it’s from MacGyver, just not from Angus MacGyver.

The basic idea is to open a safe with a dial on it. Instead of trying to figure out the lock combination, a robot can just try EVERY combination. This is called a brute-force hack since it’s not elegant but it works.

Oh, you want to build one of these yourself? You are in luck, here is an epic guide. https://learn.sparkfun.com/tutorials/building-a-safe-cracking-robot

Also, here is another brute force hack (on a key code door).

Book Cipher

I’ll be honest. I had no idea how a book cipher worked. But with a little help from the internet, I finally figured it out. Here’s how it works.

• You take some text that you want to send. The example I use is the word “cat”—yes, that’s sort of silly.
• Next, you need to convert each letter to a number. I’m using the ASCII UTF-8 format to convert each letter to a hexadecimal number (base-16 numbers instead of base 10). For “cat” this would be 43 41 54.
• Now I take a word from my “book”—in this case it’s a take out menu from a Chinese restaurant. If I use SPR (from spring roll), I can also convert that to ASCII to get 53 50 52. This is my key.
• Now I add my text and my code to get 96 91 A6. REMEMBER these are hex numbers, so you have to add them differently than you would with decimal numbers. This gives me the code—this is what you send.
• To decode the message, you just do the opposite.

Here is a longer explanation with a video.

Just for fun, here are some of my notes along with Oversight’s calculations on the dashboard.

Fuel Pump

MacGyver needs to transfer fuel from one car to another. Here is a very cool pump.

The key to most of these pumps is a one way valve. You need to make something so that water can flow the way you want to pump, but not the other way. Here is a very simple way to make a one way pump valve with a turkey baster and small ball.

Belt Handcuffs and Bolo

Really not much to say here—normal MacGyver stuff.

Ascender Rig

MacGyver and MacGyver build a device so that they can get on the roof a building. Yes, it’s an ascender rig. It’s basically just a battery (a car battery in this case) and an electric motor. The motor winds up a rope and causes the whole thing to move up.

Here’s the cool part. You could really do this with just about any electric motor. Yes, even that tiny weak motor could still lift two humans. The only difference would be the speed. If you get the gear ratio right, this tiny motor would slowly wind up the rope and just take longer to get to the top.

Spark Gap Generator

The spark gap generator was the first type of radio transmitter. When a spark is created, it also produces electromagnetic waves (over a broad range of frequencies). That means you can’t really have radio channels, but you can indeed send a signal.

If you want to know more about spark gap generators, here is some info. I even built one mostly from scratch.