0
$\begingroup$

Context:
I'm trying to make a simulation of a box that you can apply force to the top and it will oscillate back and forth until the energy in the system reaches equilibrium again.

Visual representation of how I imagine the system:
enter image description here

enter image description here

What I want to visualise:
My simulation is simply going to draw a graph of the angle over time.

enter image description here

maybe it would look a bit more like this?

enter image description here

Proof of work:
I don't want to add much fuss here so will strip out all detail but essentially I had tried starting with a pendulum due to the oscillatory nature of the system. I then added viscous damping. I basically had a graph of a pendulum and was happy with it. But then I realised, my system is totally different with centre of mass, torque, momentum, changing pivot points.

Thoughts on the problem:

  1. The potential energy from the finger is given in one initial short impulse.
  2. The finger has potential energy. PE = 1.0 (Where potential energy is 100% of the energy in the system) (Is that a good idea?)
  3. The box has a:
    1. height = 50cm,
    2. width = 10cm
    3. mass = 2kg
  4. The ground has a friction which locks the system in place (so, no need to worry about it)
  5. Air resistance:
    1. air_resistance = ? # Whatever makes it look cool in the graph

Question:

  1. What kinds of things do I need to think about in terms of the equations
  2. How do i port the equations over so that it's all as a function of time.

I think that getting help with this problem will allow me to grasp future versions of similar problems as I've been struggling with this for a whole month now and I feel like i'm close to giving up which is really frustrating me. I even feel I'm at a point where i'm happier reading equations but converting them to things as functions of time whereby one loop of the code will write out the new state of the system is getting complex for me.

If you feel you need to answer with code, that's totally fine (I'm writing this in python but am good with most languages)!

$\endgroup$
2
  • $\begingroup$ Does this really work as a pendulum? Try graphing the restoring force compared to the angle of the box; it's not linear. $\endgroup$ Commented Dec 29, 2020 at 18:05
  • $\begingroup$ It's not the same as a pendulum, so no, unfortuantely not. I used maximum amplitude multiplied by Euler constant to the power of -b (friction) multiplied by the elapsed time, all divided by 2 * the mass: A0e^((-b*t)/2*M) ... Which in turn is multiplied by the cos(sqrt(g/l)*t) - The problem with this is that it needs a starting amplitude and loses energy. I need to give an initial energy, and I also need to work out the pivot points and tipping points that change as energy moves from side to side. I am an absolute beginning in math and physics so any help is appreciated. Thank you. $\endgroup$
    – Jimmyt1988
    Commented Dec 29, 2020 at 21:13

2 Answers 2

1
$\begingroup$

Incorporating friction will be really complicated, but you can probably still model the system as a damped harmonic oscillator. Before you write the code, you will need to solve the free-body diagrams associated with your system and get an expression for the angular acceleration of the block's center-of-mass. After that, you can use a simple time-step algorithm to generate matrices for the angular position and the angular velocity of the c.o.m.

$\endgroup$
2
  • $\begingroup$ Thanks for the link. I appreciate your time to respond. I've hit that point where I'm looking at the equations and my mind is just saying "not today". I'll report back if I learn anything new. I have been through this wiki page before but your confidence is telling me to give it another try. $\endgroup$
    – Jimmyt1988
    Commented Dec 29, 2020 at 21:07
  • $\begingroup$ I've added "free body diagram" things to the above pictures and also added a normal force diagram of how I imagine those forces work as you push the bottle. The damped harmonic oscillator link does not have any trigonometry in it so am expecting it doesn't relate to a torque force. $\endgroup$
    – Jimmyt1988
    Commented Dec 29, 2020 at 23:51
1
$\begingroup$

TL;DR:
Stepping function: $$ \text{Theta}_{n+1} = \theta_{n+1} = \theta_n + \dot{\theta_n}\Delta t $$

$$ \text{Angular acceleration}_n = \alpha = \ddot{\theta}_n = - \frac{mg}{I} ( \frac{x}{2} \cos \theta_n - \frac{y}{2} \sin \theta_n ) $$

$$ \text{Angular velocity}_{n+1} = \omega = \dot{\theta}_{n+1} = \dot{\theta_n} + \ddot{\theta_n}\Delta t $$

enter image description here


Free body diagram:

![enter image description here

We will start by considering a box, that has an arbitrary starting "angular velocity":

$$ \omega = \frac{d \theta}{dt} = \dot{\theta} = 0.1 $$

and an arbitrary "angle" that we will call theta.

$$ \theta = 0 $$

Please also note some constants (with my arbitrary values):

  • I = 100, m = 1, x = 2, y = 2:

Natural laws:

  • Here's the equation for Force:

$$ \text{F} = ma $$

  • Here's the above equation in relation to Torque (I = moment of inertia, $\alpha$ = angular acceleration):

$$ \tau = I\alpha $$

  • $\ddot{\theta}$ - The second derivative of $\theta$ with respect to time "t" is equal to angular acceleration $\alpha$.
  • $\dot{\theta}$ - The first derivative of $\theta$ with respect to t is equal to angular velocity $\omega$.

Solving the free body diagram:

d is the distance perpendicular to the axis:

$$ d = \frac{x}{2} \cos \theta - \frac{y}{2} \sin \theta $$

If d > 0, then the box is tipping over.

Here is the equation for torque that takes into consideration the components of our box tipping problem:

$$ \tau_{net} = mgd = mg(\frac{x}{2} \cos \theta - \frac{y}{2} \sin \theta) $$

Torque equation with respect to our problem's components:

$$ \tau_{net} = mg(\frac{x}{2} \cos \theta - \frac{y}{2} \sin \theta) = -I \frac{d^2 \theta}{dt^2} $$

Note that the second derivative of theta is angular acceleration. We need this on its own, so we must re-work the above torque equation by dividing the left side by -I:

$$ \alpha = - \frac{mg}{I} ( \frac{x}{2} \cos \theta - \frac{y}{2} \sin \theta ) = \frac{d^2 \theta}{dt^2} $$

We now have an equation for angular acceleration.

Theta and angular velocity:

Consider a graph that draws theta, angular velocity and angular acceleration one above each other:

enter image description here

  • The second derivative is equal to the slope of the first derivative. This equation is known up front because we know theta up front. Thus here is the first step in our stepping function:

$$ \text{Angular acceleration}_n = \alpha = \ddot{\theta}_n = - \frac{mg}{I} ( \frac{x}{2} \cos \theta_n - \frac{y}{2} \sin \theta_n ) $$

  • The first derivative is the slope of theta. It can be worked out by adding the second derivative to the first derivative. Note the additional multiplication of $\Delta t$:

$$ \text{Angular velocity}_{n+1} = \omega = \dot{\theta}_{n+1} = \dot{\theta_n} + \ddot{\theta_n}\Delta t $$

  • The next theta on the next loop/step can be worked out by adding the first derivative

$$ \text{Theta}_{n+1} = \theta_{n+1} = \theta_n + \dot{\theta_n}\Delta t $$

Now continue this loop - Here is this stepping demonstrated in code:

enter image description here

To change the pivot, if theta < 0 and the elapsed time is > 0, then set theta to 0 and negate the first derivative.

if theta < 0 and elapsedTime > 0:
    theta = 0

...


if theta == 0 and elapsedTime > 0:
    firstDerivativeOfTheta = -firstDerivativeOfTheta

Adding friction or resistance:

Energy dampening due to "inelastic collision" or Air resistance (for example) can be added by simply negating the value with a constant.

$$ \text{...-b} $$

Thanks:

  • Thank you to the person who helped me along the way. You know who you are... :)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.