Drasil: Feedback on DblPendulum

Created on 22 Oct 2020  路  11Comments  路  Source: JacquesCarette/Drasil

@oluowoj, I've reviewed the physics behind the DblPendulum example and I have the following feedback:

  • the project should be renamed Pendulum (since it isn't a double pendulum)
  • your derivation uses a Cartesian coordinate system, but your diagram implies a polar coordinate system. The derivation for a single pendulum is much easier in a polar coordinate system, but then you would end up removing much of what you currently have. It will be interesting to see what the derivation looks like in a Cartesian coordinate system, and I think it will be less work at this point, so the figure of the physical system should be updated to show the correct coordinate system.
  • I found the figure that you used for the physical system. We need to replace this figure anyway, but if you use figures that you find on-line, please cite the source.
  • the current Figure for the physical system uses L for the length of the rod, but you use L_rod throughout the document
  • the derivations of the equations will eventually be necessary, since it is not obvious where your equations come from
  • If you are going to use omega for the time rate of change of theta, you should give this relationship somewhere. The relationship for alpha should also be given.
  • For GD:hForceOnPendulum, you have Force as a vector, but it should be F_x. You really should just get rid of the bold F in this equation. Your T shouldn't be bold either.
  • The previous comments apply for GD:vForce OnPendulum. In this case g should not be bold. g is the acceleration due to gravity in the y direction, not a vector.
  • For DD:positionIX, you should have theta initial, if you really mean initial position; the same comment applies for the y component.

All 11 comments

I've been thinking about the pendulum problem further. I think the work will be much easier if you switch to a polar coordinate system. If you continue on the path of Cartesian coordinates, you will get two ODEs (one for ax and one for ay). To get one ODE, we would have to convert to a polar coordinate system at this point, so why not just start there.

The web-page that you used for the figure of the physical system shows how to derive the equation of motion for a pendulum using a polar coordinate system. This switch will greatly simplify your document.

@smiths, for the derivation of the equation of pendulum motion, the equation is a 2nd order derivative
image

I don't think we have any functions in Drasil to write a 2nd derivative equation.

@JacquesCarette, any thoughts about a workaround?

@oluowoj, we discussed this problem in a previous meeting. There isn't currently a way to solve second order ODEs in Drasil. However, Drasil is close to being able to solve problems like this. Naveen (CAS 741 student) has said that he will look into it.

My guess is that you don't want to tackle adding second order ODEs to Drasil, and I know you are anxious to have a complete example. Why don't we "cheat" a little, just temporarily, and use the first derivative (as you show in your SRS above), even though we know it is really the second derivative? We can go back and fix is later, but for now, you want to be able to complete your example.

I looked at solving the second order ODE as two first order ODEs (a standard solution technique), but this doesn't work for us because the two first order ODEs are coupled. We would need to extend Drasil to solve a system of first order ODEs. Drasil is close to being able to this as well, Brooks has the infrastructure in there, but it hasn't been completed.

Yes, we did discuss this. I would just keep the equation as is. I was trying some hacks initially.
Could you please point me to Brooks's instructions to generate code in Drasil?

Brooks didn't write instructions, as far as I know, he wrote code for interfacing to an external library, like an ODE solver library. He had the input ODE as a list of ODEs (as opposed to a single ODE) to facilitate future expansion to a system of ODEs. This is what I meant when I said infrastructure.

You can simply do deriv (deriv (sy XXX) time) time where XXX is the symbol you want to get a second derivative. It won't necessarily display very well right now, but it is still correct. We can fix things later, but the knowledge should be properly encoded.

@oluowoj, I thought the question was about generating code to solve second order equations. I didn't realize the question was about displaying the correct equation. Please use the suggestion from @JacquesCarette for displaying the equation. However, we still need to solve the problem of generating code to solve second order (and higher) ODEs.

@JacquesCarette, I am getting this error when I build the pendulum project. Any thoughts?

image

I just pushed the code to pendulumDerv branch

Oh my. <<loop>> is one of the hardest things to debug in Haskell. It means it has detected that something has gone into an infinite loop.

This usually means that you've got something defined in terms of itself, in a way that you really didn't mean. Luckily, it should be the case that the problem was introduced in your latest changes. So I would back them out, and re-introduce them as slowly as possible, to know which line is the cause.

Right, it was a case of input and input constraint mismatch.

initialPendAngleCons = constrained' initialPendAngleCons [gtZeroConstr] (dbl 2.1)

instead of

initialPendAngleCons = constrained' initialPendAngle [gtZeroConstr] (dbl 2.1).

Glad it wasn't too hard to spot and fix!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samm82 picture samm82  路  4Comments

samm82 picture samm82  路  3Comments

samm82 picture samm82  路  10Comments

samm82 picture samm82  路  10Comments

smiths picture smiths  路  12Comments