Skip to content

Commit aa9a99a

Browse files
Ferit Tunçerangularsen
Ferit Tunçer
authored andcommitted
Add micropascalseconds (#314)
1 parent 0a585b8 commit aa9a99a

File tree

9 files changed

+178
-17
lines changed

9 files changed

+178
-17
lines changed

UnitsNet.Tests/CustomCode/DynamicViscosityTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace UnitsNet.Tests.CustomCode
2828
public class DynamicViscosityTests : DynamicViscosityTestsBase
2929
{
3030
protected override double CentipoiseInOneNewtonSecondPerMeterSquared => 1e3;
31+
protected override double MicropascalSecondsInOneNewtonSecondPerMeterSquared => 1e6;
3132
protected override double MillipascalSecondsInOneNewtonSecondPerMeterSquared => 1e3;
3233
protected override double NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared => 1;
3334
protected override double PascalSecondsInOneNewtonSecondPerMeterSquared => 1;

UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ namespace UnitsNet.Tests
5353
public abstract partial class DynamicViscosityTestsBase
5454
{
5555
protected abstract double CentipoiseInOneNewtonSecondPerMeterSquared { get; }
56+
protected abstract double MicropascalSecondsInOneNewtonSecondPerMeterSquared { get; }
5657
protected abstract double MillipascalSecondsInOneNewtonSecondPerMeterSquared { get; }
5758
protected abstract double NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared { get; }
5859
protected abstract double PascalSecondsInOneNewtonSecondPerMeterSquared { get; }
5960
protected abstract double PoiseInOneNewtonSecondPerMeterSquared { get; }
6061

6162
// ReSharper disable VirtualMemberNeverOverriden.Global
6263
protected virtual double CentipoiseTolerance { get { return 1e-5; } }
64+
protected virtual double MicropascalSecondsTolerance { get { return 1e-5; } }
6365
protected virtual double MillipascalSecondsTolerance { get { return 1e-5; } }
6466
protected virtual double NewtonSecondsPerMeterSquaredTolerance { get { return 1e-5; } }
6567
protected virtual double PascalSecondsTolerance { get { return 1e-5; } }
@@ -71,6 +73,7 @@ public void NewtonSecondPerMeterSquaredToDynamicViscosityUnits()
7173
{
7274
DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
7375
AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.Centipoise, CentipoiseTolerance);
76+
AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.MicropascalSeconds, MicropascalSecondsTolerance);
7477
AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.MillipascalSeconds, MillipascalSecondsTolerance);
7578
AssertEx.EqualTolerance(NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
7679
AssertEx.EqualTolerance(PascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.PascalSeconds, PascalSecondsTolerance);
@@ -81,6 +84,7 @@ public void NewtonSecondPerMeterSquaredToDynamicViscosityUnits()
8184
public void FromValueAndUnit()
8285
{
8386
AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.Centipoise).Centipoise, CentipoiseTolerance);
87+
AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.MicropascalSecond).MicropascalSeconds, MicropascalSecondsTolerance);
8488
AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.MillipascalSecond).MillipascalSeconds, MillipascalSecondsTolerance);
8589
AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.NewtonSecondPerMeterSquared).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
8690
AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.PascalSecond).PascalSeconds, PascalSecondsTolerance);
@@ -92,6 +96,7 @@ public void As()
9296
{
9397
var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
9498
AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.Centipoise), CentipoiseTolerance);
99+
AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.MicropascalSecond), MicropascalSecondsTolerance);
95100
AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.MillipascalSecond), MillipascalSecondsTolerance);
96101
AssertEx.EqualTolerance(NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.NewtonSecondPerMeterSquared), NewtonSecondsPerMeterSquaredTolerance);
97102
AssertEx.EqualTolerance(PascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.PascalSecond), PascalSecondsTolerance);
@@ -103,6 +108,7 @@ public void ConversionRoundTrip()
103108
{
104109
DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
105110
AssertEx.EqualTolerance(1, DynamicViscosity.FromCentipoise(newtonsecondpermetersquared.Centipoise).NewtonSecondsPerMeterSquared, CentipoiseTolerance);
111+
AssertEx.EqualTolerance(1, DynamicViscosity.FromMicropascalSeconds(newtonsecondpermetersquared.MicropascalSeconds).NewtonSecondsPerMeterSquared, MicropascalSecondsTolerance);
106112
AssertEx.EqualTolerance(1, DynamicViscosity.FromMillipascalSeconds(newtonsecondpermetersquared.MillipascalSeconds).NewtonSecondsPerMeterSquared, MillipascalSecondsTolerance);
107113
AssertEx.EqualTolerance(1, DynamicViscosity.FromNewtonSecondsPerMeterSquared(newtonsecondpermetersquared.NewtonSecondsPerMeterSquared).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
108114
AssertEx.EqualTolerance(1, DynamicViscosity.FromPascalSeconds(newtonsecondpermetersquared.PascalSeconds).NewtonSecondsPerMeterSquared, PascalSecondsTolerance);

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,40 @@ public static class NumberToDynamicViscosityExtensions
7878

7979
#endregion
8080

81+
#region MicropascalSecond
82+
83+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double)"/>
84+
public static DynamicViscosity MicropascalSeconds(this int value) => DynamicViscosity.FromMicropascalSeconds(value);
85+
86+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double?)"/>
87+
public static DynamicViscosity? MicropascalSeconds(this int? value) => DynamicViscosity.FromMicropascalSeconds(value);
88+
89+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double)"/>
90+
public static DynamicViscosity MicropascalSeconds(this long value) => DynamicViscosity.FromMicropascalSeconds(value);
91+
92+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double?)"/>
93+
public static DynamicViscosity? MicropascalSeconds(this long? value) => DynamicViscosity.FromMicropascalSeconds(value);
94+
95+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double)"/>
96+
public static DynamicViscosity MicropascalSeconds(this double value) => DynamicViscosity.FromMicropascalSeconds(value);
97+
98+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double?)"/>
99+
public static DynamicViscosity? MicropascalSeconds(this double? value) => DynamicViscosity.FromMicropascalSeconds(value);
100+
101+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double)"/>
102+
public static DynamicViscosity MicropascalSeconds(this float value) => DynamicViscosity.FromMicropascalSeconds(value);
103+
104+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double?)"/>
105+
public static DynamicViscosity? MicropascalSeconds(this float? value) => DynamicViscosity.FromMicropascalSeconds(value);
106+
107+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double)"/>
108+
public static DynamicViscosity MicropascalSeconds(this decimal value) => DynamicViscosity.FromMicropascalSeconds(Convert.ToDouble(value));
109+
110+
/// <inheritdoc cref="DynamicViscosity.FromMicropascalSeconds(double?)"/>
111+
public static DynamicViscosity? MicropascalSeconds(this decimal? value) => DynamicViscosity.FromMicropascalSeconds(value == null ? (double?)null : Convert.ToDouble(value.Value));
112+
113+
#endregion
114+
81115
#region MillipascalSecond
82116

83117
/// <inheritdoc cref="DynamicViscosity.FromMillipascalSeconds(double)"/>

UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ public double Centipoise
137137
get { return (_newtonSecondsPerMeterSquared*10) / 1e-2d; }
138138
}
139139

140+
/// <summary>
141+
/// Get DynamicViscosity in MicropascalSeconds.
142+
/// </summary>
143+
public double MicropascalSeconds
144+
{
145+
get { return (_newtonSecondsPerMeterSquared) / 1e-6d; }
146+
}
147+
140148
/// <summary>
141149
/// Get DynamicViscosity in MillipascalSeconds.
142150
/// </summary>
@@ -216,6 +224,44 @@ public static DynamicViscosity FromCentipoise(decimal centipoise)
216224
}
217225
#endif
218226

227+
/// <summary>
228+
/// Get DynamicViscosity from MicropascalSeconds.
229+
/// </summary>
230+
#if NETFX_CORE
231+
[Windows.Foundation.Metadata.DefaultOverload]
232+
#endif
233+
public static DynamicViscosity FromMicropascalSeconds(double micropascalseconds)
234+
{
235+
return new DynamicViscosity((micropascalseconds) * 1e-6d);
236+
}
237+
238+
/// <summary>
239+
/// Get DynamicViscosity from MicropascalSeconds.
240+
/// </summary>
241+
public static DynamicViscosity FromMicropascalSeconds(int micropascalseconds)
242+
{
243+
return new DynamicViscosity((micropascalseconds) * 1e-6d);
244+
}
245+
246+
/// <summary>
247+
/// Get DynamicViscosity from MicropascalSeconds.
248+
/// </summary>
249+
public static DynamicViscosity FromMicropascalSeconds(long micropascalseconds)
250+
{
251+
return new DynamicViscosity((micropascalseconds) * 1e-6d);
252+
}
253+
254+
// Windows Runtime Component does not support decimal type
255+
#if !WINDOWS_UWP
256+
/// <summary>
257+
/// Get DynamicViscosity from MicropascalSeconds of type decimal.
258+
/// </summary>
259+
public static DynamicViscosity FromMicropascalSeconds(decimal micropascalseconds)
260+
{
261+
return new DynamicViscosity((Convert.ToDouble(micropascalseconds)) * 1e-6d);
262+
}
263+
#endif
264+
219265
/// <summary>
220266
/// Get DynamicViscosity from MillipascalSeconds.
221267
/// </summary>
@@ -430,6 +476,66 @@ public static DynamicViscosity FromPoise(decimal poise)
430476
}
431477
}
432478

479+
/// <summary>
480+
/// Get nullable DynamicViscosity from nullable MicropascalSeconds.
481+
/// </summary>
482+
public static DynamicViscosity? FromMicropascalSeconds(double? micropascalseconds)
483+
{
484+
if (micropascalseconds.HasValue)
485+
{
486+
return FromMicropascalSeconds(micropascalseconds.Value);
487+
}
488+
else
489+
{
490+
return null;
491+
}
492+
}
493+
494+
/// <summary>
495+
/// Get nullable DynamicViscosity from nullable MicropascalSeconds.
496+
/// </summary>
497+
public static DynamicViscosity? FromMicropascalSeconds(int? micropascalseconds)
498+
{
499+
if (micropascalseconds.HasValue)
500+
{
501+
return FromMicropascalSeconds(micropascalseconds.Value);
502+
}
503+
else
504+
{
505+
return null;
506+
}
507+
}
508+
509+
/// <summary>
510+
/// Get nullable DynamicViscosity from nullable MicropascalSeconds.
511+
/// </summary>
512+
public static DynamicViscosity? FromMicropascalSeconds(long? micropascalseconds)
513+
{
514+
if (micropascalseconds.HasValue)
515+
{
516+
return FromMicropascalSeconds(micropascalseconds.Value);
517+
}
518+
else
519+
{
520+
return null;
521+
}
522+
}
523+
524+
/// <summary>
525+
/// Get nullable DynamicViscosity from MicropascalSeconds of type decimal.
526+
/// </summary>
527+
public static DynamicViscosity? FromMicropascalSeconds(decimal? micropascalseconds)
528+
{
529+
if (micropascalseconds.HasValue)
530+
{
531+
return FromMicropascalSeconds(micropascalseconds.Value);
532+
}
533+
else
534+
{
535+
return null;
536+
}
537+
}
538+
433539
/// <summary>
434540
/// Get nullable DynamicViscosity from nullable MillipascalSeconds.
435541
/// </summary>
@@ -684,6 +790,8 @@ public static DynamicViscosity From(double val, DynamicViscosityUnit fromUnit)
684790
{
685791
case DynamicViscosityUnit.Centipoise:
686792
return FromCentipoise(val);
793+
case DynamicViscosityUnit.MicropascalSecond:
794+
return FromMicropascalSeconds(val);
687795
case DynamicViscosityUnit.MillipascalSecond:
688796
return FromMillipascalSeconds(val);
689797
case DynamicViscosityUnit.NewtonSecondPerMeterSquared:
@@ -716,6 +824,8 @@ public static DynamicViscosity From(double val, DynamicViscosityUnit fromUnit)
716824
{
717825
case DynamicViscosityUnit.Centipoise:
718826
return FromCentipoise(value.Value);
827+
case DynamicViscosityUnit.MicropascalSecond:
828+
return FromMicropascalSeconds(value.Value);
719829
case DynamicViscosityUnit.MillipascalSecond:
720830
return FromMillipascalSeconds(value.Value);
721831
case DynamicViscosityUnit.NewtonSecondPerMeterSquared:
@@ -883,6 +993,8 @@ public double As(DynamicViscosityUnit unit)
883993
{
884994
case DynamicViscosityUnit.Centipoise:
885995
return Centipoise;
996+
case DynamicViscosityUnit.MicropascalSecond:
997+
return MicropascalSeconds;
886998
case DynamicViscosityUnit.MillipascalSecond:
887999
return MillipascalSeconds;
8881000
case DynamicViscosityUnit.NewtonSecondPerMeterSquared:

UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
namespace UnitsNet
5757
{
5858
/// <summary>
59-
///
59+
/// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin.
6060
/// </summary>
6161
// ReSharper disable once PartialTypeWithSinglePart
6262

UnitsNet/GeneratedCode/QuantityType.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public enum QuantityType
7979
Mass,
8080
MassFlow,
8181
MassMomentOfInertia,
82-
MolarEntropy,
8382
MolarEnergy,
83+
MolarEntropy,
8484
Molarity,
8585
MolarMass,
8686
Power,

UnitsNet/GeneratedCode/UnitSystem.Default.g.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,11 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
667667
{
668668
new AbbreviationsForCulture("en-US", "cP"),
669669
}),
670+
new CulturesForEnumValue((int) DynamicViscosityUnit.MicropascalSecond,
671+
new[]
672+
{
673+
new AbbreviationsForCulture("en-US", "µPaS"),
674+
}),
670675
new CulturesForEnumValue((int) DynamicViscosityUnit.MillipascalSecond,
671676
new[]
672677
{
@@ -1953,40 +1958,42 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
19531958
new AbbreviationsForCulture("en-US", "t·mm²"),
19541959
}),
19551960
}),
1956-
new UnitLocalization(typeof (MolarEntropyUnit),
1961+
new UnitLocalization(typeof (MolarEnergyUnit),
19571962
new[]
19581963
{
1959-
new CulturesForEnumValue((int) MolarEntropyUnit.JoulePerMoleKelvin,
1964+
new CulturesForEnumValue((int) MolarEnergyUnit.JoulePerMole,
19601965
new[]
19611966
{
1962-
new AbbreviationsForCulture("en-US", "J/(mol*K)"),
1967+
new AbbreviationsForCulture("en-US", "J/mol"),
19631968
}),
1964-
new CulturesForEnumValue((int) MolarEntropyUnit.KilojoulePerMoleKelvin,
1969+
new CulturesForEnumValue((int) MolarEnergyUnit.KilojoulePerMole,
19651970
new[]
19661971
{
1967-
new AbbreviationsForCulture("en-US", "kJ/(mol*K)"),
1972+
new AbbreviationsForCulture("en-US", "kJ/mol"),
19681973
}),
1969-
new CulturesForEnumValue((int) MolarEntropyUnit.MegajoulePerMoleKelvin,
1974+
new CulturesForEnumValue((int) MolarEnergyUnit.MegajoulePerMole,
19701975
new[]
19711976
{
1972-
new AbbreviationsForCulture("en-US", "MJ/(mol*K)"),
1973-
new UnitLocalization(typeof (MolarEnergyUnit),
1977+
new AbbreviationsForCulture("en-US", "MJ/mol"),
1978+
}),
1979+
}),
1980+
new UnitLocalization(typeof (MolarEntropyUnit),
19741981
new[]
19751982
{
1976-
new CulturesForEnumValue((int) MolarEnergyUnit.JoulePerMole,
1983+
new CulturesForEnumValue((int) MolarEntropyUnit.JoulePerMoleKelvin,
19771984
new[]
19781985
{
1979-
new AbbreviationsForCulture("en-US", "J/mol"),
1986+
new AbbreviationsForCulture("en-US", "J/(mol*K)"),
19801987
}),
1981-
new CulturesForEnumValue((int) MolarEnergyUnit.KilojoulePerMole,
1988+
new CulturesForEnumValue((int) MolarEntropyUnit.KilojoulePerMoleKelvin,
19821989
new[]
19831990
{
1984-
new AbbreviationsForCulture("en-US", "kJ/mol"),
1991+
new AbbreviationsForCulture("en-US", "kJ/(mol*K)"),
19851992
}),
1986-
new CulturesForEnumValue((int) MolarEnergyUnit.MegajoulePerMole,
1993+
new CulturesForEnumValue((int) MolarEntropyUnit.MegajoulePerMoleKelvin,
19871994
new[]
19881995
{
1989-
new AbbreviationsForCulture("en-US", "MJ/mol"),
1996+
new AbbreviationsForCulture("en-US", "MJ/(mol*K)"),
19901997
}),
19911998
}),
19921999
new UnitLocalization(typeof (MolarityUnit),

UnitsNet/GeneratedCode/Units/DynamicViscosityUnit.g.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public enum DynamicViscosityUnit
4343
{
4444
Undefined = 0,
4545
Centipoise,
46+
MicropascalSecond,
4647
MillipascalSecond,
4748
NewtonSecondPerMeterSquared,
4849
PascalSecond,

UnitsNet/UnitDefinitions/DynamicViscosity.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"PluralName": "PascalSeconds",
2222
"FromUnitToBaseFunc": "x",
2323
"FromBaseToUnitFunc": "x",
24-
"Prefixes": [ "Milli" ],
24+
"Prefixes": [ "Milli", "Micro" ],
2525
"Localization": [
2626
{
2727
"Culture": "en-US",

0 commit comments

Comments
 (0)