acpower
index
download acpower.py

A python module containing classes and functions for quickly making power
engineering calculations at the Python prompt.
 
Put in your current directory and load with 'import acpower' after starting
python. You may then create phasors with something like:
 
     $ python
     Python 2.6.4 (r264:75706, Oct 27 2009, 06:25:13)
     [GCC 4.4.1] on linux2
     Type "help", "copyright", "credits" or "license" for more information.
     >>> import acpower
     >>> v = acpower.Phasor(1+3j)
     >>> v
     phasor with:
     polar coods        =  3.162 /_ 71.565
     rectangular coords =  1.000+3.000j
 
You can call the helper functions with 'acpower.function(args)'
e.g:
 
     >>> z = acpower.Phasor([1.414,44.977])
     >>> z
     phasor with:
     polar coods        =  1.414 /_ 44.977
     rectangular coords =  1.000+0.999j
     >>> total = acpower.parallel(v,z)
     >>> total
     phasor with:
     polar coords       =  1.000 /_ 53.113
     rectangular coords =  0.600+0.800j
 
The python operators are overloaded, so you can use +,-,*,and / like you
would with an int or a float:
 
     >>> v/z
     phasor with:
     polar coods        =  2.236 /_ 0.464
     rectangular coords =  2.000+1.001j
 
By default all angles are in degrees. You can change this to radians with:
 
      >>> acpower.angle_unit = "rad"
 
eg:
 
      >>> z
      phasor with:
      polar coords       =  1.414 /_ 44.977
      rectangular coords =  1.000+0.999j
      >>> acpower.angle_unit = "rad"
      >>> z
      phasor with:
      polar coords       =  1.414 /_ 0.785
      rectangular coords =  1.000+0.999j
 
and back with:
 
      >>> acpower.angle_unit = "deg"

 
Modules
       
math

 
Classes
       
Phasor

 
class Phasor
    An object with magnitude and phase. Contains two internal representaions,
a complex number in rectangular form, and a magnitude and phase. Possible
ways to create a phasor:
 
No arguments:
 
    >>> p = acpower.Phasor()   - sets everything to zero
         
With an ordinary complex number:
    
    >>> p = acpower.Phasor(1+3j)
 
With a list or tuple of magnitude and phase:
    
    >>> p = acpower.Phasor([1.414,0.785])
 
  Methods defined here:
__add__(self, other)
Returns the phasor that is the sum of two phasor arguments.
__div__(self, other)
Returns the result of dividing the first phasor by the second.
__init__(self, z=0j)
__mul__(self, other)
Returns the product of two phasors.
__repr__(self)
# this is the string representation you see. (syntax is like printf)
__sub__(self, other)
Returns the phasor that is the second argument subracted
from the first.

 
Functions
       
apparent_power(V, I)
Return the apparent power of the phasors voltage V and current I.
average_power(V, I)
Return the average power of the phasors voltage V and current I.
complex_power(V, I)
Return the complex power of the phasors voltage V and current I.
deg2rad(theta)
Convert the given angle from degrees to radians.
is_phasor(p)
Returns true or false depending on whether the given object is a phasor.
is_scalar(p)
Returns true or false depending on whether the given object is a phasor.
parallel(*impedances)
Return the equivalent total impedance of a list of impedances in parallel.
power_factor(V, I)
Return the power factor of the phasors voltage V and current I.
rad2deg(theta)
Convert the given angle from radians to degrees.
reactive_power(V, I)
Return the reactive power of the phasors voltage V and current I.
series(*impedances)
Return the equivalent total impedance of a list of impedances in series.

 
Data
        angle_unit = 'deg'