muhammadshaheryar commited on
Commit
e1b87ca
·
verified ·
1 Parent(s): 1211d07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import numpy as np
2
- import pandas as pd
3
  import matplotlib.pyplot as plt
4
  import streamlit as st
5
 
@@ -9,6 +8,7 @@ def calculate_relay_curve(tr_kva, tr_volt, ct_pr, ct_sec, fac, tms, i_f_fac, cur
9
  pick = round(fac * tr_curr / ct_pr, 3)
10
  i_f = round(i_f_fac * tr_curr * fac, 3)
11
 
 
12
  if curve == 'IEC Normal Inverse':
13
  b_ = 0.14
14
  a_ = 0.02
@@ -25,13 +25,17 @@ def calculate_relay_curve(tr_kva, tr_volt, ct_pr, ct_sec, fac, tms, i_f_fac, cur
25
  st.error("Invalid Curve Selected.")
26
  return
27
 
 
28
  trip_t = b_ * tms / (((i_f * (ct_sec / ct_pr) / (pick * ct_sec)) ** a_) - 1)
29
 
 
30
  x_curr = np.linspace(pick * ct_pr + 0.1 * pick * ct_pr, pick * ct_pr * 5, 100)
31
  y_time = b_ * tms / (((x_curr * (ct_sec / ct_pr) / (pick * ct_sec)) ** a_) - 1)
32
 
 
33
  fault_time = b_ * tms / (((i_f * (ct_sec / ct_pr) / (pick * ct_sec)) ** a_) - 1)
34
 
 
35
  st.write('### Results:')
36
  st.write('**Rated Current:**', tr_curr, 'A')
37
  st.write('**Pickup:**', pick, 'x In')
@@ -40,18 +44,14 @@ def calculate_relay_curve(tr_kva, tr_volt, ct_pr, ct_sec, fac, tms, i_f_fac, cur
40
 
41
  # Plot the relay curve
42
  fig, ax = plt.subplots()
43
- ax.plot(x_curr, y_time)
44
- ax.plot(i_f, b_ * tms / (((i_f * (ct_sec / ct_pr) / (pick * ct_sec)) ** a_) - 1), 'o')
45
- ax.xlabel('Current (Amp)')
46
- ax.ylabel('Time (sec)')
47
- ax.title(f"Relay Curve: {curve}")
48
  ax.set_xlabel('Current (Amp)')
49
  ax.set_ylabel('Time (sec)')
50
  ax.set_title(f"Relay Curve: {curve}")
51
  ax.legend()
52
  st.pyplot(fig)
53
 
54
-
55
  # Streamlit app layout
56
  st.title("Relay Curve Calculator")
57
  st.sidebar.header("Input Parameters")
@@ -69,4 +69,3 @@ curve = st.sidebar.selectbox("Relay Curve Type", ['IEC Normal Inverse', 'IEC Ver
69
  # Run the calculation when the button is clicked
70
  if st.sidebar.button("Calculate"):
71
  calculate_relay_curve(tr_kva, tr_volt, ct_pr, ct_sec, fac, tms, i_f_fac, curve)
72
-
 
1
  import numpy as np
 
2
  import matplotlib.pyplot as plt
3
  import streamlit as st
4
 
 
8
  pick = round(fac * tr_curr / ct_pr, 3)
9
  i_f = round(i_f_fac * tr_curr * fac, 3)
10
 
11
+ # Curve coefficients
12
  if curve == 'IEC Normal Inverse':
13
  b_ = 0.14
14
  a_ = 0.02
 
25
  st.error("Invalid Curve Selected.")
26
  return
27
 
28
+ # Calculate trip time
29
  trip_t = b_ * tms / (((i_f * (ct_sec / ct_pr) / (pick * ct_sec)) ** a_) - 1)
30
 
31
+ # Generate data for the relay curve
32
  x_curr = np.linspace(pick * ct_pr + 0.1 * pick * ct_pr, pick * ct_pr * 5, 100)
33
  y_time = b_ * tms / (((x_curr * (ct_sec / ct_pr) / (pick * ct_sec)) ** a_) - 1)
34
 
35
+ # Fault time calculation
36
  fault_time = b_ * tms / (((i_f * (ct_sec / ct_pr) / (pick * ct_sec)) ** a_) - 1)
37
 
38
+ # Display results
39
  st.write('### Results:')
40
  st.write('**Rated Current:**', tr_curr, 'A')
41
  st.write('**Pickup:**', pick, 'x In')
 
44
 
45
  # Plot the relay curve
46
  fig, ax = plt.subplots()
47
+ ax.plot(x_curr, y_time, label="Relay Curve")
48
+ ax.plot(i_f, fault_time, 'ro', label="Fault Point")
 
 
 
49
  ax.set_xlabel('Current (Amp)')
50
  ax.set_ylabel('Time (sec)')
51
  ax.set_title(f"Relay Curve: {curve}")
52
  ax.legend()
53
  st.pyplot(fig)
54
 
 
55
  # Streamlit app layout
56
  st.title("Relay Curve Calculator")
57
  st.sidebar.header("Input Parameters")
 
69
  # Run the calculation when the button is clicked
70
  if st.sidebar.button("Calculate"):
71
  calculate_relay_curve(tr_kva, tr_volt, ct_pr, ct_sec, fac, tms, i_f_fac, curve)