Modest collection of electrical energy calculation tools.
Project description
energy_tools
Modest collection of electrical energy calculation tools.
Content:
Installation
Requirements
Basic requirements:
- Python 3.8+;
- numpy.
Development additional requirements:
- black;
- pre-commit;
- pytest;
- twine.
Installing energy_tools
With pip
- Open a command prompt (e.g. Start > cmd on windows systems);
- Install energy_tools by running:
pip install -U --user energy_tools
Without pip
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:
- Download and unzip the current energy_tools distribution from PyPi under “Download files”.
- Open a command prompt (e.g. Start > cmd on Windows) and navigate to the folder that contains the setup.py file with the command cd :
cd %path_to_energy_tools%\energy_tools-x.x.x\
Install energy_tools by running :
python setup.py install
Development version
To install the latest development version of energy_tools from GitLab, simply follow these steps:
- Download and install git.
- Open a git shell and navigate to the directory where you want to keep your energy_tools files.
- Run the following commands:
python -m venv energy_tools
cd energy_tools
git clone https://gitlab.com/miek770/energy_tools.git
source Scripts/activate
pip install -U pip
pip install -U wheel
pip install -r energy_tools/requirements-dev.txt
- Navigate inside the repository and check out the develop branch:
cd energy_tools
git checkout develop
- Install Black using pre-commit:
pre-commit install
Test your installation
To test your installed development version, run pytest from the energy_tools' base directory:
pytest
Features
energy_tools
currently includes the following modules:
complex
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.
energy_factors
The energy_factors
module includes functions to calculate yearly energy factors for special calculations. Currently, it includes the utilisation_factor
and loss_factor
functions.
misc
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.
per_unit
The per_unit
module includes functions that return the base current, impedance and power.
phasor
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:
- amp: The unitless phasor amplitude.
- pha: The phasor's phase in degrees.
- real: The phasor's real part (interpreted as a complex number).
- imag: The phasor's imaginary part (interpreted as a complex number).
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.
power
The power
module includes 2 functions p()
and q()
which calculate the active power and reactive power based on at least 2 of the following arguments:
p
: Active power (forq()
).q
: Reactive power (forp()
).s
: Apparent power.pf
: Power factor.
The arguments and return value are unitless.
Usage
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
Contributing
If you wish to contribute, please follow the development version instructions above and refer to the project's contribution guide.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file energy_tools-1.1.1.tar.gz
.
File metadata
- Download URL: energy_tools-1.1.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f84d17ef00befa04ddfa73d9eb9244fb243b2da8ebc965bf768b7ec41420810 |
|
MD5 | 4f040046f1b24da909162cea4570d5cd |
|
BLAKE2b-256 | 1f70af0625abf905eb5ba5a13325238df7b37fdb039e418ab9d81966ba65e33c |
File details
Details for the file energy_tools-1.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: energy_tools-1.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75b6469859b8098014e4ee940ae2d36415ae3866fd330a62307b9abf02d79472 |
|
MD5 | b0120be8ca8bf0ec3173fce6ab184c69 |
|
BLAKE2b-256 | c82c7db586e1788367ebfe0c058ee3f0bbdf921bfd2da2bdbaba4ff22e9a1aed |