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/tex/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/tex/latex/nucleardata')
-rw-r--r-- | Master/texmf-dist/tex/latex/nucleardata/nucleardata.pytxcode | 27 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nucleardata/nucleardata.sty | 35 |
2 files changed, 56 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/latex/nucleardata/nucleardata.pytxcode b/Master/texmf-dist/tex/latex/nucleardata/nucleardata.pytxcode index 29f15e528d7..0acf7e3fa54 100644 --- a/Master/texmf-dist/tex/latex/nucleardata/nucleardata.pytxcode +++ b/Master/texmf-dist/tex/latex/nucleardata/nucleardata.pytxcode @@ -1,8 +1,9 @@ -=>PYTHONTEX#py#default#default#0#code#####24# +=>PYTHONTEX#py#default#default#0#code#####26# import sys import fileinput import csv from subprocess import check_output +import random as nucrandom u2Mev=931.502 u2kev=u2Mev*1000. @@ -95,11 +96,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): @@ -323,6 +324,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) diff --git a/Master/texmf-dist/tex/latex/nucleardata/nucleardata.sty b/Master/texmf-dist/tex/latex/nucleardata/nucleardata.sty index 28b811e8755..07403be7765 100644 --- a/Master/texmf-dist/tex/latex/nucleardata/nucleardata.sty +++ b/Master/texmf-dist/tex/latex/nucleardata/nucleardata.sty @@ -15,9 +15,11 @@ %% %% See http://www.latex-project.org/lppl.txt %% +%% Version Date: 04/01/2016 +%% %% ---------------------------------------------------------------- \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} @@ -26,6 +28,7 @@ import sys import fileinput import csv from subprocess import check_output +import random as nucrandom u2Mev=931.502 u2kev=u2Mev*1000. @@ -118,11 +121,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): @@ -346,6 +349,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) @@ -381,6 +404,10 @@ nuc=Nucdata() \end{pycode} +\newcommand{\nucAran}[1]{\pyc{singleAran=nuc.getRandomA('#1')}} + +\newcommand{\nucrandom}[2][0]{\pyc{zran,aran=nuc.makeNucRandom(#2,#1)}} + \newcommand{\nucspin}[2]{\py{nuc.getSpin('#1',#2)}} \newcommand{\nucamassu}[3][6]{\py{round(nuc.getMass_u('#2',#3),#1)}} @@ -457,5 +484,7 @@ nuc=Nucdata() %% massdata.csv, %% nuccommandtest.tex, %% nuccommandtext.pdf +%% +%% Version Date: 04/01/2016 %% %% End of file `nucleardata.sty'. |