I actually didn't realize you were still developing your iphone app. I'll be one of your first customers! And thanks for the props! I'm excited to see what you've done.
I've some appreciation for the difficulty -- I work at a technology shop with a couple of applications, all of which were prototyped with Test Flight and PhoneGap before going native -- but you're right, I am no UI developer and find things like styling and design very challenging and unnatural to me. I hope you know that my testing these calculators on a mobile-friendly interface is simply for my personal/professional growth and curiosity while contributing back to our hobby for any device, and that my offer to collaborate with whatever I can on backend stuff stands! I will be making PhoneGap'd apps at some point in the future but will move forward with my other calcs so as not to compete with yours -- I really hope the best for your app and think you could charge a lot more than 0.99 for such a specialized application.
In regards to the calculation, I think my calc and APCs is right. Let's do it together (and for others doing this same thing manually):
Here's KH2PO4 broken down by atomic mass:
Stuff Friendly name Mass Total in Stuff
K Potassium 39.09831 1
H Hydrogen 1.007947 2
P Phosphorus 30.9737622 1
O Oxygen 15.99943 4
If we sum that up we get 136.0857 g/mol for KH2PO4.
If we sum up the PO4 bit we get 94.9715 g/mol
So, let's look at that data another way:
Stuff Friendly name Mass % in KH2PO4
PO4 Phosphorus 94.9715 0.6978801
K Potassium 39.09831 0.2873065
H The rest 2.015894 0.0148134
And focus on PO4 using your handy formula retitled a bit for folks following along:
mg KH2PO4 = target PPM of PO4 * tank liters / (g/mols of PO4 / g/mols of KH2PO4)
//target ppm is of PO4, targetMol is PO4's atomic weight ratio
mg = targetPPM * liter / targetMol
Target ppm is 5ppm. Each ppm is mg/L
We'll call a 55gallon tank 208.2 Liters.
PO4's atomic weight ratio to KH2PO4 is 0.698 (rounded):1
mg KH2PO4 = 5 * 208.2L / 0.698
1491.4mg of KH2PO4
But when you figure out how much K you're adding with that dose, it's not as if you're adding more KH2PO4. You're figuring out the K in that 1491 mg.
resultingPPM = mg dose * targetMolRatio / L
the mg dose is the 1491.4 we just figured out.
The targetMolRatio this time for K:KH2PO4 is 0.287:1
resultingPPM is how much K we'll end up with.
and our tank's Liters have not changed.
resultingPPM = 1491.4mg * 0.287 / 208.2L
resultingPPM = 2.056 ppm K
Does that help?
If you're curious, my calc ends up holding what you call targetMolRatio by compound in memory (hashes of hashes by compound then element). I think you have this already, but you're welcome to the list. There's plenty of stuff in there that's UK or AS specific that's been contributed by request from other forums, for example, and I suspect will help with distribution of your app once it hits the apple store.