Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Example usage of the Continuous Beam RC Design application | |
| This script demonstrates how to use the ContinuousBeam class programmatically | |
| """ | |
| from continuous_beam import ContinuousBeam | |
| def example_design(): | |
| """ | |
| Example: Design a 3-span continuous beam | |
| """ | |
| print("Continuous Beam RC Design Example") | |
| print("="*50) | |
| # Create beam instance | |
| beam = ContinuousBeam() | |
| # Set beam properties | |
| beam.beam_width = 300 # mm | |
| beam.beam_depth = 500 # mm | |
| beam.fc = 28 # MPa | |
| beam.fy = 420 # MPa | |
| beam.cover = 40 # mm | |
| beam.d = beam.beam_depth - beam.cover | |
| print(f"Beam dimensions: {beam.beam_width} × {beam.beam_depth} mm") | |
| print(f"Material properties: f'c = {beam.fc} MPa, fy = {beam.fy} MPa") | |
| print(f"Effective depth: {beam.d} mm") | |
| print() | |
| # Add spans | |
| beam.add_span(length=6.0, distributed_load=25.0) # Span 1: 6m, 25 kN/m | |
| beam.add_span(length=8.0, distributed_load=30.0) # Span 2: 8m, 30 kN/m | |
| beam.add_span(length=5.0, distributed_load=20.0) # Span 3: 5m, 20 kN/m | |
| print("Spans added:") | |
| for i, span in enumerate(beam.spans): | |
| print(f" Span {i+1}: Length = {span['length']}m, Load = {span['distributed_load']} kN/m") | |
| print() | |
| # Perform design | |
| try: | |
| design_results = beam.design_beam() | |
| # Generate report | |
| report = beam.generate_report(design_results) | |
| print(report) | |
| # Additional analysis | |
| print("\n" + "="*60) | |
| print("DESIGN SUMMARY") | |
| print("="*60) | |
| total_steel = 0 | |
| max_moment = 0 | |
| max_shear = 0 | |
| for span_data in design_results: | |
| span_num = span_data['span'] | |
| print(f"\nSpan {span_num} ({span_data['length']}m):") | |
| for reinf in span_data['reinforcement']: | |
| if reinf['As_required'] > 0: | |
| total_steel += reinf['As_provided'] | |
| if abs(reinf['moment']) > abs(max_moment): | |
| max_moment = reinf['moment'] | |
| print(f" {reinf['location']}: {reinf['bars']} (As = {reinf['As_provided']:.0f} mm²)") | |
| for stirrup in span_data['stirrups']: | |
| if stirrup['shear'] != 0 and abs(stirrup['shear']) > abs(max_shear): | |
| max_shear = stirrup['shear'] | |
| print(f"\nOverall Summary:") | |
| print(f" Total steel area: {total_steel:.0f} mm²") | |
| print(f" Maximum moment: {max_moment:.2f} kN-m") | |
| print(f" Maximum shear: {max_shear:.2f} kN") | |
| print(f" Steel ratio: {total_steel/(beam.beam_width * beam.d * len(beam.spans))*100:.2f}%") | |
| except Exception as e: | |
| print(f"Design failed: {e}") | |
| def run_gui(): | |
| """ | |
| Launch the GUI application | |
| """ | |
| try: | |
| from beam_design_app import main | |
| print("Launching GUI application...") | |
| main() | |
| except ImportError as e: | |
| print(f"GUI application not available: {e}") | |
| print("Please install tkinter and matplotlib to use the GUI") | |
| if __name__ == "__main__": | |
| # Run example design | |
| example_design() | |
| # Ask user if they want to launch GUI | |
| print("\n" + "="*60) | |
| response = input("Would you like to launch the GUI application? (y/n): ").lower().strip() | |
| if response in ['y', 'yes']: | |
| run_gui() |