예제 #1
0
        public void Powerequation()
        {
            //Q = m * Cp * dT

            //obs - UnitsNet cant do this eq..


            EngineeringUnits.SpecificEntropy P1 = new EngineeringUnits.SpecificEntropy(1, EngineeringUnits.SpecificEntropyUnit.JoulePerKilogramKelvin);
            EngineeringUnits.MassFlow        M1 = new EngineeringUnits.MassFlow(1, EngineeringUnits.MassFlowUnit.KilogramPerSecond);
            EngineeringUnits.Temperature     T2 = new EngineeringUnits.Temperature(10, EngineeringUnits.TemperatureUnit.DegreeCelsius);
            EngineeringUnits.Temperature     T1 = new EngineeringUnits.Temperature(5, EngineeringUnits.TemperatureUnit.DegreeCelsius);

            EngineeringUnits.Power Q1 = M1 * P1 * (T2 - T1);



            UnitsNet.SpecificEntropy p1 = new UnitsNet.SpecificEntropy(1, UnitsNet.Units.SpecificEntropyUnit.JoulePerKilogramKelvin);
            UnitsNet.MassFlow        m1 = new UnitsNet.MassFlow(1, UnitsNet.Units.MassFlowUnit.KilogramPerSecond);
            UnitsNet.Temperature     t2 = new UnitsNet.Temperature(10, UnitsNet.Units.TemperatureUnit.DegreeCelsius);
            UnitsNet.Temperature     t1 = new UnitsNet.Temperature(5, UnitsNet.Units.TemperatureUnit.DegreeCelsius);

            UnitsNet.Power q1 = UnitsNet.Power.FromWatts(p1.JoulesPerKilogramKelvin * m1.KilogramsPerSecond * (t2.Kelvins - t1.Kelvins));



            Assert.AreEqual(0, Q1.As(EngineeringUnits.PowerUnit.BritishThermalUnitPerHour) - q1.As(UnitsNet.Units.PowerUnit.BritishThermalUnitPerHour), 7.2E-05);
            Assert.AreEqual(0, Q1.As(EngineeringUnits.PowerUnit.Kilowatt) - q1.As(UnitsNet.Units.PowerUnit.Kilowatt), 0);
            Assert.AreEqual(0, Q1.As(EngineeringUnits.PowerUnit.Watt) - q1.As(UnitsNet.Units.PowerUnit.Watt), 0);
        }
예제 #2
0
        public void Powerequation2()
        {
            //Q = m * Cp * dT

            //obs - UnitsNet cant do this eq..


            EngineeringUnits.SpecificEntropy P1 = new EngineeringUnits.SpecificEntropy(35345, EngineeringUnits.SpecificEntropyUnit.BtuPerPoundRankine);
            EngineeringUnits.MassFlow        M1 = new EngineeringUnits.MassFlow(4356, EngineeringUnits.MassFlowUnit.PoundPerMinute);
            EngineeringUnits.Temperature     T2 = new EngineeringUnits.Temperature(342, EngineeringUnits.TemperatureUnit.DegreeRankine);
            EngineeringUnits.Temperature     T1 = new EngineeringUnits.Temperature(43, EngineeringUnits.TemperatureUnit.DegreeRankine);

            EngineeringUnits.Power Q1 = M1 * P1 * (T2 - T1);



            UnitsNet.SpecificEntropy p1 = new UnitsNet.SpecificEntropy(35345, UnitsNet.Units.SpecificEntropyUnit.BtuPerPoundFahrenheit);
            UnitsNet.MassFlow        m1 = new UnitsNet.MassFlow(4356, UnitsNet.Units.MassFlowUnit.PoundPerMinute);
            UnitsNet.Temperature     t2 = new UnitsNet.Temperature(342, UnitsNet.Units.TemperatureUnit.DegreeRankine);
            UnitsNet.Temperature     t1 = new UnitsNet.Temperature(43, UnitsNet.Units.TemperatureUnit.DegreeRankine);

            UnitsNet.Power q1 = UnitsNet.Power.FromWatts(p1.JoulesPerKilogramKelvin * m1.KilogramsPerSecond * (t2.Kelvins - t1.Kelvins));



            //BtuPerPoundFahrenheit-- > JoulePerKilogramKelvin
            //UnitsNet: 4186,8
            //EngineeringUnits: 4186,816458133984
            //UnitsNet dont not use a high precision for this conversion which gives a off result

            //Difference in procent
            Assert.AreEqual(0, HelperClass.Percent(P1.As(EngineeringUnits.SpecificEntropyUnit.JoulePerKilogramKelvin),
                                                   p1.As(UnitsNet.Units.SpecificEntropyUnit.JoulePerKilogramKelvin)), 0.0004);

            Assert.AreEqual(0, HelperClass.Percent(P1.As(EngineeringUnits.SpecificEntropyUnit.BtuPerPoundRankine),
                                                   p1.As(UnitsNet.Units.SpecificEntropyUnit.BtuPerPoundFahrenheit)), 0);

            Assert.AreEqual(0, HelperClass.Percent(M1.As(EngineeringUnits.MassFlowUnit.KilogramPerSecond),
                                                   m1.As(UnitsNet.Units.MassFlowUnit.KilogramPerSecond)), 0.0003);



            //Assert.AreEqual(0, Q1.As(EngineeringUnits.PowerUnit.BritishThermalUnitPerHour) - q1.As(UnitsNet.Units.PowerUnit.BritishThermalUnitPerHour), 0);
            //Assert.AreEqual(0, Q1.As(EngineeringUnits.PowerUnit.Kilowatt) - q1.As(UnitsNet.Units.PowerUnit.Kilowatt), 0);
            //Assert.AreEqual(0, Q1.As(EngineeringUnits.PowerUnit.Watt) - q1.As(UnitsNet.Units.PowerUnit.Watt), 0);

            //Difference in procent
            Assert.AreEqual(0, HelperClass.Percent(Q1.As(EngineeringUnits.PowerUnit.BritishThermalUnitPerHour),
                                                   q1.As(UnitsNet.Units.PowerUnit.BritishThermalUnitPerHour)), 0.0003);

            Assert.AreEqual(0, HelperClass.Percent(Q1.As(EngineeringUnits.PowerUnit.Kilowatt),
                                                   q1.As(UnitsNet.Units.PowerUnit.Kilowatt)), 0.00013);

            Assert.AreEqual(0, HelperClass.Percent(Q1.As(EngineeringUnits.PowerUnit.Watt),
                                                   q1.As(UnitsNet.Units.PowerUnit.Watt)), 0.00013);
        }
예제 #3
0
        PowerRatio(Power power)
            : this()
        {
            if (power.Watts <= 0)
                throw new ArgumentOutOfRangeException(
                    nameof(power), "The base-10 logarithm of a number ≤ 0 is undefined. Power must be greater than 0 W.");

            // P(dBW) = 10*log10(value(W)/reference(W))
            _decibelWatts = 10*Math.Log10(power.Watts/1);
        }
예제 #4
0
 /// <summary>
 ///     Gets a <see cref="PowerRatio" /> from a <see cref="Power" /> relative to one watt.
 /// </summary>
 /// <param name="power">The power relative to one watt.</param>
 public static PowerRatio FromPower(Power power)
 {
     return new PowerRatio(power);
 }
예제 #5
0
        /// <summary>
        /// Dynamically constructs a quantity of the given <see cref="QuantityType"/> with the value in the quantity's base units.
        /// </summary>
        /// <param name="quantityType">The <see cref="QuantityType"/> of the quantity to create.</param>
        /// <param name="value">The value to construct the quantity with.</param>
        /// <returns>The created quantity.</returns>
        public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value)
        {
            switch (quantityType)
            {
            case QuantityType.Acceleration:
                return(Acceleration.From(value, Acceleration.BaseUnit));

            case QuantityType.AmountOfSubstance:
                return(AmountOfSubstance.From(value, AmountOfSubstance.BaseUnit));

            case QuantityType.AmplitudeRatio:
                return(AmplitudeRatio.From(value, AmplitudeRatio.BaseUnit));

            case QuantityType.Angle:
                return(Angle.From(value, Angle.BaseUnit));

            case QuantityType.ApparentEnergy:
                return(ApparentEnergy.From(value, ApparentEnergy.BaseUnit));

            case QuantityType.ApparentPower:
                return(ApparentPower.From(value, ApparentPower.BaseUnit));

            case QuantityType.Area:
                return(Area.From(value, Area.BaseUnit));

            case QuantityType.AreaDensity:
                return(AreaDensity.From(value, AreaDensity.BaseUnit));

            case QuantityType.AreaMomentOfInertia:
                return(AreaMomentOfInertia.From(value, AreaMomentOfInertia.BaseUnit));

            case QuantityType.BitRate:
                return(BitRate.From(value, BitRate.BaseUnit));

            case QuantityType.BrakeSpecificFuelConsumption:
                return(BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.BaseUnit));

            case QuantityType.Capacitance:
                return(Capacitance.From(value, Capacitance.BaseUnit));

            case QuantityType.CoefficientOfThermalExpansion:
                return(CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.BaseUnit));

            case QuantityType.Density:
                return(Density.From(value, Density.BaseUnit));

            case QuantityType.Duration:
                return(Duration.From(value, Duration.BaseUnit));

            case QuantityType.DynamicViscosity:
                return(DynamicViscosity.From(value, DynamicViscosity.BaseUnit));

            case QuantityType.ElectricAdmittance:
                return(ElectricAdmittance.From(value, ElectricAdmittance.BaseUnit));

            case QuantityType.ElectricCharge:
                return(ElectricCharge.From(value, ElectricCharge.BaseUnit));

            case QuantityType.ElectricChargeDensity:
                return(ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit));

            case QuantityType.ElectricConductance:
                return(ElectricConductance.From(value, ElectricConductance.BaseUnit));

            case QuantityType.ElectricConductivity:
                return(ElectricConductivity.From(value, ElectricConductivity.BaseUnit));

            case QuantityType.ElectricCurrent:
                return(ElectricCurrent.From(value, ElectricCurrent.BaseUnit));

            case QuantityType.ElectricCurrentDensity:
                return(ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit));

            case QuantityType.ElectricCurrentGradient:
                return(ElectricCurrentGradient.From(value, ElectricCurrentGradient.BaseUnit));

            case QuantityType.ElectricField:
                return(ElectricField.From(value, ElectricField.BaseUnit));

            case QuantityType.ElectricInductance:
                return(ElectricInductance.From(value, ElectricInductance.BaseUnit));

            case QuantityType.ElectricPotential:
                return(ElectricPotential.From(value, ElectricPotential.BaseUnit));

            case QuantityType.ElectricPotentialAc:
                return(ElectricPotentialAc.From(value, ElectricPotentialAc.BaseUnit));

            case QuantityType.ElectricPotentialDc:
                return(ElectricPotentialDc.From(value, ElectricPotentialDc.BaseUnit));

            case QuantityType.ElectricResistance:
                return(ElectricResistance.From(value, ElectricResistance.BaseUnit));

            case QuantityType.ElectricResistivity:
                return(ElectricResistivity.From(value, ElectricResistivity.BaseUnit));

            case QuantityType.Energy:
                return(Energy.From(value, Energy.BaseUnit));

            case QuantityType.Entropy:
                return(Entropy.From(value, Entropy.BaseUnit));

            case QuantityType.Force:
                return(Force.From(value, Force.BaseUnit));

            case QuantityType.ForceChangeRate:
                return(ForceChangeRate.From(value, ForceChangeRate.BaseUnit));

            case QuantityType.ForcePerLength:
                return(ForcePerLength.From(value, ForcePerLength.BaseUnit));

            case QuantityType.Frequency:
                return(Frequency.From(value, Frequency.BaseUnit));

            case QuantityType.HeatFlux:
                return(HeatFlux.From(value, HeatFlux.BaseUnit));

            case QuantityType.HeatTransferCoefficient:
                return(HeatTransferCoefficient.From(value, HeatTransferCoefficient.BaseUnit));

            case QuantityType.Illuminance:
                return(Illuminance.From(value, Illuminance.BaseUnit));

            case QuantityType.Information:
                return(Information.From(value, Information.BaseUnit));

            case QuantityType.Irradiance:
                return(Irradiance.From(value, Irradiance.BaseUnit));

            case QuantityType.Irradiation:
                return(Irradiation.From(value, Irradiation.BaseUnit));

            case QuantityType.KinematicViscosity:
                return(KinematicViscosity.From(value, KinematicViscosity.BaseUnit));

            case QuantityType.LapseRate:
                return(LapseRate.From(value, LapseRate.BaseUnit));

            case QuantityType.Length:
                return(Length.From(value, Length.BaseUnit));

            case QuantityType.Level:
                return(Level.From(value, Level.BaseUnit));

            case QuantityType.LinearDensity:
                return(LinearDensity.From(value, LinearDensity.BaseUnit));

            case QuantityType.LuminousFlux:
                return(LuminousFlux.From(value, LuminousFlux.BaseUnit));

            case QuantityType.LuminousIntensity:
                return(LuminousIntensity.From(value, LuminousIntensity.BaseUnit));

            case QuantityType.MagneticField:
                return(MagneticField.From(value, MagneticField.BaseUnit));

            case QuantityType.MagneticFlux:
                return(MagneticFlux.From(value, MagneticFlux.BaseUnit));

            case QuantityType.Magnetization:
                return(Magnetization.From(value, Magnetization.BaseUnit));

            case QuantityType.Mass:
                return(Mass.From(value, Mass.BaseUnit));

            case QuantityType.MassFlow:
                return(MassFlow.From(value, MassFlow.BaseUnit));

            case QuantityType.MassFlux:
                return(MassFlux.From(value, MassFlux.BaseUnit));

            case QuantityType.MassMomentOfInertia:
                return(MassMomentOfInertia.From(value, MassMomentOfInertia.BaseUnit));

            case QuantityType.MolarEnergy:
                return(MolarEnergy.From(value, MolarEnergy.BaseUnit));

            case QuantityType.MolarEntropy:
                return(MolarEntropy.From(value, MolarEntropy.BaseUnit));

            case QuantityType.Molarity:
                return(Molarity.From(value, Molarity.BaseUnit));

            case QuantityType.MolarMass:
                return(MolarMass.From(value, MolarMass.BaseUnit));

            case QuantityType.Permeability:
                return(Permeability.From(value, Permeability.BaseUnit));

            case QuantityType.Permittivity:
                return(Permittivity.From(value, Permittivity.BaseUnit));

            case QuantityType.Power:
                return(Power.From(value, Power.BaseUnit));

            case QuantityType.PowerDensity:
                return(PowerDensity.From(value, PowerDensity.BaseUnit));

            case QuantityType.PowerRatio:
                return(PowerRatio.From(value, PowerRatio.BaseUnit));

            case QuantityType.Pressure:
                return(Pressure.From(value, Pressure.BaseUnit));

            case QuantityType.PressureChangeRate:
                return(PressureChangeRate.From(value, PressureChangeRate.BaseUnit));

            case QuantityType.Ratio:
                return(Ratio.From(value, Ratio.BaseUnit));

            case QuantityType.ReactiveEnergy:
                return(ReactiveEnergy.From(value, ReactiveEnergy.BaseUnit));

            case QuantityType.ReactivePower:
                return(ReactivePower.From(value, ReactivePower.BaseUnit));

            case QuantityType.RotationalAcceleration:
                return(RotationalAcceleration.From(value, RotationalAcceleration.BaseUnit));

            case QuantityType.RotationalSpeed:
                return(RotationalSpeed.From(value, RotationalSpeed.BaseUnit));

            case QuantityType.RotationalStiffness:
                return(RotationalStiffness.From(value, RotationalStiffness.BaseUnit));

            case QuantityType.RotationalStiffnessPerLength:
                return(RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.BaseUnit));

            case QuantityType.SolidAngle:
                return(SolidAngle.From(value, SolidAngle.BaseUnit));

            case QuantityType.SpecificEnergy:
                return(SpecificEnergy.From(value, SpecificEnergy.BaseUnit));

            case QuantityType.SpecificEntropy:
                return(SpecificEntropy.From(value, SpecificEntropy.BaseUnit));

            case QuantityType.SpecificVolume:
                return(SpecificVolume.From(value, SpecificVolume.BaseUnit));

            case QuantityType.SpecificWeight:
                return(SpecificWeight.From(value, SpecificWeight.BaseUnit));

            case QuantityType.Speed:
                return(Speed.From(value, Speed.BaseUnit));

            case QuantityType.Temperature:
                return(Temperature.From(value, Temperature.BaseUnit));

            case QuantityType.TemperatureChangeRate:
                return(TemperatureChangeRate.From(value, TemperatureChangeRate.BaseUnit));

            case QuantityType.TemperatureDelta:
                return(TemperatureDelta.From(value, TemperatureDelta.BaseUnit));

            case QuantityType.ThermalConductivity:
                return(ThermalConductivity.From(value, ThermalConductivity.BaseUnit));

            case QuantityType.ThermalResistance:
                return(ThermalResistance.From(value, ThermalResistance.BaseUnit));

            case QuantityType.Torque:
                return(Torque.From(value, Torque.BaseUnit));

            case QuantityType.VitaminA:
                return(VitaminA.From(value, VitaminA.BaseUnit));

            case QuantityType.Volume:
                return(Volume.From(value, Volume.BaseUnit));

            case QuantityType.VolumeFlow:
                return(VolumeFlow.From(value, VolumeFlow.BaseUnit));

            case QuantityType.VolumePerLength:
                return(VolumePerLength.From(value, VolumePerLength.BaseUnit));

            default:
                throw new ArgumentException($"{quantityType} is not a supported quantity type.");
            }
        }
예제 #6
0
        /// <summary>
        ///     Try to dynamically construct a quantity.
        /// </summary>
        /// <param name="value">Numeric value.</param>
        /// <param name="unit">Unit enum value.</param>
        /// <param name="quantity">The resulting quantity if successful, otherwise <c>default</c>.</param>
        /// <returns><c>True</c> if successful with <paramref name="quantity"/> assigned the value, otherwise <c>false</c>.</returns>
        public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity quantity)
        {
            switch (unit)
            {
            case AccelerationUnit accelerationUnit:
                quantity = Acceleration.From(value, accelerationUnit);
                return(true);

            case AmountOfSubstanceUnit amountOfSubstanceUnit:
                quantity = AmountOfSubstance.From(value, amountOfSubstanceUnit);
                return(true);

            case AmplitudeRatioUnit amplitudeRatioUnit:
                quantity = AmplitudeRatio.From(value, amplitudeRatioUnit);
                return(true);

            case AngleUnit angleUnit:
                quantity = Angle.From(value, angleUnit);
                return(true);

            case ApparentEnergyUnit apparentEnergyUnit:
                quantity = ApparentEnergy.From(value, apparentEnergyUnit);
                return(true);

            case ApparentPowerUnit apparentPowerUnit:
                quantity = ApparentPower.From(value, apparentPowerUnit);
                return(true);

            case AreaUnit areaUnit:
                quantity = Area.From(value, areaUnit);
                return(true);

            case AreaDensityUnit areaDensityUnit:
                quantity = AreaDensity.From(value, areaDensityUnit);
                return(true);

            case AreaMomentOfInertiaUnit areaMomentOfInertiaUnit:
                quantity = AreaMomentOfInertia.From(value, areaMomentOfInertiaUnit);
                return(true);

            case BitRateUnit bitRateUnit:
                quantity = BitRate.From(value, bitRateUnit);
                return(true);

            case BrakeSpecificFuelConsumptionUnit brakeSpecificFuelConsumptionUnit:
                quantity = BrakeSpecificFuelConsumption.From(value, brakeSpecificFuelConsumptionUnit);
                return(true);

            case CapacitanceUnit capacitanceUnit:
                quantity = Capacitance.From(value, capacitanceUnit);
                return(true);

            case CoefficientOfThermalExpansionUnit coefficientOfThermalExpansionUnit:
                quantity = CoefficientOfThermalExpansion.From(value, coefficientOfThermalExpansionUnit);
                return(true);

            case DensityUnit densityUnit:
                quantity = Density.From(value, densityUnit);
                return(true);

            case DurationUnit durationUnit:
                quantity = Duration.From(value, durationUnit);
                return(true);

            case DynamicViscosityUnit dynamicViscosityUnit:
                quantity = DynamicViscosity.From(value, dynamicViscosityUnit);
                return(true);

            case ElectricAdmittanceUnit electricAdmittanceUnit:
                quantity = ElectricAdmittance.From(value, electricAdmittanceUnit);
                return(true);

            case ElectricChargeUnit electricChargeUnit:
                quantity = ElectricCharge.From(value, electricChargeUnit);
                return(true);

            case ElectricChargeDensityUnit electricChargeDensityUnit:
                quantity = ElectricChargeDensity.From(value, electricChargeDensityUnit);
                return(true);

            case ElectricConductanceUnit electricConductanceUnit:
                quantity = ElectricConductance.From(value, electricConductanceUnit);
                return(true);

            case ElectricConductivityUnit electricConductivityUnit:
                quantity = ElectricConductivity.From(value, electricConductivityUnit);
                return(true);

            case ElectricCurrentUnit electricCurrentUnit:
                quantity = ElectricCurrent.From(value, electricCurrentUnit);
                return(true);

            case ElectricCurrentDensityUnit electricCurrentDensityUnit:
                quantity = ElectricCurrentDensity.From(value, electricCurrentDensityUnit);
                return(true);

            case ElectricCurrentGradientUnit electricCurrentGradientUnit:
                quantity = ElectricCurrentGradient.From(value, electricCurrentGradientUnit);
                return(true);

            case ElectricFieldUnit electricFieldUnit:
                quantity = ElectricField.From(value, electricFieldUnit);
                return(true);

            case ElectricInductanceUnit electricInductanceUnit:
                quantity = ElectricInductance.From(value, electricInductanceUnit);
                return(true);

            case ElectricPotentialUnit electricPotentialUnit:
                quantity = ElectricPotential.From(value, electricPotentialUnit);
                return(true);

            case ElectricPotentialAcUnit electricPotentialAcUnit:
                quantity = ElectricPotentialAc.From(value, electricPotentialAcUnit);
                return(true);

            case ElectricPotentialDcUnit electricPotentialDcUnit:
                quantity = ElectricPotentialDc.From(value, electricPotentialDcUnit);
                return(true);

            case ElectricResistanceUnit electricResistanceUnit:
                quantity = ElectricResistance.From(value, electricResistanceUnit);
                return(true);

            case ElectricResistivityUnit electricResistivityUnit:
                quantity = ElectricResistivity.From(value, electricResistivityUnit);
                return(true);

            case EnergyUnit energyUnit:
                quantity = Energy.From(value, energyUnit);
                return(true);

            case EntropyUnit entropyUnit:
                quantity = Entropy.From(value, entropyUnit);
                return(true);

            case ForceUnit forceUnit:
                quantity = Force.From(value, forceUnit);
                return(true);

            case ForceChangeRateUnit forceChangeRateUnit:
                quantity = ForceChangeRate.From(value, forceChangeRateUnit);
                return(true);

            case ForcePerLengthUnit forcePerLengthUnit:
                quantity = ForcePerLength.From(value, forcePerLengthUnit);
                return(true);

            case FrequencyUnit frequencyUnit:
                quantity = Frequency.From(value, frequencyUnit);
                return(true);

            case HeatFluxUnit heatFluxUnit:
                quantity = HeatFlux.From(value, heatFluxUnit);
                return(true);

            case HeatTransferCoefficientUnit heatTransferCoefficientUnit:
                quantity = HeatTransferCoefficient.From(value, heatTransferCoefficientUnit);
                return(true);

            case IlluminanceUnit illuminanceUnit:
                quantity = Illuminance.From(value, illuminanceUnit);
                return(true);

            case InformationUnit informationUnit:
                quantity = Information.From(value, informationUnit);
                return(true);

            case IrradianceUnit irradianceUnit:
                quantity = Irradiance.From(value, irradianceUnit);
                return(true);

            case IrradiationUnit irradiationUnit:
                quantity = Irradiation.From(value, irradiationUnit);
                return(true);

            case KinematicViscosityUnit kinematicViscosityUnit:
                quantity = KinematicViscosity.From(value, kinematicViscosityUnit);
                return(true);

            case LapseRateUnit lapseRateUnit:
                quantity = LapseRate.From(value, lapseRateUnit);
                return(true);

            case LengthUnit lengthUnit:
                quantity = Length.From(value, lengthUnit);
                return(true);

            case LevelUnit levelUnit:
                quantity = Level.From(value, levelUnit);
                return(true);

            case LinearDensityUnit linearDensityUnit:
                quantity = LinearDensity.From(value, linearDensityUnit);
                return(true);

            case LuminousFluxUnit luminousFluxUnit:
                quantity = LuminousFlux.From(value, luminousFluxUnit);
                return(true);

            case LuminousIntensityUnit luminousIntensityUnit:
                quantity = LuminousIntensity.From(value, luminousIntensityUnit);
                return(true);

            case MagneticFieldUnit magneticFieldUnit:
                quantity = MagneticField.From(value, magneticFieldUnit);
                return(true);

            case MagneticFluxUnit magneticFluxUnit:
                quantity = MagneticFlux.From(value, magneticFluxUnit);
                return(true);

            case MagnetizationUnit magnetizationUnit:
                quantity = Magnetization.From(value, magnetizationUnit);
                return(true);

            case MassUnit massUnit:
                quantity = Mass.From(value, massUnit);
                return(true);

            case MassFlowUnit massFlowUnit:
                quantity = MassFlow.From(value, massFlowUnit);
                return(true);

            case MassFluxUnit massFluxUnit:
                quantity = MassFlux.From(value, massFluxUnit);
                return(true);

            case MassMomentOfInertiaUnit massMomentOfInertiaUnit:
                quantity = MassMomentOfInertia.From(value, massMomentOfInertiaUnit);
                return(true);

            case MolarEnergyUnit molarEnergyUnit:
                quantity = MolarEnergy.From(value, molarEnergyUnit);
                return(true);

            case MolarEntropyUnit molarEntropyUnit:
                quantity = MolarEntropy.From(value, molarEntropyUnit);
                return(true);

            case MolarityUnit molarityUnit:
                quantity = Molarity.From(value, molarityUnit);
                return(true);

            case MolarMassUnit molarMassUnit:
                quantity = MolarMass.From(value, molarMassUnit);
                return(true);

            case PermeabilityUnit permeabilityUnit:
                quantity = Permeability.From(value, permeabilityUnit);
                return(true);

            case PermittivityUnit permittivityUnit:
                quantity = Permittivity.From(value, permittivityUnit);
                return(true);

            case PowerUnit powerUnit:
                quantity = Power.From(value, powerUnit);
                return(true);

            case PowerDensityUnit powerDensityUnit:
                quantity = PowerDensity.From(value, powerDensityUnit);
                return(true);

            case PowerRatioUnit powerRatioUnit:
                quantity = PowerRatio.From(value, powerRatioUnit);
                return(true);

            case PressureUnit pressureUnit:
                quantity = Pressure.From(value, pressureUnit);
                return(true);

            case PressureChangeRateUnit pressureChangeRateUnit:
                quantity = PressureChangeRate.From(value, pressureChangeRateUnit);
                return(true);

            case RatioUnit ratioUnit:
                quantity = Ratio.From(value, ratioUnit);
                return(true);

            case ReactiveEnergyUnit reactiveEnergyUnit:
                quantity = ReactiveEnergy.From(value, reactiveEnergyUnit);
                return(true);

            case ReactivePowerUnit reactivePowerUnit:
                quantity = ReactivePower.From(value, reactivePowerUnit);
                return(true);

            case RotationalAccelerationUnit rotationalAccelerationUnit:
                quantity = RotationalAcceleration.From(value, rotationalAccelerationUnit);
                return(true);

            case RotationalSpeedUnit rotationalSpeedUnit:
                quantity = RotationalSpeed.From(value, rotationalSpeedUnit);
                return(true);

            case RotationalStiffnessUnit rotationalStiffnessUnit:
                quantity = RotationalStiffness.From(value, rotationalStiffnessUnit);
                return(true);

            case RotationalStiffnessPerLengthUnit rotationalStiffnessPerLengthUnit:
                quantity = RotationalStiffnessPerLength.From(value, rotationalStiffnessPerLengthUnit);
                return(true);

            case SolidAngleUnit solidAngleUnit:
                quantity = SolidAngle.From(value, solidAngleUnit);
                return(true);

            case SpecificEnergyUnit specificEnergyUnit:
                quantity = SpecificEnergy.From(value, specificEnergyUnit);
                return(true);

            case SpecificEntropyUnit specificEntropyUnit:
                quantity = SpecificEntropy.From(value, specificEntropyUnit);
                return(true);

            case SpecificVolumeUnit specificVolumeUnit:
                quantity = SpecificVolume.From(value, specificVolumeUnit);
                return(true);

            case SpecificWeightUnit specificWeightUnit:
                quantity = SpecificWeight.From(value, specificWeightUnit);
                return(true);

            case SpeedUnit speedUnit:
                quantity = Speed.From(value, speedUnit);
                return(true);

            case TemperatureUnit temperatureUnit:
                quantity = Temperature.From(value, temperatureUnit);
                return(true);

            case TemperatureChangeRateUnit temperatureChangeRateUnit:
                quantity = TemperatureChangeRate.From(value, temperatureChangeRateUnit);
                return(true);

            case TemperatureDeltaUnit temperatureDeltaUnit:
                quantity = TemperatureDelta.From(value, temperatureDeltaUnit);
                return(true);

            case ThermalConductivityUnit thermalConductivityUnit:
                quantity = ThermalConductivity.From(value, thermalConductivityUnit);
                return(true);

            case ThermalResistanceUnit thermalResistanceUnit:
                quantity = ThermalResistance.From(value, thermalResistanceUnit);
                return(true);

            case TorqueUnit torqueUnit:
                quantity = Torque.From(value, torqueUnit);
                return(true);

            case VitaminAUnit vitaminAUnit:
                quantity = VitaminA.From(value, vitaminAUnit);
                return(true);

            case VolumeUnit volumeUnit:
                quantity = Volume.From(value, volumeUnit);
                return(true);

            case VolumeFlowUnit volumeFlowUnit:
                quantity = VolumeFlow.From(value, volumeFlowUnit);
                return(true);

            case VolumePerLengthUnit volumePerLengthUnit:
                quantity = VolumePerLength.From(value, volumePerLengthUnit);
                return(true);

            default:
            {
                quantity = default(IQuantity);
                return(false);
            }
            }
        }
예제 #7
0
 /// <summary>
 ///     Gets a <see cref="Power" /> from a <see cref="PowerRatio" /> (which is a power level relative to one watt).
 /// </summary>
 /// <param name="powerRatio">The power level relative to one watt.</param>
 public static Power ToPower(PowerRatio powerRatio)
 {
     // P(W) = 1W * 10^(P(dBW)/10)
     return(Power.FromWatts(Math.Pow(10, powerRatio._decibelWatts / 10)));
 }
예제 #8
0
 /// <summary>
 ///     Gets a <see cref="PowerRatio" /> from a <see cref="Power" /> relative to one watt.
 /// </summary>
 /// <param name="power">The power relative to one watt.</param>
 public static PowerRatio FromPower(Power power)
 {
     return(new PowerRatio(power));
 }