Commit 134ae120 authored by Matthias Schroeder's avatar Matthias Schroeder

elements sinvoll und rules

parent fabd4009
......@@ -10,19 +10,39 @@ OUTDIR = 'masses/'
# description of elements
elements = [
{ "formel":'C', "weight":1.01, "min":1, "max":20 },
{ "formel":'N', "weight":1.02, "min":0, "max":50 },
{ "formel":'H', "weight":1.01, "min":1, "max":20 },
{ "formel":'C' , "weight": 12 , "min":1, "max":167, val = 4, spec = 0 },
{ "formel":'C13' , "weight": 13.003354835 , "min":0, "max": 3, val = 4, spec = 0 },
{ "formel":'H' , "weight": 1.0078250 , "min":1, "max":800, val = 1, spec = 0 },
{ "formel":'O' , "weight": 15.99491461956, "min":0, "max": 90, val = 2, spec = 0 },
{ "formel":'O18' , "weight": 17.9991610 , "min":0, "max": 1, val = 2, spec = 0 },
{ "formel":'N' , "weight": 14.0030740048 , "min":0, "max": 50, val = 5, spec = 0 },
{ "formel":'N15' , "weight": 15.000108899 , "min":0, "max": 1, val = 5, spec = 0 },
{ "formel":'S' , "weight": 31.972072 , "min":0, "max": 30, val = 6, spec = 0 },
{ "formel":'S34' , "weight": 33.96786690 , "min":0, "max": 1, val = 6, spec = 0 },
{ "formel":'P' , "weight": 30.973763 , "min":0, "max": 20, val = 5, spec = 0 },
# { "formel":'Cui' , "weight": 62.92959772 , "min":0, "max": 2, val = 1, spec = 1 },
# { "formel":'Cuii' , "weight": 62.92959772 , "min":0, "max": 2, val = 2, spec = 1 },
# { "formel":'Feii' , "weight": 55.934936 , "min":0, "max": 2, val = 2, spec = 1 },
# { "formel":'FEiii', "weight": 55.934936 , "min":0, "max": 2, val = 3, spec = 1 },
# { "formel":'BR79' , "weight": 78.918338 , "min":0, "max": 2, val = 1, spec = 1 },
# { "formel":'BR81' , "weight": 80.91690 , "min":0, "max": 2, val = 1, spec = 1 },
# { "formel":'CL' , "weight": 34.9688527 , "min":0, "max": 2, val = 1, spec = 1 },
# { "formel":'Na' , "weight": 22.98976928 , "min":0, "max": 2, val = 1, spec = 1 },
# { "formel":'Ni.ii', "weight": 57.9353462 , "min":0, "max": 2, val = 2, spec = 1 },
# { "formel":'Znii' , "weight": 65.38 , "min":0, "max": 2, val = 2, spec = 1 },
# { "formel":'I' , "weight": 126.90447 , "min":0, "max": 2, val = 1, spec = 1 },
]
for i in range(len(elements)):
if elements[i]['max']>10:
elements[i]['max'] = 10
# create outdir if not exists
if not os.path.isdir(OUTDIR):
os.mkdir(OUTDIR)
# from formel to idx
element_idx= {}
idx= {}
for i in range(len(elements)):
element_idx[elements[i]['formel']] = i
idx[elements[i]['formel']] = i
# prepare some arrays
moltype = np.dtype([('strct', np.int16, len(elements)), ('weight', np.float64)])
......@@ -34,10 +54,41 @@ def check_strct(s,w):
return True for seemingly valid element,
False otherwise
"""
if w > 3000:
if w > 2000:
return False
# Valence check
val = 0
specs = 0
for i in range(len(elements)):
val += s[i] * elements[i]['val']
if elements[i]['spec'] == 1:
specs += s[i]
if val % 2 ~= 0:
return False
if specs > 2:
return False
totC= (s[idx['C']] + s[idx['C13']])
db = 1 + 0.5 * (totC * 2 - s[idx['H']] - s[idx['Cl']] + s[idx['N']] + s[idx['P']])
if db<0:
return False
if (s[idx['O']] + s[idx['O18']]) / totC >2.1:
return False
if s[idx['H']] / totC > 8:
return False
if s[idx['S']] > totC:
return False
if s[idx['P']] > totC:
return False
if s[element_idx['C']] > s[element_idx['H']]:
if s[idx['N']] > 1.25 * totC:
return False
return True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment