Skip to content
Closed
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Electric and Coulomb constants added. [#47](https://github.com/itt-ustutt/quantity/issues/47)
- ATM and POISE added as derived units. [#46](https://github.com/itt-ustutt/quantity/issues/46)

## [0.13.0] - 2026-01-06
### Changed
Expand Down
5 changes: 5 additions & 0 deletions si-units/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Correctly formats output of arrays with a unit.

### Added
- Getter and Setter generalized to common NumPy indexing, such that general slicing operations are possible in multiple dimensions.

## [0.11.1] - 2026-01-22
### Fixed
Expand Down
42 changes: 23 additions & 19 deletions si-units/docs/derived.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,32 @@ For convenience, a number of commonly used units that are not directly combinati
These constants simplify the specification of properties, that are not given in SI units. However, as the representation
of quantities is unique, they do not appear in formatted outputs.

| Unit | Unit symbol | Quantity | Definition |
| -------- | ------------ | ------------- | --------------------------------------------- |
| ANGSTROM | $\text{Å}$ | length | $10^{-10}~\text{m}$ |
| AMU | $\text{u}$ | mass | $1.6605390671738466\times 10^{-27}~\text{kg}$ |
| AU | $\text{au}$ | length | $149597870700~\text{m}$ |
| BAR | $\text{bar}$ | pressure | $10^5~\text{Pa}$ |
| CALORIE | $\text{cal}$ | energy | $4.184~\text{J}$ |
| DAY | $\text{d}$ | time | $86400~\text{s}$ |
| DEBYE | $\text{De}$ | dipole moment | $\sqrt{10^{-19}~\text{JÅ}^3}$ |
| DEGREES | $^\circ$ | angle | $\frac{\pi}{180}~\text{rad}$ |
| GRAM | $\text{g}$ | mass | $10^{-3}~\text{kg}$ |
| HOUR | $\text{h}$ | time | $3600~\text{s}$ |
| LITER | $\text{l}$ | volume | $10^{-3}~\text{m}^3$ |
| MINUTE | $\text{min}$ | time | $60~\text{s}$ |
| RADIANS | $\text{rad}$ | angle | |
| Unit | Unit symbol | Quantity | Definition |
| -------- | --------------- | ------------- | --------------------------------------------- |
| ANGSTROM | $\text{Å}$ | length | $10^{-10}~\text{m}$ |
| AMU | $\text{u}$ | mass | $1.6605390671738466\times 10^{-27}~\text{kg}$ |
| ATM | $\text{bar}$ | presssure | $101325~\text{N/m^2}$ |
| AU | $\text{au}$ | length | $149597870700~\text{m}$ |
| BAR | $\text{bar}$ | pressure | $10^5~\text{Pa}$ |
| CALORIE | $\text{cal}$ | energy | $4.184~\text{J}$ |
| DAY | $\text{d}$ | time | $86400~\text{s}$ |
| DEBYE | $\text{De}$ | dipole moment | $\sqrt{10^{-19}~\text{JÅ}^3}$ |
| DEGREES | $^\circ$ | angle | $\frac{\pi}{180}~\text{rad}$ |
| GRAM | $\text{g}$ | mass | $10^{-3}~\text{kg}$ |
| HOUR | $\text{h}$ | time | $3600~\text{s}$ |
| LITER | $\text{l}$ | volume | $10^{-3}~\text{m}^3$ |
| MINUTE | $\text{min}$ | time | $60~\text{s}$ |
| POISE | $\text{m Pa s}$ | viscosity | $0.1~\text{Pa s}$ |
| RADIANS | $\text{rad}$ | angle | |

## Additional Constants

| Constant | Name | Symbol | Value |
| -------- | ---------------------- | ------------------------- | ------------------------------------------------------------------- |
| 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}}$ |
| Constant | Name | Symbol | Value |
| -------- | ---------------------- | ----------------------------------------- | ---------------------------------------------------------------------- |
| G | Gravitational constant | $G$ | $6.6743\times 10^{-11}~\frac{\text{m}^3}{\text{kg}\cdot\text{s}^2}$ |
| EPSILON0 | Electric constant | $\epsilon_0$ | $8.8541878188e-12~\frac{\text{A}\cdot\text{s}}{\text{V}\cdot\text{m}}$ |
| KE | Coulomb constant | $k_\text{e} = \frac{1}{4 \pi \epsilon_0}$ | $8987551786.170797~\frac{\text{N}\cdot\text{m}^2}{\text{C}^2}$ |
| RGAS | Ideal gas constant | $R=N_\text{Av}k_\text{B}$ | $8.31446261815324~\frac{\text{J}}{\text{mol}\cdot\text{K}}$ |

### Example

Expand Down
9 changes: 9 additions & 0 deletions si-units/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ impl SINumber {
format!("{}\\,{}", float_to_latex(self.value), &self.unit.to_latex())
}
}

pub fn into_scaled_parts(&self) -> (f64, String) {
if let Some((unit, symbol, _, _, _)) = DERIVED_UNITS.get(&self.unit) {
if !self.value.is_nan() {
return (self.value / unit.value, symbol.clone());
}
}
(self.value, self.unit.to_string())
}
}

fn float_to_latex(f: f64) -> String {
Expand Down
Loading