Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ def calculate_relay_curve(tr_kva, tr_volt, ct_pr, ct_sec, fac, tms, i_f_fac, cur
|
|
33 |
st.error("Error: Division by zero in fault trip time calculation. Check input values.")
|
34 |
return
|
35 |
|
36 |
-
# Generate data for the relay curve
|
37 |
x_curr = np.linspace(pick * ct_pr * 1.1, pick * ct_pr * 5, 500)
|
38 |
y_time = []
|
39 |
for x in x_curr:
|
@@ -51,14 +51,22 @@ def calculate_relay_curve(tr_kva, tr_volt, ct_pr, ct_sec, fac, tms, i_f_fac, cur
|
|
51 |
st.write(f'**Trip Time:** {round(fault_time, 3)} sec')
|
52 |
|
53 |
# Plot the relay curve
|
54 |
-
fig, ax = plt.subplots()
|
55 |
ax.plot(x_curr, y_time, label="Relay Curve", color='blue')
|
|
|
|
|
56 |
ax.axvline(x=i_f, color='red', linestyle='--', label=f"Fault Current: {i_f} A")
|
57 |
ax.axhline(y=fault_time, color='green', linestyle='--', label=f"Trip Time: {round(fault_time, 3)} sec")
|
|
|
|
|
58 |
ax.set_xlabel('Current (Amp)')
|
59 |
ax.set_ylabel('Time (sec)')
|
60 |
ax.set_title(f"Relay Curve: {curve}")
|
|
|
|
|
61 |
ax.legend()
|
|
|
|
|
62 |
st.pyplot(fig)
|
63 |
|
64 |
# Streamlit app layout
|
|
|
33 |
st.error("Error: Division by zero in fault trip time calculation. Check input values.")
|
34 |
return
|
35 |
|
36 |
+
# Generate data for the relay curve (current vs time)
|
37 |
x_curr = np.linspace(pick * ct_pr * 1.1, pick * ct_pr * 5, 500)
|
38 |
y_time = []
|
39 |
for x in x_curr:
|
|
|
51 |
st.write(f'**Trip Time:** {round(fault_time, 3)} sec')
|
52 |
|
53 |
# Plot the relay curve
|
54 |
+
fig, ax = plt.subplots(figsize=(10, 6))
|
55 |
ax.plot(x_curr, y_time, label="Relay Curve", color='blue')
|
56 |
+
|
57 |
+
# Mark the fault current and trip time on the graph
|
58 |
ax.axvline(x=i_f, color='red', linestyle='--', label=f"Fault Current: {i_f} A")
|
59 |
ax.axhline(y=fault_time, color='green', linestyle='--', label=f"Trip Time: {round(fault_time, 3)} sec")
|
60 |
+
|
61 |
+
# Adding labels and title
|
62 |
ax.set_xlabel('Current (Amp)')
|
63 |
ax.set_ylabel('Time (sec)')
|
64 |
ax.set_title(f"Relay Curve: {curve}")
|
65 |
+
|
66 |
+
# Adding a legend
|
67 |
ax.legend()
|
68 |
+
|
69 |
+
# Show the plot
|
70 |
st.pyplot(fig)
|
71 |
|
72 |
# Streamlit app layout
|