This article is part of the Fool's Halfway Through 2012 series, in which we review how sectors have done since January and see what's coming for the rest of the year. Click here to read all of the articles.

The market as a whole has had a decent start to 2012, but energy stocks have been hammered so far this year. The falling prices of oil and natural gas have driven most of the losses, and they've been driven by our economic malaise.

To illustrate how bad it's been in energy, the chart below shows the SPDR S&P 500 Index ETF versus the iShares S&P Global Energy ETF and the Vanguard Energy ETF. Energy has underperformed the market by more than 10% so far this year.

IXC Chart

IXC data by YCharts.

So what has gone on, and what should we expect in the second half of the year? I'll cover these two topics for the major energy sources below.

Oil and the Middle East
In recent years, oil has been driven by two major factors: economic growth and geopolitical turmoil. When we were at war in Iraq and the economy was strong, oil reached $140 per barrel. When the economy tanked, oil crashed like a rock. More recently, when Libya was in turmoil and Iran was threatening to close the straight of Hormuz, oil peaked at more than $110 per barrel. But since early this year, the economy has begun to slow, and there hasn't been any major crisis recently, particularly in the Middle East.

Despite the falling price of oil, domestic drilling is still expanding dramatically, and drillers like Kodiak Oil & Gas (NYSE: KOG) are reaping the rewards of expansion and improving costs. Kodiak increased production by 385% to 12,696 barrels of oil equivalent per day in the second quarter, a trend that played out across the country.

In the second half of the year, oil and gas stocks will likely be driven by the same thing that drove the price of oil in the first half. If Iran and Syria don't cause any major tensions, the price of oil could remain low and hold back oil stocks. Worse yet, if the economy continues to slip and the fiscal cliff pushes us toward recession territory, the price of oil could fall again.

The situation in Syria appears to be coming to a head, and Iran has been too quiet for too long, making me think the Middle East will drive the price of oil higher. These countries also need a higher oil price than we currently have to support their economies, so they have a vested interest in higher prices. I don't expect energy stocks to underperform again in the second half of 2012, and I think this would be a great time to make a bet on oil.

The rise and fall of natural gas
Depending on how you look at it, natural gas is either at an advantage or in dire straits right now. On a macro level, natural gas is cheap, its usage is being expanded in electricity production, and we're talking about using it in vehicles and exporting it.

If you're Clean Energy Fuels (Nasdaq: CLNE), which could leverage its infrastructure of fueling stations, or Cheniere Energy, which is building an export terminal, the falling price of natural gas is a great thing. It makes the fuel more competitive versus oil, and with U.S. prices lower than international prices, Cheniere is hoping to capitalize on a newly created international trade market.

But the flip side of the coin is that producers are struggling around the country. Chesapeake Energy (NYSE: CHK) announced earlier this year that it would cut back natural-gas production, and companies with diverse assets are transitioning their wells from natural-gas-rich areas to oil.

Even with the reduction in drilling, I wouldn't expect the price of natural gas -- and by extension profits at drillers -- to increase much during the rest of the year. Any marginal improvement in the price will be met by an increase in production from drillers, which can make up for their costs at a higher price.

The quick demise of coal
If oil and gas stocks have so far had a tough 2012, it's been disastrous for coal. Demand has fallen as electricity generators move from coal to natural gas, and more than 100 coal plants have been shut down, so the demand won't be coming back online.

Earlier this month, Patriot Coal, a major U.S. miner, had to file for bankruptcy because the conditions had become so trying. With global energy trends moving toward cleaner forms of energy, investors would be wise to stay away from this industry. A diversified, low-cost producer like Peabody Energy may be able to survive, but catching a falling knife is tough to do, and right now the trends in energy don't favor coal producers at all.

The two sides of renewable energy
Like natural gas, renewable energy is either thriving or dying, depending on how you look at it. Costs have fallen so far that solar is now less expensive than grid parity in parts of the world, leading to a rapid rise in installations. But that success has come at the expense of industry profits, which don't really exist.

First Solar (Nasdaq: FSLR) has been reporting massive losses and is under pressure from Chinese firms that seem to care more about increasing production than turning a profit. Companies are going bankrupt left and right in solar energy, and wind hasn't fared much better.

With that said, the opportunity for solar in particular is massive, and the companies that survive will be big winners for investors who can make the right bets. When those bets will pay off, however, is a question no one can answer right now.

The big picture
For investors looking for energy opportunities in the second half of 2012, I would look for low-risk opportunities in oil and high-risk opportunities in solar. SeaDrill (NYSE: SDRL) and Kinder Morgan don't aren't affected by the price of oil or natural gas directly, but they will both benefit if prices rise. These are lower-rise, high-dividend plays suitable for investors looking for some energy exposure.

In solar, First Solar has a lot of upside in the downstream market, and with its strong balance sheet and current valuation, it has the potential to be a trophy stock. However, if you're looking beyond solar, we have three more energy picks that will benefit from rising oil prices. Check out our report: "3 Stocks for $100 Oil." The report is free when you click here, but only for a limited time.

This article is part of the Fool's Halfway Through 2012 series, in which we review how sectors have done since January and see what's coming for the rest of the year. Click here to read all of the articles.