-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlybackCalc.py
More file actions
42 lines (38 loc) · 1.02 KB
/
FlybackCalc.py
File metadata and controls
42 lines (38 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
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
def displayNum(num):
units = ['f', 'p', 'n', 'μ', 'm', '', 'k', 'M', 'G', 'T', 'P']
from math import log10
idx = max(min(5, int(log10(num)//3)), -5)
num /= 10**(idx * 3)
return str(round(num, 3)) + units[idx + 5]
VinMin = 170
Vout = 80
Vf = 0.4
D = 0.4
efcy = 0.9
Fsw = 300e3
Pout = 20
Bm = 0.2
Ae = 10.9e-6
Lp = efcy * D**2 * VinMin**2 / (2 * Fsw * Pout)
Ipk = 2*Pout / (efcy * VinMin * D)
N = VinMin / (Vout + Vf) * D / (1-D)
Np = Lp * Ipk / (Bm * Ae)
Ns = Np / N
if Np > Ns:
Ns2 = max(round(Ns), 1)
Np2 = round(Ns2 * N)
else:
Np2 = max(round(Np), 1)
Ns2 = round(Np2 / N)
VinRip = VinMin * 0.01
VoutRip = Vout * 0.01
N2 = Np2 / Ns2
Cin = Ipk/2 * (1/Fsw) * D / VinRip
Cout = Ipk*N2/2 * (1/Fsw) * (1-D) / VoutRip
print("N: " + str(round(N, 3)))
print("Lp: " + displayNum(Lp) + "H")
print("Ipk: " + str(round(Ipk, 3)) + "A")
print("Np: " + str(round(Np, 3)) + " -> " + str(Np2))
print("Ns: " + str(round(Ns, 3)) + " -> " + str(Ns2))
print("Cin: " + displayNum(Cin) + "F")
print("Cout: " + displayNum(Cout) + "F")