Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # f2py -h only: Pre_xt1 Pre_vc Pre_PM duringpost : n.f95
- # f2py -c n.f95 -m calcu n.o
- import calcul
- import openpyxl
- import time
- import numpy as np
- import matplotlib.pyplot as plt
- start_time = time.time()
- book = openpyxl.load_workbook('data.xlsx')
- sheet = book.active
- data = []
- for ro in range(2,6):
- for co in range(1,8):
- #print('co =%d ro =%d' % (co, ro))
- a3 = sheet.cell(row=ro, column=co)
- data.append(a3.value)
- #รับค่าจาก excel และเปลี่ยนชนิดตัวแปร
- v1, v2, P, x1o, x2o, x3o, xgo = data
- x1 = complex(x1o)
- x2 = complex(x2o)
- x3 = complex(x3o)
- xg = complex(xgo)
- # ฟังชั่นการคำนวณจากฟอร์แทรน
- x12 = calcul.pre_xt1(x1, x2, x3)
- Vcurrent = calcul.pre_vc (v1, v2, P, x12) # <class 'tuple'>((0.9+0.3j), (1+0.1j))
- Voltage = Vcurrent[0]
- Curr = Vcurrent[1]
- PmEg = calcul.pre_pm(Voltage, v2, xg, x12, Curr) # <class 'tuple'>
- Pemax = PmEg[0]
- Eg = PmEg[1]
- ceta = np.arctan(Eg.imag/Eg.real)
- Pt = calcul.duringpost(x1,x2,x3,xg,Eg,v2)
- # แสดงผลการคำนวณและกราฟ
- print('Voltage Bus 1 = %.4f +%.4fi' % (Voltage.real, Voltage.imag))
- print('Current in transmission lines = %.4f +%.4fi' % (Curr.real, Curr.imag))
- print('Eg = %.4f +%.4fi' % (Eg.real, Eg.imag))
- print('----- Power angle equation -----')
- print('Pre fault P = %.3fsin(δ)' %(abs(Pemax)))
- print('During fault P = %.3fsin(δ)' %(abs(Pt[0])))
- print('Post fault P = %.3fsin(δ)' %(abs(Pt[1])))
- print('--------------------------------')
- x = np.linspace(0, np.pi, 200 )
- plt.plot(x,abs(Pemax)*np.sin(x),label = "Pre fault")
- plt.plot(x,(abs(Pt[0]))*np.sin(x),label = "During fault")
- plt.plot(x, (abs(Pt[1]))*np.sin(x), label = "Post fault")
- plt.xlabel('δ [rad]')
- plt.ylabel('Power [pu]')
- plt.legend()
- plt.show()
- data = []
- print("finish")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement