Spaces:
Build error
Build error
Create app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354!pip install gradio# Import necessary librariesimport gradio as gr
# Function to calculate load distributiondef load_calculation(load_rating, num_of_loads, voltage, load_type): # Constants safety_factor = 1.25 # 25% safety margin cable_size_factor = 1.5 # Approximation factor for cable size
# Calculate total load (kW to kVA conversion for inductive loads) if load_type == "Inductive": total_load = load_rating * num_of_loads * 1.2 # Assuming 0.8 power factor else: total_load = load_rating * num_of_loads
# Calculate current current = (total_load * 1000) / (voltage * (3**0.5) if voltage > 240 else voltage)
# Calculate breaker size breaker_size = round(current * safety_factor, 2)
# Calculate cable size (approximation) cable_size = round(current * cable_size_factor, 2)
# Return the results return f""" Total Load: {round(total_load, 2)} kW Recommended Breaker Size: {breaker_size} A Suggested Cable Size: {cable_size} mm² """
# Gradio interfacedef interface(): # Inputs load_rating = gr.Number(label="Load Rating per Device (kW)") num_of_loads = gr.Number(label="Number of Loads") voltage = gr.Number(label="Voltage (230V for single-phase, 400V for three-phase)") load_type = gr.Dropdown(choices=["Resistive", "Inductive"], label="Load Type")
# Outputs output = gr.Textbox(label="Load Calculation Results")
# Launch the Gradio app gr.Interface( fn=load_calculation, inputs=[load_rating, num_of_loads, voltage, load_type], outputs=output, title="Load Calculation Assistant", description="Calculate load, breaker size, and cable size for electrical systems." ).launch()
# Run the interfaceinterface()app.pyAdded+54