ElectricCircuitSim


NameElectricCircuitSim JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryA powerful Python package for simulating electrical circuits and generators.
upload_time2025-02-04 23:23:53
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT
keywords simulation electrical circuits generators rl circuit sinusoidal square wave
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Electric Circuit Simulator

![Build Status](https://img.shields.io/badge/build-passing-brightgreen)
![Python Version](https://img.shields.io/badge/python-3.11-blue)
![License](https://img.shields.io/badge/license-MIT-green)

## ๐Ÿ“š Overview

**Electric Circuit Simulator** is a powerful Python package for simulating **electrical circuits** and **generators**. It supports both **sinusoidal** and **square wave generators**, as well as **RL circuit simulations**. The core calculations are written in **C++** for optimal performance, and Python bindings are provided using `pybind11` for easy integration.

This tool allows you to simulate, analyze, and visualize the behavior of **resistive-inductive (RL) circuits** powered by different signal generators.



## ๐Ÿงฎ Mathematical Explanation

### Sinusoidal Generator

The voltage $V(t)$ generated by a sinusoidal generator is given by the equation:

$$
V(t) = A \sin(2 \pi f t + \phi)
$$

Where:
- $A$ is the **amplitude**
- $f$ is the **frequency**
- $\phi$ is the **phase**
- $t$ is **time**

### Square Wave Generator

The voltage $V(t)$ produced by a square wave generator is:

<p align="center">
  <img src="https://latex.codecogs.com/svg.latex?\bg_white\color{white}\bf{V(t)%20=%20\begin{cases}%20A%20&%20\text{if%20}\mod(t,%20T)%20<%20\frac{T}{2}%20\\%20-A%20&%20\text{otherwise}%20\end{cases}}" />
</p>

Where:
- $A$ is the **amplitude**
- $T$ is the **period** (with $ T = \frac{1}{f} $)
- $f$ is the **frequency**
- $t$ is **time**

### RL Circuit Simulation

The RL circuit's behavior is governed by the differential equation:

$$
V(t) = L \frac{dI(t)}{dt} + R I(t)
$$

Where:
- $V(t)$ is the **voltage** from the generator
- $I(t)$ is the **current** flowing through the circuit
- $L$ is the **inductance**
- $R$ is the **resistance**

This equation is solved iteratively using the **Euler method** for simulation.



## ๐Ÿ›  Package Contents

- **core**: C++ bindings for generators and circuit simulation.
- **analyze**: Tools for analyzing and visualizing simulation results.



## ๐Ÿ“ฆ Installation

### From PyPI

Install the package directly from PyPI:

```bash
pip install XXXXXX
```

### From Source

To install from the source, follow these steps:

```bash
git clone https://github.com/yourusername/electric-circuit-simulator.git
cd electric-circuit-simulator
python -m venv .venv
source .venv/bin/activate
pip install .
```

---

## ๐Ÿง‘โ€๐Ÿ’ป Usage Example

Hereโ€™s how you can use the Electric Circuit Simulator to analyze an RL circuit with different generators.

#Example 1
```python

from circuit_simulator.core import CircuitRL, SquareWaveGenerator

# Create generator
square_gen = SquareWaveGenerator(frequency=0.5, amplitude=0.5)

# Create RL circuit
circuit = CircuitRL(resistance=1, inductance=5)

# Simulate Circuit
result = circuit.simulate(generator=square_gen, t_end=1, dt=0.1)

# Print result
print(result) # [(0.0, 0.5, 0.010000000000000002), (0.1, 0.5, 0.019800000000000005), (0.2, 0.5, 0.029404000000000007), ...]

```
#Example 2
```python


from circuit_simulator.analyze import CircuitRLAnalyzer
from circuit_simulator.core import CircuitRL, SinusoidalGenerator, SquareWaveGenerator

# Create generators
sin_gen = SinusoidalGenerator(frequency=0.25, amplitude=0.5)
square_gen = SquareWaveGenerator(frequency=0.2, amplitude=0.2)

# Create RL circuit
circuit = CircuitRL(resistance=0.5, inductance=15)

# Create analyzer
analyzer = CircuitRLAnalyzer(generators={"sin": sin_gen, "square": square_gen}, circuit=circuit)

# Analyze the circuit
analyzer.analyze(end_time=10.0, step=0.1)

# Plot the results
analyzer.plot_results()
```



## ๐Ÿš€ Features

- **High Performance**: Core computations are implemented in C++ for maximum performance.
- **Python Bindings**: Seamless Python API provided by `pybind11`.
- **Flexible Generators**: Includes both **sinusoidal** and **square wave** generators for different testing conditions.
- **RL Circuit Simulation**: Simulate the response of an **RL circuit** under varying conditions.
- **Analysis Tools**: Built-in functionality for analyzing and plotting the simulation results.

---

## ๐Ÿ“œ License

This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for more details.

---

## ๐Ÿค Contributing

We welcome contributions! If you'd like to contribute to **Electric Circuit Simulator**, please feel free to:

1. Fork the repository
2. Make your changes
3. Submit a **pull request**

For any issues or feature requests, please open an issue in the repository.

---

## ๐Ÿ’ก Additional Information

The **Electric Circuit Simulator** is ideal for educational purposes, research, and testing different electrical circuits using realistic signal generators. It provides a robust and easy-to-use platform for simulating real-world electrical systems.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ElectricCircuitSim",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "simulation, electrical circuits, generators, RL circuit, sinusoidal, square wave",
    "author": null,
    "author_email": "Maciej Krakowiak <maciej.krakowiak17@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/bd/9c/3985cc0047d8c73b938057b743ec95f4d47098dedc7959e6b4a20cb17aef/electriccircuitsim-0.0.2.tar.gz",
    "platform": null,
    "description": "\n# Electric Circuit Simulator\n\n![Build Status](https://img.shields.io/badge/build-passing-brightgreen)\n![Python Version](https://img.shields.io/badge/python-3.11-blue)\n![License](https://img.shields.io/badge/license-MIT-green)\n\n## \ud83d\udcda Overview\n\n**Electric Circuit Simulator** is a powerful Python package for simulating **electrical circuits** and **generators**. It supports both **sinusoidal** and **square wave generators**, as well as **RL circuit simulations**. The core calculations are written in **C++** for optimal performance, and Python bindings are provided using `pybind11` for easy integration.\n\nThis tool allows you to simulate, analyze, and visualize the behavior of **resistive-inductive (RL) circuits** powered by different signal generators.\n\n\n\n## \ud83e\uddee Mathematical Explanation\n\n### Sinusoidal Generator\n\nThe voltage $V(t)$ generated by a sinusoidal generator is given by the equation:\n\n$$\nV(t) = A \\sin(2 \\pi f t + \\phi)\n$$\n\nWhere:\n- $A$ is the **amplitude**\n- $f$ is the **frequency**\n- $\\phi$ is the **phase**\n- $t$ is **time**\n\n### Square Wave Generator\n\nThe voltage $V(t)$ produced by a square wave generator is:\n\n<p align=\"center\">\n  <img src=\"https://latex.codecogs.com/svg.latex?\\bg_white\\color{white}\\bf{V(t)%20=%20\\begin{cases}%20A%20&%20\\text{if%20}\\mod(t,%20T)%20<%20\\frac{T}{2}%20\\\\%20-A%20&%20\\text{otherwise}%20\\end{cases}}\" />\n</p>\n\nWhere:\n- $A$ is the **amplitude**\n- $T$ is the **period** (with $ T = \\frac{1}{f} $)\n- $f$ is the **frequency**\n- $t$ is **time**\n\n### RL Circuit Simulation\n\nThe RL circuit's behavior is governed by the differential equation:\n\n$$\nV(t) = L \\frac{dI(t)}{dt} + R I(t)\n$$\n\nWhere:\n- $V(t)$ is the **voltage** from the generator\n- $I(t)$ is the **current** flowing through the circuit\n- $L$ is the **inductance**\n- $R$ is the **resistance**\n\nThis equation is solved iteratively using the **Euler method** for simulation.\n\n\n\n## \ud83d\udee0 Package Contents\n\n- **core**: C++ bindings for generators and circuit simulation.\n- **analyze**: Tools for analyzing and visualizing simulation results.\n\n\n\n## \ud83d\udce6 Installation\n\n### From PyPI\n\nInstall the package directly from PyPI:\n\n```bash\npip install XXXXXX\n```\n\n### From Source\n\nTo install from the source, follow these steps:\n\n```bash\ngit clone https://github.com/yourusername/electric-circuit-simulator.git\ncd electric-circuit-simulator\npython -m venv .venv\nsource .venv/bin/activate\npip install .\n```\n\n---\n\n## \ud83e\uddd1\u200d\ud83d\udcbb Usage Example\n\nHere\u2019s how you can use the Electric Circuit Simulator to analyze an RL circuit with different generators.\n\n#Example 1\n```python\n\nfrom circuit_simulator.core import CircuitRL, SquareWaveGenerator\n\n# Create generator\nsquare_gen = SquareWaveGenerator(frequency=0.5, amplitude=0.5)\n\n# Create RL circuit\ncircuit = CircuitRL(resistance=1, inductance=5)\n\n# Simulate Circuit\nresult = circuit.simulate(generator=square_gen, t_end=1, dt=0.1)\n\n# Print result\nprint(result) # [(0.0, 0.5, 0.010000000000000002), (0.1, 0.5, 0.019800000000000005), (0.2, 0.5, 0.029404000000000007), ...]\n\n```\n#Example 2\n```python\n\n\nfrom circuit_simulator.analyze import CircuitRLAnalyzer\nfrom circuit_simulator.core import CircuitRL, SinusoidalGenerator, SquareWaveGenerator\n\n# Create generators\nsin_gen = SinusoidalGenerator(frequency=0.25, amplitude=0.5)\nsquare_gen = SquareWaveGenerator(frequency=0.2, amplitude=0.2)\n\n# Create RL circuit\ncircuit = CircuitRL(resistance=0.5, inductance=15)\n\n# Create analyzer\nanalyzer = CircuitRLAnalyzer(generators={\"sin\": sin_gen, \"square\": square_gen}, circuit=circuit)\n\n# Analyze the circuit\nanalyzer.analyze(end_time=10.0, step=0.1)\n\n# Plot the results\nanalyzer.plot_results()\n```\n\n\n\n## \ud83d\ude80 Features\n\n- **High Performance**: Core computations are implemented in C++ for maximum performance.\n- **Python Bindings**: Seamless Python API provided by `pybind11`.\n- **Flexible Generators**: Includes both **sinusoidal** and **square wave** generators for different testing conditions.\n- **RL Circuit Simulation**: Simulate the response of an **RL circuit** under varying conditions.\n- **Analysis Tools**: Built-in functionality for analyzing and plotting the simulation results.\n\n---\n\n## \ud83d\udcdc License\n\nThis project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for more details.\n\n---\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! If you'd like to contribute to **Electric Circuit Simulator**, please feel free to:\n\n1. Fork the repository\n2. Make your changes\n3. Submit a **pull request**\n\nFor any issues or feature requests, please open an issue in the repository.\n\n---\n\n## \ud83d\udca1 Additional Information\n\nThe **Electric Circuit Simulator** is ideal for educational purposes, research, and testing different electrical circuits using realistic signal generators. It provides a robust and easy-to-use platform for simulating real-world electrical systems.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A powerful Python package for simulating electrical circuits and generators.",
    "version": "0.0.2",
    "project_urls": null,
    "split_keywords": [
        "simulation",
        " electrical circuits",
        " generators",
        " rl circuit",
        " sinusoidal",
        " square wave"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "90fd37115125ffc5792f33ce0bcc3f18cc6ce52731bd1e662266c230205f7acb",
                "md5": "04dfb6cb0a61f04ea5337a09c96b93a7",
                "sha256": "c40f3e8185af6aac5b1fc51b6e0faf162f3307d1d4e2aa79ac3e55f71f195912"
            },
            "downloads": -1,
            "filename": "electriccircuitsim-0.0.2-cp311-cp311-manylinux_2_34_x86_64.whl",
            "has_sig": false,
            "md5_digest": "04dfb6cb0a61f04ea5337a09c96b93a7",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.11",
            "size": 90398,
            "upload_time": "2025-02-04T22:55:01",
            "upload_time_iso_8601": "2025-02-04T22:55:01.269977Z",
            "url": "https://files.pythonhosted.org/packages/90/fd/37115125ffc5792f33ce0bcc3f18cc6ce52731bd1e662266c230205f7acb/electriccircuitsim-0.0.2-cp311-cp311-manylinux_2_34_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5a17c317a4e31c277c84b58553044880f8c87b3213fab9e87a549a6de485f47f",
                "md5": "b68f1470f0ad581c1c87c0d687f57966",
                "sha256": "d8b92a94ab3e652187f864b4d9cdef5b18da78110b88b04fbfcb7f45b0f61d05"
            },
            "downloads": -1,
            "filename": "ElectricCircuitSim-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b68f1470f0ad581c1c87c0d687f57966",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 8560,
            "upload_time": "2025-02-04T23:23:52",
            "upload_time_iso_8601": "2025-02-04T23:23:52.214973Z",
            "url": "https://files.pythonhosted.org/packages/5a/17/c317a4e31c277c84b58553044880f8c87b3213fab9e87a549a6de485f47f/ElectricCircuitSim-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bd9c3985cc0047d8c73b938057b743ec95f4d47098dedc7959e6b4a20cb17aef",
                "md5": "80d2ade6ab4ca39fc6f54424df2c0788",
                "sha256": "11216d46d9d0954b52a555e8de3b2c15ea6b27ee94a96d0cf26da9ffdd517572"
            },
            "downloads": -1,
            "filename": "electriccircuitsim-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "80d2ade6ab4ca39fc6f54424df2c0788",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 8822,
            "upload_time": "2025-02-04T23:23:53",
            "upload_time_iso_8601": "2025-02-04T23:23:53.704367Z",
            "url": "https://files.pythonhosted.org/packages/bd/9c/3985cc0047d8c73b938057b743ec95f4d47098dedc7959e6b4a20cb17aef/electriccircuitsim-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-04 23:23:53",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "electriccircuitsim"
}
        
Elapsed time: 0.39080s