How to model measures dependent on the underlying substance

I am using the Aconcagua measurement library in Pharo . I have had great success using it to simulate things like days and kilometers, but I ran into an interesting problem where converting between units requires information about the underlying material being measured. Formula for expressing the amount of a substance in air in parts per million, taking into account the amount in milligrams per cubic meter:

PPM = mg / m ^ 3 x 24.45 / molecularWeight; where mw

is the molecular weight of the material.

I am assuming use 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, although the examples I've seen in measurements at Aconcagua contain all the information needed to convert, in this case you should know the molecular weight of the substance being measured. Thus, it mg/m3 -> ppm

doesn't make significant sense. There will be a well-formed question mg/m3 of ammonia -> ppm

.

My instinct is this:

  • create a new class, for example MaterialQuantity

    , which has material and measure, or
  • create a special class subclass that has stuff

But I am not 100% for sale and would like to contribute ...

+3


source to share


2 answers


I don't think the molecular weight is part of the unit, but is part of the calculation, for example 24.45 (which is not clear, but seems to be the average for the molecular weight of air).



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

+1


source


As I understand it, you need to reconstruct the tlv as a compound unit or formula that you can query the item. Then you could just do something like [: tlv | tlv * (item 24.45 / tlv)]



0


source







All Articles