The Webel MPsy MTools class for psychrometrics in Mathematica is intended for use as "one-shot" readonly objects. Frequently used psychrometric values are pre-calculated in the newPsy[tdb] builder function for rapid access, and are available as populated public fields, which are then available to downstream psychrometrics calculations.
This approach offers a trade-off between performance (not every pre-populated field might be used in every calculation scenario, so some CoolProp calls made during construction might be unnecessary), and convenience.
Some additional derived properties are available via accessor methods (which may cascade):
MPsy.dda[] := 1. / (M`o.vda);
MPsy.hPerVol[] := M`o.hda M`o.dda[];
Some additional derived properties available via methods require additional CoolProp wrapper calls, such as for obtaining the specific heat capacity per dry air:
MPsy.cpDa[] := propHA$Cp[M`o.tdb, M`o.p, M`o.r];
Some additional derived quantities are available via public methods that take arguments for external quantities:
MPsy.mDotDa[vfr_Quantity] := UnitConvert[vfr,$unitVFR] / (M`o.vda);
In the example above, $unitVFR is a convenient String for the units of volumetric flow rate in SI. Internally, MPsy uses SI units, so it knows vda is already an SI Quantity.
The values of the public fields of MPsy may also be accessed via corresponding accessor methods, which share a common API with the MPsyLazy implementation, which does not offer public fields and only populates privately held fields via lazy accessor methods as required, to reduce calls to CoolProp.
For example, the same value as the public field MPsy.hda (specific enthalpy per dry air) may be accessed uniformly via methods MPsy.hda[] or MPsyLazy.hda[].
The MPsyLazy implementation is faster during construction but comes with the slight overhead of If checks during lazy fetching.
MPsy and MPsyLazy implement the methods of the common abstract IPsy "interface". So functions that accept IPsy arguments can be robustly used with objects of either class (design by contract). However, type checking in MTools is expensive!
