0% found this document useful (0 votes)
11 views6 pages

Transformer Design Bot

The document is a Python Flask application that calculates transformer design parameters based on user inputs such as kVA, Ki, Ks, Kw, and del_. It performs various core, winding, impedance, and loss calculations, then displays the results in a web interface. The application includes error handling to manage input issues and provides a simple HTML form for user interaction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Transformer Design Bot

The document is a Python Flask application that calculates transformer design parameters based on user inputs such as kVA, Ki, Ks, Kw, and del_. It performs various core, winding, impedance, and loss calculations, then displays the results in a web interface. The application includes error handling to manage input issues and provides a simple HTML form for user interaction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Transformer Design Bot:

from flask import Flask, request, render_template_string


import math

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])


def calculate():
result = {}
if request.method == 'POST':
# Inputs
try:
kVA = float(request.form['kVA'])
Ki = float(request.form['Ki'])
Ks = float(request.form['Ks'])
Kw = float(request.form['Kw'])
del_ = float(request.form['del_'])

# Core Calculations
E = math.sqrt(kVA * 1000 / 3) / 40
Ai = E / (4.44 * 50 * 1.7) * 1e6
d = math.ceil(math.sqrt(4 * Ai / (Ki * Ks * math.pi)))
Ai = Ki * Ks * (math.pi / 4) * d**2
Bm = E / (4.44 * 50 * Ai) # Bm in Tesla
Aw = kVA / (3.33 * Ai * Kw * del_ * Bm * 50 * 1e-3)

# Window dimensions
dw = 1 * 250 # window width (can change)
hw = math.ceil(Aw / dw)
hww = hw # Window height
yoke = 17 # Clearance to yoke (can change)
wA = dw * hww
dc = d
Wc = 0.95 * dc
D = dw + Wc # Distance between adjacent limbs
hwwy = hww + yoke
Wt = 2 * D + Wc # Total window width
Ht = hwwy + 2 * Wc # Total window height

# LV and HV winding
Vp = 415 / math.sqrt(3)
Tpl = math.ceil(Vp / E) # LV
Tph = math.ceil((11 * 1e3) / E) # HV
Tph = math.ceil(Tph + Tph * 0.05) # Tapping 5%

# LV winding
Ipl = round(kVA * 1e3 / (math.sqrt(3) * 415))
a2 = Ipl / del_
T = 14.39
W = 18 # Cross-section dimensions

# HV winding
Iph = round(kVA * 1e3 / (3 * 11 * 1e3))
a1 = Iph / del_
d = math.ceil(math.sqrt(4 * a1 / math.pi))
a1 = math.pi * d**2 / 4
Acw = 2 * (a1 * Tph + a2 * Tpl)
Kwr = Acw / Aw # Should be near 0.29

# LV coil
a=2
tp = math.ceil(Tpl / a)
i = (W + 0.25) * (T + 0.25)
l = (T + 0.25) * 2
Cdw = l * a
hwlv = math.ceil(tp * (W + 0.25))
tc = l * a
dcl = 3.5 # Distance between coil and LV
Id = dc + (2 * dcl) # Inside diameter
Od = Id + (2 * Cdw) # Outside diameter
Md = Id + Cdw # Mean diameter
Tlv = math.pi * Md # Mean length

# HV coil
a1h = 15
c=4
Dl = 12 # Distance between LV and HV
Id1 = Od + Dl * 2 # Inside diameter
tch = math.ceil(Tph / c)
tp1 = math.ceil(tch / a1h)
h = math.ceil(tp1 * (d + 0.25))
tc1 = (d + 0.25) * a1h
Od1 = Id1 + (2 * tc1)
Md1 = Id1 + tc1
Thv = math.pi * Md1
hwhv = (h * c) + 8 + 8 + 8
HW = hwhv + 26 * 2

# Impedance and resistance calculations


Lmt = (Tlv + Thv) / 2
hc = (hwlv + hwhv) / 2
k = (Dl + (tc + tc1) / 3) * 1e-3
X = ((2 * math.pi * 50 * 4 * math.pi * 1e-7 * Lmt * Ipl * Tpl) / (E * hc)) * k
P20 = 0.01724
a20 = 0.00393
P75 = P20 * (1 + a20 * (75 - 20))
r2 = (P75 * Tlv * Tpl) / (a2 * 1e3)
r1 = (P75 * Thv * Tph) / (a1 * 1e3)
rT = round((11 * 1e3) / Vp)
Req = (r1 + r2 * rT**2)
R = (r1 + r2 * rT**2) / ((11 * 1e3) / Iph)

# Percentage impedance
Z = math.sqrt(R**2 + X**2)

# Losses
V = (Wt * 2 + hwwy * 3) * Ai
WcI = (V * 7.85) / (1e6) # Weight of iron
Cl = WcI * Bm * 0.736 * 1e6 # Core loss
VAkg = 10
VA = VAkg * WcI
Wlv = (8.89 * a2 * Tpl * Tlv) / (1e6) # Weight of LV coil
Whv = (8.89 * a1 * Tph * Thv) / (1e6) # Weight of HV coil
WT = 3 * (Wlv + Whv)
CL = 3 * (r1 + r2 * rT**2) * Iph**2
LL = CL * 1.27 # Load loss
TL = Cl + LL

# Loss percentages
load_loss = ((LL * 1e-3) / kVA) * 100
total_loss = ((TL * 1e-3) / kVA) * 100
copper_loss = ((CL * 1e-3) / kVA) * 100
stray_loss = (((LL - CL) * 1e-3) / kVA) * 100
no_load_loss = ((Cl * 1e-3) / kVA) * 100
Z = Z * 100

# Outputs
result = {
"Window width": dw,
"Window height": hww,
"Core diameter": dc,
"Largest core": Wc,
"Total window width": Wt,
"Total window height": Ht,
"Percentage impedance": Z,
"Load loss percentage": load_loss,
"Total loss percentage": total_loss,
"Copper loss percentage": copper_loss,
"Stray loss percentage": stray_loss,
"No load loss percentage": no_load_loss,
}
except Exception as e:
result = {"error": str(e)}

return render_template_string(template, result=result)

For template,

template = """
<!doctype html>
<html lang="en">
<head>
<title>Transformer Calculations</title>
</head>
<body>
<h1>Transformer Calculations</h1>
<form method="post">
kVA: <input type="text" name="kVA" required><br>
Ki: <input type="text" name="Ki" required><br>
Ks: <input type="text" name="Ks" required><br>
Kw: <input type="text" name="Kw" required><br>
del_: <input type="text" name="del_" required><br>
<button type="submit">Calculate</button>
</form>

{% if result %}
<h2>Results:</h2>
<ul>
{% for key, value in result.items() %}
<li>{{ key }}: {{ value }}</li>
{% endfor %}
</ul>
{% endif %}
</body>
</html>
"""

if __name__ == '__main__':
app.run(debug=True)

You might also like