librasteve / raku-Physics-Unit

Some physical Units (SI, metric and more...)
Artistic License 2.0
1 stars 0 forks source link

dimensions incorrect on ConsumptionRate; Flow measure #23

Closed td002 closed 1 year ago

td002 commented 1 year ago

Hi - thanks for the module. Fooling around with Physics::Measure, I think there's an error in the Physics::Unit dimensions for ConsumptionRate, i.e., 'ConsumptionRate' => (2,0,-1,0,0,0,0,0),
should be 'ConsumptionRate' => (3,0,-1,0,0,0,0,0),

I suspect this error leads to a problem when non-SI units are used (but not with SI-units), for example

[0] > use Physics::Measure :ALL; Nil [1] > my ConsumptionRate $q = ConsumptionRate.new( value => 1.1, units => 'gallons/min' )
1.1gallons/min [2] > my Time $t = Time.new( value => 1.1, units => 'minutes' ) 1.1min [3] > my $v = $q $t Use of Nil in string context in sub GetUnit at (Physics::Unit) line 334 in method in at (Physics::Measure) line 322 in method rebase at (Physics::Measure) line 386 in method multiply at (Physics::Measure) line 246 in sub infix:<> (Physics::Measure) line 656 in block at line 1

Also, generally, 'Flow' is an extremely common 'measure' in science and engineering, same dimensions as ConsumptionRate but a lot of different ways to express depending on the domain. A lot of combinations of (possibly prefixed) ( volume * time^-1 ) are used, but these are the most common:

volume:

time:

librasteve commented 1 year ago

thanks - good catch on the dims!

I have also taken the chance to adjust the name from ConsumptionRate to Flow

This means if you want ConsumptionRate for some reason, you can subset per the README

The other stuff you mention (gallons, day and so on) should ensue automagically

crag 'say :<3 in^3 / day>'
3in^3 / day

^^^ yep that seems to work

btw gallons is locale dependent - should work automatically too (you can use us-gallons / imp-gallons to force!)

I have bumped Physics::Unit to 1.1.26 and Physics::Measure to 1.0.18 accordingly