Skip to content

Commit c13f66e

Browse files
committed
Electric
Rearranged some of the electrical units, all with the prefix "Electric", and labeled the following classes as obsolete: * ApparentEnergy -> ElectricApparentEnergy * ApparentPower -> ElectricApparentPower * Capacitance -> ElectricCapacitance * ReactiveEnergy -> ElectricReactiveEnergy * ReactivePower -> ElectricReactivePower Added classes for ElectricReactance and ElectricSusceptance. Labeled ElectricPotentialAc and ElectricPotentialDc as obsolete per discussion. Labeled ElectricAdmittance as obsolete due to it being a complex number. Decided against adding ElectricImpedance for the same reason. Added math to ElectricCurrent.extra.cs and ElectricPotential.extra.cs to support ElectricApparentPower Added math for ElectricApparentPower.extra.cs Minor correction to formula in comment of Power.extra.cs
1 parent 83063d3 commit c13f66e

22 files changed

+282
-5
lines changed

Common/UnitDefinitions/ApparentEnergy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Name": "ApparentEnergy",
33
"BaseUnit": "VoltampereHour",
44
"XmlDocSummary": "A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules.",
5+
"ObsoleteText": "This class is obsolete. Please use ElectricApparentEnergy instead",
56
"BaseDimensions": {
67
"L": 2,
78
"M": 1,

Common/UnitDefinitions/ApparentPower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Name": "ApparentPower",
33
"BaseUnit": "Voltampere",
44
"XmlDocSummary": "Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current.",
5+
"ObsoleteText": "This class is obsolete. Please use ElectricApparentPower instead",
56
"BaseDimensions": {
67
"L": 2,
78
"M": 1,

Common/UnitDefinitions/Capacitance.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"BaseUnit": "Farad",
44
"XmlDocSummary": "Capacitance is the ability of a body to store an electric charge.",
55
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Capacitance",
6+
"ObsoleteText": "This class is obsolete. Please use ElectricCapacitance instead",
67
"BaseDimensions": {
78
"L": -2,
89
"M": -1,

Common/UnitDefinitions/ElectricAdmittance.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"Name": "ElectricAdmittance",
33
"BaseUnit": "Siemens",
44
"XmlDocSummary": "Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S).",
5+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Admittance",
6+
"ObsoleteText": "Admittance is a complex number, which is not currently supported by UnitsNet. Please use either ElectricConductance or ElectricSusceptance instead",
57
"BaseDimensions": {
68
"L": -2,
79
"M": -1,
@@ -21,6 +23,19 @@
2123
"Abbreviations": [ "S" ]
2224
}
2325
]
26+
},
27+
{
28+
"SingularName": "Mho",
29+
"PluralName": "Mhos",
30+
"FromUnitToBaseFunc": "{x}",
31+
"FromBaseToUnitFunc": "{x}",
32+
"Prefixes": [ "Nano", "Micro", "Milli", "Kilo" ],
33+
"Localization": [
34+
{
35+
"Culture": "en-US",
36+
"Abbreviations": [ "" ]
37+
}
38+
]
2439
}
2540
]
2641
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"Name": "ElectricApparentEnergy",
3+
"BaseUnit": "VoltampereHour",
4+
"XmlDocSummary": "A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules.",
5+
"BaseDimensions": {
6+
"L": 2,
7+
"M": 1,
8+
"T": -2
9+
},
10+
"Units": [
11+
{
12+
"SingularName": "VoltampereHour",
13+
"PluralName": "VoltampereHours",
14+
"FromUnitToBaseFunc": "{x}",
15+
"FromBaseToUnitFunc": "{x}",
16+
"Prefixes": [ "Kilo", "Mega" ],
17+
"Localization": [
18+
{
19+
"Culture": "en-US",
20+
"Abbreviations": [ "VAh" ]
21+
}
22+
]
23+
}
24+
]
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"Name": "ElectricApparentPower",
3+
"BaseUnit": "Voltampere",
4+
"XmlDocSummary": "Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. It is the product of the root mean square voltage (in volts) and the root mean square current (in amperes).",
5+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/AC_power#Active,_reactive,_apparent,_and_complex_power_in_sinusoidal_steady-state",
6+
"BaseDimensions": {
7+
"L": 2,
8+
"M": 1,
9+
"T": -3
10+
},
11+
"Units": [
12+
{
13+
"SingularName": "Voltampere",
14+
"PluralName": "Voltamperes",
15+
"FromUnitToBaseFunc": "{x}",
16+
"FromBaseToUnitFunc": "{x}",
17+
"Prefixes": [ "Micro", "Milli", "Kilo", "Mega", "Giga" ],
18+
"Localization": [
19+
{
20+
"Culture": "en-US",
21+
"Abbreviations": [ "VA" ]
22+
}
23+
]
24+
}
25+
]
26+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"Name": "ElectricCapacitance",
3+
"BaseUnit": "Farad",
4+
"XmlDocSummary": "Capacitance is the capacity of a material object or device to store electric charge.",
5+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Capacitance",
6+
"BaseDimensions": {
7+
"L": -2,
8+
"M": -1,
9+
"T": 4,
10+
"I": 2
11+
},
12+
"Units": [
13+
{
14+
"SingularName": "Farad",
15+
"PluralName": "Farads",
16+
"BaseUnits": {
17+
"L": "Meter",
18+
"M": "Kilogram",
19+
"T": "Second",
20+
"I": "Ampere"
21+
},
22+
"FromUnitToBaseFunc": "{x}",
23+
"FromBaseToUnitFunc": "{x}",
24+
"Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Kilo", "Mega" ],
25+
"Localization": [
26+
{
27+
"Culture": "en-US",
28+
"Abbreviations": [ "F" ]
29+
}
30+
]
31+
}
32+
]
33+
}

Common/UnitDefinitions/ElectricConductance.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Name": "ElectricConductance",
33
"BaseUnit": "Siemens",
4-
"XmlDocSummary": "The electrical conductance of an electrical conductor is a measure of the easeness to pass an electric current through that conductor.",
4+
"XmlDocSummary": "The electrical conductance of an object is a measure of the ease with which an electric current passes. Its reciprocal quantity is electrical resistance.",
55
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance",
66
"BaseDimensions": {
77
"L": -2,
@@ -22,6 +22,19 @@
2222
"Abbreviations": [ "S" ]
2323
}
2424
]
25+
},
26+
{
27+
"SingularName": "Mho",
28+
"PluralName": "Mhos",
29+
"FromUnitToBaseFunc": "{x}",
30+
"FromBaseToUnitFunc": "{x}",
31+
"Prefixes": [ "Nano", "Micro", "Milli", "Kilo" ],
32+
"Localization": [
33+
{
34+
"Culture": "en-US",
35+
"Abbreviations": [ "" ]
36+
}
37+
]
2538
}
2639
]
2740
}

Common/UnitDefinitions/ElectricPotential.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Name": "ElectricPotential",
33
"BaseUnit": "Volt",
44
"XmlDocSummary": "In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point.",
5+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Electric_potential",
56
"BaseDimensions": {
67
"L": 2,
78
"M": 1,

Common/UnitDefinitions/ElectricPotentialAc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"Name": "ElectricPotentialAc",
33
"BaseUnit": "VoltAc",
4-
"XmlDocSummary": "The Electric Potential of a system known to use Alternating Current.",
4+
"XmlDocSummary": "If you want to map more parameters into the ElectricPotential class (volts RMS, phase angle, etc.), just use a named tuple.",
5+
"ObsoleteText": "This class is redundant. Please use ElectricPotential instead.",
56
"Units": [
67
{
78
"SingularName": "VoltAc",

Common/UnitDefinitions/ElectricPotentialDc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"Name": "ElectricPotentialDc",
33
"BaseUnit": "VoltDc",
4-
"XmlDocSummary": "The Electric Potential of a system known to use Direct Current.",
4+
"XmlDocSummary": "If you want to map more parameters into the ElectricPotential class (volts RMS, phase angle, etc.), just use a named tuple.",
5+
"ObsoleteText": "This class is redundant. Please use ElectricPotential instead.",
56
"Units": [
67
{
78
"SingularName": "VoltDc",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"Name": "ElectricReactance",
3+
"BaseUnit": "Ohm",
4+
"XmlDocSummary": "In electrical circuits, reactance is the opposition presented to alternating current by inductance and capacitance. Along with resistance, it is one of two elements of impedance. Its reciprocal quantity is electrical susceptance.",
5+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_reactance",
6+
"BaseDimensions": {
7+
"L": 2,
8+
"M": 1,
9+
"T": -3,
10+
"I": -2
11+
},
12+
"Units": [
13+
{
14+
"SingularName": "Ohm",
15+
"PluralName": "Ohms",
16+
"FromUnitToBaseFunc": "{x}",
17+
"FromBaseToUnitFunc": "{x}",
18+
"Prefixes": [ "Micro", "Milli", "Kilo", "Mega", "Giga", "Tera" ],
19+
"Localization": [
20+
{
21+
"Culture": "en-US",
22+
"Abbreviations": [ "Ω" ]
23+
}
24+
]
25+
}
26+
]
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"Name": "ElectricReactiveEnergy",
3+
"BaseUnit": "VoltampereReactiveHour",
4+
"XmlDocSummary": "The volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour.",
5+
"BaseDimensions": {
6+
"L": 2,
7+
"M": 1,
8+
"T": -1
9+
},
10+
"Units": [
11+
{
12+
"SingularName": "VoltampereReactiveHour",
13+
"PluralName": "VoltampereReactiveHours",
14+
"FromUnitToBaseFunc": "{x}",
15+
"FromBaseToUnitFunc": "{x}",
16+
"Prefixes": [ "Kilo", "Mega" ],
17+
"Localization": [
18+
{
19+
"Culture": "en-US",
20+
"Abbreviations": [ "varh" ]
21+
}
22+
]
23+
}
24+
]
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"Name": "ElectricReactivePower",
3+
"BaseUnit": "VoltampereReactive",
4+
"XmlDocSummary": "In electric power transmission and distribution, volt-ampere reactive (var) is a unit of measurement of reactive power. Reactive power exists in an AC circuit when the current and voltage are not in phase.",
5+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/AC_power#Active,_reactive,_apparent,_and_complex_power_in_sinusoidal_steady-state",
6+
"BaseDimensions": {
7+
"L": 2,
8+
"M": 1,
9+
"T": -3
10+
},
11+
"Units": [
12+
{
13+
"SingularName": "VoltampereReactive",
14+
"PluralName": "VoltamperesReactive",
15+
"FromUnitToBaseFunc": "{x}",
16+
"FromBaseToUnitFunc": "{x}",
17+
"Prefixes": [ "Kilo", "Mega", "Giga" ],
18+
"Localization": [
19+
{
20+
"Culture": "en-US",
21+
"Abbreviations": [ "var" ]
22+
}
23+
]
24+
}
25+
]
26+
}

Common/UnitDefinitions/ElectricResistance.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"Name": "ElectricResistance",
33
"BaseUnit": "Ohm",
4-
"XmlDocSummary": "The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor.",
4+
"XmlDocSummary": "The electrical resistance of an object is a measure of its opposition to the flow of electric current. Its reciprocal quantity is electrical conductance.",
5+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance",
56
"BaseDimensions": {
67
"L": 2,
78
"M": 1,
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"Name": "ElectricSusceptance",
3+
"BaseUnit": "Siemens",
4+
"XmlDocSummary": "Electrical susceptance is the imaginary part of admittance, where the real part is conductance. Its reciprocal quantity is electrical reactance.",
5+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Susceptance",
6+
"BaseDimensions": {
7+
"L": -2,
8+
"M": -1,
9+
"T": 3,
10+
"I": 2
11+
},
12+
"Units": [
13+
{
14+
"SingularName": "Siemens",
15+
"PluralName": "Siemens",
16+
"FromUnitToBaseFunc": "{x}",
17+
"FromBaseToUnitFunc": "{x}",
18+
"Prefixes": [ "Nano", "Micro", "Milli", "Kilo" ],
19+
"Localization": [
20+
{
21+
"Culture": "en-US",
22+
"Abbreviations": [ "S" ]
23+
}
24+
]
25+
},
26+
{
27+
"SingularName": "Mho",
28+
"PluralName": "Mhos",
29+
"FromUnitToBaseFunc": "{x}",
30+
"FromBaseToUnitFunc": "{x}",
31+
"Prefixes": [ "Nano", "Micro", "Milli", "Kilo" ],
32+
"Localization": [
33+
{
34+
"Culture": "en-US",
35+
"Abbreviations": [ "" ]
36+
}
37+
]
38+
}
39+
]
40+
}

Common/UnitDefinitions/ReactiveEnergy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Name": "ReactiveEnergy",
33
"BaseUnit": "VoltampereReactiveHour",
44
"XmlDocSummary": "The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour.",
5+
"ObsoleteText": "This class is obsolete. Please use ElectricReactiveEnergy instead",
56
"BaseDimensions": {
67
"L": 2,
78
"M": 1,

Common/UnitDefinitions/ReactivePower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Name": "ReactivePower",
33
"BaseUnit": "VoltampereReactive",
44
"XmlDocSummary": "Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase.",
5+
"ObsoleteText": "This class is obsolete. Please use ElectricReactivePower instead",
56
"BaseDimensions": {
67
"L": 2,
78
"M": 1,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed under MIT No Attribution, see LICENSE file at the root.
2+
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.
3+
4+
using System;
5+
6+
namespace UnitsNet
7+
{
8+
public partial struct ElectricApparentPower
9+
{
10+
/// <summary>Calculate <see cref="ElectricCurrent"/> from <see cref="ElectricApparentPower"/> divided by <see cref="ElectricPotential"/>.</summary>
11+
/// <remarks>Electric apparent power is defined as S = voltage RMS * current RMS, so current RMS = S / voltage RMS.</remarks>
12+
public static ElectricCurrent operator /(ElectricApparentPower power, ElectricPotential potential)
13+
{
14+
return ElectricCurrent.FromAmperes((double)power.Voltampere / potential.Volts);
15+
}
16+
17+
/// <summary>Calculate <see cref="ElectricPotential"/> from <see cref="ElectricApparentPower"/> divided by <see cref="ElectricCurrent"/>.</summary>
18+
/// <remarks>Electric apparent power is defined as S = voltage RMS * current RMS, so voltage RMS = S / current RMS.</remarks>
19+
public static ElectricPotential operator /(ElectricApparentPower power, ElectricCurrent current)
20+
{
21+
return ElectricPotential.FromVolts((double)power.Voltampere / current.Amperes);
22+
}
23+
}
24+
}

UnitsNet/CustomCode/Quantities/ElectricCurrent.extra.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ public partial struct ElectricCurrent
2121
return Power.FromWatts(potential.Volts * current.Amperes);
2222
}
2323

24+
/// <summary>Calculate <see cref="ElectricApparentPower"/> from <see cref="ElectricPotential"/> multiplied by <see cref="ElectricCurrent"/>.</summary>
25+
/// <remarks>Electric apparent power is defined as S = voltage RMS * current RMS.</remarks>
26+
public static ElectricApparentPower operator *(ElectricCurrent current, ElectricPotential potential)
27+
{
28+
return ElectricApparentPower.FromVoltamperes(potential.Volts * current.Amperes);
29+
}
30+
2431
/// <summary>Calculate <see cref="ElectricCharge"/> from <see cref="ElectricCurrent"/> multiplied by <see cref="Duration"/>.</summary>
2532
public static ElectricCharge operator *(ElectricCurrent current, Duration time)
2633
{

UnitsNet/CustomCode/Quantities/ElectricPotential.extra.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public AmplitudeRatio ToAmplitudeRatio()
4040
return Power.FromWatts(potential.Volts * current.Amperes);
4141
}
4242

43+
/// <summary>Calculate <see cref="ElectricApparentPower"/> from <see cref="ElectricPotential"/> multiplied by <see cref="ElectricCurrent"/>.</summary>
44+
/// <remarks>Electric apparent power is defined as S = voltage RMS * current RMS.</remarks>
45+
public static Power operator *(ElectricPotential potential, ElectricCurrent current)
46+
{
47+
return ElectricApparentPower.FromVoltamperes(potential.Volts * current.Amperes);
48+
}
49+
4350
/// <summary>Get <see cref="Energy"/> from <see cref="ElectricPotential"/> times <see cref="ElectricCharge"/>.</summary>
4451
public static Energy operator *(ElectricPotential potential, ElectricCharge charge)
4552
{

0 commit comments

Comments
 (0)