Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dragon90o/bodediagram_final
A Qt-based application for visualizing Bode diagrams. The project includes functionality for calculating and plotting magnitude and phase graphs, analyzing the system's zeros and poles, and determining its stability. Users can interact with the system through a graphical interface.
https://github.com/dragon90o/bodediagram_final
bode-plot control-systems cpp pdf-viewer qt6 signal-processing systems-stability transfer-functions
Last synced: 3 days ago
JSON representation
A Qt-based application for visualizing Bode diagrams. The project includes functionality for calculating and plotting magnitude and phase graphs, analyzing the system's zeros and poles, and determining its stability. Users can interact with the system through a graphical interface.
- Host: GitHub
- URL: https://github.com/dragon90o/bodediagram_final
- Owner: dragon90o
- Created: 2024-11-06T20:14:38.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-01-13T19:04:57.000Z (4 days ago)
- Last Synced: 2025-01-13T19:33:48.032Z (4 days ago)
- Topics: bode-plot, control-systems, cpp, pdf-viewer, qt6, signal-processing, systems-stability, transfer-functions
- Language: C++
- Homepage: https://www.dravvt.com
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bode Diagram Viewer Project
this project is graphically representing the mathematical calculations generated by my functions, showing magnitude and phase graphs, as well as the zeros and poles, and determining if the system is stable or unstable. The project is divided into two main parts: a visual part, responsible for the user interface, and a mathematical part, which handles the calculations. The files `widget.h` and `widget.cpp` correspond to the visual part, while the mathematical calculations are contained in the files `magnitudeandphase.cpp` and `magnitudeandphase.h`.
The `main.cpp` file is solely responsible for managing the widget display.
## Visual Part: `widget.h` and `widget.cpp`
In `widget.h` and `widget.cpp`, interactive elements such as input fields (QLine) are managed, where the user can input the numerator, denominator, and the minimum and maximum frequencies, as well as a sigma value. If no sigma is entered, a default value is used. The widget offers the user the flexibility to define the frequency range they wish to observe.
### Key Methods:
- `void Widget::onCalculatePushButtonClicked()`: Handles the calculation and generates magnitude and phase graphs.
- `void Widget::onExportButtonClicked()`: Exports the graphs as a PDF using Qt libraries like QPainter and QPixmap.
- `void Widget::onClearButtonClicked()`: Clears the widget, allowing the user to input new data without restarting the application.## Mathematical Part: `magnitudeandphase.h` and `magnitudeandphase.cpp`
In the mathematical part, I implemented methods to perform necessary calculations:
- **`processTransferFunction()`**: This method processes the transfer function, calculates the system's zeros and poles from the numerator and denominator coefficients, and returns the results in a human-readable format.
- **`parseCoefficients(const std::string& polynomial)`**: Processes a polynomial string and extracts the coefficients of each term using regular expressions, returning them as a vector.
- **`findRoots(const std::vector& coefficients)`**: Solves the polynomial's roots using the companion matrix method, utilizing Eigen for matrix operations. It adjusts the roots based on a sigma value, if provided.
- **`frequencies()`**: Calculates logarithmic frequencies and corresponding angular frequencies, using a user-defined frequency range (_freqMin and _freqMax).
- **`translateFunction(double angularFrequency, bool isNumerator)`**: Evaluates the transfer function (numerator or denominator) at a specific angular frequency, handling terms using regular expressions and complex number calculations.
- **`calculateMagnitude(double angularFrequency)`**: Calculates the magnitude in dB of the transfer function evaluated at a specific angular frequency.
- **`calculatePhase(const std::complex& transferFunction)`**: Calculates the phase of a complex transfer function using the `atan2` function.
- **`isStable()`**: Checks the stability of the system by examining the poles' position in the complex plane. If any pole has a real part greater than or equal to zero, the system is unstable.
These methods work together to provide the necessary calculations for the graphs and determine the stability of the system.
## Conclusion
This project represents a robust Bode diagram viewer that integrates both the user interface and complex mathematical calculations. It allows for dynamic interaction with the system's parameters, real-time graph updates, and stability analysis. The mathematical methods used provide accurate results, ensuring that the system's behavior is displayed correctly and that its stability is easily assessed.