You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of using python floats for variables (wavenumbers, energy, etc, ...), we can build a physical variable class. This class would automatically takes care of unit mismatch.
For example, we initialize energy quantity:
from pmutt import var
E = var(-6.77,'eV')
print(E)
-6.77 eV
and the class has orders of various unit type (mass, temperature, length, time...) as well as names
E.unitorders
[1,0,2,-2,0] # in the order of mass, temperature, length, time, quantity of molecules
E.unitnames
['ev','','ev','ev',''] # since eV is a lumped unit it all shows eV, but for nonlumped unit, it would show name of the unit for each unit type.
When we perform operation then these unit orders can be added and subtracted (for multiplication and division, respectively):
R = pmutt.constants.R('J/mol/K')
8.3145 J mol-1 K-1
R.unitnames
['J','K','J',','J','mol']
R.unitorders
[1,-1,2,-2,1]
T = var(32,'F')
print(T)
32 F
print(T.unitnames)
['','F','','','']
EoRT = E/R/T # unit mismatch automatically taken care of under the hood
print(EoRT.unitorders)
[0,0,0,0,0]
In above case, this var class would take care of unit mismatch automatically by comparing unitorders and unitnames between var. For what would get outputted in the class mismatch, we can set a class variable for what would be default unit. What we can additional do is, if we try to construct a statmech class:
Even if wave1 is not in the required unit cm-1, it can automatically also does conversion as well.
The current noninvasive variables should be kept, but this function can be additionally handled as a "high-level" language within pmutt which would help minimize mistakes in the unit conversions.
The text was updated successfully, but these errors were encountered:
Implemented VUnits, which has a generic Quantity class for arithmetic and logic operations. Under the hood, it converts inputted values to SI base quantities to simplify unit management. It also supports a variety of units and their prefixes (complete list here) and a unit parser to support compounded units.
Next steps will involve integrating VUnits into pMuTT.
Instead of using python floats for variables (wavenumbers, energy, etc, ...), we can build a physical variable class. This class would automatically takes care of unit mismatch.
For example, we initialize energy quantity:
and the class has orders of various unit type (mass, temperature, length, time...) as well as names
When we perform operation then these unit orders can be added and subtracted (for multiplication and division, respectively):
In above case, this var class would take care of unit mismatch automatically by comparing unitorders and unitnames between var. For what would get outputted in the class mismatch, we can set a class variable for what would be default unit. What we can additional do is, if we try to construct a statmech class:
Even if wave1 is not in the required unit cm-1, it can automatically also does conversion as well.
The current noninvasive variables should be kept, but this function can be additionally handled as a "high-level" language within pmutt which would help minimize mistakes in the unit conversions.
The text was updated successfully, but these errors were encountered: