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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -2
app.py CHANGED
@@ -800,10 +800,67 @@ with gr.Blocks() as demo:
800
  inputs=[initial_input, final_input],
801
  outputs=titre_output
802
  )
803
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
804
  test_calculate_titre()
805
 
806
- test_calculate_concentration()
807
 
808
  demo.launch()
809
 
 
800
  inputs=[initial_input, final_input],
801
  outputs=titre_output
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
+ )
845
+
846
+ concentration_output = gr.Textbox(
847
+ label="Calculation Result"
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
 
865
  demo.launch()
866