Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --]] Atom assemblr made by: Lewisk3 (Redxone)
- --]] order of ops
- --:KLMNOP = 2,8,18,32,32...
- --= 1s,
- --= 2s,2p,
- --= 3s,3p,
- --= 4s,3d,4p,
- --= 5s,4d,5p,
- --= 6s,4f,5d,6p
- --= 7s,5f,6d,7p
- --= 8s
- --=_________________________________________=--
- local suborbits = {
- ['s'] = 2,
- ['p'] = 6,
- ['d'] = 10,
- ['f'] = 14,
- ['g'] = 18,
- ['h'] = 22,
- ['i'] = 26,
- ['j'] = 30,
- ['k'] = 34,
- }
- local shells = {
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- }
- local fillorder = {
- {1,1},
- {2,1},
- {2,2},
- {3,1},
- {3,2},
- {4,1},
- {3,3},
- {4,2},
- {5,1},
- {4,3},
- {5,2},
- {6,1},
- {4,4},
- {5,3},
- {6,2},
- {7,1},
- {5,4},
- {6,3},
- {7,2},
- {8,1},
- {5,5},
- {6,4},
- {7,3},
- {8,2},
- {9,1},
- }
- local fills = {
- {'s'}, -- K
- {'s','p'}, -- L
- {'s','p','d'}, -- M
- {'s','p','d','f'}, -- N
- {'s','p','d','f','g'}, -- O
- {'s','p','d','f','g','h'}, -- P
- {'s','p','d','f','g','h','i'}, -- Q
- {'s','p','d','f','g','h','i','j'}, -- R
- {'s','p','d','f','g','h','i','j','k'}, -- S
- }
- local e = 1
- -- minimum valence electrons
- local mnval = 1
- -- maximum valence electrons
- local mval = 8
- -- Get sub orbit ammount.
- function getsoa(soch)
- return suborbits[soch]
- end
- -- Get shell orbit ammount
- function getshoa(so)
- local acc = 0
- for i = 1, #so do
- acc = acc + getsoa(so[i])
- end
- return acc
- end
- -- Get max electrons from shell oribit table
- function getmaxe(atm)
- local tacc = 0
- for i = 1, #atm do
- tacc = tacc + getshoa(atm[i])
- end
- return tacc
- end
- -- shell print
- function shprint(sh)
- for i = 1, #sh do
- if(sh[i] > 0)then print(sh[i]) end
- end
- end
- -- gets needed shell ammount to make atom
- function getnshells(em)
- local sizes = {2,8,32,50,72}
- local fls = 0
- for i = 1, #sizes do
- fls = fls + sizes[i]
- if(fls >= em)then
- return i+1
- end
- end
- end
- -- distribute electrons
- local targs = { ... }
- if(#targs ~= 1)then error("Ussage: matom <electrons>") end
- -- convert to number
- targs[1] = tonumber(targs[1])
- if(targs[1] > 570 or targs[1] < 1)then error("Invalid electrons maximum is 570, minimum is 1. ") end
- -- give our electron count the provided electrons.
- local e = targs[1]
- local soa = 0
- local mshls = #fillorder
- for s = 1, #fillorder do
- if(e == 0)then break end
- local shl = fillorder[s][1]
- local orb = fillorder[s][2]
- if(shl <= mshls)then
- local soa = getsoa(fills[shl][orb])
- if(e >= soa)then
- shells[shl] = shells[shl] + soa
- e = e - soa
- elseif(e <= 8)then
- shells[shl] = shells[shl] + e
- e = 0
- break
- end
- else
- break
- end
- end
- shprint(shells)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement