Skip to content

Commit 3601d80

Browse files
authored
Add EPSILON0 and KE as additional constants (#113)
1 parent b0fd749 commit 3601d80

7 files changed

Lines changed: 27 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Added
99
- Added implementations for trigonometric funtions for `Angle<T>` with `T: DualNum<f64>` when the `num-dual` feature is active. [#105](https://github.com/itt-ustutt/quantity/pull/105)
1010
- Added `ATM` and `POISE` as additional units for pressure and viscosity.
11+
- Added `EPSILON0` and `KE` as additional constants. [#113](https://github.com/itt-ustutt/quantity/pull/113)
1112

1213
## [0.13.0] - 2026-01-06
1314
### Changed

si-units/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
### Added
1212
- Added `ATM` and `POISE` as additional units for pressure and viscosity.
1313
- Added `sum` for `SIObject`s that can be summed. [#111](https://github.com/itt-ustutt/quantity/pull/111)
14+
- Added `EPSILON0` and `KE` as additional constants. [#113](https://github.com/itt-ustutt/quantity/pull/113)
1415

1516
### Fixed
1617
- Fixed the String representation of non-scalar mass quantities. [#111](https://github.com/itt-ustutt/quantity/pull/111)

si-units/docs/derived.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ of quantities is unique, they do not appear in formatted outputs.
4747
| -------- | ---------------------- | ------------------------- | ------------------------------------------------------------------- |
4848
| G | Gravitational constant | $G$ | $6.6743\times 10^{-11}~\frac{\text{m}^3}{\text{kg}\cdot\text{s}^2}$ |
4949
| RGAS | Ideal gas constant | $R=N_\text{Av}k_\text{B}$ | $8.31446261815324~\frac{\text{J}}{\text{mol}\cdot\text{K}}$ |
50+
| EPSILON0 | Electric constant | $\varepsilon_0$ | $8.8541878188e-12~\frac{\text{F}}{\text{m}}$ |
51+
| KE | Coulomb constant | $k_\text{e} = \frac{1}{4\pi\varepsilon_0}$ | $8987551786.1708~\frac{\text{m}}{\text{F}}$ |
5052

5153
### Example
5254

si-units/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use pyo3::exceptions::PyRuntimeError;
77
use pyo3::prelude::*;
88
use pyo3::types::{PyFloat, PyNotImplemented};
99
use pyo3::{PyErr, PyTypeInfo};
10+
use std::f64::consts::FRAC_1_PI;
1011
use thiserror::Error;
1112

1213
mod si_unit;
@@ -537,6 +538,13 @@ pub fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> {
537538
add_constant(m, "G", 6.6743e-11, SIUnit([3, -1, -2, 0, 0, 0, 0]))?;
538539
let rgas = 1.380649e-23 * 6.02214076e23;
539540
add_constant(m, "RGAS", rgas, _JOULE_PER_MOL_AND_KELVIN)?;
541+
add_constant(m, "EPSILON0", 8.8541878188e-12, _FARAD / _METER)?;
542+
add_constant(
543+
m,
544+
"KE",
545+
FRAC_1_PI / (4.0 * 8.8541878188e-12),
546+
_METER / _FARAD,
547+
)?;
540548

541549
m.add("QUECTO", QUECTO)?;
542550
m.add("RONTO", RONTO)?;

si-units/src/si_units/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
MINUTE,
7070
G,
7171
RGAS,
72+
EPSILON0,
73+
KE,
7274
QUECTO,
7375
RONTO,
7476
YOCTO,
@@ -147,6 +149,8 @@
147149
"MINUTE",
148150
"G",
149151
"RGAS",
152+
"EPSILON0",
153+
"KE",
150154
"QUECTO",
151155
"RONTO",
152156
"YOCTO",

si-units/src/si_units/_core.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ LITER: Final[SIObject]
254254
MINUTE: Final[SIObject]
255255
G: Final[SIObject]
256256
RGAS: Final[SIObject]
257+
EPSILON0: Final[SIObject]
258+
KE: Final[SIObject]
257259
QUECTO: Final[float]
258260
RONTO: Final[float]
259261
YOCTO: Final[float]

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
//! -|-|-|-
6969
//! [G] | Gravitational constant | $G$ | $6.6743\\times 10^{-11}\\,\\frac{\text{m}^3}{\text{kg}\cdot\text{s}^2}$
7070
//! [RGAS] | Ideal gas constant | $R=N_\text{Av}k_\text{B}$ | $8.31446261815324\\,\\frac{\text{J}}{\text{mol}\\cdot\text{K}}$
71+
//! [EPSILON0] | Electric constant | $\varepsilon_0$ | $8.8541878188e-12~\frac{\text{F}}{\text{m}}$
72+
//! [KE] | Coulomb constant | $k_\text{e} = \frac{1}{4\pi\varepsilon_0}$ | $8987551786.1708~\frac{\text{m}}{\text{F}}$
7173
//!
7274
//! ## Prefixes
7375
//!
@@ -143,6 +145,7 @@
143145
#![warn(clippy::all)]
144146
#[cfg(feature = "ndarray")]
145147
use ndarray::{Array, ArrayBase, Data, Dimension};
148+
use std::f64::consts::FRAC_1_PI;
146149
use std::marker::PhantomData;
147150
use std::ops::{Add, Deref, Div, Mul, Neg, Sub};
148151

@@ -556,6 +559,12 @@ pub const CLIGHT: Velocity = Quantity(299792458.0, PhantomData);
556559
pub const KCD: Quantity<f64, SIUnit<-2, -1, 3, 0, 0, 0, 1>> = Quantity(683.0, PhantomData);
557560
/// Gravitational constant $\\left(G=6.6743\\times 10^{-11}\\,\\frac{\text{m}^3}{\text{kg}\cdot\text{s}^2}\\right)$
558561
pub const G: Quantity<f64, SIUnit<-2, 3, -1, 0, 0, 0, 0>> = Quantity(6.6743e-11, PhantomData);
562+
/// Electric constant $\\left(\\varepsilon_0=8.8541878188\times 10^{-12}\\,\\frac{\text{F}}{\text{m}}\\right)$
563+
pub const EPSILON0: Quantity<f64, SIUnit<4, -3, -1, 2, 0, 0, 0>> =
564+
Quantity(8.8541878188e-12, PhantomData);
565+
/// Coulomb constant $\\left(k_\text{e}=\frac{1}{4\pi\varepsilon_0}=8987551786.1708\\,\\frac{\text{m}}{\text{F}}\\right)$
566+
pub const KE: Quantity<f64, SIUnit<-4, 3, 1, -2, 0, 0, 0>> =
567+
Quantity(FRAC_1_PI / (4.0 * 8.8541878188e-12), PhantomData);
559568

560569
/// Prefix quecto $\\left(\text{q}=10^{-30}\\right)$
561570
pub const QUECTO: f64 = 1e-30;

0 commit comments

Comments
 (0)