Sompote commited on
Commit
157b77e
·
verified ·
1 Parent(s): 4160060

Upload 7 files

Browse files
Files changed (2) hide show
  1. README.md +4 -4
  2. continuous_beam.py +124 -65
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Continuous Beam RC Design - Thai Standards
3
- emoji: 🏗️
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: gradio
7
- sdk_version: 5.34.2
8
  app_file: app.py
9
  pinned: false
10
  ---
@@ -57,4 +57,4 @@ A comprehensive continuous beam reinforced concrete design application using fin
57
 
58
  ---
59
 
60
- *Using advanced finite element analysis for accurate continuous beam behavior*
 
1
  ---
2
+ title: "Continuous Beam RC Design - Thai Standards"
3
+ emoji: "🏗️"
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: gradio
7
+ sdk_version: "4.0.0"
8
  app_file: app.py
9
  pinned: false
10
  ---
 
57
 
58
  ---
59
 
60
+ *Using advanced finite element analysis for accurate continuous beam behavior*
continuous_beam.py CHANGED
@@ -1078,87 +1078,139 @@ class ContinuousBeam:
1078
  ax.add_patch(plt.Rectangle((0, 0), total_length, beam_height,
1079
  fill=False, edgecolor='black', linewidth=2))
1080
 
1081
- # Draw stirrups for each span
1082
  for i, span_data in enumerate(design_results):
1083
  span_start = span_positions[i]
1084
  span_end = span_positions[i + 1]
1085
  span_length = span_end - span_start
1086
 
1087
- # Get stirrup information
1088
- stirrup_info = []
1089
  for stirrup in span_data['stirrups']:
1090
  if 'No stirrups' not in stirrup['stirrup_spacing']:
1091
- spacing_str = stirrup['stirrup_spacing'].replace(' mm c/c', '')
1092
- try:
1093
- spacing = float(spacing_str) / 1000 # Convert mm to m
1094
- stirrup_info.append({
1095
- 'location': stirrup['location'],
1096
- 'spacing': spacing,
1097
- 'shear': stirrup['shear']
1098
- })
1099
- except:
1100
- pass
 
 
 
 
 
 
 
 
1101
 
1102
- if stirrup_info:
1103
- # Determine stirrup spacing pattern
1104
- # For simplicity, use average spacing
1105
- avg_spacing = np.mean([s['spacing'] for s in stirrup_info])
 
 
 
 
1106
 
1107
- # Draw stirrups
1108
- num_stirrups = int(span_length / avg_spacing) + 1
1109
- for j in range(num_stirrups):
1110
- x_pos = span_start + j * avg_spacing
1111
- if x_pos <= span_end:
1112
- # Draw stirrup as vertical line
1113
- ax.plot([x_pos, x_pos], [0, beam_height], 'g-', linewidth=2, alpha=0.7)
1114
-
1115
- # Add stirrup symbol (small rectangle)
1116
- stirrup_width = avg_spacing * 0.1
1117
- ax.add_patch(plt.Rectangle((x_pos - stirrup_width/2, beam_height*0.1),
1118
- stirrup_width, beam_height*0.8,
1119
- fill=False, edgecolor='green', linewidth=1))
1120
-
1121
- # Add detailed spacing annotations with dimension lines
1122
- mid_span = (span_start + span_end) / 2
1123
 
1124
- # Main spacing annotation
1125
- ax.annotate(f'Stirrups @ {avg_spacing*1000:.0f}mm c/c',
1126
- xy=(mid_span, beam_height + 0.1),
1127
- ha='center', va='bottom', fontsize=9,
1128
- bbox=dict(boxstyle="round,pad=0.2", facecolor="lightgreen", alpha=0.7))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1129
 
1130
- # Add dimension lines between first few stirrups to show actual spacing
1131
- if num_stirrups >= 2:
1132
- # Show spacing between first two stirrups
1133
- x1 = span_start
1134
- x2 = span_start + avg_spacing
1135
- dim_y = beam_height + 0.25
1136
 
1137
- # Dimension line
1138
- ax.annotate('', xy=(x1, dim_y), xytext=(x2, dim_y),
1139
- arrowprops=dict(arrowstyle='<->', color='red', lw=1.5))
1140
 
1141
- # Dimension text
1142
- ax.text((x1 + x2) / 2, dim_y + 0.02, f'{avg_spacing*1000:.0f}mm',
1143
- ha='center', va='bottom', fontsize=8, color='red', fontweight='bold',
1144
- bbox=dict(boxstyle="round,pad=0.1", facecolor="white", alpha=0.9))
1145
 
1146
- # Vertical dimension lines from stirrups to dimension line
1147
- ax.plot([x1, x1], [beam_height, dim_y - 0.01], 'r--', linewidth=1, alpha=0.7)
1148
- ax.plot([x2, x2], [beam_height, dim_y - 0.01], 'r--', linewidth=1, alpha=0.7)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1149
 
1150
  # Draw supports
1151
- for pos in span_positions:
1152
  # Support line
1153
  ax.plot([pos, pos], [-0.1, beam_height + 0.05], 'r--', linewidth=2, alpha=0.7)
1154
 
1155
- # Support symbol
1156
  triangle = plt.Polygon([
1157
  [pos - 0.05, -0.1],
1158
  [pos + 0.05, -0.1],
1159
  [pos, -0.2]
1160
  ], fill=True, facecolor='red', edgecolor='black')
1161
  ax.add_patch(triangle)
 
 
 
1162
 
1163
  # Add dimension lines and labels
1164
  for i, span in enumerate(self.spans):
@@ -1174,20 +1226,27 @@ class ContinuousBeam:
1174
  ax.text(span_center, -0.35, f'{span["length"]}m',
1175
  ha='center', va='top', fontsize=10)
1176
 
1177
- # Formatting
1178
- ax.set_xlim(-0.2, total_length + 0.2)
1179
- ax.set_ylim(-0.5, beam_height + 0.4)
1180
  ax.set_xlabel('Distance along beam (m)', fontsize=12)
1181
- ax.set_ylabel('Beam Height', fontsize=12)
1182
- ax.set_title('Shear Stirrup Layout', fontsize=14, fontweight='bold')
1183
  ax.grid(True, alpha=0.3)
1184
 
1185
- # Add legend
1186
  legend_elements = [
1187
- plt.Line2D([0], [0], color='green', linewidth=2, alpha=0.7, label='Stirrups'),
1188
- plt.Line2D([0], [0], color='red', linestyle='--', linewidth=2, alpha=0.7, label='Supports')
 
 
1189
  ]
1190
- ax.legend(handles=legend_elements, loc='upper right')
 
 
 
 
 
1191
 
1192
  plt.tight_layout()
1193
 
 
1078
  ax.add_patch(plt.Rectangle((0, 0), total_length, beam_height,
1079
  fill=False, edgecolor='black', linewidth=2))
1080
 
1081
+ # Draw detailed stirrup layout for each span
1082
  for i, span_data in enumerate(design_results):
1083
  span_start = span_positions[i]
1084
  span_end = span_positions[i + 1]
1085
  span_length = span_end - span_start
1086
 
1087
+ # Get stirrup information with locations
1088
+ stirrup_regions = []
1089
  for stirrup in span_data['stirrups']:
1090
  if 'No stirrups' not in stirrup['stirrup_spacing']:
1091
+ # Extract stirrup type and spacing
1092
+ stirrup_parts = stirrup['stirrup_spacing'].split(' @ ')
1093
+ if len(stirrup_parts) == 2:
1094
+ stirrup_type = stirrup_parts[0] # e.g., "RB9" or "RB6"
1095
+ spacing_str = stirrup_parts[1].replace(' mm c/c', '')
1096
+ try:
1097
+ spacing_mm = float(spacing_str)
1098
+ spacing_m = spacing_mm / 1000
1099
+
1100
+ stirrup_regions.append({
1101
+ 'location': stirrup['location'],
1102
+ 'type': stirrup_type,
1103
+ 'spacing_mm': spacing_mm,
1104
+ 'spacing_m': spacing_m,
1105
+ 'shear': stirrup['shear']
1106
+ })
1107
+ except:
1108
+ pass
1109
 
1110
+ if stirrup_regions:
1111
+ # Create detailed stirrup pattern for the span
1112
+ # Divide span into regions based on stirrup requirements
1113
+ regions = {
1114
+ 'Left Support': {'start': span_start, 'end': span_start + span_length * 0.25},
1115
+ 'Mid-span': {'start': span_start + span_length * 0.25, 'end': span_start + span_length * 0.75},
1116
+ 'Right Support': {'start': span_start + span_length * 0.75, 'end': span_end}
1117
+ }
1118
 
1119
+ stirrup_positions = []
1120
+ stirrup_labels = []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1121
 
1122
+ for stirrup_region in stirrup_regions:
1123
+ location = stirrup_region['location']
1124
+ if location in regions:
1125
+ region_start = regions[location]['start']
1126
+ region_end = regions[location]['end']
1127
+ region_length = region_end - region_start
1128
+ spacing = stirrup_region['spacing_m']
1129
+
1130
+ # Calculate stirrup positions in this region
1131
+ num_stirrups = max(2, int(region_length / spacing) + 1)
1132
+ actual_spacing = region_length / (num_stirrups - 1) if num_stirrups > 1 else region_length
1133
+
1134
+ for j in range(num_stirrups):
1135
+ x_pos = region_start + j * actual_spacing
1136
+ if x_pos <= region_end:
1137
+ stirrup_positions.append(x_pos)
1138
+ stirrup_labels.append({
1139
+ 'x': x_pos,
1140
+ 'type': stirrup_region['type'],
1141
+ 'spacing': stirrup_region['spacing_mm'],
1142
+ 'location': location
1143
+ })
1144
 
1145
+ # Draw all stirrups
1146
+ colors = {'RB6': 'green', 'RB9': 'darkgreen'}
1147
+ for pos in stirrup_positions:
1148
+ # Draw stirrup as detailed U-shape
1149
+ stirrup_width = 0.02
 
1150
 
1151
+ # Main vertical lines
1152
+ ax.plot([pos, pos], [beam_height*0.05, beam_height*0.95], 'g-', linewidth=3, alpha=0.8)
 
1153
 
1154
+ # Horizontal top and bottom connections
1155
+ ax.plot([pos-stirrup_width, pos+stirrup_width], [beam_height*0.05, beam_height*0.05], 'g-', linewidth=2, alpha=0.8)
1156
+ ax.plot([pos-stirrup_width, pos+stirrup_width], [beam_height*0.95, beam_height*0.95], 'g-', linewidth=2, alpha=0.8)
 
1157
 
1158
+ # Side connections
1159
+ ax.plot([pos-stirrup_width, pos-stirrup_width], [beam_height*0.05, beam_height*0.95], 'g-', linewidth=2, alpha=0.8)
1160
+ ax.plot([pos+stirrup_width, pos+stirrup_width], [beam_height*0.05, beam_height*0.95], 'g-', linewidth=2, alpha=0.8)
1161
+
1162
+ # Add spacing dimensions between stirrups
1163
+ if len(stirrup_positions) >= 2:
1164
+ # Group consecutive stirrups and show spacing
1165
+ prev_pos = stirrup_positions[0]
1166
+ for k in range(1, min(4, len(stirrup_positions))): # Show first few spacings
1167
+ curr_pos = stirrup_positions[k]
1168
+ spacing_actual = (curr_pos - prev_pos) * 1000 # Convert to mm
1169
+
1170
+ # Dimension line above beam
1171
+ dim_y = beam_height + 0.15 + (k-1) * 0.08
1172
+ ax.annotate('', xy=(prev_pos, dim_y), xytext=(curr_pos, dim_y),
1173
+ arrowprops=dict(arrowstyle='<->', color='red', lw=1.5))
1174
+
1175
+ # Spacing text
1176
+ ax.text((prev_pos + curr_pos) / 2, dim_y + 0.02, f'{spacing_actual:.0f}mm',
1177
+ ha='center', va='bottom', fontsize=7, color='red', fontweight='bold',
1178
+ bbox=dict(boxstyle="round,pad=0.1", facecolor="white", alpha=0.9))
1179
+
1180
+ # Vertical dimension lines
1181
+ ax.plot([prev_pos, prev_pos], [beam_height, dim_y - 0.01], 'r--', linewidth=1, alpha=0.5)
1182
+ ax.plot([curr_pos, curr_pos], [beam_height, dim_y - 0.01], 'r--', linewidth=1, alpha=0.5)
1183
+
1184
+ prev_pos = curr_pos
1185
+
1186
+ # Add stirrup type and spacing summary
1187
+ mid_span = (span_start + span_end) / 2
1188
+
1189
+ # Create summary text for stirrup types used
1190
+ stirrup_summary = []
1191
+ for region in stirrup_regions:
1192
+ stirrup_summary.append(f"{region['type']} @ {region['spacing_mm']:.0f}mm ({region['location']})")
1193
+
1194
+ summary_text = "\n".join(stirrup_summary)
1195
+ ax.text(mid_span, beam_height + 0.4, f'Span {i+1} Stirrups:\n{summary_text}',
1196
+ ha='center', va='bottom', fontsize=8,
1197
+ bbox=dict(boxstyle="round,pad=0.3", facecolor="lightgreen", alpha=0.7))
1198
 
1199
  # Draw supports
1200
+ for i, pos in enumerate(span_positions):
1201
  # Support line
1202
  ax.plot([pos, pos], [-0.1, beam_height + 0.05], 'r--', linewidth=2, alpha=0.7)
1203
 
1204
+ # Support symbol (triangle)
1205
  triangle = plt.Polygon([
1206
  [pos - 0.05, -0.1],
1207
  [pos + 0.05, -0.1],
1208
  [pos, -0.2]
1209
  ], fill=True, facecolor='red', edgecolor='black')
1210
  ax.add_patch(triangle)
1211
+
1212
+ # Support label
1213
+ ax.text(pos, -0.25, f'Support {i+1}', ha='center', va='top', fontsize=8, fontweight='bold')
1214
 
1215
  # Add dimension lines and labels
1216
  for i, span in enumerate(self.spans):
 
1226
  ax.text(span_center, -0.35, f'{span["length"]}m',
1227
  ha='center', va='top', fontsize=10)
1228
 
1229
+ # Formatting with more space for detailed annotations
1230
+ ax.set_xlim(-0.3, total_length + 0.3)
1231
+ ax.set_ylim(-0.6, beam_height + 0.8)
1232
  ax.set_xlabel('Distance along beam (m)', fontsize=12)
1233
+ ax.set_ylabel('Beam Cross-Section', fontsize=12)
1234
+ ax.set_title('Detailed Shear Stirrup Layout with Spacing Dimensions', fontsize=14, fontweight='bold')
1235
  ax.grid(True, alpha=0.3)
1236
 
1237
+ # Add comprehensive legend
1238
  legend_elements = [
1239
+ plt.Line2D([0], [0], color='green', linewidth=3, alpha=0.8, label='Stirrups (U-shaped)'),
1240
+ plt.Line2D([0], [0], color='red', linestyle='-', linewidth=1.5, label='Spacing Dimensions'),
1241
+ plt.Line2D([0], [0], color='red', linestyle='--', linewidth=2, alpha=0.7, label='Supports'),
1242
+ plt.Rectangle((0,0),1,1, facecolor='lightgreen', alpha=0.7, label='Stirrup Details')
1243
  ]
1244
+ ax.legend(handles=legend_elements, loc='upper right', fontsize=10)
1245
+
1246
+ # Add beam dimensions annotation
1247
+ ax.text(total_length/2, -0.45, f'Beam: {self.beam_width}mm × {self.beam_depth}mm',
1248
+ ha='center', va='center', fontsize=10, fontweight='bold',
1249
+ bbox=dict(boxstyle="round,pad=0.3", facecolor="lightyellow", alpha=0.8))
1250
 
1251
  plt.tight_layout()
1252