Python Libraries with functions and constants related to electrical engineering.

Overview

logo

ElectricPy

Electrical-Engineering-for-Python

sphinx Tox Import Test pytest pydocstyle

Python Libraries with functions and constants related to electrical engineering.

The functions and constants that make up these modules represent a library of material compiled with the intent of being used primarily for research, development, education, and exploration in the realm of electrical engineering.

Check out our full documentation: https://engineerjoe440.github.io/ElectricPy/

Special thanks to:

  • Lakshmikanth Ayyadevara | Student - NIT Warangal (National Institute of Technology Warangal)
  • Stephen Weeks | Student - University of Idaho
  • Jeremy Perhac | Student - University of Idaho
  • Daniel Allen | Student - Universtiy of Idaho
  • Dr. Dennis Sullivan | Proffessor - University of Idaho
  • Dr. Brian Johnson | Proffessor - University of Idaho
  • Dr. Joe Law | Proffessor - University of Idaho
  • StackOverflow user gg349
  • Shaurya Uppal | Online Code Contributor
  • Paul Ortman | Power Quality Engineer - Idaho Power | Instructor - University of Idaho

Dependencies:

  • NUMPY
  • MATPLOTLIB
  • SCIPY
  • SYMPY
  • NUMDIFFTOOLS

INSTALLATION:

1) (option a) Install ElectricPy with Python's Own pip

Install electricpy

  • pip install electricpy

1) (option b) Install ElectricPy from Source

Python Documentation

Collect Repository and Install

  1. Clone/Download Source Code from GitHub Repository
  2. Open Terminal and Navigate to Folder with cd Commands:
  • cd \electricpy
  1. Use Python to Install Module from setup.py:
  • python setup.py install

2) Verify Installation

Check installation success in Python environment

import electricpy
electricpy._version_

To Do List:

  • Add Heat Sink Solver
  • DC/DC Converters
  • DC/AC Converters
  • Stationary and Synchronous Reference Frame conversion Matrices/Constants
  • Add arc-flash calculators suggested
  • Add Simple decibel Formulas
  • Add Simple Battery Discharge Rate Formula
  • Add Simple Air Core Inductor Formula(s)
  • Add Simple Zener Diode Formulas
  • Develop Testing for All Functions

Get Involved / Contribute

If you're interested in contributing, we'd love to see your support in a number of ways!

  1. Write Tests - We're really lacking in this area. We've recently added simple GitHub actions to test installation, but that's about it. We hope that someday we can test all functions in this module for verification.
  2. Contribute New Electrical Engineering Functions - If you've got a new function related to electrical engineering that you'd like to see added, we'd love to throw it into this module. Our goal is that this module can become the comprehensive electrical engineering toolkit in Python. Drop us a note, or create a pull request!
  3. Report Issues - We don't want issues to go unnoticed. Please help us track bugs and resolve them!
  4. Get the Word Out - This project is still in its infancy, so please share it with your friends and colleagues. We want to make sure that everyone has the opportunity to take advantage of this project.

Check out the contribution guide

Contact:

For more information regarding this resource, please contact Joe Stanley

License and Usage:

ElectricPy is licensed under the standard MIT license, and as such, you are permitted to use this resource as you see fit. Please feel free to ask questions, suggest edits and report bugs or other issues.

Comments
  • Format for test functions

    Format for test functions

    Can we organized all our test functions in this format

    def test_distance():
        
        def test_0():
            p1 = Point(1, 2)
            p2 = Point(3, 4)
            assert geometry.distance(p1, p2) == 2*(2**0.5)
    
            p1 = Point(4, -6)
            p2 = Point(-2, -5)
            assert geometry.distance(p2, p1) ==  (37**0.5)
    
            p1 = Point(1.3, 2.3)
            p2 = Point(1.4, 2.4)
    
            d_output = geometry.distance(p1, p2)
            d_actual = 0.1*(2**0.5)
    
            assert_array_almost_equal(d_output, d_actual, decimal=6)
    
        def test_1():
            p1 = Point(1, 2)
            p2 = Point(1, 3)
            assert geometry.distance(p1, p2) == 1
    
            p1 = Point(2.0, 1)
            p2 = Point(3.0, 1)
            assert geometry.distance(p1, p2) == 1
    
        for i in range(2):
            exec("test_{}()".format(i))
    
    

    Where all test function contain at least two test case with increasing level of complexity

    opened by Lakshmikanth2001 6
  • Source Code url in documentation

    Source Code url in documentation

    image

    Can we have a similar source pointing anchor tag in our https://engineerjoe440.github.io/ElectricPy/api/ documentation page

    I have written a python script to generate URL for each function

    function_url =  dict()
    REMOTE_URL = "https://github.com/engineerjoe440/ElectricPy/blob/master/electricpy/"
    
    #get only files electricpy directory
    SOURCES = [file for file in os.listdir('./electricpy') if os.path.isfile(file)]
    
    for source in SOURCES:
        with open(os.path.join(sys.path[0], f"electricpy\{source}"), "r") as code:
            # buid a regular expression for "def ()"
            RE = re.compile('def ()')
    
            # iterate over the lines in the file
            for line_number, line in enumerate(code):
                # find all the functions
                match = RE.findall(line)
                # if there are any matches
                if match:
                    #get text between def and (
                    
                    function_name = line[line.find("def")+4:line.find("(")]
    
                    function_url[function_name] = f"{REMOTE_URL}{source}#L{line_number+1}"
    
            with open("urls.json", 'w') as url_data:
                json.dump(function_url, url_data) 
    

    urls.json would look similar to this

     "phasorz": "https://github.com/engineerjoe440/ElectricPy/blob/master/electricpy/__init__.py#L844",
    

    https://github.com/engineerjoe440/ElectricPy/blob/master/electricpy/init.py#L844 will directly point to the actual function

    Can we include this feature

    opened by Lakshmikanth2001 5
  • added some function which are mentioned in todolist

    added some function which are mentioned in todolist

    refactored code using Pycharm (this is the reason which caused so changes i am sorry for that) and added some function

    '''bridge impedance'' using electric.dynetz '''propagation_constants''' for long transmission line '''tapchaning_transformer" for calculating turns ration

    I want to added method to find voltage across string capacitors https://circuitglobe.com/string-efficiency-of-suspension-insulator.html and many more I hope you like my work and please excuse me for making so many changes by refactoring

    documentation enhancement 
    opened by Lakshmikanth2001 5
  • Problem installing a package in Visual Studio 2019

    Problem installing a package in Visual Studio 2019

    Hello!

    I tried to install a package in Visual Studio 2019. All the necessary and listed packages were installed successfully. The installation of ElectricPy failed (see below).

    Thank you.

    ----- Installing 'electricpy==0.1.4' ----- Collecting electricpy==0.1.4 Using cached electricpy-0.1.4.tar.gz (71 kB) ERROR: Command errored out with exit status 1: command: 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy\setup.py'"'"'; file='"'"'C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy\pip-egg-info' cwd: C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy
    Complete output (7 lines): Traceback (most recent call last): File "", line 1, in File "C:\Users\dmitr\AppData\Local\Temp\pip-install-enrxccjp\electricpy\setup.py", line 11, in file_str = fh.read() File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\encodings\cp1251.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 43488: character maps to ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ----- Failed to install 'electricpy==0.1.4' -----

    opened by DmitryPetrichenko 5
  • `Bug` in `sphinx-build.yml`

    `Bug` in `sphinx-build.yml`

      remote: Permission to Lakshmikanth2001/ElectricPy.git denied to github-actions[bot].
      fatal: unable to access 'https://github.com/Lakshmikanth2001/ElectricPy.git/': The requested URL returned error: 403
      Error: Action failed with "The process '/usr/bin/git' failed with exit code 128"
    

    sphinx-build is failling in my forked repository

    bug documentation continuous-integration 
    opened by Lakshmikanth2001 4
  • Redundant parentheses and comparison to None should be 'if cond is not None':

    Redundant parentheses and comparison to None should be 'if cond is not None':

    According to PEP 8 guidance, there must be no redundant parentheses for example

    def foo():
      # return (2) # Bad
      return 2 # Good
    
    if (value == 2): # Bad
       pass
    
    if value == 2: # Good
      pass
    

    Comparison conditions According to PEP 8: E711 comparison to None should be if cond is not None

      if VLL != None: # Bad
          Vm = _np.sqrt(2 / 3) * VLL
    
      if VLL is not None: # Good
          Vm = _np.sqrt(2 / 3) * VLL
    
    enhancement 
    opened by khan-asfi-reza 4
  • Add Automatic Contributor List to README

    Add Automatic Contributor List to README

    There's GOT to be some way to show contributors automatically in the README. So that Github contributors can automatically be listed without needing to be added manually (would save me some time, and make sure people get some of the credit and thanks that they need).

    documentation enhancement help wanted 
    opened by engineerjoe440 4
  • Correct NumPy/SciPy/SymPy Casing in Documentation

    Correct NumPy/SciPy/SymPy Casing in Documentation

    In several places throughout the documentation, "NumPy" is not properly capitalized, the same is true for "SciPy" and "SymPy". All three names should be corrected throughout documentation wherever they appear.

    documentation enhancement good first issue 
    opened by engineerjoe440 4
  • Sphinx Build Warning

    Sphinx Build Warning

    WARNING: autodoc: failed to import function 'step' from module 'electricpy'; the following exception was raised:
    Traceback (most recent call last):
      File "D:\ElectricProject\ElectricPy\.venv\lib\site-packages\sphinx\util\inspect.py", line 448, in safe_getattr
        return getattr(obj, name, *defargs)
    AttributeError: module 'electricpy' has no attribute 'step'
    

    please check out the output of sphinx-build action

    opened by Lakshmikanth2001 4
  • Incorrect formula for resistance/reactance in powerimpedance function in __init__.py .

    Incorrect formula for resistance/reactance in powerimpedance function in __init__.py .

    According to Wikipedia, using R = (V ** 2 )/P is only valid when PF = 1 (purely resistive load). If you call the function powerimpedance(S=1111.11,PF=0.9,V=120), it'll return R=14.4 (120²/1000), instead of 11.66 (aprox).

    I am currently learning about Circuits and searching for python libraries that could help me during my tests. I'll be very happy to lend a hend if possible in this project.

    Best regards.

    bug documentation 
    opened by MrTuckie 4
  • Refactored Code 2

    Refactored Code 2

    sir I wish I was successful in making the changes which you have mentioned in previous pull request one thing which I was unable to add is the image of wheat stone bridge I am still finding methods to add images to python documentation I hope this pull requests covered all the changes which you have mentioned

    documentation enhancement 
    opened by Lakshmikanth2001 4
  • Adding `Frequency Response` for series and parallel `RLC` circuits to `electricpy.visu`

    Adding `Frequency Response` for series and parallel `RLC` circuits to `electricpy.visu`

    Describe the solution you'd like

    • A clear and concise description of what you want to happen.
    • Computing various parameters like bandwidth, quality factor, resonating frequency,and characteristic equation
    • Plotting the frequency response using matlplotlob

    Link to Formulas and Example References

    enhancement 
    opened by Lakshmikanth2001 3
  • Add Documentation for Development Practices and Improve Contributing Docs

    Add Documentation for Development Practices and Improve Contributing Docs

    There's a real lack of documentation regarding contribution best practices and suggestions for this project. We should document some of the following:

    • how Pull Requests (PRs) should be managed
    • what documentation styles are in place (NumPyDoc)
    • contributions getting started
    • what determinations should be used to decide where new functions should be added
    documentation enhancement 
    opened by engineerjoe440 0
  • Add Operational Amplifier (OpAmp) Module and Start with a Few Basic Formulas

    Add Operational Amplifier (OpAmp) Module and Start with a Few Basic Formulas

    It'll be good to add a submodule electricpy.opamp to contain a variety of op-amp related formulas. We can start with the formulas laid out in BasicTables. We should make a unique function for each formula and include an example and copy of the image for each.

    • non_inverting_vout - Image Link: https://www.basictables.com/media/non-inverting-opamp-circuit.png
    • inverting_vout - Image Link: https://www.basictables.com/media/inverting-opamp-circuit.png
    • differential_vout - Image Link: https://www.basictables.com/media/differential-opamp-circuit.png
    • inverting_summing_vout - Image Link: https://www.basictables.com/media/inverting-summing-opamp-circuit.png
    enhancement help wanted good first issue 
    opened by engineerjoe440 3
  • Create Air-Core Inductor Functions

    Create Air-Core Inductor Functions

    We've got one Air Core Inductor formula, but it would be beneficial to have a few others, namely we need to:

    • calculate required length
    • calculate desired diameter
    • calculate desired number of turns

    We should use the formulas called out here and make three formulas:

    • air_core_required_length
    • air_core_required_diameter
    • air_core_required_num_turns
    enhancement help wanted good first issue 
    opened by engineerjoe440 0
  • Phasor Class in `phasor.py`

    Phasor Class in `phasor.py`

    Can we replace all our functional code into objected-oriented fashion so that it will be really intuitive for users to just add, sub, mul, eq phasor

    >>> p1 = Phasor(3, 120)
    >>> p2 = Phasor(4, 120)
    >>> p1 + p2
    Phasor(7, 120)
    >> p1 - p2
    >> p1 * p2
    
    class Phasor:
        """
        Complex Phasor Generator.
    
        Generates the standard Pythonic complex representation
        of a phasor voltage or current when given the magnitude
        and angle of the specific voltage or current.
        """
    
        def __init__(self, mag: float, ang: float) -> None:
            """Initialize the phasor.
    
            Parameters
            ----------
            mag : float
                The magnitude of the phasor
            ang : float
                The angle of the phasor in degrees
            """
            self.mag = mag
            self.ang = _np.radians(ang)
    
        def __add__(self, other: 'Phasor') -> 'Phasor':
            """Return the sum of the phasors.
    
            Parameters
            ----------
            other : object
                The other phasor to add to the current phasor
    
            Returns
            -------
            object
                The sum of the two phasors
            """
            if isinstance(other, Phasor):
                a = _c.rect(self.mag, self.ang)
                b = _c.rect(other.mag, other.ang)
    
                return Phasor(_np.abs(a + b), _np.radians(_np.angle(a + b)))
    
            else:
                return ValueError("Phasor can only be added to another phasor")
    
        def __sub__(self, other: 'Phasor') -> 'Phasor':
            """Return the difference of the phasors.
    
            Parameters
            ----------
            other : object
                The other phasor to subtract from the current phasor
    
            Returns
            -------
            object
                The difference of the two phasors
            """
            if isinstance(other, Phasor):
                a = _c.rect(self.mag, self.ang)
                b = _c.rect(other.mag, other.ang)
    
                return Phasor(_np.abs(a - b), _np.radians(_np.angle(a + b)))
    
            else:
                return ValueError("Phasor can only be subtracted from another phasor")
    
        def __mul__(self, other: 'Phasor') -> 'Phasor':
            """Return the product of the phasors.
    
            Parameters
            ----------
            other: object
                The other phasor to subtract from the current phasor
    
            Returns
            -------
            object
                The difference of the two phasors
            """
            return Phasor(self.mag * other.mag, self.ang + other.ang)
    
        def __eq__(self, __o: 'Phasor') -> bool:
            """Return True if the phasors are equal.
    
            Parameters
            ----------
            __o : Phasor
                The other Phasor object to compare to the current phasor
    
            Returns
            -------
            bool
                True if the phasors are equal, False otherwise
            """
            if isinstance(__o, Phasor):
                return self.mag == __o.mag and self.ang == __o.ang
            else:
                return False
    
        def __str__(self) -> str:
            """Return the string representation of the phasor."""
            return _cprint(self())
    
    enhancement question 
    opened by Lakshmikanth2001 2
  • Enforcing `black` for python code formatting

    Enforcing `black` for python code formatting

    021cfe787fb3d9ac28167b73eafb1198c46dffc4 Sir as our code base is growing in size i want a uniform python code format across all our modules please review it and give your valuable feed bak

    enhancement help wanted 
    opened by Lakshmikanth2001 4
Owner
Joe Stanley
Pythonista and automation enthusiast. Inherently lazy.... I'll spend 6 days automating a 6 minute task so I'll never do it again.
Joe Stanley
Python utilities for writing cross-version compatible libraries

Python utilities for writing cross-version compatible libraries

Tyler M. Kontra 85 Jun 29, 2022
A Python package implementing various colour checker detection algorithms and related utilities.

A Python package implementing various colour checker detection algorithms and related utilities.

colour-science 147 Dec 29, 2022
Utility to play with ADCS, allows to request tickets and collect information about related objects.

certi Utility to play with ADCS, allows to request tickets and collect information about related objects. Basically, it's the impacket copy of Certify

Eloy 185 Dec 29, 2022
A python package containing all the basic functions and classes for python. From simple addition to advanced file encryption.

A python package containing all the basic functions and classes for python. From simple addition to advanced file encryption.

PyBash 11 May 22, 2022
Cleaning-utils - a collection of small Python functions and classes which make cleaning pipelines shorter and easier

cleaning-utils [] [] [] cleaning-utils is a collection of small Python functions

null 4 Aug 31, 2022
Airspy-Utils is a small software collection to help with firmware related operations on Airspy HF+ devices.

Airspy-Utils Airspy-Utils is a small software collection to help with firmware related operations on Airspy HF+ devices on Linux (and other free syste

Dhiru Kholia 11 Oct 4, 2022
Python @deprecat decorator to deprecate old python classes, functions or methods.

deprecat Decorator Python @deprecat decorator to deprecate old python classes, functions or methods. Installation pip install deprecat Usage To use th

null 12 Dec 12, 2022
pydsinternals - A Python native library containing necessary classes, functions and structures to interact with Windows Active Directory.

pydsinternals - Directory Services Internals Library A Python native library containing necessary classes, functions and structures to interact with W

Podalirius 36 Dec 14, 2022
A simple and easy to use collection of random python functions.

A simple and easy to use collection of random python functions.

Diwan Mohamed Faheer 1 Nov 17, 2021
Pyfunctools is a module that provides functions, methods and classes that help in the creation of projects in python

Pyfunctools Pyfunctools is a module that provides functions, methods and classes that help in the creation of projects in python, bringing functional

Natanael dos Santos Feitosa 5 Dec 22, 2022
This script allows you to retrieve all functions / variables names of a Python code, and the variables values.

Memory Extractor This script allows you to retrieve all functions / variables names of a Python code, and the variables values. How to use it ? The si

Venax 2 Dec 26, 2021
Helpful functions for use alongside the rich Python library.

?? Rich Tools A python package with helpful functions for use alongside with the rich python library. ???? The current features are: Convert a Pandas

Avi Perl 14 Oct 14, 2022
A collection of utility functions to prototype geometry processing research in python

gpytoolbox This repo is a work in progress and contains general utility functions I have needed to code while trying to work on geometry process resea

Silvia Sellán 73 Jan 6, 2023
A simple example for calling C++ functions in Python by `ctypes`.

ctypes-example A simple example for calling C++ functions in Python by ctypes. Features call C++ function int bar(int* value, char* msg) with argumene

Yusu Pan 3 Nov 23, 2022
Make your functions return something meaningful, typed, and safe!

Make your functions return something meaningful, typed, and safe! Features Brings functional programming to Python land Provides a bunch of primitives

dry-python 2.6k Jan 9, 2023
Keval allows you to call arbitrary Windows kernel-mode functions from user mode, even (and primarily) on another machine.

Keval Keval allows you to call arbitrary Windows kernel-mode functions from user mode, even (and primarily) on another machine. The user mode portion

null 42 Dec 17, 2022
Conveniently measures the time of your loops, contexts and functions.

Conveniently measures the time of your loops, contexts and functions.

Maciej J Mikulski 79 Nov 15, 2022
We provide useful util functions. When adding a util function, please add a description of the util function.

Utils Collection Motivation When we implement codes, we often search for util functions that are already implemented. Here, we are going to share util

null 6 Sep 9, 2021
Run functions in parallel easily, with their results typed correctly!

typesafe_parmap pip install pip install typesafe-parmap Run functions in parallel safely with typesafe parmap! GitHub: https://github.com/thejaminato

James Chua 3 Nov 6, 2021