-
Notifications
You must be signed in to change notification settings - Fork 2
/
FluidDynamics.h
1168 lines (1082 loc) · 47.1 KB
/
FluidDynamics.h
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
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Created by Ryan.Zurrin001 on 12/16/2021.
//
#ifndef PHYSICSFORMULA_FLUIDDYNAMICS_H
#define PHYSICSFORMULA_FLUIDDYNAMICS_H
/**
* @class FluidDynamics
* @details driver class for solving complex physics problems
* @author Ryan Zurrin
* @date 12/17/2020
*/
#include <iostream>
#include <cmath>
#include "Constants.h"
using namespace std;
static int fluidDynamic_objectCount = 0;
static struct FlowRateConversions
{
static ld litersPerSecond_to_cubicMetersPerSecond(const ld lps)
{
return lps * .001; // m^3/sec
}
static ld litersPerSecond_to_cubicMetersPerMin(const ld lps)
{
return lps * .06; // m^3/min
}
static ld literMin_to_cubicCentimeterSecond(const ld ltrMin)
{
return ltrMin * 16.6667; // cm^3/s
}
static ld cubicCentimeterSecond_to_literMin(const ld ccms)
{
return ccms / 16.6667; // L/min
}
static ld literMin_to_cubicMeterSecond(const ld ltrMin)
{
return ltrMin * 1.6667 * pow(10.0, -5.0); // m^3/s
}
static ld cubicMeterSecond_to_literMin(const ld cms)
{
return cms / 1.6667 * pow(10.0, -5.0); // L/min
}
}flow_rate_converter;
static struct ViscosityCoefficients
{
const ld air_0C = 0.0171; //mPa*s
const ld air_20C = 0.0181; //mPa*s
const ld air_40C = 0.0190; //mPa*s
const ld air_100C = 0.00974; //mPa*s
const ld ammonia_20C = 0.00974; // mPa*s
const ld carbonDioxide_20C = 0.0147; //mPa*s
const ld helium_20C = 0.0196; // mPa*s
const ld hydrogen_0C = .0090; // mPa*s
const ld mercury_20C = 0.0450; // mPa*s
const ld oxygen_20C = .0203; // mPa*s
const ld steam_100C = .0130; // mPa*s
const ld water_0C = 1.792; // mPa*s
const ld water_20C = 1.002; // mPa*s
const ld water_37C = 0.6947; // mPa*s
const ld water_40C = 0.653; // mPa*s
const ld water_100C = 0.282; // mPa*s
const ld wholeBlood_20C = 3.015; // mPa*s
const ld wholeBlood_37C = 2.084; // mPa*s
const ld bloodPlasma_20C = 1.810; // mPa*s
const ld bloodPlasma_37C = 1.257; // mPa*s
const ld ethylAlcohol_20C = 1.20; // mPa*s
const ld methanol_20C = 0.584; // mPa*s
const ld oil_heavyMachine_20C = 660.0; // mPa*s
const ld oil_motorSAE10_30C = 200.0; // mPa*s
const ld oil_olive_20C = 138.0; // mPa*s
const ld glycerin_20C = 1500; // mPa*s
ld honey_20C = 2000; // mPa*s
/// <summary>
/// Sets the honey_20C viscosity which can be between 2000 and 10000.
/// </summary>
/// <param name="n">The argument.</param>
void setHoney(ld n)
{
if(n >=2000 && n <= 10000)
{
honey_20C = n;
}
else
honey_20C = 2000;
}
ld mapleSyrup_20C = 2000; //mPa*s
/// <summary>
/// Sets the maple syrup between 2000 and 3000.
/// </summary>
/// <param name="n">The n.</param>
void setMapleSyrup(ld n)
{
if (n >= 2000 && n <= 3000)
{
mapleSyrup_20C = n;
}
else
mapleSyrup_20C = 2000;
}
const ld milk_20C = 3.0; // //mPa*s
const ld oil_corn_20C = 65.0; //mPa*s
}viscosity_coefficients;
static struct DiffusionConstants
{
const ld HYDROGEN_AIR = 6.4 * pow(10.0, -5.0); // .000064
const ld OXYGEN_AIR = 1.8 * pow(10.0, -5.0); //.000018
const ld OXYGEN_WATER = 1.0 * pow(10.0, -9.0); // .000000001
const ld GLUCOSE_WATER = 6.7 * pow(10.0, -10.0); // .00000000067
const ld HEMOGLOBIN_WATER = 6.9 * pow(10.0, -11.0); //.000000000069
const ld DNA_WATER = 1.3 * pow(10.0, -12.0); // .0000000000013
}diffusion_constants;
class FluidDynamics
{
private:
static void countIncrease() { fluidDynamic_objectCount += 1; }
static void countDecrease() { fluidDynamic_objectCount -= 1; }
public:
FluidDynamics* _fluidDynamicPtr;
FluidDynamics()
{
_fluidDynamicPtr = nullptr;
countIncrease();
}
/**
* @brief copy constructor
*/
FluidDynamics(const FluidDynamics& t)
{
_fluidDynamicPtr = t._fluidDynamicPtr;
countIncrease();
}
/**
* #brief move constructor
*/
FluidDynamics(FluidDynamics&& t) noexcept
{
_fluidDynamicPtr = t._fluidDynamicPtr;
countIncrease();
}
/**
* @brief copy assignment operator
*/
FluidDynamics& operator=(FluidDynamics&& t) noexcept
{
if (this != &t)
{
_fluidDynamicPtr = t._fluidDynamicPtr;
countIncrease();
}
return *this;
}
static void show_objectCount() { std::cout << "\n fluid dynamic object count: "
<< fluidDynamic_objectCount << std::endl; }
static int get_objectCount() { return fluidDynamic_objectCount; }
/// <summary>
/// calculates the volumes of a cylinder.
/// </summary>
/// <param name="radius">The radius is used to find the cross sectional area of a cylinder.</param>
/// <param name="distance">The distance.</param>
/// <returns>volume</returns>
static ld volumeCylinder(const ld radius, const ld distance)
{
return constants::PI * (radius * radius) * distance;
}
/// <summary>
/// finds the flow rate of fluid in a cylinder.
/// </summary>
/// <param name="radius">The radius.</param>
/// <param name="distance">The distance.</param>
/// <param name="time">The time.</param>
/// <returns>flow rate (COULOMB)</returns>
static ld flowRateCylinder_radius(const ld radius, const ld distance, const ld time)
{
return constants::PI * (radius * radius) * distance * time;
}
/// <summary>
/// calculates the flow rate of a cylinder using the diameter.
/// </summary>
/// <param name="diameter">The diameter.</param>
/// <param name="velocity">The velocity.</param>
/// <returns></returns>
static ld flowRateCylinder_diameter(const ld diameter, const ld velocity)
{
return (constants::PI * (diameter * diameter) / 4.0) * velocity;
}
/// <summary>
/// calculates the flow rate.
/// </summary>
/// <param name="volume">The volume.</param>
/// <param name="time">The time.</param>
/// <returns>flow rate</returns>
static ld flowRate(const ld volume, const ld time)
{
return volume / time;
}
/// <summary>
/// calculates the volume of flow rate.
/// </summary>
/// <param name="crossSectionalArea">The cross sectional area.</param>
/// <param name="avgVelocity">The average velocity.</param>
/// <returns>volume flow rate</returns>
static ld volumeFlowRate(const ld crossSectionalArea, const ld avgVelocity)
{
return crossSectionalArea * avgVelocity;
}
/// <summary>
/// finds the average velocity.
/// </summary>
/// <param name="volumeFlowRate">The volume flow rate.</param>
/// <param name="area">The area.</param>
/// <returns>average velocity</returns>
static ld averageVelocity(const ld volumeFlowRate, const ld area)
{
return volumeFlowRate / area;
}
/// <summary>
/// average velocity in tube or aorta with given radius and flow.
/// </summary>
/// <param name="volumeFlowRate">The volume flow rate.</param>
/// <param name="radius">The radius.</param>
/// <returns>average velocity</returns>
static ld averageVelocity_tubeLike(const ld volumeFlowRate, const ld radius)
{
return volumeFlowRate / (constants::PI * (radius * radius));
}
/// <summary>
/// calculates the volume from flow rate and time
/// </summary>
/// <param name="flowRate">The flow rate.</param>
/// <param name="time">The time.</param>
/// <returns>volume</returns>
static ld volume(const ld flowRate, const ld time)
{
return flowRate * time;
}
/// <summary>
/// calculates the time
/// </summary>
/// <param name="flowRate">The flow rate.</param>
/// <param name="volume">The volume.</param>
/// <returns>time</returns>
static ld time(const ld flowRate, const ld volume)
{
return volume / flowRate;
}
/// <summary>
/// finds the velocity using the equation of continuity solved for
/// velocity2.
/// </summary>
/// <param name="velocity1">The velocity of flow through the area1.</param>
/// <param name="area1">The cross-sectional area1.</param>
/// <param name="area2">The cross-sectional area2.</param>
/// <returns>velocity through area2</returns>
static ld velocity2_eqOfContinuity(const ld velocity1, const ld area1, const ld area2)
{
return (area1 / area2) * velocity1;
}
/// <summary>
/// Flows the rate tube like.
/// </summary>
/// <param name="radius">The radius.</param>
/// <param name="avgVelocity">The average velocity.</param>
/// <returns></returns>
static ld flowRate_tubeLike(const ld radius, const ld avgVelocity)
{
return constants::PI * (radius * radius) * avgVelocity;
}
/// <summary>
/// calculates the total volume to flow over a period of time.
/// </summary>
/// <param name="radius">The radius.</param>
/// <param name="avgVelocity">The average velocity.</param>
/// <param name="time">The time.</param>
/// <returns>volume total</returns>
static ld volumeTotal(const ld radius, const ld avgVelocity, const ld time)
{
return constants::PI * (radius * radius) * avgVelocity * time;
}
/// <summary>
/// finds the factor the velocity is reduced by branching.
/// </summary>
/// <param name="mainRadius">The main radius.</param>
/// <param name="branchRadius">The branch radius.</param>
/// <param name="branches">The number of smaller branches.</param>
/// <returns>factor of velocity reduction</returns>
static ld reducedVelocity_branchingArteries(const ld mainRadius, const ld branchRadius, const ld branches)
{
return (1.0 * mainRadius) / (branches * branchRadius);
}
/// <summary>
/// Average velocity of blood flow through ad capillary.
/// </summary>
/// <param name="flowRate">The flow rate.</param>
/// <param name="capillaryVessels">The capillary vessels.</param>
/// <param name="diameterEach">The diameter each.</param>
/// <returns>average blood flow</returns>
static ld averageVelocityBloodFlowThroughCapillary_diameter(const ld flowRate, const ld capillaryVessels, const ld diameterEach)
{
return (4.0 * flowRate) / (capillaryVessels * constants::PI * (diameterEach * diameterEach));
}
/// <summary>
/// Averages the velocity blood flow through capillary with the radius.
/// </summary>
/// <param name="flowRate">The flow rate.</param>
/// <param name="radius">The radius.</param>
/// <returns></returns>
static ld averageVelocityBloodFlowThroughCapillary_radius(const ld flowRate, const ld radius)
{
return flowRate / (constants::PI * (radius * radius));
}
/// <summary>
/// calculates the total number of capillaries.
/// </summary>
/// <param name="area">The area.</param>
/// <param name="diameter">The diameter.</param>
/// <returns>capillaries</returns>
static ld capillaryFlowTotal_diameter(const ld area, const ld diameter)
{
return (4.0 * area) / (constants::PI * (diameter * diameter));
}
/// <summary>
/// calculates the total number of Capillaries with the radius.
/// </summary>
/// <param name="flow">The flow.</param>
/// <param name="radius">The radius.</param>
/// <returns></returns>
static ld capillaryFlowTotal_radius(const ld flow, const ld radius)
{
return flow / (constants::PI * (radius * radius));
}
/// <summary>
/// calculates the total flow rate
/// </summary>
/// <param name="capillaries">The number of capillaries.</param>
/// <param name="crossSectionalArea">The cross sectional area.</param>
/// <param name="avgVelocity">The average velocity.</param>
/// <returns>total flow rate</returns>
static ld totalFlowRate_capillary(const ld capillaries, const ld crossSectionalArea, const ld avgVelocity)
{
return capillaries * crossSectionalArea * avgVelocity;
}
/// <summary>
/// Calculates the air flow through a circular duct into a rectangular room.
/// </summary>
/// <param name="roomVolume">The rooms volume = L * W * H.</param>
/// <param name="radiusDuct">The radius duct or r = diameter/2.</param>
/// <param name="time">The time in seconds.</param>
/// <returns>average speed of air flow out of duct</returns>
static ld airFlowThroughCircularDuctIntoRectangularRoom(const ld roomVolume, const ld radiusDuct, const ld time)
{
return roomVolume / (constants::PI * (radiusDuct * radiusDuct) * time);
}
/// <summary>
/// calculates the inside diameters of a hose nozzle.
/// </summary>
/// <param name="flowRate">The flow rate.</param>
/// <param name="velocity">The velocity.</param>
/// <returns>diameter</returns>
static ld diameterStream(const ld flowRate, const ld velocity)
{
return 2.0 * sqrt((flowRate) / (constants::PI * velocity));
}
/// <summary>
/// calculates the diameter that a pipe would need to be at minimum to
/// meet the requirements for the specified values
/// </summary>
/// <param name="densityFluid">The density fluid.</param>
/// <param name="flowRateFluid">The flow rate fluid.</param>
/// <param name="viscosityFluid">The viscosity fluid.</param>
/// <param name="reynoldsNumber">The Reynolds number.</param>
/// <returns></returns>
static ld diameterPipeForSpecifiedValues(const ld densityFluid,
const ld flowRateFluid,
const ld viscosityFluid,
const ld reynoldsNumber)
{
return (4.0 * densityFluid * flowRateFluid) /
(constants::PI * reynoldsNumber * viscosityFluid);
}
/// <summary>
/// uses Bernoulli's equation to calculate the amount of work.
/// </summary>
/// <param name="mass">The mass.</param>
/// <param name="velocityFinal">The velocity final.</param>
/// <param name="velocityInitial">The velocity initial.</param>
/// <returns>work new</returns>
static ld workNet_BernoulliEquation(const ld mass, const ld velocityFinal, const ld velocityInitial = 0.0)
{
return (.5 * mass * (velocityFinal * velocityFinal)) - (.5 * mass * (velocityInitial * velocityInitial));
}
/// <summary>
/// calculates the final Velocity using the Bernoulli equation.
/// </summary>
/// <param name="velocityInitial">The velocity initial.</param>
/// <param name="changeInHeight">Height of the change in.</param>
/// <returns>final velocity</returns>
static ld velocityFinal_bernoulliEquation(const ld velocityInitial, const ld changeInHeight)
{
return sqrt(pow(velocityInitial, 2.0) + (2.0 * constants::Ga * changeInHeight));
}
/**
* @brief speed of liquid emerging from the drain of a tank.
* @param height of liquid in tank
* @return speed of liquid
*/
static ld speedOfLiquidEmergingFromTank(const ld height,
bool print =false) {
auto speed = sqrt(2.0 * constants::Ga * height);
if (print) {
std::cout << "speed of liquid emerging from tank: "
<< speed << std::endl;
}
return speed;
}
/**
* @brief X_ has a nuclei density around rhoX while Y_'s density is rhoY.
* Roughly what fraction of Y_'s volume is not empty space?
* @param rhoX nuclei density of X_
* @param rhoY nuclei density of Y_
* @param print print results to console
* @return fraction of Y_'s volume that is not empty space
*/
static ld fractionOfYVolumeNotEmptySpace(const ld rhoX,
const ld rhoY,
bool print = false) {
auto fraction = (rhoY / rhoX);
if (print) {
std::cout << "fraction of Y_'s volume that is not empty space: "
<< fraction << std::endl;
}
return fraction;
}
/// <summary>
/// calculates the final pressure.
/// </summary>
/// <param name="pressureInitial">The initial pressure.</param>
/// <param name="density">The density.</param>
/// <param name="velocityInitial">The initial velocity</param>
/// <param name="velocityFinal">The final velocity final.</param>
/// <returns></returns>
static ld pressureFinal_bernoulliEquationConstantAltitude(
const ld pressureInitial,
const ld density,
const ld velocityInitial,
const ld velocityFinal)
{
return pressureInitial + .5 * density *
((velocityInitial * velocityInitial) - (velocityFinal * velocityFinal));
}
/// <summary>
/// Calculates the maximums height water from a hose can reach.
/// </summary>
/// <param name="velocity">The velocity.</param>
/// <returns>height</returns>
static ld maxHeightWaterFromHose(const ld velocity)
{
return (velocity * velocity) / (2.0 * constants::Ga);
}
/**
* @brief calculates the maximum height above a nozzle the water can rise?
* (The actual height will be significantly smaller due to air resistance.)
* @param volumeROF volume rate of flow
* @param nozzleDiameter nozzle diameter (in meters)
* @param print print to console
* @return max height
*/
static ld maxHeightAboveNozzleLiquidRise(const ld volumeROF,
const ld nozzleDiameter,
bool print =false) {
auto maxHeight = (8.0 * pow(volumeROF, 2.0)) /
(pow(constants::PI, 2.0) *
constants::Ga * pow(nozzleDiameter, 4.0));
if (print) {
std::cout << "max height above nozzle: "
<< maxHeight << std::endl;
}
return maxHeight;
}
/**
* @brief venturi flowmeter guage reading
* @param p
* @param A_big
* @param A_small
* @param density
* @param print print to console
* @return flowrate
*/
static ld venturiFlowSpeed(const ld p,
const ld A_big,
const ld A_small,
const ld density,
bool print =false) {
auto ratioOfAreas = A_big / A_small;
auto flowRate = sqrt((2.0 * p)/(density*(ratioOfAreas*ratioOfAreas-1.0)));
if (print) {
std::cout << "flow rate: "
<< flowRate << std::endl;
}
return flowRate;
}
/// <summary>
/// Calculates approximately the force due to the Bernoulli effect on a roof
/// having a specified area. F = 1/2 * p * v^2 * A
/// </summary>
/// <param name="density">The density of the air.</param>
/// <param name="velocity">The velocity of the wind.</param>
/// <param name="area">The area of the roof.</param>
/// <returns>Force on roof</returns>
static ld force_bernoulliEquationConstantAltitude(const ld density,
const ld velocity,
const ld area)
{
return .5 * density * (velocity * velocity) * area;
}
/// <summary>
/// Calculate the approximate force on a area of sail, given the
/// horizontal velocityHigh of the wind is faster and parallel to its front surface
/// while a velocitySlow wind runs along its back surface.
/// </summary>
/// <param name="density">The density.</param>
/// <param name="velocityHigh">The velocity high.</param>
/// <param name="velocityLow">The velocity low.</param>
/// <param name="area">The area.</param>
/// <returns>force of wind</returns>
static ld force_bernoulliEquationConstantAltitude(const ld density,
const ld velocityHigh,
const ld velocityLow,
const ld area)
{
return .5 * density * ((velocityHigh * velocityHigh) -
(velocityLow * velocityLow)) * area;
}
/// <summary>
/// calculates the pressure drop due to the Bernoulli effect as water goes into a
/// smaller diameter nozzle from a larger diameter hose while carrying a
/// specified volumeFlowRate.
/// </summary>
/// <param name="density">The density.</param>
/// <param name="volumeRateOfFlow">The volume rate of flow.</param>
/// <param name="diameterLarge">The larger diameter.</param>
/// <param name="diameterSmall">The smaller diameter.</param>
/// <returns>drop in pressure</returns>
static ld pressureDrop_bernoulliEquationConstantAlt(const ld density,
const ld volumeRateOfFlow,
const ld diameterLarge,
const ld diameterSmall)
{
return (8.0 * density * (volumeRateOfFlow * volumeRateOfFlow) /
(constants::PI * constants::PI)) * (1.0 / pow(diameterSmall, 4.0) - 1.0 /
pow(diameterLarge, 4));
}
/// <summary>
/// Fluids the speed pitot tube.
/// </summary>
/// <param name="meterFluidDensity">The meter fluid density.</param>
/// <param name="heightOfFluid">The height of fluid.</param>
/// <param name="airDensity">The air density.</param>
/// <returns></returns>
static ld fluidSpeed_pitotTube(const ld meterFluidDensity, const ld heightOfFluid, const ld airDensity)
{
return pow((2.0 * meterFluidDensity * constants::Ga * heightOfFluid) / airDensity, .5);
}
/// <summary>
/// calculates the powers by multiplying Bernoulli's equation by the flow rate
/// </summary>
/// <param name="density">The density.</param>
/// <param name="changeInHeight">change in Height.</param>
/// <param name="flowRate">The flow rate.</param>
/// <returns>Power in Watts</returns>
static ld power_bernoulliEquation(const ld density, const ld changeInHeight, const ld flowRate)
{
return density * constants::Ga * changeInHeight * flowRate;
}
/// <summary>
/// The left ventricle of a resting adult's heart pumps blood at a fluidFlowRate of,
/// increasing its pressureToFluid by mm Hg, its speedChangeOfFluid in m/s, and its heightChangeOfFluid.
/// (All numbers are averaged over the entire heartbeat.)
/// Calculate the total power output of the left ventricle. Note that most of the power is used to increase blood pressure.
/// </summary>
/// <param name="pressureToFluid">The pressure to fluid.</param>
/// <param name="fluidDensity">The fluid density.</param>
/// <param name="speedChangeOfFluid">The speed change of fluid.</param>
/// <param name="heightChangeOfFluid">The height change of fluid.</param>
/// <param name="fluidFlowRate">The fluid flow rate.</param>
/// <returns>power</returns>
static ld power_bernoulliEquation_ventricle(const ld pressureToFluid,
const ld fluidDensity,
const ld speedChangeOfFluid,
const ld heightChangeOfFluid,
const ld fluidFlowRate)
{
return (pressureToFluid + (.5 * (fluidDensity * pow(speedChangeOfFluid, 2)))
+ (fluidDensity *constants::Ga * heightChangeOfFluid)) * fluidFlowRate;
}
/// <summary>
/// calculates the power of a force at a certain speed
/// </summary>
/// <param name="force">The force.</param>
/// <param name="velocity">The velocity.</param>
/// <returns></returns>
static ld power(const ld force, const ld velocity)
{
return force * velocity;
}
/// <summary>
/// calculates the power
/// </summary>
/// <param name="flowRate">The flow rate.</param>
/// <param name="power">The power.</param>
/// <returns>power to provide flow</returns>
static ld powerQP(const ld flowRate, const ld power)
{
return flowRate * power;
}
/// <summary>
/// A frequently quoted rule of thumb in aircraft design is that wings should
/// produce about 1000 N of lift per square meter of wing. (The fact that a
/// wing has a top and bottom surface does not double its area.)
/// At takeoff, an aircraft travels at 60.0 m/s, so that the air speed relative
/// to the bottom of the wing is 60.0 m/s. Given the sea level density of air to be
/// 1.29 kg/m3, how fast must it move over the upper surface to create the ideal lift?
/// </summary>
/// <param name="density">The density.</param>
/// <param name="forceLiftPerSquareMeterOfWing">The force lift per square meter of wing.</param>
/// <param name="speedUnderWing">The speed under wing.</param>
/// <returns>wind speed over wing</returns>
static ld speedTopOfWing_bernoulliEquation(const ld density,
const ld forceLiftPerSquareMeterOfWing,
const ld speedUnderWing)
{
return sqrt(((2.0 * forceLiftPerSquareMeterOfWing) /
(density)) + (speedUnderWing * speedUnderWing));
}
/// <summary>
/// calculates the pressure at a certain point along a sump pump.
/// </summary>
/// <param name="outputPressure">The pressure at pump level.</param>
/// <param name="density">The density.</param>
/// <param name="HeightOfPoint">The height of point.</param>
/// <returns>pressure</returns>
static ld sumpPumpPressureAtPoint(const ld outputPressure,
const ld density,
const ld HeightOfPoint)
{
return outputPressure + ((density * constants::Ga) * (-HeightOfPoint));
}
/// <summary>
/// A pump hose goes over the foundation wall, it is a certain height from the pump and widens from diameter1 to diameter2.
/// It can pump water from a basement at a volumeFlowRate and starts at the pump with a outputPressure. this method will
/// calculate the pressure at the widened spot of the hose.
/// widened part of the hose?
/// </summary>
/// <param name="outputPressure">The output pressure where hose leaves pump.</param>
/// <param name="density">The density of water on average is 1000kg/m^3.</param>
/// <param name="volumeFlowRate">The volume flow rate.</param>
/// <param name="diameter1">The diameter of the hose at start.</param>
/// <param name="diameter2">The diameter the hose changes to.</param>
/// <param name="height">The height.</param>
/// <returns>pressure in hose</returns>
static ld sumpPumpPressureChangeInPipeDiameter(const ld outputPressure,
const ld density,
const ld volumeFlowRate,
const ld diameter1,
const ld diameter2,
const ld height)
{
return (outputPressure + ((8.0 * density * (volumeFlowRate * volumeFlowRate)) /
(constants::PI * constants::PI)) * ((1.0 / pow(diameter1, 4) -
(1.0 / pow(diameter2, 4))))) + (density * constants::Ga * -height);
}
/// <summary>
/// Calculates the retarding force due to the viscosity of the air layer between a cart and
/// a level air track given the following information
/// — air temperature,
/// — the carts velocity,
/// — its surface area,
/// — the thickness of the air layer
/// </summary>
/// <param name="viscosity">The viscosity.</param>
/// <param name="velocity">The velocity.</param>
/// <param name="crossSectionalArea">The cross sectional area.</param>
/// <param name="layerThickness">The layer thickness.</param>
/// <returns>retarding force</returns>
static ld retardingForce_airLayer(const ld viscosity,
const ld velocity,
const ld crossSectionalArea,
const ld layerThickness)
{
return viscosity * (velocity * crossSectionalArea) / (layerThickness);
}
/// <summary>
/// finds the coefficient of viscosity of a fluid.
/// </summary>
/// <param name="force">The force.</param>
/// <param name="layerLength">Length of the layer.</param>
/// <param name="velocity">The velocity.</param>
/// <param name="crossSectionalArea">The cross sectional area.</param>
/// <returns>viscosity coefficient</returns>
static ld viscosityCoefficient(const ld force, const ld layerLength,
const ld velocity, const ld crossSectionalArea)
{
return (force * layerLength) / (velocity * crossSectionalArea);
}
/// <summary>
/// calculates the viscosity of fluid in a pipe with laminar flow using
/// Perseus law for laminar flow solved for viscosity
/// </summary>
/// <param name="radiusPipe">The radius of the pipe.</param>
/// <param name="resistance">The resistance.</param>
/// <param name="lengthOfPipe">The length of pipe.</param>
/// <returns>viscosity</returns>
static ld viscosity_laminarFlowPerseusLaw(const ld radiusPipe,
const ld resistance,
const ld lengthOfPipe)
{
return (constants::PI * pow(radiusPipe, 4.0) * resistance) /
(8.0 * lengthOfPipe);
}
/// <summary>
/// calculates the flow rate between two pressures
/// </summary>
/// <param name="pressure1">The pressure1.</param>
/// <param name="pressure2">The pressure2.</param>
/// <param name="resistance">The resistance.</param>
/// <returns>flow rate</returns>
static ld pressureDifferentialFlowRate(const ld pressure1,
const ld pressure2,
const ld resistance)
{
return (pressure2 - pressure1) / resistance;
}
/// <summary>
/// calculates the resistance using pressure change and flow rate
/// </summary>
/// <param name="pressureStart">The pressure start.</param>
/// <param name="pressureEnd">The pressure end.</param>
/// <param name="flowRate">The flow rate.</param>
/// <returns>resistance</returns>
static ld resistance(const ld pressureStart,
const ld pressureEnd,
const ld flowRate)
{
return (pressureStart - pressureEnd) / flowRate;
}
/// <summary>
/// calculates the resistances using Poiseuille's law.
/// </summary>
/// <param name="viscosityCoef">The viscosity coef.</param>
/// <param name="lengthOfTube">The length of tube.</param>
/// <param name="radiusOfTube">The radius of tube.</param>
/// <returns></returns>
static ld resistance_poiseuilleLawFor(const ld viscosityCoef,
const ld lengthOfTube,
const ld radiusOfTube)
{
return (8.0 * viscosityCoef * lengthOfTube) /
(constants::PI * pow(radiusOfTube, 4.0));
}
/// <summary>
/// calculates the flow rate using Poiseuille's law for laminar flow
/// </summary>
/// <param name="pressure1">pressure 1.</param>
/// <param name="pressure2">pressure 2.</param>
/// <param name="radiusOfTube">The radius of tube.</param>
/// <param name="viscosity">The viscosity of the fluid in tube.</param>
/// <param name="lengthOfTube">The length of tube.</param>
/// <returns>flow rate</returns>
static ld laminarFlow_poiseuilleLawFor(const ld pressure1,
const ld pressure2,
const ld radiusOfTube,
const ld viscosity,
const ld lengthOfTube)
{
return ((pressure2 - pressure1) * constants::PI * pow(radiusOfTube, 4.0)) / (8.0 * viscosity * lengthOfTube);
}
/// <summary>
/// calculates the pressures to produce a specified flow rate assuming laminar flow.
/// </summary>
/// <param name="supplyFlowRate">The supply flow rate.</param>
/// <param name="lengthTube">The length tube.</param>
/// <param name="radiusTube">The radius tube.</param>
/// <param name="viscosity">The viscosity.</param>
/// <param name="gaugePressurePoint1">The gauge pressure point 1.</param>
/// <returns>pressure point 2</returns>
static ld pressureToProduceFlowRate_laminarFLow(const ld supplyFlowRate,
const ld lengthTube,
const ld radiusTube,
const ld viscosity,
const ld gaugePressurePoint1)
{
return ((8.0 * viscosity * lengthTube) /
(constants::PI * pow(radiusTube, 4.0))) *
supplyFlowRate + gaugePressurePoint1;
}
/// <summary>
/// calculates the Reynolds Number(NR) for the flow in a tube.\n
/// if NR <= 2000 than flow is laminar.\n
/// if NR > 2000 && NR <= 3000 than flow is unstable.\n
/// if NR > 3000 flow is turbulent.
/// </summary>
/// <param name="fluidDensity">The fluid density.</param>
/// <param name="fluidSpeed">The fluid speed.</param>
/// <param name="viscosity">The viscosity.</param>
/// <param name="tubeRadius">The tube radius.</param>
/// <returns>Reynolds Number, flow in a tube</returns>
static ld reynoldsNumber_flowInHorizontalTube(const ld fluidDensity,
const ld fluidSpeed,
const ld viscosity,
const ld tubeRadius)
{
return (2.0 * fluidDensity * fluidSpeed * tubeRadius) / viscosity;
}
/// <summary>
/// calculates the Reynolds number using flowrate solved for velocity subbed into the equation.
/// </summary>
/// <param name="density">The density.</param>
/// <param name="flowRate">The flow rate.</param>
/// <param name="radius">The radius.</param>
/// <param name="viscosity">The viscosity.</param>
/// <returns>Reynolds number</returns>
static ld reynoldsNumber_usingFlowRate(const ld density,
const ld flowRate,
const ld radius,
const ld viscosity)
{
return (2.0 * density * flowRate) / (constants::PI * radius * viscosity);
}
/// <summary>
/// calculates the Reynolds Number(NR) for the flow in a vertical tube.\n
/// if NR <= 2000 than flow is laminar.\n
/// if NR > 2000 && NR <= 3000 than flow is unstable.\n
/// if NR > 3000 flow is turbulent.
/// </summary>
/// <param name="fluidDensity">The fluid density.</param>
/// <param name="height">The fluid height.</param>
/// <param name="viscosity">The viscosity.</param>
/// <param name="tubeRadius">The tube radius.</param>
/// <returns>Reynolds Number, flow in a tube</returns>
static ld reynoldsNumber_flowInVerticalTube(const ld fluidDensity,
const ld height,
const ld viscosity,
const ld tubeRadius)
{
return (2.0 * fluidDensity * (sqrt(2.0*constants::Ga*height)) * tubeRadius) / viscosity;
}
/// <summary>
/// calculates the Reynolds Number(NR) for a object in fluid
/// if NR <= 1 than flow around object can be laminar.\n
/// if NR > 1 && NR < 10 than flow is in transition to turbulent flow.\n
/// if NR > 10 && NR <= 10^6 than either laminar or turbulent or may oscillate between the two.\n
/// if NR > 10^6 than flow is entirely turbulent.
/// </summary>
/// <param name="fluidDensity">The fluid density.</param>
/// <param name="viscosity">The viscosity of fluid.</param>
/// <param name="objectSpeed">The objects speed.</param>
/// <param name="objectLength">Length of the object; a spheres diameter for example.</param>
/// <returns>Reynolds Number, object in fluid</returns>
static ld reynoldsNumber_objectInFluid(const ld fluidDensity,
const ld viscosity,
const ld objectSpeed,
const ld objectLength)
{
return (fluidDensity * objectSpeed * objectLength) / viscosity;
}
/// <summary>
/// calculates the viscous drag of a small sphere
/// </summary>
/// <param name="radius">The radius.</param>
/// <param name="viscosity">The viscosity.</param>
/// <param name="velocity">The velocity.</param>
/// <returns></returns>
static ld viscous_drag_sphereSM(const ld radius, const ld viscosity, const ld velocity)
{
return 6.0 * constants::PI * radius * viscosity * velocity;
}
/// <summary>
/// calculates the net force from the change in pressure and the area of the cross sectional
/// </summary>
/// <param name="pressureChange">The pressure change.</param>
/// <param name="crossSectionalArea">The cross sectional area.</param>
/// <returns>net force</returns>
static ld forceNetFromPressureDifference(const ld pressureChange, const ld crossSectionalArea)
{
return pressureChange * crossSectionalArea;
}
/// <summary>
/// calculates the pressure change.
/// </summary>
/// <param name="pressureStart">The start pressure.</param>
/// <param name="pressureEnd">The end pressure.</param>
/// <returns>difference in pressure</returns>
static ld pressureChange(const ld pressureStart, const ld pressureEnd)
{
return pressureEnd - pressureStart;
}
/// <summary>
/// calculates the pressure being supplied with the change in flow rate
/// </summary>
/// <param name="startingPressure">The starting pressure.</param>
/// <param name="startingFlowRate">The starting flow rate.</param>
/// <param name="changedFlowRate">The changed flow rate.</param>
/// <returns>the pressure related to the changed flow rate</returns>
static ld changedPressure_byFlowRateChange_withConstantResistance(
const ld startingPressure,
const ld startingFlowRate,
const ld changedFlowRate)
{
return (startingPressure * changedFlowRate) / startingFlowRate;
}
/// <summary>
/// Pressures the difference factor by decreased radius.
/// </summary>
/// <param name="percentChange">The percent change.</param>
/// <returns></returns>
static ld pressureDifferenceFactor_byChangedRadius(const ld percentChange)
{
return 1.0 / (pow(percentChange / 100.0, 4.0));
}
/// <summary>
/// calculates the percent change in the radius when there is a certain percent
/// change in laminar flow in a tube.
/// </summary>
/// <param name="percentChangeInLaminarFlow">The percent change in laminar flow.</param>
/// <returns></returns>
static ld radiusChangePercent_byPercentChangeInLaminarFlowInTube(const ld percentChangeInLaminarFlow)
{
return (1.0 - pow(1.0 - (percentChangeInLaminarFlow / 100.0), 1.0/4.0)) * 100;