-
Notifications
You must be signed in to change notification settings - Fork 407
Expand file tree
/
Copy pathPressure.g.cs
More file actions
745 lines (621 loc) · 41.8 KB
/
Pressure.g.cs
File metadata and controls
745 lines (621 loc) · 41.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by \generate-code.bat.
//
// Changes to this file will be lost when the code is regenerated.
// The build server regenerates the code before each build and a pre-build
// step will regenerate the code on each local build.
//
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities.
//
// </auto-generated>
//------------------------------------------------------------------------------
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
using System;
using UnitsNet.Units;
namespace UnitsNet
{
/// <inheritdoc />
/// <summary>
/// Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa).
/// </summary>
public struct Pressure
{
/// <summary>
/// The numeric value this quantity was constructed with.
/// </summary>
private readonly double _value;
/// <summary>
/// The unit this quantity was constructed with.
/// </summary>
private readonly PressureUnit _unit;
/// <summary>
/// The numeric value this quantity was constructed with.
/// </summary>
public double Value => _value;
/// <inheritdoc />
public PressureUnit Unit => _unit;
/// <summary>
/// Creates the quantity with the given numeric value and unit.
/// </summary>
/// <param name="value">The numeric value to construct this quantity with.</param>
/// <param name="unit">The unit representation to construct this quantity with.</param>
public Pressure(double value, PressureUnit unit)
{
_value = value;
_unit = unit;
}
/// <summary>
/// The base unit of Pressure, which is Second. All conversions go via this value.
/// </summary>
public static PressureUnit BaseUnit { get; } = PressureUnit.Pascal;
/// <summary>
/// Represents the largest possible value of Pressure.
/// </summary>
public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, BaseUnit);
/// <summary>
/// Represents the smallest possible value of Pressure.
/// </summary>
public static Pressure MinValue { get; } = new Pressure(double.MinValue, BaseUnit);
/// <summary>
/// Gets an instance of this quantity with a value of 0 in the base unit Second.
/// </summary>
public static Pressure Zero { get; } = new Pressure(0, BaseUnit);
#region Conversion Properties
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Atmosphere"/>
/// </summary>
public double Atmospheres => As(PressureUnit.Atmosphere);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Bar"/>
/// </summary>
public double Bars => As(PressureUnit.Bar);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Centibar"/>
/// </summary>
public double Centibars => As(PressureUnit.Centibar);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.CentimeterOfWaterColumn"/>
/// </summary>
public double CentimetersOfWaterColumn => As(PressureUnit.CentimeterOfWaterColumn);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Decapascal"/>
/// </summary>
public double Decapascals => As(PressureUnit.Decapascal);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Decibar"/>
/// </summary>
public double Decibars => As(PressureUnit.Decibar);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.DynePerSquareCentimeter"/>
/// </summary>
public double DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.FootOfHead"/>
/// </summary>
public double FeetOfHead => As(PressureUnit.FootOfHead);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Gigapascal"/>
/// </summary>
public double Gigapascals => As(PressureUnit.Gigapascal);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Hectopascal"/>
/// </summary>
public double Hectopascals => As(PressureUnit.Hectopascal);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.InchOfMercury"/>
/// </summary>
public double InchesOfMercury => As(PressureUnit.InchOfMercury);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.InchOfWaterColumn"/>
/// </summary>
public double InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Kilobar"/>
/// </summary>
public double Kilobars => As(PressureUnit.Kilobar);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.KilogramForcePerSquareCentimeter"/>
/// </summary>
public double KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.KilogramForcePerSquareMeter"/>
/// </summary>
public double KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.KilogramForcePerSquareMillimeter"/>
/// </summary>
public double KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.KilonewtonPerSquareCentimeter"/>
/// </summary>
public double KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.KilonewtonPerSquareMeter"/>
/// </summary>
public double KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.KilonewtonPerSquareMillimeter"/>
/// </summary>
public double KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Kilopascal"/>
/// </summary>
public double Kilopascals => As(PressureUnit.Kilopascal);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.KilopoundForcePerSquareFoot"/>
/// </summary>
public double KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.KilopoundForcePerSquareInch"/>
/// </summary>
public double KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.KilopoundForcePerSquareMil"/>
/// </summary>
public double KilopoundsForcePerSquareMil => As(PressureUnit.KilopoundForcePerSquareMil);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Megabar"/>
/// </summary>
public double Megabars => As(PressureUnit.Megabar);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.MeganewtonPerSquareMeter"/>
/// </summary>
public double MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Megapascal"/>
/// </summary>
public double Megapascals => As(PressureUnit.Megapascal);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.MeterOfHead"/>
/// </summary>
public double MetersOfHead => As(PressureUnit.MeterOfHead);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.MeterOfWaterColumn"/>
/// </summary>
public double MetersOfWaterColumn => As(PressureUnit.MeterOfWaterColumn);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Microbar"/>
/// </summary>
public double Microbars => As(PressureUnit.Microbar);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Micropascal"/>
/// </summary>
public double Micropascals => As(PressureUnit.Micropascal);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Millibar"/>
/// </summary>
public double Millibars => As(PressureUnit.Millibar);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.MilligramForcePerSquareFoot"/>
/// </summary>
public double MilligramsForcePerSquareFoot => As(PressureUnit.MilligramForcePerSquareFoot);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.MilligramForcePerSquareMeter"/>
/// </summary>
public double MilligramsForcePerSquareMeter => As(PressureUnit.MilligramForcePerSquareMeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.MillimeterOfMercury"/>
/// </summary>
public double MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.MillimeterOfWaterColumn"/>
/// </summary>
public double MillimetersOfWaterColumn => As(PressureUnit.MillimeterOfWaterColumn);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Millipascal"/>
/// </summary>
public double Millipascals => As(PressureUnit.Millipascal);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Millitorr"/>
/// </summary>
public double Millitorrs => As(PressureUnit.Millitorr);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.NewtonPerSquareCentimeter"/>
/// </summary>
public double NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.NewtonPerSquareMeter"/>
/// </summary>
public double NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.NewtonPerSquareMillimeter"/>
/// </summary>
public double NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Pascal"/>
/// </summary>
public double Pascals => As(PressureUnit.Pascal);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.PoundForcePerSquareFoot"/>
/// </summary>
public double PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.PoundForcePerSquareInch"/>
/// </summary>
public double PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.PoundForcePerSquareMil"/>
/// </summary>
public double PoundsForcePerSquareMil => As(PressureUnit.PoundForcePerSquareMil);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.PoundPerInchSecondSquared"/>
/// </summary>
public double PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.TechnicalAtmosphere"/>
/// </summary>
public double TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.TonneForcePerSquareCentimeter"/>
/// </summary>
public double TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.TonneForcePerSquareMeter"/>
/// </summary>
public double TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.TonneForcePerSquareMillimeter"/>
/// </summary>
public double TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter);
/// <summary>
/// Gets a <see cref="double"/> value of this quantity converted into <see cref="PressureUnit.Torr"/>
/// </summary>
public double Torrs => As(PressureUnit.Torr);
#endregion
#region Static Factory Methods
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Atmosphere"/>.
/// </summary>
public static Pressure FromAtmospheres(double atmospheres) => new Pressure(atmospheres, PressureUnit.Atmosphere);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Bar"/>.
/// </summary>
public static Pressure FromBars(double bars) => new Pressure(bars, PressureUnit.Bar);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Centibar"/>.
/// </summary>
public static Pressure FromCentibars(double centibars) => new Pressure(centibars, PressureUnit.Centibar);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.CentimeterOfWaterColumn"/>.
/// </summary>
public static Pressure FromCentimetersOfWaterColumn(double centimetersofwatercolumn) => new Pressure(centimetersofwatercolumn, PressureUnit.CentimeterOfWaterColumn);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Decapascal"/>.
/// </summary>
public static Pressure FromDecapascals(double decapascals) => new Pressure(decapascals, PressureUnit.Decapascal);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Decibar"/>.
/// </summary>
public static Pressure FromDecibars(double decibars) => new Pressure(decibars, PressureUnit.Decibar);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.DynePerSquareCentimeter"/>.
/// </summary>
public static Pressure FromDynesPerSquareCentimeter(double dynespersquarecentimeter) => new Pressure(dynespersquarecentimeter, PressureUnit.DynePerSquareCentimeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.FootOfHead"/>.
/// </summary>
public static Pressure FromFeetOfHead(double feetofhead) => new Pressure(feetofhead, PressureUnit.FootOfHead);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Gigapascal"/>.
/// </summary>
public static Pressure FromGigapascals(double gigapascals) => new Pressure(gigapascals, PressureUnit.Gigapascal);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Hectopascal"/>.
/// </summary>
public static Pressure FromHectopascals(double hectopascals) => new Pressure(hectopascals, PressureUnit.Hectopascal);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.InchOfMercury"/>.
/// </summary>
public static Pressure FromInchesOfMercury(double inchesofmercury) => new Pressure(inchesofmercury, PressureUnit.InchOfMercury);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.InchOfWaterColumn"/>.
/// </summary>
public static Pressure FromInchesOfWaterColumn(double inchesofwatercolumn) => new Pressure(inchesofwatercolumn, PressureUnit.InchOfWaterColumn);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Kilobar"/>.
/// </summary>
public static Pressure FromKilobars(double kilobars) => new Pressure(kilobars, PressureUnit.Kilobar);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.KilogramForcePerSquareCentimeter"/>.
/// </summary>
public static Pressure FromKilogramsForcePerSquareCentimeter(double kilogramsforcepersquarecentimeter) => new Pressure(kilogramsforcepersquarecentimeter, PressureUnit.KilogramForcePerSquareCentimeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.KilogramForcePerSquareMeter"/>.
/// </summary>
public static Pressure FromKilogramsForcePerSquareMeter(double kilogramsforcepersquaremeter) => new Pressure(kilogramsforcepersquaremeter, PressureUnit.KilogramForcePerSquareMeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.KilogramForcePerSquareMillimeter"/>.
/// </summary>
public static Pressure FromKilogramsForcePerSquareMillimeter(double kilogramsforcepersquaremillimeter) => new Pressure(kilogramsforcepersquaremillimeter, PressureUnit.KilogramForcePerSquareMillimeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.KilonewtonPerSquareCentimeter"/>.
/// </summary>
public static Pressure FromKilonewtonsPerSquareCentimeter(double kilonewtonspersquarecentimeter) => new Pressure(kilonewtonspersquarecentimeter, PressureUnit.KilonewtonPerSquareCentimeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.KilonewtonPerSquareMeter"/>.
/// </summary>
public static Pressure FromKilonewtonsPerSquareMeter(double kilonewtonspersquaremeter) => new Pressure(kilonewtonspersquaremeter, PressureUnit.KilonewtonPerSquareMeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.KilonewtonPerSquareMillimeter"/>.
/// </summary>
public static Pressure FromKilonewtonsPerSquareMillimeter(double kilonewtonspersquaremillimeter) => new Pressure(kilonewtonspersquaremillimeter, PressureUnit.KilonewtonPerSquareMillimeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Kilopascal"/>.
/// </summary>
public static Pressure FromKilopascals(double kilopascals) => new Pressure(kilopascals, PressureUnit.Kilopascal);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.KilopoundForcePerSquareFoot"/>.
/// </summary>
public static Pressure FromKilopoundsForcePerSquareFoot(double kilopoundsforcepersquarefoot) => new Pressure(kilopoundsforcepersquarefoot, PressureUnit.KilopoundForcePerSquareFoot);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.KilopoundForcePerSquareInch"/>.
/// </summary>
public static Pressure FromKilopoundsForcePerSquareInch(double kilopoundsforcepersquareinch) => new Pressure(kilopoundsforcepersquareinch, PressureUnit.KilopoundForcePerSquareInch);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.KilopoundForcePerSquareMil"/>.
/// </summary>
public static Pressure FromKilopoundsForcePerSquareMil(double kilopoundsforcepersquaremil) => new Pressure(kilopoundsforcepersquaremil, PressureUnit.KilopoundForcePerSquareMil);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Megabar"/>.
/// </summary>
public static Pressure FromMegabars(double megabars) => new Pressure(megabars, PressureUnit.Megabar);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.MeganewtonPerSquareMeter"/>.
/// </summary>
public static Pressure FromMeganewtonsPerSquareMeter(double meganewtonspersquaremeter) => new Pressure(meganewtonspersquaremeter, PressureUnit.MeganewtonPerSquareMeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Megapascal"/>.
/// </summary>
public static Pressure FromMegapascals(double megapascals) => new Pressure(megapascals, PressureUnit.Megapascal);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.MeterOfHead"/>.
/// </summary>
public static Pressure FromMetersOfHead(double metersofhead) => new Pressure(metersofhead, PressureUnit.MeterOfHead);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.MeterOfWaterColumn"/>.
/// </summary>
public static Pressure FromMetersOfWaterColumn(double metersofwatercolumn) => new Pressure(metersofwatercolumn, PressureUnit.MeterOfWaterColumn);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Microbar"/>.
/// </summary>
public static Pressure FromMicrobars(double microbars) => new Pressure(microbars, PressureUnit.Microbar);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Micropascal"/>.
/// </summary>
public static Pressure FromMicropascals(double micropascals) => new Pressure(micropascals, PressureUnit.Micropascal);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Millibar"/>.
/// </summary>
public static Pressure FromMillibars(double millibars) => new Pressure(millibars, PressureUnit.Millibar);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.MilligramForcePerSquareFoot"/>.
/// </summary>
public static Pressure FromMilligramsForcePerSquareFoot(double milligramsforcepersquarefoot) => new Pressure(milligramsforcepersquarefoot, PressureUnit.MilligramForcePerSquareFoot);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.MilligramForcePerSquareMeter"/>.
/// </summary>
public static Pressure FromMilligramsForcePerSquareMeter(double milligramsforcepersquaremeter) => new Pressure(milligramsforcepersquaremeter, PressureUnit.MilligramForcePerSquareMeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.MillimeterOfMercury"/>.
/// </summary>
public static Pressure FromMillimetersOfMercury(double millimetersofmercury) => new Pressure(millimetersofmercury, PressureUnit.MillimeterOfMercury);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.MillimeterOfWaterColumn"/>.
/// </summary>
public static Pressure FromMillimetersOfWaterColumn(double millimetersofwatercolumn) => new Pressure(millimetersofwatercolumn, PressureUnit.MillimeterOfWaterColumn);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Millipascal"/>.
/// </summary>
public static Pressure FromMillipascals(double millipascals) => new Pressure(millipascals, PressureUnit.Millipascal);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Millitorr"/>.
/// </summary>
public static Pressure FromMillitorrs(double millitorrs) => new Pressure(millitorrs, PressureUnit.Millitorr);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.NewtonPerSquareCentimeter"/>.
/// </summary>
public static Pressure FromNewtonsPerSquareCentimeter(double newtonspersquarecentimeter) => new Pressure(newtonspersquarecentimeter, PressureUnit.NewtonPerSquareCentimeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.NewtonPerSquareMeter"/>.
/// </summary>
public static Pressure FromNewtonsPerSquareMeter(double newtonspersquaremeter) => new Pressure(newtonspersquaremeter, PressureUnit.NewtonPerSquareMeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.NewtonPerSquareMillimeter"/>.
/// </summary>
public static Pressure FromNewtonsPerSquareMillimeter(double newtonspersquaremillimeter) => new Pressure(newtonspersquaremillimeter, PressureUnit.NewtonPerSquareMillimeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Pascal"/>.
/// </summary>
public static Pressure FromPascals(double pascals) => new Pressure(pascals, PressureUnit.Pascal);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.PoundForcePerSquareFoot"/>.
/// </summary>
public static Pressure FromPoundsForcePerSquareFoot(double poundsforcepersquarefoot) => new Pressure(poundsforcepersquarefoot, PressureUnit.PoundForcePerSquareFoot);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.PoundForcePerSquareInch"/>.
/// </summary>
public static Pressure FromPoundsForcePerSquareInch(double poundsforcepersquareinch) => new Pressure(poundsforcepersquareinch, PressureUnit.PoundForcePerSquareInch);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.PoundForcePerSquareMil"/>.
/// </summary>
public static Pressure FromPoundsForcePerSquareMil(double poundsforcepersquaremil) => new Pressure(poundsforcepersquaremil, PressureUnit.PoundForcePerSquareMil);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.PoundPerInchSecondSquared"/>.
/// </summary>
public static Pressure FromPoundsPerInchSecondSquared(double poundsperinchsecondsquared) => new Pressure(poundsperinchsecondsquared, PressureUnit.PoundPerInchSecondSquared);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.TechnicalAtmosphere"/>.
/// </summary>
public static Pressure FromTechnicalAtmospheres(double technicalatmospheres) => new Pressure(technicalatmospheres, PressureUnit.TechnicalAtmosphere);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.TonneForcePerSquareCentimeter"/>.
/// </summary>
public static Pressure FromTonnesForcePerSquareCentimeter(double tonnesforcepersquarecentimeter) => new Pressure(tonnesforcepersquarecentimeter, PressureUnit.TonneForcePerSquareCentimeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.TonneForcePerSquareMeter"/>.
/// </summary>
public static Pressure FromTonnesForcePerSquareMeter(double tonnesforcepersquaremeter) => new Pressure(tonnesforcepersquaremeter, PressureUnit.TonneForcePerSquareMeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.TonneForcePerSquareMillimeter"/>.
/// </summary>
public static Pressure FromTonnesForcePerSquareMillimeter(double tonnesforcepersquaremillimeter) => new Pressure(tonnesforcepersquaremillimeter, PressureUnit.TonneForcePerSquareMillimeter);
/// <summary>
/// Creates a <see cref="Pressure"/> from <see cref="PressureUnit.Torr"/>.
/// </summary>
public static Pressure FromTorrs(double torrs) => new Pressure(torrs, PressureUnit.Torr);
/// <summary>
/// Dynamically convert from value and unit enum <see cref="PressureUnit" /> to <see cref="Pressure" />.
/// </summary>
/// <param name="value">Value to convert from.</param>
/// <param name="fromUnit">Unit to convert from.</param>
/// <returns>Pressure unit value.</returns>
public static Pressure From(double value, PressureUnit fromUnit)
{
return new Pressure(value, fromUnit);
}
#endregion
#region Conversion Methods
/// <summary>
/// Convert to the unit representation <paramref name="unit" />.
/// </summary>
/// <returns>Value converted to the specified unit.</returns>
public double As(PressureUnit unit) => GetValueAs(unit);
/// <summary>
/// Converts this Pressure to another Pressure with the unit representation <paramref name="unit" />.
/// </summary>
/// <returns>A Pressure with the specified unit.</returns>
public Pressure ToUnit(PressureUnit unit)
{
var convertedValue = GetValueAs(unit);
return new Pressure(convertedValue, unit);
}
/// <summary>
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
/// </summary>
/// <returns>The value in the base unit representation.</returns>
private double GetValueInBaseUnit()
{
return Unit switch
{
PressureUnit.Atmosphere => _value * 1.01325 * 1e5,
PressureUnit.Bar => _value * 1e5,
PressureUnit.Centibar => (_value * 1e5) * 1e-2d,
PressureUnit.CentimeterOfWaterColumn => (_value * 9.80665e3) * 1e-2d,
PressureUnit.Decapascal => (_value) * 1e1d,
PressureUnit.Decibar => (_value * 1e5) * 1e-1d,
PressureUnit.DynePerSquareCentimeter => _value * 1.0e-1,
PressureUnit.FootOfHead => _value * 9804.139432 * 0.3048,
PressureUnit.Gigapascal => (_value) * 1e9d,
PressureUnit.Hectopascal => (_value) * 1e2d,
PressureUnit.InchOfMercury => _value * 2.54e1 * 133.322387415,
PressureUnit.InchOfWaterColumn => _value * 2.54e-2 * 9.80665e3,
PressureUnit.Kilobar => (_value * 1e5) * 1e3d,
PressureUnit.KilogramForcePerSquareCentimeter => _value * 9.80665e4,
PressureUnit.KilogramForcePerSquareMeter => _value * 9.80665,
PressureUnit.KilogramForcePerSquareMillimeter => _value * 9.80665e6,
PressureUnit.KilonewtonPerSquareCentimeter => (_value * 1e4) * 1e3d,
PressureUnit.KilonewtonPerSquareMeter => (_value) * 1e3d,
PressureUnit.KilonewtonPerSquareMillimeter => (_value * 1e6) * 1e3d,
PressureUnit.Kilopascal => (_value) * 1e3d,
PressureUnit.KilopoundForcePerSquareFoot => (_value * 4.4482216152605 / 9.290304e-2) * 1e3d,
PressureUnit.KilopoundForcePerSquareInch => (_value * 4.4482216152605 / 0.00064516) * 1e3d,
PressureUnit.KilopoundForcePerSquareMil => (_value * 4.4482216152605 / (2.54e-5 * 2.54e-5)) * 1e3d,
PressureUnit.Megabar => (_value * 1e5) * 1e6d,
PressureUnit.MeganewtonPerSquareMeter => (_value) * 1e6d,
PressureUnit.Megapascal => (_value) * 1e6d,
PressureUnit.MeterOfHead => _value * 9804.139432,
PressureUnit.MeterOfWaterColumn => _value * 9.80665e3,
PressureUnit.Microbar => (_value * 1e5) * 1e-6d,
PressureUnit.Micropascal => (_value) * 1e-6d,
PressureUnit.Millibar => (_value * 1e5) * 1e-3d,
PressureUnit.MilligramForcePerSquareFoot => _value * 9.80665e-6 / 9.290304e-2,
PressureUnit.MilligramForcePerSquareMeter => _value * 9.80665e-6,
PressureUnit.MillimeterOfMercury => _value * 133.322387415,
PressureUnit.MillimeterOfWaterColumn => (_value * 9.80665e3) * 1e-3d,
PressureUnit.Millipascal => (_value) * 1e-3d,
PressureUnit.Millitorr => (_value * 101325 / 760) * 1e-3d,
PressureUnit.NewtonPerSquareCentimeter => _value * 1e4,
PressureUnit.NewtonPerSquareMeter => _value,
PressureUnit.NewtonPerSquareMillimeter => _value * 1e6,
PressureUnit.Pascal => _value,
PressureUnit.PoundForcePerSquareFoot => _value * 4.4482216152605 / 9.290304e-2,
PressureUnit.PoundForcePerSquareInch => _value * 4.4482216152605 / 0.00064516,
PressureUnit.PoundForcePerSquareMil => _value * 4.4482216152605 / (2.54e-5 * 2.54e-5),
PressureUnit.PoundPerInchSecondSquared => _value * (4.4482216152605 / 0.00064516) / 386.0886,
PressureUnit.TechnicalAtmosphere => _value * 9.80665e4,
PressureUnit.TonneForcePerSquareCentimeter => _value * 9.80665e7,
PressureUnit.TonneForcePerSquareMeter => _value * 9.80665e3,
PressureUnit.TonneForcePerSquareMillimeter => _value * 9.80665e9,
PressureUnit.Torr => _value * 101325 / 760,
_ => throw new NotImplementedException($"Can't convert {Unit} to base units.")
};
}
private double GetValueAs(PressureUnit unit)
{
if (Unit == unit)
return _value;
var baseUnitValue = GetValueInBaseUnit();
return unit switch
{
PressureUnit.Atmosphere => baseUnitValue / (1.01325 * 1e5),
PressureUnit.Bar => baseUnitValue / 1e5,
PressureUnit.Centibar => (baseUnitValue / 1e5) / 1e-2d,
PressureUnit.CentimeterOfWaterColumn => (baseUnitValue / 9.80665e3) / 1e-2d,
PressureUnit.Decapascal => (baseUnitValue) / 1e1d,
PressureUnit.Decibar => (baseUnitValue / 1e5) / 1e-1d,
PressureUnit.DynePerSquareCentimeter => baseUnitValue / 1.0e-1,
PressureUnit.FootOfHead => baseUnitValue / (9804.139432 * 0.3048),
PressureUnit.Gigapascal => (baseUnitValue) / 1e9d,
PressureUnit.Hectopascal => (baseUnitValue) / 1e2d,
PressureUnit.InchOfMercury => baseUnitValue / (2.54e1 * 133.322387415),
PressureUnit.InchOfWaterColumn => baseUnitValue / (2.54e-2 * 9.80665e3),
PressureUnit.Kilobar => (baseUnitValue / 1e5) / 1e3d,
PressureUnit.KilogramForcePerSquareCentimeter => baseUnitValue / 9.80665e4,
PressureUnit.KilogramForcePerSquareMeter => baseUnitValue / 9.80665,
PressureUnit.KilogramForcePerSquareMillimeter => baseUnitValue / 9.80665e6,
PressureUnit.KilonewtonPerSquareCentimeter => (baseUnitValue / 1e4) / 1e3d,
PressureUnit.KilonewtonPerSquareMeter => (baseUnitValue) / 1e3d,
PressureUnit.KilonewtonPerSquareMillimeter => (baseUnitValue / 1e6) / 1e3d,
PressureUnit.Kilopascal => (baseUnitValue) / 1e3d,
PressureUnit.KilopoundForcePerSquareFoot => (baseUnitValue * 9.290304e-2 / 4.4482216152605) / 1e3d,
PressureUnit.KilopoundForcePerSquareInch => (baseUnitValue * 0.00064516 / 4.4482216152605) / 1e3d,
PressureUnit.KilopoundForcePerSquareMil => (baseUnitValue * (2.54e-5 * 2.54e-5) / 4.4482216152605) / 1e3d,
PressureUnit.Megabar => (baseUnitValue / 1e5) / 1e6d,
PressureUnit.MeganewtonPerSquareMeter => (baseUnitValue) / 1e6d,
PressureUnit.Megapascal => (baseUnitValue) / 1e6d,
PressureUnit.MeterOfHead => baseUnitValue / 9804.139432,
PressureUnit.MeterOfWaterColumn => baseUnitValue / 9.80665e3,
PressureUnit.Microbar => (baseUnitValue / 1e5) / 1e-6d,
PressureUnit.Micropascal => (baseUnitValue) / 1e-6d,
PressureUnit.Millibar => (baseUnitValue / 1e5) / 1e-3d,
PressureUnit.MilligramForcePerSquareFoot => baseUnitValue / 9.80665e-6 * 9.290304e-2,
PressureUnit.MilligramForcePerSquareMeter => baseUnitValue / 9.80665e-6,
PressureUnit.MillimeterOfMercury => baseUnitValue / 133.322387415,
PressureUnit.MillimeterOfWaterColumn => (baseUnitValue / 9.80665e3) / 1e-3d,
PressureUnit.Millipascal => (baseUnitValue) / 1e-3d,
PressureUnit.Millitorr => (baseUnitValue * 760 / 101325) / 1e-3d,
PressureUnit.NewtonPerSquareCentimeter => baseUnitValue / 1e4,
PressureUnit.NewtonPerSquareMeter => baseUnitValue,
PressureUnit.NewtonPerSquareMillimeter => baseUnitValue / 1e6,
PressureUnit.Pascal => baseUnitValue,
PressureUnit.PoundForcePerSquareFoot => baseUnitValue * 9.290304e-2 / 4.4482216152605,
PressureUnit.PoundForcePerSquareInch => baseUnitValue * 0.00064516 / 4.4482216152605,
PressureUnit.PoundForcePerSquareMil => baseUnitValue * (2.54e-5 * 2.54e-5) / 4.4482216152605,
PressureUnit.PoundPerInchSecondSquared => baseUnitValue * 386.0886 / (4.4482216152605 / 0.00064516),
PressureUnit.TechnicalAtmosphere => baseUnitValue / 9.80665e4,
PressureUnit.TonneForcePerSquareCentimeter => baseUnitValue / 9.80665e7,
PressureUnit.TonneForcePerSquareMeter => baseUnitValue / 9.80665e3,
PressureUnit.TonneForcePerSquareMillimeter => baseUnitValue / 9.80665e9,
PressureUnit.Torr => baseUnitValue * 760 / 101325,
_ => throw new NotImplementedException($"Can't convert {Unit} to {unit}.")
};
}
#endregion
}
}