Skip to main content

energy_tools

Modest collection of electrical energy calculation tools.

Content:

Installation

pip install -U --user energy_tools

Development version

energy_tools is now managed with uv. After downloading or cloning the project from GitHub, run uv sync to fetch and install the requirements.

You can then test the installation with make tests or uv run python -m 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 (for q()).
  • q: Reactive power (for p()).
  • 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.

Release files for energy-tools 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for energy-tools 1.2.2
File Size Uploaded
energy_tools-1.2.2.tar.gz 26.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for energy-tools 1.2.2
File Interpreter ABI Platform
energy_tools-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.4 kB

Release files / energy_tools-1.2.2.tar.gz

Download URL energy_tools-1.2.2.tar.gz
Size 26.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e6ebff6c5341cdb4584969cc3373fb066ae4882ccc55d5311fafae3583e1e918
BLAKE2b-256 checksum
How to use checksums
b760b117938b588181b7f3a4aa30d32b6cf304c2ffc4914159c7b114804f57b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.22

Release files / energy_tools-1.2.2-py3-none-any.whl

Download URL energy_tools-1.2.2-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94d221ed43104a1b7e33115a5c06b137291a86dd30d7e4e03aa34e50f6cf57b4
BLAKE2b-256 checksum
How to use checksums
20620b4249d2ab16fc9a52642067351becd092ca47532961a2e9cb60c6155218
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.22

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page