Skip to main content

Modest collection of electrical energy calculation tools.

Project description

energy_tools

Modest collection of electrical energy calculation tools.

Content:

Installation

Requirements

Basic requirements:

Development requirements:

  • black;
  • pre-commit;
  • pytest;
  • twine.

Installing energy_tools

With pip

  1. Open a command prompt (e.g. Start > cmd on windows systems);
  2. Install energy_tools by running:
pip install 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:

  1. Download and unzip the current energy_tools distribution from PyPi under “Download files”.
  2. 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:

  1. Download and install git.
  2. Open a git shell and navigate to the directory where you want to keep your energy_tools files.
  3. Run the following commands:
/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 black numpy pre-commit pytest twine
  1. Navigate inside the repository and check out the develop branch:
cd energy_tools
git checkout develop
  1. Install Black using pre-commit:
pre-commit install
  1. Set your Python path to the outer energy_tools folder (/energy_tools, NOT energy_tools/energy_tools).
  2. If necessary, install missing dependencies via pip install (see Development requirements above).

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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

energy_tools-0.3.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

energy_tools-0.3.1-py2.py3-none-any.whl (9.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file energy_tools-0.3.1.tar.gz.

File metadata

  • Download URL: energy_tools-0.3.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for energy_tools-0.3.1.tar.gz
Algorithm Hash digest
SHA256 c3cd911804b5ae8e9ed9c0a9e2dd74bdba39c781e070fd1f9e4b68d62425c627
MD5 86504d874c87c7170fc3ad39eb0ded51
BLAKE2b-256 e1f890331861de521db66dc41238f13c99e40a7378de525209e6bb2139dc366c

See more details on using hashes here.

File details

Details for the file energy_tools-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: energy_tools-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for energy_tools-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b8c7814676c1f306ae77466c5171b2bbb8ac2e08505261f0ec2ed198e14310c0
MD5 52230a82868dfbbbc2456cece24bbe73
BLAKE2b-256 ef9038f25f38e00a5b13135174971365e40663b977ee4712f4b2329a166edd62

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page