JSteam Toolbox Engineering Units
The toolbox comes with flexibility to support multiple unit sets to suit the user. Examples below cover their use, based on Examples/JSteam_Units.m
.
Viewing All Units
To view all unit sets, and the available units, use the following function:
Pressure Units: bar, barg, psi, psig, kPa, MPa, atm [Set via JSteamMEX('SetUnit','Pressure',unit)]
Temperature Units: C, F, K, R [Set via JSteamMEX('SetUnit','Temperature',unit)]
Mass Flow Units: tonne/hr, kg/hr, kg/s, lbm/hr, lbm/s, ton(UK)/hr, ton(US)/hr [Set via JSteamMEX('SetUnit','MassFlow',unit)]
Mole Flow Units: kmol/hr, kmol/s, mol/hr, mol/s [Set via JSteamMEX('SetUnit','MoleFlow',unit)]
Power Units: kW, MW, W, Btu/hr, MMBtu/hr, kcal/hr, kcal/s, ft.lbf/hr, ft.lbf/s, hp(Mech), hp(Metric), hp(Elec), hp(Blr) [Set via JSteamMEX('SetUnit','Power',unit)]
Energy Units: kJ, J, cal, kcal, cal(th), kcal(th), Btu, MMBtu [Set via JSteamMEX('SetUnit','Energy',unit)]
Volume Units: m3, cm3, in3, ft3, gal(UK), gal(US) [Set via JSteamMEX('SetUnit','Volume',unit)]
Mass Units: kg, g, lbm [Set via JSteamMEX('SetUnit','Mass',unit)]
Mole Units: kmol, mol, lbmol [Set via JSteamMEX('SetUnit','Mole',unit)]
Viscosity Units: uPa.s, mPa.s, Pa.s, uP, mP, cP, P, lb/(ft.hr), lb/(ft.s), lbf.s/ft2, lbf.s/in2 [Set via JSteamMEX('SetUnit','Viscosity',unit)]
Thermal Conductivity Units: mW/(m.K), W/(m.K), W/(cm.K), cal/(s.cm.K), kcal/(hr.m.K), Btu.in/(hr.ft2.F), Btu.in/(s.ft2.F), Btu.ft/(hr.ft2.F) [Set via JSteamMEX('SetUnit','ThermalConductivity',unit)]
Basis Units: mass, mole [Set via JSteamMEX('SetUnit','Basis',unit)]
As viewable above, every engineering unit within JSteam is customizable to a wide range of metric and imperial options. At any point you can check the current unit set via:
ans =
12×1 cell array
{'bar' }
{'C' }
{'tonne/hr'}
{'kmol/hr' }
{'kW' }
{'kJ' }
{'kg' }
{'kmol' }
{'m3' }
{'uPa.s' }
{'mW/(m.K)'}
{'mass' }
Or check a specific unit:
ans =
'bar'
Changing Units
To change units, simply use the SetUnit
functionality:
JSteamMEX('SetUnit','Temperature','K')
%Get Current Units [to check]
>> JSteamMEX('GetCurrentUnits')
ans =
12×1 cell array
{'MPa' }
{'K' }
{'tonne/hr'}
{'kmol/hr' }
{'kW' }
{'kJ' }
{'kg' }
{'kmol' }
{'m3' }
{'uPa.s' }
{'mW/(m.K)'}
{'mass' }
Computations done with the new unit set will expect inputs in MPa and K, as below:
H = JSteamMEX('HPT',0.1,373.15)
H =
2675.76736720583
At any point you can revert to the default unit set:
JSteamMEX('SetDefaultUnits')
%Example thermo call
H = JSteamMEX('HPT',1,100)
H =
2675.76736720583
You may also save the current unit set and return to it later, as below:
% Example computation in different units
JSteamMEX('SetUnit','Pressure','MPa');
H = JSteamMEX('HPT',0.1,100)
% Return to original unit set
JSteamMEX('SetCurrentUnits',myUnits);
Unit Conversion
The toolbox also provides Unit Conversion functionality between any of the available units:
JSteamMEX('ConvUnit',10,'kg/s','kg/hr')
% New Basis requires Molecular Weight
JSteamMEX('ConvUnit',350,'kJ/kg','cal(th)/lbmol',18)
Note if converting between mass vs mole you will need the molecular weight of the fluid/mixture.