Modest collection of electrical energy calculation tools.
pip install energy-tools==0.2.1
Modest collection of electrical energy calculation tools.
Content:
Basic requirements:
Development requirements:
pip install energy_tools
If you don’t have internet access on your system or don’t want to use pip for some other reason, energy_tools can also be installed without using pip:
cd %path_to_energy_tools%\energy_tools-x.x.x\
Install energy_tools by running :
python setup.py install
To install the latest development version of energy_tools from GitLab, simply follow these steps:
/c/Python36/python.exe -m venv energy_tools
cd energy_tools
git clone https://gitlab.com/miek770/energy_tools.git
source Scripts/activate
python -m pip install -U pip
pip install numpy pre-commit pytest twine
cd energy_tools
git checkout develop
pre-commit install
To test your installed development version, run pytest from the energy_tools' base directory:
pytest
energy_tools
currently includes the following modules:
The complex
module includes an improved EleComplex
class which adds the following attributes (properties): phase
, module
.
EleComplex.phase
returns the complex number's phase in degrees.EleComplex.module
returns the complex number's amplitude.The complex
module also includes a complex_impedance
function that returns an improved EleComplex
number, based on a provided real impedance z and an X/R ratio.
The EleComplex
class must be imported in order for some of the other tools to be usable:
from energy_tools.complex import EleComplex
See Usage below for more details.
The energy_factors
module includes functions to calculate yearly energy factors for special calculations. Currently, it includes the utilisation_factor
and loss_factor
functions.
The misc
module includes basic functions to manipulate impedances, including serie
, parallel
, zCap
and zInd
. These calculate series impedance, parallel impedances, capacitance impedance and inductance impedance respectively.
The per_unit
module includes functions that return the base current, impedance and power.
The phasor
module includes a new data type Phasor
for the electrical phasor used in power systems.
A phasor is defined by an amplitude and a phase. The instance can be created either using those, or by providing a complex amplitude (in this case the phase is ignored). Several operations are supported, including: addition, substraction, multiplication, division, power, inversion and equality with either another phasor, a float or an integer.
It also provides a nice representation in this form: 120.000 @ 0.000°
Attributes:
The phasor
module also includes functions sequences
and phasors
. The former retuns phase A's sequence voltages from phase A, B and C's voltages. The latter does the opposite, i.e. it returns phase A, B and C's voltages from phases A's sequence voltages.
Sample usage may be found in the tests directory. Most of these tools are straightforward (or aim to be), so the tests and docstrings should be helpful enough.
As mentioned above, the EleComplex
class must be imported in order for many of the other tools to be usable:
from energy_tools.complex import EleComplex
When the improved EleComplex
type is imported this way, the following call will result in variable a
being an energy_tools.complex.EleComplex
instance, as expected:
a = EleComplex(1, 1)
a.phase # Will return 45 degrees
Implicitly declaring a complex number, however, will return the built-in complex
type:
a = 1 + 1j
a.phase # Will raise AttributeError
If you wish to contribute, please follow the development version instructions above and refer to the project's contribution guide.