---
title: "Utilities and constants"
---

Docstrings from `src/staticvec.jl`, `src/constants.jl`.

## Exported

### `CGS.c_light` {#CGS-c_light}

Source: [`src/constants.jl:12`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L12)

Speed of light [cm s⁻¹]

### `CGS.k_B` {#CGS-k_B}

Source: [`src/constants.jl:14`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L14)

Boltzmann constant [erg K⁻¹]

### `CGS.m_u` {#CGS-m_u}

Source: [`src/constants.jl:16`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L16)

Atomic mass unit [g]

### `CGS.m_H` {#CGS-m_H}

Source: [`src/constants.jl:18`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L18)

Hydrogen mass [g]

### `CGS.h_planck` {#CGS-h_planck}

Source: [`src/constants.jl:20`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L20)

Planck constant [erg s]

### `CGS.sigma_SB` {#CGS-sigma_SB}

Source: [`src/constants.jl:22`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L22)

Stefan-Boltzmann constant [erg cm⁻² s⁻¹ K⁻⁴]

### `CGS.a_rad` {#CGS-a_rad}

Source: [`src/constants.jl:24`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L24)

Radiation constant a_r = 4σ/c [erg cm⁻³ K⁻⁴]

### `CGS.G_grav` {#CGS-G_grav}

Source: [`src/constants.jl:26`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L26)

Gravitational constant [cm³ g⁻¹ s⁻²]

### `CGS.M_sun` {#CGS-M_sun}

Source: [`src/constants.jl:28`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L28)

Solar mass [g]

### `CGS.parsec` {#CGS-parsec}

Source: [`src/constants.jl:30`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L30)

Parsec [cm]

### `CGS.au` {#CGS-au}

Source: [`src/constants.jl:32`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L32)

Astronomical unit [cm]

### `CGS.year` {#CGS-year}

Source: [`src/constants.jl:34`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L34)

Year [s]

### `CGS.eV` {#CGS-eV}

Source: [`src/constants.jl:36`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L36)

Electron volt [erg]

## Internals

### `Honghu.CGS` {#Honghu-CGS}

Source: [`src/constants.jl:1`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/constants.jl#L1)

```julia
Honghu.CGS
```

Physical constants in CGS units (2018 CODATA where applicable).

Honghu is unit-agnostic: every physical parameter (`RadiationPhysics.c`,
`IdealGas.cv`, opacities, ...) is supplied by the user. Use these when you want
to run in CGS; use your own numbers when you want code units.

### `SVec` {#SVec}

Source: [`src/staticvec.jl:7`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/staticvec.jl#L7)

```julia
SVec{N,T}
```

Immutable, stack-allocated vector of `N` elements of type `T`.

Supports the arithmetic used by the Riemann solvers: `+`, `-`, scalar `*` and
`/`, indexing, and iteration. Deliberately *not* an `AbstractArray`, so that a
stray broadcast cannot silently allocate a heap array in a hot loop.

```julia
julia> Honghu.SVec(1.0, 2.0) + Honghu.SVec(3.0, 4.0)
SVec{2, Float64}(4.0, 6.0)
```

### `sumvec` {#sumvec}

Source: [`src/staticvec.jl:56`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/staticvec.jl#L56)

```julia
sumvec(a::SVec)
```

Sum of the components. Named to avoid extending `Base.sum`, which would invite
the generic iterator machinery into a hot loop.

### `maxabs` {#maxabs}

Source: [`src/staticvec.jl:64`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/staticvec.jl#L64)

```julia
maxabs(a::SVec)
```

Largest absolute component, for convergence tests on a group vector.

### `dot` {#dot}

Source: [`src/staticvec.jl:71`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/staticvec.jl#L71)

```julia
dot(a::SVec, b::SVec)
```

Euclidean inner product. (Local to Honghu; not `LinearAlgebra.dot`.)

### `norm` {#norm}

Source: [`src/staticvec.jl:78`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/staticvec.jl#L78)

```julia
norm(a::SVec)
```

Euclidean 2-norm.

