Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- 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)
- Added `ATM` and `POISE` as additional units for pressure and viscosity.
- Added `EPSILON0` and `KE` as additional constants. [#113](https://github.com/itt-ustutt/quantity/pull/113)

## [0.13.0] - 2026-01-06
### Changed
Expand Down
1 change: 1 addition & 0 deletions si-units/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added `ATM` and `POISE` as additional units for pressure and viscosity.
- Added `sum` for `SIObject`s that can be summed. [#111](https://github.com/itt-ustutt/quantity/pull/111)
- Added `EPSILON0` and `KE` as additional constants. [#113](https://github.com/itt-ustutt/quantity/pull/113)

### Fixed
- Fixed the String representation of non-scalar mass quantities. [#111](https://github.com/itt-ustutt/quantity/pull/111)
Expand Down
2 changes: 2 additions & 0 deletions si-units/docs/derived.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ of quantities is unique, they do not appear in formatted outputs.
| -------- | ---------------------- | ------------------------- | ------------------------------------------------------------------- |
| G | Gravitational constant | $G$ | $6.6743\times 10^{-11}~\frac{\text{m}^3}{\text{kg}\cdot\text{s}^2}$ |
| RGAS | Ideal gas constant | $R=N_\text{Av}k_\text{B}$ | $8.31446261815324~\frac{\text{J}}{\text{mol}\cdot\text{K}}$ |
| EPSILON0 | Electric constant | $\varepsilon_0$ | $8.8541878188e-12~\frac{\text{F}}{\text{m}}$ |
| KE | Coulomb constant | $k_\text{e} = \frac{1}{4\pi\varepsilon_0}$ | $8987551786.1708~\frac{\text{m}}{\text{F}}$ |

### Example

Expand Down
8 changes: 8 additions & 0 deletions si-units/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use pyo3::exceptions::PyRuntimeError;
use pyo3::prelude::*;
use pyo3::types::{PyFloat, PyNotImplemented};
use pyo3::{PyErr, PyTypeInfo};
use std::f64::consts::FRAC_1_PI;
use thiserror::Error;

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

m.add("QUECTO", QUECTO)?;
m.add("RONTO", RONTO)?;
Expand Down
4 changes: 4 additions & 0 deletions si-units/src/si_units/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
MINUTE,
G,
RGAS,
EPSILON0,
KE,
QUECTO,
RONTO,
YOCTO,
Expand Down Expand Up @@ -147,6 +149,8 @@
"MINUTE",
"G",
"RGAS",
"EPSILON0",
"KE",
"QUECTO",
"RONTO",
"YOCTO",
Expand Down
2 changes: 2 additions & 0 deletions si-units/src/si_units/_core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ LITER: Final[SIObject]
MINUTE: Final[SIObject]
G: Final[SIObject]
RGAS: Final[SIObject]
EPSILON0: Final[SIObject]
KE: Final[SIObject]
QUECTO: Final[float]
RONTO: Final[float]
YOCTO: Final[float]
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
//! -|-|-|-
//! [G] | Gravitational constant | $G$ | $6.6743\\times 10^{-11}\\,\\frac{\text{m}^3}{\text{kg}\cdot\text{s}^2}$
//! [RGAS] | Ideal gas constant | $R=N_\text{Av}k_\text{B}$ | $8.31446261815324\\,\\frac{\text{J}}{\text{mol}\\cdot\text{K}}$
//! [EPSILON0] | Electric constant | $\varepsilon_0$ | $8.8541878188e-12~\frac{\text{F}}{\text{m}}$
//! [KE] | Coulomb constant | $k_\text{e} = \frac{1}{4\pi\varepsilon_0}$ | $8987551786.1708~\frac{\text{m}}{\text{F}}$
//!
//! ## Prefixes
//!
Expand Down Expand Up @@ -143,6 +145,7 @@
#![warn(clippy::all)]
#[cfg(feature = "ndarray")]
use ndarray::{Array, ArrayBase, Data, Dimension};
use std::f64::consts::FRAC_1_PI;
use std::marker::PhantomData;
use std::ops::{Add, Deref, Div, Mul, Neg, Sub};

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

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