Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to model measures that depend on the underlying substance

Tags:

oop

smalltalk

I'm using the Aconcagua measurement library in Pharo. I've had a lot of success using it to model things like days and kilometers, but have encountered an interesting problem where converting between units requires information on the underlying substance being measured. The formula for expressing the amount of a substance in air in parts per million, given the amount in milligrams per cubic meter is:

PPM = mg/m^3 x 24.45 / molecularWeight; where mw is the molecular weight of the material.

I'm envisioning usage like: tlvCO := carbonMonoxide tlv. "returns the Threshold limit Value as 29 mg/m3" ... tlvCO convertTo: PPM "where PPM is an Aconcagua unit"

The problem is that, while the examples I've seen of measurements in Aconcagua are contain in themselves all the info you need for conversion, in this case, you have to know the molecular weight of the underlying substance being measured. Thus mg/m3 -> ppm is not inherently meaningful. A properly formed question would be mg/m3 of ammonia -> ppm.

My instinct is to either:

  1. create a new class like MaterialQuantity which has a material and a measure, or
  2. create a special unit subclass that has a material

But I'm not 100% sold and would like some input...

like image 802
Sean DeNigris Avatar asked Jan 24 '26 21:01

Sean DeNigris


1 Answers

I don't think that molecular weight is part of the unit, but part of a calculation, like the 24.45 (which is not clear, but it seems that is an average you consider for air molecular mass).

I am not sure that ppm is a unit that you can convert to a density unit, because they belong in different domains.

like image 188
Carlos E. Ferro Avatar answered Jan 27 '26 02:01

Carlos E. Ferro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!