# 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... Aug 3, 2014 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. Aug 4, 2014 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.

On a related note, the ideal gas law can't be applied to stars because IGL assumes the particles are infinitely spread such that gravity between particles is negligible - which is obviously not true for a star!

• My apologies for not responding earlier, I was out of town and the mobile app for SE does nothing but crash ;-) Since the IGL can't be applied to stars, would you be able to recommend another way that I could go about it? I understand that we don't know everything there is to know about star formation, but perhaps there's a way to compare the temperature of the star to some sort of constant at which fusion is started, thus saying "Ok, here's where it starts"? Darn, and I thought I had a good idea (for once)! Jun 4, 2013 at 21:38
• I'm not sure what you're asking. What sort of "constant" are you looking for? (and you might be interested to know that stars are not uniform in temperature - there can be a very wide difference between the corona and the core).
– Zen
Jun 5, 2013 at 1:54
• Good point! I'm not exactly sure what I was shooting for...the goal was to make a sort of simulation for gas clouds forming into stars, but it seems like that is going to be next to impossible to do without another 8 years of physics and chemistry... I thought that perhaps the IGL would have been a great starting point, because at least from that I would have been able to calculate temperature and pressure, and then using the mass of the cloud, calculate how strongly it would affect nearby clouds (pulling on each other), etc. Thanks for the help anyway, though ;-( Jun 5, 2013 at 20:33