-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_retriever.py
76 lines (65 loc) · 2.92 KB
/
data_retriever.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
R"""
To easily retrieve data.
"""
import opertateOnMysql as osql
class search_engine_for_simulation_database:
def __init__(self):
pass
def get_table_names(self):
R"""
import data_retriever as dr
se = dr.search_engine_for_simulation_database()
se.get_table_names()
table_name index
'pin_hex_to_honeycomb_klt_2m'
'pin_hex_to_honeycomb_part_klt_2m'
"""
list_table_names = osql.showTables()
for i in range(len(list_table_names)):
print(list_table_names[i])
def search_single_simu_by_lcr_k(self,table_name = 'pin_hex_to_honeycomb_part_klt_2m',lcr1=0.8,k1=300,kt1=1.0):
R"""
| SimuIndex | HarmonicK | LinearCompressionRatio | kT | Psi3 | Psi6 | RandomSeed |
'pin_hex_to_honeycomb_part_klt_2m'
'pin_hex_to_honeycomb_klt_2m'
"""
lcr_step = 0.0001
lcr_min=lcr1 - 0.5*lcr_step
lcr_max=lcr1 + 0.5*lcr_step
kt_step = 0.1
kt_min = kt1 - 0.5*kt_step
kt_max = kt1 + 0.5*kt_step
cont=' distinct SimuIndex '#, RandomSeed
con=' where HarmonicK='+str(int(k1))+\
' and LinearCompressionRatio >'+str(lcr_min)+' and LinearCompressionRatio <'+str(lcr_max)+\
' and kT >'+str(kt_min)+' and kT <'+str(kt_max)
#' order by RandomSeed asc'
simu_index_seed=osql.getDataFromMysql(table_name=table_name,
search_condition=con,select_content=cont)
print(simu_index_seed)#what if return more than 1 results? 0.8,300 as an example -> 4288,5060.
#where 5060 is low Temperature.
#just take the first result!
return simu_index_seed[0][0]#((index1,),)
def search_single_simu_by_lcr(self,k1,table_name = 'pin_hex_to_honeycomb_part_klt_2m',lcr1=0.8,kt1=1.0):
R"""
| SimuIndex | HarmonicK | LinearCompressionRatio | kT | Psi3 | Psi6 | RandomSeed |
'pin_hex_to_honeycomb_part_klt_2m'
'pin_hex_to_honeycomb_klt_2m'
"""
lcr_step = 0.0001
lcr_min=lcr1 - 0.5*lcr_step
lcr_max=lcr1 + 0.5*lcr_step
kt_step = 0.1
kt_min = kt1 - 0.5*kt_step
kt_max = kt1 + 0.5*kt_step
cont=' distinct SimuIndex '#, RandomSeed
con=' where HarmonicK='+str(int(k1))+\
' and LinearCompressionRatio >'+str(lcr_min)+' and LinearCompressionRatio <'+str(lcr_max)+\
' and kT >'+str(kt_min)+' and kT <'+str(kt_max)
#' order by RandomSeed asc'
simu_index_seed=osql.getDataFromMysql(table_name=table_name,
search_condition=con,select_content=cont)
print(simu_index_seed)#what if return more than 1 results? 0.8,300 as an example -> 4288,5060.
#where 5060 is low Temperature.
#just take the first result!
return simu_index_seed[0][0]#((index1,),)