Package: energy-tools
energy_toolsModest collection of electrical energy calculation tools.Content:InstallationRequirementsInstalling energy_toolsWith pipWithout pipDevelopment versionTest your installationFeaturescomplexenergy_factorsmiscper_unitphasorpowerUsageContributingInstallationRequirementsBasic requirements:Python 3.8+;numpy.Development additional requirements:black;pre-commit;pytest;twine.Installing energy_toolsWith pipOpen a command prompt (e.g. Start > cmd on windows systems);Install energy_tools by running:pip install -U --user energy_toolsWithout pipIf 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 installDevelopment versionTo 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.txtNavigate inside the repository and check out the develop branch:cd energy_tools
git checkout developInstallBlackusing pre-commit:pre-commit installTest your installationTo test your installed development version, run pytest from the energy_tools' base directory:pytestFeaturesenergy_toolscurrently includes the following modules:complexThecomplexmodule includes an improvedEleComplexclass which adds the following attributes (properties):phase,module.EleComplex.phasereturns the complex number's phase in degrees.EleComplex.modulereturns the complex number's amplitude.Thecomplexmodule also includes acomplex_impedancefunction that returns an improvedEleComplexnumber, based on a provided real impedancezand anX/Rratio.TheEleComplexclass must be imported in order for some of the other tools to be usable:fromenergy_tools.compleximportEleComplexSeeUsagebelow for more details.energy_factorsTheenergy_factorsmodule includes functions to calculate yearly energy factors for special calculations. Currently, it includes theutilisation_factorandloss_factorfunctions.miscThemiscmodule includes basic functions to manipulate impedances, includingserie,parallel,zCapandzInd. These calculate series impedance, parallel impedances, capacitance impedance and inductance impedance respectively.per_unitTheper_unitmodule includes functions that return the base current, impedance and power.phasorThephasormodule includes a new data typePhasorfor 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).Thephasormodule also includes functionssequencesandphasors. 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.powerThepowermodule includes 2 functionsp()andq()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.UsageSample usage may be found in thetestsdirectory. Most of these tools are straightforward (or aim to be), so the tests and docstrings should be helpful enough.As mentionedabove, theEleComplexclass must be imported in order for many of the other tools to be usable:fromenergy_tools.compleximportEleComplexWhen the improvedEleComplextype is imported this way, the following call will result in variableabeing anenergy_tools.complex.EleComplexinstance, as expected:a = EleComplex(1, 1)
a.phase #  Will return 45 degreesImplicitly declaring a complex number, however, will return the built-incomplextype:a = 1 + 1j
a.phase #  Will raise AttributeErrorContributingIf you wish to contribute, please follow the development version instructions above and refer to the project'scontribution guide.