muhammadshaheryar commited on
Commit
0b76d6c
·
verified ·
1 Parent(s): cae177b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -22
app.py CHANGED
@@ -1,29 +1,70 @@
1
- # Install required libraries
2
 
3
- # CT Sizing Calculation
4
  def calculate_ct_size(primary_current, secondary_current, burden, accuracy_factor):
5
- """
6
- Calculate CT size based on input parameters.
7
-
8
- Parameters:
9
- - primary_current: Maximum load current (Amps)
10
- - secondary_current: Standard CT secondary current (Amps)
11
- - burden: Total load on CT secondary circuit (Ohms)
12
- - accuracy_factor: Safety factor for sizing
13
-
14
- Returns:
15
- - CT size (Amps)
16
- """
17
  ct_size = primary_current / secondary_current * accuracy_factor
18
  return ct_size
19
 
20
- # Example Usage in Google Colab
21
- if __name__ == "__main__":
22
- print("Example CT Sizing Calculation:")
23
- primary_current = 500 # Example primary current in Amps
24
- secondary_current = 5 # Example secondary current in Amps
25
- burden = 10 # Example burden in Ohms
26
- accuracy_factor = 1.2 # Example safety factor
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ct_size = calculate_ct_size(primary_current, secondary_current, burden, accuracy_factor)
29
- print(f"Calculated CT Size: {ct_size} Amps")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
 
3
+ # CT Sizing Calculation Function
4
  def calculate_ct_size(primary_current, secondary_current, burden, accuracy_factor):
 
 
 
 
 
 
 
 
 
 
 
 
5
  ct_size = primary_current / secondary_current * accuracy_factor
6
  return ct_size
7
 
8
+ # App UI Configuration
9
+ st.set_page_config(
10
+ page_title="CT Sizing Calculator",
11
+ page_icon="⚡",
12
+ layout="centered",
13
+ initial_sidebar_state="expanded"
14
+ )
15
 
16
+ # App Header
17
+ st.title("⚡ CT Sizing Calculator for Substations")
18
+ st.subheader("Easily calculate CT sizes for 132kV, 220kV, and 500kV substations")
19
+
20
+ # Sidebar for Instructions
21
+ with st.sidebar:
22
+ st.header("Instructions")
23
+ st.markdown(
24
+ """
25
+ 1. Enter the **Primary Current** in Amps (A).
26
+ 2. Select the **Secondary Current** (1A or 5A).
27
+ 3. Specify the **Burden** (total load in Ohms).
28
+ 4. Adjust the **Accuracy Factor** (typical range: 1.0–2.0).
29
+ 5. Click **Calculate CT Size** to see the results.
30
+ """
31
+ )
32
+ st.markdown("For questions or feedback, contact [[email protected]](mailto:[email protected]).")
33
+
34
+ # Main Input Form
35
+ with st.form("ct_sizing_form"):
36
+ st.write("### Input Parameters")
37
+
38
+ col1, col2 = st.columns(2)
39
+
40
+ # Input fields
41
+ primary_current = col1.number_input("🔌 Primary Current (Amps)", min_value=1.0, value=500.0, step=1.0)
42
+ secondary_current = col2.radio("🔄 Secondary Current (Amps)", options=[1, 5], index=1)
43
+
44
+ col3, col4 = st.columns(2)
45
+
46
+ burden = col3.number_input("⚙️ Burden (Ohms)", min_value=1.0, value=10.0, step=0.1)
47
+ accuracy_factor = col4.slider("📊 Accuracy Factor", min_value=1.0, max_value=2.0, value=1.2, step=0.01)
48
+
49
+ # Submit button
50
+ submitted = st.form_submit_button("Calculate CT Size")
51
+
52
+ # Display Results
53
+ if submitted:
54
  ct_size = calculate_ct_size(primary_current, secondary_current, burden, accuracy_factor)
55
+
56
+ # Display results with a success message
57
+ st.success(f"✅ Calculated CT Size: **{ct_size:.2f} Amps**")
58
+
59
+ # Additional information
60
+ st.info(
61
+ """
62
+ - Ensure the calculated CT size meets substation requirements.
63
+ - Consult applicable standards (e.g., IEC 61869) for validation.
64
+ """
65
+ )
66
+
67
+ # Footer
68
+ st.markdown("---")
69
+ st.markdown("Designed with ❤️ by [Your Name](https://github.com/your-profile)")
70
+