Skip to content

Commit

Permalink
text_report with utf-8 encoding and minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
dioph committed Apr 4, 2020
1 parent 17588a8 commit 77b2a86
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions elegant/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def text_report(system, curves, grid, filename):
trafos = system.trafos
buses = system.buses
filepath = filename.strip('.pdf')
f = open(f'{filepath}.dat', 'w')
f = open(f'{filepath}.dat', 'w', encoding='utf-8')
now = datetime.datetime.now()
f.write(f'Report auto-generated by Elegant at '
f'{now.day:02d}/{now.month:02d}/{now.year:04d} '
Expand All @@ -261,7 +261,8 @@ def text_report(system, curves, grid, filename):
f.write('========\n\n')
f.write('1.1 Power-Flow Solution\n')
f.write('=======================\n\n')
f.write('Bus |V|(pu) \u03B4(deg) Pg(MW) Pl(MW) Qg(Mvar) Ql(Mvar) Zl(pu)\n')
f.write('Bus |V|(pu) \u03B4(deg) Pg(MW)'
' Pl(MW) Qg(Mvar) Ql(Mvar) Zl(pu)\n')
for b in buses:
f.write(f'{b.bus_id + 1:3d} '
f'{b.v:7.04f} '
Expand Down Expand Up @@ -292,31 +293,31 @@ def text_report(system, curves, grid, filename):
f.write('\n========\n')
f.write('2. Lines\n')
f.write('========\n\n')
f.write(' Line Parametrization Loss Flow\n')
f.write(' R (%pu) Xl (%pu) Bc (%pu) Ploss(MW) Qloss(Mvar) '
'P(MW) Q(Mvar) I/Imax(%%)\n')
f.write(' Line Parametrization Loss Flow\n')
f.write(' R (%pu) Xl (%pu) Bc (%pu) P(MW) Q(Mvar) '
' P(MW) Q(Mvar) I/Imax(%)\n')
for lt in lines:
f.write(f'{lt.orig.bus_id+1:2d}-{lt.dest.bus_id+1:<2d} '
f'{lt.Zpu.real*100:8.04f} '
f'{lt.Zpu.imag*100:8.04f} '
f'{lt.Ypu.imag*100:8.04f} '
f'{lt.Sper.real*100:9.02f} '
f'{lt.Sper.imag*100:11.02f} '
f'{lt.S2.real*100:5.02f} '
f'{lt.Sper.real*100:6.02f} '
f'{lt.Sper.imag*100:7.02f} '
f'{lt.S2.real*100:6.02f} '
f'{lt.S2.imag*100:7.02f} '
f'{np.abs(lt.Ia)/lt.imax*100:9.02f}\n')
f.write('\n========\n')
f.write('3. Trafos\n')
f.write('========\n\n')
f.write('Trafo Parametrization Loss Flow\n')
f.write(' x+(%pu) x0(%pu) Config. Qloss(Mvar) P(MW) Q(Mvar) S/Snom(%%)\n')
f.write('Trafo Parametrization Loss Flow\n')
f.write(' x+(%pu) x0(%pu) Config. Q(Mvar) P(MW) Q(Mvar) S/Snom(%)\n')
for tr in trafos:
f.write(f'{tr.orig.bus_id+1:2d}-{tr.dest.bus_id+1:<2d} '
f'{tr.Z1.imag*100:7.02f} '
f'{tr.Z0.imag*100:7.02f} '
f'{get_scheme_txt(tr)} '
f'{tr.Sper.imag*100:11.02f} '
f'{tr.S2.real*100:5.02f} '
f'{tr.Sper.imag*100:7.02f} '
f'{tr.S2.real*100:6.02f} '
f'{tr.S2.imag*100:7.02f} '
f'{np.abs(tr.S2)*1e8/tr.snom*100:9.02f}\n')
f.close()
Expand Down

0 comments on commit 77b2a86

Please sign in to comment.