Exemple #1
0
        public override void Given()
        {
            this.System = UnitSystemFactory.CreateSystem("SI");

            //Base units
            this.m   = this.System.AddBaseUnit("m", "metre");
            this.kg  = this.System.AddBaseUnit("kg", "kilogram", true);
            this.s   = this.System.AddBaseUnit("s", "second");
            this.A   = this.System.AddBaseUnit("A", "ampere");
            this.K   = this.System.AddBaseUnit("K", "kelvin");
            this.mol = this.System.AddBaseUnit("mol", "mole");
            this.cd  = this.System.AddBaseUnit("cd", "candela");

            //Derived units
            this.Hz  = this.System.AddDerivedUnit("Hz", "hertz", s ^ -1);
            this.N   = this.System.AddDerivedUnit("N", "newton", kg * m * (s ^ -2));
            this.Pa  = this.System.AddDerivedUnit("Pa", "pascal", N * (m ^ -2));
            this.J   = this.System.AddDerivedUnit("J", "joule", N * m);
            this.W   = this.System.AddDerivedUnit("W", "watt", J / s);
            this.C   = this.System.AddDerivedUnit("C", "coulomb", s * A);
            this.V   = this.System.AddDerivedUnit("V", "volt", W / A);
            this.F   = this.System.AddDerivedUnit("F", "farad", C / V);
            this.Ω   = this.System.AddDerivedUnit("Ω", "joule", V / A);
            this.S   = this.System.AddDerivedUnit("S", "siemens", A / V);
            this.Wb  = this.System.AddDerivedUnit("Wb", "weber", V * s);
            this.T   = this.System.AddDerivedUnit("T", "tesla", Wb * (s ^ -2));
            this.H   = this.System.AddDerivedUnit("H", "inductance", Wb / A);
            this.lx  = this.System.AddDerivedUnit("lx", "immulinance", (m ^ -2) * cd);
            this.Sv  = this.System.AddDerivedUnit("Sv", "sievert", J / kg);
            this.kat = this.System.AddDerivedUnit("kat", "katal", (s ^ -1) * mol);

            //Incoherent units
            this.h = this.System.AddDerivedUnit("h", "hour", 60 * 60 * s);
        }
Exemple #2
0
        static SI()
        {
            System = UnitSystemFactory.CreateSystem("SI");

            //Base units
            m   = System.AddBaseUnit("m", "metre");
            kg  = System.AddBaseUnit("kg", "kilogram", true);
            s   = System.AddBaseUnit("s", "second");
            A   = System.AddBaseUnit("A", "ampere");
            K   = System.AddBaseUnit("K", "kelvin");
            mol = System.AddBaseUnit("mol", "mole");
            cd  = System.AddBaseUnit("cd", "candela");

            //Derived units
            Hz  = System.AddDerivedUnit("Hz", "hertz", s ^ -1);
            N   = System.AddDerivedUnit("N", "newton", kg * m * (s ^ -2));
            Pa  = System.AddDerivedUnit("Pa", "pascal", N * (m ^ -2));
            J   = System.AddDerivedUnit("J", "joule", N * m);
            W   = System.AddDerivedUnit("W", "watt", J / s);
            C   = System.AddDerivedUnit("C", "coulomb", s * A);
            V   = System.AddDerivedUnit("V", "volt", W / A);
            F   = System.AddDerivedUnit("F", "farad", C / V);
            Ω   = System.AddDerivedUnit("Ω", "joule", V / A);
            S   = System.AddDerivedUnit("S", "siemens", A / V);
            Wb  = System.AddDerivedUnit("Wb", "weber", V * s);
            T   = System.AddDerivedUnit("T", "tesla", Wb * (s ^ -2));
            H   = System.AddDerivedUnit("H", "inductance", Wb / A);
            lx  = System.AddDerivedUnit("lx", "illuminance", (m ^ -2) * cd);
            Sv  = System.AddDerivedUnit("Sv", "sievert", J / kg);
            kat = System.AddDerivedUnit("kat", "katal", (s ^ -1) * mol);

            //Incoherent units
            h = System.AddDerivedUnit("h", "hour", 60 * 60 * s);
        }
Exemple #3
0
        public void CheckOnlyBaseUnitSIPerformance()
        {
            var system = UnitSystemFactory.CreateSystem("SI");

            var m  = system.AddBaseUnit("m", "metre");
            var kg = system.AddBaseUnit("kg", "kilogram", true);
            var s  = system.AddBaseUnit("s", "second");

            var kWh = 1000 * kg * (m ^ 2) * (s ^ -2) * 60 * 60;

            RunTest("BaseSI", () =>
            {
                var m3     = m ^ 3;
                var energy = new Quantity(100, kWh);
                var volume = new Quantity(5, m3);
                var result = energy / volume;
            });
        }
Exemple #4
0
        public void CheckDefineWhatYouNeedSIPerformance()
        {
            var system = UnitSystemFactory.CreateSystem("SI");

            var m  = system.AddBaseUnit("m", "metre");
            var kg = system.AddBaseUnit("kg", "kilogram", true);
            var s  = system.AddBaseUnit("s", "second");
            var N  = system.AddDerivedUnit("N", "newton", kg * m * (s ^ -2));
            var J  = system.AddDerivedUnit("J", "joule", N * m);
            var W  = system.AddDerivedUnit("W", "watt", J / s);
            var h  = system.AddDerivedUnit("h", "hour", 60 * 60 * s);

            var kWh = 1000 * W * h;

            RunTest("SimpleSI", () =>
            {
                var m3     = m ^ 3;
                var energy = new Quantity(100, kWh);
                var volume = new Quantity(5, m3);
                var result = energy / volume;
            });
        }