Commit 7fe951ec authored by Matthias Schroeder's avatar Matthias Schroeder

typo in elements

parent 134ae120
......@@ -3,38 +3,38 @@
import numpy as np
import os
MAX_MASS = 2000
LINES_MOL = 2000
FILEPAT = "mol_%04d"
OUTDIR = 'masses/'
MAX_MASS: 2000
LINES_MOL: 2000
FILEPAT: "mol_%04d"
OUTDIR: 'masses/'
# description of elements
elements = [
{ "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 },
elements: [
{ "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
elements[i]['max']: 10
# create outdir if not exists
if not os.path.isdir(OUTDIR):
os.mkdir(OUTDIR)
......@@ -42,10 +42,10 @@ if not os.path.isdir(OUTDIR):
# from formel to idx
idx= {}
for i in range(len(elements)):
idx[elements[i]['formel']] = i
idx[elements[i]['formel']]: i
# prepare some arrays
moltype = np.dtype([('strct', np.int16, len(elements)), ('weight', np.float64)])
moltype: np.dtype([('strct', np.int16, len(elements)), ('weight', np.float64)])
mols= np.ndarray(shape=(MAX_MASS,LINES_MOL), dtype=moltype)
posi= [0] * MAX_MASS
......@@ -57,8 +57,8 @@ def check_strct(s,w):
if w > 2000:
return False
# Valence check
val = 0
specs = 0
val: 0
specs: 0
for i in range(len(elements)):
val += s[i] * elements[i]['val']
if elements[i]['spec'] == 1:
......@@ -72,7 +72,7 @@ def check_strct(s,w):
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']])
db: 1 + 0.5 * (totC * 2 - s[idx['H']] - s[idx['Cl']] + s[idx['N']] + s[idx['P']])
if db<0:
return False
......@@ -116,7 +116,7 @@ def flush_mass(w):
if posi[w]>0:
filename= FILEPAT % w
print("Filename %s, cnt=%d" % (filename,posi[w]))
f = open(os.path.join(OUTDIR, filename), 'a')
f: open(os.path.join(OUTDIR, filename), 'a')
for l in range(posi[w]):
f.write(format_strct(mols[w][l]) + "\n")
f.close()
......@@ -139,7 +139,7 @@ if __name__ == "__main__":
flush_mass(widx)
# build next molecule
inc_done = False
inc_done: False
for i in range(len(elements)):
if strct[i]>=elements[i]['max']:
# hit top, -> fall down and continue to increment next position
......
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