forked from mpusz/mp-units
Added charge density
This commit is contained in:
@@ -158,6 +158,13 @@ struct dim_energy_density : derived_dimension<Child, U, exp<E, 1>, exp<L, -3>> {
|
||||
template<typename Child, Unit U, DimensionOf<dim_voltage> V, DimensionOf<dim_length> L>
|
||||
struct dim_electric_field_strength : derived_dimension<Child, U, exp<V, 1>, exp<L, -1>> {};
|
||||
|
||||
template<typename Child, Unit U, DimensionOf<dim_electric_charge> Q, DimensionOf<dim_length> L>
|
||||
struct dim_charge_density : derived_dimension<Child, U, exp<Q, 1>, exp<L, -3>> {};
|
||||
|
||||
template<typename Child, Unit U, DimensionOf<dim_electric_charge> Q, DimensionOf<dim_length> L>
|
||||
struct dim_surface_charge_density : derived_dimension<Child, U, exp<Q, 1>, exp<L, -2>> {};
|
||||
|
||||
|
||||
} // namespace physical
|
||||
|
||||
template<typename T>
|
||||
@@ -274,4 +281,10 @@ concept ThermalConductivity = physical::QuantityOf<T, physical::dim_thermal_cond
|
||||
template<typename T>
|
||||
concept ElectricFieldStrength = physical::QuantityOf<T, physical::dim_electric_field_strength>;
|
||||
|
||||
template<typename T>
|
||||
concept ChargeDensity = physical::QuantityOf<T, physical::dim_charge_density>;
|
||||
|
||||
template<typename T>
|
||||
concept SurfaceChargeDensity = physical::QuantityOf<T, physical::dim_surface_charge_density>;
|
||||
|
||||
} // namespace units
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "si/area.h"
|
||||
#include "si/capacitance.h"
|
||||
#include "si/catalytic_activity.h"
|
||||
#include "si/charge_density.h"
|
||||
#include "si/concentration.h"
|
||||
#include "si/conductance.h"
|
||||
#include "si/constants.h"
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/si/electric_charge.h>
|
||||
#include <units/physical/si/length.h>
|
||||
#include <units/physical/si/prefixes.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::si {
|
||||
|
||||
struct coulomb_per_metre_cub : unit<coulomb_per_metre_cub> {};
|
||||
struct coulomb_per_metre_sq : unit<coulomb_per_metre_sq> {};
|
||||
|
||||
struct dim_charge_density : physical::dim_charge_density<dim_charge_density, coulomb_per_metre_cub, dim_electric_charge, dim_length> {};
|
||||
struct dim_surface_charge_density : physical::dim_surface_charge_density<dim_surface_charge_density, coulomb_per_metre_sq, dim_electric_charge, dim_length> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using charge_density = quantity<dim_charge_density, U, Rep>;
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using surface_charge_density = quantity<dim_surface_charge_density, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// C/m³
|
||||
constexpr auto operator"" q_C_per_m3(unsigned long long l) { return charge_density<coulomb_per_metre_cub, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_C_per_m3(long double l) { return charge_density<coulomb_per_metre_cub, long double>(l); }
|
||||
|
||||
// C/m²
|
||||
constexpr auto operator"" q_C_per_m2(unsigned long long l) { return surface_charge_density<coulomb_per_metre_sq, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_C_per_m2(long double l) { return surface_charge_density<coulomb_per_metre_sq, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
Reference in New Issue
Block a user