Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,23 @@ st.markdown("- Power Factor")
|
|
| 11 |
st.markdown("- Reactive Power (kVAR)")
|
| 12 |
st.markdown("- Capacitor Rating Recommendation to Compensate Reactive Power")
|
| 13 |
st.markdown("- Capacitor kVAR Contribution")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Inputs
|
| 16 |
voltage = st.number_input("Enter Voltage (V)", min_value=0.0, step=0.1)
|
|
@@ -63,6 +80,15 @@ if st.button("Calculate"):
|
|
| 63 |
st.write(f"To compensate the **{round(reactive_power, 2)} kVAR** of reactive power:")
|
| 64 |
st.write(f"💡 Required Capacitor Size: **{round(required_capacitance_uF, 2)} µF**")
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
# Display Capacitor Reactive Power (kVAR)
|
| 67 |
if required_capacitance_uF > 0:
|
| 68 |
st.subheader("Capacitor Reactive Power Contribution:")
|
|
@@ -70,7 +96,6 @@ if st.button("Calculate"):
|
|
| 70 |
st.write(f"the capacitor will provide **{round(capacitor_reactive_power, 2)} kVAR** of reactive power.")
|
| 71 |
else:
|
| 72 |
st.write("No compensation needed as reactive power is zero or negative.")
|
| 73 |
-
|
| 74 |
else:
|
| 75 |
st.warning("Please enter valid voltage and current values.")
|
| 76 |
|
|
@@ -78,3 +103,4 @@ if st.button("Calculate"):
|
|
| 78 |
|
| 79 |
|
| 80 |
|
|
|
|
|
|
| 11 |
st.markdown("- Reactive Power (kVAR)")
|
| 12 |
st.markdown("- Capacitor Rating Recommendation to Compensate Reactive Power")
|
| 13 |
st.markdown("- Capacitor kVAR Contribution")
|
| 14 |
+
st.markdown("- Capacitor Bank Combination Suggestion")
|
| 15 |
+
|
| 16 |
+
# Suggest capacitor bank combination using standard sizes
|
| 17 |
+
def suggest_capacitor_bank(target_kvar, available_units=[25, 20, 15, 10, 5, 2.5]):
|
| 18 |
+
result = []
|
| 19 |
+
remaining = target_kvar
|
| 20 |
+
|
| 21 |
+
for unit in available_units:
|
| 22 |
+
count = int(remaining // unit)
|
| 23 |
+
if count > 0:
|
| 24 |
+
result.append((unit, count))
|
| 25 |
+
remaining -= unit * count
|
| 26 |
+
|
| 27 |
+
if remaining > 0:
|
| 28 |
+
result.append(("Remaining uncompensated", round(remaining, 2)))
|
| 29 |
+
|
| 30 |
+
return result
|
| 31 |
|
| 32 |
# Inputs
|
| 33 |
voltage = st.number_input("Enter Voltage (V)", min_value=0.0, step=0.1)
|
|
|
|
| 80 |
st.write(f"To compensate the **{round(reactive_power, 2)} kVAR** of reactive power:")
|
| 81 |
st.write(f"💡 Required Capacitor Size: **{round(required_capacitance_uF, 2)} µF**")
|
| 82 |
|
| 83 |
+
# Suggest Capacitor Bank Combination
|
| 84 |
+
bank_recommendation = suggest_capacitor_bank(reactive_power)
|
| 85 |
+
st.subheader("🧮 Capacitor Bank Recommendation:")
|
| 86 |
+
for item in bank_recommendation:
|
| 87 |
+
if isinstance(item[0], (int, float)):
|
| 88 |
+
st.write(f"🔸 {item[1]} x {item[0]} kVAR capacitor(s)")
|
| 89 |
+
else:
|
| 90 |
+
st.warning(f"⚠️ {item[1]} kVAR is not compensated (no exact match)")
|
| 91 |
+
|
| 92 |
# Display Capacitor Reactive Power (kVAR)
|
| 93 |
if required_capacitance_uF > 0:
|
| 94 |
st.subheader("Capacitor Reactive Power Contribution:")
|
|
|
|
| 96 |
st.write(f"the capacitor will provide **{round(capacitor_reactive_power, 2)} kVAR** of reactive power.")
|
| 97 |
else:
|
| 98 |
st.write("No compensation needed as reactive power is zero or negative.")
|
|
|
|
| 99 |
else:
|
| 100 |
st.warning("Please enter valid voltage and current values.")
|
| 101 |
|
|
|
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
+
|