Skip to content

Commit 0f8c06b

Browse files
zykovaa-eplanangularsen
authored andcommitted
Extend volume flow by cubic millimeter per second (#571)
* Extend volume flow by cubic millimeter per second
1 parent a9a20ff commit 0f8c06b

File tree

8 files changed

+76
-0
lines changed

8 files changed

+76
-0
lines changed

Common/GeneratedCode/Quantities/VolumeFlow.Common.g.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ public static BaseDimensions BaseDimensions
201201
/// </summary>
202202
public double CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond);
203203

204+
/// <summary>
205+
/// Get VolumeFlow in CubicMillimetersPerSecond.
206+
/// </summary>
207+
public double CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond);
208+
204209
/// <summary>
205210
/// Get VolumeFlow in CubicYardsPerHour.
206211
/// </summary>
@@ -417,6 +422,20 @@ public static VolumeFlow FromCubicMetersPerSecond(QuantityValue cubicmetersperse
417422
return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerSecond);
418423
}
419424

425+
/// <summary>
426+
/// Get VolumeFlow from CubicMillimetersPerSecond.
427+
/// </summary>
428+
#if WINDOWS_UWP
429+
[Windows.Foundation.Metadata.DefaultOverload]
430+
public static VolumeFlow FromCubicMillimetersPerSecond(double cubicmillimeterspersecond)
431+
#else
432+
public static VolumeFlow FromCubicMillimetersPerSecond(QuantityValue cubicmillimeterspersecond)
433+
#endif
434+
{
435+
double value = (double) cubicmillimeterspersecond;
436+
return new VolumeFlow(value, VolumeFlowUnit.CubicMillimeterPerSecond);
437+
}
438+
420439
/// <summary>
421440
/// Get VolumeFlow from CubicYardsPerHour.
422441
/// </summary>
@@ -863,6 +882,7 @@ private double AsBaseUnit()
863882
case VolumeFlowUnit.CubicMeterPerHour: return _value/3600;
864883
case VolumeFlowUnit.CubicMeterPerMinute: return _value/60;
865884
case VolumeFlowUnit.CubicMeterPerSecond: return _value;
885+
case VolumeFlowUnit.CubicMillimeterPerSecond: return _value*1e-9;
866886
case VolumeFlowUnit.CubicYardPerHour: return _value*2.1237634944E-4;
867887
case VolumeFlowUnit.CubicYardPerMinute: return _value*0.0127425809664;
868888
case VolumeFlowUnit.CubicYardPerSecond: return _value*0.764554857984;
@@ -904,6 +924,7 @@ private double AsBaseNumericType(VolumeFlowUnit unit)
904924
case VolumeFlowUnit.CubicMeterPerHour: return baseUnitValue*3600;
905925
case VolumeFlowUnit.CubicMeterPerMinute: return baseUnitValue*60;
906926
case VolumeFlowUnit.CubicMeterPerSecond: return baseUnitValue;
927+
case VolumeFlowUnit.CubicMillimeterPerSecond: return baseUnitValue/1e-9;
907928
case VolumeFlowUnit.CubicYardPerHour: return baseUnitValue/2.1237634944E-4;
908929
case VolumeFlowUnit.CubicYardPerMinute: return baseUnitValue/0.0127425809664;
909930
case VolumeFlowUnit.CubicYardPerSecond: return baseUnitValue/0.764554857984;

Common/UnitDefinitions/VolumeFlow.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,22 @@
275275
"Abbreviations": [ "bbl/hr", "bph" ]
276276
}
277277
]
278+
},
279+
{
280+
"SingularName": "CubicMillimeterPerSecond",
281+
"PluralName": "CubicMillimetersPerSecond",
282+
"FromUnitToBaseFunc": "x*1e-9",
283+
"FromBaseToUnitFunc": "x/1e-9",
284+
"Localization": [
285+
{
286+
"Culture": "en-US",
287+
"Abbreviations": [ "mm³/s" ]
288+
},
289+
{
290+
"Culture": "ru-RU",
291+
"Abbreviations": [ "мм³/с" ]
292+
}
293+
]
278294
}
279295
]
280296
}

UnitsNet.Tests/CustomCode/VolumeFlowTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public class VolumeFlowTests : VolumeFlowTestsBase
9898

9999
protected override double KilousGallonsPerMinuteInOneCubicMeterPerSecond => 1.5850323141489e1;
100100

101+
protected override double CubicMillimetersPerSecondInOneCubicMeterPerSecond => 1e9;
102+
101103
[Theory]
102104
[InlineData(20, 2, 40)]
103105
[InlineData(20, 62, 1240)]

UnitsNet.Tests/GeneratedCode/VolumeFlowTestsBase.g.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public abstract partial class VolumeFlowTestsBase
6161
protected abstract double CubicMetersPerHourInOneCubicMeterPerSecond { get; }
6262
protected abstract double CubicMetersPerMinuteInOneCubicMeterPerSecond { get; }
6363
protected abstract double CubicMetersPerSecondInOneCubicMeterPerSecond { get; }
64+
protected abstract double CubicMillimetersPerSecondInOneCubicMeterPerSecond { get; }
6465
protected abstract double CubicYardsPerHourInOneCubicMeterPerSecond { get; }
6566
protected abstract double CubicYardsPerMinuteInOneCubicMeterPerSecond { get; }
6667
protected abstract double CubicYardsPerSecondInOneCubicMeterPerSecond { get; }
@@ -90,6 +91,7 @@ public abstract partial class VolumeFlowTestsBase
9091
protected virtual double CubicMetersPerHourTolerance { get { return 1e-5; } }
9192
protected virtual double CubicMetersPerMinuteTolerance { get { return 1e-5; } }
9293
protected virtual double CubicMetersPerSecondTolerance { get { return 1e-5; } }
94+
protected virtual double CubicMillimetersPerSecondTolerance { get { return 1e-5; } }
9395
protected virtual double CubicYardsPerHourTolerance { get { return 1e-5; } }
9496
protected virtual double CubicYardsPerMinuteTolerance { get { return 1e-5; } }
9597
protected virtual double CubicYardsPerSecondTolerance { get { return 1e-5; } }
@@ -123,6 +125,7 @@ public void CubicMeterPerSecondToVolumeFlowUnits()
123125
AssertEx.EqualTolerance(CubicMetersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.CubicMetersPerHour, CubicMetersPerHourTolerance);
124126
AssertEx.EqualTolerance(CubicMetersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.CubicMetersPerMinute, CubicMetersPerMinuteTolerance);
125127
AssertEx.EqualTolerance(CubicMetersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.CubicMetersPerSecond, CubicMetersPerSecondTolerance);
128+
AssertEx.EqualTolerance(CubicMillimetersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.CubicMillimetersPerSecond, CubicMillimetersPerSecondTolerance);
126129
AssertEx.EqualTolerance(CubicYardsPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.CubicYardsPerHour, CubicYardsPerHourTolerance);
127130
AssertEx.EqualTolerance(CubicYardsPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.CubicYardsPerMinute, CubicYardsPerMinuteTolerance);
128131
AssertEx.EqualTolerance(CubicYardsPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.CubicYardsPerSecond, CubicYardsPerSecondTolerance);
@@ -155,6 +158,7 @@ public void FromValueAndUnit()
155158
AssertEx.EqualTolerance(1, VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerHour).CubicMetersPerHour, CubicMetersPerHourTolerance);
156159
AssertEx.EqualTolerance(1, VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerMinute).CubicMetersPerMinute, CubicMetersPerMinuteTolerance);
157160
AssertEx.EqualTolerance(1, VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerSecond).CubicMetersPerSecond, CubicMetersPerSecondTolerance);
161+
AssertEx.EqualTolerance(1, VolumeFlow.From(1, VolumeFlowUnit.CubicMillimeterPerSecond).CubicMillimetersPerSecond, CubicMillimetersPerSecondTolerance);
158162
AssertEx.EqualTolerance(1, VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerHour).CubicYardsPerHour, CubicYardsPerHourTolerance);
159163
AssertEx.EqualTolerance(1, VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerMinute).CubicYardsPerMinute, CubicYardsPerMinuteTolerance);
160164
AssertEx.EqualTolerance(1, VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerSecond).CubicYardsPerSecond, CubicYardsPerSecondTolerance);
@@ -188,6 +192,7 @@ public void As()
188192
AssertEx.EqualTolerance(CubicMetersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicMeterPerHour), CubicMetersPerHourTolerance);
189193
AssertEx.EqualTolerance(CubicMetersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicMeterPerMinute), CubicMetersPerMinuteTolerance);
190194
AssertEx.EqualTolerance(CubicMetersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicMeterPerSecond), CubicMetersPerSecondTolerance);
195+
AssertEx.EqualTolerance(CubicMillimetersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicMillimeterPerSecond), CubicMillimetersPerSecondTolerance);
191196
AssertEx.EqualTolerance(CubicYardsPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicYardPerHour), CubicYardsPerHourTolerance);
192197
AssertEx.EqualTolerance(CubicYardsPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicYardPerMinute), CubicYardsPerMinuteTolerance);
193198
AssertEx.EqualTolerance(CubicYardsPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicYardPerSecond), CubicYardsPerSecondTolerance);
@@ -246,6 +251,10 @@ public void ToUnit()
246251
AssertEx.EqualTolerance(CubicMetersPerSecondInOneCubicMeterPerSecond, (double)cubicmeterpersecondQuantity.Value, CubicMetersPerSecondTolerance);
247252
Assert.Equal(VolumeFlowUnit.CubicMeterPerSecond, cubicmeterpersecondQuantity.Unit);
248253

254+
var cubicmillimeterpersecondQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicMillimeterPerSecond);
255+
AssertEx.EqualTolerance(CubicMillimetersPerSecondInOneCubicMeterPerSecond, (double)cubicmillimeterpersecondQuantity.Value, CubicMillimetersPerSecondTolerance);
256+
Assert.Equal(VolumeFlowUnit.CubicMillimeterPerSecond, cubicmillimeterpersecondQuantity.Unit);
257+
249258
var cubicyardperhourQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicYardPerHour);
250259
AssertEx.EqualTolerance(CubicYardsPerHourInOneCubicMeterPerSecond, (double)cubicyardperhourQuantity.Value, CubicYardsPerHourTolerance);
251260
Assert.Equal(VolumeFlowUnit.CubicYardPerHour, cubicyardperhourQuantity.Unit);
@@ -335,6 +344,7 @@ public void ConversionRoundTrip()
335344
AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerHour(cubicmeterpersecond.CubicMetersPerHour).CubicMetersPerSecond, CubicMetersPerHourTolerance);
336345
AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerMinute(cubicmeterpersecond.CubicMetersPerMinute).CubicMetersPerSecond, CubicMetersPerMinuteTolerance);
337346
AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerSecond(cubicmeterpersecond.CubicMetersPerSecond).CubicMetersPerSecond, CubicMetersPerSecondTolerance);
347+
AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMillimetersPerSecond(cubicmeterpersecond.CubicMillimetersPerSecond).CubicMetersPerSecond, CubicMillimetersPerSecondTolerance);
338348
AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerHour(cubicmeterpersecond.CubicYardsPerHour).CubicMetersPerSecond, CubicYardsPerHourTolerance);
339349
AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerMinute(cubicmeterpersecond.CubicYardsPerMinute).CubicMetersPerSecond, CubicYardsPerMinuteTolerance);
340350
AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerSecond(cubicmeterpersecond.CubicYardsPerSecond).CubicMetersPerSecond, CubicYardsPerSecondTolerance);

UnitsNet/GeneratedCode/Extensions/Number/NumberToVolumeFlowExtensions.g.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ public static class NumberToVolumeFlowExtensions
132132

133133
#endregion
134134

135+
#region CubicMillimeterPerSecond
136+
137+
/// <inheritdoc cref="VolumeFlow.FromCubicMillimetersPerSecond(UnitsNet.QuantityValue)" />
138+
public static VolumeFlow CubicMillimetersPerSecond<T>(this T value) => VolumeFlow.FromCubicMillimetersPerSecond(Convert.ToDouble(value));
139+
140+
/// <inheritdoc cref="VolumeFlow.FromCubicMillimetersPerSecond(UnitsNet.QuantityValue)" />
141+
[Obsolete("Nullable type support has been deprecated and will be removed in a future release.")]
142+
public static VolumeFlow? CubicMillimetersPerSecond<T>(this T? value) where T : struct => VolumeFlow.FromCubicMillimetersPerSecond(value == null ? (double?)null : Convert.ToDouble(value.Value));
143+
144+
#endregion
145+
135146
#region CubicYardPerHour
136147

137148
/// <inheritdoc cref="VolumeFlow.FromCubicYardsPerHour(UnitsNet.QuantityValue)" />

UnitsNet/GeneratedCode/Quantities/VolumeFlow.NetFramework.g.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ public partial struct VolumeFlow : IComparable, IComparable<VolumeFlow>
134134
return cubicmeterspersecond.HasValue ? FromCubicMetersPerSecond(cubicmeterspersecond.Value) : default(VolumeFlow?);
135135
}
136136

137+
/// <summary>
138+
/// Get nullable VolumeFlow from nullable CubicMillimetersPerSecond.
139+
/// </summary>
140+
[Obsolete("Nullable type support is obsolete and will be removed in a future release.")]
141+
public static VolumeFlow? FromCubicMillimetersPerSecond(QuantityValue? cubicmillimeterspersecond)
142+
{
143+
return cubicmillimeterspersecond.HasValue ? FromCubicMillimetersPerSecond(cubicmillimeterspersecond.Value) : default(VolumeFlow?);
144+
}
145+
137146
/// <summary>
138147
/// Get nullable VolumeFlow from nullable CubicYardsPerHour.
139148
/// </summary>

UnitsNet/GeneratedCode/UnitSystem.Default.g.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4816,6 +4816,12 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
48164816
new AbbreviationsForCulture("en-US", "m³/s"),
48174817
new AbbreviationsForCulture("ru-RU", "м³/с"),
48184818
}),
4819+
new CulturesForEnumValue((int) VolumeFlowUnit.CubicMillimeterPerSecond,
4820+
new[]
4821+
{
4822+
new AbbreviationsForCulture("en-US", "mm³/s"),
4823+
new AbbreviationsForCulture("ru-RU", "мм³/с"),
4824+
}),
48194825
new CulturesForEnumValue((int) VolumeFlowUnit.CubicYardPerHour,
48204826
new[]
48214827
{

UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public enum VolumeFlowUnit
5353
CubicMeterPerHour,
5454
CubicMeterPerMinute,
5555
CubicMeterPerSecond,
56+
CubicMillimeterPerSecond,
5657
CubicYardPerHour,
5758
CubicYardPerMinute,
5859
CubicYardPerSecond,

0 commit comments

Comments
 (0)