public Unit CreateUnit(IUnitSystem system, double factor, Dimension dimension) { Check.SystemKnowsDimension(system, dimension); var unit = new DerivedUnit(system, factor, dimension); return unit; }
public void UnitReversedConvertToThroughOtherUnitSystems() { Unit pu = new DerivedUnit(Physics.CGS_Units, new SByte[] { 2, 0, -4, 0, 0, 0, 0 }); Unit expectedunit = new DerivedUnit(Physics.MGM_Units, pu.Exponents); Quantity expected = new Quantity(1D / (Math.Pow(100, 2) * Math.Pow(24 * 60 * 60, -4) / Math.Pow(10000, -4)), expectedunit); IQuantity actual = pu.ConvertTo(expectedunit); Assert.AreEqual(expected, actual); }
public void DerivedUnitToStringTest() { Unit MeterPerSecond2 = new DerivedUnit(Physics.SI_Units, new SByte[] { 1, 0, -2, 0, 0, 0, 0 }); //String expected = "SI.m·s-2"; String expected = "m·s-2"; String actual = MeterPerSecond2.ToString(); Assert.AreEqual(expected, actual); }
public void UnitConvertToSIUnit() { Unit pu = new DerivedUnit(Physics.MGD_Units, new SByte[] { 2, 0, -4, 0, 0, 0, 0 }); Unit expectedunit = new DerivedUnit(Physics.SI_Units, pu.Exponents); Quantity expected = new Quantity(Math.Pow(24 * 60 * 60, -4), expectedunit); IQuantity actual = pu.ConvertTo(expectedunit); Assert.AreEqual(expected, actual); }
public void QuantityTest_DivDerivedunitAndBaseUnitTest() { Unit pu1 = (Unit)Physics.SI_Units.UnitFromSymbol("J"); // m2∙kg∙s−2 Unit pu2 = (Unit)Physics.SI_Units.BaseUnits[(int)(PhysicalBaseQuantityKind.Mass)]; Unit expected = new DerivedUnit(Physics.SI_Units, new SByte[] { 2, 0, -2, 0, 0, 0, 0 }); Unit actual = pu1 / pu2; Assert.AreEqual(expected, actual); }
/// <summary> /// Unregisters the unit. /// </summary> /// <param name="derivedUnit"> /// The unit to be unregistered. /// </param> public void Unregister(DerivedUnit derivedUnit) { this.unitDefinitions.Remove(derivedUnit.Notation); var baseExpression = derivedUnit.GetBaseExpression(); var flatRepresentation = this.expressionToFlatRepresentationConverter.Convert( baseExpression, false, new FlatRepresentationBuilder()); this.derivedUnits.Remove(flatRepresentation); }
public void PowerQuantityInterface(int power, string expected) { var unitAndPower = new UnitAndPower(_metres, power); var derivedUnit = new DerivedUnit("sdf", "ssf", unitAndPower) { QuantityName = "Qty" }; var quantity = new Quantity(derivedUnit); var @interface = quantity.Interface; Assert.AreEqual(expected, @interface); }
public void QuantityTest_QuantityFunctionTest() { Quantity m = new Quantity(0.001, Physics.SI_Units.BaseUnits[(int)(PhysicalBaseQuantityKind.Mass)]); Unit MeterPerSecond = new DerivedUnit(Physics.SI_Units, new SByte[] { 1, 0, -1, 0, 0, 0, 0 }); Quantity c = new Quantity(299792458, MeterPerSecond); Quantity expected = new Quantity(0.001 * 299792458 * 299792458, Physics.SI_Units.UnitFromSymbol("J")); Quantity E = EnergyEquivalentOfMass(m); Assert.AreEqual(expected, E); }
public void MultKiloGramToMilliGram() { Quantity pg1 = new Quantity(0.000123, Physics.SI_Units.BaseUnits[(int)(PhysicalBaseQuantityKind.Mass)]); Quantity pg2 = new Quantity(456, Physics.SI_Units.BaseUnits[(int)(PhysicalBaseQuantityKind.Mass)]); Unit MassSquared = new DerivedUnit(Physics.SI_Units, new SByte[] { 0, 2, 0, 0, 0, 0, 0 }); Quantity expected = new Quantity(0.000123 * 456, MassSquared); Quantity actual = pg1 * pg2; Assert.AreEqual(expected, actual); }
/// <summary> /// Registers the unit. /// </summary> /// <param name="derivedUnit"> /// The unit to be registered. /// </param> public void Register(DerivedUnit derivedUnit) { var derivedNotation = derivedUnit.Notation; this.unitDefinitions.Add(derivedNotation, derivedUnit); var expression = derivedUnit.GetBaseExpression(); var flatRepresentation = this.expressionToFlatRepresentationConverter.Convert( expression, false, new FlatRepresentationBuilder()); this.derivedUnits.Add(flatRepresentation, derivedUnit); }
public void PowerOperatorCalculateEnergyIn1Gram() { Quantity m = new Quantity(0.001, Physics.SI_Units.BaseUnits[(int)(PhysicalBaseQuantityKind.Mass)]); Unit MeterPerSecond = new DerivedUnit(Physics.SI_Units, new SByte[] { 1, 0, -1, 0, 0, 0, 0 }); Quantity c = new Quantity(299792458, MeterPerSecond); Quantity expected = new Quantity(0.001 * 299792458 * 299792458, Physics.SI_Units.UnitFromSymbol("J")); Quantity E = m * c.Pow(2); Assert.AreEqual(expected, E); }
public void CleanTests() { t = null; bm1 = null; bm2 = null; bm3 = null; m1 = null; m2 = null; m3 = null; d1 = null; d2 = null; d3 = null; d4 = null; }
public void DerivedUnitBaseUnitStringTest() { Unit MeterPerSecond2 = new DerivedUnit(Physics.SI_Units, new SByte[] { 1, 0, -2, 0, 0, 0, 0 }); String expected = "m·s-2"; IQuantity pq = MeterPerSecond2.ConvertToBaseUnit(); Assert.AreEqual(pq.Value, 1d); String actual = pq.Unit.ToString(); Assert.AreEqual(expected, actual); }
public void CalculateEnergyOf1GramAfterFalling10MeterAtEarthSurface() { Quantity m = Quantity.Parse("1 g") as Quantity; Quantity h = Quantity.Parse("10 m") as Quantity; //!!! To do: make this work: Quantity g = Quantity.Parse("9.81 m/s^2"); Unit MeterPerSecond2 = new DerivedUnit(Physics.SI_Units, new SByte[] { 1, 0, -2, 0, 0, 0, 0 }); Quantity g = new Quantity(9.81, MeterPerSecond2); Quantity expected = new Quantity(0.001 * 9.81 * 10, Physics.SI_Units.UnitFromSymbol("J")); Quantity E = m * g * h; Assert.AreEqual(expected, E); }
public void AddNewUnits() { #region UsageRegisterUnits // Only units registered in the code below will be supported by the unit systems. // If it is desired to use the default units and add/remove additional unit, use the UnitSystem.InitializeWithDefaults method instead. UnitSystem.Initialize(unitRegistrar => { // Register base unit meters. var meters = new Unit("m"); unitRegistrar.Register(meters); // Register base unit seconds. var seconds = new Unit("s"); unitRegistrar.Register(seconds); // Register mile as a factored unit relative to the base unit meter. unitRegistrar.Register(new FactoredUnit(1609.344, "mi", meters)); // Register base unit kelvins. var kelvins = new Unit("K"); unitRegistrar.Register(kelvins); // Register method unit fahrenheits, with conversion to and from the base unit kelvin. var fahrenheits = new MethodUnit( fahrenheit => ((fahrenheit - 32) / 1.8) + 273.15, kelvin => ((kelvin - 273.15) * 1.8) + 32, "°F", kelvins); unitRegistrar.Register(fahrenheits); // Register special base unit Kilograms (Prefixed base unit) var kilograms = new PrefixedBaseUnit(Prefixes.Kilo, "g"); unitRegistrar.Register(kilograms); // Register derived unit newtons, by specifying the base unit expression. var newtons = new DerivedUnit("N", kilograms * meters / seconds.Exp(2)); unitRegistrar.Register(newtons); }); #endregion }
public void InitTests() { t = new DerivedUnit(); bm1 = new BaseMeasure("pk"); bm2 = new BaseMeasure("ae"); bm3 = new BaseMeasure("mi"); Measures.Instance.Add(bm1); Measures.Instance.Add(bm2); Measures.Instance.Add(bm3); m1 = new BaseUnit(bm1, 1, "s", "pikkus"); m2 = new BaseUnit(bm2, 1, "t", "aeg"); m3 = new BaseUnit(bm3, 1, "k", "midagi"); Units.Instance.Add(m1); Units.Instance.Add(m2); Units.Instance.Add(m3); d1 = (DerivedUnit)m1.Multiply(m2); //s1*t1 d2 = (DerivedUnit)m1.Multiply(m3); //s1*k1 d3 = (DerivedUnit)m2.Multiply(m3); //t1*k1 d4 = (DerivedUnit)m3.Multiply(m3); //k2 }
/// <summary> /// Serialize the <see cref="DerivedUnit"/> /// </summary> /// <param name="derivedUnit">The <see cref="DerivedUnit"/> to serialize</param> /// <returns>The <see cref="JObject"/></returns> private JObject Serialize(DerivedUnit derivedUnit) { var jsonObject = new JObject(); jsonObject.Add("alias", this.PropertySerializerMap["alias"](derivedUnit.Alias.OrderBy(x => x, this.guidComparer))); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), derivedUnit.ClassKind))); jsonObject.Add("definition", this.PropertySerializerMap["definition"](derivedUnit.Definition.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](derivedUnit.ExcludedDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](derivedUnit.ExcludedPerson.OrderBy(x => x, this.guidComparer))); jsonObject.Add("hyperLink", this.PropertySerializerMap["hyperLink"](derivedUnit.HyperLink.OrderBy(x => x, this.guidComparer))); jsonObject.Add("iid", this.PropertySerializerMap["iid"](derivedUnit.Iid)); jsonObject.Add("isDeprecated", this.PropertySerializerMap["isDeprecated"](derivedUnit.IsDeprecated)); jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](derivedUnit.ModifiedOn)); jsonObject.Add("name", this.PropertySerializerMap["name"](derivedUnit.Name)); jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](derivedUnit.RevisionNumber)); jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](derivedUnit.ShortName)); jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](derivedUnit.ThingPreference)); jsonObject.Add("unitFactor", this.PropertySerializerMap["unitFactor"](derivedUnit.UnitFactor.OrderBy(x => x, this.orderedItemComparer))); return(jsonObject); }
public void VerifyIsContainedByIidWorks() { var model = new EngineeringModel(Guid.NewGuid(), null, null); var sitedir = new SiteDirectory(Guid.NewGuid(), null, null); var rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null); var unit = new DerivedUnit(Guid.NewGuid(), null, null); var factor = new UnitFactor(Guid.NewGuid(), null, null); sitedir.SiteReferenceDataLibrary.Add(rdl); rdl.Unit.Add(unit); unit.UnitFactor.Add(factor); Assert.IsTrue(factor.IsContainedBy(sitedir.Iid)); Assert.IsTrue(factor.IsContainedBy(rdl.Iid)); Assert.IsTrue(factor.IsContainedBy(unit.Iid)); Assert.IsFalse(factor.IsContainedBy(model.Iid)); Assert.IsFalse(sitedir.IsContainedBy(sitedir.Iid)); Assert.Throws <ArgumentNullException>(() => factor.IsContainedBy(iid: Guid.Empty)); }
public ImperialUnitSystem() { //length ft = new ScaleUnit("ft", "feet", FeetToMetres, Unit.SI.m, this); @in = new ScaleUnit("in", "inch", 1D / 12, ft); thou = new ScaleUnit("th", "thou", 1D / 1000, @in); ya = new ScaleUnit("yd", "yard", 3, ft); ch = new ScaleUnit("ch", "chain", 22, ya); fur = new ScaleUnit("fur", "furlong", 10, ch); mi = new ScaleUnit("mi", "mile", 8, fur); lea = new ScaleUnit("lea", "league", 3, mi); rod = new ScaleUnit("rod", "rod", 1D / 4, ch); link = new ScaleUnit("link", "link", 1D / 25, rod); //area acre = new DerivedUnit("acre", "acre", fur * ch); rood = new DerivedUnit("rood", "rood", fur * rod); perch = new DerivedUnit("perch", "perch", rod ^ 2); //volume _cubic_inch = @in ^ 3; pt = new ScaleUnit("pt", "pint", CubicInchToPint, _cubic_inch); gi = new ScaleUnit("gi", "gill", 1D / 4, pt); fl_oz = new ScaleUnit("fl oz", "fluid ounce", 1D / 5, gi); qt = new ScaleUnit("qt", "quart", 2, pt); gal = new ScaleUnit("gal", "gallon", 4, qt); //weight lb = new ScaleUnit("lb", "pound", PoundToKilogram, Unit.SI.kg, this); oz = new ScaleUnit("oz", "ounce", 1D / 16, lb); drc = new ScaleUnit("drc", "drachm", 1D / 16, oz); gr = new ScaleUnit("gr", "grain", 1D / 7000, lb); st = new ScaleUnit("st", "stone", 14, lb); qtr = new ScaleUnit("qtr", "quarter", 28, lb); cwt = new ScaleUnit("cwt", "hundredweight", 4, qtr); t = new ScaleUnit("t", "ton", 20, cwt); }
public MockSettings() { Metres = new SiUnit("Metres", "m") { QuantityName = "Length" }; SiUnits.Add(Metres); Length = Metres.Quantity; Seconds = new SiUnit("Seconds", "s") { QuantityName = "Time" }; SiUnits.Add(Seconds); Time = Seconds.Quantity; Kilograms = new SiUnit("Kilograms", "kg") { QuantityName = "Mass" }; SiUnits.Add(Kilograms); Mass = Kilograms.Quantity; Amperes = new SiUnit("Amperes", "A") { QuantityName = "ElectricalCurrent" }; SiUnits.Add(Amperes); Current = Amperes.Quantity; MetresPerSecond = new DerivedUnit( "MetresPerSecond", "m/s", new UnitAndPower(Metres, 1), new UnitAndPower(Seconds, -1)) { QuantityName = "Speed" }; DerivedUnits.Add(MetresPerSecond); Speed = MetresPerSecond.Quantity; Newtons = new DerivedUnit( "Newtons", "N", new UnitAndPower(Kilograms, 1), new UnitAndPower(Metres, 1), new UnitAndPower(Seconds, -2)) { QuantityName = "Force" }; DerivedUnits.Add(Newtons); Force = Newtons.Quantity; Joules = new DerivedUnit( "Joules", "J", new UnitAndPower(Newtons, 1), new UnitAndPower(Metres, 1)) { QuantityName = "Energy" }; DerivedUnits.Add(Joules); Energy = Joules.Quantity; Watts = new DerivedUnit( "Watts", "W", new UnitAndPower(Joules, 1), new UnitAndPower(Seconds, -1)) { QuantityName = "Power" }; DerivedUnits.Add(Watts); Power = Watts.Quantity; Volts = new DerivedUnit( "Volts", "V", new UnitAndPower(Watts, 1), new UnitAndPower(Amperes, -1)) { QuantityName = "Voltage" }; DerivedUnits.Add(Volts); Voltage = Volts.Quantity; Coloumbs = new DerivedUnit( "Coloumbs", "C", new UnitAndPower(Seconds, 1), new UnitAndPower(Amperes, 1)) { QuantityName = "ElectricCharge" }; DerivedUnits.Add(Coloumbs); ElectricCharge = Coloumbs.Quantity; SquareMetres = new DerivedUnit("SquareMetres", "m^2", new UnitAndPower(Metres, 2)) { QuantityName = "Area" }; DerivedUnits.Add(SquareMetres); Area = SquareMetres.Quantity; CubicMetres = new DerivedUnit("CubicMetres", "m^3", new UnitAndPower(Metres, 3)) { QuantityName = "Volume" }; DerivedUnits.Add(CubicMetres); Volume = CubicMetres.Quantity; Hertz = new DerivedUnit("Hertz", "1/s", new UnitAndPower(Seconds, -1)) { QuantityName = "Frequency" }; DerivedUnits.Add(Hertz); Frequency = Hertz.Quantity; }
/// <summary> /// Tries to get the unit. /// </summary> /// <param name="flatRepresentation">The flat representation.</param> /// <param name="derivedUnit">The found derived unit.</param> /// <returns> /// <c>true</c> if the flat representation is found, otherwise <c>false</c> /// </returns> public bool TryGetUnit(FlatRepresentation flatRepresentation, out DerivedUnit derivedUnit) { return(this.derivedUnits.TryGetValue(flatRepresentation, out derivedUnit)); }
public void CompositeUnitDivision_When_PrefixesAreDifferent_Then_NotationShouldBeRhsPrefixSquared() { var testee = new DerivedUnit(null, MeterUnit / CentiMeterUnitExpression); testee.ToString().Should().Be("m/cm"); }
public void CompositeUnitMultiplication_When_PrefixesAreDifferent_Then_NotationShouldBeLhsPrefixTimesRhsPrefix() { var testee = new DerivedUnit(null, MeterUnit * CentiMeterUnitExpression); testee.ToString().Should().Be("m*cm"); }
public abstract T Visit(DerivedUnit v);
/// <summary> /// Persist the <see cref="DerivedUnit"/> containment tree to the ORM layer. Update if it already exists. /// This is typically used during the import of existing data to the Database. /// </summary> /// <param name="transaction"> /// The current <see cref="NpgsqlTransaction"/> to the database. /// </param> /// <param name="partition"> /// The database partition (schema) where the requested resource will be stored. /// </param> /// <param name="derivedUnit"> /// The <see cref="DerivedUnit"/> instance to persist. /// </param> /// <returns> /// True if the persistence was successful. /// </returns> private bool UpsertContainment(NpgsqlTransaction transaction, string partition, DerivedUnit derivedUnit) { var results = new List <bool>(); foreach (var alias in this.ResolveFromRequestCache(derivedUnit.Alias)) { results.Add(this.AliasService.UpsertConcept(transaction, partition, alias, derivedUnit)); } foreach (var definition in this.ResolveFromRequestCache(derivedUnit.Definition)) { results.Add(this.DefinitionService.UpsertConcept(transaction, partition, definition, derivedUnit)); } foreach (var hyperLink in this.ResolveFromRequestCache(derivedUnit.HyperLink)) { results.Add(this.HyperLinkService.UpsertConcept(transaction, partition, hyperLink, derivedUnit)); } foreach (var unitFactor in this.ResolveFromRequestCache(derivedUnit.UnitFactor)) { results.Add(this.UnitFactorService.UpsertConcept(transaction, partition, (UnitFactor)unitFactor.V, derivedUnit, unitFactor.K)); } return(results.All(x => x)); }
public void Setup() { this.npgsqlTransaction = null; this.securityContext = new Mock <ISecurityContext>(); // There is a chain duA -> ufA -> duB -> ufB -> suD this.simpleUnitD = new SimpleUnit { Iid = Guid.NewGuid() }; this.unitFactorD = new UnitFactor { Iid = Guid.NewGuid(), Unit = this.simpleUnitD.Iid }; this.unitFactorB = new UnitFactor { Iid = Guid.NewGuid(), Unit = this.simpleUnitD.Iid }; var unitFactorForB = new OrderedItem { K = 1, V = this.unitFactorB.Iid }; var unitFactorsForB = new List <OrderedItem> { unitFactorForB }; this.derivedUnitB = new DerivedUnit { Iid = Guid.NewGuid(), UnitFactor = unitFactorsForB }; this.unitFactorA = new UnitFactor { Iid = Guid.NewGuid(), Unit = this.derivedUnitB.Iid }; var unitFactorForA = new OrderedItem { K = 1, V = this.unitFactorA.Iid }; var unitFactorsForA = new List <OrderedItem> { unitFactorForA }; this.derivedUnitA = new DerivedUnit { Iid = Guid.NewGuid(), UnitFactor = unitFactorsForA }; this.unitFactorC = new UnitFactor { Iid = Guid.NewGuid(), Unit = this.derivedUnitA.Iid }; // There is a chain librayA -> LibraryB this.referenceDataLibraryB = new SiteReferenceDataLibrary { Iid = Guid.NewGuid(), Unit = { this.simpleUnitD.Iid } }; this.referenceDataLibraryA = new ModelReferenceDataLibrary { Iid = Guid.NewGuid(), Unit = { this.derivedUnitA.Iid, this.derivedUnitB.Iid }, RequiredRdl = this.referenceDataLibraryB.Iid }; this.siteReferenceDataLibraryService = new Mock <ISiteReferenceDataLibraryService>(); this.siteReferenceDataLibraryService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), null, It.IsAny <ISecurityContext>())) .Returns(new List <ReferenceDataLibrary> { this.referenceDataLibraryB }); this.derivedUnitService = new Mock <IDerivedUnitService>(); this.derivedUnitService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.simpleUnitD.Iid, this.derivedUnitA.Iid, this.derivedUnitB.Iid }, It.IsAny <ISecurityContext>())) .Returns(new List <DerivedUnit> { this.derivedUnitA, this.derivedUnitB }); this.unitFactorService = new Mock <IUnitFactorService>(); this.unitFactorService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.unitFactorA.Iid }, It.IsAny <ISecurityContext>())).Returns(new List <UnitFactor> { this.unitFactorA }); this.unitFactorService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.unitFactorB.Iid }, It.IsAny <ISecurityContext>())).Returns(new List <UnitFactor> { this.unitFactorB }); this.unitFactorService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.unitFactorC.Iid }, It.IsAny <ISecurityContext>())).Returns(new List <UnitFactor> { this.unitFactorC }); this.unitFactorService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.unitFactorD.Iid }, It.IsAny <ISecurityContext>())).Returns(new List <UnitFactor> { this.unitFactorD }); }
private MockSettings() : base(new ObservableCollection <Prefix>(), new ObservableCollection <BaseUnit>(), new ObservableCollection <DerivedUnit>()) { this.Prefixes.Add(this.Micro); this.Prefixes.Add(this.Milli); this.Prefixes.Add(this.Kilo); this.Metres = new BaseUnit("Metres", "m", "Length"); this.BaseUnits.Add(this.Metres); this.Length = this.Metres.Quantity; this.Kelvins = new BaseUnit("Kelvin", "K", "Temperature"); this.BaseUnits.Add(this.Kelvins); this.Temperature = this.Kelvins.Quantity; this.Seconds = new BaseUnit("Seconds", "s", "Time"); this.BaseUnits.Add(this.Seconds); this.Time = this.Seconds.Quantity; this.Kilograms = new BaseUnit("Kilograms", "kg", "Mass"); this.Grams = new FactorConversion("Grams", "g", 0.001); this.Kilograms.FactorConversions.Add(this.Grams); this.BaseUnits.Add(this.Kilograms); this.Mass = this.Kilograms.Quantity; this.Amperes = new BaseUnit("Amperes", "A", "ElectricalCurrent"); this.BaseUnits.Add(this.Amperes); this.Current = this.Amperes.Quantity; this.MetresPerSecond = new DerivedUnit( "MetresPerSecond", "m/s", "Speed", new[] { UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -1) }); this.DerivedUnits.Add(this.MetresPerSecond); this.Speed = this.MetresPerSecond.Quantity; this.MetresPerSecondSquared = new DerivedUnit( "MetresPerSecondSquared", "m/s^2", "Acceleration", new[] { UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -2) }); this.DerivedUnits.Add(this.MetresPerSecondSquared); this.Acceleration = this.MetresPerSecondSquared.Quantity; this.Newtons = new DerivedUnit( "Newtons", "N", "Force", new[] { UnitAndPower.Create(this.Kilograms, 1), UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -2), }); this.DerivedUnits.Add(this.Newtons); this.Force = this.Newtons.Quantity; this.Joules = new DerivedUnit( "Joules", "J", "Energy", new[] { UnitAndPower.Create(this.Newtons, 1), UnitAndPower.Create(this.Metres, 1) }); this.DerivedUnits.Add(this.Joules); this.Energy = this.Joules.Quantity; this.Watts = new DerivedUnit( "Watts", "W", "Power", new[] { UnitAndPower.Create(this.Joules, 1), UnitAndPower.Create(this.Seconds, -1) }); this.DerivedUnits.Add(this.Watts); this.Power = this.Watts.Quantity; this.Volts = new DerivedUnit( "Volts", "V", "Voltage", new[] { UnitAndPower.Create(this.Watts, 1), UnitAndPower.Create(this.Amperes, -1) }); this.DerivedUnits.Add(this.Volts); this.Voltage = this.Volts.Quantity; this.Coulombs = new DerivedUnit( "Coulombs", "C", "ElectricCharge", new[] { UnitAndPower.Create(this.Seconds, 1), UnitAndPower.Create(this.Amperes, 1) }); this.DerivedUnits.Add(this.Coulombs); this.ElectricCharge = this.Coulombs.Quantity; this.SquareMetres = new DerivedUnit("SquareMetres", "m^2", "Area", new[] { UnitAndPower.Create(this.Metres, 2) }); this.DerivedUnits.Add(this.SquareMetres); this.Area = this.SquareMetres.Quantity; this.CubicMetres = new DerivedUnit("CubicMetres", "m^3", "Volume", new[] { UnitAndPower.Create(this.Metres, 3) }); this.DerivedUnits.Add(this.CubicMetres); this.Volume = this.CubicMetres.Quantity; this.KilogramsPerCubicMetre = new DerivedUnit("KilogramsPerCubicMetre", "kg/m^3", "Density", new[] { UnitAndPower.Create(this.Kilograms, 1), UnitAndPower.Create(this.Metres, -3) }); this.DerivedUnits.Add(this.KilogramsPerCubicMetre); this.Density = this.CubicMetres.Quantity; this.Hertz = new DerivedUnit("Hertz", "1/s", "Frequency", new[] { UnitAndPower.Create(this.Seconds, -1) }); this.DerivedUnits.Add(this.Hertz); this.Frequency = this.Hertz.Quantity; }