Update README.md

This commit is contained in:
judsonupchurch 2024-09-30 22:09:31 +00:00
parent 3c59598d38
commit ab2cdc1b48

110
README.md
View File

@ -0,0 +1,110 @@
# System Uncertainty Analysis Using Monte Carlo Simulations
## Overview
This project provides a framework for performing Monte Carlo analysis on systems that utilize various sensors and instrumentation. It allows users to represent complex systems where calculations are performed on sensor data and evaluates the impact of sensor uncertainties on overall system performance.
The tool performs:
- **Monte Carlo Analysis**: Evaluates the uncertainty of the entire system by simulating sensor errors.
- **Sensitivity Analysis**: Analyzes the impact of individual sensor errors on the system output.
- **Range Analysis**: Studies how variations in sensor input ranges affect the system.
An example report generated by this tool is included in the repository ([System Uncertainty Report.pdf](System_Uncertainty_Report.pdf)).
## Features
- **Customizable Sensor Models**: Define sensors with specific error characteristics.
- **Complex System Equations**: Represent the system's governing equations using sensor inputs.
- **Parallel Processing**: Utilize multiple processes to speed up simulations.
- **Visualization**: Generate plots for sensitivity and range analyses.
## How It Works
### 1. Define Sensors and Errors
Each sensor is modeled with its true value and associated error characteristics. Error parameters can include:
- **Static Error Band**
- **Repeatability**
- **Hysteresis**
- **Non-linearity**
- **Temperature Effects**
- **Full-Scale Output (FSO)**
Example of defining sensor errors:
```
pt_1_errors = {
"k": 2, # Number of standard deviations
"fso": 100, # Full-scale output
"static_error_band": 0.15, # % of FSO
"repeatability": 0.02, # % of FSO
"hysteresis": 0.07, # % of FSO
"non-linearity": 0.15, # % of FSO
"temperature_zero_error": 0.005, # % of FSO per degree
"temperature_offset": 30, # Degrees off from calibration
}
```
### 2. Create Sensor Instances
Sensors are instantiated using the defined error characteristics:
```
pressure_transmitter_1 = PressureTransmitter(25, pt_1_errors, name="PT 1")
pressure_transmitter_2 = PressureTransmitter(20, pt_1_errors, name="PT 2")
temperature_sensor_1 = RTD(250, RTD_1_errors, name="RTD 1")
flow_speed = TurbineFlowMeter(10, flow_1_errors, name="Flow Sensor 1")
pipe_diameter = PhysicalInput(1, pipe_diameter_error, name="Pipe Diameter")
```
### 3. Define the System Equation
The system's governing equation is defined using the sensor instances. For example:
```
combined_input = math.pi * density_lookup * flow_speed * (pipe_diameter / 12 / 2) ** 2
```
### 4. Perform Monte Carlo Analysis
The SystemUncertaintyMonteCarlo class is used to perform the analysis:
```monte_carlo = SystemUncertaintyMonteCarlo(combined_input)
monte_carlo.perform_system_analysis(monte_carlo_settings={
"num_runs": num_of_tests,
"num_processes": num_of_processes
})
```
### 5. Perform Sensitivity and Range Analyses
Sensitivity Analysis evaluates the impact of individual sensor errors:
```
monte_carlo.perform_sensitivity_analysis(
input_to_analyze=flow_speed,
gain_settings=[1, 2, 3, 4, 5],
monte_carlo_settings={
"num_runs": sensitivity_analysis_num_runs,
"num_processes": num_of_processes
}
)
```
Range Analysis studies the effect of varying sensor inputs:
```
monte_carlo.perform_range_analysis(
input_to_analyze=pressure_transmitter_1,
range_settings=[28, 31, 20], # Start, Stop, Number of Points
monte_carlo_settings={
"num_runs": range_analysis_num_runs,
"num_processes": num_of_processes
}
)
```
### 6. Generate Reports
After the analyses, a detailed report is generated summarizing the findings:
```
monte_carlo.save_report()
```