Skip to content

Commit

Permalink
Merge pull request #36 from rdemaria/fixwall
Browse files Browse the repository at this point in the history
fix wall issue
  • Loading branch information
rdemaria authored Oct 13, 2020
2 parents e334e77 + ab18907 commit d4a3eaa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
31 changes: 20 additions & 11 deletions sixdeskdb/deskdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def load_extra(self):
cur = conn.cursor()
# env_var = self.env_var
basedir = self.basedir
cur.execute("begin IMMEDIATE transaction")
#cur.execute("begin IMMEDIATE transaction")
sql = """SELECT path,content from files"""
cur.execute(sql)
files = cur.fetchall()
Expand Down Expand Up @@ -808,6 +808,7 @@ def load_extra(self):
else:
f.write(decompressBuf(str(file[1])))
f.close()
cur.commit()

def load_mad6t_run(self):
''' load mad runs from DB '''
Expand Down Expand Up @@ -883,7 +884,7 @@ def load_mad6t_results(self):
conn = self.conn
cur = conn.cursor()
env_var = self.env_var
cur.execute("begin IMMEDIATE transaction")
#cur.execute("begin IMMEDIATE transaction")
sql = """SELECT * from mad6t_results"""
cur.execute(sql)
forts = cur.fetchall()
Expand Down Expand Up @@ -927,6 +928,7 @@ def load_mad6t_results(self):
f.close()
else:
print('fort.16_%s.gz was not created at %s',(seed,path))
cur.commit()

def load_six_beta(self):
'''load general_input,betavalues and sixdesktunes from DB'''
Expand All @@ -936,7 +938,7 @@ def load_six_beta(self):
cur = conn.cursor()
env_var = self.env_var
path = os.path.join(env_var['sixdesktrack'],self.LHCDescrip)
cur.execute("begin IMMEDIATE transaction")
#cur.execute("begin IMMEDIATE transaction")
sql = """SELECT * from six_beta"""
cur.execute(sql)
beta = cur.fetchall()
Expand Down Expand Up @@ -985,6 +987,7 @@ def load_six_beta(self):
f = open(temp,'w')
f.write(stri)
f.close()
cur.commit()

def load_six_input_results(self):
'''load fort.3 and fort.10 files from DB '''
Expand All @@ -994,7 +997,7 @@ def load_six_input_results(self):
cur = conn.cursor()
env_var = self.env_var
path = os.path.join(env_var['sixdesktrack'],self.LHCDescrip)
cur.execute("begin IMMEDIATE transaction")
#cur.execute("begin IMMEDIATE transaction")
sql = """SELECT * from six_input"""
cur.execute(sql)
six = cur.fetchall()
Expand Down Expand Up @@ -1037,6 +1040,7 @@ def load_six_input_results(self):
f = gzip.open(temp,'w')
f.write(stri)
f.close()
cur.commit()

def get_missing_fort10(self):
'''get input values for which fort.10 is not present '''
Expand Down Expand Up @@ -1747,6 +1751,7 @@ def read10b(self):
turnse=self.env_var['turnse']
ns1l=self.env_var['ns1l']
ns2l=self.env_var['ns2l']
nsincl = self.env_var['nsincl']
Elhc,Einj = self.execute('SELECT emitn,gamma from six_beta LIMIT 1')[0]
angles=self.get_db_angles()
seeds=self.get_db_seeds()
Expand All @@ -1756,7 +1761,8 @@ def read10b(self):
LHCDescrip=self.LHCDescrip
for tunex,tuney in self.get_tunes():
anumber=1
sql1='SELECT %s FROM results WHERE betx>0 AND bety>0 AND emitx>1e-10 AND emity>1e-10 AND turn_max=%d AND amp1>=%s AND amp1<=%s'%(names,turnsl,ns1l,ns2l)
#sql1='SELECT %s FROM results WHERE betx>0 AND bety>0 AND emitx>1e-10 AND emity>1e-10 AND turn_max=%d AND amp1>=%s AND amp1<=%s'%(names,turnsl,ns1l,ns2l)
sql1='SELECT %s FROM results WHERE turn_max=%d AND amp1>=%s AND amp1<=%s'%(names,turnsl,ns1l,ns2l)
sixdesktunes="%s_%s"%(tunex,tuney)
sql1+=' AND tunex=%s AND tuney=%s '%(tunex,tuney)
for angle in angles:
Expand All @@ -1775,12 +1781,17 @@ def read10b(self):
achaos = 0.
achaos1 = 0.
sql=sql1+' AND seed=%s '%seed
#sql+=' AND ROUND(angle,5)=ROUND(%s,5) '%angle
sql+=' AND angle=%s '%angle
sql+=' ORDER BY emitx+emity '
sql+=' ORDER BY amp1+%g*row_num'%(nsincl/pairs/10) #ordering based on file (10 ordering only)
if self.debug:
print(sql)
inp=np.array(self.execute(sql),dtype=rectype)
zerotest=np.where(inp['betx']==0)[0] # remove everything from first zero line
truncated=False
if len(zerotest)>0:
truncated=True
izerotest=zerotest[0]
inp=inp[:izerotest]
if self.debug:
print(inp.shape)
if len(inp)==0:
Expand All @@ -1804,10 +1815,6 @@ def read10b(self):
turn_max=inp['turn_max'].max()
amp2=inp['amp2'][-1]
row_num=inp['row_num'][-1]
if row_num<pairs :
truncated=True
else:
truncated=False
zero = 1e-10
#xidx=(betx>zero) & (emitx>zero)
#yidx=(bety>zero) & (emity>zero)
Expand Down Expand Up @@ -1876,6 +1883,8 @@ def read10b(self):
alost2test=np.where((sturns1<turn_max)|(sturns2<turn_max))[0]
if len(alost2test)>0:
ialost2=alost2test[0]
if ialost2>0:
ialost2-=1 #last stable particle
alost2=rad*sigx1[ialost2]
icount=1.
if iin != -999 and iend == -999 : iend=iel
Expand Down
8 changes: 4 additions & 4 deletions sixdeskdb/sqltable.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def insert(self,data,replace=True):
else:
sql="INSERT INTO %s(%s) VALUES (%s)"
cur=db.cursor()
if dbtype == "sql":
cur.execute("begin IMMEDIATE transaction")
#if dbtype == "sql":
# cur.execute("begin IMMEDIATE transaction")
if len(data) == 0:
return
cols=','.join(data.dtype.names)
Expand All @@ -111,8 +111,8 @@ def insertl(self,data,artype="?",replace=True):
else:
sql="INSERT INTO %s VALUES (%s)"
cur=db.cursor()
if dbtype == "sql":
cur.execute("begin IMMEDIATE transaction")
#if dbtype == "sql":
# cur.execute("begin IMMEDIATE transaction")
if len(data) == 0:
return
#if not isinstance(data[0], list):
Expand Down
Binary file modified test/simple/job_hllhc10_test8.db
Binary file not shown.

0 comments on commit d4a3eaa

Please sign in to comment.