Eduard Kharakhashyan commited on
Commit
e8e508c
·
1 Parent(s): 50916a6

non_h and h parts

Browse files
Files changed (1) hide show
  1. app.py +32 -24
app.py CHANGED
@@ -7,14 +7,17 @@ gc_full_key = "full name"
7
  GC_FULL_NAMES = ['Hydrogen sulphide',
8
  'Carbone dioxide', 'Nitrogen', 'Methane', 'Ethane', 'Propane', 'N-butane', 'Iso-butane', 'N-pentane',
9
  'Iso-pentane', 'N-hexane',
10
- 'N-heptane', 'C7+', 'Hydrogen', 'Air', 'Water', 'Oxygen']
11
  GC_SHORT_NAMES = ['H2S', 'CO2', 'N2', "C1", "C2", "C3", "nC4", "iC4", "nC5", "iC5", "C6",
12
- "C7", "C7+", "H2", "Air", "H2O", "O2"]
13
 
14
  GC_NAMES = []
15
  for full_name, short_name in zip(GC_FULL_NAMES, GC_SHORT_NAMES):
16
  GC_NAMES.append({gc_full_key: full_name, gc_formula_k: short_name})
17
 
 
 
 
18
 
19
  sg_k = 'sg_value'
20
  pc_k = 'p_crit_value'
@@ -23,16 +26,11 @@ gc_state_k = 'gc_state'
23
  for key in [sg_k, pc_k, tc_k]:
24
  if key not in ss:
25
  ss[key] = 0
26
- # Display the selected options
27
-
28
-
29
- if st.button("Rerun"):
30
- st.rerun()
31
 
32
  if st.button("Calculate"):
33
  ss[sg_k] = 30
34
- # Force a rerun to update the display
35
- # st.rerun()
36
 
37
  UD = "User defined"
38
  SG_LIST = [UD,
@@ -51,8 +49,8 @@ else:
51
 
52
  def text_for_gc(col, gc):
53
  # Generate unique class names for each image
54
- hover_class = f'hoverable_{i}'
55
- tooltip_class = f'tooltip_{i}'
56
 
57
  # Define the unique CSS for each image
58
  hover_css = f'''
@@ -96,21 +94,31 @@ def text_for_gc(col, gc):
96
  params = []
97
  ss[gc_state_k] = UD
98
  if sg_source != SG_GC:
99
- cur_gc = GC_NAMES[:3]
 
100
  else:
101
- cur_gc = GC_NAMES
 
102
  with st.expander("Gas components") as gc_exp:
103
- for i in range(0, len(cur_gc), 3):
104
- cols = st.columns(3)
105
- j = i
106
- for col in cols:
107
- if j >= len(cur_gc):
108
- break
109
- gc11, gc12 = col.columns([1, 1.5])
110
- text_for_gc(gc11, cur_gc[j])
111
- params.append(gc12.text_input(cur_gc[j][gc_formula_k], value=0, label_visibility='collapsed',
112
- help=cur_gc[j][gc_formula_k]))
113
- j += 1
 
 
 
 
 
 
 
 
114
 
115
 
116
  CRIT_LIST = [UD]
 
7
  GC_FULL_NAMES = ['Hydrogen sulphide',
8
  'Carbone dioxide', 'Nitrogen', 'Methane', 'Ethane', 'Propane', 'N-butane', 'Iso-butane', 'N-pentane',
9
  'Iso-pentane', 'N-hexane',
10
+ 'N-heptane', 'C7_PLUS_', 'Hydrogen', 'Air', 'Water', 'Oxygen']
11
  GC_SHORT_NAMES = ['H2S', 'CO2', 'N2', "C1", "C2", "C3", "nC4", "iC4", "nC5", "iC5", "C6",
12
+ "C7", "C7_PLUS_", "H2", "Air", "H2O", "O2"]
13
 
14
  GC_NAMES = []
15
  for full_name, short_name in zip(GC_FULL_NAMES, GC_SHORT_NAMES):
16
  GC_NAMES.append({gc_full_key: full_name, gc_formula_k: short_name})
17
 
18
+ hydrocarbons = GC_NAMES[3:13]
19
+ non_hc = GC_NAMES[:3]
20
+ add_non_hc = GC_NAMES[13:]
21
 
22
  sg_k = 'sg_value'
23
  pc_k = 'p_crit_value'
 
26
  for key in [sg_k, pc_k, tc_k]:
27
  if key not in ss:
28
  ss[key] = 0
 
 
 
 
 
29
 
30
  if st.button("Calculate"):
31
  ss[sg_k] = 30
32
+ ss[tc_k] = 15
33
+ ss[pc_k] = 20
34
 
35
  UD = "User defined"
36
  SG_LIST = [UD,
 
49
 
50
  def text_for_gc(col, gc):
51
  # Generate unique class names for each image
52
+ hover_class = f'hoverable_{gc[gc_formula_k]}'
53
+ tooltip_class = f'tooltip_{gc[gc_formula_k]}'
54
 
55
  # Define the unique CSS for each image
56
  hover_css = f'''
 
94
  params = []
95
  ss[gc_state_k] = UD
96
  if sg_source != SG_GC:
97
+ curr_non_hc = non_hc
98
+ cur_hc = None
99
  else:
100
+ curr_non_hc = non_hc + add_non_hc
101
+ cur_hc = hydrocarbons
102
  with st.expander("Gas components") as gc_exp:
103
+
104
+ def get_components_block(cur_gc, text):
105
+ st.text(f'{text}')
106
+ # st.markdown("***")
107
+ for i in range(0, len(cur_gc), 3):
108
+ cols = st.columns(3)
109
+ j = i
110
+ for col in cols:
111
+ if j >= len(cur_gc):
112
+ break
113
+ gc11, gc12 = col.columns([1, 1.5])
114
+ text_for_gc(gc11, cur_gc[j])
115
+ params.append(gc12.text_input(cur_gc[j][gc_formula_k], value=0, label_visibility='collapsed',
116
+ help=cur_gc[j][gc_formula_k]))
117
+ j += 1
118
+
119
+ get_components_block(curr_non_hc, "non hydrocarbons")
120
+ if cur_hc:
121
+ get_components_block(cur_hc, "hydrocarbons")
122
 
123
 
124
  CRIT_LIST = [UD]