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 simple language and reference decompiler/compiler for MHW THK Files

Leviathon A simple language and reference decompiler/compiler for MHW THK Files. Project Goals The project aims to define a language specification for

11 Jan 07, 2023
A simple tool to extract python code from a Jupyter notebook, and then run pylint on it for static analysis.

Jupyter Pylinter A simple tool to extract python code from a Jupyter notebook, and then run pylint on it for static analysis. If you find this tool us

Edmund Goodman 10 Oct 13, 2022
Extends the pyranges module with operations on joined genomic intervals

tiedpyranges Extends the pyranges module with operations on joined genomic intervals (e.g. exons of same transcript) Install with: pip install tiedpyr

Marco Mariotti 4 Aug 05, 2022
Group imports from Windows binaries

importsort This is a tool that I use to group imports from Windows binaries. Sometimes, you have a gigantic folder full of executables, and you want t

【☆ ゆう ☆ 】 15 Aug 27, 2022
Easy compression and extraction for any compression or archival format.

Tzar: Tar, Zip, Anything Really Easy compression and extraction for any compression or archival format. Usage/Examples tzar compress large-dir compres

DanielVZ 37 Nov 02, 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
jsoooooooon derulo - Make sure your 'jason derulo' is featured as the first part of your json data

jsonderulo Make sure your 'jason derulo' is featured as the first part of your json data Install: # python pip install jsonderulo poetry add jsonderul

jesse 3 Sep 13, 2021
A BlackJack simulator in Python to simulate thousands or millions of hands using different strategies.

BlackJack Simulator (in Python) A BlackJack simulator to play any number of hands using different strategies The Rules To keep the code relatively sim

Hamid 4 Jun 24, 2022
Skywater 130nm Klayout Device Generators PDK

Skywaters 130nm Technology for KLayout Device Generators Mabrains is excited to share with you our Device Generator Library for Skywater 130nm PDK. It

Mabrains 18 Dec 14, 2022
Find version automatically based on git tags and commit messages.

GIT-CONVENTIONAL-VERSION Find version automatically based on git tags and commit messages. The tool is very specific in its function, so it is very fl

0 Nov 07, 2021
A random cats photos python module

A random cats photos python module

Fayas Noushad 6 Dec 01, 2021
🌲 A simple BST (Binary Search Tree) generator written in python

Tree-Traversals (BST) 🌲 A simple BST (Binary Search Tree) generator written in python Installation Use the package manager pip to install BST. Usage

Jan Kupczyk 1 Dec 12, 2021
Give you a better view of your Docker registry disk usage.

registry-du Give you a better view of your Docker registry disk usage. This small tool will analysis your Docker registry(vanilla or Harbor both work)

Nova Kwok 16 Jan 07, 2023
ColorController is a Pythonic interface for managing colors by english-language name and various color values.

ColorController.py Table of Contents Encode color data in various formats. 1.1: Create a ColorController object using a familiar, english-language col

Tal Zaken 2 Feb 12, 2022
tade is a discussion/forum/link aggregator application. It provides three interfaces: a regular web page, a mailing list bridge and an NNTP server

tade is a discussion/forum/link aggregator application. It provides three interfaces: a regular web page, a mailing list bridge and an NNTP server

Manos Pitsidianakis 23 Nov 04, 2022
A sys-botbase client for remote control automation of Nintendo Switch consoles. Based on SysBot.NET, written in python.

SysBot.py A sys-botbase client for remote control automation of Nintendo Switch consoles. Based on SysBot.NET, written in python. Setup: Download the

7 Dec 16, 2022
Early version for manipulate Geo localization data trough API REST.

Backend para obtener los datos (beta) Descripción El servidor está diseñado para recibir y almacenar datos enviados en forma de JSON por una aplicació

Víctor Omar Vento Hernández 1 Nov 14, 2021
A Python script that parses and checks public proxies. Multithreading is supported.

A Python script that parses and checks public proxies. Multithreading is supported.

LevPrav 7 Nov 25, 2022
Password generator

Password generator technologies used What is? It is Password generator How to Download? Download on releases Clone repo git clone https://github.com/m

Miek 1 Nov 02, 2021
Run async workflows using pytest-fixtures-style dependency injection

Run async workflows using pytest-fixtures-style dependency injection

Simon Willison 26 Jun 26, 2022