phetsims / gas-properties

"Gas Properties" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
6 stars 6 forks source link

What is the relationship between mass and radius? #55

Closed pixelzoom closed 5 years ago

pixelzoom commented 5 years ago

For the Diffusion screen (but relevant to all screens), the design document says:

The size of the particles is proportional to the mass.

The design doc also says that the heavy particles are 28 AMU, light particles are 4 AMU. But if "proportional" is linear, then the radius of heavy particles would be 7x larger than light particles.

What is the desired relationship between mass and radius?

pixelzoom commented 5 years ago

I'm at the point where this issue is blocking multiple bits of work.

The options are:

(1) Keep radius constant, regardless of mass.

(2) Provide me with r = f(m), where r is radius, and m is mass.

Please come to 5/2/19 design meeting prepared to discuss.

ariel-phet commented 5 years ago

@pixelzoom atomic radius as a function of atomic mass is a little tricky

As you can see for most elements, it cycles in the periodic table

atomic radius

Since we are dealing with gasses, we can probably think more of the noble gasses which follow a more regular pattern. Basically the noble gasses change radius near what would expect for a constant density object, so the mass is related to the radius cubed (very approximately). So mass=(volume)(density), if the densities are nearly the same, the volume goes as radius^3, so mass~r^1/3

For instance:

noble gasses

If we look at something like helium (radius 31 pm) something like Radon is 43 times more massive, cube root of 43 is 4.41, and atomic radius of radon is ~ 4 times bigger (radius 120 pm).

So personally, I think using a cubic relationship would be the most appropriate. Lets start with that.

pixelzoom commented 5 years ago

@ariel-phet Currently we have:

heavy particles: N2, 28 AMU, 0.125nm (125pm) light particles: He, 4 AMU, 0.0875nm (87.5pm)

That doesn't match a cubic relationship, and the radii don't match reality (values were taken from the Java version).

If we use the actual radii for N2 (0.2nm) and He (0.031nm), here's what you'll see on the first 3 screens:

screenshot_1173
pixelzoom commented 5 years ago

@ariel-phet

cube root of 43 is 4.41,

Math.cbrt( 43 ) -> 3.5033980603867243

So personally, I think using a cubic relationship would be the most appropriate. Lets start with that.

FYI, Math.cbrt( n ) (cube root) is not supported on IE. But since we're dealing with positive numbers, we could probably use Math.pow( n, 1/3 ).

ariel-phet commented 5 years ago

@pixelzoom sorry, not sure how I calculated that wrong...but either way approximately a cube root relationship.

I was not suggesting to use the actual diameters...just choose a base diameter that looks good and scale up from there with the cube root scaling

ariel-phet commented 5 years ago

So if I have that right if the range is 4 AMU to 28 AMU I believe the 28 AMU should be ~ 1.9 times bigger

pixelzoom commented 5 years ago

Sorry, let me try to explain this again. The current heavy and light particles are:

heavy particles: N2, 28 AMU, 0.125nm (125pm) light particles: He, 4 AMU, 0.0875nm (87.5pm)

Apparently there was some motivation to make these N2 and He, and the radii were set to "look nice". Consequently, the relationship of these masses and radii is not cubic. So if you want to use a cubic relationship, either the mass or radius of one of these particles needs to be changed.

My recommendation is to use a linear relationship, based on the above values:

var f = new phet.dot.LinearFunction( 4, 28, 0.0875, 0.125 );
for ( let mass = 4; mass <= 32; mass++ ) {
  console.log( `mass=${mass} radius=${f(mass)}` );
}

This results in:

mass=4 radius=0.0875
mass=5 radius=0.08906249999999999
mass=6 radius=0.090625
mass=7 radius=0.09218749999999999
mass=8 radius=0.09375
mass=9 radius=0.0953125
mass=10 radius=0.09687499999999999
mass=11 radius=0.0984375
mass=12 radius=0.09999999999999999
mass=13 radius=0.1015625
mass=14 radius=0.103125
mass=15 radius=0.1046875
mass=16 radius=0.10625
mass=17 radius=0.1078125
mass=18 radius=0.109375
mass=19 radius=0.1109375
mass=20 radius=0.1125
mass=21 radius=0.1140625
mass=22 radius=0.115625
mass=23 radius=0.1171875
mass=24 radius=0.11875
mass=25 radius=0.1203125
mass=26 radius=0.12187500000000001
mass=27 radius=0.1234375
mass=28 radius=0.125
mass=29 radius=0.1265625
mass=30 radius=0.128125
mass=31 radius=0.1296875
mass=32 radius=0.13125
pixelzoom commented 5 years ago

Here's the cubic relationship, and the resulting values for the mass range (4,32) AMU. This results in the heavy particles being 25% larger (0.125nm => 0.167nm).

function f( mass ) {
  return 0.0875 * Math.pow( mass / 4, 1/3 ); 
}
for ( let mass = 4; mass <= 32; mass++ ) {
  console.log( `mass=${mass} radius=${f(mass)}` );
}

Results:

 mass=4 radius=0.0875
 mass=5 radius=0.09425651768889491
 mass=6 radius=0.10016249622341654
 mass=7 radius=0.10544372405766632
 mass=8 radius=0.11024309186580139
 mass=9 radius=0.1146574359966392
 mass=10 radius=0.11875577072602714
 mass=11 radius=0.12258922071617319
 mass=12 radius=0.12619683740189822
 mass=13 radius=0.12960920299282244
 mass=14 radius=0.1328507675195602
 mass=15 radius=0.1359414221354813
 mass=16 radius=0.13889759204721744
 mass=17 radius=0.1417330163058899
 mass=18 radius=0.1444593171391399
 mass=19 radius=0.14708642404745462
 mass=20 radius=0.14962289533421097
 mass=21 radius=0.15207616571378216
 mass=22 radius=0.15445273967051523
 mass=23 radius=0.15675834435694766
 mass=24 radius=0.1589980518728122
 mass=25 radius=0.1611763780655169
 mass=26 radius=0.1632973631107546
 mass=27 radius=0.16536463779870209
 mass=28 radius=0.16738147849258403
 mass=29 radius=0.16935085302746608
 mass=30 radius=0.17127545930113777
 mass=31 radius=0.17315775792351773
 mass=32 radius=0.175
arouinfar commented 5 years ago

Apparently there was some motivation to make these N2 and He, and the radii were set to "look nice".

Right. The masses were chosen as that of N2 and He because these are abundant examples of a heavier/lighter gas. The radii in Java are not at all related to these actual gases, but were chosen because they had a reasonable looking size difference, which was enough to serve the goals of the Java sim. Since the Diffraction screen has a mass control, I think it makes sense to have a somewhat more realistic mass/radius mapping.

Here's the cubic relationship, and the resulting values for the mass range (4,32) AMU. This results in the heavy particles being 25% larger (0.125nm => 0.167nm).

I quite like this approach. I'm not sure that we would want the 4 AMU mass to have a smaller radius, so starting at 0.0875 nm seems reasonable to me. The trade-off is that most of these values are irrational. Not sure if that would pose any particular challenges, but perhaps it would be reasonable to truncate the values after 4 or 5 decimals.

pixelzoom commented 5 years ago

5/2/19 design meeting @arouinfar @ariel-phet @kathy-phet

pixelzoom commented 5 years ago

This is implemented and working nicely. But when the sim is paused, the particles shift back and forth as their radius is changed. I suspect something with the default padding for the elements drawn using CanvasNode. Tracking this in https://github.com/phetsims/gas-properties/issues/66.

pixelzoom commented 5 years ago

@arouinfar @ariel-phet @kathy-phet This is implemented and ready for review. See master or 1.0.0-dev.18.

ariel-phet commented 5 years ago

This is all looking good to me, I like the radius control quite a bit.

arouinfar commented 5 years ago

Agreed, it's looking really nice @pixelzoom! My one gripe would be that the large particles look a bit aliased. image

pixelzoom commented 5 years ago

@arouinfar On what platform? They look great on my MacBook Pro with retina display.

arouinfar commented 5 years ago

@arouinfar On what platform? They look great on my MacBook Pro with retina display.

Latest macOS and Chrome, though the screenshot in https://github.com/phetsims/gas-properties/issues/55#issuecomment-490621654 was taken on my external monitor (Asus ProArt, 2560x1440 resolution, ~110 ppi) with Chrome maximized.

I'm seeing similar aliasing on my 15" retina screen with Chrome maximized. image

pixelzoom commented 5 years ago

In the above commit, I tried scaling up the HTMLCanvasElements (by 2x), then scaling them back down when they are rendered using drawImage. I can't see any different on my devices (all retina).

@arouinfar please have a look at master. Did this improve the anti-aliasing at all?

arouinfar commented 5 years ago

Master is looking much crisper on my laptop and external monitor now. Thanks @pixelzoom!

image

pixelzoom commented 5 years ago

5/9/19 design meeting @arouinfar @ariel-phet @KatieWoe

We have a quorum, so closing.