diff options
author | Karl Berry <karl@freefriends.org> | 2016-04-02 21:57:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-04-02 21:57:34 +0000 |
commit | 736d573263d6969c828cadd202b3f248d8cc604e (patch) | |
tree | b5562e31bb4a085499a0ec309eebac89015b3420 /Master/texmf-dist/source/latex/nucleardata | |
parent | 7a1515b2305eebd7a55d99e4c779c5e79c329783 (diff) |
nucleardata (2apr16)
git-svn-id: svn://tug.org/texlive/trunk@40216 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/nucleardata')
-rw-r--r-- | Master/texmf-dist/source/latex/nucleardata/nucleardata.dtx | 87 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/nucleardata/nucleardata.ins | 8 |
2 files changed, 79 insertions, 16 deletions
diff --git a/Master/texmf-dist/source/latex/nucleardata/nucleardata.dtx b/Master/texmf-dist/source/latex/nucleardata/nucleardata.dtx index ac26399822d..eda908c1769 100644 --- a/Master/texmf-dist/source/latex/nucleardata/nucleardata.dtx +++ b/Master/texmf-dist/source/latex/nucleardata/nucleardata.dtx @@ -14,6 +14,8 @@ Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt +Version Date: 04/01/2016 + ---------------------------------------------------------------- This package provides data and commands for including nuclear and atomic mass and energy data in LaTeX documents. It uses the PythonTeX package and requires pythontex.exe to be called with the tex file as the argument. @@ -45,6 +47,8 @@ Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt +Version Date: 04/01/2016 + ---------------------------------------------------------------- \endpreamble \postamble @@ -68,6 +72,8 @@ and the derived files nucleardata.ins, massdata.csv, nuccommandtest.tex, nuccommandtext.pdf + +Version Date: 04/01/2016 \endpostamble \usedir{./} \generate{ @@ -97,7 +103,7 @@ and the derived files nucleardata.ins, % %<*package> \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{nucleardata}[2015/01/06 v1.01b LaTeX package for providing basic nuclear properties to documents efficiently] +\ProvidesPackage{nucleardata}[2016/04/01 v1.01c LaTeX package for providing basic nuclear properties to documents efficiently] \RequirePackage{pythontex} \RequirePackage{siunitx} %</package> @@ -137,13 +143,15 @@ and the derived files nucleardata.ins, %\changes{v1.00}{2015/11/15}{Initial Public Release} %\changes{v1.01}{2015/11/18}{getIsotopes() returns an integer list; getHalfLifeValue returns a float} %\changes{v1.01b}{2016/01/06}{getIsotopes() bug fix; calls to timeenergy(), time_dict, units_dict bug fixes} +%\changes{v1.01c}{2016/04/01}{add macros to generate random lists of isotopes and a valid random A for given Z} % -% The |nucleardata| package provides a method for quickly accessing information about atomic nuclides (isotopes of elements) by referring to the chemical symbol and mass number (A) or to the atomic number (Z) and mass number (A). This information can be inserted and typeset without the user having to search an outside source. The information available in the current version includes chemical symbol or name given Z, Z given the chemical symbol or name, atomic mass, nuclear mass, Q-values for radioactive decay, half-life of ground states, binding energy, mass excess, and list of known isotopes of an element. \par +% The |nucleardata| package provides a method for quickly accessing information about atomic nuclides (isotopes of elements) by referring to the chemical symbol and mass number (A) or to the atomic number (Z) and mass number (A). This information can be inserted and typeset without the user having to search an outside source. The information available, via macro commands, in the current version includes chemical symbol or name given Z, Z given the chemical symbol or name, atomic mass, nuclear mass, Q-values for radioactive decay, half-life of ground states, binding energy, mass excess, and list of known isotopes of an element. \par %~ +% There is a macro command for generating a random set of nuclides, accessible as elements of lists of Z and corresponding (valid) A. The elements of the list can be used as arguments for Z and A arguments of other |nucleardata| macros. Another macro will randomly select an valid A for a user-specified Z. +%\subsection*{Source of Data} % The data is contained in two CSV format files: |massdata.csv| and |elementlist.csv|. These files must be installed in the same directory as the |nucleardata.sty| file. They are read during the \LaTeX\ compile process and lookups are done by Python code embedded into the |.sty| file. Initially, the Python code loads all the data from the |CSV| files into Python arrays, |nucleardata| and |elementdata|. \par %~ % The \texttt{massdata.csv} file was created by the author (Nettles) from ENSDF data files and the file \texttt{mass.mas03round} from ``The Ame2003 atomic mass evaluation (II)'' by G.Audi, A.H.Wapstra and C.Thibault, \textit{ Nuclear Physics} A729 p. 337-676, December 22, 2003. The \texttt{elementlist.csv} file was created by the author from public sources. -%~ % \subsection*{Using Python\TeX\ } % Because Python is the basis of the lookup engine, the package |pythontex| is automatically loaded. The user must follow a three-step compiling sequence to get a semifinal/final document. For example, if the user's file is named |carbon.tex|, the sequence will be \par %\begin{tabular}{l} @@ -152,7 +160,7 @@ and the derived files nucleardata.ins, % |pdflatex carbon.tex| %\end{tabular}\par % If the user is familiar with Python\TeX\ this shouldn't seem unusual. -% \subsection*{A Python Class--Nucdata} +% \subsection*{A Python Class--|Nucdata|} % Python functions are called by customized \LaTeX\ commands to extract the data from the |nucleardata| and |elementdata| arrays, so the user has the capability of using these functions to write custom Python routines within the default Python\TeX\ environment. The functions belong to a class defined in this package as |Nucdata|. The class is instantiated in the package Python code as |nuc|.\par % The functions will allow the user to use the data for more specific calculations such as Q-values of reactions or decay chain behaviors. Python\TeX\ was designed for tasks such as this. The user can utilize the functions as part of the |nuc| instantiation or can implement their own instance. The data arrays are loaded external to the class. %~ @@ -166,7 +174,12 @@ and the derived files nucleardata.ins, % \end{center} % This definition gives a default rounding of six decimal places. % -% \subsection*{Commands} +% \subsection*{Using Python variable names as arguments} +% If a command calls for an integer value for either Z or A, you can supply the name of a Python variable which contains an integer value. This value could be set using a PythonTeX call or one of the |nucleardata| commands that selects random Z or A values (see |nucrandom[]{}| and |nucAran{}|). +% \begin{center} +% |\pyc{myz=6} Element Z=\py{myz} is called \nucname{myz}.| +% \end{center} +% \subsection*{Macro Commands} %\DescribeMacro{\nucsymbol} % Command form: |\nucsymbol{|\meta{namez}|}|.\par % The argument can be an unquoted string (the name of the element) or an integer (atomic number, Z). Returns a string with the element symbol. Calls a Python function |getSymbol('|\meta{namez}|')|. \par @@ -188,8 +201,9 @@ and the derived files nucleardata.ins, %\DescribeMacro{\nuchalfunit} % Command form: |\nuchalflife[|\meta{unit}|]{|\meta{namez}|}{|\meta{A}|}|. \par % The optional argument is an unquoted string specifying the time unit to use for the return value. The chart below lists valid arguments. The first required argument can be an unquoted string (the symbol) or an integer (Z). The second required value must be an integer, the mass number, A. Returns a string with the value and units of the halflife of the specific nuclide. Calls a Python function |getHalfLife('|\meta{namez}|'|, \meta{A}, |'|\meta{unit}|')|. \par -% There are two variations on this command: |\nuchalfvalue| calls |getHalfLifeValue("|\meta{namez}|'|, \meta{A}, |'|\meta{unit}|')| and returns the unformatted numerical portion of the halflife and |\nuchalfunit| calls |getHalfLifeUnit('|\meta{namez}|'|, \meta{A}, |'|\meta{unit}|')| returns a string with the unit portion. They take the same arguments as |\nuchalflife|. If there is no half life listed, the call returns the None token.\par +% There are two variations on this command: \par |\nuchalfvalue| calls |getHalfLifeValue('|\meta{namez}|'|, \meta{A}, |'|\meta{unit}|')| and returns the unformatted numerical portion of the halflife and |\nuchalfunit| calls |getHalfLifeUnit('|\meta{namez}|'|, \meta{A}, |'|\meta{unit}|')| returns a string with the unit portion. They take the same arguments as |\nuchalflife|. If there is no half life listed, the call returns the None token.\par %~ +%\begin{center} %\begin{tabular}{ccc} % argument & unit symbol & unit name \\ % \hline @@ -201,17 +215,15 @@ and the derived files nucleardata.ins, % |us| & \si{\micro\second} & microsecond \\ % |ms| & \si{\ms} & millisecond \\ % |s| & \si{\second} & second \\ -% |m| & \si{\min} & minute \\ -% |min| & \si{\min} & minute \\ -% |h| & \si{\hour} & hour \\ -% |hr| & \si{\hour} & hour \\ -% |d| & \si{\day} & day \\ -% |day| & \si{\day} & day \\ -% |y| & \si{\ensuremath{\mathrm{yr}}} & year \\ -% |yr| & \si{\ensuremath{\mathrm{yr}}} & year \\ +% |m| or |min| & \si{\min} & minute \\ +% |h| or |hr| & \si{\hour} & hour \\ +% |d| or |day| & \si{\day} & day \\ +% |y| or |yr| & \si{\ensuremath{\mathrm{yr}}} & year \\ % |My| & \si{\ensuremath{\mathrm{My}}} & megayear \\ % |Gy| & \si{\ensuremath{\mathrm{Gy}}} & gigayear \\ +% \hline %\end{tabular}\par +%\end{center} %~ % %\DescribeMacro{\nucspin} @@ -284,6 +296,16 @@ and the derived files nucleardata.ins, % Returns the Q-value of the reaction in atomic mass units (u), MeV/c$^2$ or keV/c$^2$, respectively. Calls Python function |getReaction_u('|\meta{namez1}|'|, \meta{A1}, |'|\meta{namez2}|'|, \meta{A2}, |'|\meta{namez3}|'|, \meta{A3}, |'| \meta{namez4}|'|, \meta{A4}|)|, etc. \par %~ % +%\DescribeMacro{\nucAran} +% Command form: |\nucAran{|\meta{namez}|}|.\par +% This macro generates a random A value for the given element specified by the required argument. The argument can be a string (the element symbol) or a number (Z). The generated A is stored in a Python variable, \textbf{singleAran}, accessible via |PythonTeX| macros such as |\py{singleAran}|. This list element name can also be used as the A argument for other |nucleardata| macros. Calls Python function |nuc.getRandomA('|\meta{namez}|')|. \par +%~ +% +%\DescribeMacro{\nucrandom} +% Command form: |\nucrandom[|\meta{repeater}|]{|\meta{listsize}|}|.\par +% This macro generates a list of random Z values and a list with a valid random A value for each chosen Z. The optional argument determines whether a Z value can selected more than once (0=no repeat [default], 1=repeats allowed). The required argument is an integer specifying the length of the lists. The generated list of Z is stored in a Python list, \textbf{zran}, and the associated A for each Z is stored in a Python list, \textbf{aran}. \textbf{zran[k]}$\to$\textbf{aran[k]}. The values in each list are accessible via |PythonTeX| macros such as |\py{zran[0]}|. The list element members can also be used as Z or A arguments for other |nucleardata| macros.\par +% Calls Python function |nuc.makeNucRandom(|\meta{listsize}|,|\meta{repeater}|)|. +%~ %\StopEventually{^^A % \PrintChanges % ^^A \PrintIndex @@ -297,6 +319,7 @@ import sys import fileinput import csv from subprocess import check_output +import random as nucrandom u2Mev=931.502 u2kev=u2Mev*1000. @@ -389,11 +412,11 @@ class Nucdata(object): return massu*931502. def getNuclearMass_mev(self,EL,A): - massu=self.getnuclearmass_u(EL,A) + massu=self.getNuclearMass_u(EL,A) return massu*931.502 def getNuclearMass_kev(self,EL,A): - massu=self.getnuclearmass_u(EL,A) + massu=self.getNuclearMass_u(EL,A) return massu*931502. def getReaction_u(self,EL1,A1,EL2,A2,EL3,A3,EL4,A4): @@ -617,6 +640,26 @@ class Nucdata(object): res=[v for v in nucleardata if v.get('SYM').strip().upper()== EL.upper() and v.get('A') == A] return res[0].get('spin-parity') + def makeNucRandom(self,count,repeater): + alist=[] + zlist=[] + for k in range(0,count): + if repeater==0: + ok=0 + while ok==0: + myz=nucrandom.randint(1,118) + ok=1 if (myz not in zlist) else 0 + zlist.append(myz) + else: + zlist.append(nucrandom.randint(1,118)) + mya=nucrandom.choice(self.getIsotopes(str(zlist[k]))) + alist.append(mya) + return(zlist,alist) + + def getRandomA(self,EL): + aRandomA=nucrandom.choice(self.getIsotopes(EL)) + return(aRandomA) + elementdata=[] #list of dictionaries of Z, Elemental symbol, Name of element filename=check_output("kpsewhich elementlist.csv", shell=True) @@ -653,6 +696,18 @@ nuc=Nucdata() \end{pycode} %pythoncode +%\begin{macro}{\nucAran} +% \begin{macrocode} +\newcommand{\nucAran}[1]{\pyc{singleAran=nuc.getRandomA('#1')}} +% \end{macrocode} +%\end{macro} + +%\begin{macro}{\nucrandom} +% \begin{macrocode} +\newcommand{\nucrandom}[2][0]{\pyc{zran,aran=nuc.makeNucRandom(#2,#1)}} +% \end{macrocode} +%\end{macro} + %\begin{macro}{\nucspin} % \begin{macrocode} \newcommand{\nucspin}[2]{\py{nuc.getSpin('#1',#2)}} diff --git a/Master/texmf-dist/source/latex/nucleardata/nucleardata.ins b/Master/texmf-dist/source/latex/nucleardata/nucleardata.ins index 8fd793b7b11..8bc936cb117 100644 --- a/Master/texmf-dist/source/latex/nucleardata/nucleardata.ins +++ b/Master/texmf-dist/source/latex/nucleardata/nucleardata.ins @@ -15,6 +15,8 @@ %% %% See http://www.latex-project.org/lppl.txt %% +%% Version Date: 04/01/2016 +%% %% ---------------------------------------------------------------- \input docstrip.tex \keepsilent @@ -30,6 +32,8 @@ Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt +Version Date: 04/01/2016 + ---------------------------------------------------------------- \endpreamble \postamble @@ -53,6 +57,8 @@ and the derived files nucleardata.ins, massdata.csv, nuccommandtest.tex, nuccommandtext.pdf + +Version Date: 04/01/2016 \endpostamble \usedir{./} \generate{ @@ -79,5 +85,7 @@ and the derived files nucleardata.ins, %% massdata.csv, %% nuccommandtest.tex, %% nuccommandtext.pdf +%% +%% Version Date: 04/01/2016 %% %% End of file `nucleardata.ins'. |