"platforms/cuda-old/src/kernels/kCalculateCDLJForces.h" did not exist on "78c26f712ceb6e5e81a98d348a6d4472caf277a5"
Commit 65b9d0b6 authored by Peter Eastman's avatar Peter Eastman
Browse files

Python API wrappers are now part of OpenMM

parent abb19052
"""
Physical quantities with units for dimensional analysis and automatic unit conversion.
"""
__docformat__ = "epytext en"
__author__ = "Christopher M. Bruns"
__copyright__ = "Copyright 2010, Stanford University and Christopher M. Bruns"
__credits__ = []
__license__ = "MIT"
__maintainer__ = "Christopher M. Bruns"
__email__ = "cmbruns@stanford.edu"
from unit import Unit, is_unit
from quantity import Quantity, is_quantity
from unit_math import *
from unit_definitions import *
from constants import *
#!/bin/env python
"""
Module simtk.unit.basedimension
BaseDimension class for use by units and quantities.
BaseDimensions are things like "length" and "mass".
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.6"
class BaseDimension(object):
'''
A physical dimension such as length, mass, or temperature.
It is unlikely the user will need to create new ones.
'''
# Keep deterministic order of dimensions
_index_by_name = {
'mass': 1,
'length': 2,
'time': 3,
'temperature': 4,
'amount': 5,
'charge': 6,
'luminous intensity': 7,
'angle': 8,
}
_next_unused_index = 9
def __init__(self, name):
"""Create a new BaseDimension.
Each new BaseDimension is assumed to be independent of all other BaseDimensions.
Use the existing BaseDimensions in simtk.dimension instead of creating
new ones.
"""
self.name = name
if not self.name in BaseDimension._index_by_name.keys():
BaseDimension._index_by_name[name] = BaseDimension._next_unused_index
BaseDimension._next_unused_index += 1
def __cmp__(self, other):
"""
The implicit order of BaseDimensions is the order in which they were created.
This method is used for using BaseDimensions as hash keys, and also affects
the order in which units appear in multi-dimensional Quantities.
Returns 0 if self == other, -1 if self < other, and 1 if self > other.
"""
return cmp(BaseDimension._index_by_name[self.name], BaseDimension._index_by_name[other.name])
def __hash__(self):
"""
Needed for using BaseDimensions as hash keys.
"""
return hash(BaseDimension._index_by_name[self.name])
def __repr__(self):
return 'BaseDimension("%s")' % self.name
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit.baseunit
Contains BaseUnit class, which is a component of the
Unit class.
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.6"
class BaseUnit(object):
'''
Physical unit expressed in exactly one BaseDimension.
For example, meter_base_unit could be a BaseUnit for the length dimension.
The BaseUnit class is used internally in the more general Unit class.
'''
def __init__(self, base_dim, name, symbol):
"""Creates a new BaseUnit.
Parameters
- self: The newly created BaseUnit.
- base_dim: (BaseDimension) The dimension of the new unit, e.g. 'mass'
- name: (string) Name of the unit, e.g. "kilogram"
- symbol: (string) Symbol for the unit, e.g. 'kg'. This symobol will
Quantity string descriptions.
"""
self.dimension = base_dim
self.name = name
self.symbol = symbol
self._conversion_factor_to = {}
self._conversion_factor_to[self] = 1.0
self._conversion_factor_to_by_name = {}
self._conversion_factor_to_by_name[self.name] = 1.0
def __cmp__(self, other):
"""
Comparison function that sorts BaseUnits by BaseDimension
"""
# First sort on dimension
c = cmp(self.dimension, other.dimension)
if c != 0: return c
# Second on conversion factor
return cmp(self.conversion_factor_to(other), 1.0)
def iter_base_dimensions(self):
"""
Returns a dictionary of BaseDimension:exponent pairs, describing the dimension of this unit.
"""
yield (self.dimension, 1)
def iter_base_units(self):
yield (self, 1)
def get_dimension_tuple(self):
"""
Returns a sorted tuple of (BaseDimension, exponent) pairs, that can be used as a dictionary key.
"""
l = list(self.iter_base_dimensions())
l.sort()
return tuple(l)
def __str__(self):
"""Returns a string with the name of this BaseUnit
"""
return self.name
def __repr__(self):
return 'BaseUnit(base_dim=%s, name="%s", symbol="%s")' % (self.dimension, self.name, self.symbol)
def define_conversion_factor_to(self, other, factor):
"""
Defines a conversion factor between two BaseUnits.
self * factor = other
Parameters:
- self: (BaseUnit) 'From' unit in conversion.
- other: (BaseUnit) 'To' unit in conversion.
- factor: (float) Conversion factor.
After calling this method, both self and other will have stored
conversion factors for one another, plus all other BaseUnits which
self and other have previously defined.
Both self and other must have the same dimension, otherwise a TypeError
will be raised.
Returns None.
"""
if self.dimension != other.dimension:
raise TypeError('Cannot define conversion for BaseUnits with different dimensions.')
assert(factor != 0)
assert(not self is other)
# import all transitive conversions
self._conversion_factor_to[other] = factor
self._conversion_factor_to_by_name[other.name] = factor
for (unit, cfac) in other._conversion_factor_to.items():
if unit is self: continue
if self._conversion_factor_to.has_key(unit): continue
self._conversion_factor_to[unit] = factor * cfac
unit._conversion_factor_to[self] = pow(factor * cfac, -1)
self._conversion_factor_to_by_name[unit.name] = factor * cfac
unit._conversion_factor_to_by_name[self.name] = pow(factor * cfac, -1)
# and for the other guy
invFac = pow(factor, -1.0)
other._conversion_factor_to[self] = invFac
other._conversion_factor_to_by_name[self.name] = invFac
for (unit, cfac) in self._conversion_factor_to.items():
if unit is other: continue
if other._conversion_factor_to.has_key(unit): continue
other._conversion_factor_to[unit] = invFac * cfac
unit._conversion_factor_to[other] = pow(invFac * cfac, -1)
other._conversion_factor_to_by_name[unit.name] = invFac * cfac
unit._conversion_factor_to_by_name[other.name] = pow(invFac * cfac, -1)
def conversion_factor_to(self, other):
"""Returns a conversion factor from this BaseUnit to another BaseUnit.
It does not matter which existing BaseUnit you define the conversion factor to.
Conversions for all other known BaseUnits will be computed at the same time.
Raises TypeError if dimension does not match.
Raises LookupError if no conversion has been defined. (see define_conversion_factor_to).
"""
if self is other: return 1.0
if self.dimension != other.dimension:
raise TypeError('Cannot get conversion for BaseUnits with different dimensions.')
if not other.name in self._conversion_factor_to_by_name:
raise LookupError('No conversion defined from BaseUnit "%s" to "%s".' % (self, other))
return self._conversion_factor_to_by_name[other.name]
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit.constants
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.5"
from unit_definitions import *
#################
### CONSTANTS ###
#################
# codata 2006
AVOGADRO_CONSTANT_NA = 6.02214179e23 / mole
BOLTZMANN_CONSTANT_kB = 1.3806504e-23 * joule / kelvin
MOLAR_GAS_CONSTANT_R = AVOGADRO_CONSTANT_NA * BOLTZMANN_CONSTANT_kB
# From simtkcommon
SPEED_OF_LIGHT_C = 2.99792458e8 * meter / second
GRAVITATIONAL_CONSTANT_G = 6.6742e-11 * newton * meter**2 / kilogram**2
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit.doctests
Lots of in-place doctests would no longer work after I rearranged
so that specific unit definitions are defined late. So those tests
are here.
Examples
>>> furlong = BaseUnit(length_dimension, "furlong", "fur")
Examples
>>> furlong_base_unit = BaseUnit(length_dimension, "furlong", "fur")
>>> furlong_base_unit.define_conversion_factor_to(meter_base_unit, 201.16800)
>>> furlong_base_unit.conversion_factor_to(angstrom_base_unit)
2011680000000.0
Examples
>>> furlong_base_unit = BaseUnit(length_dimension, "furlong", "fur")
>>> furlong_base_unit.define_conversion_factor_to(meter_base_unit, 201.16800)
Examples
Some of these example test methods from Unit and Quantity
from unit.is_unit
>>> is_unit(meter)
True
>>> is_unit(5*meter)
False
>>> c = 1.0*calories
>>> c
Quantity(value=1.0, unit=calorie)
>>> print calorie.conversion_factor_to(joule)
4.184
>>> print joule.conversion_factor_to(calorie)
0.239005736138
>>> c.in_units_of(joules)
Quantity(value=4.1840000000000002, unit=joule)
>>> j = 1.0*joules
>>> j
Quantity(value=1.0, unit=joule)
>>> j.in_units_of(calories)
Quantity(value=0.23900573613766729, unit=calorie)
>>> j/joules
1.0
>>> print j/calories
0.239005736138
>>> print c/joules
4.184
>>> c/calories
1.0
>>> c**2
Quantity(value=1.0, unit=calorie**2)
>>> (c**2).in_units_of(joule*joule)
Quantity(value=17.505856000000001, unit=joule**2)
>>> ScaledUnit(1000.0, kelvin, "kilokelvin", "kK")
ScaledUnit(factor=1000.0, master=kelvin, name='kilokelvin', symbol='kK')
>>> str(ScaledUnit(1000.0, kelvin, "kilokelvin", "kK"))
'kilokelvin'
Examples
>>> meters > centimeters
True
>>> angstroms > centimeters
False
Examples
>>> print meter / second
meter/second
>>> print meter / meter
dimensionless
Heterogeneous units are not reduced unless they are in a quantity.
>>> print meter / centimeter
meter/centimeter
Examples
>>> meters_per_second = Unit({meter_base_unit: 1.0, second_base_unit: -1.0})
>>> print meters_per_second
meter/second
>>> us = UnitSystem([ScaledUnit(1.0, coulomb/second, "ampere", "A"), second_base_unit])
>>> print us.express_unit(second)
second
>>> print us.express_unit(coulomb/second)
ampere
>>> print us.express_unit(coulomb)
second*ampere
>>> print us.express_unit(meter/second)
meter/second
>>> us = UnitSystem([ScaledUnit(1.0, coulomb/second, "ampere", "A"), second_base_unit])
>>> print us
UnitSystem([ampere, second])
Examples
>>> meter.is_dimensionless()
False
>>> (meter/meter).is_dimensionless()
True
>>> print (meter*meter).sqrt()
meter
>>> meter.sqrt()
Traceback (most recent call last):
...
ArithmeticError: Exponents in Unit.sqrt() must be even.
>>> (meter*meter*meter).sqrt()
Traceback (most recent call last):
...
ArithmeticError: Exponents in Unit.sqrt() must be even.
>>> print (meter*meter/second/second).sqrt()
meter/second
Mixture of BaseUnits and ScaledUnits should cause no trouble:
>>> print sqrt(kilogram*joule)
kilogram*meter/second
>>> print sqrt(kilogram*calorie)
kilogram*meter/second
Examples
>>> newton.get_name()
'newton'
>>> meter.get_name()
'meter'
Examples
>>> newton.get_symbol()
'N'
>>> meter.get_symbol()
'm'
Examples
>>> print angstrom.in_unit_system(si_unit_system)
meter
>>> print angstrom.in_unit_system(cgs_unit_system)
centimeter
>>> print angstrom.in_unit_system(md_unit_system)
nanometer
>>> u = meter/second**2
>>> print u
meter/(second**2)
>>> print u.in_unit_system(si_unit_system)
meter/(second**2)
>>> print u.in_unit_system(cgs_unit_system)
centimeter/(second**2)
>>> print u.in_unit_system(md_unit_system)
nanometer/(picosecond**2)
Examples
>>> meter.is_compatible(centimeter)
True
>>> meter.is_compatible(meter)
True
>>> meter.is_compatible(kelvin)
False
>>> meter.is_compatible(meter/second)
False
>>> joule.is_compatible(calorie)
True
Examples
>>> meter.conversion_factor_to(centimeter)
100.0
>>> print (md_kilocalorie/mole/angstrom).conversion_factor_to(md_kilojoule/mole/nanometer)
41.84
Examples
>>> print meter
meter
>>> print meter * second * second * kilogram
kilogram*meter*second**2
>>> print meter / second / second / kilogram
meter/(kilogram*second**2)
Examples
>>> print meter**3
meter**3
>>> print meter**3
meter**3
>>> meter.get_conversion_factor_to_base_units()
1.0
Simple ScaledUnit in calorie
>>> print calorie.get_conversion_factor_to_base_units()
4.184
Compound ScaledUnit in md_kilocalorie
>>> print md_kilocalorie.get_conversion_factor_to_base_units()
4.184
calorie in a more complex unit
>>> print (md_kilocalorie/mole/angstrom).get_conversion_factor_to_base_units()
4.184
Examples
Create simple Quantities with either the multiply operator or the Quantity constructor.
>>> print 5 * centimeters
5 cm
>>> print Quantity(value=5, unit=centimeter)
5 cm
>>> print Quantity(5, centimeter)
5 cm
Extract the underlying value using either division or the value_in_unit() method.
>>> i = 5 * centimeters
>>> print i / millimeters
50.0
>>> print i.value_in_unit(millimeters)
50.0
Collections of numbers can also be used as values.
>>> s = [1,2,3] * centimeters
>>> print s
[1, 2, 3] cm
>>> print s / millimeters
[10.0, 20.0, 30.0]
>>> s2 = [[1,2,3],[4,5,6]] * centimeters
>>> print s2
[[1, 2, 3], [4, 5, 6]] cm
>>> print s2 / millimeters
[[10.0, 20.0, 30.0], [40.0, 50.0, 60.0]]
>>> s3 = [(1,2,3),(4,5,6)] * centimeters
>>> print s3
[(1, 2, 3), (4, 5, 6)] cm
>>> print s3 / millimeters
[[10.0, 20.0, 30.0], [40.0, 50.0, 60.0]]
>>> s4 = ((1,2,3),(4,5,6)) * centimeters
>>> print s4
((1, 2, 3), (4, 5, 6)) cm
>>> print s4 / millimeters
[[10.0, 20.0, 30.0], [40.0, 50.0, 60.0]]
>>> t = (1,2,3) * centimeters
>>> print t
(1, 2, 3) cm
>>> print t / millimeters
[10.0, 20.0, 30.0]
Numpy examples are commented out because not all systems have numpy installed
# >>> import numpy
# >>>
# >>> a = Quantity(numpy.array([1,2,3]), centimeters)
# >>> print a
# [1 2 3] cm
# >>> print a / millimeters
# [ 10. 20. 30.]
# >>>
# >>> a2 = Quantity(numpy.array([[1,2,3],[4,5,6]]), centimeters)
# >>> print a2
# [[1 2 3]
# [4 5 6]] cm
# >>> print a2 / millimeters
# [[ 10. 20. 30.]
# [ 40. 50. 60.]]
Addition, subtraction, multiplication, division, and powers of Quantities
exhibit correct dimensional analysis and unit conversion.
>>> x = 1.3 * meters
>>> y = 75.2 * centimeters
>>> print x + y
2.052 m
>>> print x - y
0.548 m
>>> print x/y
1.72872340426
>>> print x*y
0.9776 m**2
The following examples are derived from the C++ Boost.Units examples at
http://www.boost.org/doc/libs/1_37_0/doc/html/boost_units/Examples.html
>>>
>>> l = 2.0 * meters
>>>
>>> print l + 2.0 * nanometers
2.000000002 m
>>> print 2.0 * nanometers + l
2000000002.0 nm
>>>
>>> print l
2.0 m
>>> print l+l
4.0 m
>>> print l-l
0.0 m
>>> print l*l
4.0 m**2
>>> print l/l
1.0
>>> print l * meter
2.0 m**2
>>> print kilograms * (l/seconds) * (l/seconds)
4.0 kg m**2/(s**2)
>>> print kilograms * (l/seconds)**2
4.0 kg m**2/(s**2)
>>> print l ** 3
8.0 m**3
>>> print l ** (3.0/2.0)
2.82842712475 m**1.5
>>> print l ** 0.5
1.41421356237 m**0.5
>>> print l ** (2.0/3.0)
1.58740105197 m**0.666667
>>> # complex example
>>> l = (3.0 + 4.0j) * meters
>>> print l
(3+4j) m
>>> print l+l
(6+8j) m
>>> print l-l
0j m
>>> print l*l
(-7+24j) m**2
>>> # Numerical error yields tiny imaginary component of l/l on linux CentOS5
>>> err = abs(l/l - 1)
>>> assert err < 1e-8
>>> print l * meter
(3+4j) m**2
>>> print kilograms * (l/seconds) * (l/seconds)
(-7+24j) kg m**2/(s**2)
>>> print kilograms * (l/seconds)**2
(-7+24j) kg m**2/(s**2)
>>> print l ** 3
(-117+44j) m**3
>>> print l ** (3.0/2.0)
(2+11j) m**1.5
>>> print l ** 0.5
(2+1j) m**0.5
>>> print l ** (2.0/3.0)
(2.38285471252+1.69466313833j) m**0.666667
>>> # kitchen sink example
... s1 = 2.0
>>> x1 = 2
>>> x2 = 4.0/3.0
>>> u1 = kilogram * meter / second**2
>>> u2 = u1 * meter
>>> q1 = 1.0*u1
>>> q2 = 2.0*u2
>>> print s1
2.0
>>> print x1
2
>>> print x2
1.33333333333
>>> print u1
kilogram*meter/(second**2)
>>> print u2
kilogram*meter**2/(second**2)
>>> print q1
1.0 kg m/(s**2)
>>> print q2
2.0 kg m**2/(s**2)
>>> print u1*s1
2.0 kg m/(s**2)
>>> print s1*u1
2.0 kg m/(s**2)
>>> print u1/s1
0.5 kg m/(s**2)
>>> print s1/u1
2.0 s**2/(kg m)
>>> print u1*u1
kilogram**2*meter**2/(second**4)
>>> print u1/u1
dimensionless
>>> print u1*u2
kilogram**2*meter**3/(second**4)
>>> print u1/u2
/meter
>>> print u1**x1
kilogram**2*meter**2/(second**4)
>>> print u1**(1.0/x1)
kilogram**0.5*meter**0.5/second
>>> print u1**x2
kilogram**1.33333*meter**1.33333/(second**2.66667)
>>> print u1**(1.0/x2)
kilogram**0.75*meter**0.75/(second**1.5)
>>> l1 = 1.0*meters
>>> l2 = 2.0*meters
>>> print l1 == l2
False
>>> print l1 != l2
True
>>> print l1 <= l2
True
>>> print l1 < l2
True
>>> print l1 >= l2
False
>>> print l1 > l2
False
>>>
>>> def work(f, dx):
... return f * dx
...
>>> F = 1.0 * kilogram * meter / second**2
>>> dx = 1.0 * meter
>>> E = work(F, dx)
>>>
>>> print "F = ", F
F = 1.0 kg m/(s**2)
>>> print "dx = ", dx
dx = 1.0 m
>>>
>>> def idealGasLaw(P, V, T):
... R = MOLAR_GAS_CONSTANT_R
... print "P * V = ", P * V
... print "R * T = ", R * T
... return (P * V / (R * T)).in_units_of(mole)
...
>>> T = (273.0 + 37.0) * kelvin
>>> P = 1.01325e5 * pascals
>>> r = 0.5e-6 * meters
>>> V = 4.0/3.0 * 3.14159 * r**3
>>> n = idealGasLaw(P, V, T)
P * V = 5.3053601125e-14 m**3 Pa
R * T = 2577.48646608 J/mol
>>> R = MOLAR_GAS_CONSTANT_R
>>>
>>> print "r = ", r
r = 5e-07 m
>>> print "P = ", P
P = 101325.0 Pa
>>> print "V = ", V
V = 5.23598333333e-19 m**3
>>> print "T = ", T
T = 310.0 K
>>> print "n = ", n
n = 2.05834644811e-17 mol
>>> print "R = ", R
R = 8.31447247122 J/(K mol)
>>> print "E = ", E
E = 1.0 kg m**2/(s**2)
>>> print "is_quantity(V) = ", is_quantity(V)
is_quantity(V) = True
>>> print (1.0*radians) / degrees
57.2957795131
>>> print (1.0*radians).in_units_of(degrees)
57.2957795131 deg
>>> print (1.0*angstroms).in_units_of(nanometers)
0.1 nm
>>>
>>> print (90*degrees)/radians
1.57079632679
>>> print sin(90*degrees)
1.0
>>> x = 90 * degrees
>>> x += 0.3 * radians
>>> print x
107.188733854 deg
>>> print 1 * nanometers > 1 * angstroms
True
>>> print 1 * nanometers > 1 * degrees
Traceback (most recent call last):
...
TypeError: Unit "degree" is not compatible with Unit "nanometer".
>>>
>>> x = 1.5 * nanometers
>>> print x / meters
1.5e-09
>>> x = 1.5 * angstroms
>>> print x / meters
1.5e-10
>>> print x / nanometers
0.15
Examples
>>> print is_quantity(meters)
False
>>> print is_quantity(2.3*meters)
True
>>> print is_quantity(2.3)
False
Examples
>>> x = 100.0 * millimeter
>>> print x.value_in_unit_system(si_unit_system)
0.1
>>> print x.value_in_unit_system(cgs_unit_system)
10.0
>>> print x.value_in_unit_system(md_unit_system)
100000000.0
>>>
>>> y = 20 * millimeters / millisecond**2
>>> print y.value_in_unit_system(si_unit_system)
20000.0
>>> print y.value_in_unit_system(cgs_unit_system)
2000000.0
>>> print y.value_in_unit_system(md_unit_system)
2e-11
>>> eps = Quantity(1.0, md_kilocalorie/mole)
>>> epsQ = eps.value_in_unit_system(md_unit_system)
>>> print epsQ
4.184
Dimensionless quantities return their unmodified values.
>>> Quantity(5, dimensionless).value_in_unit_system(md_unit_system)
5
Examples
>>> x = 2.3*meters
>>> print x.value_in_unit(centimeters)
230.0
Examples
>>> print bool(2.3*meters)
True
>>> print bool(0*meters)
False
Examples
>>> print -(2.3*meters)
-2.3 m
>>> print -(-2.3*meters)
2.3 m
Examples
>>> print +(2.3*meters)
2.3 m
Examples
>>> print abs(-2.3*meters)
2.3 m
>>> (9.0*meter*meter).sqrt()
Quantity(value=3.0, unit=meter)
>>> (9.0*meter).sqrt()
Traceback (most recent call last):
...
ArithmeticError: Exponents in Unit.sqrt() must be even.
>>> (9.0*meter*meter*meter).sqrt()
Traceback (most recent call last):
...
ArithmeticError: Exponents in Unit.sqrt() must be even.
>>> (9.0*meter*meter/second/second).sqrt()
Quantity(value=3.0, unit=meter/second)
Mixture of BaseUnits and ScaledUnits should cause no trouble:
>>> sqrt(1.0 * kilogram * joule)
Quantity(value=1.0, unit=kilogram*meter/second)
>>> sqrt(1.0 * kilogram * calorie)
Quantity(value=2.0454828280872954, unit=kilogram*meter/second)
Examples
>>> print (2.3*meters)**2
5.29 m**2
Examples
>>> x = 4.2 * centimeters
>>> print 8.4 / x
2.0 /cm
Examples
>>> x = 4.3 * meters
>>> print x/centimeters
430.0
>>> print x/seconds
4.3 m/s
>>> x = [1,2,3]*centimeter
>>> x/millimeter
[10.0, 20.0, 30.0]
Examples
>>> x = 1.2*meters
>>> print 5*x
6.0 m
Examples
>>> x = 1.2*meters
>>> y = 72*centimeters
>>> print x*y
0.864 m**2
>>> x = [1,2,3]*centimeter
>>> x
Quantity(value=[1, 2, 3], unit=centimeter)
>>> x * meter
Quantity(value=[100.0, 200.0, 300.0], unit=centimeter**2)
>>> u = nanometer**2/angstrom**2
>>> print u
nanometer**2/(angstrom**2)
>>> q = Quantity(2.0, u)
>>> q
Quantity(value=2.0, unit=nanometer**2/(angstrom**2))
>>> "%.1f" % q.reduce_unit()
'200.0'
Examples
>>> 1.2*meters < 72*centimeters
False
>>> meter != None
True
>>> meter == None
False
Examples
>>> print 1.2 * meters - 72 * centimeters
0.48 m
Examples
>>> print 1.2 * meters + 72 * centimeters
1.92 m
Examples
>>> print repr(1.2*meter)
Quantity(value=1.2, unit=meter)
Examples
>>> print 5.0 * nanometers
5.0 nm
Examples
>>> Quantity(5.0, meters)
Quantity(value=5.0, unit=meter)
>>> Quantity([1*angstrom,2*nanometer,3*angstrom])
Quantity(value=[1, 20.0, 3], unit=angstrom)
>>> Quantity((1,2,3))
Quantity(value=(1, 2, 3), unit=dimensionless)
>>> Quantity([1*angstrom,2*nanometer,3*angstrom])
Quantity(value=[1, 20.0, 3], unit=angstrom)
>>> Quantity([1*angstrom,2*nanometer,3*second])
Traceback (most recent call last):
...
TypeError: Unit "second" is not compatible with Unit "angstrom".
>>> Quantity(5)
Quantity(value=5, unit=dimensionless)
Passing a unit to the constructor yields a Quantity with an empty list value.
>>> Quantity(angstrom)
Quantity(value=[], unit=angstrom)
>>> Quantity(5*angstrom)
Quantity(value=5, unit=angstrom)
>>> Quantity(([1*angstrom,2*nanometer,3*angstrom], [1*angstrom,4*nanometer,3*angstrom]))
Quantity(value=([1, 20.0, 3], [1, 40.0, 3]), unit=angstrom)
>>> Quantity([])
Quantity(value=[], unit=dimensionless)
A simple scalar Quantity can be used as the unit argument.
>>> Quantity(value=5.0, unit=100.0*meters)
Quantity(value=500.0, unit=meter)
Examples
>>> x = 2.3*meters
>>> y = x.in_units_of(centimeters)
>>> print y
230.0 cm
>>> x = 2.3*meters
>>> print x.in_units_of(centimeters)
230.0 cm
>>> print x.in_units_of(seconds)
Traceback (most recent call last):
...
TypeError: Unit "meter" is not compatible with Unit "second".
Examples
>>> x = 100.0 * millimeter
>>> print x
100.0 mm
>>> print x.in_unit_system(si_unit_system)
0.1 m
>>> print x.in_unit_system(cgs_unit_system)
10.0 cm
>>> print x.in_unit_system(md_unit_system)
100000000.0 nm
>>> y = 20 * millimeters / millisecond**2
>>> print y
20 mm/(ms**2)
>>> print y.in_unit_system(si_unit_system)
20000.0 m/(s**2)
>>> print y.in_unit_system(cgs_unit_system)
2000000.0 cm/(s**2)
>>> print y.in_unit_system(md_unit_system)
2e-11 nm/(ps**2)
Sometimes mixed internal units have caused trouble:
>>> q = 1.0 * md_kilocalorie/mole/angstrom
>>> print q.in_units_of(md_kilojoule/mole/nanometer)
41.84 kJ/(nm mol)
Examples
>>> class Foo:
... def bar(self):
... print "bar"
...
>>> x = Foo()
>>> x.bar()
bar
>>> y = x * nanometers
>>> y.bar()
bar
Examples
>>> print meters * centimeters
centimeter*meter
>>> print meters * meters
meter**2
>>> print meter * meter
meter**2
Examples
>>> print meter / 2
0.5 m
Examples
>>> define_prefixed_units(kelvin_base_unit, sys.modules["__main__"])
>>> from __main__ import millikelvin
>>> print 5.0 * millikelvin
5.0 mK
Creating a new BaseUnit:
>>> ms = milli * second_base_unit
>>> ms
BaseUnit(base_dim=BaseDimension("time"), name="millisecond", symbol="ms")
>>> ms.conversion_factor_to(second_base_unit)
0.001
Creating a new ScaledUnit:
>>> mC = milli * ScaledUnit(4.184, joule, "calorie", "cal")
>>> mC
ScaledUnit(factor=0.0041840000000000002, master=joule, name='millicalorie', symbol='mcal')
Creating a new Unit:
>>> ms = milli * second
>>> ms
Unit({BaseUnit(base_dim=BaseDimension("time"), name="millisecond", symbol="ms"): 1.0})
Don't try a Quantity though:
>>> ms = milli * (1.0 * second)
Traceback (most recent call last):
...
TypeError: Unit prefix "milli" can only be applied to a Unit, BaseUnit, or ScaledUnit.
Comparison of dimensionless quantities issue (fixed in svn 513)
>>> x = Quantity(1.0, dimensionless)
>>> y = Quantity(1.0, dimensionless)
>>> assert not x is y
>>> assert x == y
Formatting of Quantities
>>> x = 5.439999999 * picosecond
>>> x
Quantity(value=5.4399999990000003, unit=picosecond)
>>> x.format("%.3f")
'5.440 ps'
# Bug report Dec 17, 2009 from John Chodera
# deepcopy of Quantity containing numpy array wrongly strips units
>>> try:
... import numpy
... import copy
... x = Quantity(numpy.zeros([2,3]), nanometer)
... y = copy.deepcopy(x)
... assert x[0][0] == y[0][0]
... except ImportError:
... pass
# Passing a string through Quantity constructor should return a string/dimensionless
>>> x = Quantity("string").value_in_unit_system(md_unit_system)
>>> assert x == "string"
# Trouble with complicated unit conversion factors
# Jan 29 1010 email from John Chodera
>>> p1 = 1.0 * atmosphere
>>> p2 = (1.0 * atmosphere).in_units_of(joule/nanometer**3)
>>> V = 2.4 * nanometer**3
>>> beta = 4.e-4 * mole/joule
>>> x1 = beta*p1*V
>>> # print x1
... y1 = x1 * AVOGADRO_CONSTANT_NA
>>> print y1
0.0585785776197
# Wrong answer is 5.85785776197e+25
>>> x2 = beta*p2*V
>>> # print x2
... y2 = x2 * AVOGADRO_CONSTANT_NA
>>> print y2
0.0585785776197
>>> assert( abs(y1 - y2) < 0.01)
# division of numpy arrays error
# April 2010, thanks to John Chodera for reporting
>>> try:
... import numpy
... x = Quantity(numpy.array([1.,2.]), nanometer)
... y = Quantity(numpy.array([3.,4.]), picosecond)
... assert str(x/y) == '[ 0.33333333 0.5 ] nm/ps'
... except ImportError:
... pass
# another numpy problem from retarded implementation of == operator
# Thanks to Kyle Beauchamp July 2010
>>> try:
... import numpy
... from simtk.unit.quantity import _is_string
... a = numpy.array([[1,2,3],[4,5,6]])
... assert isinstance("", str)
... assert _is_string("")
... assert _is_string("t")
... assert _is_string("test")
... assert not _is_string(3)
... assert not _is_string(a)
... except ImportError:
... pass
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.5"
# This unit code might be found in different packages...
# So use local import
from baseunit import BaseUnit
from standard_dimensions import *
from unit import is_unit, dimensionless
from quantity import Quantity, is_quantity, is_dimensionless
from unit_definitions import *
from unit_math import *
from constants import *
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
(failed, passed) = doctest.testmod(sys.modules[__name__])
# For use in automated testing, return number of failed tests as exit code
exit(failed)
"""
Pure python inversion of small matrices, to avoid requiring numpy or similar in SimTK.
"""
import sys
def eye(size):
"""
Returns identity matrix.
>>> print eye(3)
[[1, 0, 0]
[0, 1, 0]
[0, 0, 1]]
"""
result = []
for row in range(0, size):
r = []
for col in range(0, size):
if row == col:
r.append(1)
else:
r.append(0)
result.append(r)
return MyMatrix(result)
def zeros(m, n=None):
"""
Returns matrix of zeroes
>>> print zeros(3)
[[0, 0, 0]
[0, 0, 0]
[0, 0, 0]]
"""
if n == None:
n = m
result = []
for row in range(0, m):
r = []
for col in range(0, n):
r.append(0)
result.append(r)
return MyMatrix(result)
class MyVector(object):
"""
Parent class of MyMatrix and type of Matrix Row.
"""
def __init__(self, collection):
if isinstance(collection, MyVector):
self.data = collection.data
else:
self.data = collection
def __str__(self):
return str(self.data)
def __repr__(self):
return self.__class__.__name__ + "(" + repr(self.data) + ")"
def __getitem__(self, key):
return self.data[key]
def __contains__(self, item):
return item in self.data
def __delitem__(self, key):
del self.data[key]
def __iter__(self):
for item in self.data:
yield item
def __len__(self):
return len(self.data)
def __setitem__(self, key, value):
self.data[key] = value
def __rmul__(self, lhs):
try:
len(lhs)
# left side is not scalar, delegate mul to that class
return NotImplemented
except TypeError:
new_vec = []
for element in self:
new_vec.append(lhs * element)
return self.__class__(new_vec)
class MyMatrix(MyVector):
"""
Pure python linear algebra matrix for internal matrix inversion in UnitSystem.
>>> m = MyMatrix([[1,0,],[0,1,]])
>>> print m
[[1, 0]
[0, 1]]
>>> print ~m
[[1.0, 0.0]
[0.0, 1.0]]
>>> print eye(5)
[[1, 0, 0, 0, 0]
[0, 1, 0, 0, 0]
[0, 0, 1, 0, 0]
[0, 0, 0, 1, 0]
[0, 0, 0, 0, 1]]
>>> m = eye(5)
>>> m[1][1]
1
>>> m[1:4]
MyMatrixTranspose([[0, 0, 0],[1, 0, 0],[0, 1, 0],[0, 0, 1],[0, 0, 0]])
>>> print m[1:4]
[[0, 0, 0]
[1, 0, 0]
[0, 1, 0]
[0, 0, 1]
[0, 0, 0]]
>>> print m[1:4][0:2]
[[0, 1]
[0, 0]
[0, 0]]
>>> m[1:4][0:2] = [[9,8],[7,6],[5,4]]
>>> print m
[[1, 0, 0, 0, 0]
[9, 8, 0, 0, 0]
[7, 6, 1, 0, 0]
[5, 4, 0, 1, 0]
[0, 0, 0, 0, 1]]
"""
def numRows(self):
return len(self.data)
def numCols(self):
if len(self.data) == 0:
return 0
else:
return len(self.data[0])
def __len__(self):
return self.numRows()
def __str__(self):
result = ""
start_char = "["
for m in range(0, self.numRows()):
result += start_char
result += str(self[m])
if m < self.numRows() - 1:
result += "\n"
start_char = " "
result += "]"
return result
def __repr__(self):
return 'MyMatrix(' + MyVector.__repr__(self) + ')'
def is_square(self):
return self.numRows() == self.numCols()
def __iter__(self):
for item in self.data:
yield MyVector(item)
def __getitem__(self, m):
if isinstance(m, slice):
return MyMatrixTranspose(self.data[m])
else:
return MyVector(self.data[m])
def __setitem__(self, key, rhs):
if isinstance(key, slice):
self.data[key] = rhs
else:
assert len(rhs) == self.numCols()
self.data[key] = MyVector(rhs)
def __mul__(self, rhs):
"""
Matrix multiplication.
>>> a = MyMatrix([[1,2],[3,4]])
>>> b = MyMatrix([[5,6],[7,8]])
>>> print a
[[1, 2]
[3, 4]]
>>> print b
[[5, 6]
[7, 8]]
>>> print a*b
[[19, 22]
[43, 50]]
"""
m = self.numRows()
n = len(rhs[0])
r = len(rhs)
if self.numCols() != r:
raise ArithmeticError("Matrix multplication size mismatch (%d vs %d)" % (self.numCols(), r))
result = zeros(m, n)
for i in range(0, m):
for j in range(0, n):
for k in range(0, r):
result[i][j] += self[i][k]*rhs[k][j]
return result
def __add__(self, rhs):
"""
Matrix addition.
>>> print MyMatrix([[1, 2],[3, 4]]) + MyMatrix([[5, 6],[7, 8]])
[[6, 8]
[10, 12]]
"""
m = self.numRows()
n = self.numCols()
assert len(rhs) == m
assert len(rhs[0]) == n
result = zeros(m,n)
for i in range(0,m):
for j in range(0,n):
result[i][j] = self[i][j] + rhs[i][j]
return result
def __sub__(self, rhs):
"""
Matrix subtraction.
>>> print MyMatrix([[1, 2],[3, 4]]) - MyMatrix([[5, 6],[7, 8]])
[[-4, -4]
[-4, -4]]
"""
m = self.numRows()
n = self.numCols()
assert len(rhs) == m
assert len(rhs[0]) == n
result = zeros(m,n)
for i in range(0,m):
for j in range(0,n):
result[i][j] = self[i][j] - rhs[i][j]
return result
def __pos__(self):
return self
def __neg__(self):
m = self.numRows()
n = self.numCols()
result = zeros(m, n)
for i in range(0,m):
for j in range(0,n):
result[i][j] = -self[i][j]
return result
def __invert__(self):
"""
>>> m = MyMatrix([[1,1],[0,1]])
>>> print m
[[1, 1]
[0, 1]]
>>> print ~m
[[1.0, -1.0]
[0.0, 1.0]]
>>> print m*~m
[[1.0, 0.0]
[0.0, 1.0]]
>>> print ~m*m
[[1.0, 0.0]
[0.0, 1.0]]
>>> m = MyMatrix([[1,0,0],[0,0,1],[0,-1,0]])
>>> print m
[[1, 0, 0]
[0, 0, 1]
[0, -1, 0]]
>>> print ~m
[[1.0, 0.0, 0.0]
[0.0, 0.0, -1.0]
[0.0, 1.0, 0.0]]
>>> print m*~m
[[1.0, 0.0, 0.0]
[0.0, 1.0, 0.0]
[0.0, 0.0, 1.0]]
>>> print ~m*m
[[1.0, 0.0, 0.0]
[0.0, 1.0, 0.0]
[0.0, 0.0, 1.0]]
"""
assert self.is_square()
if self.numRows() == 0:
return self
elif self.numRows() == 1:
val = self[0][0]
val = 1.0/val
return MyMatrix([[val]])
elif self.numRows() == 2: # 2x2 is analytic
# http://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2.C3.972_matrices
a = self[0][0]
b = self[0][1]
c = self[1][0]
d = self[1][1]
determinant = a*d - b*c
if determinant == 0:
raise ArithmeticError("Cannot invert 2x2 matrix with zero determinant")
else:
return 1.0/(a*d - b*c) * MyMatrix([[d, -b],[-c, a]])
else:
# Gauss Jordan elimination from numerical recipes
n = self.numRows()
m1 = self.numCols()
assert n == m1
# Copy initial matrix into result matrix
a = zeros(n, n)
for i in range (0,n):
for j in range (0,n):
a[i][j] = self[i][j]
# These arrays are used for bookkeeping on the pivoting
indxc = [0] * n
indxr = [0] * n
ipiv = [0] * n
for i in range (0,n):
big = 0.0
for j in range (0,n):
if ipiv[j] != 1:
for k in range (0,n):
if ipiv[k] == 0:
if abs(a[j][k]) >= big:
big = abs(a[j][k])
irow = j
icol = k
ipiv[icol] += 1
# We now have the pivot element, so we interchange rows...
if irow != icol:
for l in range(0,n):
temp = a[irow][l]
a[irow][l] = a[icol][l]
a[icol][l] = temp
indxr[i] = irow
indxc[i] = icol
if a[icol][icol] == 0:
raise ArithmeticError("Cannot invert singular matrix")
pivinv = 1.0/a[icol][icol]
a[icol][icol] = 1.0
for l in range(0,n):
a[icol][l] *= pivinv
for ll in range(0,n): # next we reduce the rows
if ll == icol:
continue # except the pivot one, of course
dum = a[ll][icol]
a[ll][icol] = 0.0
for l in range(0,n):
a[ll][l] -= a[icol][l]*dum
# Unscramble the permuted columns
for l in range(n-1, -1, -1):
if indxr[l] == indxc[l]:
continue
for k in range(0,n):
temp = a[k][indxr[l]]
a[k][indxr[l]] = a[k][indxc[l]]
a[k][indxc[l]] = temp
return a
def transpose(self):
return MyMatrixTranspose(self.data)
class MyMatrixTranspose(MyMatrix):
def transpose(self):
return MyMatrix(self.data)
def numRows(self):
if len(self.data) == 0:
return 0
else:
return len(self.data[0])
def numCols(self):
return len(self.data)
def __getitem__(self, key):
result = []
for row in self.data:
result.append(row[key])
if isinstance(key, slice):
return MyMatrix(result)
else:
return MyVector(result)
def __setitem__(self, key, rhs):
for n in range(0, len(self.data)):
self.data[n][key] = rhs[n]
def __str__(self):
if len(self.data) == 0:
return "[[]]"
start_char = "["
result = ""
for m in range(0, len(self.data[0])):
result += start_char
result += "["
sep_char = ""
for n in range(0, len(self.data)):
result += sep_char
result += str(self.data[n][m])
sep_char = ", "
result += "]"
if m < len(self.data[0]) - 1:
result += "\n"
start_char = " "
result += "]"
return result
def __repr__(self):
if len(self.data) == 0:
return "MyMatrixTranspose([[]])"
start_char = "["
result = 'MyMatrixTranspose('
for m in range(0, len(self.data[0])):
result += start_char
result += "["
sep_char = ""
for n in range(0, len(self.data)):
result += sep_char
result += repr(self.data[n][m])
sep_char = ", "
result += "]"
if m < len(self.data[0]) - 1:
result += ","
start_char = ""
result += '])'
return result
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit.prefix
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.6"
from baseunit import BaseUnit
from unit import Unit, ScaledUnit
import sys
###################
### SI PREFIXES ###
###################
class SiPrefix(object):
"""
Unit prefix that can be multiplied by a unit to yield a new unit.
e.g. millimeter = milli*meter
"""
def __init__(self, prefix, factor, symbol):
self.prefix = prefix
self.factor = factor
self.symbol = symbol
def __mul__(self, unit):
"""
SiPrefix * BaseUnit yields new BaseUnit
SiPrefix * ScaledUnit yields new ScaledUnit
SiPrefix * Unit with exactly one BaseUnit or ScaledUnit yields new Unit
"""
if isinstance(unit, BaseUnit):
# BaseUnit version
symbol = self.symbol + unit.symbol
name = self.prefix + unit.name
factor = self.factor
# TODO - check for existing BaseUnit with same name, symbol, and factor
new_base_unit = BaseUnit(unit.dimension, name, symbol)
new_base_unit.define_conversion_factor_to(unit, factor)
return new_base_unit
elif isinstance(unit, ScaledUnit):
# ScaledUnit version
symbol = self.symbol + unit.symbol
name = self.prefix + unit.name
factor = self.factor * unit.factor
# TODO - check for existing BaseUnit with same name, symbol, and factor
return ScaledUnit(factor, unit.master, name, symbol)
elif isinstance(unit, Unit):
base_units = list(unit.iter_base_or_scaled_units())
if 1 != len(base_units):
raise TypeError('Unit prefix "%s" can only be with simple Units containing one component.' % self.prefix)
if 1 != base_units[0][1]:
raise TypeError('Unit prefix "%s" can only be with simple Units with an exponent of 1.' % self.prefix)
base_unit = base_units[0][0]
# Delegate to Base or Scaled Unit multiply
new_base_unit = self * base_unit
new_unit = Unit({new_base_unit: 1.0})
return new_unit
else:
raise TypeError('Unit prefix "%s" can only be applied to a Unit, BaseUnit, or ScaledUnit.' % self.prefix)
yotto = SiPrefix("yotto", 1e-24, 'y')
zepto = SiPrefix("zepto", 1e-21, 'z')
atto = SiPrefix("atto", 1e-18, 'a')
femto = SiPrefix("femto", 1e-15, 'f')
pico = SiPrefix("pico", 1e-12, 'p')
nano = SiPrefix("nano", 1e-9, 'n')
micro = SiPrefix("micro", 1e-6, 'u')
milli = SiPrefix("milli", 1e-3, 'm')
centi = SiPrefix("centi", 1e-2, 'c')
deci = SiPrefix("deci", 1e-1, 'd')
# two spellings for deka prefix
deka = SiPrefix("deka", 1e1, 'da')
deca = SiPrefix("deca", 1e1, 'da')
hecto = SiPrefix("hecto", 1e2, 'h')
kilo = SiPrefix("kilo", 1e3, 'k')
mega = SiPrefix("mega", 1e6, 'M')
giga = SiPrefix("giga", 1e9, 'G')
tera = SiPrefix("tera", 1e12, 'T')
peta = SiPrefix("peta", 1e15, 'P')
exa = SiPrefix("exa", 1e18, 'E')
zetta = SiPrefix("zetta", 1e21, 'Z')
yotta = SiPrefix("yotta", 1e24, 'Y')
si_prefixes = ( yotto
, zepto
, atto
, femto
, pico
, nano
, micro
, milli
, centi
, deci
, deka
, deca
, hecto
, kilo
, mega
, giga
, tera
, peta
, exa
, zetta
, yotta)
def define_prefixed_units(base_unit, module = sys.modules[__name__]):
"""
Create attributes for prefixed units derived from a particular BaseUnit, e.g. "kilometer" from "meter_base_unit"
Parameters
- base_unit (BaseUnit) existing base unit to use as a basis for prefixed units
- module (Module) module which will contain the new attributes. Defaults to simtk.unit module.
"""
for prefix in si_prefixes:
new_base_unit = prefix * base_unit
name = new_base_unit.name
new_unit = Unit({new_base_unit: 1.0})
# Create base_unit attribute, needed for creating UnitSystems
module.__dict__[name + '_base_unit'] = new_base_unit # e.g. "kilometer_base_unit"
# Create attribue in this module
module.__dict__[name] = new_unit # e.g. "kilometer"
# And plural version
module.__dict__[name + 's'] = new_unit # e.g. "kilometers"
# Binary prefixes
kibi = SiPrefix("kibi", 2.0**10, 'Ki')
mebi = SiPrefix("mebi", 2.0**20, 'Mi')
gibi = SiPrefix("gibi", 2.0**30, 'Gi')
tebi = SiPrefix("tebi", 2.0**40, 'Ti')
pebi = SiPrefix("pebi", 2.0**50, 'Pi')
exbi = SiPrefix("exbi", 2.0**60, 'Ei')
zebi = SiPrefix("zebi", 2.0**70, 'Zi')
yobi = SiPrefix("yobi", 2.0**80, 'Yi')
binary_prefixes = ( kibi
, mebi
, gibi
, tebi
, pebi
, exbi
, zebi
, yobi)
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit.quantity
Physical quantities with units, intended to produce similar functionality
to Boost.Units package in C++ (but with a runtime cost).
Uses similar API as Scientific.Physics.PhysicalQuantities
but different internals to satisfy our local requirements.
In particular, there is no underlying set of 'canonical' base
units, whereas in Scientific.Physics.PhysicalQuantities all
units are secretly in terms of SI units. Also, it is easier
to add new fundamental dimensions to simtk.dimensions. You
might want to make new dimensions for, say, "currency" or
"information".
Some features of this implementation:
* Quantities are a combination of a value and a unit. The value
part can be any python type, including numbers, lists, numpy
arrays, and anything else. The unit part must be a simtk.unit.Unit.
* Operations like adding incompatible units raises an error.
* Multiplying or dividing units/quantities creates new units.
* Users can create new Units and Dimensions, but most of the useful
ones are predefined.
* Conversion factors between units are applied transitively, so all
possible conversions are available.
* I want dimensioned Quantities that are compatible with numpy arrays,
but do not necessarily require the python numpy package. In other
words, Quantities can be based on either numpy arrays or on built in
python types.
* Units are NOT necessarily stored in terms of SI units internally.
This is very important for me, because one important application
area for us is at the molecular scale. Using SI units internally
can lead to exponent overflow in commonly used molecular force
calculations. Internally, all unit systems are equally fundamental
in SimTK.
Two possible enhancements that have not been implemented are
1) Include uncertainties with propagation of errors
2) Incorporate offsets for celsius <-> kelvin conversion
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.5"
import math
import copy
from standard_dimensions import *
from unit import Unit, is_unit, dimensionless
class Quantity(object):
"""Physical quantity, such as 1.3 meters per second.
Quantities contain both a value, such as 1.3; and a unit,
such as 'meters per second'.
Supported value types include:
1 - numbers (float, int, long)
2 - lists of numbers, e.g. [1,2,3]
3 - tuples of numbers, e.g. (1,2,3)
Note - unit conversions will cause tuples to be converted to lists
4 - lists of tuples of numbers, lists of lists of ... etc. of numbers
5 - numpy.arrays
Create numpy.arrays with units using the Quantity constructor, not the
multiply operator. e.g.
Quantity(numpy.array([1,2,3]), centimeters) # correct
*NOT*
numpy.array([1,2,3]) * centimeters # won't work
because numpy.arrays already overload the multiply operator for EVERYTHING.
"""
def __init__(self, value=None, unit=None):
"""
Create a new Quantity from a value and a unit.
Parameters
- value: (any type, usually a number) Measure of this quantity
- unit: (Unit) the physical unit, e.g. simtk.unit.meters.
"""
# When no unit is specified, bend over backwards to handle all one-argument possibilities
if unit == None: # one argument version, copied from UList
if is_unit(value):
# Unit argument creates an empty list with that unit attached
unit = value
value = []
elif is_quantity(value):
# Ulist of a Quantity is just the Quantity itself
unit = value.unit
value = value._value
elif _is_string(value):
unit = dimensionless
else:
# Is value a container?
is_container = True
try:
i = iter(value)
except TypeError:
is_container = False
if is_container:
if len(value) < 1:
unit = dimensionless
else:
first_item = iter(value).next()
# Avoid infinite recursion for string, because a one-character
# string is its own first element
if value == first_item:
unit = dimensionless
else:
unit = Quantity(first_item).unit
# Notice that tuples, lists, and numpy.arrays can all be initialized with a list
new_container = Quantity([], unit)
for item in value:
new_container.append(Quantity(item)) # Strips off units into list new_container._value
# __class__ trick does not work for numpy.arrays
try:
import numpy
if isinstance(value, numpy.ndarray):
value = numpy.array(new_container._value)
else:
# delegate contruction to container class from list
value = value.__class__(new_container._value)
except ImportError:
# delegate contruction to container class from list
value = value.__class__(new_container._value)
else:
# Non-Quantity, non container
# Wrap in a dimensionless Quantity
unit = dimensionless
# Accept simple scalar quantities as units
if is_quantity(unit):
value = value * unit._value
unit = unit.unit
# Use empty list for unspecified values
if value == None:
value = []
self._value = value
self.unit = unit
def __getstate__(self):
state = dict()
state['_value'] = self._value
state['unit'] = self.unit
return state
def __setstate__(self, state):
self._value = state['_value']
self.unit = state['unit']
return
def __copy__(self):
"""
Shallow copy produces a new Quantity with the shallow copy of value and the same unit.
Because we want copy operations to work just the same way they would on the underlying value.
"""
return Quantity(copy.copy(self._value), self.unit)
def __deepcopy__(self, memo):
"""
Deep copy produces a new Quantity with a deep copy of the value, and the same unit.
Because we want copy operations to work just the same way they would on the underlying value.
"""
return Quantity(copy.deepcopy(self._value, memo), self.unit)
def __getattr__(self, attribute):
"""
Delegate unrecognized attribute calls to the underlying value type.
"""
ret_val = getattr(self._value, attribute)
return ret_val
def __str__(self):
"""Printable string version of this Quantity.
Returns a string consisting of quantity number followed by unit abbreviation.
"""
return str(self._value) + ' ' + str(self.unit.get_symbol())
def __repr__(self):
"""
"""
return (Quantity.__name__ + '(value=' + repr(self._value) + ', unit=' +
str(self.unit) + ')')
def format(self, format_spec):
return format_spec % self._value + ' ' + str(self.unit.get_symbol())
def __add__(self, other):
"""Add two Quantities.
Only Quantities with the same dimensions (e.g. length)
can be added. Raises TypeError otherwise.
Parameters
- self: left hand member of sum
- other: right hand member of sum
Returns a new Quantity that is the sum of the two arguments.
"""
# can only add using like units
if not self.unit.is_compatible(other.unit):
raise TypeError('Cannot add two quantities with incompatible units "%s" and "%s".' % (self.unit, other.unit))
value = self._value + other.value_in_unit(self.unit)
unit = self.unit
return Quantity(value, unit)
def __sub__(self, other):
"""Subtract two Quantities.
Only Quantities with the same dimensions (e.g. length)
can be subtracted. Raises TypeError otherwise.
Parameters
- self: left hand member (a) of a - b.
- other: right hand member (b) of a - b.
Returns a new Quantity that is the difference of the two arguments.
"""
if not self.unit.is_compatible(other.unit):
raise TypeError('Cannot subtract two quantities with incompatible units "%s" and "%s".' % (self.unit, other.unit))
value = self._value - other.value_in_unit(self.unit)
unit = self.unit
return Quantity(value, unit)
def __eq__(self, other):
"""
"""
if not is_quantity(other):
return False
else:
return NotImplemented # punt to cmp
def __ne__(self, other):
"""
"""
if not is_quantity(other):
return True
else:
return NotImplemented # punt to cmp
def __cmp__(self, other):
"""Compares two quantities.
Raises TypeError if the Quantities are of different dimension (e.g. length vs. mass)
Returns -1 if self < other, 0 if self == other, and 1 if self > other.
"""
return cmp(self._value, (other.value_in_unit(self.unit)))
def __ge__(self, other):
return self._value >= (other.value_in_unit(self.unit))
def __gt__(self, other):
return self._value > (other.value_in_unit(self.unit))
def __le__(self, other):
return self._value <= (other.value_in_unit(self.unit))
def __lt__(self, other):
return self._value < (other.value_in_unit(self.unit))
def reduce_unit(self, guide_unit=None):
"""
Combine similar component units and scale, to form an
equal Quantity in simpler units.
Returns underlying value type if unit is dimensionless.
"""
value_factor = 1.0
canonical_units = {} # dict of dimensionTuple: (Base/ScaledUnit, exponent)
# Bias result toward guide units
if guide_unit != None:
for u, exponent in guide_unit.iter_base_or_scaled_units():
d = u.get_dimension_tuple()
if d not in canonical_units:
canonical_units[d] = [u, 0]
for u, exponent in self.unit.iter_base_or_scaled_units():
d = u.get_dimension_tuple()
# Take first unit found in a dimension as canonical
if d not in canonical_units:
canonical_units[d] = [u, exponent]
else:
value_factor *= (u.conversion_factor_to(canonical_units[d][0])**exponent)
canonical_units[d][1] += exponent
new_base_units = {}
for d in canonical_units:
u, exponent = canonical_units[d]
if exponent != 0:
assert u not in new_base_units
new_base_units[u] = exponent
# Create new unit
if len(new_base_units) == 0:
unit = dimensionless
else:
unit = Unit(new_base_units)
# There might be a factor due to unit conversion, even though unit is dimensionless
# e.g. suppose unit is meter/centimeter
if unit.is_dimensionless():
unit_factor = unit.conversion_factor_to(dimensionless)
if unit_factor != 1.0:
value_factor *= unit_factor
# print "value_factor = %s" % value_factor
unit = dimensionless
# Create Quantity, then scale (in case value is a container)
# That's why we don't just scale the value.
result = Quantity(self._value, unit)
if value_factor != 1.0:
# __mul__ strips off dimensionless, if appropriate
result = result * value_factor
if unit.is_dimensionless():
assert unit is dimensionless # should have been set earlier in this method
if is_quantity(result):
result = result._value
return result
def __mul__(self, other):
"""Multiply a quantity by another object
Returns a new Quantity that is the product of the self * other,
unless the resulting unit is dimensionless, in which case the
underlying value type is returned, instead of a Quantity.
"""
if is_unit(other):
# print "quantity * unit"
# Many other mul/div operations delegate to here because I was debugging
# a dimensionless unit conversion problem, which I ended up fixing within
# the reduce_unit() method.
unit = self.unit * other
return Quantity(self._value, unit).reduce_unit(self.unit)
elif is_quantity(other):
# print "quantity * quantity"
# Situations where the units cancel can result in scale factors from the unit cancellation.
# To simplify things, delegate Quantity * Quantity to (Quantity * scalar) * unit
return (self * other._value) * other.unit
else:
# print "quantity * scalar"
return self._change_units_with_factor(self.unit, other, post_multiply=False)
# value type might not be commutative for multiplication
def __rmul__(self, other):
"""Multiply a scalar by a Quantity
Returns a new Quantity with the same units as self, but with the value
multiplied by other.
"""
if is_unit(other):
raise NotImplementedError('programmer is surprised __rmul__ was called instead of __mul__')
# print "R unit * quantity"
elif is_quantity(other):
# print "R quantity * quantity"
raise NotImplementedError('programmer is surprised __rmul__ was called instead of __mul__')
else:
# print "scalar * quantity"
return self._change_units_with_factor(self.unit, other, post_multiply=True)
# return Quantity(other * self._value, self.unit)
def __div__(self, other):
"""Divide a Quantity by another object
Returns a new Quantity, unless the resulting unit type is dimensionless,
in which case the underlying value type is returned.
"""
if is_unit(other):
# print "quantity / unit"
return self * pow(other, -1.0)
# unit = self.unit / other
# return Quantity(self._value, unit).reduce_unit(self.unit)
elif is_quantity(other):
# print "quantity / quantity"
# Delegate quantity/quantity to (quantity/scalar)/unit
return (self/other._value) / other.unit
else:
# print "quantity / scalar"
return self * pow(other, -1.0)
# return Quantity(self._value / other, self.unit)
def __rdiv__(self, other):
"""Divide a scalar by a quantity.
Returns a new Quantity. The resulting units are the inverse of the self argument units.
"""
if is_unit(other):
# print "R unit / quantity"
raise NotImplementedError('programmer is surprised __rdiv__ was called instead of __div__')
elif is_quantity(other):
raise NotImplementedError('programmer is surprised __rdiv__ was called instead of __div__')
else:
# print "R scalar / quantity"
return other * pow(self, -1.0)
# return Quantity(other / self._value, pow(self.unit, -1.0))
def __pow__(self, exponent):
"""Raise a Quantity to a power.
Generally both the value and the unit of the Quantity are affected by this operation.
Returns a new Quantity equal to self**exponent.
"""
return Quantity(pow(self._value, exponent), pow(self.unit, exponent))
def sqrt(self):
"""
Returns square root of a Quantity.
Raises ArithmeticError if component exponents are not even.
This behavior can be changed if you present a reasonable real life case to me.
"""
# There might be a conversion factor from taking the square root of the unit
new_value = math.sqrt(self._value)
new_unit = self.unit.sqrt()
unit_factor = self.unit.conversion_factor_to(new_unit*new_unit)
if unit_factor != 1.0:
new_value *= math.sqrt(unit_factor)
return Quantity(value=new_value, unit=new_unit)
def __abs__(self):
"""
Return absolute value of a Quantity.
The unit is unchanged. A negative value of self will result in a positive value
in the result.
"""
return Quantity(abs(self._value), self.unit)
def __pos__(self):
"""
Returns a reference to self.
"""
return Quantity(+(self._value), self.unit)
def __neg__(self):
"""Negate a Quantity.
Returns a new Quantity with a different sign on the value.
"""
return Quantity(-(self._value), self.unit)
def __nonzero__(self):
"""Returns True if value underlying Quantity is zero, False otherwise.
"""
return bool(self._value)
def __complex__(self):
return Quantity(complex(self._value), self.unit)
def __float__(self):
return Quantity(float(self._value), self.unit)
def __int__(self):
return Quantity(int(self._value), self.unit)
def __long__(self):
return Quantity(int(self._value), self.unit)
def value_in_unit(self, unit):
"""
Returns underlying value, in the specified units.
"""
val = self.in_units_of(unit)
if is_quantity(val):
return val._value
else: # naked dimensionless
return val
def value_in_unit_system(self, system):
"""
Returns the underlying value type, after conversion to a particular unit system.
"""
result = self.in_unit_system(system)
if is_quantity(result):
return result._value
else:
return result # dimensionless
def in_unit_system(self, system):
"""
Returns a new Quantity equal to this one, expressed in a particular unit system.
"""
return self.in_units_of(self.unit.in_unit_system(system))
def in_units_of(self, other_unit):
"""
Returns an equal Quantity expressed in different units.
If the units are the same as those in self, a reference to self is returned.
Raises a TypeError if the new unit is not compatible with the original unit.
The post_multiply argument is used in case the multiplication operation is not commutative.
i.e. result = factor * value when post_multiply is False
and result = value * factor when post_multiply is True
"""
if not self.unit.is_compatible(other_unit):
raise TypeError('Unit "%s" is not compatible with Unit "%s".' % (self.unit, other_unit))
f = self.unit.conversion_factor_to(other_unit)
return self._change_units_with_factor(other_unit, f)
def _change_units_with_factor(self, new_unit, factor, post_multiply=True):
# numpy arrays cannot be compared with 1.0, so just "try"
factor_is_identity = False
try:
if (factor == 1.0):
factor_is_identity = True
except ValueError:
pass
if factor_is_identity:
# No multiplication required
if (self.unit is new_unit):
result = self
else:
result = Quantity(self._value, new_unit)
else:
try:
# multiply operator, if it exists, is preferred
if post_multiply:
value = self._value * factor # works for number, numpy.array, or vec3, e.g.
else:
value = factor * self._value # works for number, numpy.array, or vec3, e.g.
result = Quantity(value, new_unit)
except TypeError:
# list * float fails with TypeError
# Presumably a list type
# deep copy
value = self._value[:] # deep copy
# convert tuple to list
try:
value[0] = value[0] # tuple is immutable
except TypeError:
# convert immutable tuple to list
value = []
for i in self._value:
value.append(i)
result = Quantity(value, new_unit)
for i in range(len(result)):
# Push multiply operation one level deeper
if post_multiply:
result[i] = result[i]*factor
else:
result[i] = factor*result[i]
if (new_unit.is_dimensionless()):
return result._value
else:
return result
####################################
### Sequence methods of Quantity ###
### in case value is a sequence ###
####################################
def __len__(self):
"""
Return size of internal value type.
"""
return len(self._value)
def __getitem__(self, key):
"""
Keep the same units on contained elements.
"""
assert not is_quantity(self._value[key])
return Quantity(self._value[key], self.unit)
def __setitem__(self, key, value):
# Delegate slices to one-at-a time ___setitem___
if isinstance(key, slice): # slice
indices = key.indices(len(self))
for i in range(*indices):
self[i] = value[i]
else: # single index
# Check unit compatibility
if self.unit.is_dimensionless() and is_dimensionless(value):
pass # OK
elif not self.unit.is_compatible(value.unit):
raise TypeError('Unit "%s" is not compatible with Unit "%s".' % (self.unit, value.unit))
self._value[key] = value / self.unit
assert not is_quantity(self._value[key])
def __delitem__(self, key):
del(self._value[key])
def __contains__(self, item):
return self._value.__contains__(item.value_in_unit(self.unit))
def __iter__(self):
for item in self._value:
yield Quantity(item, self.unit)
def count(self, item):
return self._value.count(item.value_in_unit(self.unit))
def index(self, item):
return self._value.index(item.value_in_unit(self.unit))
def append(self, item):
if is_quantity(item):
return self._value.append(item.value_in_unit(self.unit))
elif is_dimensionless(self.unit):
return self._value.append(item)
else:
raise TypeError("Cannot append item without units into list with units")
def extend(self, rhs):
self._value.extend(rhs.value_in_unit(self.unit))
def insert(self, index, item):
self._value.insert(index, item.value_in_unit(self.unit))
def remove(self, item):
self._value.remove(item)
def pop(self, *args):
return self._value.pop(*args) * self.unit
# list.reverse will automatically delegate correctly
# list.sort with no arguments will delegate correctly
# list.sort with a comparison function cannot be done correctly
def is_quantity(x):
"""
Returns True if x is a Quantity, False otherwise.
"""
return isinstance(x, Quantity)
def is_dimensionless(x):
"""
"""
if is_unit(x):
return x.is_dimensionless()
elif is_quantity(x):
return x.unit.is_dimensionless()
else:
# everything else in the universe is dimensionless
return True
# Strings can cause trouble
# as can any container that has infinite levels of containment
def _is_string(x):
# step 1) String is always a container
# and its contents are themselves containers.
if isinstance(x, str):
return True
try:
first_item = iter(x).next()
inner_item = iter(first_item).next()
if first_item is inner_item:
return True
else:
return False
except TypeError:
return False
except StopIteration:
return False
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit.standard_dimensions
Definition of principal dimensions: mass, length, time, etc.
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.6"
from basedimension import BaseDimension
##################
### DIMENSIONS ###
##################
mass_dimension = BaseDimension('mass')
length_dimension = BaseDimension('length')
time_dimension = BaseDimension('time')
temperature_dimension = BaseDimension('temperature')
amount_dimension = BaseDimension('amount')
charge_dimension = BaseDimension('charge')
luminous_intensity_dimension = BaseDimension('luminous intensity')
angle_dimension = BaseDimension('angle')
information_dimension = BaseDimension('information')
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit
Contains classes Unit and ScaledUnit.
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.5"
import math
import sys
from mymatrix import MyMatrix, zeros
from basedimension import BaseDimension
from baseunit import BaseUnit
from standard_dimensions import *
class Unit(object):
"""
Physical unit such as meter or ampere.
"""
def __init__(self, base_or_scaled_units):
"""Create a new Unit.
Parameters:
- self (Unit) The newly created Unit.
- base_or_scaled_units (dict) Keys are BaseUnits or ScaledUnits. Values are exponents (numbers).
"""
# Unit contents are of two types: BaseUnits and ScaledUnits
self._top_base_units = {}
self._all_base_units = {}
self._scaled_units = []
for (base_or_scaled_unit, power) in base_or_scaled_units.items():
if power == 0:
continue
if isinstance(base_or_scaled_unit, BaseUnit):
bu = base_or_scaled_unit
dim = bu.dimension
if dim not in self._top_base_units:
self._top_base_units[dim] = {}
if bu not in self._top_base_units[dim]:
self._top_base_units[dim][bu] = 0
self._top_base_units[dim][bu] += power
else:
self._scaled_units.append((base_or_scaled_unit, power))
# Populate self._all_base_units
# first, deep copy of self._top_base_units
self._all_base_units = {}
for d in self._top_base_units:
self._all_base_units[d] = {}
for u in self._top_base_units[d]:
self._all_base_units[d][u] = self._top_base_units[d][u]
# second, BaseUnits from self._scaled_units
for scaled_unit, exponent1 in self._scaled_units:
for base_unit, exponent2 in scaled_unit.iter_base_units():
dim = base_unit.dimension
if dim not in self._all_base_units:
self._all_base_units[dim] = {}
if base_unit not in self._all_base_units[dim]:
self._all_base_units[dim][base_unit] = 0
self._all_base_units[dim][base_unit] += exponent1 * exponent2
# What about heterogenous units that cancel? --> leave them
self._scaled_units.sort()
def create_unit(self, scale, name, symbol):
"""
Convenience method for creating a new simple unit from another simple unit.
Both units must consist of a single BaseUnit.
"""
# TODO - also handle non-simple units, i.e. units with multiple BaseUnits/ScaledUnits
assert len(self._top_base_units) == 1
assert len(self._scaled_units) == 0
dimension = self._top_base_units.iterkeys().next()
base_unit_dict = self._top_base_units[dimension]
assert len(base_unit_dict) == 1
parent_base_unit = base_unit_dict.iterkeys().next()
parent_exponent = base_unit_dict[parent_base_unit]
new_base_unit = BaseUnit(parent_base_unit.dimension, name, symbol)
# BaseUnit scale might be different depending on exponent
true_scale = scale
if parent_exponent != 1.0:
true_scale = math.pow(scale, 1.0/parent_exponent)
new_base_unit.define_conversion_factor_to(parent_base_unit, true_scale)
new_unit = Unit({new_base_unit: 1.0})
return new_unit
def iter_base_dimensions(self):
"""
Yields (BaseDimension, exponent) tuples comprising this unit.
"""
result = {}
# There might be two units with the same dimension? No.
for dimension in sorted(self._all_base_units.iterkeys()):
exponent = 0
for base_unit in sorted(self._all_base_units[dimension].iterkeys()):
exponent += self._all_base_units[dimension][base_unit]
if exponent != 0:
yield (dimension, exponent)
def iter_all_base_units(self):
"""
Yields (BaseUnit, exponent) tuples comprising this unit, including those BaseUnits
found within ScaledUnits.
There might be multiple BaseUnits with the same dimension.
"""
result = {}
for dimension in sorted(self._all_base_units.iterkeys()):
for base_unit in sorted(self._all_base_units[dimension].iterkeys()):
exponent = self._all_base_units[dimension][base_unit]
yield (base_unit, exponent)
def iter_top_base_units(self):
"""
Yields (BaseUnit, exponent) tuples in this Unit, excluding those within BaseUnits.
"""
for dimension in sorted(self._top_base_units.iterkeys()):
for unit in sorted(self._top_base_units[dimension].iterkeys()):
exponent = self._top_base_units[dimension][unit]
yield (unit, exponent)
def iter_scaled_units(self):
for unit, exponent in self._scaled_units:
yield (unit, exponent)
def iter_base_or_scaled_units(self):
for item in self.iter_top_base_units():
yield item
for item in self.iter_scaled_units():
yield item
def get_conversion_factor_to_base_units(self):
"""
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
"""
factor = 1.0
for scaled_unit, exponent in self._scaled_units:
# print scaled_unit.factor
factor *= scaled_unit.factor ** exponent
return factor
def __eq__(self, other):
if not is_unit(other):
return False
if not self.is_compatible(other):
return False
return NotImplemented # punt to cmp()
def __ne__(self, other):
if not is_unit(other):
return True
if not self.is_compatible(other):
return True
return NotImplemented # punt to cmp()
def __cmp__(self, other):
"""Compare two Units.
Raises a TypeError if the units have different dimensions.
Returns 0 if the Units are equal, -1 if the first Unit is smaller,
and returns 1 if the first Unit is larger.
"""
if not self.is_compatible(other):
raise TypeError('Unit "%s" is not compatible with Unit "%s".', (self, other))
return cmp(self.conversion_factor_to(other), 1.0)
# def __mul__(self, other):
# See unit_operators.py for Unit.__mul__ operator
def __div__(self, other):
"""Divide a Unit by another object.
Returns a composite Unit if other is another Unit.
Returns a Quantity otherwise. UNLESS other is a Quantity AND
the resulting unit type is dimensionless, in which case the underlying
value type of the Quantity is returned.
"""
return self * pow(other, -1)
# def __rdiv__(self, other):
# Because rdiv returns a Quantity, look in quantity.py for definition of Unit.__rdiv__
def __pow__(self, exponent):
"""Raise a Unit to a power.
Returns a new Unit with different exponents on the BaseUnits.
"""
result = {} # dictionary of unit: exponent
for unit, exponent2 in self.iter_base_or_scaled_units():
result[unit] = exponent2 * exponent
return Unit(result)
def sqrt(self):
"""
Returns square root of a unit.
Raises ArithmeticError if component exponents are not even.
This behavior can be changed if you present a reasonable real life case to me.
"""
new_units = {}
# There might be odd exponents in base and scaled units that
# boil down to even exponents in base dimensions.
# But if ScaledUnits and BaseUnits have even exponents, we should use them.
nice_and_even = True
for u, exponent in self.iter_base_or_scaled_units():
if exponent%2 != 0:
# This isn't going to work, we need to bust apart the ScaledUnits
nice_and_even = False
break
new_units[u] = exponent/2
if not nice_and_even:
# Create a new unit formed from inner BaseUnits
new_units = {}
base_units_by_dimension = {}
# Choose the first BaseUnit for each dimension
for base_unit, exponent in self.iter_all_base_units():
d = base_unit.dimension
if d not in base_units_by_dimension:
base_units_by_dimension[d] = base_unit
new_units[base_unit] = exponent
else:
# Already assigned a BaseUnit to this dimension, just update exponent
bu = base_units_by_dimension[d]
new_units[bu] += exponent
# If exponents are not even by now, they never will be even
for u, exponent in new_units.items():
if exponent%2 != 0:
raise ArithmeticError('Exponents in Unit.sqrt() must be even.')
new_units[u] = exponent/2
return Unit(new_units)
def __str__(self):
"""Returns the human-readable name of this unit"""
return self.get_name()
def __repr__(self):
"""
Returns a unit name (string) for this Unit, composed of its various
BaseUnit symbols. e.g. 'kilogram meter**2 second**-1'
"""
units = {}
for unit, power in self.iter_base_or_scaled_units():
units[unit] = power
return 'Unit(%s)' % repr(units)
def is_compatible(self, other):
"""
Returns True if two Units share the same dimension.
Returns False otherwise.
"""
if not is_unit(other):
if self.is_dimensionless():
return True
else:
return False
self_dims = {}
for dimension, exponent in self.iter_base_dimensions():
self_dims[dimension] = exponent
other_dims = {}
for dimension, exponent in other.iter_base_dimensions():
other_dims[dimension] = exponent
if len(self_dims) != len(other_dims):
return False
return self_dims == other_dims
def is_dimensionless(self):
"""Returns True if this Unit has no dimensions.
Returns False otherwise.
"""
for dimension, exponent in self.iter_base_dimensions():
if exponent != 0:
return False
return True
def conversion_factor_to(self, other):
"""
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.
"""
factor = 1.0
if (self is other):
return factor
assert self.is_compatible(other)
factor *= self.get_conversion_factor_to_base_units()
factor /= other.get_conversion_factor_to_base_units()
# Organize both units' base units by dimension
canonical_units = {} # dimension: BaseUnit
for unit, power in self.iter_all_base_units():
d = unit.dimension
if d in canonical_units:
if unit != canonical_units[d]:
factor *= unit.conversion_factor_to(canonical_units[d])**power
else:
canonical_units[d] = unit
for unit, power in other.iter_all_base_units():
d = unit.dimension
if d in canonical_units:
if unit != canonical_units[d]:
factor /= unit.conversion_factor_to(canonical_units[d])**power
else:
canonical_units[d] = unit
return factor
def in_unit_system(self, system):
"""
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
"""
return system.express_unit(self)
def get_symbol(self):
"""
Returns a unit symbol (string) for this Unit, composed of its various
BaseUnit symbols. e.g. 'kg m**2 s**-1'
"""
symbol = ""
# emit positive exponents first
pos = ""
pos_count = 0
for unit, power in self.iter_base_or_scaled_units():
if power > 0:
pos_count += 1
if pos_count > 1: pos += " "
pos += unit.symbol
if power != 1.0:
pos += "**%g" % power
# emit negative exponents second
neg = ""
neg_count = 0
simple_denominator = True
for unit, power in self.iter_base_or_scaled_units():
if power < 0:
neg_count += 1
if neg_count > 1: neg += " "
neg += unit.symbol
if power != -1.0:
neg += "**%g" % -power
simple_denominator = False
# Format of denominator depends on number of terms
if 0 == neg_count:
neg_string = ""
elif 1 == neg_count and simple_denominator:
neg_string = "/%s" % neg
else:
neg_string = "/(%s)" % neg
if 0 == pos_count:
pos_string = ""
else:
pos_string = pos
if 0 == pos_count == neg_count:
symbol = "dimensionless"
else:
symbol = "%s%s" % (pos_string, neg_string)
return symbol
def get_name(self):
"""
Returns a unit name (string) for this Unit, composed of its various
BaseUnit symbols. e.g. 'kilogram meter**2 secon**-1'.
"""
# emit positive exponents first
pos = ""
pos_count = 0
for unit, power in self.iter_base_or_scaled_units():
if power > 0:
pos_count += 1
if pos_count > 1: pos += "*"
pos += unit.name
if power != 1.0:
pos += "**%g" % power
# emit negative exponents second
neg = ""
neg_count = 0
simple_denominator = True
for unit, power in self.iter_base_or_scaled_units():
if power < 0:
neg_count += 1
if neg_count > 1: neg += "*"
neg += unit.name
if power != -1.0:
neg += "**%g" % -power
simple_denominator = False
# Format of denominator depends on number of terms
if 0 == neg_count:
neg_string = ""
elif 1 == neg_count and simple_denominator:
neg_string = "/%s" % neg
else:
neg_string = "/(%s)" % neg
if 0 == pos_count:
pos_string = ""
else:
pos_string = pos
if 0 == pos_count == neg_count:
name = "dimensionless"
else:
name = "%s%s" % (pos_string, neg_string)
return name
class ScaledUnit(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.
"""
def __init__(self, factor, master, name, symbol):
self.factor = factor
# Convert to one base_unit per dimension
base_units = {}
for bu, exponent in master.iter_all_base_units():
dim = bu.dimension
if dim not in base_units:
base_units[dim] = [bu, exponent]
else:
base_units[dim][1] += exponent
self.factor *= base_units[dim][0].conversion_factor_to(bu)
for sbu, exponent in master.iter_scaled_units():
self.factor *= sbu.factor**exponent
self.base_units = base_units
self.master = master
self.name = name
self.symbol = symbol
def __iter__(self):
for dim in sorted(self.base_units.iterkeys()):
yield self.base_units[dim]
def iter_base_units(self):
for base_unit, exponent in self:
yield(base_unit, exponent)
def iter_base_dimensions(self):
"""
Returns a sorted tuple of (BaseDimension, exponent) pairs, describing the dimension of this unit.
"""
for base_unit, exponent in self:
if exponent != 0:
yield (base_unit.dimension, exponent)
def get_dimension_tuple(self):
"""
Returns a sorted tuple of (BaseDimension, exponent) pairs, that can be used as a dictionary key.
"""
l = list(self.iter_base_dimensions())
l.sort()
return tuple(l)
def get_conversion_factor_to_base_units(self):
return self.factor
def conversion_factor_to(self, other):
# Create fake unit based on base units
if self is other:
return 1.0
u = {}
for base_unit, exponent in self.iter_base_units():
u[base_unit] = exponent
if isinstance(other, Unit):
other_u = other
else:
other_u = Unit({other: 1.0})
return self.factor * Unit(u).conversion_factor_to(other_u)
def __str__(self):
"""Returns a string with the name of this ScaledUnit
"""
return self.name
def __repr__(self):
"""
"""
base_units = ""
for base_unit, power in self.iter_base_units():
if len(base_units) > 0:
base_units += ", "
base_units += "%s: %d" % (base_unit, power)
return "ScaledUnit(factor=" + repr(self.factor) + \
", master="+str(self.master)+", name=" + repr(self.name)\
+ ", symbol=" + repr(self.symbol) + ")"
class UnitSystem(object):
def __init__(self, units):
self.units = units
# Create a set of base units to be used for dimension conversion
base_units = {}
for unit in self.units:
for base_unit, exponent in unit.iter_base_units():
d = base_unit.dimension
if d not in base_units:
base_units[d] = base_unit
self.base_units = base_units
if not len(self.base_units) == len(self.units):
raise ArithmeticError("UnitSystem must have same number of units as base dimensions")
# self.dimensions is a dict of {BaseDimension: index}
dimensions = base_units.keys()
dimensions.sort()
self.dimensions = {}
for d in range(len(dimensions)):
self.dimensions[dimensions[d]] = d
# Create units->base units exponent matrix
to_base_units = zeros(len(self.units))
for m in range(len(self.units)):
unit = self.units[m]
for dim, power in unit.iter_base_dimensions():
n = self.dimensions[dim]
to_base_units[m][n] = power
try:
self.from_base_units = ~to_base_units
except ArithmeticError, e:
# for compatibility between python 2.5 and python 3.0,
# try replacing line above with the following two lines:
# except ArithmeticError:
# e=sys.exc_info[1]
raise ArithmeticError("UnitSystem is not a valid basis set. " + str(e))
def __iter__(self):
for unit in self.units:
yield unit
def __str__(self):
"""
"""
result = "UnitSystem(["
sep = ""
for unit in self:
result += sep
result += str(unit)
sep = ", "
result += "])"
return result
def express_unit(self, old_unit):
"""
"""
# First express unit in terms of base dimensions found in this unit system
# (plus other dimensions not found)
m = len(self.dimensions)
base_dims = [0] * m
other_dims = {}
for dim, exponent in old_unit.iter_base_dimensions():
if dim in self.dimensions:
base_dims[self.dimensions[dim]] = exponent
else:
other_dims[dim] = exponent
# Multiply by self.from_base_units to convert to unit system units
u = MyMatrix([base_dims,]) * self.from_base_units
new_unit = dimensionless
for i in range(m):
exponent = u[0][i]
if exponent != 0:
new_unit *= Unit({self.units[i]: exponent})
if len(other_dims) > 0:
# Find one base unit for each dimension
found_dims = {}
for base_unit, useless_exponent in old_unit.iter_all_base_units():
dim = base_unit.dimension
if dim not in other_dims:
continue # this dimension is in the unit system
if dim in found_dims:
continue # already got a BaseUnit for this dimension
found_dims[dim] = base_unit
exponent = other_dims[dim]
new_unit *= Unit({base_unit: exponent})
return new_unit
def is_unit(x):
"""
Returns True if x is a Unit, False otherwise.
Examples
>>> is_unit(16)
False
"""
return isinstance(x, Unit)
dimensionless = Unit({})
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit.unit_definitions
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.6"
from baseunit import BaseUnit
from standard_dimensions import *
from unit import Unit, ScaledUnit, UnitSystem, dimensionless
from unit_operators import * ; # needed for manipulation of units
from prefix import *
import math
import sys
#####################
### DIMENSIONLESS ###
#####################
# dimensionless = Unit({}); # defined in unit.py
##############
### LENGTH ###
##############
meter_base_unit = BaseUnit(length_dimension, "meter", "m")
meters = meter = Unit({meter_base_unit: 1.0})
define_prefixed_units(meter_base_unit, module = sys.modules[__name__])
angstrom_base_unit = BaseUnit(length_dimension, "angstrom", "A")
angstrom_base_unit.define_conversion_factor_to(meter_base_unit, 1e-10)
angstroms = angstrom = Unit({angstrom_base_unit: 1.0})
planck_length_base_unit = BaseUnit(length_dimension, "Planck length", "l_P")
planck_length_base_unit.define_conversion_factor_to(meter_base_unit, 1.61625281e-35)
inch_base_unit = BaseUnit(length_dimension, "inch", "in")
inch_base_unit.define_conversion_factor_to(centimeter_base_unit, 2.5400)
inch = inches = Unit({inch_base_unit: 1.0})
foot_base_unit = BaseUnit(length_dimension, "foot", "ft")
foot_base_unit.define_conversion_factor_to(inch_base_unit, 12.0)
foot = feet = Unit({foot_base_unit: 1.0})
yard_base_unit = BaseUnit(length_dimension, "yard", "yd")
yard_base_unit.define_conversion_factor_to(foot_base_unit, 3.0)
yard = yards = Unit({yard_base_unit: 1.0})
furlongs = furlong = yard.create_unit(scale=220.0, name="furlong", symbol="furlong")
miles = mile = furlong.create_unit(scale=8.0, name="mile", symbol="mi")
############
### MASS ###
############
gram_base_unit = BaseUnit(mass_dimension, "gram", "g")
grams = gram = Unit({gram_base_unit: 1.0})
define_prefixed_units(gram_base_unit, module = sys.modules[__name__])
planck_mass_base_unit = BaseUnit(mass_dimension, "Planck mass", "m_P")
planck_mass_base_unit.define_conversion_factor_to(kilogram_base_unit, 2.1764411e-8)
# pound can be mass, force, or currency
pound_mass_base_unit = BaseUnit(mass_dimension, "pound", "lb")
pound_mass_base_unit.define_conversion_factor_to(kilogram_base_unit, 0.3732)
pound_mass = pounds_mass = Unit({pound_mass_base_unit: 1.0})
stone_base_unit = BaseUnit(mass_dimension, "stone", "stone")
stone_base_unit.define_conversion_factor_to(pound_mass_base_unit, 14.0)
stone = stones = Unit({stone_base_unit: 1.0})
############
### TIME ###
############
second_base_unit = BaseUnit(time_dimension, "second", "s")
seconds = second = Unit({second_base_unit: 1.0})
define_prefixed_units(second_base_unit, module = sys.modules[__name__])
planck_time_base_unit = BaseUnit(time_dimension, "Planck time", "t_P")
planck_time_base_unit.define_conversion_factor_to(second_base_unit, 5.3912427e-44)
minutes = minute = second.create_unit(scale=60.0, name="minute", symbol="min")
hours = hour = minute.create_unit(scale=60.0, name="hour", symbol="hr")
days = day = hour.create_unit(scale=24.0, name="day", symbol="day")
weeks = week = day.create_unit(scale=7.0, name="week", symbol="week")
years = year = day.create_unit(scale=365.25, name="julian year", symbol="a")
centuries = centurys = century = year.create_unit(scale=100.0, name="century", symbol="century")
millenia = milleniums = millenium = century.create_unit(scale=10.0, name="millenium", symbol="ka")
fortnights = fortnight = day.create_unit(scale=14.0, name="fortnight", symbol="fortnight")
###################
### TEMPERATURE ###
###################
kelvin_base_unit = BaseUnit(temperature_dimension, "kelvin", "K")
kelvins = kelvin = Unit({kelvin_base_unit: 1.0})
planck_temperature_base_unit = BaseUnit(temperature_dimension, "Planck temperature", "T_p")
planck_temperature_base_unit.define_conversion_factor_to(kelvin_base_unit, 1.41678571e32)
##############
### CHARGE ###
##############
elementary_charge_base_unit = BaseUnit(charge_dimension, "elementary charge", "q")
elementary_charges = elementary_charge = Unit({elementary_charge_base_unit: 1.0})
coulomb_base_unit = BaseUnit(charge_dimension, "elementary charge", "q")
# Exact conversion factor
coulomb_base_unit.define_conversion_factor_to(elementary_charge_base_unit, 6.24150962915265e18)
coulombs = coulomb = Unit({coulomb_base_unit: 1.0})
planck_charge_base_unit = BaseUnit(charge_dimension, "Planck charge", "q_P")
planck_charge_base_unit.define_conversion_factor_to(elementary_charge_base_unit, 11.706237639840)
##############
### AMOUNT ###
##############
mole_base_unit = BaseUnit(amount_dimension, "mole", "mol")
moles = mole = Unit({mole_base_unit: 1.0})
single_item_amount_base_unit = BaseUnit(amount_dimension, "item", "")
mole_base_unit.define_conversion_factor_to(single_item_amount_base_unit, 6.0221417930e23)
items = item = Unit({single_item_amount_base_unit: 1.0})
##########################
### Luminous Intensity ###
##########################
candela_base_unit = BaseUnit(luminous_intensity_dimension, "candela", "cd")
candelas = candela = Unit({candela_base_unit: 1.0})
#############
### ANGLE ###
#############
radian_base_unit = BaseUnit(angle_dimension, "radian", "rad")
radians = radian = Unit({radian_base_unit: 1.0})
degree_base_unit = BaseUnit(angle_dimension, "degree", "deg")
degree_base_unit.define_conversion_factor_to(radian_base_unit, math.pi/180.0)
degrees = degree = Unit({degree_base_unit: 1.0})
arcminutes = arcminute = degree.create_unit(scale=1.0/60.0, name="arcminute", symbol="'")
arcseconds = arcsecond = arcminute.create_unit(scale=1.0/60.0, name="arcsecond", symbol='"')
###################
### INFORMATION ###
###################
bit_base_unit = BaseUnit(information_dimension, "bit", "bit")
bits = bit = Unit({bit_base_unit: 1.0})
byte_base_unit = BaseUnit(information_dimension, "byte", "B")
byte_base_unit.define_conversion_factor_to(bit_base_unit, 8.0)
bytes = byte = Unit({byte_base_unit: 1.0})
nat_base_unit = BaseUnit(information_dimension, "nat", "nat")
nat_base_unit.define_conversion_factor_to(bit_base_unit, 1.0/math.log(2.0))
nats = nat = nits = nit = nepits = nepit = Unit({nat_base_unit: 1.0})
ban_base_unit = BaseUnit(information_dimension, "ban", "ban")
ban_base_unit.define_conversion_factor_to(bit_base_unit, math.log(10.0, 2.0))
bans = ban = hartleys = hartley = dits = dit = Unit({ban_base_unit: 1.0})
###############
### DERIVED ###
###############
# Molar mass
# daltons = dalton = grams / mole
daltons = dalton = Unit({ScaledUnit(1.0, gram/mole, "dalton", "Da"): 1.0})
amus = amu = dalton
atom_mass_units = atomic_mass_unit = dalton
# Volume
liter_base_unit = ScaledUnit(1.0, decimeter**3, "liter", "l")
liter = liters = litre = litres = Unit({liter_base_unit: 1.0})
define_prefixed_units(liter_base_unit, module = sys.modules[__name__])
# Concentration
molar_base_unit = ScaledUnit(1.0, mole/liter, "molar", "M")
molar = molal = Unit({molar_base_unit: 1.0})
define_prefixed_units(molar_base_unit, module = sys.modules[__name__])
# Force
newton_base_unit = ScaledUnit(1.0, kilogram * meter / second / second, "newton", "N")
newtons = newton = Unit({newton_base_unit: 1.0})
define_prefixed_units(newton_base_unit, module = sys.modules[__name__])
# pound can be mass, force, or currency
pound_force_base_unit = ScaledUnit(4.448, newton, "pound", "lb")
pound_force = pounds_force = Unit({pound_force_base_unit: 1.0})
dyne_base_unit = ScaledUnit(1.0, gram * centimeter / second**2, "dyne", "dyn")
dyne = dynes = Unit({dyne_base_unit: 1.0})
# Energy
joule_base_unit = ScaledUnit(1.0, newton * meter, "joule", "J")
joules = joule = Unit({joule_base_unit: 1.0})
define_prefixed_units(joule_base_unit, module = sys.modules[__name__])
erg_base_unit = ScaledUnit(1.0, dyne * centimeter, "erg", "erg")
erg = ergs = Unit({erg_base_unit: 1.0})
# In molecular simulations, "kilojoules" are in microscopic units
# And you really only want to use kilojoules/mole.
md_kilojoule_raw = gram * nanometer**2 / picosecond**2
md_kilojoules = md_kilojoule = Unit({ScaledUnit(1.0, md_kilojoule_raw, "kilojoule", "kJ"): 1.0})
kilojoules_per_mole = kilojoule_per_mole = md_kilojoule / mole
calorie_base_unit = ScaledUnit(4.184, joule, "calorie", "cal")
calories = calorie = Unit({calorie_base_unit: 1.0})
define_prefixed_units(calorie_base_unit, module = sys.modules[__name__])
md_kilocalories = md_kilocalorie = Unit({ScaledUnit(4.184, md_kilojoule, "kilocalorie", "kcal"): 1.0})
kilocalories_per_mole = kilocalorie_per_mole = md_kilocalorie / mole
# Power
watt_base_unit = ScaledUnit(1.0, joule / second, "watt", "W")
watt = watts = Unit({watt_base_unit: 1.0})
# Current
ampere_base_unit = ScaledUnit(1.0, coulomb / second, "ampere", "A")
ampere = amperes = amp = amps = Unit({ampere_base_unit: 1.0})
# Electrical potential
volt_base_unit = ScaledUnit(1.0, watt / ampere, "volt", "V")
volt = volts = Unit({volt_base_unit: 1.0})
# Magnetic field
tesla_base_unit = ScaledUnit(1.0, newton / (ampere * meter), "tesla", "T")
tesla = teslas = Unit({tesla_base_unit: 1.0})
gauss_base_unit = ScaledUnit(10.0**-4, tesla, "gauss", "G")
gauss = Unit({gauss_base_unit: 1.0})
# Electrical resistance
ohm_base_unit = ScaledUnit(1.0, volt / ampere, "ohm", "O")
ohm = ohms = Unit({ohm_base_unit: 1.0})
# Capacitance
farad_base_unit = ScaledUnit(1.0, coulomb / volt, "farad", "F")
farad = farads = Unit({farad_base_unit: 1.0})
# Inductance
henry_base_unit = ScaledUnit(1.0, volt * second / ampere, "henry", "H")
henry = henries = henrys = Unit({henry_base_unit: 1.0})
# Pressure
pascal_base_unit = ScaledUnit(1.0, newton / (meter**2), "pascal", "Pa")
pascals = pascal = Unit({pascal_base_unit: 1.0})
define_prefixed_units(pascal_base_unit, module = sys.modules[__name__])
psi_base_unit = ScaledUnit(1.0, pound_force / (inch**2), "psi", "psi")
psi = Unit({psi_base_unit: 1.0})
bar_base_unit = ScaledUnit(10.0**5, pascal, "bar", "bar")
bar = bars = Unit({bar_base_unit: 1.0})
atmosphere_base_unit = ScaledUnit(101325.0, pascal, "atmosphere", "atm")
atmosphere = atmospheres = Unit({atmosphere_base_unit: 1.0})
torr_base_unit = ScaledUnit(1.0/760.0, atmosphere, "torr", "Torr")
torr = Unit({torr_base_unit: 1.0})
mmHg_base_unit = ScaledUnit(133.322, pascal, "mmHg", "mmHg")
mmHg = Unit({mmHg_base_unit: 1.0})
####################
### Unit Systems ###
####################
ampere_base_unit = ScaledUnit(1.0, coulomb/second, "ampere", "A")
si_unit_system = UnitSystem([\
meter_base_unit,\
kilogram_base_unit,\
second_base_unit,\
ampere_base_unit,
kelvin_base_unit,
mole_base_unit,
candela_base_unit,
radian_base_unit])
cgs_unit_system = UnitSystem([\
centimeter_base_unit,\
gram_base_unit,\
second_base_unit,\
ampere_base_unit,
kelvin_base_unit,
mole_base_unit,
radian_base_unit])
dalton_base_unit = ScaledUnit(1.0, gram/mole, "dalton", "Da")
md_unit_system = UnitSystem([\
nanometer_base_unit,\
dalton_base_unit,
picosecond_base_unit,\
elementary_charge_base_unit,
kelvin_base_unit,
mole_base_unit,
radian_base_unit])
planck_unit_system = UnitSystem([\
planck_length_base_unit,
planck_mass_base_unit,
planck_time_base_unit,
planck_charge_base_unit,
planck_temperature_base_unit,
single_item_amount_base_unit,
radian_base_unit])
########################
### TESTING/EXAMPLES ###
########################
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit.math
Arithmetic methods on Quantities and Units
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.5"
import math
from quantity import is_quantity
from unit_definitions import *
####################
### TRIGONOMETRY ###
####################
def sin(angle):
"""
Examples
>>> sin(90*degrees)
1.0
"""
if is_quantity(angle):
return math.sin(angle/radians)
else:
return math.sin(angle)
def sinh(angle):
if is_quantity(angle):
return math.sinh(angle/radians)
else:
return math.sinh(angle)
def cos(angle):
"""
Examples
>>> cos(180*degrees)
-1.0
"""
if is_quantity(angle):
return math.cos(angle/radians)
else:
return math.cos(angle)
def cosh(angle):
if is_quantity(angle):
return math.cosh(angle/radians)
else:
return math.cosh(angle)
def tan(angle):
if is_quantity(angle):
return math.tan(angle/radians)
else:
return math.tan(angle)
def tanh(angle):
if is_quantity(angle):
return math.tanh(angle/radians)
else:
return math.tanh(angle)
def acos(x):
"""
>>> acos(1.0)
Quantity(value=0.0, unit=radian)
>>> print acos(1.0)
0.0 rad
"""
return math.acos(x) * radians
def acosh(x):
return math.acosh(x) * radians
def asin(x):
return math.asin(x) * radians
def asinh(x):
return math.asinh(x) * radians
def atan(x):
return math.atan(x) * radians
def atanh(x):
return math.atanh(x) * radians
def atan2(x, y):
return math.atan2(x, y) * radians
###################
### SQUARE ROOT ###
###################
def sqrt(val):
"""
>>> sqrt(9.0)
3.0
>>> print sqrt(meter*meter)
meter
>>> sqrt(9.0*meter*meter)
Quantity(value=3.0, unit=meter)
>>> sqrt(9.0*meter*meter*meter)
Traceback (most recent call last):
...
ArithmeticError: Exponents in Unit.sqrt() must be even.
"""
try:
return val.sqrt()
except AttributeError:
return math.sqrt(val)
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
Module simtk.unit.unit_operators
Physical quantities with units, intended to produce similar functionality
to Boost.Units package in C++ (but with a runtime cost).
Uses similar API as Scientific.Physics.PhysicalQuantities
but different internals to satisfy our local requirements.
In particular, there is no underlying set of 'canonical' base
units, whereas in Scientific.Physics.PhysicalQuantities all
units are secretly in terms of SI units. Also, it is easier
to add new fundamental dimensions to simtk.dimensions. You
might want to make new dimensions for, say, "currency" or
"information".
Two possible enhancements that have not been implemented are
1) Include uncertainties with propagation of errors
2) Incorporate offsets for celsius <-> kelvin conversion
"""
__author__ = "Christopher M. Bruns"
__version__ = "0.5"
from unit import Unit, is_unit
from quantity import Quantity, is_quantity
# Attach methods of Unit class that return a Quantity to Unit class.
# I put them here to avoid circular dependence in imports.
# i.e. Quantity depends on Unit, but not vice versa
def _unit_class_rdiv(self, other):
"""
Divide another object type by a Unit.
Returns a new Quantity with a value of other and units
of the inverse of self.
"""
if is_unit(other):
raise NotImplementedError('programmer is surprised __rdiv__ was called instead of __div__')
else:
# print "R scalar / unit"
unit = pow(self, -1.0)
value = other
return Quantity(value, unit).reduce_unit(self)
Unit.__rdiv__ = _unit_class_rdiv
def _unit_class_mul(self, other):
"""Multiply a Unit by an object.
If other is another Unit, returns a new composite Unit.
Exponents of similar dimensions are added. If self and
other share similar BaseDimension, but
with different BaseUnits, the resulting BaseUnit for that
BaseDimension will be that used in self.
If other is a not another Unit, this method returns a
new Quantity... UNLESS other is a Quantity and the resulting
unit is dimensionless, in which case the underlying value type
of the Quantity is returned.
"""
if is_unit(other):
# print "unit * unit"
result1 = {} # dictionary of dimensionTuple: (BaseOrScaledUnit, exponent)
for unit, exponent in self.iter_base_or_scaled_units():
d = unit.get_dimension_tuple()
if d not in result1:
result1[d] = {}
assert unit not in result1[d]
result1[d][unit] = exponent
for unit, exponent in other.iter_base_or_scaled_units():
d = unit.get_dimension_tuple()
if d not in result1:
result1[d] = {}
if unit not in result1[d]:
result1[d][unit] = 0
result1[d][unit] += exponent
result2 = {} # stripped of zero exponents
for d in result1:
for unit in result1[d]:
exponent = result1[d][unit]
if exponent != 0:
assert unit not in result2
result2[unit] = exponent
return Unit(result2)
elif is_quantity(other):
# print "unit * quantity"
value = other._value
unit = self * other.unit
return Quantity(value, unit).reduce_unit(self)
else:
# print "scalar * unit"
value = other
unit = self
return Quantity(other, self).reduce_unit(self)
Unit.__mul__ = _unit_class_mul
Unit.__rmul__ = Unit.__mul__
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
#!/bin/env python
"""
vec3.py: Used for managing vectors of lenght three.
"""
__author__ = "Christopher M. Bruns"
__version__ = "1.0"
import sys
import simtk.unit
class Vec3(object):
"""
Vec3 represents a three-dimensional point or displacement in space.
Examples
>>> v = Vec3((1, 2, 3))
>>> print v.dot(v)
14
>>> print abs(v)
3.74165738677
>>> v += Vec3((3,2,1))
>>> print v
[4, 4, 4]
>>> print v**2
48.0
>>> print v**1
6.92820323028
>>> print v
[4, 4, 4]
"""
def __init__(self, xyz):
"""
Create a new Vec3 object, specifying its three elements.
Examples:
>>> v = Vec3((1,2,3))
>>> print v
[1, 2, 3]
"""
x = xyz[0]
y = xyz[1]
z = xyz[2]
self.data = [x, y, z]
def __repr__(self):
"""
Create a string containing a python code representation of this Vec3.
Examples
>>> v = Vec3([1,2,3])
>>> v
Vec3([1, 2, 3])
"""
return self.__class__.__name__ + \
'([' + repr(self[0]) + ", " + repr(self[1]) + ", " + repr(self[2]) + '])'
def __len__(self):
"""
Returns the number of elements in this Vec3. Always 3.
Examples
>>> v = Vec3((1, 2, 3))
>>> len(v)
3
"""
return 3
def __iter__(self):
"""
Examples
>>> v = Vec3((1,2,3))
>>> for c in v:
... print c
...
1
2
3
"""
for coord in self.data:
yield coord
def __getitem__(self, key):
return self.data[key]
def __setitem__(self, key, value):
self.data[key] = value
def __abs__(self):
return pow(self.dot(self), 0.5)
def __neg__(self):
return self.__class__([-self[0], -self[1], -self[2]])
def __pos__(self):
return self
def __add__(self, other):
return self.__class__([self[0] + other[0], self[1] + other[1], self[2] + other[2]])
def __radd__(self, other):
return self.__class__([other[0] + self[0], other[1] + self[1], other[2] + self[2]])
def __sub__(self, other):
return self.__class__([self[0] - other[0], self[1] - other[1], self[2] - other[2]])
def __rsub__(self, other):
return self.__class__([other[0] - self[0], other[1] - self[1], other[2] - self[2]])
def __mul__(self, other):
"""
Returns NotImplemented if the right hand side is a simtk.unit.Unit,
so the Unit class can return a proper Quantity unit.
Example
>>> import simtk.unit
>>> Vec3([1,2,3]) * simtk.unit.meter
Quantity(Vec3([1, 2, 3]), meter)
"""
# If other is a Unit, delegate to Unit.__rmul__ multiplication
if simtk.unit.is_unit(other):
return NotImplemented
return self.__class__([self[0] * other, self[1] * other, self[2] * other])
def __rmul__(self, other):
return self.__class__([other * self[0], other * self[1], other * self[2]])
def __div__(self, other):
# If other is a Unit, delegate to Unit.__rmul__ multiplication
if simtk.unit.is_unit(other):
return NotImplemented
return self.__class__([self[0] / other, self[1] / other, self[2] / other])
def __rdiv__(self, other):
return self.__class__([other / self[0], other / self[1], other / self[2]])
def __str__(self):
return "["+str(self[0])+", "+str(self[1])+", "+str(self[2])+"]"
def __pow__(self, exponent):
return pow(self.dot(self), exponent * 0.5)
def dot(self, other):
assert len(other) == 3
return self[0] * other[0] + self[1] * other[1] + self[2] * other[2]
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
import doctest, sys
doctest.testmod(sys.modules[__name__])
%define DOCSTRING
"PyOpenMM is a Python application programming interface (API) to be
used for performing molecular dynamics (MD) simulations on various
computer architectures (including GPUs). It is implemented in Python
and C/C++, and provides a Python interface to the OpenMM libraries
(see https://simtk.org/home/openmm for OpenMM details). The primary
motivation for creating PyOpenMM is to make it possible to write
GPU-accelerated MD code in pure Python.
See https://simtk.org/home/pyopenmm for details"
%enddef
%module (docstring=DOCSTRING) openmm
%include "typemaps.i"
%include "factory.i"
%include "std_string.i"
%include "std_iostream.i"
%include "std_pair.i"
%include "std_vector.i"
namespace std {
%template(pairii) pair<int,int>;
%template(vectord) vector<double>;
%template(vectorddd) vector< vector< vector<double> > >;
%template(vectori) vector<int>;
%template(vectorii) vector < vector<int> >;
%template(vectorpairii) vector< pair<int,int> >;
%template(vectorstring) vector<string>;
};
%include "windows.i"
%{
#define SWIG_FILE_WITH_INIT
#include <sstream>
#include <exception>
#include "OpenMM.h"
#include "OpenMMFreeEnergy.h"
#include "OpenMMAmoeba.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/XmlSerializer.h"
using namespace OpenMM;
%}
%feature("autodoc", "1");
%nodefaultctor;
%include features.i
%include OpenMM_docstring.i
%include OpenMM_headers.i
/*
%extend OpenMM::XmlSerializer {
%template(XmlSerializer_serialize_AndersenThermostat) XmlSerializer::serialize<AndersenThermostat>;
%template(XmlSerializer_serialize_RBTorsionForce) XmlSerializer::serialize<RBTorsionForce>;
%template(XmlSerializer_serialize_CMAPTorsionForce) XmlSerializer::serialize<CMAPTorsionForce>;
%template(XmlSerializer_serialize_CMMotionRemover) XmlSerializer::serialize<CMMotionRemover>;
%template(XmlSerializer_serialize_CustomAngleForce) XmlSerializer::serialize<CustomAngleForce>;
%template(XmlSerializer_serialize_CustomBondForce) XmlSerializer::serialize<CustomBondForce>;
%template(XmlSerializer_serialize_CustomExternalForce) XmlSerializer::serialize<CustomExternalForce>;
%template(XmlSerializer_serialize_CustomGBForce) XmlSerializer::serialize<CustomGBForce>;
%template(XmlSerializer_serialize_CustomHbondForce) XmlSerializer::serialize<CustomHbondForce>;
%template(XmlSerializer_serialize_CustomNonbondedForce) XmlSerializer::serialize<CustomNonbondedForce>;
%template(XmlSerializer_serialize_CustomTorsionForce) XmlSerializer::serialize<CustomTorsionForce>;
%template(XmlSerializer_serialize_GBSAOBCForce) XmlSerializer::serialize<GBSAOBCForce>;
%template(XmlSerializer_serialize_GBVIForce) XmlSerializer::serialize<GBVIForce>;
%template(XmlSerializer_serialize_HarmonicAngleForce) XmlSerializer::serialize<HarmonicAngleForce>;
%template(XmlSerializer_serialize_HarmonicBondForce) XmlSerializer::serialize<HarmonicBondForce>;
%template(XmlSerializer_serialize_MonteCarloBarostat) XmlSerializer::serialize<MonteCarloBarostat>;
%template(XmlSerializer_serialize_NonbondedForce) XmlSerializer::serialize<NonbondedForce>;
%template(XmlSerializer_serialize_RBTorsionForce) XmlSerializer::serialize<RBTorsionForce>;
%template(XmlSerializer_serialize_System) XmlSerializer::serialize<System>;
%template(XmlSerializer_deserialize_AndersenThermostat) XmlSerializer::deserialize<AndersenThermostat>;
%template(XmlSerializer_deserialize_RBTorsionForce) XmlSerializer::deserialize<RBTorsionForce>;
%template(XmlSerializer_deserialize_CMAPTorsionForce) XmlSerializer::deserialize<CMAPTorsionForce>;
%template(XmlSerializer_deserialize_CMMotionRemover) XmlSerializer::deserialize<CMMotionRemover>;
%template(XmlSerializer_deserialize_CustomAngleForce) XmlSerializer::deserialize<CustomAngleForce>;
%template(XmlSerializer_deserialize_CustomBondForce) XmlSerializer::deserialize<CustomBondForce>;
%template(XmlSerializer_deserialize_CustomExternalForce) XmlSerializer::deserialize<CustomExternalForce>;
%template(XmlSerializer_deserialize_CustomGBForce) XmlSerializer::deserialize<CustomGBForce>;
%template(XmlSerializer_deserialize_CustomHbondForce) XmlSerializer::deserialize<CustomHbondForce>;
%template(XmlSerializer_deserialize_CustomNonbondedForce) XmlSerializer::deserialize<CustomNonbondedForce>;
%template(XmlSerializer_deserialize_CustomTorsionForce) XmlSerializer::deserialize<CustomTorsionForce>;
%template(XmlSerializer_deserialize_GBSAOBCForce) XmlSerializer::deserialize<GBSAOBCForce>;
%template(XmlSerializer_deserialize_GBVIForce) XmlSerializer::deserialize<GBVIForce>;
%template(XmlSerializer_deserialize_HarmonicAngleForce) XmlSerializer::deserialize<HarmonicAngleForce>;
%template(XmlSerializer_deserialize_HarmonicBondForce) XmlSerializer::deserialize<HarmonicBondForce>;
%template(XmlSerializer_deserialize_MonteCarloBarostat) XmlSerializer::deserialize<MonteCarloBarostat>;
%template(XmlSerializer_deserialize_NonbondedForce) XmlSerializer::deserialize<NonbondedForce>;
%template(XmlSerializer_deserialize_RBTorsionForce) XmlSerializer::deserialize<RBTorsionForce>;
%template(XmlSerializer_deserialize_System) XmlSerializer::deserialize<System>;
};
*/
This source diff could not be displayed because it is too large. You can view the blob instead.
This swig based, wrapper code only works from a Bash shell.
You *must* have the following installed:
1) Python 2.5 or 2.6
2) swig 2.0.0 or better (earlier versions are likely to fail)
3) Some type of XSLT processor (xsltproc, saxon, etc)
4) Doxygen (tested with version 1.4.7, but others should also work)
5) py-dom-xpath (tested with version 0.1, but others should also work):
http://code.google.com/p/py-dom-xpath
To build the wrapper codes, the following must be done
1) Run doxygen to generate xml files containing OpenMM API info (doxygen
uses the OpenMM header files to do this).
2) Run a python script that builds SWIG input files based on info in the
doxygen xml files
3) Run SWIG to generate python and C code that wraps the OpenMM libraries
We have created a single Bash script that does the full build for you.
But before running it, you must create and export environment variables
containing the OpenMM lib path (OPENMM_LIB_PATH) and the include directory
path (OPENMM_INCLUDE_PATH). The include directory should contain the "OpenMM.h"
file and an "openmm" directory. The lib directory should contain
the OpenMM dynamic library (OpenMM.dll, libOpenMM.so or libOpenMM.dylib) and
plugins. For example, when I build OpenMM on a Bash system, I set the
install dir to $HOME (in ccmake). Then I type the following two lines at
the command line:
export OPENMM_LIB_PATH=$HOME/lib
export OPENMM_INCLUDE_PATH=$HOME/include
Next run the Bash build script as follows:
/bin/bash buildSwigWrapper.sh
You may need to edit this script to work on your system
If all went well, the wrapper code is now updated; cd ../.. and follow
instuctions for building the PyOpenMM libraries.
1. Edit swigInputConfig.py to add new classes, ...
2. Add template <class T> to XmlSerializer (serialize/deserialize)
class XmlSerializer {
public:
%apply std::ostream & OUTPUT { std::ostream & stream };
template <class T>static void serialize(const T *object, const std::string
&rootName, std::ostream &stream) ;
%clear std::ostream & stream;
%apply std::istream & OUTPUT { std::istream & stream };
template <class T>static T* deserialize(std::istream &stream) ;
%clear std::istream & stream;
};
#!/bin/bash
rm -f *.xml
rm -f OpenMM_headers*
rm -f *.cxx
SWIG_REV_FILE_OPENMM=RevisionNumber_OpenMM.txt
SWIG_REV_FILE_PYOPENMM=RevisionNumber_pyopenmm.txt
PYTHON_PACKAGE_DIR=../../simtk/chem/openmm
if [ -n "$OPENMM_SVN_PATH" ] ; then
SVN_INFO=$(svn info $OPENMM_SVN_PATH 2>/dev/null | awk '$0~/^Revision:/{print $2}')
if [ -n "$SVN_INFO" ] ; then
echo $SVN_INFO >| $SWIG_REV_FILE_OPENMM
fi
fi
if [ -z "$OPENMM_INCLUDE_PATH" ] ; then
OPENMM_INCLUDE_PATH=../../OpenMM/include
fi
SVN_INFO=$(svn info 2>/dev/null | awk '$0~/^Revision:/{print $2}')
if [ -n "$SVN_INFO" ] ; then
echo $SVN_INFO >| $SWIG_REV_FILE_PYOPENMM
fi
cd doxygen
rm -rf xml/ html/
echo "Calling doxygen >| doxygen.out 2>| doxygen.err"
doxygen >| doxygen.out 2>| doxygen.err
if [ "$?" -ne "0" ]; then
echo "ERROR: doxygen did not run"
echo " See doxygen/doxygen.out and doxygen/doxygen.err!"
echo "Exiting!"
exit 1
fi
cd xml
echo "Calling xsltproc combine.xslt index.xml >| ../../OpenMM_headers.xml"
xsltproc combine.xslt index.xml >| ../../OpenMM_headers.xml
cd ../../
#Build ref platform only
echo "Calling swigInputBuilder.py -i OpenMM_headers.xml -c swigInputConfig.py -o OpenMM_headers.i -d OpenMM_docstring.i -a swig_lib/python/pythonprepend.i -z swig_lib/python/pythonappend.i "
python swigInputBuilder.py -i OpenMM_headers.xml \
-c swigInputConfig.py \
-o OpenMM_headers.i \
-d OpenMM_docstring.i \
-a swig_lib/python/pythonprepend.i \
-z swig_lib/python/pythonappend.i \
>| swigInputBuilder.out
USING_SWIG_VERSION=$(swig -version | awk '/^SWIG Version/{print $3}')
USING_SWIG_VERSION_NUM=$(echo $USING_SWIG_VERSION | awk -F. '{print 1000*(1000*$1+$2)+$3}')
if (( $USING_SWIG_VERSION_NUM < 2000000 )) ; then
echo "ERROR: Using swig $USING_SWIG_VERSION. Must use 2.0.0 or better"
exit 1
fi
echo "calling swig -python -c++ -Wall -outdir $PYTHON_PACKAGE_DIR -o OpenMMSwig.cxx OpenMM.i"
swig -python -c++ -Wall \
-outdir $PYTHON_PACKAGE_DIR \
-o OpenMMSwig.cxx \
OpenMM.i
echo "Done: swig -python -c++\n"
# Doxyfile 1.5.9
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
# This tag specifies the encoding used for all characters in the config file
# that follow. The default is UTF-8 which is also the encoding used for all
# text before the first occurrence of this tag. Doxygen uses libiconv (or the
# iconv built into libc) for the transcoding. See
# http://www.gnu.org/software/libiconv for the list of possible encodings.
DOXYFILE_ENCODING = UTF-8
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
PROJECT_NAME =
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER =
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY =
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
# format and will distribute the generated files over these directories.
# Enabling this option can be useful when feeding doxygen a huge amount of
# source files, where putting all generated files in the same directory would
# otherwise cause performance problems for the file system.
CREATE_SUBDIRS = NO
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
OUTPUT_LANGUAGE = English
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
REPEAT_BRIEF = YES
# This tag implements a quasi-intelligent brief description abbreviator
# that is used to form the text in various listings. Each string
# in this list, if found as the leading text of the brief description, will be
# stripped from the text and the result after processing the whole list, is
# used as the annotated text. Otherwise, the brief description is used as-is.
# If left blank, the following values are used ("$name" is automatically
# replaced with the name of the entity): "The $name class" "The $name widget"
# "The $name file" "is" "provides" "specifies" "contains"
# "represents" "a" "an" "the"
ABBREVIATE_BRIEF =
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
ALWAYS_DETAILED_SEC = NO
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
# inherited members of a class in the documentation of that class as if those
# members were ordinary class members. Constructors, destructors and assignment
# operators of the base classes will not be shown.
INLINE_INHERITED_MEMB = NO
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
FULL_PATH_NAMES = YES
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user-defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. The tag can be used to show relative paths in the file list.
# If left blank the directory from which doxygen is run is used as the
# path to strip.
STRIP_FROM_PATH =
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
# the path mentioned in the documentation of a class, which tells
# the reader which header file to include in order to use a class.
# If left blank only the name of the header file containing the class
# definition is used. Otherwise one should specify the include paths that
# are normally passed to the compiler using the -I flag.
STRIP_FROM_INC_PATH =
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful is your file systems
# doesn't support long names like on DOS, Mac, or CD-ROM.
SHORT_NAMES = NO
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
# comments will behave just like regular Qt-style comments
# (thus requiring an explicit @brief command for a brief description.)
JAVADOC_AUTOBRIEF = NO
# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
# interpret the first line (until the first dot) of a Qt-style
# comment as the brief description. If set to NO, the comments
# will behave just like regular Qt-style comments (thus requiring
# an explicit \brief command for a brief description.)
QT_AUTOBRIEF = NO
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
# treat a multi-line C++ special comment block (i.e. a block of //! or ///
# comments) as a brief description. This used to be the default behaviour.
# The new default is to treat a multi-line C++ comment block as a detailed
# description. Set this tag to YES if you prefer the old behaviour instead.
MULTILINE_CPP_IS_BRIEF = NO
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# re-implements.
INHERIT_DOCS = YES
# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
# a new page for each member. If set to NO, the documentation of a member will
# be part of the file/class/namespace that contains it.
SEPARATE_MEMBER_PAGES = NO
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
TAB_SIZE = 8
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user-defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
ALIASES =
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
# sources only. Doxygen will then generate output that is more tailored for C.
# For instance, some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = NO
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
# sources only. Doxygen will then generate output that is more tailored for
# Java. For instance, namespaces will be presented as packages, qualified
# scopes will look different, etc.
OPTIMIZE_OUTPUT_JAVA = NO
# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
# sources only. Doxygen will then generate output that is more tailored for
# Fortran.
OPTIMIZE_FOR_FORTRAN = NO
# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
# sources. Doxygen will then generate output that is tailored for
# VHDL.
OPTIMIZE_OUTPUT_VHDL = NO
# Doxygen selects the parser to use depending on the extension of the files it parses.
# With this tag you can assign which parser to use for a given extension.
# Doxygen has a built-in mapping, but you can override or extend it using this tag.
# The format is ext=language, where ext is a file extension, and language is one of
# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
EXTENSION_MAPPING =
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
# to include (a tag file for) the STL sources as input, then you should
# set this tag to YES in order to let doxygen match functions declarations and
# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
# func(std::string) {}). This also make the inheritance and collaboration
# diagrams that involve STL classes more complete and accurate.
BUILTIN_STL_SUPPORT = NO
# If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support.
CPP_CLI_SUPPORT = NO
# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
# Doxygen will parse them like normal C++ but will assume all classes use public
# instead of private inheritance when no explicit protection keyword is present.
SIP_SUPPORT = NO
# For Microsoft's IDL there are propget and propput attributes to indicate getter
# and setter methods for a property. Setting this option to YES (the default)
# will make doxygen to replace the get and set methods by a property in the
# documentation. This will only work if the methods are indeed getting or
# setting a simple type. If this is not the case, or you want to show the
# methods anyway, you should set this option to NO.
IDL_PROPERTY_SUPPORT = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
DISTRIBUTE_GROUP_DOC = NO
# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
# the same type (for instance a group of public functions) to be put as a
# subgroup of that type (e.g. under the Public Functions section). Set it to
# NO to prevent subgrouping. Alternatively, this can be done per class using
# the \nosubgrouping command.
SUBGROUPING = YES
# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
# is documented as struct, union, or enum with the name of the typedef. So
# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
# with name TypeT. When disabled the typedef will appear as a member of a file,
# namespace, or class. And the struct will be named TypeS. This can typically
# be useful for C code in case the coding convention dictates that all compound
# types are typedef'ed and only the typedef is referenced, never the tag name.
TYPEDEF_HIDES_STRUCT = NO
# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
# determine which symbols to keep in memory and which to flush to disk.
# When the cache is full, less often used symbols will be written to disk.
# For small to medium size projects (<1000 input files) the default value is
# probably good enough. For larger projects a too small cache size can cause
# doxygen to be busy swapping symbols to and from disk most of the time
# causing a significant performance penality.
# If the system has enough physical memory increasing the cache will improve the
# performance by keeping more symbols in memory. Note that the value works on
# a logarithmic scale so increasing the size by one will rougly double the
# memory usage. The cache size is given by this formula:
# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
# corresponding to a cache size of 2^16 = 65536 symbols
SYMBOL_CACHE_SIZE = 0
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
EXTRACT_ALL = NO
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = NO
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
# If set to NO only classes defined in header files are included.
EXTRACT_LOCAL_CLASSES = YES
# This flag is only useful for Objective-C code. When set to YES local
# methods, which are defined in the implementation section but not in
# the interface are included in the documentation.
# If set to NO (the default) only methods in the interface are included.
EXTRACT_LOCAL_METHODS = NO
# If this flag is set to YES, the members of anonymous namespaces will be
# extracted and appear in the documentation as a namespace called
# 'anonymous_namespace{file}', where file will be replaced with the base
# name of the file that contains the anonymous namespace. By default
# anonymous namespace are hidden.
EXTRACT_ANON_NSPACES = NO
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these classes will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
# friend (class|struct|union) declarations.
# If set to NO (the default) these declarations will be included in the
# documentation.
HIDE_FRIEND_COMPOUNDS = NO
# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
# documentation blocks found inside the body of a function.
# If set to NO (the default) these blocks will be appended to the
# function's detailed documentation block.
HIDE_IN_BODY_DOCS = NO
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = NO
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower-case letters. If set to YES upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# and Mac users are advised to set this option to NO.
CASE_SENSE_NAMES = YES
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
HIDE_SCOPE_NAMES = NO
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put a list of the files that are included by a file in the documentation
# of that file.
SHOW_INCLUDE_FILES = YES
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = YES
# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
# brief documentation of file, namespace and class members alphabetically
# by member name. If set to NO (the default) the members will appear in
# declaration order.
SORT_BRIEF_DOCS = NO
# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
# hierarchy of group names into alphabetical order. If set to NO (the default)
# the group names will appear in their defined order.
SORT_GROUP_NAMES = NO
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
# sorted by fully-qualified names, including namespaces. If set to
# NO (the default), the class list will be sorted only by class name,
# not including the namespace part.
# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
# Note: This option applies only to the class list, not to the
# alphabetical list.
SORT_BY_SCOPE_NAME = NO
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = YES
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
GENERATE_TESTLIST = YES
# The GENERATE_BUGLIST tag can be used to enable (YES) or
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
GENERATE_BUGLIST = YES
# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
# disable (NO) the deprecated list. This list is created by putting
# \deprecated commands in the documentation.
GENERATE_DEPRECATEDLIST= YES
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
ENABLED_SECTIONS =
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consists of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and defines in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
MAX_INITIALIZER_LINES = 30
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
SHOW_USED_FILES = YES
# If the sources in your project are distributed over multiple directories
# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
# in the documentation. The default is NO.
SHOW_DIRECTORIES = NO
# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
# This will remove the Files entry from the Quick Index and from the
# Folder Tree View (if specified). The default is YES.
SHOW_FILES = YES
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
# Namespaces page.
# This will remove the Namespaces entry from the Quick Index
# and from the Folder Tree View (if specified). The default is YES.
SHOW_NAMESPACES = YES
# The FILE_VERSION_FILTER tag can be used to specify a program or script that
# doxygen should invoke to get the current version for each file (typically from
# the version control system). Doxygen will invoke the program by executing (via
# popen()) the command <command> <input-file>, where <command> is the value of
# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
# provided by doxygen. Whatever the program writes to standard output
# is used as the file version. See the manual for examples.
FILE_VERSION_FILTER =
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
# doxygen. The layout file controls the global structure of the generated output files
# in an output format independent way. The create the layout file that represents
# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
# file name after the option, if omitted DoxygenLayout.xml will be used as the name
# of the layout file.
LAYOUT_FILE =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
WARNINGS = YES
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
WARN_IF_UNDOCUMENTED = NO
# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as not documenting some
# parameters in a documented function, or documenting parameters that
# don't exist or using markup commands wrongly.
WARN_IF_DOC_ERROR = YES
# This WARN_NO_PARAMDOC option can be abled to get warnings for
# functions that are documented, but have no documentation for their parameters
# or return value. If set to NO (the default) doxygen will only warn about
# wrong or incomplete parameter documentation, but not about the absence of
# documentation.
WARN_NO_PARAMDOC = NO
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
# warning originated and the warning text. Optionally the format may contain
# $version, which will be replaced by the version of the file (if it could
# be obtained via FILE_VERSION_FILTER)
WARN_FORMAT = "$file:$line: $text"
# The WARN_LOGFILE tag can be used to specify a file to which warning
# and error messages should be written. If left blank the output is written
# to stderr.
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = "$(OPENMM_INCLUDE_PATH)/OpenMM.h" \
"$(OPENMM_INCLUDE_PATH)/OpenMMFreeEnergy.h" \
"$(OPENMM_INCLUDE_PATH)/openmm"
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
# also the default input encoding. Doxygen uses libiconv (or the iconv built
# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
# the list of possible encodings.
INPUT_ENCODING = UTF-8
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank the following patterns are tested:
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
FILE_PATTERNS =
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
RECURSIVE = YES
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
# directories that are symbolic links (a Unix filesystem feature) are excluded
# from the input.
EXCLUDE_SYMLINKS = NO
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories. Note that the wildcards are matched
# against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/*
#EXCLUDE_PATTERNS = */tests/* \
# */src/* \
# */.svn/*
EXCLUDE_PATTERNS = */tests/* \
*/.svn/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
# output. The symbol name can be a fully qualified name, a word, or if the
# wildcard * is used, a substring. Examples: ANamespace, AClass,
# AClass::ANamespace, ANamespace::*Test
EXCLUDE_SYMBOLS = StandardMMForceField::*Info \
GBSAOBCForceField::AtomInfo \
System::ConstraintInfo
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude
# commands irrespective of the value of the RECURSIVE tag.
# Possible values are YES and NO. If left blank NO is used.
EXAMPLE_RECURSIVE = NO
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH =
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command <filter> <input-file>, where <filter>
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output.
# If FILTER_PATTERNS is specified, this tag will be
# ignored.
INPUT_FILTER =
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
# basis.
# Doxygen will compare the file name with each pattern and apply the
# filter if there is a match.
# The filters are a list of the form:
# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
# is applied to all files.
FILTER_PATTERNS =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse (i.e. when SOURCE_BROWSER is set to YES).
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
# Note: To get rid of all source code in the generated output, make sure also
# VERBATIM_HEADERS is set to NO.
SOURCE_BROWSER = NO
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
STRIP_CODE_COMMENTS = YES
# If the REFERENCED_BY_RELATION tag is set to YES
# then for each documented function all documented
# functions referencing it will be listed.
REFERENCED_BY_RELATION = NO
# If the REFERENCES_RELATION tag is set to YES
# then for each documented function all documented entities
# called/used by that function will be listed.
REFERENCES_RELATION = NO
# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
# link to the source code.
# Otherwise they will link to the documentation.
REFERENCES_LINK_SOURCE = YES
# If the USE_HTAGS tag is set to YES then the references to source code
# will point to the HTML generated by the htags(1) tool instead of doxygen
# built-in source browser. The htags tool is part of GNU's global source
# tagging system (see http://www.gnu.org/software/global/global.html). You
# will need version 4.8.6 or higher.
USE_HTAGS = NO
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
ALPHABETICAL_INDEX = NO
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
COLS_IN_ALPHA_INDEX = 5
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
# should be ignored while generating the index headers.
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
GENERATE_HTML = YES
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
HTML_OUTPUT = html
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
# doxygen will generate files with .html extension.
HTML_FILE_EXTENSION = .html
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
# standard header.
HTML_HEADER =
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.
HTML_FOOTER =
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet. Note that doxygen will try to copy
# the style sheet file to the HTML output directory, so don't put your own
# stylesheet in the HTML output directory as well, or it will be erased!
HTML_STYLESHEET =
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded. For this to work a browser that supports
# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
HTML_DYNAMIC_SECTIONS = NO
# If the GENERATE_DOCSET tag is set to YES, additional index files
# will be generated that can be used as input for Apple's Xcode 3
# integrated development environment, introduced with OSX 10.5 (Leopard).
# To create a documentation set, doxygen will generate a Makefile in the
# HTML output directory. Running make will produce the docset in that
# directory and running "make install" will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
# it at startup.
# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
GENERATE_DOCSET = NO
# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
# feed. A documentation feed provides an umbrella under which multiple
# documentation sets from a single provider (such as a company or product suite)
# can be grouped.
DOCSET_FEEDNAME = "Doxygen generated docs"
# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
# should uniquely identify the documentation set bundle. This should be a
# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
# will append .docset to the name.
DOCSET_BUNDLE_ID = org.doxygen.Project
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
# of the generated HTML documentation.
GENERATE_HTMLHELP = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
# be used to specify the file name of the resulting .chm file. You
# can add a path in front of the file if the result should not be
# written to the html output directory.
CHM_FILE =
# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
# be used to specify the location (absolute path including file name) of
# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
# the HTML help compiler on the generated index.hhp.
HHC_LOCATION =
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
GENERATE_CHI = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
# is used to encode HtmlHelp index (hhk), content (hhc) and project file
# content.
CHM_INDEX_ENCODING =
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set to YES to add extra items for group members
# to the contents of the HTML help documentation and to the tree view.
TOC_EXPAND = NO
# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
# are set, an additional index file will be generated that can be used as input for
# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
# HTML documentation.
GENERATE_QHP = NO
# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
# be used to specify the file name of the resulting .qch file.
# The path specified is relative to the HTML output folder.
QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#namespace
QHP_NAMESPACE =
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#virtual-folders
QHP_VIRTUAL_FOLDER = doc
# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
# For more information please see
# http://doc.trolltech.com/qthelpproject.html#custom-filters
QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
# filter section matches.
# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
QHP_SECT_FILTER_ATTRS =
# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
# be used to specify the location of Qt's qhelpgenerator.
# If non-empty doxygen will try to run qhelpgenerator on the generated
# .qhp file.
QHG_LOCATION =
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it.
DISABLE_INDEX = NO
# This tag can be used to set the number of enum values (range [1..20])
# that doxygen will group on one line in the generated HTML documentation.
ENUM_VALUES_PER_LINE = 4
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information.
# If the tag value is set to FRAME, a side panel will be generated
# containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
# probably better off using the HTML help feature. Other possible values
# for this tag are: HIERARCHIES, which will generate the Groups, Directories,
# and Class Hierarchy pages using a tree view instead of an ordered list;
# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which
# disables this behavior completely. For backwards compatibility with previous
# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE
# respectively.
GENERATE_TREEVIEW = NONE
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
TREEVIEW_WIDTH = 250
# Use this tag to change the font size of Latex formulas included
# as images in the HTML documentation. The default is 10. Note that
# when you change the font size after a successful doxygen run you need
# to manually remove any form_*.png images from the HTML output directory
# to force them to be regenerated.
FORMULA_FONTSIZE = 10
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
GENERATE_LATEX = NO
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
LATEX_OUTPUT = latex
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked. If left blank `latex' will be used as the default command name.
LATEX_CMD_NAME = latex
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
# generate index for LaTeX. If left blank `makeindex' will be used as the
# default command name.
MAKEINDEX_CMD_NAME = makeindex
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_LATEX = NO
# The PAPER_TYPE tag can be used to set the paper type that is used
# by the printer. Possible values are: a4, a4wide, letter, legal and
# executive. If left blank a4wide will be used.
PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
EXTRA_PACKAGES =
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until
# the first chapter. If it is left blank doxygen will generate a
# standard header. Notice: only use this tag if you know what you are doing!
LATEX_HEADER =
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer.
PDF_HYPERLINKS = YES
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
USE_PDFLATEX = YES
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
# running if errors occur, instead of asking the user for help.
# This option is also used when generating formulas in HTML.
LATEX_BATCHMODE = NO
# If LATEX_HIDE_INDICES is set to YES then doxygen will not
# include the index chapters (such as File Index, Compound Index, etc.)
# in the output.
LATEX_HIDE_INDICES = NO
# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
LATEX_SOURCE_CODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
# The RTF output is optimized for Word 97 and may not look very pretty with
# other RTF readers or editors.
GENERATE_RTF = NO
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `rtf' will be used as the default path.
RTF_OUTPUT = rtf
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
# RTF documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_RTF = NO
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
# will contain hyperlink fields. The RTF file will
# contain links (just like the HTML output) instead of page references.
# This makes the output suitable for online browsing using WORD or other
# programs which support those fields.
# Note: wordpad (write) and others do not support links.
RTF_HYPERLINKS = NO
# Load stylesheet definitions from file. Syntax is similar to doxygen's
# config file, i.e. a series of assignments. You only have to provide
# replacements, missing definitions are set to their default value.
RTF_STYLESHEET_FILE =
# Set optional variables used in the generation of an rtf document.
# Syntax is similar to doxygen's config file.
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
GENERATE_MAN = NO
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
MAN_OUTPUT = man
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
MAN_EXTENSION = .3
# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
# then it will generate one additional man file for each entity
# documented in the real man page(s). These additional files
# only source the real man page, but without them the man command
# would be unable to find the correct page. The default is NO.
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
# If the GENERATE_XML tag is set to YES Doxygen will
# generate an XML file that captures the structure of
# the code including all documentation.
GENERATE_XML = YES
# The XML_OUTPUT tag is used to specify where the XML pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `xml' will be used as the default path.
XML_OUTPUT = xml
# The XML_SCHEMA tag can be used to specify an XML schema,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_SCHEMA =
# The XML_DTD tag can be used to specify an XML DTD,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_DTD =
# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
# dump the program listings (including syntax highlighting
# and cross-referencing information) to the XML output. Note that
# enabling this will significantly increase the size of the XML output.
XML_PROGRAMLISTING = NO
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
# generate an AutoGen Definitions (see autogen.sf.net) file
# that captures the structure of the code including all
# documentation. Note that this feature is still experimental
# and incomplete at the moment.
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
# If the GENERATE_PERLMOD tag is set to YES Doxygen will
# generate a Perl module file that captures the structure of
# the code including all documentation. Note that this
# feature is still experimental and incomplete at the
# moment.
GENERATE_PERLMOD = NO
# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
# the necessary Makefile rules, Perl scripts and LaTeX code to be able
# to generate PDF and DVI output from the Perl module output.
PERLMOD_LATEX = NO
# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
# nicely formatted so it can be parsed by a human reader.
# This is useful
# if you want to understand what is going on.
# On the other hand, if this
# tag is set to NO the size of the Perl module output will be much smaller
# and Perl will parse it just the same.
PERLMOD_PRETTY = YES
# The names of the make variables in the generated doxyrules.make file
# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
# This is useful so different doxyrules.make files included by the same
# Makefile don't overwrite each other's variables.
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
ENABLE_PREPROCESSING = YES
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = NO
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_DEFINED tags.
EXPAND_ONLY_PREDEF = NO
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# in the INCLUDE_PATH (see below) will be search if a #include is found.
SEARCH_INCLUDES = YES
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by
# the preprocessor.
INCLUDE_PATH =
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will
# be used.
INCLUDE_FILE_PATTERNS =
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed. To prevent a macro definition from being
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
PREDEFINED =
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all function-like macros that are alone
# on a line, have an all uppercase name, and do not end with a semicolon. Such
# function macros are typically used for boiler-plate code, and will confuse
# the parser if not removed.
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
# The TAGFILES option can be used to specify one or more tagfiles.
# Optionally an initial location of the external documentation
# can be added for each tagfile. The format of a tag file without
# this location is as follows:
#
# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows:
#
# TAGFILES = file1=loc1 "file2 = loc2" ...
# where "loc1" and "loc2" can be relative or absolute paths or
# URLs. If a location is present for each tag, the installdox tool
# does not have to be run to correct the links.
# Note that each tag file must have a unique name
# (where the name does NOT include the path)
# If a tag file is not located in the directory in which doxygen
# is run, you must also specify the path to the tagfile here.
TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
GENERATE_TAGFILE =
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
# will be listed.
ALLEXTERNALS = NO
# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
# in the modules index. If set to NO, only the current project's groups will
# be listed.
EXTERNAL_GROUPS = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
# or super classes. Setting the tag to NO turns the diagrams off. Note that
# this option is superseded by the HAVE_DOT option below. This is only a
# fallback. It is recommended to install and use dot, since it yields more
# powerful graphs.
CLASS_DIAGRAMS = YES
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see
# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
MSCGEN_PATH =
# If set to YES, the inheritance and collaboration graphs will hide
# inheritance and usage relations if the target is undocumented
# or is not a class.
HIDE_UNDOC_RELATIONS = YES
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = NO
# By default doxygen will write a font called FreeSans.ttf to the output
# directory and reference it in all dot files that doxygen generates. This
# font does not include all possible unicode characters however, so when you need
# these (or just want a differently looking font) you can specify the font name
# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
# which can be done by putting it in a standard location or by setting the
# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
# containing the font.
DOT_FONTNAME = FreeSans
# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
# The default size is 10pt.
DOT_FONTSIZE = 10
# By default doxygen will tell dot to use the output directory to look for the
# FreeSans.ttf font (which doxygen will put there itself). If you specify a
# different font using DOT_FONTNAME you can set the path where dot
# can find it using this tag.
DOT_FONTPATH =
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
# the CLASS_DIAGRAMS tag to NO.
CLASS_GRAPH = YES
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect implementation dependencies (inheritance, containment, and
# class references variables) of the class with other documented classes.
COLLABORATION_GRAPH = YES
# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for groups, showing the direct groups dependencies
GROUP_GRAPHS = YES
# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
UML_LOOK = NO
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
TEMPLATE_RELATIONS = NO
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
# tags are set to YES then doxygen will generate a graph for each documented
# file showing the direct and indirect include dependencies of the file with
# other documented files.
INCLUDE_GRAPH = YES
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
# documented header file showing the documented files that directly or
# indirectly include this file.
INCLUDED_BY_GRAPH = YES
# If the CALL_GRAPH and HAVE_DOT options are set to YES then
# doxygen will generate a call dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable call graphs
# for selected functions only using the \callgraph command.
CALL_GRAPH = NO
# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
# doxygen will generate a caller dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable caller
# graphs for selected functions only using the \callergraph command.
CALLER_GRAPH = NO
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
GRAPHICAL_HIERARCHY = YES
# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
# then doxygen will show the dependencies a directory has on other directories
# in a graphical way. The dependency relations are determined by the #include
# relations between the files in the directories.
DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. Possible values are png, jpg, or gif
# If left blank png will be used.
DOT_IMAGE_FORMAT = png
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found in the path.
DOT_PATH =
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the
# \dotfile command).
DOTFILE_DIRS =
# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
# nodes that will be shown in the graph. If the number of nodes in a graph
# becomes larger than this value, doxygen will truncate the graph, which is
# visualized by representing a node as a red box. Note that doxygen if the
# number of direct children of the root node in a graph is already larger than
# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
DOT_GRAPH_MAX_NODES = 50
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
# graphs generated by dot. A depth value of 3 means that only nodes reachable
# from the root by following a path via at most 3 edges will be shown. Nodes
# that lay further from the root node will be omitted. Note that setting this
# option to 1 or 2 may greatly reduce the computation time needed for large
# code bases. Also note that the size of a graph can be further restricted by
# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
MAX_DOT_GRAPH_DEPTH = 0
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
# background. This is disabled by default, because dot on Windows does not
# seem to support this out of the box. Warning: Depending on the platform used,
# enabling this option may lead to badly anti-aliased labels on the edges of
# a graph (i.e. they become hard to read).
DOT_TRANSPARENT = NO
# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
# files in one run (i.e. multiple -o and -T options on the command line). This
# makes dot run faster, but since only newer versions of dot (>1.8.10)
# support this, this feature is disabled by default.
DOT_MULTI_TARGETS = NO
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermediate dot files that are used to generate
# the various graphs.
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Options related to the search engine
#---------------------------------------------------------------------------
# The SEARCHENGINE tag specifies whether or not a search engine should be
# used. If set to NO the values of all tags below this one will be ignored.
SEARCHENGINE = NO
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment