How to drill a well

In one of my courses this semester students were learning about the coriolis and centrifugal forces that things seem to experience on the earth. There’s a problem at the back of the chapter that asks when a dropped rock would hit the side of a well. A couple of students attempted it, but I noticed that they assumed the well was drilled straight toward the center of the earth. I encouraged them to think about that and figured I’d get a resubmission before the end of the term. I haven’t yet, and I started to realize today that it’s a pretty interesting problem. Namely, how do you drill a straight well?

I came up with three ways (four if you count straight to the center of the earth) and all of them give a different shape for the well:

  1. Slowly reel out a heavy plumb bob on a line. When you stop reeling, it’ll point out away from the axis of rotation of the earth due to the centrifugal force. As long as you do it slow enough, you can ignore the coriolis force. Have the well shape match the path the plumb bob  takes during its (slow) descent.
  2. Slowly reel out a chain or rope that doesn’t have negligible weight but also doesn’t have a heavy plumb bob at the bottom. Have the well shape match the shape of the rope when you’ve got it as deep as you like it.
  3. Drop a rock and see which way it goes. Have the shape of the well match the trajectory. This one has the benefit that future rocks won’t hit the side!

So I set about trying to figure out each of those shapes. For those that don’t want the details, here’s a plot showing all three. Well 1 is in blue, well 2 is in red, well 3 is in green.

Blue: well type 1. Red: well type 2. Green: well type 3

Blue: well type 1. Red: well type 2. Green: well type 3

The easiest one is the green one. I just do a pretty straightforward integration of the equations of motion where:

\vec{F}=\{0,0,-m g\}-m\vec{\omega}\times(\vec{\omega}\times\vec{r})-2 m \vec{\omega}\times\vec{v}

Where the first term is gravity (note that g changes like a spring as you go deeper), the second is the centrifugal force, and the third is the coriolis force. Once you know the form of the force, doing an NDSolve command in Mathematica is pretty easy.

The other two wells were a little harder to calculate. For well 2 I modeled several (19) masses connected by inextensible strings. I started with them all anchored at the top and hanging straight toward the center of the earth. Then I turn on time with a lot of friction to see where they all settle down to. Here’s an animated gif of that process:

Evolution of well 2

Evolution of well 2

I actually used Lagrange multipliers for all the strings and simply solved for x,y, and z of every particle along with the tension forces necessary to keep their spacing correct.

For well 1 I only used one particle but I changed the constraint to be time dependent. Basically I just had the length between the ball and the anchor grow linearly.

Cool, huh? I wonder which is the better way to do it. What do you think? Here’s some starters for you:

  • I’m in this class and I love this. I’ll redo that standard using all of these just so you’ll brag about me.
  • I’m in this class and I’m pissed. Why couldn’t you post this a long time ago?
  • This is cool. What happens with well 3 if you add air resistance?
  • I’m confused. What do you mean when you say “g” changes like a spring as you go deeper?
  • This is cool, but I don’t think you did _____ correctly. Here’s a post of mine that does it correctly.
  • This is dumb. I build wells for a living and we don’t do this at all. Instead we . . .
  • This is cool, but as usual you haven’t bothered to post your code, jerk.
  • Having just redone all your work, I’m now convinced that you used a huge omega value (0.5) and a tiny earth (10 m radius) with g=9.8 at the surface, all at 45 degrees N latitude. You could have just put that in your post, you know. Jerk.
Posted in mathematica, physics, teaching | 7 Comments

In class versus screencast

Something happened in class on Friday that I wanted to get down before I forgot about it. It’s a good follow up to my last post about the value of class time.

On Fridays we do a review of the two new standards for the week. This time it was about tops/gyroscopes and simple normal mode systems. I set up two problems and two groups to work on them:

  1. Consider a spinning top balanced perfectly. What happens when a ball hits it from the side?
  2. Consider two weakly coupled mass/spring systems. Describe how the energy seems to go back and forth between them.

The groups worked hard. Their first assignment, due 5 minutes into the work, was to report any questions they had. Those ranged from “What’s the mass of the top? (whatever you want)” and “Are the two main springs identical? (if you want)” to “Will it tip? (good question)” and “Is this the same math we developed on Wednesday? (What do you think).” They then worked hard trying to figure out what was relevant and what they could do to spice it up (to make it 4-worthy in my system).

But then the inevitable happened. Both groups developed enough that they wanted to see what would happen if we modeled it in Mathematica. Group 1 wanted to see if the top truly would tip at a 90 degree angle to the trajectory of the ball and group 2 wanted to see a Fourier transform of the motion of the masses for various settings of the springs. And both of those sounded like a lot of fun to set up and to play with. However, there wasn’t time left in class for both. How to decide? That’s what I wanted to get down in this post. Not an answer, mind you, but how our discussion went.

At first we tried to figure out which project was harder. The Fourier transform stuff had them a little worried, as we hadn’t done that in this class at all. But figuring out how to the ball impact was difficult too. The problem was, there wasn’t consensus on whether “hard” meant that it should be done in class where they could ask questions, or done in a screencast (by me) outside of class where they could watch it and rewind etc.

One student really liked the latter argument, saying that they were worried that the subtle details would come too fast if I did it in class. I said that maybe I should do the hard one in class to make sure we figured out what was hard for them.

In the end we did what I thought would be the easiest one in class, though it’s finny that even that one proved too difficult to do in class. Here’s the two scasts I made for them after class if you’re interested.

So what do you think. What should be done in class and what should be an out-of-class resource? Here’s some starters for you:

  • I’m in this class and I like that you ask us our opinions about this. I like tailoring my learning that way.
  • I’m in this class and I hate the way you waste time asking us what we should do. You’re the expert, so teach!
  • This is cool. Do they change what types of things they ask for as the class goes on?
  • This is dumb. You shouldn’t put them in two groups if both of the problems are things they should learn.
  • This is cool. What happens when you do what they ask for but you don’t quite finish?
  • This is dumb. You should promise to do both as scasts and then just spend class time having them predict what’ll happen. That way they’re motivated to watch the vids.
  • This is cool. Do you just have the vote be democratic or do you always wait for consensus?
  • This is dumb. The whole class should work this way, not just the end.
  • This is cool. I’m really surprised at how the top moves. Maybe doing the impact as a temporary gravity adjustment is wrong.
  • This is dumb. Doing everything in Mathematica is stunting their growth, stop it.
Posted in syllabus creation, teaching | 1 Comment

Back flip doesn’t help students who miss class

In my Theoretical Mechanics course the other day we were talking about noninertial forces (like centrifugal and coriolis forces) on the surface of the earth. We did all kinds of examples related to weather, cannons, and cars driving. However, we didn’t finish any of them. Instead I did my usual back flip trick and said that I’d be happy to finish the details in a video after class.

However, at the end of class, the students made it clear that they didn’t want me to finish any of them. They each had a different example they had in mind that they were intrigued by and they wanted to see if they could finish it to submit as an assessment of the day’s standard (“I can do an interesting problem involving noninertial forces on the earth”). So instead we all decided that I should do a totally different example and leave all the rest unfinished.

I really like how they’re taking ownership of the material, and how they’re being honest with me and with each other about what they understand and what they’re willing to work at to see where it goes. I say each other because they sometimes argue about whether it would be worth it for me to fill in the blanks. Usually the people asking for me to do it are saying something like “… but I’m confused about where that comes from …” or “… I don’t even know what the first step should be …” or similar sentiments. So I like how it makes the videos I do meaningful to the students. I’m no longer guessing what they’ll struggle with and providing vids ahead of time. Now I wait to see what they struggle with in class (when they first are hearing about the concepts) and we work together to make the (now pretty short) list of screencasts that I should go make.

So, to be clear, I’m pretty happy with all of that. However, it hit me the other day that students who miss class are missing out on more than they used to when I did a regular flipped format. In the old days, I could say “don’t worry, just watch the vids and work some practice problems” because my scasts usually covered what I thought were the missing or mysterious steps from the book. But now the vids are very personal to the students who were in class that day. I personalize them by saying things like “as xxxxx said in class, this is where it gets weird” or “remember, what yyyyy suggested is another way to do it, but it takes longer.” What do the students get out of that if they’re not there in the first place?

I thought of all this as I got an email from a student apologizing for missing class. I don’t feel like suggesting that he watch the vids is going to be overly useful, but they and the book are all there are. Of course he can come to my office to get caught up, but that’s still a far cry from the inquiry atmosphere that I’m trying to build in class.

Anyways, I just wanted to put this out there to see what you guys think. Here’s some starters for you:

  • I’m in this class and I hate it when I miss class for just this reason. I like that class is super useful.
  • I’m in this class and I hate it when I miss class for just this reason. Could you please just do a normal flipped class?
  • Why do you sometimes write vids, sometimes scasts, and sometimes videos?
  • If you personalize the vids, does that mean that you do a whole new set of scasts every time you teach the course? (yes)
  • Of course you must have an arbitrary attendance policy to give the students all kinds of extra credit for showing up, right?
  • For me, if the students miss class, I figure it’s their own fault and I lie about what went on. You should do that too.
  • For me, if the students miss class, I take it as a personal failure and I vow to entertain them better so they’ll show up more. You should do that too.
  • If you taught at 8 o’clock you’d have all kinds of problems with this. (Actually I teach at 8 all the time and I rarely have any skips)
Posted in sbar, sbg, syllabus creation | 8 Comments

Genetic algorithm for randomizing oral exams

I’ve written before about using genetic algorithms to solve problems, but I wanted to show how flexible they can be by writing here about how they helped me this week. My problem was that I wanted to assign standards to students for our oral exam week coming up after spring break (next week). I want each student to do three different standards throughout the week. However, I want to make sure of each of the following:

  • No student should do the same standard twice
  • On any given day, there should be a minimum of repeat standards
  • No two students should have the same set of standards (even in a different order)

At first I thought I could just randomize the student names and then count out the standards in order. It takes care of the first two bullet points, but it turns out that the third one kept happening. So, on to using a genetic algorithm to do this.

Here’s what I did:

  1. Put together a population of possibilities
    1. each one of these randomly assigns three standards to each student
    2. Note that the three bullet points above are not at all considered (in fact, usually all three are violated with each of these random starters)
  2. rank each candidate according to the three bullet points above
    1. For example, if a student has a repeat, that’s a penalty. If they have all the same standard all three times, that’s a double penalty
  3. Using a weighted selection scheme, choose a parent and then mutate it to make a new candidate for the next generation
    1. The weights are the penalties (lower are selected more often, though)
    2. A mutation consists of randomly changing one or more of the student/standard assignments
    3. The mutation rate goes down throughout the run (this I borrowed from Simulated Annealing)
  4. Repeat 2-4 until you have a solution you like

After about 100 iterations it settles into something that meets all the requirements.

The flexibility I was mentioning above comes in when I realize that I want to make some other subtle changes. I realized that I want to add these conditions:

  • Minimize the number of standards that students repeat throughout the semester (we have 9 oral exams all together)
  • Maximize the spread of the standards for each student
    • I simply do Max(list) – Min(list) to get that
    • In an earlier “solution” I noticed that one student was assigned numbers 1, 2, and 3 and I didn’t want them to spend the week working on just one section of our material

Instituting those changes was simple, just change the cost function to include them and then re-run the simulation.

At the end of the day it all works quite well. I get a distribution of the standards into my students hands (so they can prepare over spring break) and I know that all my bullet points are met.

So what do you think? Here are some Rhett-Allain(TM) starters for you:

  • I’m in this class and I’m really glad you’ve worked this out. I was super nervous that a fellow student might have the same standards as me and this fixes that.
  • I’m in this class and I’d much rather just pick my own standards, focussing on the ones I’ve done poorly on.
  • Why do you put “solution” in quotes?
  • How much do you pay Rhett when you use these starters?
  • Why do you have the mutation rate change? Why not have it evolve?
  • If you change the weights of each category, do you get drastically different results? (yes, though not if I let it run a really long time)
  • Can you post the code you use for this?
  • I’ve got a similar problem, how would you code it?
  • Wait, this is the Friday before your break? Why are you posting to your blog? Get a life!
Posted in mathematica, syllabus creation | 8 Comments

Stepper motor with Arduino motor shield

We have a bunch of Ardunio-brand motor shields and I wanted to jot down what it took to drive a stepper motor with them. The documentation really only tells you how to hook up DC motors, though it does say you can just use the outputs to drive a stepper. I thought that meant I should use pins 3, 11, 12, and 13 for the four coils of my stepper, but that didn’t quite work out. I was confused about how to energize each of the outputs so I finally just sent all 16 combinations of those pins to see which combos are the ones I needed. Here’s what I found. For the list below, A+, A-, B+, and B- refer to the outputs on the board and the pin order is 3, 11, 12, 13. 1 means high, 0 means low. The integer in parentheses is the decimal equivalent to the binary.

  • B-: 1000 (4)
  • B+: 1001 (5)
  • A-: 1000 (8)
  • A+: 1010 (10)

If you consider the four coils to be the cardinal directions, I put north on B-, south on B+, east on A-, and west on A+. To get half steps:

  • NE: 1100 (12)
  • SE: 1101 (13)
  • SW: 1111 (15)
  • NW: 1110 (14)

So to do the standard 8 steps when doing half steps, the decimal order is

4, 12, 8, 13, 5, 15, 10, 14

Here’s some quick code for turning decimals into firing the correct pins:

void fixbool(int n) {
digitalWrite(3, HIGH && (n & B1000));
digitalWrite(11, HIGH && (n & B100));
digitalWrite(12, HIGH && (n & B10));
digitalWrite(13, HIGH && (n & B1));

Posted in arduino | 1 Comment

Keep from just plowing through

I spent a good portion of the day trying to figure out what I wanted to do in my Theoretical Mechanics class tomorrow. We’ve recently begun the chapter on central potentials and I wasn’t sure how far to try to get. I started writing down the big ideas that I thought were important:

  • The effective potential idea gets us all the way down to a single variable (from 6 with the x’s, y’s, and z’s of the two particles involved in a central potential interaction)
  • Kepler’s second law (which really applies for any central potential). This is the one about the orbit sweeping out an equal area for every equal time period.
  • Kepler->Newton (showing how a 1/r^2 force leads to ellipses): more on this below
  • Finding relationships for the eccentricity and ellipse axes in terms of the energy and angular momentum of the orbit.

I knew I couldn’t do all that in one class period, but I thought I could probably get through the first two and a half or so.

But that’s when I wondered what the “I can . . .” statement of the day would be and it hit me that I shouldn’t just be plowing through material. Instead I want the “I can . . .” statement to be driving the work, motivating the students to engage and to figure out what other resources they’re going to need to figure out how to prove that “they can.” I realized that repackaging the first two points made it a nice consistent idea that we could really play with in class. The r- and \theta-equations each bring something to the table when understanding orbits and I think if we do them well, we’ll be really set up for the rest on the next day.

It’s funny that I fell off my “standards-decide-the-day” wagon and didn’t even notice. I spent so much of my day today trying to find cool connections between Kepler and Newton that I lost track of the utility of really focussing each class day on a articulatable idea.

One other idea came out of my brainstorming today. The proof that inverse-square-law orbits are ellipses is a beast. The integrals involved are nasty, often utilizing all kinds of “I would have never thought of that” tricks. So I really tried thinking today of other ways to get that point across. I thought about having the students code up some numerical simulations to see that all the orbits seem to be ellipses, but I knew that it would fall short of the goal of proving that all possibilities are ellipses. I talked with a friend in the math(ematics) department about this and we explored a number of interesting pedagogical/curricular issues:

  • Do students need to do a derivation like this?
    • yes: it’s famous and really interesting, tying together Brahe, Kepler, and Newton
    • no: ugh, you’ll never assess it, so why bother
  • My friend uses the phrase “it’s good for your soul” to motivate students to try to struggle with a tough idea, even if there’s a good chance it won’t be formally assessed.
  • I make it clear what will be assessed and try hard to not have anything else in the class. This has led to cutting material (like catenaries) even if it’s “interesting” if I’m not planning on assessing it. My friend suggests that I’m limiting myself and my students’ learning by doing that.

So what do you think? Here are some starters for you:

  • I’m in this class and I want to see if Newton was a genius or if I could have figured this out.
  • I’m in this class and I’ll take your word for it that Newton was able to do that nasty integral by hand.
  • I like how you try to make each class a stand-alone idea, but I don’t think “articulatable” is a word (and neither does Chrome)
  • I don’t understand why you put so much focus on the arbitrary class time breaks. The material is huge and doesn’t have to fit cleanly into those breaks. I say just plow through.
  • I say “it’s good for your soul” a lot too. Here’s an example . . .
  • I don’t like the “it’s good for your soul” motivation because . . .
  • If the students’ numeric results are always ellipses, good enough!
  • Do you know if the “equal area in equal time” only works in the reduced mass system?
  • I’m the friend from the math(ematics) department and you’ve misquoted me like heck. What I really said was . . .
Posted in sbar, sbg, syllabus creation | 2 Comments

Double pendulum roller coaster FIXED

My last post was wrong. I’m to blame. But in thinking about it and talking about it with with lots of helpful friends I ended up learning a ton. Here’s the upshot: There were kinks in the roller coaster loop that led to integration mistakes on the part of Mathematica. Thanks to a great suggestion from my friend Craig I smoothed those out:

The blue track is the one with kinks in it. The orange one is the used for the simulation in this post

The blue track is the one with kinks in it. The orange one is the used for the simulation in this post

And now the simulation animation looks like this (there’s some extra annotation that I’ll talk about below):

The green dot is the center of mass of the system. The orange arrow is the normal force. The purple arrow is the direction that the center of mass is traveling.

The green dot is the center of mass of the system. The orange arrow is the normal force. The purple arrow is the direction that the center of mass is traveling.

Note first that the system never gets above the dotted green line, which was my (mistaken) idea from the last post. This post will try to talk about what I learned about whether the normal force does any work (which was my mistaken explanation in the last post).

The track exerts a force on the red ball to keep it on the track. Gravity and the connection to the first black ball are yanking on that ball and the track does whatever it has to in order to ensure that the red ball stays on the track. My argument from the last post boils down to this: The normal force is an external force to the system of three balls. That system has a center of mass that I can pretend the external force acts on. If the center of mass is moving perpendicularly to the normal force (as would happen with just the red bead), there would be no work. But if the center of mass is moving at times slightly parallel to the normal force, then there would be some work. It turns out there’s really nothing wrong with that description. However, assuming that changes the kinetic energy of the system is wrong. What it does (as again my friend Craig suggested) is it changes the translational kinetic energy of the system (basically the kinetic energy of the system if you replaced it with all the mass being at the center of mass). However, the total kinetic energy of the system is both the translational and rotational kinetic energy. What I intend to discuss here is that the effect on the rotational kinetic energy due to the normal force is exactly the opposite of the effect on the translational kinetic energy.

First a quick plot. This shows in blue the time derivative of the translational kinetic energy of the system (subtracting out the effects of gravity) and in orange the work per unit time that the normal force does on the system:

The comparison of the rates of change of the translational kinetic energy (without gravity effects) and the work that the normal force does on the system.

The comparison of the rates of change of the translational kinetic energy (without gravity effects) and the work that the normal force does on the system.

Actually, you don’t see the orange because, to the accuracy of the thickness of the lines, the orange is completely underneath the blue.

Let’s try to understand what’s going on. Consider first the time rate of change of the kinetic energy of the system:

\frac{d}{dt}\left(\frac{1}{2}\sum_i m_i v_i^2\right)=\frac{d}{dt}\left(\frac{1}{2}\sum_i m_i \vec{v}_i\cdot \vec{v}_i\right)

The derivative can come right into the sum, and the vector product rule gives us:

\frac{d\text{KE}}{dt}=\sum_i m_i \vec{a}_i \cdot \vec{v}_i=\sum_i \vec{F}_i\cdot \vec{v}_i

where I’ve used Newton’s second law in the last step. Now the normal force is only “attached” to the red bead, but that’s the one bead that’s guaranteed to be moving perpendicular to the normal force. So the contribution to the time change of kinetic energy due to the normal force is indeed zero! Hence my last post is wrong.

But what about this business with the translational kinetic energy? We tell our students all the time that they can think of all forces as acting on the center of mass. In other words, the change of momentum of the center of mass is due to the collection of all external forces. Those forces will do work if they act, at least partially, in the direction that the center of mass is traveling. In the animation above the purple arrow shows the direction that the center of mass is traveling. You can see that it doesn’t always point along the track. That means that it’s not always perpendicular to the normal force. Hence work is done on the center of mass. But that just affects the translation of that center of mass, not any rotation about it. To see the whole story, let’s redo the last calculation using a coordinate system centered on the center of mass. For those variables, I’ll use primes. First I’ll start with an expression for the kinetic energy:

\text{KE}=\frac{1}{2}\sum_i m_i (\vec{v}_\text{cm}+\vec{v}_i')\cdot(\vec{v}_\text{cm}+\vec{v}_i')

Now when you do the FOIL of that dot product, two of the terms go to zero (that’s the beauty of using the center of mass, by the way) and you’re left with:

\text{KE}=\frac{1}{2} M V^2+\frac{1}{2}\sum_i m_i \vec{v}_i'\cdot \vec{v}_i'

where M is the total mass of the system and V is the velocity of the center of mass. Now, let’s consider doing a time derivative of that. For the first term you’ll get exactly what I was talking about above. In other words you’ll get the dot product of the total external forces and the velocity of the center of mass.

\frac{d}{dt}\text{KE}=\sum_i \vec{F}_i\cdot \vec{v}_\text{cm}+\sum_i m_i \vec{a}_i\cdot \vec{v}_i'

Now here’s a trick. Let’s re-express the velocity back into the normal frame (and use Newton’s second law again) for the second term above:


Here’s where the magic happens. The normal force is only applied to the particle on the track. But it’s velocity is perpendicular to the normal force by definition. So the first term in the parenthesis yields a zero. What we’re left with is:

-\sum_i \vec{F}_i\cdot \vec{v}_\text{cm}

which is exactly the opposite of the change to the translational energy. In other words, you can either say that, yes, the normal force does some work, but it changes the translational kinetic energy by exactly an amount that is the opposite of how it changes the rotational kinetic energy, or you can just say that the normal force does no work. You decide.

Thoughts? Here are some starters for you:

  • Thanks for this, I was totally at a loss for figuring out the mistakes in the last post.
  • I’m glad you figured this out for yourself, just know that the rest of us knew this all along and have been laughing at you for your last post for a few days now.
  • Wait, it doesn’t work!? I’ve already starting building it in my backyard!
  • How did you figure out the normal force? Did you determine the accelerations of all the particles and subtract all known forces, starting with the last black dot and moving up to the red dot. Or did you use Lagrange multipliers to figure out the normal force more directly, and, if so, how did you figure out the constraint equations for the track? (yes, yes, and it’s a long but interesting story involving me jumping out of bed this morning and trying something that worked!)
  • So how would you say it? Does the track do work on the system?
  • How is it that you were willing to believe that the track could help you violate energy conservation? What, are you some sort of “momentum is king” kind of guy or something?
Posted in mathematica, physics | 7 Comments