As with any of the heroes, it's important to consider the team composition in which a character can excel.
Not all Tanks are Main Tanks
Zarya is a prototypical off tank. If you're not used to the MOBA genre, off tanks generally have higher damage potential and/or higher mobility than their main tank counterparts, at the cost of not being able to take as much sustained punishment.
I have categorically placed the tanks in Overwatch as follows:
Main Tanks: Reinhardt, Winston, Roadhog
Off Tanks: D-Va, Zarya
Now admittedly it's not all that straightforward (things change depending on if you're offense or defense) but I feel this is a very safe guideline for new players when deciding how to fill out their team comps.
Off tanks have combat roles that sometimes overlap with main tanks, with the one big exception being they can't lead a push down the main channel themselves. The main channel is the the path towards the objective that is the most open and exposed while also being the shortest (for heroes without special movement abilities). It is absolutely critical to establish position in the main channel so the flankers/counter-flankers can do their thing along the side channels (which is why main tank is the most important role in the game and the skill/awareness of the tank has the biggest effect on the game, but I digress).
So let's look at some combat situations where off tanks can excel and how to play Zarya's strengths in these situations:
Off Tank Strengths
Help lead the charge down the main channel - This is where the particle barriers really shine, and where it really helps to have a main tank with a bit of movement. A combo that can carry you through the learning phase and really illustrates what she's about is Reinhardt/Zarya. Reinhardt charges forward, disrupting the enemy team but exposing himself. E him to give him a particle barrier and then follow him up with your own L-shift barrier. You're going to want to interpose yourself in the line of fire while firing right click pot shots to knock up and disrupt enemies and give Reinhardt a chance to establish position with his shield or clear a room. You and the main tank will take turns absorbing damage in a do-si-do of bullets and carnage. Ideally you don't want to have both of your barriers on cooldown at the same time - this is Zarya's biggest time of vulnerability during a push.
While offense heroes excel at clearing flanks, and defense heroes are noted for the ability to hold any channel including flanks, only the off tanks excel at clearing and holding flanks (Zarya flex). Zarya is going to take the role as sole meat shield here - lead the charge, barrier yourself and go wild. Unlike main charges, you're going to have to hope your team mates take your cue and follow you up so you have someone in sight to E, and conversely you must be aware of your team's general location and awareness of this charge. Once you gain confidence with Zarya and the game in general, it's not uncommon to clear a side room of 3 squishies solo. If you're on defense and you see them bunched up in a side room, you should be drooling - your right click is going to do massive damage. This is also where her high base shields naturally come in to play - with flanks you have a lot of cover where you can regenerate and reload your weapon. How scary is it that a tank can lose half her life and simply hide for a few seconds to return to full strength without a healer, med pack, or activated ability? This is a very uncommon feature for tanks in any genre and for good reason - it's super strong. Abuse it.
Cover your back line - this is more straightforward and is really something you should be doing at all times, including either of the previous situations. It comes with having situation awareness and general game experience. You should not have to rely on your Mercy telling you over voice that there's a Genji behind you stabbing her to death - by then it's too late. Rely on context and hearing (sound is huge in this game like most good shooters). E your teammate as a stopgap, then get in front of them and give them a chance to escape while your L-shift is up. You don't even need to kill them necessarily, as most offensive flankers are too evasive for your weapons. Allow your teammate to lead them into a disadvantageous position - into the open and surrounded by enemies - like a fish chasing the bait.
- Pair with a main tank - Reinhardt is a combo that is easy and natural for beginners
- Weave right click with left click - while enemies are knocked up from the right click it's easier to hit with the precision left click. What she lacks in movement she makes up for by having a strong knock up that you can fire while moving
- Take turns tanking with barriers - try not to have both your barriers on cooldown at the same time. Staggered barriers means your energy won't be as spikey
- Cover is your friend - Use cover excessively to regenerate shields, reload, and restore cooldowns
- She is strongest when her energy is high - The other answer went into this so I didn't mention it. I personally don't really pay attention to the number that much - if you are using her barriers correctly, this should remain at an average of 50%
- Her passive shields and range lend herself to defense - but that doesn't mean she can't be effective on offense. Two tank teams are the strongest comp in almost every situation IMHO
- Finally, Be patient as you learn her - Zarya is a high skill cap hero, one of the highest in the game. Her symbiotic nature revolving around barriers means she is extremely effective with certain heroes and near useless with others. I like to pair with close range and mid range heroes: Reinhardt, Winston, D-Va, Roadhog, Reaper, Genji, Mei, Lucio, Symmetra
(I refer to shields as her passive 200 health that regenerates. Barriers are her activated E and L-Shift)
Afterthoughts - Barrier Usage
A big part of the learning curve for Zarya is how to use her barriers. I've explained how to put yourself in situations where she can use them effectively, but it's a little more nebulous to put into words exactly how to use it. Like you said, it is very punishing when you aren't using barriers right because she relies on them for offense and defense. The biggest part is, of course, practice. I thought I would write a few of my thoughts I had while learning her.
My natural tendency when I started was to use shields proactively. This may be some what of a past game training response - if you played a priest in WoW you would place your bubble on the tank before he rounded the corner or made the pull. The bubble lasted long enough, and if it timed out you would simply refresh the bubble. Lots of support work this way in other games with "preemptive healing" mechanics, but Zarya is not a support - not in our normal sense of the archetype.
It is a much safer bet to use your barrier reactively. Almost like it were some nova weapon for an offense - you wait to fire until you have a few targets in your cross-hairs for maximum "damage". Except it's not damage, it's damage absorption, which translates to your damage (embrace the greed). Too often I would throw a barrier on a tank rounding a corner, worried that he would get out of my line of sight and die, only for... no enemies to be there. That's doubly painful - you can't charge your energy and you lose out on damage absorption. Other times my target simply didn't realize they got shielded and waffled around before charging (you'd think a big Russian woman yelling "YOU'RE COVERED. GO" would be a clear hint).
Instead wait until you see the Reinhardt actually getting bombarded with bullets, THEN hit him with the E. The tanks will survive the initial damage, and the light offense... well they shouldn't be relying on you to save their ass anyways. You'll find much more of your barriers get whittled down that way, which is good - you don't want them to expire. Not to mention the shield is very visible to the enemy - they will just hold fire briefly until it goes off to avoid giving you the energy charge. Harder to do that if they are in the middle of unloading a clip ("Damn the torpedoes").
(Note that there are situations where it's good to use proactively, generally when you have sound information on enemy locations and you and your barrier partner are on the same page)
Afterthoughts - Particle Beam
Finally, a brief note on her particle weapon. Yeah, the right mouse is just straight "better", it does more damage and has that nasty knock up, plus it's easier to aim. However the primary fire definitely has it's place. I mentioned "weaving" and taking advantage of the projectile travel time and cooldown. This is a somewhat advanced concept. The most clear usage is ammo efficiency.
Think of her ammo like a $100 bill. You can break it into four $25 bill, which you're probably going to want to do most of the time, because hey, throwing around fat stacks of $25 bills makes you feel like a G. But some things aren't worth it. Sometimes you need singles, like to tip that guy in the club bathroom who just stands there and gives you a towel. Think of the low health Genji, panicked by your power, abandoning the cause and going full retreat. He's like that guy in the club bathroom. Don't waste a $25 on Genji. Cut him off a few singles and get back to making it rain.