Commit 58afb4ce authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Started to merge SimpleMatcher with NomadParser

parent 3a5d0ae6
#! /usr/bin/env python
import cp2kparser.generics.logconfig
from pint import UnitRegistry
import os
ureg = UnitRegistry(os.path.dirname(__file__)+"/unit_registry.txt")
# Pint constants for NomadParsers
# source: http://physics.nist.gov/cuu/Constants/Table/allascii.txt
# Source: http://physics.nist.gov/cuu/Constants/Table/allascii.txt
speed_of_light = 299792458 * meter / second = c
standard_gravity = 9.806650 * meter / second ** 2 = g_0 = g_n = gravity
vacuum_permeability = 4 * pi * 1e-7 * newton / ampere ** 2 = mu_0 = magnetic_constant
vacuum_permittivity = 1 / (mu_0 * c **2 ) = epsilon_0 = electric_constant
Z_0 = mu_0 * c = impedance_of_free_space = characteristic_impedance_of_vacuum
bohr = 0.52917721067e-10 m
# 0.000 000 29 e-34
planck_constant = 6.62606957e-34 J s = h
hbar = planck_constant / (2 * pi) = ħ
# 0.000 80 e-11
newtonian_constant_of_gravitation = 6.67384e-11 m^3 kg^-1 s^-2
# 0.000 000 035 e-19
# elementary_charge = 1.602176565e-19 C = e
# 0.000 0075
molar_gas_constant = 8.3144621 J mol^-1 K^-1 = R
# 0.000 000 0024 e-3
fine_structure_constant = 7.2973525698e-3
# 0.000 000 27 e23
avogadro_number = 6.02214129e23 mol^-1 =N_A
# 0.000 0013 e-23
boltzmann_constant = 1.3806488e-23 J K^-1 = k
# 0.000 021 e-8
stefan_boltzmann_constant = 5.670373e-8 W m^-2 K^-4 = σ
# 0.000 0053 e10
wien_frequency_displacement_law_constant = 5.8789254e10 Hz K^-1
# 0.000 055
rydberg_constant = 10973731.568539 m^-1
# 0.000 000 40 e-31
electron_mass = 9.10938291e-31 kg = m_e
# 0.000 000 074 e-27
neutron_mass = 1.674927351e-27 kg = m_n
# 0.000 000 074 e-27
proton_mass = 1.672621777e-27 kg = m_p
This diff is collapsed.
......@@ -29,9 +29,10 @@ def scan_path_for_files(path):
#===============================================================================
def get_parser(path, test_mode=True, stream=sys.stdout):
files = scan_path_for_files(path)
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../nomad-meta-info/meta_info/nomad_meta_info/cp2k.nomadmetainfo.json"))
json_input = {
"version": "nomadparsein.json 1.0",
"metaInfoFile": os.path.join(os.path.dirname(__file__), 'metainfo.json'),
"metaInfoFile": metaInfoPath,
"tmpDir": "/home",
"metainfoToKeep": [],
"metainfoToSkip": [],
......@@ -45,4 +46,4 @@ def get_parser(path, test_mode=True, stream=sys.stdout):
if __name__ == '__main__':
path = os.path.dirname(os.path.realpath(os.path.dirname(__file__)))
parser = get_parser(path)
parser.parse_all()
parser.parse()
This diff is collapsed.
import os
import re2 as re
from cp2kparser.generics.nomadparser import NomadParser, Result, ResultCode
from cp2kparser.generics.nomadparser import NomadParser
from cp2kparser.implementation.regexs import *
from cp2kparser.engines.regexengine import RegexEngine
from cp2kparser.engines.csvengine import CSVEngine
......@@ -8,6 +8,7 @@ from cp2kparser.engines.cp2kinputengine import CP2KInputEngine
from cp2kparser.engines.xmlengine import XMLEngine
from nomadcore.coordinate_reader import CoordinateReader
from nomadcore.unit_conversion.unit_conversion import convert_unit, ureg
from nomadcore.simple_parser import SimpleMatcher as SM
from cp2kparser.engines.cp2kinputenginedata.input_tree import CP2KInput
import numpy as np
import logging
......@@ -43,26 +44,14 @@ class CP2KParser(NomadParser):
self.regexs = None
self.extended_input = None
# Use some convenient functions from base
self.determine_file_ids_pre_setup()
self.input_preprocessor()
self.setup_version()
self.determine_file_ids_post_setup()
def get_supported_quantities(self):
"""Inherited from NomadParser.
"""
supported_quantities = []
implementation_methods = [method for method in dir(self.implementation) if callable(getattr(self.implementation, method))]
for method in implementation_methods:
if method.startswith("_Q_"):
method = method[3:]
supported_quantities.append(method)
return supported_quantities
def setup_version(self):
"""Inherited from NomadParser.
"""Setups the version by looking at the output file and the version
specified in it.
"""
# Determine the CP2K version from the output file
beginning = self.read_part_of_file("output", 2048)
......@@ -92,23 +81,13 @@ class CP2KParser(NomadParser):
logger.debug("Using default implementation.")
self.implementation = globals()["CP2KImplementation"](self)
def start_parsing(self, name):
"""Inherited from NomadParser.
"""
# Ask the implementation for the quantity
function = getattr(self.implementation, "_Q_" + name)
if function:
return function()
else:
logger.error("The function for quantity '{}' is not defined".format(name))
def read_part_of_file(self, file_id, size=1024):
fh = self.get_file_handle(file_id)
buffer = fh.read(size)
return buffer
def input_preprocessor(self):
"""Preprocess the input file. Concatenate separate files into one and
"""Preprocess the input file. Concatenate .inc files into the main input file and
explicitly state all variables.
"""
......@@ -185,11 +164,6 @@ class CP2KParser(NomadParser):
rest = new_line[offset+end:]
new_line = beginning + value + rest
offset += len_value - len_name - 1
# print offset
# print "BEG:" + beginning
# print "VALUE:" + value
# print "REST: " + rest
# print new_line
input_variables_replaced.append(new_line)
self.extended_input = '\n'.join(input_variables_replaced)
......@@ -218,7 +192,8 @@ class CP2KParser(NomadParser):
self.setup_file_id(filepath, "include")
def determine_file_ids_post_setup(self):
"""Inherited from NomadParser.
"""Determines the file id's after the CP2K verion has been set
up.
"""
# Determine the presence of force file
force_path = self.input_tree.get_keyword("FORCE_EVAL/PRINT/FORCES/FILENAME")
......@@ -337,10 +312,35 @@ class CP2KParser(NomadParser):
break
return folders
def get_all_quantities(self):
"""Parse all supported quantities."""
for method in self.get_supported_quantities:
self.get_quantity(method)
def parse(self):
self.implementation.parse()
# def get_all_quantities(self):
# """Parse all supported quantities."""
# for method in self.get_supported_quantities:
# self.get_quantity(method)
# def start_parsing(self, name):
# """Inherited from NomadParser.
# """
# # Ask the implementation for the quantity
# function = getattr(self.implementation, "_Q_" + name)
# if function:
# return function()
# else:
# logger.error("The function for quantity '{}' is not defined".format(name))
# def get_supported_quantities(self):
# """Inherited from NomadParser.
# """
# supported_quantities = []
# implementation_methods = [method for method in dir(self.implementation) if callable(getattr(self.implementation, method))]
# for method in implementation_methods:
# if method.startswith("_Q_"):
# method = method[3:]
# supported_quantities.append(method)
# return supported_quantities
#===============================================================================
......@@ -363,6 +363,58 @@ class CP2KImplementation(object):
self.atomsengine = parser.atomsengine
self.input_tree = parser.input_tree
# Define the output parsing tree for this version
self.outputstructure = SM(
name='root',
startReStr="",
subMatchers=[
SM(
name='new_run',
startReStr=r" DBCSR\| Multiplication driver",
endReStr="[.\*]+PROGRAM STOPPED IN",
required=True,
sections=['section_run'],
subMatchers=[
SM(
name="run_datetime",
startReStr=r"[\*\s]+PROGRAM STARTED AT\s+(?P<cp2k_run_start_date>\d{4}-\d{2}-\d{2}) (?P<cp2k_run_start_time>\d{2}:\d{2}:\d{2}.\d{3})",
),
SM(
name="version",
startReStr=r" CP2K\| version string:\s+(?P<program_version>[\w\d\W\s]+)",
),
SM(
name="svn_revision",
startReStr=r" CP2K\| source code revision number:\s+svn:(?P<cp2k_svn_revision>\d+)",
)
]
)
]
)
def parse(self):
"""Parses everything that can be found from the given files. The
results are outputted to std.out by using the backend. The scala layer
will the take on from that.
"""
# Write the starting bracket
self.parser.stream.write("[")
# Use the SimpleMatcher to extract most of the results
parserInfo = {"name": "cp2k-parser", "version": "1.0"}
outputfilename = self.parser.get_file_handle("output").name
metainfoenv = self.parser.metainfoenv
backend = self.parser.backend
outputstructure = self.outputstructure
self.parser.parse_file(outputfilename, outputstructure, metainfoenv, backend, parserInfo)
# Then extract the things that cannot be extracted by the SimpleMatcher
# Write the ending bracket
self.parser.stream.write("]\n")
# def dateconverter(datestring):
def _Q_energy_total(self):
"""Return the total energy from the bottom of the input file"""
result = Result()
......
......@@ -9,10 +9,10 @@
DBCSR| Communication thread load 87
**** **** ****** ** PROGRAM STARTED AT 2015-12-11 13:23:01.535
**** **** ****** ** PROGRAM STARTED AT 2015-12-17 15:46:27.167
***** ** *** *** ** PROGRAM STARTED ON lauri-Lenovo-Z50-70
** **** ****** PROGRAM STARTED BY lauri
***** ** ** ** ** PROGRAM PROCESS ID 6042
***** ** ** ** ** PROGRAM PROCESS ID 4844
**** ** ******* ** PROGRAM STARTED IN /home/lauri/Dropbox/nomad-dev/gitlab/
parser-cp2k/cp2kparser/tests/cp2k_2.6
.2/functionals/lda
......@@ -46,12 +46,12 @@
MEMORY| system memory details [Kb]
MEMORY| rank 0 min max average
MEMORY| MemTotal 8070392 8070392 8070392 8070392
MEMORY| MemFree 4240172 4240172 4240172 4240172
MEMORY| Buffers 198080 198080 198080 198080
MEMORY| Cached 1678908 1678908 1678908 1678908
MEMORY| Slab 185560 185560 185560 185560
MEMORY| SReclaimable 147440 147440 147440 147440
MEMORY| MemLikelyFree 6264600 6264600 6264600 6264600
MEMORY| MemFree 1865648 1865648 1865648 1865648
MEMORY| Buffers 696732 696732 696732 696732
MEMORY| Cached 2894484 2894484 2894484 2894484
MEMORY| Slab 690424 690424 690424 690424
MEMORY| SReclaimable 647708 647708 647708 647708
MEMORY| MemLikelyFree 6104572 6104572 6104572 6104572
*** Fundamental physical constants (SI units) ***
......@@ -440,7 +440,7 @@
Total charge density on r-space grids: -0.0036805695
Total charge density g-space grids: -0.0036805695
1 P_Mix/Diag. 0.40E+00 0.1 0.74330726 -3.7598777522 -3.76E+00
1 P_Mix/Diag. 0.40E+00 0.0 0.74330726 -3.7598777522 -3.76E+00
Trace(PS): 4.0000000000
Electronic density on regular grids: -3.9998298977 0.0001701023
......@@ -1306,13 +1306,13 @@
ROUTINE CALLS TOT TIME [s] AVE VOLUME [Bytes] PERFORMANCE [MB/s]
MP_Group 3 0.000
MP_Bcast 102 0.009 4. 0.05
MP_Allreduce 1170 0.001 8. 12.58
MP_Bcast 102 0.000 4. 1.72
MP_Allreduce 1170 0.001 8. 18.12
MP_Sync 2 0.000
MP_Alltoall 2316 0.002 522. 750.18
MP_Alltoall 2316 0.001 522. 877.41
MP_Wait 2424 0.001
MP_ISend 808 0.002 228. 101.12
MP_IRecv 808 0.000 228. 379.36
MP_ISend 808 0.001 228. 131.63
MP_IRecv 808 0.000 228. 452.67
MP_Memory 2424 0.001
-------------------------------------------------------------------------------
......@@ -1384,62 +1384,50 @@
-------------------------------------------------------------------------------
SUBROUTINE CALLS ASD SELF TIME TOTAL TIME
MAXIMUM AVERAGE MAXIMUM AVERAGE MAXIMUM
CP2K 1 1.0 0.098 0.098 1.488 1.488
qs_forces 1 2.0 0.019 0.019 0.984 0.984
qs_energies_scf 1 3.0 0.021 0.021 0.962 0.962
scf_env_do_scf 1 4.0 0.000 0.000 0.694 0.694
scf_env_do_scf_inner_loop 100 5.0 0.011 0.011 0.693 0.693
rebuild_ks_matrix 101 7.0 0.000 0.000 0.333 0.333
qs_ks_build_kohn_sham_matrix 101 8.0 0.012 0.012 0.333 0.333
qs_ks_update_qs_env 100 6.0 0.001 0.001 0.332 0.332
quickstep_create_force_env 1 2.0 0.033 0.033 0.298 0.298
fft3d_s 608 12.0 0.127 0.127 0.259 0.259
fft_wrap_pw1pw2 607 10.0 0.003 0.003 0.215 0.215
fft_wrap_pw1pw2_30 405 10.7 0.010 0.010 0.199 0.199
qs_rho_update_rho 101 6.0 0.000 0.000 0.164 0.164
calculate_rho_elec 101 7.0 0.067 0.067 0.164 0.164
sum_up_and_integrate 101 9.0 0.003 0.003 0.153 0.153
integrate_v_rspace 101 10.0 0.085 0.085 0.150 0.150
qs_init_subsys 1 3.0 0.053 0.053 0.139 0.139
get_fft_scratch 608 13.0 0.132 0.132 0.132 0.132
init_scf_run 1 4.0 0.001 0.001 0.121 0.121
density_rs2pw 101 8.0 0.001 0.001 0.095 0.095
qs_vxc_create 101 9.0 0.001 0.001 0.092 0.092
xc_vxc_pw_create 101 10.0 0.009 0.009 0.090 0.090
qs_energies_init_hamiltonians 1 4.0 0.001 0.001 0.090 0.090
xc_rho_set_and_dset_create 101 11.0 0.002 0.002 0.081 0.081
xc_functional_eval 101 12.0 0.077 0.077 0.077 0.077
create_qs_kind_set 1 3.0 0.000 0.000 0.074 0.074
read_qs_kind 1 4.0 0.039 0.039 0.074 0.074
scf_env_initial_rho_setup 1 5.0 0.002 0.002 0.073 0.073
calculate_first_density_matrix 1 6.0 0.000 0.000 0.068 0.068
calculate_atomic_block_dm 1 7.0 0.024 0.024 0.068 0.068
calculate_dm_sparse 100 6.0 0.000 0.000 0.067 0.067
cp_dbcsr_plus_fm_fm_t_native 101 7.0 0.002 0.002 0.067 0.067
potential_pw2rs 101 11.0 0.001 0.001 0.059 0.059
eigensolver 100 6.0 0.000 0.000 0.058 0.058
qs_env_update_s_mstruct 1 5.0 0.002 0.002 0.052 0.052
topology_control 1 3.0 0.018 0.018 0.051 0.051
dbcsr_mm_cannon_multiply 101 8.0 0.004 0.004 0.049 0.049
qs_env_setup 1 4.0 0.000 0.000 0.048 0.048
calculate_rho_core 1 6.0 0.009 0.009 0.046 0.046
cp_fm_cholesky_decompose 1 5.0 0.046 0.046 0.046 0.046
qs_diis_b_step 99 6.0 0.001 0.001 0.044 0.044
build_core_hamiltonian_matrix 1 5.0 0.011 0.011 0.036 0.036
parser_read_line 3297 5.0 0.001 0.001 0.036 0.036
cp_fm_syevd 100 7.0 0.000 0.000 0.035 0.035
cp_fm_syevd_base 100 8.0 0.035 0.035 0.035 0.035
parser_read_line_low 4 6.0 0.034 0.034 0.034 0.034
scf_post_calculation_gpw 1 4.0 0.000 0.000 0.034 0.034
write_available_results 1 5.0 0.033 0.033 0.034 0.034
qs_env_rebuild_pw_env 3 3.7 0.000 0.000 0.032 0.032
pw_env_rebuild 1 6.0 0.014 0.014 0.032 0.032
CP2K 1 1.0 0.002 0.002 0.583 0.583
qs_forces 1 2.0 0.000 0.000 0.557 0.557
qs_energies_scf 1 3.0 0.000 0.000 0.554 0.554
scf_env_do_scf 1 4.0 0.000 0.000 0.539 0.539
scf_env_do_scf_inner_loop 100 5.0 0.007 0.007 0.538 0.538
rebuild_ks_matrix 101 7.0 0.000 0.000 0.284 0.284
qs_ks_build_kohn_sham_matrix 101 8.0 0.008 0.008 0.284 0.284
qs_ks_update_qs_env 100 6.0 0.000 0.000 0.283 0.283
fft_wrap_pw1pw2 607 10.0 0.002 0.002 0.165 0.165
fft_wrap_pw1pw2_30 405 10.7 0.008 0.008 0.152 0.152
qs_rho_update_rho 101 6.0 0.000 0.000 0.147 0.147
calculate_rho_elec 101 7.0 0.057 0.057 0.146 0.146
sum_up_and_integrate 101 9.0 0.002 0.002 0.132 0.132
integrate_v_rspace 101 10.0 0.076 0.076 0.130 0.130
fft3d_s 608 12.0 0.102 0.102 0.112 0.112
density_rs2pw 101 8.0 0.001 0.001 0.088 0.088
qs_vxc_create 101 9.0 0.001 0.001 0.078 0.078
xc_vxc_pw_create 101 10.0 0.009 0.009 0.077 0.077
xc_rho_set_and_dset_create 101 11.0 0.001 0.001 0.068 0.068
xc_functional_eval 101 12.0 0.065 0.065 0.065 0.065
calculate_dm_sparse 100 6.0 0.000 0.000 0.056 0.056
cp_dbcsr_plus_fm_fm_t_native 101 7.0 0.001 0.001 0.055 0.055
potential_pw2rs 101 11.0 0.001 0.001 0.049 0.049
dbcsr_mm_cannon_multiply 101 8.0 0.004 0.004 0.041 0.041
quickstep_create_force_env 1 2.0 0.000 0.000 0.023 0.023
dbcsr_complete_redistribute 302 9.0 0.010 0.010 0.023 0.023
copy_dbcsr_to_fm 400 7.0 0.003 0.003 0.022 0.022
pw_gather_s 304 12.0 0.021 0.021 0.021 0.021
pw_poisson_solve 101 9.0 0.016 0.016 0.021 0.021
pw_scatter_s 303 12.0 0.020 0.020 0.020 0.020
qs_diis_b_step 99 6.0 0.001 0.001 0.017 0.017
create_qs_kind_set 1 3.0 0.000 0.000 0.014 0.014
read_qs_kind 1 4.0 0.008 0.008 0.014 0.014
eigensolver 100 6.0 0.000 0.000 0.014 0.014
pw_copy 606 10.8 0.013 0.013 0.013 0.013
dbcsr_finalize 726 10.0 0.002 0.002 0.012 0.012
dbcsr_make_images 202 9.0 0.000 0.000 0.012 0.012
make_images 202 10.0 0.002 0.002 0.012 0.012
-------------------------------------------------------------------------------
**** **** ****** ** PROGRAM ENDED AT 2015-12-11 13:23:03.786
**** **** ****** ** PROGRAM ENDED AT 2015-12-17 15:46:27.824
***** ** *** *** ** PROGRAM RAN ON lauri-Lenovo-Z50-70
** **** ****** PROGRAM RAN BY lauri
***** ** ** ** ** PROGRAM PROCESS ID 6042
***** ** ** ** ** PROGRAM PROCESS ID 4844
**** ** ******* ** PROGRAM STOPPED IN /home/lauri/Dropbox/nomad-dev/gitlab/
parser-cp2k/cp2kparser/tests/cp2k_2.6
.2/functionals/lda
# NomadParser Pint units definition file
# Based on the International System of Units
# decimal prefixes
yocto- = 1e-24 = y-
zepto- = 1e-21 = z-
atto- = 1e-18 = a-
femto- = 1e-15 = f-
pico- = 1e-12 = p-
nano- = 1e-9 = n-
micro- = 1e-6 = u- = µ-
milli- = 1e-3 = m-
centi- = 1e-2 = c-
deci- = 1e-1 = d-
deca- = 1e+1 = da-
hecto- = 1e2 = h-
kilo- = 1e3 = k-
mega- = 1e6 = M-
giga- = 1e9 = G-
tera- = 1e12 = T-
peta- = 1e15 = P-
exa- = 1e18 = E-
zetta- = 1e21 = Z-
yotta- = 1e24 = Y-
# binary_prefixes
kibi- = 2**10 = Ki-
mebi- = 2**20 = Mi-
gibi- = 2**30 = Gi-
tebi- = 2**40 = Ti-
pebi- = 2**50 = Pi-
exbi- = 2**60 = Ei-
zebi- = 2**70 = Zi-
yobi- = 2**80 = Yi-
# SI units
meter = [length] = m = metre
second = [time] = s = sec
ampere = [current] = A = amp
candela = [luminosity] = cd = candle
kilogram = [mass] = kg
mole = [substance] = mol
kelvin = [temperature]; offset: 0 = K = degK
@import constants.txt
# Acceleration
[acceleration] = [length] / [time] ** 2
# Angle
radian = [] = rad
turn = 2 * pi * radian = revolution = cycle = circle
degree = pi / 180 * radian = deg = arcdeg = arcdegree = angular_degree
arcminute = arcdeg / 60 = arcmin = arc_minute = angular_minute
arcsecond = arcmin / 60 = arcsec = arc_second = angular_second
steradian = radian ** 2 = sr
# Area
[area] = [length] ** 2
are = 100 * m**2
barn = 1e-28 * m ** 2 = b
cmil = 5.067075e-10 * m ** 2 = circular_mils
darcy = 9.869233e-13 * m ** 2
acre = 4046.8564224 * m ** 2 = international_acre
hectare = 100 * are = ha
US_survey_acre = 160 * rod ** 2
# Electromagetism
esu = 1 * erg**0.5 * centimeter**0.5 = statcoulombs = statC = franklin = Fr
esu_per_second = 1 * esu / second = statampere
ampere_turn = 1 * A
gilbert = 10 / (4 * pi ) * ampere_turn
coulomb = ampere * second = C
volt = joule / coulomb = V
farad = coulomb / volt = F
ohm = volt / ampere = Ω
siemens = ampere / volt = S = mho
weber = volt * second = Wb
tesla = weber / meter ** 2 = T
henry = weber / ampere = H
elementary_charge = 1.602176487e-19 * coulomb = e
chemical_faraday = 9.64957e4 * coulomb
physical_faraday = 9.65219e4 * coulomb
faraday = 96485.3399 * coulomb = C12_faraday
gamma = 1e-9 * tesla
gauss = 1e-4 * tesla
maxwell = 1e-8 * weber = mx
oersted = 1000 / (4 * pi) * A / m = Oe
statfarad = 1.112650e-12 * farad = statF = stF
stathenry = 8.987554e11 * henry = statH = stH
statmho = 1.112650e-12 * siemens = statS = stS
statohm = 8.987554e11 * ohm
statvolt = 2.997925e2 * volt = statV = stV
unit_pole = 1.256637e-7 * weber
# Energy
[energy] = [force] * [length]
joule = newton * meter = J
erg = dyne * centimeter
btu = 1.05505585262e3 * joule = Btu = BTU = british_thermal_unit
electron_volt = 1.60217653e-19 * J = eV
quadrillion_btu = 10**15 * btu = quad
thm = 100000 * BTU = therm = EC_therm
cal = 4.184 * joule = calorie = thermochemical_calorie
international_steam_table_calorie = 4.1868 * joule
ton_TNT = 4.184e9 * joule = tTNT
US_therm = 1.054804e8 * joule
watt_hour = watt * hour = Wh = watthour
hartree = 4.35974394e-18 * joule = E_h = hartree_energy
rydberg = h * c * rydberg_constant
# Force
[force] = [mass] * [acceleration]
force_au = hartree / bohr
newton = kilogram * meter / second ** 2 = N
dyne = gram * centimeter / second ** 2 = dyn
force_kilogram = g_0 * kilogram = kgf = kilogram_force = pond
force_gram = g_0 * gram = gf = gram_force
force_ounce = g_0 * ounce = ozf = ounce_force
force_pound = g_0 * lb = lbf = pound_force
force_ton = 2000 * force_pound = ton_force
poundal = lb * feet / second ** 2 = pdl
kip = 1000*lbf
# Frequency
[frequency] = 1 / [time]
hertz = 1 / second = Hz = rps
revolutions_per_minute = revolution / minute = rpm
counts_per_second = count / second = cps
# Heat
#RSI = degK * meter ** 2 / watt
#clo = 0.155 * RSI = clos
#R_value = foot ** 2 * degF * hour / btu
# Information
bit = []
byte = 8 * bit = Bo = octet
baud = bit / second = Bd = bps
# Irradiance
peak_sun_hour = 1000 * watt_hour / meter**2 = PSH
langley = thermochemical_calorie / centimeter**2 = Langley
# Length
angstrom = 1e-10 * meter = Å = ångström = Å
inch = 2.54 * centimeter = in = international_inch = inches = international_inches
foot = 12 * inch = ft = international_foot = feet = international_feet
mile = 5280 * foot = mi = international_mile
yard = 3 * feet = yd = international_yard
mil = inch / 1000 = thou
parsec = 3.08568025e16 * meter = pc
light_year = speed_of_light * julian_year = ly = lightyear
astronomical_unit = 149597870691 * meter = au
nautical_mile = 1.852e3 * meter = nmi
printers_point = 127 * millimeter / 360 = point
printers_pica = 12 * printers_point = pica
US_survey_foot = 1200 * meter / 3937
US_survey_yard = 3 * US_survey_foot
US_survey_mile = 5280 * US_survey_foot = US_statute_mile
rod = 16.5 * US_survey_foot = pole = perch
furlong = 660 * US_survey_foot
fathom = 6 * US_survey_foot
chain = 66 * US_survey_foot
barleycorn = inch / 3
arpentlin = 191.835 * feet
kayser = 1 / centimeter = wavenumber
# Mass
dram = oz / 16 = dr = avoirdupois_dram
ounce = 28.349523125 * gram = oz = avoirdupois_ounce
pound = 0.45359237 * kilogram = lb = avoirdupois_pound
stone = 14 * lb = st
carat = 200 * milligram
grain = 64.79891 * milligram = gr
long_hundredweight = 112 * lb
short_hundredweight = 100 * lb
metric_ton = 1000 * kilogram = t = tonne
pennyweight = 24 * gram = dwt
slug = 14.59390 * kilogram
troy_ounce = 480 * grain = toz = apounce = apothecary_ounce
troy_pound = 12 * toz = tlb = appound = apothecary_pound
drachm = 60 * grain = apdram = apothecary_dram
atomic_mass_unit = 1.660538782e-27 * kilogram = u = amu = dalton = Da
scruple = 20 * grain
bag = 94 * lb
ton = 2000 * lb = short_ton
# Textile
denier = gram / (9000 * meter)
tex = gram/ (1000 * meter)
dtex = decitex
# Photometry
lumen = candela * steradian = lm
lux = lumen / meter ** 2 = lx
# Power
[power] = [energy] / [time]
watt = joule / second = W = volt_ampere = VA
horsepower = 33000 * ft * lbf / min = hp = UK_horsepower = British_horsepower
boiler_horsepower = 33475 * btu / hour
metric_horsepower = 75 * force_kilogram * meter / second
electric_horsepower = 746 * watt
hydraulic_horsepower = 550 * feet * lbf / second
refrigeration_ton = 12000 * btu / hour = ton_of_refrigeration