# Finding Pv in Pv=nRT for molecular hydrogen

I'm attempting to write a small program that will calculate the values for the Ideal Gas Law, specifically for molecular Hydrogen (H2) in space. Eventually, this will grow to be a sort of "simulator", but right now I seem to be having problems with remembering my college chemistry and physics.

Here is a picture of the form that I created: So in my program (written in C#), I have the following as initial values for those variables:

        P = ?
v = ?
n = 2.0158 (weight in grams of H2)
T = 2.725 (average temp in space)
R = 1.67E-27 (1.67 * 10^-27)


My problem is that, how does one go about trying to solve for P or v? Do you assign an arbitrary number for what you suppose the volume of the gas would be in space, and then calculate P based on that? Or is it the other way around?

Extra, yet entirely unneeded info: This was brought about because my 7 year old daughter asked me how stars were made. I gave her the explanation that anyone who's got even a remote interest in it gives to their kids, but thought it would be pretty cool to make a little program that would give her a visual. Here was my explanation:

"we think that Hydrogen stuck together to make even larger clouds of Hydrogen, which increased the total mass of the gas cloud, increasing the gravitational pull on other atoms/molecules of nearby gas, etc. This eventually got to the point that the gases started to heat up as they were squished together by their own mass, but that increase in temperature created an outward push (pressure), which got into a tug-of-war with gravity acting on the mass of the gas itself. And later, we got a star. That's how most of us non-scientists think it happens, anyway!"

• That's a pretty cool genesis for the question, but I don't think gaseous plasmas inside a star strictly follow the ideal gas law... – fluffy Aug 3 '14 at 22:00
• Yea, I realize that there are things that we do not know, or things that cannot be modeled by something like this, but the goal was just for a small simulation of gasses gathering. – SalarianEngineer Aug 4 '14 at 4:57

You can solve for either $P$ or $V$. Choose one, say $P$, and then divide that into the right hand side $nRT$ to get $V$; i.e. $V=\frac{nRT}{P}$.
More seriously, you need to check your units! You seem to be using Kelvins for $T$, which is right, and $n$ is just a count in moles. But I do not recognize your value of $R$. The SI value for $R$ is $8.3144621(75)$, in units of joules per Kelvin-mole. Joules, in turn, are Pascal-meters$^3$. Personally, I think most people find Pascals too small a unit for pressure. Far more practical would be Torr-liters, and then $R=62.36367(11)$. You can examine lots of different unit combinations for $R$ at the ideal gas constant page on Wiki: Ideal Gas Constant
You need one of p or V to solve for the other. If you have a spherical body, then $V=\frac{4}{3}\pi r^3$ and plug in what you want the radius of your star to be.