Skip to main content

Crate pvlib

Crate pvlib 

Source
Expand description

§pvlib-rust

A Rust port of pvlib-python, the open-source solar photovoltaic modeling library. The crate covers the full PV simulation pipeline: solar position, clear-sky irradiance, transposition, incidence-angle modifier, cell temperature, and DC/AC power.

§Feature flags

  • pvgis (default) — enables network I/O for PVGIS and NREL SAM helpers in iotools. Pulls in reqwest with rustls-tls. Disable with default-features = false to build the pure-compute parts of the library on targets where blocking HTTP is not available (e.g. wasm32-unknown-unknown).

§Quick start — batch simulation

use chrono::TimeZone;
use chrono_tz::US::Mountain;
use pvlib::batch::{BatchModelChain, WeatherSeries};
use pvlib::irradiance::DiffuseModel;
use pvlib::Location;

let location = Location::try_new(39.74, -105.18, Mountain, 1830.0, "Golden, CO").unwrap();

let mc = BatchModelChain::pvwatts(location, 30.0, 180.0, 5000.0)
    .with_gamma_pdc(-0.004)
    .with_inverter(5000.0, 0.96)
    .with_albedo(0.2)
    .with_transposition(DiffuseModel::Perez)
    .with_auto_decomposition(true)
    .with_system_losses(0.14);

let weather = WeatherSeries {
    times,
    ghi: zeros.clone(), dni: zeros.clone(), dhi: zeros.clone(),
    temp_air: zeros.clone(), wind_speed: zeros.clone(),
    albedo: None,
};

let results = mc.run(&weather).unwrap();
println!("Annual energy: {:.0} kWh", results.total_energy_wh() / 1000.0);

See the README for the full Quick Start, step-by-step usage, and the comparison with pvlib-python.

§Algorithm notes

  • irradiance::dirint and irradiance::dirint_series are faithful ports of pvlib.irradiance.dirint, including the full 6×6×7×5 coefficient tensor. The scalar version uses the delta_kt' = -1 fallback bin; call the series version for time-aware persistence.
  • clearsky::detect_clearsky is a faithful port of the Reno–Hansen (2016) windowed 5-criterion algorithm with iterative α rescaling.
  • bifacial exposes the real 2-D view-factor primitives (vf_row_sky_2d, vf_row_sky_2d_integ, vf_row_ground_2d, vf_row_ground_2d_integ, unshaded_ground_fraction, solar_projection_tangent) used inside pvlib.bifacial.infinite_sheds, plus a composed rear-irradiance helper bifacial::rear_irradiance_sheds. The front-face / shadow-fraction pipeline of the full get_irradiance_poa is tracked in ROADMAP.md.

Re-exports§

pub use location::Location;
pub use location::LocationError;
pub use batch::BatchModelChain;
pub use batch::WeatherSeries;
pub use batch::SimulationSeries;
pub use modelchain::ModelChain;
pub use modelchain::ModelChainConfig;
pub use modelchain::ModelChainResult;
pub use modelchain::WeatherInput;
pub use pvsystem::PVSystem;
pub use pvsystem::Array;
pub use pvsystem::Mount;
pub use pvsystem::FixedMount;
pub use pvsystem::SingleAxisTrackerMount;

Modules§

albedo
atmosphere
batch
bifacial
Bifacial / row-to-row view-factor primitives (2-D infinite-sheds model).
clearsky
iam
inverter
iotools
irradiance
ivtools
IV curve tools: utilities and parameter fitting for the single diode model.
location
modelchain
pvarray
pvsystem
scaling
shading
singlediode
snow
soiling
solarposition
spectrum
temperature
tracking
transformer