-
100.00%
Rate
-
44
Hits
-
0
Missed
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
-
-
-
-
-
- 1x
- 1x
- 1x
-
- 1x
-
-
-
-
-
- 1x
-
- 1x
-
-
- 1x
-
-
-
- 9x
- 9x
- 6x
- 6x
- 2x
- 2x
-
-
- 5x
- 5x
- 5x
-
- 5x
- 4x
- 3x
-
- 3x
- 1x
- 1x
- 1x
-
- 1x
- 1x
- 1x
-
-
- 2x
-
-
- 6x
- 6x
- 3x
- 6x
-
-
- 3x
- 3x
- 3x
- 3x
-
- 3x
-
-
- 1x
-
-
-
-
-
-
- 1x
-
- 121x
- 120x
-
-
-
-
-
-
- 1x
- 1x
- 1x
-
-
-
-
-
-
- 1x
- -------------------------------------------------------------------------------
- -- Atomic elements for PUMAS
- -- Author: Valentin Niess
- -- License: GNU LGPL-3.0
- -------------------------------------------------------------------------------
- local compat = require('pumas.compat')
- local error = require('pumas.error')
- local metatype = require('pumas.metatype')
-
- local element = {}
-
-
- -------------------------------------------------------------------------------
- -- The atomic Element metatype
- -------------------------------------------------------------------------------
- local Element = {__index = {}}
-
- Element.__index.__metatype = 'Element'
-
- do
- local raise_error = error.ErrorFunction{fname = 'Element'}
-
- local function new (cls, ...)
- local Z, A, I, argname, argnum, var
- local nargs = select('#', ...)
- if nargs == 1 then
- local args = select(1, ...)
- if type(args) ~= 'table' then
- raise_error{argnum = 1, expected = 'a table',
- got = metatype.a(args)}
- end
-
- Z = args.Z
- A = args.A
- I = args.I
-
- if type(Z) ~= 'number' then argname, var = 'Z', Z
- elseif type(A) ~= 'number' then argname, var = 'A', A
- elseif type(I) ~= 'number' then argname, var = 'I', I
- end
- elseif nargs == 3 then
- Z = select(1, ...)
- A = select(2, ...)
- I = select(3, ...)
-
- if type(Z) ~= 'number' then argnum, var = 1, Z
- elseif type(A) ~= 'number' then argnum, var = 2, A
- elseif type(I) ~= 'number' then argnum, var = 3, A
- end
- else
- raise_error{argnum = 'bad', expected = '1 or 3', got = nargs}
- end
-
- if argname or argnum then
- raise_error{
- argname = argname, argnum = argnum, expected = 'a number',
- got = metatype.a(var)}
- end
-
- local self = compat.table_new(0, 3)
- self.Z = Z
- self.A = A
- self.I = I
-
- return setmetatable(self, cls)
- end
-
- element.Element = setmetatable(Element, {__call = new})
- end
-
-
- -------------------------------------------------------------------------------
- -- Build the Elements table
- -------------------------------------------------------------------------------
- element.elements = require('pumas.data.elements')
-
- for k, v in pairs(element.elements) do
- element.elements[k] = setmetatable(v, Element)
- end
-
-
- -------------------------------------------------------------------------------
- -- Register the subpackage
- -------------------------------------------------------------------------------
- function element.register_to (t)
- t.Element = element.Element
- t.elements = element.elements
- end
-
-
- -------------------------------------------------------------------------------
- -- Return the package
- -------------------------------------------------------------------------------
- return element