Last spring I ran a half marathon. I trained rather well for it and hit distance close to and equal to 13 miles in my training. I managed these training runs without incident. However, during the race I experienced incredible muscle spasms in my calves from around mile 9 to the end of the race. It was as though my calves were experiencing electric shock. Why did this not happen during my training and what can I do to prevent for the same race this coming Spring?
First, there are two things that you note in your comments that are the most likely culprits. The race being hillier than your training area is the first indicator, as hill running is an entirely different beast than flat. It's much harder on the legs, and the calves especially, as they are the springs and shock absorbers for your legs.
You're also doing this at a faster pace than your training (more on the training in a bit), which will also contribute to muscle failure, because you're working your muscles harder and faster than they are used to.
just a side note, is you say
...hit distance close to and equal to 13 miles in my training.
You really should have some overdistance, some slow easy miles longer than a 1/2 marathon a few times in your training. Not often, but every once in a while.
As to what will help it, it's basically just more hills. Find ways to incorporate hills into your runs, and if you can manage it, a few times a month go out and do 1/4 - 1/2 mile repeats up a hill. Run it hard, and use the down and a minute or two at the bottom of the hill as rest. If you don't run hills in training, they will hurt you badly in races.