parmed.unit.unit module¶
Module simtk.unit
Contains classes Unit and ScaledUnit.
This is part of the OpenMM molecular simulation toolkit originating from Simbios, the NIH National Center for PhysicsBased Simulation of Biological Structures at Stanford, funded under the NIH Roadmap for Medical Research, grant U54 GM072970. See https://simtk.org.
Portions copyright (c) 2012 Stanford University and the Authors. Authors: Christopher M. Bruns Contributors: Peter Eastman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

class
parmed.unit.unit.
ScaledUnit
(factor, master, name, symbol)[source]¶ Bases:
object
ScaledUnit is like a BaseUnit, but it is based on another Unit.
ScaledUnit and BaseUnit are both used in the internals of Unit. They should only be used during the construction of Units.
Methods
Returns a sorted tuple of (BaseDimension, exponent) pairs, that can be used as a dictionary key.
Returns a sorted tuple of (BaseDimension, exponent) pairs, describing the dimension of this unit.
conversion_factor_to
get_conversion_factor_to_base_units
iter_base_units

get_dimension_tuple
()[source]¶ Returns a sorted tuple of (BaseDimension, exponent) pairs, that can be used as a dictionary key.


class
parmed.unit.unit.
Unit
(base_or_scaled_units)[source]¶ Bases:
object
Physical unit such as meter or ampere.
Methods
conversion_factor_to
(other)Returns conversion factor for computing all of the common dimensions between self and other from self base units to other base units.
create_unit
(scale, name, symbol)Convenience method for creating a new simple unit from another simple unit.
There may be ScaleUnit components to this Unit.
get_name
()Returns a unit name (string) for this Unit, composed of its various BaseUnit symbols.
Returns a unit symbol (string) for this Unit, composed of its various BaseUnit symbols.
in_unit_system
(system)Returns a new Unit with the same dimensions as this one, expressed in a particular unit system.
is_compatible
(other)Returns True if two Units share the same dimension.
Returns True if this Unit has no dimensions.
Yields (BaseUnit, exponent) tuples comprising this unit, including those BaseUnits found within ScaledUnits.
Yields (BaseDimension, exponent) tuples comprising this unit.
Yields (BaseUnit, exponent) tuples in this Unit, excluding those within BaseUnits.
sqrt
()Returns square root of a unit.
iter_base_or_scaled_units
iter_scaled_units

conversion_factor_to
(other)[source]¶ Returns conversion factor for computing all of the common dimensions between self and other from self base units to other base units.
The two units need not share all of the same dimensions. In case they do not, the conversion factor applies only to the BaseUnits of self that correspond to different BaseUnits in other.
This method requires strict compatibility between the two units.

create_unit
(scale, name, symbol)[source]¶ Convenience method for creating a new simple unit from another simple unit. Both units must consist of a single BaseUnit.

get_conversion_factor_to_base_units
()[source]¶ There may be ScaleUnit components to this Unit. Returns conversion factor to the set of BaseUnits returned by iter_all_base_units().
Units comprised of only BaseUnits return 1.0

get_name
()[source]¶ Returns a unit name (string) for this Unit, composed of its various BaseUnit symbols. e.g. ‘kilogram meter**2 secon**1’.

get_symbol
()[source]¶ Returns a unit symbol (string) for this Unit, composed of its various BaseUnit symbols. e.g. ‘kg m**2 s**1’

in_unit_system
(system)[source]¶ Returns a new Unit with the same dimensions as this one, expressed in a particular unit system.
Strips off any ScaledUnits in the Unit, leaving only BaseUnits.
 Parameters
system: a dictionary of (BaseDimension, BaseUnit) pairs

is_compatible
(other)[source]¶ Returns True if two Units share the same dimension. Returns False otherwise.

iter_all_base_units
()[source]¶ Yields (BaseUnit, exponent) tuples comprising this unit, including those BaseUnits found within ScaledUnits.
There might be multiple BaseUnits with the same dimension.
