Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
diagnostics.hpp
Go to the documentation of this file.
1#pragma once
2
36
37#include <span>
38
41#include "orrery/core/types.hpp"
42#include "orrery/core/vec3.hpp"
44
45namespace orrery::core {
46
53 Real kinetic_energy{};
54 Real potential_energy{};
55 Vec3 linear_momentum{};
56 Vec3 angular_momentum{};
57
58 [[nodiscard]] constexpr Real total_energy() const noexcept {
59 return kinetic_energy + potential_energy;
60 }
61
79 [[nodiscard]] constexpr Real virial_ratio() const noexcept {
80 const Real magnitude = potential_energy < 0 ? -potential_energy : potential_energy;
81 return 2 * kinetic_energy / magnitude;
82 }
83};
84
86[[nodiscard]] Real total_mass(std::span<const Real> masses);
87
93[[nodiscard]] Vec3 centre_of_mass(Vec3Span<const Real> positions, std::span<const Real> masses);
94
98 std::span<const Real> masses);
99
101[[nodiscard]] Real kinetic_energy(Vec3Span<const Real> velocities, std::span<const Real> masses);
102
107[[nodiscard]] Real potential_energy(Vec3Span<const Real> positions, std::span<const Real> masses,
108 Softening softening);
109
111[[nodiscard]] Vec3 linear_momentum(Vec3Span<const Real> velocities, std::span<const Real> masses);
112
120 std::span<const Real> masses);
121
130[[nodiscard]] Diagnostics measure_diagnostics(const ParticleData& data, Softening softening);
131
132} // namespace orrery::core
Storage for a set of point masses in structure-of-arrays layout.
Definition particle_data.hpp:43
The softening length of the Plummer kernel above.
Definition softening.hpp:49
Vec3 centre_of_mass(Vec3Span< const Real > positions, std::span< const Real > masses)
The mass-weighted mean position.
Real potential_energy(Vec3Span< const Real > positions, std::span< const Real > masses, Softening softening)
U = -G sum over pairs of m_i m_j / sqrt(r_ij^2 + eps^2).
Vec3 angular_momentum(Vec3Span< const Real > positions, Vec3Span< const Real > velocities, std::span< const Real > masses)
L = sum over i of m_i (r_i cross v_i), about the origin.
Real kinetic_energy(Vec3Span< const Real > velocities, std::span< const Real > masses)
T = sum over i of m_i v_i^2 / 2.
Diagnostics measure_diagnostics(const ParticleData &data, Softening softening)
Every quantity above, measured together.
Vec3 centre_of_mass_velocity(Vec3Span< const Real > velocities, std::span< const Real > masses)
The mass-weighted mean velocity, which is the velocity of the centre of mass and is what a sampler su...
Vec3 linear_momentum(Vec3Span< const Real > velocities, std::span< const Real > masses)
P = sum over i of m_i v_i.
Real total_mass(std::span< const Real > masses)
The sum of the masses.
The particle store: one contiguous array per component.
Plummer softening, defined once for everything that needs it.
Every conserved quantity of a configuration, measured at one instant.
Definition diagnostics.hpp:52
constexpr Real virial_ratio() const noexcept
The virial ratio 2T / |U|.
Definition diagnostics.hpp:79
A view of three component arrays of equal length.
Definition vec3_span.hpp:33
A vector in three-dimensional Euclidean space.
Definition vec3.hpp:26
The scalar and index types that every layer of the project agrees on.
A three-component vector for interfaces, not for storage.
Three parallel component arrays, viewed as one sequence of 3-vectors.