Aizaz96 commited on
Commit
d6164bf
Β·
verified Β·
1 Parent(s): 89fd235

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -8
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  import time
 
3
 
4
  st.set_page_config(page_title="Structural Designer (Imperial Units)", layout="centered")
5
  st.title("πŸ—οΈ Structural Component Designer (Layman-Friendly)")
@@ -36,28 +37,60 @@ else:
36
  sbc = sbc_defaults[soil_type]
37
  st.markdown(f"**Estimated SBC:** {sbc} psf based on soil type")
38
 
39
- # πŸ”„ Mocked Grok API response
40
  def call_mock_grok_api(inputs):
41
- time.sleep(1.5) # simulate delay
42
  return {
43
  "slab": {
44
  "type": "Two-way" if inputs["slab_length"] / inputs["slab_width"] < 2 else "One-way",
45
- "thickness": 6 + 0.1 * inputs["floors"]
 
 
46
  },
47
  "beam": {
48
  "depth": 12 + (5 if inputs["carries_heavy_items"] == "Yes" else 0),
49
- "reinforcement": "#4 bars @ 6\" c/c top and bottom"
 
 
 
50
  },
51
  "column": {
52
  "size": "12x12",
53
- "reinforcement": "4 #5 bars with ties @ 8\" c/c"
 
54
  },
55
  "footing": {
56
  "size": f"{round(1.5 + 0.1 * inputs['floors'], 2)} x {round(1.5 + 0.1 * inputs['floors'], 2)} ft",
57
- "reinforcement": "#4 bars @ 6\" both ways"
 
 
58
  }
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  if st.button("🧠 Run Design"):
62
  inputs = {
63
  "building_type": building_type,
@@ -79,18 +112,21 @@ if st.button("🧠 Run Design"):
79
  st.subheader("πŸ”Ή Slab Design")
80
  st.write(f"**Type:** {grok_response['slab']['type']}")
81
  st.write(f"**Thickness:** {grok_response['slab']['thickness']} inches")
 
82
 
83
  st.subheader("πŸ”Ή Beam Design")
84
  st.write(f"**Recommended Depth:** {grok_response['beam']['depth']} inches")
85
  st.write(f"**Reinforcement:** {grok_response['beam']['reinforcement']}")
 
86
 
87
  st.subheader("πŸ”Ή Column Design")
88
  st.write(f"**Column Size:** {grok_response['column']['size']} inches")
89
  st.write(f"**Reinforcement:** {grok_response['column']['reinforcement']}")
 
90
 
91
  st.subheader("πŸ”Ή Footing Design")
92
  st.write(f"**Footing Size:** {grok_response['footing']['size']}")
93
  st.write(f"**Reinforcement:** {grok_response['footing']['reinforcement']}")
 
94
 
95
- st.success("βœ… Design completed using mock Grok engine.")
96
-
 
1
  import streamlit as st
2
  import time
3
+ import matplotlib.pyplot as plt
4
 
5
  st.set_page_config(page_title="Structural Designer (Imperial Units)", layout="centered")
6
  st.title("πŸ—οΈ Structural Component Designer (Layman-Friendly)")
 
37
  sbc = sbc_defaults[soil_type]
38
  st.markdown(f"**Estimated SBC:** {sbc} psf based on soil type")
39
 
40
+ # πŸ”„ Mocked Grok API logic
41
  def call_mock_grok_api(inputs):
42
+ time.sleep(1.5)
43
  return {
44
  "slab": {
45
  "type": "Two-way" if inputs["slab_length"] / inputs["slab_width"] < 2 else "One-way",
46
+ "thickness": 6 + 0.1 * inputs["floors"],
47
+ "bars_top": 6,
48
+ "bars_bottom": 6
49
  },
50
  "beam": {
51
  "depth": 12 + (5 if inputs["carries_heavy_items"] == "Yes" else 0),
52
+ "reinforcement": "#4 bars @ 6\" c/c top and bottom",
53
+ "top_bars": 2,
54
+ "bottom_bars": 2,
55
+ "stirrups": 5
56
  },
57
  "column": {
58
  "size": "12x12",
59
+ "reinforcement": "4 #5 bars with ties @ 8\" c/c",
60
+ "bars": 4
61
  },
62
  "footing": {
63
  "size": f"{round(1.5 + 0.1 * inputs['floors'], 2)} x {round(1.5 + 0.1 * inputs['floors'], 2)} ft",
64
+ "reinforcement": "#4 bars @ 6\" both ways",
65
+ "bars_x": 5,
66
+ "bars_y": 5
67
  }
68
  }
69
 
70
+ # Drawing functions
71
+ def draw_rebars(title, x_bars, y_bars=None):
72
+ fig, ax = plt.subplots()
73
+ ax.set_aspect('equal')
74
+ ax.set_xlim(0, 10)
75
+ ax.set_ylim(0, 10)
76
+ ax.axis('off')
77
+
78
+ if y_bars is None: # 1D bars
79
+ spacing = 8 / (x_bars + 1)
80
+ for i in range(x_bars):
81
+ ax.plot([1 + spacing * (i + 1)]*2, [2, 8], 'r', linewidth=2)
82
+ else: # Grid (2D) bars
83
+ spacing_x = 8 / (x_bars + 1)
84
+ spacing_y = 8 / (y_bars + 1)
85
+ for i in range(x_bars):
86
+ ax.plot([1 + spacing_x * (i + 1)]*2, [2, 8], 'r', linewidth=1.5)
87
+ for j in range(y_bars):
88
+ ax.plot([2, 8], [1 + spacing_y * (j + 1)]*2, 'b', linewidth=1.5)
89
+
90
+ ax.set_title(title)
91
+ st.pyplot(fig)
92
+
93
+ # Run design
94
  if st.button("🧠 Run Design"):
95
  inputs = {
96
  "building_type": building_type,
 
112
  st.subheader("πŸ”Ή Slab Design")
113
  st.write(f"**Type:** {grok_response['slab']['type']}")
114
  st.write(f"**Thickness:** {grok_response['slab']['thickness']} inches")
115
+ draw_rebars("Slab Reinforcement", grok_response['slab']['bars_top'], grok_response['slab']['bars_bottom'])
116
 
117
  st.subheader("πŸ”Ή Beam Design")
118
  st.write(f"**Recommended Depth:** {grok_response['beam']['depth']} inches")
119
  st.write(f"**Reinforcement:** {grok_response['beam']['reinforcement']}")
120
+ draw_rebars("Beam Reinforcement", grok_response['beam']['bottom_bars'])
121
 
122
  st.subheader("πŸ”Ή Column Design")
123
  st.write(f"**Column Size:** {grok_response['column']['size']} inches")
124
  st.write(f"**Reinforcement:** {grok_response['column']['reinforcement']}")
125
+ draw_rebars("Column Vertical Bars", grok_response['column']['bars'])
126
 
127
  st.subheader("πŸ”Ή Footing Design")
128
  st.write(f"**Footing Size:** {grok_response['footing']['size']}")
129
  st.write(f"**Reinforcement:** {grok_response['footing']['reinforcement']}")
130
+ draw_rebars("Footing Reinforcement", grok_response['footing']['bars_x'], grok_response['footing']['bars_y'])
131
 
132
+ st.success("βœ… Design completed with visual detailing.")