Skip to content

Instantly share code, notes, and snippets.

@sash13
Created October 21, 2011 18:55
Show Gist options
  • Save sash13/1304634 to your computer and use it in GitHub Desktop.
Save sash13/1304634 to your computer and use it in GitHub Desktop.
Расчет ТОЭ схем в Python
from math import *
def toExpForm(a,s):
if a.real != 0:
real=sqrt(pow(a.real,2)+pow(a.imag,2))
agle=degrees(atan(a.imag/a.real))
else:
real=a.imag
agle=90.0 if a.imag>0 else -90.0
print (s+'='+str(round(a.real,3))+'','' if a.imag<0 else '+', str(round(a.imag,3))+'='+str(round(real,3)) + '∠' + str(round(agle,3)))
def tz(a,b,c):
return (a*c)/(a+b+c) , (b*c)/(a+b+c), (a*b)/(a+b+c)
a=4+3j
b=3+6j
c=7-3j
e=tz(a,b,c)
toExpForm(e[0],'Zao')
toExpForm(e[1],'Zbo')
toExpForm(e[2],'Zco')
toExpForm(a,'Za')
toExpForm(b,'Zb')
toExpForm(c,'Zc')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment