So I am in fourth year and doing the BT Young Scientist (Ireland’s version for a science fair but bigger and there is a cash prize) and came up with the idea to launch a space shuttle from a rail gun, and was wondering if a 45 degree angle would be the most effective way to orbit around the earth.
Any orbit achieved will (discounting perturbations) pass through the point at which it was last altered by some external force. In the case of your rail gun, if it's on the ground, any possible non-escape trajectory it will take will also intersect the ground. For a sustaining orbit, you need a second impulse near apogee to raise the perigee above the atmosphere.
Any launch based on rail guns is going to result in acceleration magnitudes so great (thousands of Gs) that anything resembling a recognizable spacecraft will quite simply be crushed.
To keep the acceleration manageable, you need a very long rail gun: say 8000 m/s of speed needed, 40 m/s2 acceleration (4G), that's 8000/40= 200 seconds of 'flight' on the rail. That's 800 km. That's impossible to build at an angle of 45º (highest we can build is about 10 km) so that will dictate a much shallower angle.
This ignores the heat load in the atmosphere, as Uwe said, it's almost impossible to accelerate a spacecraft to orbital speed at sea level without it burning up.
It also ignores the drag from the atmosphere: as soon as it leaves the rail, the spacecraft will start to slow down.
45 degrees is probably not ideal.
...but it depends on your shuttle design.
To get to orbit, you need to go fast, not high. It's hard to go fast at low altitudes though, because there is a lot of air in the way. If you go higher up, it's easier to go fast because there is less air. But even after you get out of the air, you still have to get going fast.
Air resistance is a force (i.e. acceleration) which scales opposite velocity. So, the faster you go, the more the wind pushes you backwards. That resistance also scales with how dense the air is, because denser air means more air molecules to get in the way.
If we assume that your shuttle has only a "go" button on it's propulsion, and then will provide a pre-set thrust, you maximize the speed you get out of that thrust by minimizing the amount of force the air applies to your shuttle. For most rockets, that looks like launching (almost) straight up, then slowly curving further and further toward the orbit they want. For anything basically like a rocket, this is probably the optimal method.
But your shuttle may have other constraints. Maybe you're launching it super fast, but have a way to minimize drag enough that it will fly out of the atmosphere using the energy from the launch, then rocket it's way to orbit. Maybe 45 degrees is your maximum elevation, because after that you run out of mountain. Maybe you can launch the shuttle really, really fast, and are launching it only into elliptical orbits(like not-quite-Molniya orbits). There may be any number of reasons that 45 degrees is good for your application. In general though, I would not expect 45 degrees to be optimal.
The best primer I know of on everything space is the US Air Force's primer, which is available free: http://space.au.af.mil/au-18-2009/index.htm.
If you want to understand orbits in detail, including getting to and from orbit, Sellers' Understanding Space is good.
Ignoring the atmosphere, let's say you're launching from the moon, the best angle to launch at would be 0 degrees.
This way you can accelerate to orbital speed at sea-level plus however much you need to get straight into basically a Hohmann transfer orbit using only the rail gun. After this you only need a small amount of fuel from the shuttle itself to circularize the orbit.
Launching at a higher angle will make you reach the height of your desired orbit faster but at a lower velocity. Meaning you get less energy out of the rail gun and would need more from the shuttle.
As others have mentioned, once an atmosphere comes into play the whole idea of using a rail gun becomes very difficult.
As others have mentioned, orbits pass through the last point where a force acted upon the body, so a 45 degree angle shot will (attempt) to pass back through the ground at the point of launch at the same angle. Obviously that's not going to work because there's a lot of Earth in between.
Now what is the best angle? Again, because orbits pass back through the last point of acceleration (yeah I know that there's always acceleration, you know what I mean), you're going to have to accelerate again once you're in space, or your shuttle will re-enter the atmosphere and not achieve orbit.
So your aim should be to make it to space and then fire engines to accelerate to orbital velocity. The ideal scenario here is that you shoot your rail gun at 0 degrees (tangential to the surface) and aim for your highest point to be exactly on the opposite side of the earth, at the height you want to orbit. The problem with that is that there happens to be a lot of air in the way, so you're going to be streaking through the sky like a meteor for hundreds of miles. Not very efficient, and very likely to destroy your shuttle.
So let's try and minimize the amount of in-atmosphere flight time. The best way to do that is to go straight up. So let's try shooting the rail gun at a 90 degree angle. You're going to fly way up high into space until you reach the highest point, where you'll burn your engines until you reach orbital velocity. The problem with this scenario is that, at the top of your flight, you'll have very little horizontal velocity (you'll have gotten some from the earth's rotation, but because you're much higher than the earth's surface, and if you don't fire your engines, the surface will pass you by and you'll land behind where you lifted off from). The upshot (get it?) here is that you have to burn more fuel to achieve orbital speed than if you had fired at the 0 degree orbit to make up for the lack of horizontal speed (that's assuming there's no atmosphere; it's likely not possible to launch at 0 degrees with an atmosphere).
So you're going to need to do something in between. Finding that in-between is very hard; you'll need to balance how much drag from the atmosphere you are willing to take against how much fuel you need to achieve orbital velocity. The lower the angle, the less fuel you'll need, but the faster you'll have to launch your shuttle from the rail-gun, and the more atmosphere you'll have to pass through to get to space. Keep in mind that the faster you launch the shuttle the more likely it is to burn up in the atmosphere, and that the more fuel you need to get to orbital velocity, the larger your shuttle will need to be, and therefore the more drag will act on it in the atmosphere.
Finally all of this is assuming you have a rail-gun that can fire your shuttle to begin with. The amount of energy it takes to take a shuttle from a standstill to orbital speed is astronomical (sorry for the puns). Expending all that energy in such a short time as you're considering would take ludicrous amounts of power, and that will likely be your limiting factor when it comes to making this plan work.
You might want to try posting this question on the physics stack exchange. It might be that someone with much better aerodynamics knowledge than myself can at least give you better guess. That being said I'm going to say that, as an educated guess, you're likely going to need to fire almost straight up, if this is possible at all, or you're going to burn up in the atmosphere.
As many before me have commented, there is a trade-off between gaining altitude (for purposes of reducing drag and raising the highest possible perigee) and gaining horizontal speed (reducing spacecraft Delta-v reqs to manageable levels, raising actual perigee). Knowing that you have to have a very long railgun to reduce G-loads, you can actually model the ideal path of travel in a very similar way to normal rocket launch trajectories. You would just substitute the gun's acceleration for the increasing acceleration of rocketry.
I don't see the cost of such an enormous structure being less than the cost of the inefficiencies of the rocket equation any time soon especially considering that you would need multiple guns or a rotating gun to service different orbital inclinations without an enormous amount of spacecraft Delta-v.
Essentially, as infeasible as the project is and probably will remain for quite some time, we can say that your gun's optimum shape is not a line at a given angle, but a curve quite like a gravity turn.