TL;DR: Physics-informed simulation of DC-motor degradation over 10,000 hours; logs temperature/vibration/load, estimates health & RUL, and triggers maintenance to minimize cost.
- Final health: declined non-linearly to ~50% threshold, with partial recoveries post-maintenance
- Maintenance events triggered: 8 (Baseline policy)
- Estimated RUL at final hour: health plateaued near threshold, no catastrophic failure
- Thermal stability: motor <55 °C throughout (threshold = 75 °C)
- Unplanned downtime: 0 h (vs. 72 h under reactive)
- Total lifecycle cost: $768 (PdM) vs. $1,483.20 (reactive)
- Net savings with PdM: $715.20 (≈48.2%)
- External validity: simulated vibration features correlated >0.88 with NASA IMS bearing dataset (early/mid degradation)
Reproduce:
python -m src.main
→ writes outputs & figures inoutputs/
anddocs/
.
This repository contains a modularized Python simulation of a DC motor’s degradation (health) and remaining useful life (RUL) over time, based on sensor-generated inputs. The code is organized under the src/
directory to follow best practices in project structure.
- Features
- Project Structure
- Installation
- Usage
- Example Output
- Dependencies
- Contributing
- License
- Acknowledgments
- Sensor Simulation (
src/sensors.py
): Generates synthetic readings for load, temperature, RPM, current, noise, and vibration under different operational modes (idle
,active
,stressed
). - Health & RUL Calculation (
src/health_rul.py
): Computes motor health percentage, estimates remaining useful life (RUL), classifies health status (Normal/Warning/Critical), and logs maintenance events when health falls below a threshold. - Visualization (
src/plotting.py
): Produces a 2×2 panel plot of motor health, temperatures, load, RPM, and current over time for easy analysis. - Main Script (
src/main.py
): Orchestrates the simulation for 10,000 hours, saves results to CSV, and displays summary statistics and plots.
digital_twin_dc_motor/
├── README.md
├── requirements.txt
├── LICENSE
├── data/
│ └── complex_digital_twin_output_10000hrs
└── src/
├── sensors.py # Sensor simulation module
├── health_rul.py # Health & RUL calculation module
├── plotting.py # Plotting utilities module
└── main.py # Main entry-point script
README.md
: This file.requirements.txt
: Lists Python dependencies.LICENSE
: MIT License file.data/
: sample output file.src/
: Contains all source code modules.
-
Clone this repository:
git clone https://github.com/<your-username>/digital_twin_dc_motor.git cd digital_twin_dc_motor
-
(Optional) Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # macOS/Linux # or venv\Scripts\activate # Windows
-
Install dependencies:
pip install -r requirements.txt
There are two common ways to run the simulation.
cd src
python main.py
- Generates
complex_digital_twin_output_10000hrs.csv
insrc/
. - Displays a four-panel plot of health, temperature, load, RPM, and current over time.
- Prints any maintenance events and final health & RUL statistics to the console.
cd digital_twin_dc_motor
python -m src.main
- This assumes that imports in
src/main.py
remain relative (i.e.,from sensors import ...
), allowing Python to treatsrc/
as a package.
-
Sample Data:
- After running, you will find
src/complex_digital_twin_output_10000hrs.csv
containing all simulated sensor readings, health percentages, RUL estimates, and status labels.
- After running, you will find
-
Plots:
- A window displaying a 2×2 panel plot:
- Motor Health (%) vs. Time with maintenance event markers.
- Motor & Ambient Temperatures vs. Time.
- Load (%) vs. Time.
- RPM & Current (A) vs. Time (dual-axis).
- A window displaying a 2×2 panel plot:
-
Console Summary:
Maintenance events occurred at the following hours: [1234, 3456, 6789, ...] # examples Final Motor Health: XX.XX% Estimated RUL at final hour: YY.YY hrs
- Python 3.x
numpy
pandas
matplotlib
Install all required packages via:
pip install -r requirements.txt
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes, write tests if applicable, and update the documentation.
- Submit a pull request, describing your changes and why they improve the project.
Please follow PEP 8 style guidelines for Python code.
This project is licensed under the MIT License. See the LICENSE file for full terms.
MIT License
Copyright (c) 2025 Raghav Sharma
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Inspired by DC motor predictive maintenance research and digital twin frameworks.
- Data and method ideas adapted from standard reliability engineering models.