Commit 8faaae6b authored by Matthias Schroeder's avatar Matthias Schroeder

typo in elements

parent 7fe951ec
......@@ -3,13 +3,13 @@
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: [
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 },
......@@ -34,7 +34,7 @@ elements: [
]
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