In a class about simulations, you'd be correct in thinking we're going to design and analyze quite a few simulations. These are going to differ in really fundamental ways, but there are many broad concepts that show up repeatedly in this field.

float energy_in_joules = distance_in_feet * force_in_pounds;

Of course, foot * pound force gives you ft-lb of energy, not joules. But all the variables are "float", so the compiler happily lets these errors creep in.

The best way to avoid unit errors is to pick your units when you begin building the simulation, and stick with them throughout. Metric units (meters, kilograms, seconds) seem to be the most common, although I've worked with everything from astrophysical simulations where "1.0" is the size of the universe, and molecular dynamics simulations where "1.0" is the size of an atom.

It is possible to go back and figure out the effective units you're working in after the fact, but it's less effort and more reliable to figure them out as you go. Sometimes I'll work without units just to try to capture the overall "feel" of a phenomena before actually matching it to reality.

The usual definition of velocity is the time derivative of
position:

V = dP/dt

This is extremely mathematically useful, since we can use all the
tools of calculus on a differential definition like this.
But it's less computationally useful, since computers don't do
infinitesimals. There are a variety of ways to discretize
this equation into actual numerical steps; but the simplest is to
replace the infinitesimal derivative with a finite difference:

V = delta_P / delta_t

which means

V = (new_P - old_P) / delta_t

Given a set of positions, this equation lets us estimate the
velocity between known positions. We can also solve for new_P, to
get the Euler update:

new_P = old_P + V * delta_t

There are many variations on this method with better properties,
but this is the basic idea. One big problem here is to best
approximate the underlying partial differential equation,
"delta_t" should be as small as possible. Small enough, and
roundoff begins to change your simulation results. Also,
making the timestep half as big needs twice as many steps for the
same simulated time, so you quickly run into computational
limitations: even a simple partial differential equation can
consume arbitrary computational power and still not be perfect!

Energy is conserved mostly because:

- If you keep adding energy, everything explodes (the world "ends in fire").
- If you keep removing energy, everything freezes in place (the world "ends in ice").
- If you don't add or remove energy, everything keeps working reasonably.

You can also lose or gain energy at the borders of the simulation, where things like the energy added to the wind as your object passes by, or the electrical energy input to the motor, aren't accounted for. You can often fairly easily add these border energy terms back in, and sometimes they can be quite useful (e.g., noting that most of the drag energy loss in a boat is happening at the tail).

Linear and angular momentum are also conserved quantities. Loss of momentum conservation tends to look weird, causing objects to fly off into the distance.

One common trick is to make the boundaries periodic, essentially wrapping the simulation around at the boundaries.