def airflow_conv(): second_output = False st.markdown('##### Air flowrate Input') input_unit = st.selectbox('Select input air flowrate unit', options=['CFM', 'l/s']) output_unit = 'CFM' if input_unit != 'CFM' else 'l/s' x = st.slider(input_unit, min_value=50, max_value=20000, value=500, step=10) x = st.number_input('', value=x) if input_unit == 'CFM': p1 = conv_core.Cal(CFM=x) second_output = True elif input_unit == 'l/s': p1 = conv_core.Cal(lps=x) result = p1.airflow() if second_output == True: st.write("Result:", x, str(input_unit), ' is equal to', result, str(output_unit), " or", round(result * 3.6, 2), " m³/hr", '.') else: st.write("Result:", x, str(input_unit), ' is equal to', result, str(output_unit) + '.')
def velocity_conv(): second_output = False st.markdown('##### Velocity Input') input_unit = st.selectbox('Select input velocity unit', options=['FPS', 'FPM', 'm/s']) output_unit = 'FPS' if input_unit != 'FPS' and input_unit != 'FPM' else 'm/s' x = st.slider(input_unit, min_value=0.0, max_value=15.0, value=2.0, step=0.2) x = st.number_input('', value=x) if input_unit == 'FPS': p1 = conv_core.Cal(FPS=x) elif input_unit == 'FPM': p1 = conv_core.Cal(FPS=(x / 60)) elif input_unit == 'm/s': p1 = conv_core.Cal(mps=x) result = p1.velocity() if second_output == True: st.write("Result:", x, str(input_unit), ' is equal to', result, str(output_unit), " or", round(result * 60, 2), " FPM", '.') else: st.write("Result:", x, str(input_unit), ' is equal to', result, str(output_unit) + '.')
def temperature_conv(): st.markdown('##### Temperature Input') input_unit = st.selectbox('Select input temperature unit', options=['°F', '°C']) output_unit = '°F' if input_unit != '°F' else '°C' x = st.slider(input_unit, min_value=-50, max_value=250, value=68, step=1) x = st.number_input('', value=x) if input_unit == '°F': p1 = conv_core.Cal(F=x) elif input_unit == '°C': p1 = conv_core.Cal(C=x) result = p1.temperature() st.write("Result:", x, str(input_unit), ' is equal to', result, str(output_unit) + '.')
def waterflow_conv(): st.markdown('##### Water flowrate Input') input_unit = st.selectbox('Select input water flowrate unit', options=['GPM', 'l/s']) output_unit = 'GPM' if input_unit != 'GPM' else 'l/s' x = st.slider(input_unit, min_value=1.0, max_value=200.0, value=23.0, step=0.1) x = st.number_input('', value=x) if input_unit == 'GPM': p1 = conv_core.Cal(GPM=x) elif input_unit == 'l/s': p1 = conv_core.Cal(lps=x) result = p1.waterflow() st.write("Result:", x, str(input_unit), ' is equal to', result, str(output_unit) + '.')
def pressure_conv(): input = st.selectbox('Select input pressure unit', options=[ 'in.w.g.', 'ft.w.g.', 'Pa', 'kPa', 'Pa/m', 'kPa/100m', 'in.w.g. per 100ft', 'ft.w.g. per 100ft' ]) second_output = False if input == 'in.w.g.': slider_setting = { "input_unit": 'in.w.g.', "output_unit": 'Pa', "min": 0.01, "max": 2.0, "start": 0.03, "step": 0.01, "factor": 1 } if input == 'ft.w.g.': slider_setting = { "input_unit": 'in.w.g.', "output_unit": 'Pa', "min": 1, "max": 50, "start": 10, "step": 1, "factor": 12 } if input == 'Pa': slider_setting = { "input_unit": 'Pa', "output_unit": 'in.w.g.', "min": 15, "max": 1000, "start": 50, "step": 1, "factor": 1 } second_output = True second_unit = "ft.w.g." if input == 'kPa': slider_setting = { "input_unit": 'Pa', "output_unit": 'in.w.g.', "min": 1.0, "max": 10.0, "start": 1.0, "step": 0.2, "factor": 1000 } second_output = True second_unit = "ft.w.g." if input == 'Pa/m' or input == 'kPa/100m': slider_setting = { "input_unit": 'Pa/m', "output_unit": 'in.w.g. per 100ft', "min": 0.4, "max": 1.2, "start": 0.8, "step": 0.05, "factor": 1 } second_output = True second_unit = "ft.w.g. per 100ft" if input == 'in.w.g. per 100ft': slider_setting = { "input_unit": 'in.w.g. per 100ft', "output_unit": 'Pa/m', "min": 0.01, "max": 0.1, "start": 0.08, "step": 0.01, "factor": 1 } if input == 'ft.w.g. per 100ft': slider_setting = { "input_unit": 'in.w.g. per 100ft', "output_unit": 'Pa/m', "min": 1.0, "max": 5.0, "start": 3.0, "step": 0.1, "factor": 12 } x = st.slider(input, min_value=slider_setting['min'], max_value=slider_setting['max'], value=slider_setting['start'], step=slider_setting['step']) x = st.number_input('', value=x) if slider_setting['input_unit'] == 'Pa': p1 = conv_core.Cal(pa=x * slider_setting['factor']) elif slider_setting['input_unit'] == 'in.w.g.': p1 = conv_core.Cal(inwg=x * slider_setting['factor']) elif slider_setting['input_unit'] == 'in.w.g. per 100ft': p1 = conv_core.Cal(inwg_100ft=x * slider_setting['factor']) elif slider_setting['input_unit'] == 'Pa/m': p1 = conv_core.Cal(pa_m=x * slider_setting['factor']) result = p1.pressure() if second_output == True: st.write("Result:", x, str(input), " is equal to", result, str(slider_setting['output_unit']), "or", round(result / 12, 2), second_unit, ".") else: st.write("Result:", x, str(input), " is equal to", result, str(slider_setting['output_unit']), ".")