![]() More evidence can be gained by integrating the change in energy expression across a path. This does not prove that method B is stable, but it is a clue that method B is more stable than method A. If method B is used, the energy can decrease when v=0. Since it also increases when x=0, this is a clue that method A might be unstable. If method A is used, the energy always increases when v=0. However, the change in energy differs when v=0. These results show that both systems gain energy when x=0. Evaluating these expressions at x=0 and v=0 can give some insight into how the energy will change overall. As the simulation progresses, the mass will follow some path through this 2D space and will gain or lose energy depending on the value of. Since k is a constant, these expressions have two variables, x and v. The expressions (A2) and (B2) show how the energy of the system will change in the next time-step compared to the current time-step. Subtracting the energy from the current state gives the change in energy. With this information, the energy of the next state can be calculated. For this example, the following equations are used: These are the rules that calculate the next state given the current state. Next, the update rules need to be defined. The following equation will be used to calculate the energy: The potential energy ( PE) is from x, and the kinetic energy ( KE) is from v. This system has two state variables that contribute to its energy: x and v. An energy analysis can help in understanding why this is so.įirst, an expression is needed to calculate the system’s energy given its state. When running the program, it is clear that method A is unstable, but method B appears to be stable. One uses the velocity from the current time-step ( method A), the other uses the velocity from the next time-step ( method B). The code shows two different ways to calculate the next position of the mass. The oscillator is modeled as a mass on a spring, with the usual restoring force of -kx. * two ways to calculate next position */ The oscillator is implemented in C using the following source code:ĭouble x, v, a /* position, velocity, acceleration */ĭouble xn, vn /* next position and velocity */Ī = -( x * SC ) /* acceleration from spring force */ ![]() ![]() The example presented here is a simple harmonic oscillator. This can provide clues about whether the simulation will be stable or not.Īn example will help to illustrate this analysis process. In many cases, these rules can be analyzed to calculate the change in energy from one time-step to the next. For a discrete time-step simulation, there will be a set of rules that transform the state at one time to the state at the next time. Given a system state, it should be possible to calculate the total energy of the system. In a physical system, the total energy will be constant. In many cases, this can be done with an energy analysis.
0 Comments
Leave a Reply. |