Giter Site home page Giter Site logo

christiankral / electricalengineering.jl Goto Github PK

View Code? Open in Web Editor NEW
32.0 2.0 10.0 448 KB

Julia electrical engineering package

Home Page: https://christiankral.github.io/ElectricalEngineering.jl/

License: BSD 3-Clause "New" or "Revised" License

Julia 100.00%
julia engineering electrical-engineering electric complex-numbers phasor

electricalengineering.jl's Introduction

ElectricalEngineering.jl

This is a Julia package on electrical engineering based on Unitful and PyPlot. The package ElectricalEngineering.jl is tested with Julia 1.1.0. To install the package, start Julia and hit ] to switch to the package manager.

add PyPlot Unitful ElectricalEngineering

In order to update to the actual version of GitHub in the package manager, hit ] and apply:

update ElectricalEngineering

To switch back to the Julia REPL and to start working hit Backspace.

The module ElectricalEngineering.jl has to be loaded by using ElectricalEngineering. In order to use all the features of ElectricalEngineering.jl, modules Unitful and PyPlot have to be loaded as well. It is thus recommended to appy:

using Unitful, Unitful.DefaultSymbols, PyPlot, ElectricalEngineering

Features

Phasors

  • Function pol to generate a complex quantity based on the length and the angle (polar representation)
julia> U1 = pol(2V, pi)
-2 + 0im V
julia> U2 = pol(sqrt(2) * 1V, 45°)
1 + 1im V
  • Constant j representing the imaginary unit equivalent to 1im
  • Function phasor
    • Plot publication ready phasor diagrams
    • LaTeX labeling with absolute or relative rotation of text

Phasor diagram Circuit diagram

  • Function phasorsine
    • Plot phasor in the left subplot of a figure
    • Plot sine wave corresponding to the phasor in the right subplot Phasor and sine wave
  • Function angulardimension
    • Draw arc to indicate angle between phasors
    • Chose between different arrow shapes
    • Create dimension of phasor
  • Function phasordimension
    • Create auxiliary lines and parallel shifted dimensions Length dimension

Circuits and Physics

  • Function
    • Calculate parallel connections of impedances
    • Calculate parallel impedance with or without units
julia> 4Ω6Ω
2.4000000000000004 Ω
julia> 4Ω(j*4Ω)
2.0 + 2.0im Ω

Inputs and Outputs

  • Function printuln
    • Print complex variables (including) units in rectangular and polar form
    • Limit output to six significant digits
    • Convert printed quantity optionally into a target unit
    • Works with scalars and vectors of real or complex quantities
julia> U1 = 300V + j*400V
julia> printuln("U1", U1, kV)
              U1 = 0.3 kV + j 0.4 kV
                 = 0.5 kV ∠ 53.1301°
julia> printuln("real(U1)", real(U1),kV)
        real(U1) = 0.3 kV
julia> printuln("U1", U1, V, label="(a)")
(a)           U1 = 300 V + j 400 V
                 = 500 V ∠ 53.1301°
  • Function save3fig

    • Save one figure in the three file formats png, eps and pdf
    • Optionally crop figures

    Plotting

  • Assign two different color schemes (may be loaded alternatively)

  • Additional light background color colorBlack5

  • Different line and marker types

    • lineStyle1, lineStyle2, lineStyle3, lineStyle4
    • lineWidth1, lineWidth2, lineWidth3, lineWidth4,
    • marker1, marker2 ,marker3, marker4
    • markerSize1, markerSize2 ,markerSize3 ,markerSize4
    • legendFontSize
    • Type ?ElectricalEngineering.Gray or ?ElectricalEngineering.Tab20bc to see application examples
  • Assign color schemes to quantities, using either using ElectricalEngineering.Gray of gray scale graphics or using ElectricalEngineering.Tab20bc

  • Function removeaxes

    • Removes the axes of the active plot
  • Function arrowaxes

    • Plot graphs with arrowed axes
    • Add plot labels Curves
  • Function lengthdimension

    • Create length dimension with arrows
    • Create auxiliary lines and parallel shifted dimensions Length dimension

Other Packages related with Electrical Engineering

  • ColorPalette.jl allows exchangable color palettes to be used in Julia, LaTeX and Ipe
  • ESeriesRounding.jl provides functions to round given values to the nearest standardized value for circuit components, namely the E-series.
  • Modia.jl is a package for modeling and simulation of multidomain engineering systems described by differential equations, algebraic equations, and (space-discretized) partial differential equations.
  • ModelingToolkit.jl is a modeling language for high-performance symbolic-numeric computation in scientific computing and scientific machine learning.

electricalengineering.jl's People

Contributors

christiankral avatar juliatagbot avatar kronosthelate avatar mtiller-jh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

electricalengineering.jl's Issues

Compatibility issue with Compat

When trying to install version v0.4.7 an error occurs:

(@v1.8) pkg> add ElectricalEngineering@0.4.7
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Compat [34da2185]:
 Compat [34da2185] log:
 ├─possible versions are: 1.0.0-4.3.0 or uninstalled
 ├─restricted to versions * by OMJulia [0f4fe800], leaving only versions 1.0.0-4.3.0
 │ └─OMJulia [0f4fe800] log:
 │   ├─possible versions are: 0.2.1 or uninstalled
 │   └─OMJulia [0f4fe800] is fixed to version 0.2.1
 ├─restricted by compatibility requirements with ElectricalEngineering [84e62fa8] to versions: 4.1.0-4.3.0
 │ └─ElectricalEngineering [84e62fa8] log:
 │   ├─possible versions are: 0.4.1-0.4.7 or uninstalled
 │   └─restricted to versions 0.4.7 by an explicit requirement, leaving only versions 0.4.7
 └─restricted by compatibility requirements with LNR [7c4cb9fa] to versions: 1.0.0-3.46.0 — no versions left
   └─LNR [7c4cb9fa] log:
     ├─possible versions are: 0.2.0-0.2.1 or uninstalled

PyPlot issue with v0.4.1

(v1.1) pkg> add ElectricalEngineering
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
 Installed CodeTracking ────────── v0.5.0
 Installed Compat ──────────────── v2.1.0
 Installed JuliaInterpreter ────── v0.3.2
 Installed WebSockets ──────────── v1.5.2
 Installed ElectricalEngineering ─ v0.4.1
  Updating `~/.julia/environments/v1.1/Project.toml`
  [84e62fa8] + ElectricalEngineering v0.4.1
  Updating `~/.julia/environments/v1.1/Manifest.toml`
  [da1fd8a2] ↑ CodeTracking v0.4.0 ⇒ v0.5.0
  [34da2185] ↑ Compat v2.0.0 ⇒ v2.1.0
  [84e62fa8] + ElectricalEngineering v0.4.1
  [aa1ae85d] ↑ JuliaInterpreter v0.3.1 ⇒ v0.3.2
  [104b5d7c] ↑ WebSockets v1.5.1 ⇒ v1.5.2

julia> using ElectricalEngineering
[ Info: Precompiling ElectricalEngineering [84e62fa8-74a0-5990-9214-c45bd74ae4d7]
┌ Warning: Package ElectricalEngineering does not have PyPlot in its dependencies:
│ - If you have ElectricalEngineering checked out for development and have
│   added PyPlot as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with ElectricalEngineering
└ Loading PyPlot into ElectricalEngineering from project dependency, future warnings for ElectricalEngineering are suppressed.
/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py:846: MatplotlibDeprecationWarning: 
The text.latex.unicode rcparam was deprecated in Matplotlib 2.2 and will be removed in 3.1.
  "2.2", name=key, obj_type="rcparam", addendum=addendum)
/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py:846: MatplotlibDeprecationWarning: 
The text.latex.unicode rcparam was deprecated in Matplotlib 2.2 and will be removed in 3.1.
  "2.2", name=key, obj_type="rcparam", addendum=addendum)

save2fig causes error

The function save2fig does cause an error.

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1884, in __call__
    return self.func(*args)
  File "/usr/lib/python3.9/tkinter/__init__.py", line 805, in callit
    func(*args)
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backends/_backend_tk.py", line 253, in idle_draw
    self.draw()
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backends/backend_tkagg.py", line 9, in draw
    super(FigureCanvasTkAgg, self).draw()
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py", line 407, in draw
    self.figure.draw(self.renderer)
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backend_bases.py", line 1544, in _draw
    def _draw(renderer): raise Done(renderer)
matplotlib.backend_bases._get_renderer.<locals>.Done: <matplotlib.backends.backend_agg.RendererAgg object at 0x7f6f93af4280>
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1884, in __call__
    return self.func(*args)
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backends/_backend_tk.py", line 242, in resize
    self.draw()
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backends/backend_tkagg.py", line 9, in draw
    super(FigureCanvasTkAgg, self).draw()
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py", line 407, in draw
    self.figure.draw(self.renderer)
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backend_bases.py", line 1544, in _draw
    def _draw(renderer): raise Done(renderer)
matplotlib.backend_bases._get_renderer.<locals>.Done: <matplotlib.backends.backend_agg.RendererAgg object at 0x7f6f9702dac0>
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1884, in __call__
    return self.func(*args)
  File "/usr/lib/python3.9/tkinter/__init__.py", line 805, in callit
    func(*args)
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backends/_backend_tk.py", line 253, in idle_draw
    self.draw()
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backends/backend_tkagg.py", line 9, in draw
    super(FigureCanvasTkAgg, self).draw()
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py", line 407, in draw
    self.figure.draw(self.renderer)
  File "/home/christian/.local/lib/python3.9/site-packages/matplotlib/backend_bases.py", line 1544, in _draw
    def _draw(renderer): raise Done(renderer)
matplotlib.backend_bases._get_renderer.<locals>.Done: <matplotlib.backends.backend_agg.RendererAgg object at 0x7f6f9702dac0>

Check dependency on PyPlot

In Julia 1.1.0 the following message is gernerated:

using EE
[ Info: Precompiling EE [c638b1ac-f202-5047-8f20-c6a32b8565b5]
┌ Warning: Package EE does not have PyPlot in its dependencies:
│ - If you have EE checked out for development and have
│   added PyPlot as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with EE
└ Loading PyPlot into EE from project dependency, future warnings for EE are suppressed.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

New relevant package

I just announced my first package in this discourse post. In researching it's need, I have stumbled over this package. I was just thinking that my package is likely relevant to whoever might use this one. So I would simply like to invite to do one of the following:

  1. Add a reference to my package, to make it more discoverable to the relevant people
  2. Add it as a dependency, and export its functionality directly.

The second option is viable, as the package is very small and lightweight. I am however still open to suggestions for API changes, and so this should possibly wait until I release a 1.0.0 version.

Add function par

Add additional function par as equivalent to to simplify writing of calculations.

Do not remove for compatibility reasons

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.