amkj84 commited on
Commit
17e3c13
·
verified ·
1 Parent(s): 68f221e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -73
app.py CHANGED
@@ -1,81 +1,83 @@
1
  import streamlit as st
2
- import matplotlib.pyplot as plt
3
- import numpy as np
4
- import time
5
 
6
  # Page Configurations
7
  st.set_page_config(
8
- page_title="CBT: Gun Firing Internal Mechanism",
9
  layout="centered"
10
  )
11
 
12
  # Title and Description
13
- st.title("CBT: Gun Firing Internal Mechanism")
14
- st.write("This app simulates the internal mechanism of a gun firing process, including the combustion and pressure dynamics inside the chamber.")
15
-
16
- # Parameters Input
17
- st.sidebar.header("Simulation Parameters")
18
- chamber_pressure = st.sidebar.number_input("Chamber Pressure (MPa):", min_value=1, max_value=100, value=50, step=1)
19
- barrel_length = st.sidebar.number_input("Barrel Length (cm):", min_value=10, max_value=200, value=50, step=5)
20
- bullet_mass = st.sidebar.number_input("Bullet Mass (grams):", min_value=1, max_value=50, value=10, step=1)
21
- gas_expansion_ratio = st.sidebar.slider("Gas Expansion Ratio:", min_value=1.0, max_value=5.0, value=1.5, step=0.1)
22
-
23
- def simulate_internal_mechanism():
24
- # Constants
25
- chamber_pressure_pa = chamber_pressure * 1e6 # Convert MPa to Pa
26
- barrel_length_m = barrel_length / 100 # Convert cm to meters
27
- bullet_mass_kg = bullet_mass / 1000 # Convert grams to kg
28
-
29
- # Time array for simulation (arbitrary resolution)
30
- time_steps = np.linspace(0, 0.01, num=500) # 10 ms simulation
31
-
32
- # Pressure dynamics (simplified as linear decay for simulation purposes)
33
- pressure_profile = chamber_pressure_pa * np.exp(-time_steps / (gas_expansion_ratio * 0.002))
34
-
35
- # Force on bullet
36
- force_profile = pressure_profile * (np.pi * (0.01)**2) # Assuming a barrel diameter of 2 cm
37
-
38
- # Acceleration of bullet
39
- acceleration_profile = force_profile / bullet_mass_kg
40
-
41
- # Velocity and displacement
42
- velocity = np.cumsum(acceleration_profile * np.diff(np.insert(time_steps, 0, 0)))
43
- displacement = np.cumsum(velocity * np.diff(np.insert(time_steps, 0, 0)))
44
-
45
- return time_steps, pressure_profile, velocity, displacement
46
-
47
- # Simulate and Plot
48
- if st.button("Simulate Gun Firing!"):
49
- st.write("## Internal Mechanism Simulation")
50
- st.write("Simulating the internal dynamics of the gun firing process...")
51
-
52
- time_steps, pressure_profile, velocity, displacement = simulate_internal_mechanism()
53
-
54
- # Plot Chamber Pressure
55
- fig1, ax1 = plt.subplots()
56
- ax1.plot(time_steps * 1000, pressure_profile / 1e6, label="Chamber Pressure")
57
- ax1.set_xlabel("Time (ms)")
58
- ax1.set_ylabel("Pressure (MPa)")
59
- ax1.set_title("Chamber Pressure Over Time")
60
- ax1.legend()
61
- st.pyplot(fig1)
62
-
63
- # Plot Bullet Velocity
64
- fig2, ax2 = plt.subplots()
65
- ax2.plot(time_steps * 1000, velocity, label="Bullet Velocity")
66
- ax2.set_xlabel("Time (ms)")
67
- ax2.set_ylabel("Velocity (m/s)")
68
- ax2.set_title("Bullet Velocity Over Time")
69
- ax2.legend()
70
- st.pyplot(fig2)
71
-
72
- # Plot Bullet Displacement
73
- fig3, ax3 = plt.subplots()
74
- ax3.plot(time_steps * 1000, displacement, label="Bullet Displacement")
75
- ax3.set_xlabel("Time (ms)")
76
- ax3.set_ylabel("Displacement (m)")
77
- ax3.set_title("Bullet Displacement Over Time")
78
- ax3.legend()
79
- st.pyplot(fig3)
80
-
81
- st.write("Simulation Complete! Explore the dynamics of the gun's internal firing mechanism.")
 
 
 
 
 
 
1
  import streamlit as st
 
 
 
2
 
3
  # Page Configurations
4
  st.set_page_config(
5
+ page_title="CBT: Digestive System for Class 6",
6
  layout="centered"
7
  )
8
 
9
  # Title and Description
10
+ st.title("CBT: Digestive System")
11
+ st.write("This Computer-Based Tutorial (CBT) is designed for Class 6 students to learn about the digestive system in an interactive way.")
12
+
13
+ # Sidebar
14
+ st.sidebar.header("Navigation")
15
+ sections = ["Introduction", "Organs of the Digestive System", "Process of Digestion", "Quiz"]
16
+ selected_section = st.sidebar.radio("Select Section:", sections)
17
+
18
+ if selected_section == "Introduction":
19
+ st.header("Introduction")
20
+ st.write("The digestive system is a group of organs that work together to break down food into smaller parts so the body can use them for energy, growth, and repair.")
21
+ st.image("https://upload.wikimedia.org/wikipedia/commons/thumb/e/e5/Digestive_system_diagram_en.svg/1200px-Digestive_system_diagram_en.svg.png", caption="Diagram of the Digestive System")
22
+
23
+ elif selected_section == "Organs of the Digestive System":
24
+ st.header("Organs of the Digestive System")
25
+ st.write("The digestive system includes the following major organs:")
26
+ st.markdown("""
27
+ - **Mouth**: The starting point of digestion where food is chewed and mixed with saliva.
28
+ - **Esophagus**: A tube that connects the mouth to the stomach.
29
+ - **Stomach**: Breaks down food using acids and enzymes.
30
+ - **Small Intestine**: Absorbs nutrients from food.
31
+ - **Large Intestine**: Absorbs water and forms waste products.
32
+ - **Liver**: Produces bile to help digest fats.
33
+ - **Pancreas**: Produces enzymes that help in digestion.
34
+ - **Rectum and Anus**: Store and eliminate waste.
35
+ """)
36
+
37
+ elif selected_section == "Process of Digestion":
38
+ st.header("Process of Digestion")
39
+ st.write("The process of digestion involves several steps:")
40
+ st.markdown("""
41
+ 1. **Ingestion**: Food enters the mouth.
42
+ 2. **Propulsion**: Food moves through the esophagus to the stomach.
43
+ 3. **Mechanical Digestion**: Food is physically broken down into smaller pieces.
44
+ 4. **Chemical Digestion**: Enzymes break down food into simpler molecules.
45
+ 5. **Absorption**: Nutrients are absorbed into the bloodstream in the small intestine.
46
+ 6. **Elimination**: Waste is eliminated through the rectum and anus.
47
+ """)
48
+
49
+ elif selected_section == "Quiz":
50
+ st.header("Quiz: Test Your Knowledge")
51
+ st.write("Answer the following questions to test your knowledge of the digestive system.")
52
+
53
+ # Question 1
54
+ question1 = st.radio(
55
+ "1. Which organ is responsible for absorbing nutrients from food?",
56
+ ("Mouth", "Stomach", "Small Intestine", "Large Intestine")
57
+ )
58
+ if question1 == "Small Intestine":
59
+ st.success("Correct! The small intestine absorbs nutrients from food.")
60
+ elif question1:
61
+ st.error("Incorrect. The correct answer is 'Small Intestine'.")
62
+
63
+ # Question 2
64
+ question2 = st.radio(
65
+ "2. What is the function of bile?",
66
+ ("To digest proteins", "To help digest fats", "To break down carbohydrates", "To eliminate waste")
67
+ )
68
+ if question2 == "To help digest fats":
69
+ st.success("Correct! Bile helps in the digestion of fats.")
70
+ elif question2:
71
+ st.error("Incorrect. The correct answer is 'To help digest fats'.")
72
+
73
+ # Question 3
74
+ question3 = st.radio(
75
+ "3. Which organ produces enzymes for digestion?",
76
+ ("Liver", "Stomach", "Pancreas", "Esophagus")
77
+ )
78
+ if question3 == "Pancreas":
79
+ st.success("Correct! The pancreas produces enzymes that aid in digestion.")
80
+ elif question3:
81
+ st.error("Incorrect. The correct answer is 'Pancreas'.")
82
+
83
+ st.write("Keep learning and practicing!")