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
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
Grank is a feature-rich script that automatically grinds Dank Memer for you

Grank Inspired by this repository. This is a WIP and there will be more functions added in the future. What is Grank? Grank is a feature-rich script t

42 Jul 20, 2022
Dice Rolling Simulator using Python-random

Dice Rolling Simulator As the name of the program suggests, we will be imitating a rolling dice. This is one of the interesting python projects and wi

PyLaboratory 1 Feb 02, 2022
Functional UUIDs for Python.

🏷️FUUID stands for Functional Universally Unique IDentifier. FUUIDs are compatible with regular UUIDs but are naturally ordered by generation time, collision-free and support succinct representations

Phil Demetriou 147 Oct 27, 2022
A tool for testing improper put method vulnerability

Putter-CUP A tool for testing improper put method vulnerability Usage :- python3 put.py -f live-subs.txt Result :- The result in txt file "result.txt"

Zahir Tariq 6 Aug 06, 2021
A Python script that transcript Arcaea chart file (.aff file) into AutoJS touchscreen script which automatically plays the Arcaea chart

ArcaeaAutoplay (AutoJS Version) A Python script that transcript Arcaea chart file (.aff file) into AutoJS touchscreen script which automatically plays

7 Dec 03, 2021
Check the basic quality of any dataset

Data Quality Checker in Python Check the basic quality of any dataset. Sneak Peek Read full tutorial at Medium. Explore the app Requirements python 3.

MalaDeep 8 Feb 23, 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

4 Aug 31, 2022
Monte Carlo simulation of 3G rules

mc3g Monte Carlo simulation of 3G rules This project contains the Python code to do simulations of events according to the 3G rule (in German: "Geimpf

Jan Christoph Terasa 4 Nov 01, 2021
Simplex using Jordan exchanges taught in 236A

Simplex for 236A Python script to solve LP using simplex by Jordan exchanges taught in 236A. You will need python installed along with the 'numpy' and

Kunal Kishore 1 Nov 30, 2021
🍰 ConnectMP - An easy and efficient way to share data between Processes in Python.

ConnectMP - Taking Multi-Process Data Sharing to the moon 🚀 Contribute · Community · Documentation 🎫 Introduction : 🍤 ConnectMP is the easiest and

Aiden Ellis 1 Dec 24, 2021
Bounding Boxes Python Utils

Bounding Boxes Python Utils

Vadim 4 May 01, 2022
Tools to connect to and interact with the Mila cluster

milatools The milatools package provides the mila command, which is meant to help with connecting to and interacting with the Mila cluster. Install Re

Mila 32 Dec 01, 2022
Dependency Injector is a dependency injection framework for Python.

What is Dependency Injector? Dependency Injector is a dependency injection framework for Python. It helps implementing the dependency injection princi

ETS Labs 2.6k Jan 04, 2023
Auto-generate /etc/hosts for HackTheBox machines

Auto-generate /etc/hosts for HackTheBox machines Save yourself some tedium on getting started on a new machine by having your /etc/hosts ready to go.

3 Feb 16, 2022
Backup a folder to an another folder by using mirror update method.

Mirror Update Backup Backup a folder to an another folder by using mirror update method. How to use Install requirement pip install -r requirements.tx

1 Nov 21, 2022
An online streamlit development platform

streamlit-playground An online streamlit development platform Run, Experiment and Play with streamlit Components Develop full-fledged apps online All

Akshansh Kumar 3 Nov 06, 2021
Spacegit is a .git exposed finder

Spacegit Spacegit is a basic .git exposed finder Usage: You need python3 installed to run spacegit use: python3 spacegit.py (url) Disclaimer: **This i

2 Nov 30, 2021
A tiny Python library for generating public IDs from integers

pids Create short public identifiers based on integer IDs. Installation pip install pids Usage from pids import pid public_id = pid.from_int(1234) #

Simon Willison 7 Nov 11, 2021
This tool lets you perform some quick tasks for CTFs and Pentesting.

This tool lets you convert strings and numbers between number bases (2, 8, 10 and 16) as well as ASCII text. You can use the IP address analyzer to find out details on IPv4 and perform abbreviation a

Ayomide Ayodele-Soyebo 1 Jul 16, 2022