# force-electric
`force-electric` is a dependency-free Rust library for a compact set of
electrical relationships. It uses validated unit types instead of unlabelled
numbers and keeps these principles connected:
- Ohm's law: voltage, current, and resistance;
- DC power: voltage multiplied by current;
- series and parallel equivalent resistance;
- energy: power integrated over time.
## Example
```rust
use force_electric::{
Duration, Energy, Resistance, Voltage, DcOperatingPoint, parallel_resistance,
};
let point = DcOperatingPoint::from_voltage_and_resistance(
Voltage::volts(12.0)?,
Resistance::ohms(6.0)?,
)?;
assert_eq!(point.current().as_amperes(), 2.0);
assert_eq!(point.power().as_watts(), 24.0);
let energy = Energy::from_power_over(point.power(), Duration::hours(3.0)?)?;
assert_eq!(energy.as_watt_hours(), 72.0);
let parallel = parallel_resistance(&[
Resistance::ohms(100.0)?,
Resistance::ohms(100.0)?,
])?;
assert!((parallel.as_ohms() - 50.0).abs() < 1e-12);
# Ok::<(), force_electric::ElectricError>(())
```
Run the bundled example:
```text
cargo run --example dc_circuit
```
## Scope and safety
The crate models ideal scalar DC relationships. It does not model AC phase,
reactance, transients, temperature, component tolerances, insulation,
protective devices, or regulatory compliance. It is not a substitute for
qualified electrical design or safe measurement practice.
## License
MIT