ChemDave commited on
Commit
a4d4d5e
·
verified ·
1 Parent(s): 0d06bc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -22
app.py CHANGED
@@ -802,43 +802,47 @@ with gr.Blocks() as demo:
802
  )
803
 
804
  # Section 3: Concentration calculator
 
 
805
  with gr.Tab("Concentration Calculator"):
806
  gr.Markdown(
807
- "### Calculate an unknown solution concentration\n"
808
- "Use the balanced chemical equation to account for "
809
- "the mole ratio. Enter both volumes in mL."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
810
  )
811
 
812
  known_concentration_input = gr.Number(
813
- label="Known solution concentration (mol/dm³)",
814
  value=0.100,
815
  precision=4
816
  )
817
 
818
  known_volume_input = gr.Number(
819
- label="Known solution volume / titre (mL)",
820
  value=24.30,
821
  precision=2
822
  )
823
 
824
  unknown_volume_input = gr.Number(
825
- label="Unknown solution volume (mL)",
826
  value=25.00,
827
  precision=2
828
  )
829
 
830
- unknown_coefficient_input = gr.Number(
831
- label="Coefficient of unknown solution in equation",
832
- value=1,
833
- precision=0
834
- )
835
-
836
- known_coefficient_input = gr.Number(
837
- label="Coefficient of known solution in equation",
838
- value=1,
839
- precision=0
840
- )
841
-
842
  concentration_button = gr.Button(
843
  "Calculate Concentration"
844
  )
@@ -848,17 +852,17 @@ with gr.Blocks() as demo:
848
  )
849
 
850
  concentration_button.click(
851
- fn=calculate_concentration,
852
  inputs=[
 
853
  known_concentration_input,
854
  known_volume_input,
855
- unknown_volume_input,
856
- unknown_coefficient_input,
857
- known_coefficient_input
858
  ],
859
  outputs=concentration_output
860
  )
861
 
 
862
  test_calculate_titre()
863
 
864
 
 
802
  )
803
 
804
  # Section 3: Concentration calculator
805
+
806
+ # Section 3: Guided concentration calculator
807
  with gr.Tab("Concentration Calculator"):
808
  gr.Markdown(
809
+ "### Calculate an unknown acid concentration\n"
810
+ "Select a supported reaction. Enter the known "
811
+ "solution concentration and both volumes in mL."
812
+ )
813
+
814
+ reaction_input = gr.Dropdown(
815
+ choices=[
816
+ "HCl unknown; NaOH known (1:1)",
817
+ "H2SO4 unknown; NaOH known (1:2)"
818
+ ],
819
+ value="HCl unknown; NaOH known (1:1)",
820
+ label="Select the reaction"
821
+ )
822
+
823
+ gr.Markdown(
824
+ "**HCl reaction:** HCl + NaOH → NaCl + H₂O\n\n"
825
+ "**H₂SO₄ reaction:** H₂SO₄ + 2NaOH → Na₂SO₄ + 2H₂O"
826
  )
827
 
828
  known_concentration_input = gr.Number(
829
+ label="Known NaOH concentration (mol/dm³)",
830
  value=0.100,
831
  precision=4
832
  )
833
 
834
  known_volume_input = gr.Number(
835
+ label="NaOH volume delivered / titre (mL)",
836
  value=24.30,
837
  precision=2
838
  )
839
 
840
  unknown_volume_input = gr.Number(
841
+ label="Unknown acid volume (mL)",
842
  value=25.00,
843
  precision=2
844
  )
845
 
 
 
 
 
 
 
 
 
 
 
 
 
846
  concentration_button = gr.Button(
847
  "Calculate Concentration"
848
  )
 
852
  )
853
 
854
  concentration_button.click(
855
+ fn=calculate_selected_concentration,
856
  inputs=[
857
+ reaction_input,
858
  known_concentration_input,
859
  known_volume_input,
860
+ unknown_volume_input
 
 
861
  ],
862
  outputs=concentration_output
863
  )
864
 
865
+
866
  test_calculate_titre()
867
 
868