Skip to content

Commit

Permalink
Path issues resolved. Docs corrected.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Jenni committed Sep 7, 2020
1 parent 407e42c commit bc0d2d4
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 95 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Author: Thomas Jenni

Version: 1.0.1
Version: 1.0.2

Date: 2020-09-05
Date: 2020-09-07

License: MIT

Expand Down
Binary file modified lua-physical.pdf
Binary file not shown.
67 changes: 34 additions & 33 deletions lua-physical.tex
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@
keywordstyle=\ttfamily\bfseries\color{black},
basicstyle=\ttfamily\footnotesize,
commentstyle=\itshape\color{gray},
columns=flexible,
stringstyle=\ttfamily,
tabsize=2,
numbers=right,
showstringspaces=false,
breaklines=true,
breakindent=30pt,
Expand Down Expand Up @@ -152,7 +152,7 @@

\lstset{language=[LaTex]Tex}

\title{The \textsc{lua-physical} library \\\ \\\normalsize Version 1.0.1}
\title{The \textsc{lua-physical} library \\\ \\\normalsize Version 1.0.2}
\author{Thomas Jenni}
\date{\today}
\maketitle
Expand Down Expand Up @@ -184,7 +184,6 @@ \section{Loading}
The following \LaTeX{} preamble loads the |lua-physical| package and creates a macro |\q| for printing physical quantities.
\nopagebreak
\begin{lstlisting}[language=Tex, caption=basic preamble, label=lst:basic preamble]
\usepackage{lua-physical}
\usepackage{siunitx}

% configure siunitx
Expand Down Expand Up @@ -244,9 +243,9 @@ \section{Usage}
\end{luacode}

A car travels $\q{s}$ in $\q{t}$. calculate its velocity.
$$
\begin{align}
v=\frac{s}{t} = \frac{\q{s}}{\q{t}} = \uuline{\q{v}}
$$
\end{align}
\end{lstlisting}

\begin{luacode}
Expand All @@ -258,9 +257,9 @@ \section{Usage}

\leftbar
A car travels $\q{s}$ in $\q{t}$. Calculate its velocity.
$$
\begin{align}
v=\frac{s}{t} = \frac{\q{s}}{\q{t}} = \uuline{\q{v}}
$$
\end{align}
\endleftbar

In the above listing~\ref{lst:Car Velocity}, the variable |s| stands for displacement and has the unit meter |_m|, the variable |t| stands for time and is given in seconds |_s|. If mathematical operations are done on them, new physical quantities are created. In the problem above, the velocity |v| is calculated by dividing |s| by |t|. The instance |v| has the derived unit \si{\m\per\s}. By using the macro |\q{}| all quantities can be printed to the \LuaLaTeX{} code directly.
Expand All @@ -284,12 +283,12 @@ \subsection{Unit conversion}

Find the volume of a rectangular cuboid with lengths $\q{a}$,
$\q{b}$ and $\q{c}$.
$$
\begin{align}
V= a \cdot b \cdot c
= \q{a} \cdot \q{b} \cdot \q{c}
= \q{V}
= \uuline{\q{V:to(_dm^3)}}
$$
\end{align}
\end{lstlisting}

\begin{luacode}
Expand All @@ -302,12 +301,12 @@ \subsection{Unit conversion}

\leftbar
Find the volume of a rectangular cuboid with lengths $\q{a}$, $\q{b}$ and $\q{c}$.
$$
\begin{align}
V= a \cdot b \cdot c
= \q{a} \cdot \q{b} \cdot \q{c}
= \q{V}
= \uuline{\q{V:to(_dm^3)}}
$$
\end{align}
\endleftbar


Expand Down Expand Up @@ -395,9 +394,9 @@ \subsection{Uncertainty Propagation}
The package supports uncertainty propagation. To create a number with an uncertainty, an instance of |physical.Number| has to be created, see listing~\ref{lst:rectangular area}. It has to be remembered, that |N| is a alias for |physical.Number|. The first argument of the constructor |N(mean, uncertainty)| is the mean value and the second one the uncertainty of the measurement. If the proposed preamble \ref{lst:basic preamble} is used, the uncertainty is by default seperated from the mean value by a plus-minus sign.

For the uncertainty propagation the gaussian formula
$$
\begin{align}
\Delta f = \sqrt{ \left(\frac{\partial f}{x_1} \cdot \Delta x_1\right)^2 + \dots + \left(\frac{\partial f}{x_n} \cdot \Delta x_2 \right)^2 }
$$
\end{align}
is used. This formula is a good estimation for the uncertainty $\Delta f$, if the quantities $x_1, \dots, x_n$ the function $f$ depends on, have no correlation. Further, the function $f$ has to change linear, if quantities $x_i$ are changed in the range of their uncertainties.


Expand All @@ -411,11 +410,11 @@ \subsection{Uncertainty Propagation}
\end{luacode}

Calculate the area of a rectangle with lengths $\q{a}$ and $\q{b}$.
$$
\begin{align}
A = a \cdot b
= \q{a} \cdot \q{b}
= \uuline{\q{A}}
$$
\end{align}
\end{lstlisting}

\begin{luacode}
Expand All @@ -427,11 +426,11 @@ \subsection{Uncertainty Propagation}

\leftbar
Calculate the area of a rectangle with lengths $\q{a}$ and $\q{b}$.
$$
\begin{align}
A = a \cdot b
= \q{a} \cdot \q{b}
= \uuline{\q{A}}
$$
\end{align}
\endleftbar


Expand All @@ -450,11 +449,11 @@ \subsection{Uncertainty Propagation}
\end{luacode}

An ideal gas ($\q{n}$) has a pressure of $\q{p}$ and a temperature of $\q{T}$. Calculate the volume of the gas.
$$
\begin{align}
V=\frac{ \q{n} \cdot \q{_R} \cdot \q{(T + _degC_0):to(_K)} }{ \q{p} }
= \q{V}
= \uuline{\q{V}}
$$
\end{align}
\end{lstlisting}


Expand All @@ -470,10 +469,10 @@ \subsection{Uncertainty Propagation}
\leftbar
An ideal gas ($\q{n}$) has a pressure of $\q{p}$ and a temperature of $\q{T}$. Calculate the volume of the gas.

$$
\begin{align}
V=\frac{ \q{n} \cdot \q{(_R*N(1,0.001)):to(_J/(_mol*_K))} \cdot \q{(T + _degC_0):to(_K)} }{ \q{p} }
= \uuline{\q{V}}
$$
\end{align}
\endleftbar

This example shows, that the result has only two digits. If more digits are needed, the uncertainties of the given quantities should be smaller.
Expand Down Expand Up @@ -2036,9 +2035,9 @@ \subsection{physical.Quantity}
\method{Q}{sinh(q)}
\begin{quote}
Returns the value of the hyperbolic sine function of the given quantity. The quantity has to be dimensionless. Since Lua doesn't implement the hyperbolic functions, the following formula is used
$$
\begin{align}
\sinh(x) = 0.5 \cdot e^x - 0.5 / e^x \quad.
$$
\end{align}

\begin{description}
\item |q| : |Q|, |N|, |number|\\
Expand Down Expand Up @@ -2067,9 +2066,9 @@ \subsection{physical.Quantity}
\method{Q}{cosh(q)}
\begin{quote}
Returns the value of the hyperbolic cosine function of the given quantity. The quantity has to be dimensionless. Since Lua doesn't implement the hyperbolic functions, the following formula is used
$$
\begin{align}
\cosh(x) = 0.5 \cdot e^x + 0.5 / e^x \quad.
$$
\end{align}

\begin{description}
\item |q| : |Q|, |N|, |number|\\
Expand Down Expand Up @@ -2097,9 +2096,9 @@ \subsection{physical.Quantity}
\method{Q}{tanh(q)}
\begin{quote}
Returns the value of the hyperbolic tangent function of the given quantity. The quantity has to be dimensionless. Since Lua doesn't implement the hyperbolic functions, the following formula is used
$$
\begin{align}
\tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}} \quad.
$$
\end{align}

\begin{description}
\item |q| : |Q|, |N|, |number|\\
Expand Down Expand Up @@ -2128,9 +2127,9 @@ \subsection{physical.Quantity}
\method{Q}{asinh(q)}
\begin{quote}
Returns the value of the inverse hyperbolic sine function of the given quantity. The quantity has to be dimensionless. Since Lua doesn't implement the hyperbolic functions, the following formula is used
$$
\begin{align}
\text{asinh}(x) = \ln\left( x + \sqrt{x^2 + 1} \right) \quad.
$$
\end{align}

\begin{description}
\item |q| : |Q|, |N|, |number|\\
Expand Down Expand Up @@ -2159,9 +2158,9 @@ \subsection{physical.Quantity}
\method{Q}{acosh(q)}
\begin{quote}
Returns the value of the inverse hyperbolic cosine function of the given quantity. The quantity has to be dimensionless. Since Lua doesn't implement the hyperbolic functions, the following formula is used
$$
\begin{align}
\text{acosh}(x) = \ln\left( x + \sqrt{x^2 - 1} \right) \quad, x > 1 \quad.
$$
\end{align}

\begin{description}
\item |q| : |Q|, |N|, |number|\\
Expand Down Expand Up @@ -2190,9 +2189,9 @@ \subsection{physical.Quantity}
\method{Q}{atanh(q)}
\begin{quote}
Returns the value of the inverse hyperbolic tangent function of the given quantity. The quantity has to be dimensionless. Since Lua doesn't implement the hyperbolic functions, the following formula is used
$$
\begin{align}
\text{atanh}(x) = \ln\left( \frac{1 + x}{1 - x} \right) \quad, -1 < x < 1 \quad.
$$
\end{align}

\begin{description}
\item |q| : |Q|, |N|, |number|\\
Expand Down Expand Up @@ -3053,6 +3052,8 @@ \subsection{physical.Number}
\newpage
\section{Change History}

V1.0.2 \quad (2020/09/07) Minor release. Path issues resolved. Docs corrected.

V1.0.1 \quad (2020/09/05) Minor release. Files renamed.

V1.0 \quad (2020/09/03) First official release.
Expand Down
52 changes: 51 additions & 1 deletion physical.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
return require((...) .. '.physical-init')
--[[
lua-physical
Author: Thomas Jenni
Version: 1.0.2
Date: 2020-09-07
License: MIT
Copyright (c) 2020 Thomas Jenni
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]--

-- Source: http://kiki.to/blog/2014/04/12/rule-5-beware-of-multiple-files/

local Dimension = require('physical-dimension')
local Unit = require('physical-unit')
local Quantity = require('physical-quantity')
local Number = require('physical-number')

require('physical-definition')

local Data = require('physical-data')

local m = {
Dimension = Dimension,
Unit = Unit,
Number = Number,
Quantity = Quantity,
Data = Data
}

return m
53 changes: 0 additions & 53 deletions physical/physical-init.lua

This file was deleted.

2 changes: 1 addition & 1 deletion test/testData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

local lu = require("luaunit")

package.path = "../?.lua;" .. package.path
package.path = "../physical/?.lua;" .. package.path

local physical = require("physical")

Expand Down
2 changes: 1 addition & 1 deletion test/testDefinition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

local lu = require("luaunit")

package.path = "../?.lua;" .. package.path
package.path = "../physical/?.lua;" .. package.path
local physical = require("physical")
local N = physical.Number

Expand Down
2 changes: 1 addition & 1 deletion test/testDimension.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

local lu = require("luaunit")

package.path = "../?.lua;" .. package.path
package.path = "../physical/?.lua;" .. package.path
local physical = require("physical")

local D = physical.Dimension
Expand Down
2 changes: 1 addition & 1 deletion test/testNumber.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

local lu = require("luaunit")

package.path = "../?.lua;" .. package.path
package.path = "../physical/?.lua;" .. package.path
local physical = require("physical")

local N = physical.Number
Expand Down
2 changes: 1 addition & 1 deletion test/testQuantity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

local lu = require("luaunit")

package.path = "../?.lua;" .. package.path
package.path = "../physical/?.lua;" .. package.path
local physical = require("physical")

local N = physical.Number
Expand Down
Loading

0 comments on commit bc0d2d4

Please sign in to comment.