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
A monitor than send discord webhook when a specific monitored product has stock in your nearby pickup stores.

Welcome to Apple In-store Monitor This is a monitor that are not fully scaled, and might still have some bugs.

5 Jun 16, 2022
Simple tool for creating changelogs

Description Simple utility for quickly generating changelogs, assuming your commits are ordered as they should be. This tool will simply log all lates

2 Jan 05, 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 dictionary that can be flattened and re-inflated

deflatable-dict A dictionary that can be flattened and re-inflated. Particularly useful if you're interacting with yaml, for example. Installation wit

Lucas Sargent 2 Oct 18, 2021
DUQ is a python package for working with physical Dimensions, Units, and Quantities.

DUQ is a python package for working with physical Dimensions, Units, and Quantities.

2 Nov 02, 2022
A program to convert celcius to faranheit. made with python

Temp-Converter What is Temp-Converter Temp-Converter is little program made with pyhton to convert celcius to faranheit. Needed A python interpreter P

Chandula Janith 0 Nov 27, 2021
Script to generate a massive volume of data in sql, csv, json or xml format

DataGenerator Made with Python Open for pull requests 1. Dependencies To install required dependencies run pip install -r requirements.txt 2. Executi

icrescenti 3 Sep 20, 2022
A python mathematics module

A python mathematics module

Fayas Noushad 4 Nov 28, 2021
A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use that mirror

Kali Mirror Finder Using Single Python File A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use tha

MrSingh 6 Dec 12, 2022
A hashtag from string extract python module

A hashtag from string extract python module

Fayas Noushad 3 Aug 10, 2022
Install, run, and update apps without root and only in your home directory

Qube Apps Install, run, and update apps in the private storage of a Qube. Build and install in Qubes Get the code: git clone https://github.com/micahf

Micah Lee 26 Dec 27, 2022
Python utility for discovering interesting CFPreferences values on iDevices

Description Simple utility to search for interesting preferences in iDevices. Installation python3 -m pip install -U --user cfprefsmon Example In this

12 Aug 19, 2022
A python lib for generate random string and digits and special characters or A combination of them

A python lib for generate random string and digits and special characters or A combination of them

Torham 4 Nov 15, 2022
Python implementation of Gorilla time series compression

Gorilla Time Series Compression This is an implementation (with some adaptations) of the compression algorithm described in section 4.1 (Time series c

Ghiles Meddour 19 Jan 01, 2023
The Black shade analyser and comparison tool.

diff-shades The Black shade analyser and comparison tool. AKA Richard's personal take at a better black-primer (by stealing ideas from mypy-primer) :p

Richard Si 10 Apr 29, 2022
A utility tool to create .env files

A utility tool to create .env files dump-env takes an .env.template file and some optional environmental variables to create a new .env file from thes

wemake.services 89 Dec 08, 2022
A random cats photos python module

A random cats photos python module

Fayas Noushad 6 Dec 01, 2021
A Program that generates and checks Stripe keys 24x7.

A Program that generates and checks Stripe keys 24x7. This was made only for Educational Purposes, I'm not responsible for the damages cause by you

iNaveen 18 Dec 17, 2022
Manage your exceptions in Python like a PRO

A linter to manage all your python exceptions and try/except blocks (limited only for those who like dinosaurs).

Guilherme Latrova 353 Dec 31, 2022
A simple package for handling variables in string.

A simple package for handling string variables. Welcome! This is a simple package for handling variables in string, You can add or remove variables wi

1 Dec 31, 2021