Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,50 +1,59 @@
|
|
1 |
-
|
2 |
import streamlit as st
|
3 |
import numpy as np
|
4 |
from sklearn.linear_model import LinearRegression
|
5 |
import pandas as pd
|
6 |
|
7 |
-
#
|
8 |
-
st.title("Transformer Tap Changer Optimization App")
|
|
|
|
|
|
|
9 |
|
10 |
# Input fields for voltage and load
|
11 |
-
voltage_in = st.number_input("Enter the Input Voltage (kV)", min_value=
|
12 |
-
voltage_out = st.number_input("Enter the Output Voltage (kV)", min_value=
|
13 |
load = st.number_input("Enter the Current Load (MW)", min_value=50, max_value=500, value=250)
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
#
|
31 |
-
#
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
#
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
3 |
from sklearn.linear_model import LinearRegression
|
4 |
import pandas as pd
|
5 |
|
6 |
+
# Title of the app
|
7 |
+
st.title("132/11 kV Transformer Tap Changer Optimization App")
|
8 |
+
|
9 |
+
# Nominal secondary voltage (11.5 kV)
|
10 |
+
nominal_secondary_voltage = 11.5
|
11 |
|
12 |
# Input fields for voltage and load
|
13 |
+
voltage_in = st.number_input("Enter the Input Voltage (132 kV)", min_value=100, max_value=150, value=132)
|
14 |
+
voltage_out = st.number_input("Enter the Output Voltage (11 kV)", min_value=10.0, max_value=15.0, value=11.0)
|
15 |
load = st.number_input("Enter the Current Load (MW)", min_value=50, max_value=500, value=250)
|
16 |
|
17 |
+
# Convert secondary voltage to primary voltage using transformer ratio (132 kV / 11 kV)
|
18 |
+
# This is the nominal transformer voltage ratio
|
19 |
+
transformer_ratio = 132 / 11
|
20 |
+
|
21 |
+
# Calculate the optimal tap position based on output voltage
|
22 |
+
def calculate_optimal_tap(voltage_in, voltage_out, load):
|
23 |
+
# Desired output voltage should be 11.5 kV (nominal secondary voltage)
|
24 |
+
target_voltage_out = nominal_secondary_voltage
|
25 |
+
|
26 |
+
# Calculate the required primary voltage to achieve desired secondary voltage (11.5 kV)
|
27 |
+
required_primary_voltage = target_voltage_out * transformer_ratio
|
28 |
+
|
29 |
+
# Calculate the voltage deviation from nominal (in primary)
|
30 |
+
voltage_deviation = voltage_in - required_primary_voltage
|
31 |
+
|
32 |
+
# Optimizing tap changer setting based on voltage deviation
|
33 |
+
# Assuming tap positions range from -13 (decreasing voltage) to +13 (increasing voltage)
|
34 |
+
# Tap range can be calculated based on the voltage deviation and transformer ratio
|
35 |
+
tap_position = round(voltage_deviation / (voltage_in / 27)) # 27 is the number of taps
|
36 |
+
|
37 |
+
# Ensure that the tap position is within the range of the 27-tap MR tap changer
|
38 |
+
if tap_position > 13:
|
39 |
+
tap_position = 13
|
40 |
+
elif tap_position < -13:
|
41 |
+
tap_position = -13
|
42 |
+
|
43 |
+
# Return the tap position recommendation
|
44 |
+
return tap_position
|
45 |
+
|
46 |
+
# Button to get the recommended tap position
|
47 |
+
if st.button('Get Tap Position'):
|
48 |
+
# Calculate the optimal tap position
|
49 |
+
optimal_tap = calculate_optimal_tap(voltage_in, voltage_out, load)
|
50 |
+
|
51 |
+
# Show the recommended tap position
|
52 |
+
st.write(f"**Recommended Tap Position**: Tap {optimal_tap} (Adjust to maintain 11.5 kV output)")
|
53 |
+
|
54 |
+
# Display additional results
|
55 |
+
st.write(f"**Nominal Secondary Voltage**: {nominal_secondary_voltage} kV")
|
56 |
+
st.write(f"**Input Voltage**: {voltage_in} kV")
|
57 |
+
st.write(f"**Output Voltage**: {voltage_out} kV")
|
58 |
+
st.write(f"**Current Load**: {load} MW")
|
59 |
|