libpower/mppt/
mod.rs

1//! # Maximum Power Point Tracking (MPPT) Algorithms
2//!
3//! This module provides implementations of Maximum Power Point Tracking algorithms
4//! commonly used in photovoltaic (PV) systems and other renewable energy applications.
5//! MPPT algorithms optimize power extraction from variable sources like solar panels.
6//!
7//! ## Theory
8//!
9//! The maximum power point (MPP) of a photovoltaic array varies with:
10//! - **Irradiance levels**: Higher light intensity increases power output
11//! - **Temperature**: Higher temperatures generally reduce voltage and power
12//! - **Partial shading**: Can create multiple local maxima
13//! - **Array degradation**: Aging affects the characteristic curves
14//!
15//! ## Available Algorithms
16//!
17//! ### Perturb and Observe (P&O)
18//! - [`perturb_and_observe`] - Classical hill-climbing algorithm
19//! - **Principle**: Perturb voltage and observe power change
20//! - **Advantages**: Simple implementation, low computational cost
21//! - **Disadvantages**: Oscillates around MPP, can be confused by rapid irradiance changes
22//!
23//! ### Incremental Conductance (IC)
24//! - [`incremental_conductance`] - Advanced gradient-based method
25//! - **Principle**: Uses dP/dV = 0 condition at MPP
26//! - **Advantages**: Can detect when MPP is reached, better dynamic response
27//! - **Disadvantages**: More complex implementation, sensitive to noise
28//!
29//! ## Algorithm Comparison
30//!
31//! | Feature | P&O | IC |
32//! |---------|-----|-----|
33//! | Simplicity | High | Medium |
34//! | Speed | Fast | Medium |
35//! | Steady-state accuracy | Medium | High |
36//! | Dynamic response | Medium | Good |
37//! | Noise sensitivity | Low | Medium |
38//! | Memory requirements | Low | Low |
39//!
40//! ## Implementation Considerations
41//!
42//! ### Step Size Selection
43//! - **Large steps**: Faster tracking, more oscillation
44//! - **Small steps**: Slower tracking, less oscillation
45//! - **Adaptive step size**: Optimal compromise (not implemented)
46//!
47//! ### Sampling Frequency
48//! - **Typical range**: 1-100 Hz depending on application
49//! - **Trade-offs**: Faster sampling vs. computational load
50//! - **Consideration**: PV array time constants (typically slow)
51//!
52//! ### Practical Considerations
53//! - **Voltage and current measurement accuracy**
54//! - **Converter dynamics and control loop interactions**
55//! - **Protection against out-of-range operating points**
56//! - **Startup and shutdown procedures**
57//!
58//! ## Applications
59//!
60//! - Grid-tied solar inverters
61//! - Battery charging systems
62//! - Standalone PV systems
63//! - Solar water pumping
64//! - Electric vehicle solar charging
65//! - Building-integrated photovoltaics (BIPV)
66//!
67//! ## Example Usage
68//!
69//! ```rust
70//! use libpower::mppt::perturb_and_observe::MPPT;
71//!
72//! // Create and configure MPPT tracker
73//! let mut mppt = MPPT::new();
74//! mppt.set_step_size(0.1);           // 0.1V step size
75//! mppt.set_mppt_v_out_max(24.0);     // 24V maximum
76//! mppt.set_mppt_v_out_min(12.0);     // 12V minimum
77//!
78//! // Simulate control loop samples
79//! let pv_measurements = [
80//!     (5.0, 18.0),  // (current, voltage) pairs
81//!     (5.1, 18.2),
82//!     (5.2, 18.1),
83//! ];
84//!
85//! for (pv_current, pv_voltage) in pv_measurements.iter() {
86//!     mppt.calculate(*pv_current, *pv_voltage);     // Run MPPT algorithm
87//!     let reference_voltage = mppt.get_mppt_v_out(); // Get voltage reference
88//!     // In real application: set_converter_reference(reference_voltage);
89//! }
90//! ```
91
92pub mod incremental_conductance;
93pub mod perturb_and_observe;