diff --git a/DESCRIPTION b/DESCRIPTION index 4442bd0..593ba44 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: common Type: Package Title: chepec common -Version: 0.0.0.9006 +Version: 0.0.0.9007 Description: Commonly used functions and scripts. Authors@R: person("Taha", "Ahmed", email = "taha@chepec.se", role = c("aut", "cre")) License: GPL-3 diff --git a/NAMESPACE b/NAMESPACE index 74a7225..31425bb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -21,11 +21,13 @@ export(int2padstr) export(is.wholenumber) export(molarity2mass) export(numbers2words) +export(pascal2torr) export(potentials.as.SHE) export(roundup) export(simpleCap) export(siunitx.uncertainty) export(thth2d) +export(torr2pascal) export(trapz) export(wavelength2num) export(wavenum2length) diff --git a/R/data.R b/R/data.R new file mode 100644 index 0000000..7780215 --- /dev/null +++ b/R/data.R @@ -0,0 +1,18 @@ +#' @name vapourwater +#' @title Vapour pressure and other saturation properties of water +#' @description A dataset summarising vapour pressure, enthalpy of vapourisation, +#' and surface tension of water from 0.01 Celsius to 373.95 Celsius. +#' Data as accepted by the International Association for the Properties +#' of Water and Steam for general scientific use. +#' Source: CRC handbook, 94th ed., table 6-10-90, Eric W. Lemmon. +#' @docType data +#' @format A data frame with 189 rows and 4 variables: +#' \describe{ +#' \item{temperature}{temperature/celsius} +#' \item{pressure}{pressure/kilopascal} +#' \item{enthalpy}{enthalpy of vapourisation/kilojoule per kilogram} +#' \item{surfacetension}{surface tension/millinewton per metre} +#' } +#' @source Handbook of Chemistry and Physics, 94th ed., 6-10-90, Eric W. Lemmon. +#' @author Taha Ahmed +NULL diff --git a/R/unit-converters.R b/R/unit-converters.R index 901db16..5e99865 100644 --- a/R/unit-converters.R +++ b/R/unit-converters.R @@ -53,7 +53,7 @@ wavelength2num <- function(wavelength) { #' #' @param wavenumber number or vector of numbers #' -#' @return number ofr vector +#' @return number or vector #' @export wavenum2length <- function(wavenumber) { wavelength <- @@ -62,6 +62,37 @@ wavenum2length <- function(wavenumber) { } +#' Convert Pascal to Torr +#' +#' @param pascal numeric (note: please supply Pa, not kPa) +#' +#' @return torr, numeric +#' @export +pascal2torr <- function(pascal) { + # 1 Pascal == newton per square metre == kg per metre second squared + # 1 Torr == 1/760 atm + # 1 atm == 101325 Pascal + torr <- pascal / 101325 * 760 + return(torr) +} + + +#' Convert Torr to Pascal +#' +#' @param torr numeric +#' +#' @return pascal, numeric (note returns Pa, not kPa) +#' @export +torr2pascal <- function(torr) { + # 1 Pascal == newton per square metre == kg per metre second squared + # 1 Torr == 1/760 atm + # 1 atm == 101325 Pascal + # torr <- pascal / 101325 * 760 + pascal <- torr * 101325 / 760 + return(pascal) +} + + #' Convert from radians to degrees #' #' @param radians numeric diff --git a/README b/README new file mode 100644 index 0000000..49bad9c --- /dev/null +++ b/README @@ -0,0 +1,4 @@ +A collection of general functions and data + +Includes common numerical functions, unit converters, +some LaTeX-specific functions, as well as reference data. diff --git a/data/vapourwater.csv b/data/vapourwater.csv new file mode 100644 index 0000000..65c5364 --- /dev/null +++ b/data/vapourwater.csv @@ -0,0 +1,190 @@ +"T/degreeCelsius","P/kPa","dvapH/kJ kg-1","surface tension/mN m-1" +0.01,0.61165,2500.9,75.65 +2,0.70599,2496.2,75.37 +4,0.81355,2491.4,75.08 +6,0.93536,2486.7,74.8 +8,1.073,2481.9,74.51 +10,1.2282,2477.2,74.22 +12,1.4028,2472.5,73.93 +14,1.599,2467.7,73.63 +16,1.8188,2463,73.34 +18,2.0647,2458.3,73.04 +20,2.3393,2453.5,72.74 +22,2.6453,2448.8,72.43 +24,2.9858,2444,72.13 +25,3.1699,2441.7,71.97 +26,3.3639,2439.3,71.82 +28,3.7831,2434.6,71.51 +30,4.247,2429.8,71.19 +32,4.7596,2425.1,70.88 +34,5.3251,2420.3,70.56 +36,5.9479,2415.5,70.24 +38,6.6328,2410.8,69.92 +40,7.3849,2406,69.6 +42,8.2096,2401.2,69.27 +44,9.1124,2396.4,68.94 +46,10.099,2391.6,68.61 +48,11.177,2386.8,68.28 +50,12.352,2381.9,67.94 +52,13.631,2377.1,67.61 +54,15.022,2372.3,67.27 +56,16.533,2367.4,66.93 +58,18.171,2362.5,66.58 +60,19.946,2357.7,66.24 +62,21.867,2352.8,65.89 +64,23.943,2347.8,65.54 +66,26.183,2342.9,65.19 +68,28.599,2338,64.84 +70,31.201,2333,64.48 +72,34,2328.1,64.12 +74,37.009,2323.1,63.76 +76,40.239,2318.1,63.4 +78,43.703,2313,63.04 +80,47.414,2308,62.67 +82,51.387,2302.9,62.31 +84,55.635,2297.9,61.94 +86,60.173,2292.8,61.56 +88,65.017,2287.6,61.19 +90,70.182,2282.5,60.82 +92,75.684,2277.3,60.44 +94,81.541,2272.1,60.06 +96,87.771,2266.9,59.68 +98,94.39,2261.7,59.3 +100,101.42,2256.4,58.91 +102,108.87,2251.1,58.53 +104,116.78,2245.8,58.14 +106,125.15,2240.4,57.75 +108,134.01,2235.1,57.36 +110,143.38,2229.6,56.96 +112,153.28,2224.2,56.57 +114,163.74,2218.7,56.17 +116,174.77,2213.2,55.77 +118,186.41,2207.7,55.37 +120,198.67,2202.1,54.97 +122,211.59,2196.5,54.56 +124,225.18,2190.9,54.16 +126,239.47,2185.2,53.75 +128,254.5,2179.5,53.34 +130,270.28,2173.7,52.93 +132,286.85,2167.9,52.52 +134,304.23,2162.1,52.11 +136,322.45,2156.2,51.69 +138,341.54,2150.3,51.27 +140,361.54,2144.3,50.86 +142,382.47,2138.3,50.44 +144,404.37,2132.2,50.01 +146,427.26,2126.1,49.59 +148,451.18,2119.9,49.17 +150,476.16,2113.7,48.74 +152,502.25,2107.5,48.31 +154,529.46,2101.2,47.89 +156,557.84,2094.8,47.46 +158,587.42,2088.4,47.02 +160,618.23,2082,46.59 +162,650.33,2075.5,46.16 +164,683.73,2068.9,45.72 +166,718.48,2062.3,45.28 +168,754.62,2055.6,44.85 +170,792.19,2048.8,44.41 +172,831.22,2042,43.97 +174,871.76,2035.1,43.52 +176,913.84,2028.2,43.08 +178,957.51,2021.2,42.64 +180,1002.8,2014.2,42.19 +182,1049.8,2007,41.74 +184,1098.5,1999.8,41.3 +186,1148.9,1992.6,40.85 +188,1201.1,1985.3,40.4 +190,1255.2,1977.9,39.95 +192,1311.2,1970.4,39.49 +194,1369.1,1962.8,39.04 +196,1429,1955.2,38.59 +198,1490.9,1947.5,38.13 +200,1554.9,1939.7,37.67 +202,1621,1931.9,37.22 +204,1689.3,1923.9,36.76 +206,1759.8,1915.9,36.3 +208,1832.6,1907.8,35.84 +210,1907.7,1899.6,35.38 +212,1985.1,1891.4,34.92 +214,2065,1883,34.46 +216,2147.3,1874.6,33.99 +218,2232.2,1866,33.53 +220,2319.6,1857.4,33.07 +222,2409.6,1848.6,32.6 +224,2502.3,1839.8,32.14 +226,2597.8,1830.9,31.67 +228,2696,1821.8,31.2 +230,2797.1,1812.7,30.74 +232,2901,1803.5,30.27 +234,3008,1794.1,29.8 +236,3117.9,1784.7,29.33 +238,3230.8,1775.1,28.86 +240,3346.9,1765.4,28.39 +242,3466.2,1755.6,27.92 +244,3588.7,1745.7,27.45 +246,3714.5,1735.6,26.98 +248,3843.6,1725.5,26.51 +250,3976.2,1715.2,26.04 +252,4112.2,1704.7,25.57 +254,4251.8,1694.2,25.1 +256,4394.9,1683.5,24.63 +258,4541.7,1672.6,24.16 +260,4692.3,1661.6,23.69 +262,4846.6,1650.5,23.22 +264,5004.7,1639.2,22.75 +266,5166.8,1627.8,22.28 +268,5332.9,1616.2,21.81 +270,5503,1604.4,21.34 +272,5677.2,1592.5,20.87 +274,5855.6,1580.4,20.4 +276,6038.3,1568.1,19.93 +278,6225.2,1555.6,19.46 +280,6416.6,1543,18.99 +282,6612.4,1530.1,18.53 +284,6812.8,1517.1,18.06 +286,7017.7,1503.8,17.59 +288,7227.4,1490.4,17.13 +290,7441.8,1476.7,16.66 +292,7661,1462.7,16.2 +294,7885.2,1448.6,15.74 +296,8114.3,1434.2,15.28 +298,8348.5,1419.5,14.82 +300,8587.9,1404.6,14.36 +302,8832.5,1389.4,13.9 +304,9082.4,1374,13.45 +306,9337.8,1358.2,12.99 +308,9598.6,1342.1,12.54 +310,9865.1,1325.7,12.09 +312,10137,1309,11.64 +314,10415,1291.9,11.19 +316,10699,1274.5,10.75 +318,10989,1256.6,10.3 +320,11284,1238.4,9.86 +322,11586,1219.7,9.43 +324,11895,1200.6,8.99 +326,12209,1180.9,8.56 +328,12530,1160.8,8.13 +330,12858,1140.2,7.7 +332,13193,1118.9,7.28 +334,13534,1097.1,6.86 +336,13882,1074.6,6.44 +338,14238,1051.3,6.03 +340,14601,1027.3,5.63 +342,14971,1002.5,5.22 +344,15349,976.7,4.83 +346,15734,949.9,4.43 +348,16128,922,4.05 +350,16529,892.7,3.67 +352,16939,862.1,3.29 +354,17358,829.8,2.93 +356,17785,795.5,2.57 +358,18221,759,2.22 +360,18666,719.8,1.88 +362,19121,677.3,1.55 +364,19585,630.5,1.23 +366,20060,578.2,0.93 +368,20546,517.8,0.65 +370,21044,443.8,0.39 +372,21554,340.3,0.16 +373.95,22064,0,0 diff --git a/data/vapourwater.rda b/data/vapourwater.rda new file mode 100644 index 0000000..d810127 Binary files /dev/null and b/data/vapourwater.rda differ diff --git a/man/pascal2torr.Rd b/man/pascal2torr.Rd new file mode 100644 index 0000000..2874b8d --- /dev/null +++ b/man/pascal2torr.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/unit-converters.R +\name{pascal2torr} +\alias{pascal2torr} +\title{Convert Pascal to Torr} +\usage{ +pascal2torr(pascal) +} +\arguments{ +\item{pascal}{numeric (note: please supply Pa, not kPa)} +} +\value{ +torr, numeric +} +\description{ +Convert Pascal to Torr +} diff --git a/man/torr2pascal.Rd b/man/torr2pascal.Rd new file mode 100644 index 0000000..7858486 --- /dev/null +++ b/man/torr2pascal.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/unit-converters.R +\name{torr2pascal} +\alias{torr2pascal} +\title{Convert Torr to Pascal} +\usage{ +torr2pascal(torr) +} +\arguments{ +\item{torr}{numeric} +} +\value{ +pascal, numeric (note returns Pa, not kPa) +} +\description{ +Convert Torr to Pascal +} diff --git a/man/vapourwater.Rd b/man/vapourwater.Rd new file mode 100644 index 0000000..4f4c460 --- /dev/null +++ b/man/vapourwater.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{vapourwater} +\alias{vapourwater} +\title{Vapour pressure and other saturation properties of water} +\format{A data frame with 189 rows and 4 variables: +\describe{ + \item{temperature}{temperature/celsius} + \item{pressure}{pressure/kilopascal} + \item{enthalpy}{enthalpy of vapourisation/kilojoule per kilogram} + \item{surfacetension}{surface tension/millinewton per metre} +}} +\source{ +Handbook of Chemistry and Physics, 94th ed., 6-10-90, Eric W. Lemmon. +} +\description{ +A dataset summarising vapour pressure, enthalpy of vapourisation, + and surface tension of water from 0.01 Celsius to 373.95 Celsius. + Data as accepted by the International Association for the Properties + of Water and Steam for general scientific use. + Source: CRC handbook, 94th ed., table 6-10-90, Eric W. Lemmon. +} +\author{ +Taha Ahmed +} diff --git a/man/wavenum2length.Rd b/man/wavenum2length.Rd index fd1fd3f..aa782d6 100644 --- a/man/wavenum2length.Rd +++ b/man/wavenum2length.Rd @@ -10,7 +10,7 @@ wavenum2length(wavenumber) \item{wavenumber}{number or vector of numbers} } \value{ -number ofr vector +number or vector } \description{ Converts wavenumber (cm-1) to wavelength (nm)