Example #1
0
            public void GetAngularVelocity()
            {
                Mass     massSM          = Mass.FromEarthMasses(1.0);
                Length   radiusKM        = Length.FromKilometers(10000.0);
                Density  densityGCC      = Density.FromGramsPerCubicCentimeter(2.0);
                Length   semiMajorAxisAU = Length.FromAstronomicalUnits(1.0);
                bool     isGasGiant      = false;
                Mass     largeMassSM     = Mass.FromSolarMasses(1.0);
                Duration largeAgeYears   = Duration.FromYears365(1e10);

                Assert.AreEqual(Env.AngularVelocity(massSM.SolarMasses,
                                                    radiusKM.Kilometers,
                                                    densityGCC.GramsPerCubicCentimeter,
                                                    semiMajorAxisAU.AstronomicalUnits,
                                                    isGasGiant,
                                                    largeMassSM.SolarMasses,
                                                    largeAgeYears.Years365),
                                _phy.Dynamics.GetAngularVelocity(massSM,
                                                                 radiusKM,
                                                                 densityGCC,
                                                                 semiMajorAxisAU,
                                                                 isGasGiant,
                                                                 largeMassSM,
                                                                 largeAgeYears).RadiansPerSecond,
                                LowDelta);
            }
Example #2
0
        public void ConversionRoundTrip()
        {
            Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);

            AssertEx.EqualTolerance(1, Density.FromDecigramsPerDeciLiter(kilogrampercubicmeter.DecigramsPerDeciLiter).KilogramsPerCubicMeter, DecigramsPerDeciLiterTolerance);
            AssertEx.EqualTolerance(1, Density.FromDecigramsPerLiter(kilogrampercubicmeter.DecigramsPerLiter).KilogramsPerCubicMeter, DecigramsPerLiterTolerance);
            AssertEx.EqualTolerance(1, Density.FromDecigramsPerMilliliter(kilogrampercubicmeter.DecigramsPerMilliliter).KilogramsPerCubicMeter, DecigramsPerMilliliterTolerance);
            AssertEx.EqualTolerance(1, Density.FromGramsPerCubicCentimeter(kilogrampercubicmeter.GramsPerCubicCentimeter).KilogramsPerCubicMeter, GramsPerCubicCentimeterTolerance);
            AssertEx.EqualTolerance(1, Density.FromGramsPerCubicMeter(kilogrampercubicmeter.GramsPerCubicMeter).KilogramsPerCubicMeter, GramsPerCubicMeterTolerance);
            AssertEx.EqualTolerance(1, Density.FromGramsPerCubicMillimeter(kilogrampercubicmeter.GramsPerCubicMillimeter).KilogramsPerCubicMeter, GramsPerCubicMillimeterTolerance);
            AssertEx.EqualTolerance(1, Density.FromGramsPerDeciLiter(kilogrampercubicmeter.GramsPerDeciLiter).KilogramsPerCubicMeter, GramsPerDeciLiterTolerance);
            AssertEx.EqualTolerance(1, Density.FromGramsPerLiter(kilogrampercubicmeter.GramsPerLiter).KilogramsPerCubicMeter, GramsPerLiterTolerance);
            AssertEx.EqualTolerance(1, Density.FromGramsPerMilliliter(kilogrampercubicmeter.GramsPerMilliliter).KilogramsPerCubicMeter, GramsPerMilliliterTolerance);
            AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicCentimeter(kilogrampercubicmeter.KilogramsPerCubicCentimeter).KilogramsPerCubicMeter, KilogramsPerCubicCentimeterTolerance);
            AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicMeter(kilogrampercubicmeter.KilogramsPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
            AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicMillimeter(kilogrampercubicmeter.KilogramsPerCubicMillimeter).KilogramsPerCubicMeter, KilogramsPerCubicMillimeterTolerance);
            AssertEx.EqualTolerance(1, Density.FromKilopoundsPerCubicFoot(kilogrampercubicmeter.KilopoundsPerCubicFoot).KilogramsPerCubicMeter, KilopoundsPerCubicFootTolerance);
            AssertEx.EqualTolerance(1, Density.FromKilopoundsPerCubicInch(kilogrampercubicmeter.KilopoundsPerCubicInch).KilogramsPerCubicMeter, KilopoundsPerCubicInchTolerance);
            AssertEx.EqualTolerance(1, Density.FromMilligramsPerCubicMeter(kilogrampercubicmeter.MilligramsPerCubicMeter).KilogramsPerCubicMeter, MilligramsPerCubicMeterTolerance);
            AssertEx.EqualTolerance(1, Density.FromMilligramsPerDeciLiter(kilogrampercubicmeter.MilligramsPerDeciLiter).KilogramsPerCubicMeter, MilligramsPerDeciLiterTolerance);
            AssertEx.EqualTolerance(1, Density.FromMilligramsPerLiter(kilogrampercubicmeter.MilligramsPerLiter).KilogramsPerCubicMeter, MilligramsPerLiterTolerance);
            AssertEx.EqualTolerance(1, Density.FromMilligramsPerMilliliter(kilogrampercubicmeter.MilligramsPerMilliliter).KilogramsPerCubicMeter, MilligramsPerMilliliterTolerance);
            AssertEx.EqualTolerance(1, Density.FromPoundsPerCubicFoot(kilogrampercubicmeter.PoundsPerCubicFoot).KilogramsPerCubicMeter, PoundsPerCubicFootTolerance);
            AssertEx.EqualTolerance(1, Density.FromPoundsPerCubicInch(kilogrampercubicmeter.PoundsPerCubicInch).KilogramsPerCubicMeter, PoundsPerCubicInchTolerance);
            AssertEx.EqualTolerance(1, Density.FromPoundsPerImperialGallon(kilogrampercubicmeter.PoundsPerImperialGallon).KilogramsPerCubicMeter, PoundsPerImperialGallonTolerance);
            AssertEx.EqualTolerance(1, Density.FromPoundsPerUSGallon(kilogrampercubicmeter.PoundsPerUSGallon).KilogramsPerCubicMeter, PoundsPerUSGallonTolerance);
            AssertEx.EqualTolerance(1, Density.FromSlugsPerCubicFoot(kilogrampercubicmeter.SlugsPerCubicFoot).KilogramsPerCubicMeter, SlugsPerCubicFootTolerance);
            AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicCentimeter(kilogrampercubicmeter.TonnesPerCubicCentimeter).KilogramsPerCubicMeter, TonnesPerCubicCentimeterTolerance);
            AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicMeter(kilogrampercubicmeter.TonnesPerCubicMeter).KilogramsPerCubicMeter, TonnesPerCubicMeterTolerance);
            AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicMillimeter(kilogrampercubicmeter.TonnesPerCubicMillimeter).KilogramsPerCubicMeter, TonnesPerCubicMillimeterTolerance);
        }
        /// <summary>
        /// Density given a Volume and a Mass.
        /// </summary>
        /// <param name="mass">Mass in units of solar masses</param>
        /// <param name="equatRadius">Equatorial radius in km</param>
        /// <returns>Units of grams/cc</returns>
        public static Density GetDensityFromVolume(Mass m, Length r)
        {
            double mass        = m.Grams;
            double equatRadius = r.Centimeters;
            double volume      = (4.0 * Math.PI * Extensions.Pow3(equatRadius)) / 3.0;

            return(Density.FromGramsPerCubicCentimeter(mass / volume));
        }
        public virtual Density GetDensityFromBody(Mass massSM,
                                                  Length radius)
        {
            //return Environment.VolumeDensity(massSM, radius);

            var    mass        = massSM.SolarMasses * GlobalConstants.SOLAR_MASS_IN_GRAMS;
            var    equatRadius = radius.Kilometers * GlobalConstants.CM_PER_KM;
            double volume      = (4.0 * Math.PI * Extensions.Pow3(equatRadius)) / 3.0;

            return(Density.FromGramsPerCubicCentimeter(mass / volume));
        }
Example #5
0
        }                                            // Max inspired partial pressure im millibars

        /// <summary>
        /// Initializes a new instance of the <see cref="Chemical"/> class.
        /// </summary>
        /// <param name="an">An.</param>
        /// <param name="sym">The sym.</param>
        /// <param name="htmlsym">The htmlsym.</param>
        /// <param name="name">The name.</param>
        /// <param name="w">The w.</param>
        /// <param name="m">The m.</param>
        /// <param name="b">The b.</param>
        /// <param name="dens">The dens.</param>
        /// <param name="ae">The ae.</param>
        /// <param name="abs">The abs.</param>
        /// <param name="rea">The rea.</param>
        /// <param name="mipp">The mipp.</param>
        public Chemical(int an, string sym, string htmlsym, string name, double w, double m, double b, double dens, double ae, double abs, double rea, double mipp)
        {
            Num           = an;
            Symbol        = sym;
            DisplaySymbol = htmlsym;
            Name          = name;
            Weight        = Mass.FromGrams(w);
            Melt          = Temperature.FromKelvins(m);
            Boil          = Temperature.FromKelvins(b);
            Density       = Density.FromGramsPerCubicCentimeter(dens);
            Abunde        = Ratio.FromDecimalFractions(ae);
            Abunds        = Ratio.FromDecimalFractions(abs);
            Reactivity    = Ratio.FromDecimalFractions(rea);
            MaxIpp        = Pressure.FromMillibars(mipp);
        }
Example #6
0
        public void ConversionRoundTrip()
        {
            Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);

            Assert.AreEqual(1, Density.FromGramsPerCubicCentimeter(kilogrampercubicmeter.GramsPerCubicCentimeter).KilogramsPerCubicMeter, GramsPerCubicCentimeterTolerance);
            Assert.AreEqual(1, Density.FromGramsPerCubicMeter(kilogrampercubicmeter.GramsPerCubicMeter).KilogramsPerCubicMeter, GramsPerCubicMeterTolerance);
            Assert.AreEqual(1, Density.FromGramsPerCubicMillimeter(kilogrampercubicmeter.GramsPerCubicMillimeter).KilogramsPerCubicMeter, GramsPerCubicMillimeterTolerance);
            Assert.AreEqual(1, Density.FromKilogramsPerCubicCentimeter(kilogrampercubicmeter.KilogramsPerCubicCentimeter).KilogramsPerCubicMeter, KilogramsPerCubicCentimeterTolerance);
            Assert.AreEqual(1, Density.FromKilogramsPerCubicMeter(kilogrampercubicmeter.KilogramsPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
            Assert.AreEqual(1, Density.FromKilogramsPerCubicMillimeter(kilogrampercubicmeter.KilogramsPerCubicMillimeter).KilogramsPerCubicMeter, KilogramsPerCubicMillimeterTolerance);
            Assert.AreEqual(1, Density.FromKilopoundsPerCubicFoot(kilogrampercubicmeter.KilopoundsPerCubicFoot).KilogramsPerCubicMeter, KilopoundsPerCubicFootTolerance);
            Assert.AreEqual(1, Density.FromKilopoundsPerCubicInch(kilogrampercubicmeter.KilopoundsPerCubicInch).KilogramsPerCubicMeter, KilopoundsPerCubicInchTolerance);
            Assert.AreEqual(1, Density.FromPoundsPerCubicFoot(kilogrampercubicmeter.PoundsPerCubicFoot).KilogramsPerCubicMeter, PoundsPerCubicFootTolerance);
            Assert.AreEqual(1, Density.FromPoundsPerCubicInch(kilogrampercubicmeter.PoundsPerCubicInch).KilogramsPerCubicMeter, PoundsPerCubicInchTolerance);
            Assert.AreEqual(1, Density.FromTonnesPerCubicCentimeter(kilogrampercubicmeter.TonnesPerCubicCentimeter).KilogramsPerCubicMeter, TonnesPerCubicCentimeterTolerance);
            Assert.AreEqual(1, Density.FromTonnesPerCubicMeter(kilogrampercubicmeter.TonnesPerCubicMeter).KilogramsPerCubicMeter, TonnesPerCubicMeterTolerance);
            Assert.AreEqual(1, Density.FromTonnesPerCubicMillimeter(kilogrampercubicmeter.TonnesPerCubicMillimeter).KilogramsPerCubicMeter, TonnesPerCubicMillimeterTolerance);
        }
        public virtual Density GetDensityFromStar(Mass massSM,
                                                  Length semiMajorAxisAU,
                                                  Length ecosphereRadiusAU,
                                                  bool isGasGiant)
        {
            double density = Math.Pow(massSM.SolarMasses * GlobalConstants.SUN_MASS_IN_EARTH_MASSES, 1.0 / 8.0);

            density *= Extensions.Pow1_4(ecosphereRadiusAU / semiMajorAxisAU);

            if (isGasGiant)
            {
                return(Density.FromGramsPerCubicCentimeter(density * 1.2));
            }
            else
            {
                return(Density.FromGramsPerCubicCentimeter(density * 5.5));
            }
        }
Example #8
0
            public void GetChangeInAngularVelocity()
            {
                Density densityGCC      = Density.FromGramsPerCubicCentimeter(2.5);
                Mass    massSM          = Mass.FromEarthMasses(0.75);
                Length  radiusKM        = Length.FromKilometers(2500.0);
                Length  semiMajorAxisAU = Length.FromAstronomicalUnits(1.4);
                Mass    largeMassSM     = Mass.FromSolarMasses(1.5);

                Assert.AreEqual(Env.ChangeInAngularVelocity(densityGCC.GramsPerCubicCentimeter,
                                                            massSM.SolarMasses,
                                                            radiusKM.Kilometers,
                                                            semiMajorAxisAU.AstronomicalUnits,
                                                            largeMassSM.SolarMasses),
                                _phy.Dynamics.GetChangeInAngularVelocity(densityGCC,
                                                                         massSM,
                                                                         radiusKM,
                                                                         semiMajorAxisAU,
                                                                         largeMassSM).RadiansPerSecond,
                                LowDelta);
            }
Example #9
0
        public void ConversionRoundTrip()
        {
            Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);

            Assert.AreEqual(1, Density.FromCentigramsPerDeciLiter(kilogrampercubicmeter.CentigramsPerDeciLiter).KilogramsPerCubicMeter, CentigramsPerDeciLiterTolerance);
            Assert.AreEqual(1, Density.FromCentigramsPerLiter(kilogrampercubicmeter.CentigramsPerLiter).KilogramsPerCubicMeter, CentigramsPerLiterTolerance);
            Assert.AreEqual(1, Density.FromCentigramsPerMilliliter(kilogrampercubicmeter.CentigramsPerMilliliter).KilogramsPerCubicMeter, CentigramsPerMilliliterTolerance);
            Assert.AreEqual(1, Density.FromDecigramsPerDeciLiter(kilogrampercubicmeter.DecigramsPerDeciLiter).KilogramsPerCubicMeter, DecigramsPerDeciLiterTolerance);
            Assert.AreEqual(1, Density.FromDecigramsPerLiter(kilogrampercubicmeter.DecigramsPerLiter).KilogramsPerCubicMeter, DecigramsPerLiterTolerance);
            Assert.AreEqual(1, Density.FromDecigramsPerMilliliter(kilogrampercubicmeter.DecigramsPerMilliliter).KilogramsPerCubicMeter, DecigramsPerMilliliterTolerance);
            Assert.AreEqual(1, Density.FromGramsPerCubicCentimeter(kilogrampercubicmeter.GramsPerCubicCentimeter).KilogramsPerCubicMeter, GramsPerCubicCentimeterTolerance);
            Assert.AreEqual(1, Density.FromGramsPerCubicMeter(kilogrampercubicmeter.GramsPerCubicMeter).KilogramsPerCubicMeter, GramsPerCubicMeterTolerance);
            Assert.AreEqual(1, Density.FromGramsPerCubicMillimeter(kilogrampercubicmeter.GramsPerCubicMillimeter).KilogramsPerCubicMeter, GramsPerCubicMillimeterTolerance);
            Assert.AreEqual(1, Density.FromGramsPerDeciLiter(kilogrampercubicmeter.GramsPerDeciLiter).KilogramsPerCubicMeter, GramsPerDeciLiterTolerance);
            Assert.AreEqual(1, Density.FromGramsPerLiter(kilogrampercubicmeter.GramsPerLiter).KilogramsPerCubicMeter, GramsPerLiterTolerance);
            Assert.AreEqual(1, Density.FromGramsPerMilliliter(kilogrampercubicmeter.GramsPerMilliliter).KilogramsPerCubicMeter, GramsPerMilliliterTolerance);
            Assert.AreEqual(1, Density.FromKilogramsPerCubicCentimeter(kilogrampercubicmeter.KilogramsPerCubicCentimeter).KilogramsPerCubicMeter, KilogramsPerCubicCentimeterTolerance);
            Assert.AreEqual(1, Density.FromKilogramsPerCubicMeter(kilogrampercubicmeter.KilogramsPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
            Assert.AreEqual(1, Density.FromKilogramsPerCubicMillimeter(kilogrampercubicmeter.KilogramsPerCubicMillimeter).KilogramsPerCubicMeter, KilogramsPerCubicMillimeterTolerance);
            Assert.AreEqual(1, Density.FromKilopoundsPerCubicFoot(kilogrampercubicmeter.KilopoundsPerCubicFoot).KilogramsPerCubicMeter, KilopoundsPerCubicFootTolerance);
            Assert.AreEqual(1, Density.FromKilopoundsPerCubicInch(kilogrampercubicmeter.KilopoundsPerCubicInch).KilogramsPerCubicMeter, KilopoundsPerCubicInchTolerance);
            Assert.AreEqual(1, Density.FromMicrogramsPerDeciLiter(kilogrampercubicmeter.MicrogramsPerDeciLiter).KilogramsPerCubicMeter, MicrogramsPerDeciLiterTolerance);
            Assert.AreEqual(1, Density.FromMicrogramsPerLiter(kilogrampercubicmeter.MicrogramsPerLiter).KilogramsPerCubicMeter, MicrogramsPerLiterTolerance);
            Assert.AreEqual(1, Density.FromMicrogramsPerMilliliter(kilogrampercubicmeter.MicrogramsPerMilliliter).KilogramsPerCubicMeter, MicrogramsPerMilliliterTolerance);
            Assert.AreEqual(1, Density.FromMilligramsPerDeciLiter(kilogrampercubicmeter.MilligramsPerDeciLiter).KilogramsPerCubicMeter, MilligramsPerDeciLiterTolerance);
            Assert.AreEqual(1, Density.FromMilligramsPerLiter(kilogrampercubicmeter.MilligramsPerLiter).KilogramsPerCubicMeter, MilligramsPerLiterTolerance);
            Assert.AreEqual(1, Density.FromMilligramsPerMilliliter(kilogrampercubicmeter.MilligramsPerMilliliter).KilogramsPerCubicMeter, MilligramsPerMilliliterTolerance);
            Assert.AreEqual(1, Density.FromNanogramsPerDeciLiter(kilogrampercubicmeter.NanogramsPerDeciLiter).KilogramsPerCubicMeter, NanogramsPerDeciLiterTolerance);
            Assert.AreEqual(1, Density.FromNanogramsPerLiter(kilogrampercubicmeter.NanogramsPerLiter).KilogramsPerCubicMeter, NanogramsPerLiterTolerance);
            Assert.AreEqual(1, Density.FromNanogramsPerMilliliter(kilogrampercubicmeter.NanogramsPerMilliliter).KilogramsPerCubicMeter, NanogramsPerMilliliterTolerance);
            Assert.AreEqual(1, Density.FromPicogramsPerDeciLiter(kilogrampercubicmeter.PicogramsPerDeciLiter).KilogramsPerCubicMeter, PicogramsPerDeciLiterTolerance);
            Assert.AreEqual(1, Density.FromPicogramsPerLiter(kilogrampercubicmeter.PicogramsPerLiter).KilogramsPerCubicMeter, PicogramsPerLiterTolerance);
            Assert.AreEqual(1, Density.FromPicogramsPerMilliliter(kilogrampercubicmeter.PicogramsPerMilliliter).KilogramsPerCubicMeter, PicogramsPerMilliliterTolerance);
            Assert.AreEqual(1, Density.FromPoundsPerCubicFoot(kilogrampercubicmeter.PoundsPerCubicFoot).KilogramsPerCubicMeter, PoundsPerCubicFootTolerance);
            Assert.AreEqual(1, Density.FromPoundsPerCubicInch(kilogrampercubicmeter.PoundsPerCubicInch).KilogramsPerCubicMeter, PoundsPerCubicInchTolerance);
            Assert.AreEqual(1, Density.FromSlugsPerCubicFoot(kilogrampercubicmeter.SlugsPerCubicFoot).KilogramsPerCubicMeter, SlugsPerCubicFootTolerance);
            Assert.AreEqual(1, Density.FromTonnesPerCubicCentimeter(kilogrampercubicmeter.TonnesPerCubicCentimeter).KilogramsPerCubicMeter, TonnesPerCubicCentimeterTolerance);
            Assert.AreEqual(1, Density.FromTonnesPerCubicMeter(kilogrampercubicmeter.TonnesPerCubicMeter).KilogramsPerCubicMeter, TonnesPerCubicMeterTolerance);
            Assert.AreEqual(1, Density.FromTonnesPerCubicMillimeter(kilogrampercubicmeter.TonnesPerCubicMillimeter).KilogramsPerCubicMeter, TonnesPerCubicMillimeterTolerance);
        }
Example #10
0
        public void AreaTimesDensityEqualsLinearDensity()
        {
            LinearDensity linearDensity = Area.FromSquareCentimeters(2) * Density.FromGramsPerCubicCentimeter(10);

            Assert.Equal(LinearDensity.FromGramsPerCentimeter(20), linearDensity);
        }
Example #11
0
 public static Density GramsPerCubicCentimeter <T>(this T value) =>
 Density.FromGramsPerCubicCentimeter(Convert.ToDouble(value));
 public static Density?GramsPerCubicCentimeter <T>(this T?value) where T : struct => Density.FromGramsPerCubicCentimeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
Example #13
0
        public void DensityTimesAreaEqualsLinearDensity()
        {
            LinearDensity linearDensity = Density.FromGramsPerCubicCentimeter(10) * Area.FromSquareCentimeters(2);

            Assert.Equal(LinearDensity.FromGramsPerCentimeter(20), linearDensity);
        }
 /// <inheritdoc cref="Density.FromGramsPerCubicCentimeter(double?)"/>
 public static Density?GramsPerCubicCentimeter(this decimal?value) => Density.FromGramsPerCubicCentimeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
 /// <inheritdoc cref="Density.FromGramsPerCubicCentimeter(double?)"/>
 public static Density?GramsPerCubicCentimeter(this float?value) => Density.FromGramsPerCubicCentimeter(value);
 /// <inheritdoc cref="Density.FromGramsPerCubicCentimeter(double)"/>
 public static Density GramsPerCubicCentimeter(this double value) => Density.FromGramsPerCubicCentimeter(value);
Example #17
0
        public void LinearDensityDividedByDensityEqualsArea()
        {
            Area area = LinearDensity.FromGramsPerCentimeter(10) / Density.FromGramsPerCubicCentimeter(2);

            Assert.Equal(Area.FromSquareCentimeters(5), area);
        }
Example #18
0
        public void LinearDensityDividedByAreaEqualsDensity()
        {
            Density density = LinearDensity.FromGramsPerCentimeter(10) / Area.FromSquareCentimeters(2);

            Assert.Equal(Density.FromGramsPerCubicCentimeter(5), density);
        }
 public void NumberToGramsPerCubicCentimeterTest() =>
 Assert.Equal(Density.FromGramsPerCubicCentimeter(2), 2.GramsPerCubicCentimeter());