Both Mathcad and Prode Physical Properties (PPP) use SI system as their default unit system. The PPP program doesn't have a way to change entire unit systems. You can only change the default unit for a single property at a time. Mathcad does have the capability of changing the default unit system.
I prefer to keep the SI system as the defaults for both programs. If I were to change some worksheets to another system, I'm sure I would make errors later. I can still specify units for each input and output variable as desired.
Units in the stream report
For my simulator stream report function, I wanted the capability to report results in either SI or US units. The SI report requires no change in units since I use that system as the default. For the US units report, I had two options. The first option would be to get the SI value for a variable, attach the SI unit to the result, and then divide by the desired US unit. The other option, which I chose, is to select the US unit for PPP results for every variable in the stream report. At the end of the report program, the units are all switched back to the SI units. This actually was quite easy to do.
The physical property codes in PPP
Each property in PPP has a numerical code as shown in the figure below. The property codes run from 15 to 54. This image was taken from the PPP manual.
Units codes for each property
Each property has a set of units, and each unit has a numerical code. For example, pressure (abs) is property 15. The units for that property are shown below:
If I want the US unit, I would select the 11th unit. [Note: for some reason the PPP units for absolute pressure also includes relative pressures. The relative pressure property #16 correctly lists only relative pressure units.]
The P_units vector starts with 0 for the first element, but PPP starts range variables with 1. Therefore, the first element in P_units is a place holder so that the element indexes agree with the PPP values.
Each property has a different number of possible units, so the US unit is not always in the same position. Thus, I manually created a lookup matrix, USsel which has the property code numbers in the first column. The second column has the number of the US unit for the property in the first column. A portion of the USsel matrix is shown below:
The USsel matrix can be used to change an individual property to the US value given the property code as input to a vlookup Mathcad function. Instead, I will use the matrix to change the entire unit system just for stream reports.
Changing the unit system in PPP
With the USsel matrix, the setUS routine below changes all of the properties to the US sytem for the PPP program. The second routine, setSI is used to set the system back to the SI values. All of the SI units are in the first position for each property.
The "dum" argument is a dummy string variable in the setSI routine.
Next: the stream report