-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathElectroMagneticInduction.h
More file actions
2831 lines (2583 loc) · 103 KB
/
ElectroMagneticInduction.h
File metadata and controls
2831 lines (2583 loc) · 103 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
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_ELECTROMAGNETICINDUCTION_H
#define PHYSICSFORMULA_ELECTROMAGNETICINDUCTION_H
/**
* @class ElectroMagneticInduction
* @details driver class for solving complex physics problems
* @author Ryan Zurrin
* @date 3/21/2021
* @version 12.13.2022
*/
#include <iostream>
#include "Magnetism.h"
#include <string>
static int emi_objectCount = 0;
typedef long double ld;
class ElectroMagneticInduction :
public Magnetism
{
public:
ElectroMagneticInduction()
{
countIncrease();
}
explicit ElectroMagneticInduction(ld val)
{
countIncrease();
}
/**
* @brief copy constructor
*/
ElectroMagneticInduction(const ElectroMagneticInduction& t)
: Magnetism(t) {
countIncrease();
}
/**
* #brief move constructor
*/
ElectroMagneticInduction(ElectroMagneticInduction&& t) noexcept
{
countIncrease();
}
/**
* @brief copy assignment operator
*/
ElectroMagneticInduction& operator=(ElectroMagneticInduction&& t)noexcept
{
if (this != &t)
{
countIncrease();
}
return *this;
}
static void show_objectCount() { std::cout << "\n electromagnetic induction object count: "
<< emi_objectCount << std::endl; }
static int get_objectCount() { return emi_objectCount; }
/**
* @brief Calculates the magnetic flux where B is the magnetic field strength(T)
* over an area of A (m^2), at an angle theta with the perpendicular to
* the area. Any change in the magnetic flux induces an emf. This process
* is defined to be electromagnetic induction.
* @param B The magnetic field strength(T).
* @param A The area(m^2).
* @param theta The angle theta default is at 0 degrees which
* is equal to 1 making the equation flux = B*A.
* @param print (default is true) if true prints the equation and result.
* @return the magnetic flux (T*m^2)
*/
static ld magneticFlux( ld B, ld A, ld theta = 0.0, bool print = true);
/**
* @brief A generator coil is rotated through a revolution from 0 to theta degrees,
* in t seconds. Having N turns the coil has a radius of r (m) and is in a
* uniform magnetic field of B. Calculate the average emf induced.
* @param N The number of turns in coil.
* @param r The radius of coil.
* @param B The magnetic uniform field.
* @param t The time it takes to rotate theta degrees.
* @param thetaS The starting angle of rotation.
* @param thetaF The finishing angle of rotation.
* @param print (default is true) if true prints the equation and result.
* @return emf average (V)
*/
static ld emfFaradayFullEquation(
ld N, ld r, ld B, ld t, ld thetaS, ld thetaF, bool print = true);
/**
* @brief Calculates the magnitude of an induced emf when a bar magnet is thrust
* into a coil with N loops having a radius of r (m) and the average value of
* B cos(theta) that is given due to complexity as increasing from B1 to B2
* over a period of t seconds.
* @param N The number of loops.
* @param r The radius.
* @param B1 The starting magnetic field.
* @param B2 The ending magnetic field.
* @param t The time over which the increase of the
* magnetic field takes place.
* @param theta The angle theta.
* @param print (default is true) if true prints the equation and result.
* @return magnitude of emf (V)
*/
static ld emfMagnitude_FaradayNoMinus(
ld N, ld r, ld B1, ld B2, ld t, ld theta, bool print = true);
/**
* @brief Calculates the change in flux.
* @param A the area = pi*r^2.
* @param deltaB The delta b = B2 - B1.
* @param theta The angle theta.
* @return the change in flux (T*m^2)
*/
static ld deltaFlux(ld A, ld deltaB, bool print = true);
/**
* @brief EMFs the induced in generator coil.
* @param N The number of loop in coil.
* @param l The length of the loop.
* @param w The width of coil loop.
* @param aW a angular velocity.
* @param B The magnetic field strength.
* @param t The time for a rotation.
* @param print (default is true) if true prints the equation and result.
* @return emf total from generator coil (V)
*/
static ld emf_inducedInGeneratorCoil(
ld N, ld l, ld w, ld aW, ld B, ld t, bool print = true);
/**
* @brief Calculates the peek emf.
* @param N The number of turns in a coil.
* @param A The area.
* @param B The magnetic field strength.
* @param aW The angular velocity.
* @param print (default is true) if true prints the equation and result.
* @return peek emf (V)
*/
static ld emf_peek(ld N, ld A, ld B, ld aW, bool print = true);
/**
* @brief Calculates the peek emf.
* @param N The number of turns in a coil.
* @param r The radius of coil.
* @param B The magnetic field strength.
* @param rad The angle of rotation in radians.
* @param t The time for a rotation.
* @param print (default is true) if true prints the equation and result.
* @return peek emf (V)
*/
static ld emf_peek(ld N, ld r, ld B, ld rad, ld t, bool print = true);
/**
* @brief A N turn, r(m) radius coil rotates at an angular velocity of
* aW rad/s in a B(T) field, starting with the normal of the plane
* of the coil perpendicular to the field. Assume that the positive max
* emf is reached first.
* @param N The number of turns in coil.
* @param r The radius or half of the diameter.
* @param B The magnetic field strength.
* @param aW a angular velocity.
* @param print (default is true) if true prints the equation and result.
* @return peek emf
*/
static ld emfPeek_r(ld N, ld r, ld B, ld aW, bool print = true);
/**
* @brief Calculate the peak voltage of a generator that rotates its N-turn,
* d m diameter coil rotating at rpm rpms in a B T field.
* @param N The number of loops in coil.
* @param d The diameter of coil.
* @param B The magnetic filed strength.
* @param rpm The RPMs.
* @param print (default is true) if true prints the equation and result.
* @return peek emf voltage
*/
static ld emf_peekFromDiameterAndRPMs(
ld N, ld d, ld B, ld rpm, bool print = true);
/**
* @brief Calculates the EMF induced by magnetic flux over t time having N turns
* is considered Faraday's law of induction: Lenz's Law->(why there is a
* minus sign.
* @param N The amount of turns in coil.
* @param f The flux.
* @param t The time.
* @param print (default is true) if true prints the equation and result.
* @return emf = volts(V)
*/
static ld emf_inducedByMagneticFlux(ld N, ld f, ld t, bool print = true);
/**
* @brief An MRI technician moves his hand from a region of very low magnetic field
* strength into an MRI scanner’s magnetic field of B(T) with his fingers
* pointing in the direction of the field. Calculate the average emf induced in
* his wedding ring, given its diameter is d(m) and assuming it takes time
* t(s) to move it into the field.
* @param B The magnetic filed.
* @param d The diameter.
* @param t The time in seconds.
* @param print (default is true) if true prints the equation and result.
* @return average emf (V)
*/
static ld emf_avgOnCoil(ld B, ld d, ld t, bool print = true);
/**
* @brief number of turns in a coil from EMF and time t over the flux;
* @param t The time.
* @param emf The EMF.
* @param f The flux.
* @param print (default is true) if true prints the equation and result.
* @return turns in a coil
*/
static ld n_turnsInCoilFromEMFEquation(ld t, ld emf, ld f, bool print = true);
/**
* @brief calculates the fluxes from EMF equation, with a time of t and N turns in
* a coil
* @param emf The EMF.
* @param t The time.
* @param N The number of turns in a coil.
* @param print (default is true) if true prints the equation and result.
* @return magnetic flux(T*m^2)
*/
static ld flux_fromEMFEquation(ld emf, ld t, ld N, bool print = true);
/**
* @brief calculates the times from EMF equation with a flux and emf with N turns
* of a coil.
* @param N The number of turns of a coil
* @param f The flux.
* @param emf The EMF.
* @param print (default is true) if true prints the equation and result.
* @return time in seconds
*/
static ld time_fromEMFEquation(ld N, ld f, ld emf, bool print = true);
/**
* @brief Calculates the motional EMF.
* @param B The magnetic field.
* @param l The length of rod.
* @param x The distance the rod moves.
* @param t The time it moves over.
* @param print (default is true) if true prints the equation and result.
* @return emf from motion (V)
*/
static ld motionalEMF(ld B, ld l, ld x, ld t, bool print = true);
/**
* @brief Calculates the motional EMF.
* @param B The magnetic field.
* @param l The length of rod.
* @param v The velocity -> x/t .
* @param print (default is true) if true prints the equation and result.
* @return emf from motion(V)
*/
static ld motionalEMF(ld B, ld l, ld v, bool print = true);
/**
* @brief calculates the length a magnetic rod must be when producing an emf of V.
* @param V The EMF voltage (V).
* @param B The magnetic field (B).
* @param v The velocity (v).
* @param print (default is true) if true prints the equation and result.
* @return length of magnetic rod
*/
static ld lengthOfRod_emfEq(ld V, ld B, ld v, bool print = true);
/**
* @brief Calculates the velocity of the motion of magnetic rod when a emf of V is
* created with a magnetic field of B and having a rod of length l (m).
* @param V The emf voltage (V).
* @param B The magnetic field (T).
* @param l The length of rod (m).
* @param print (default is true) if true prints the equation and result.
* @return velocity (m/s)
*/
static ld velocityOfMotion_emfEq(ld V, ld B, ld l, bool print = true);
/**
* @brief Calculates the magnetic field from when a rod of length l moves at a
* velocity of v causing a magnetic field strength of B.
* @param V The emf voltage.
* @param l The length of rod.
* @param v The velocity.
* @param print (default is true) if true prints the equation and result.
* @return magnetic field strength (T)
*/
static ld magneticFieldFrom_emfEq(ld V, ld l, ld v, bool print = true);
/**
* @brief Magnetics the field magnitude.
* @param flux The flux.
* @param Ard The Area, radius or diameter.
* @param theta The theta, is at default value of 0.
* @param mode The mode is used as a switch between what
* information you use for the Ard argument: use 'r' for radius or 'd'
* for diameter and if you are using the already calculated cross sectional
* then leave out..
* @param print (default is true) if true prints the equation and result.
* @return magnetic field (T)
*/
static ld magneticFieldMagnitude(ld flux, ld Ard, ld theta, ld mode, bool print = true);
/**
* @brief Calculates the voltage or number of loops in a transformer. Use a 0 as
* placeholder in the unknowns method argument.
* @param Vs The volts secondary(output).
* @param Vp The volts primary(input).
* @param Ns The number of loops secondary(output).
* @param Np The number of loops primary(input).
* @param mode The mode used to specify what you want to solve for,
* "Vs" = volts secondary,
* "vp" = volts primary,
* "Ns" = number of loops secondary,
* "Np" = number of loops primary.
* example: transformerEquation(2.5,3.4,5,10,"Ns");
* this would solve for the number of loops in the secondary transformer
* @param print (default is true) if true prints the equation and result.
* @return volts or loops depending on mode used
*/
static ld transformerEquations_VN(ld Vs, ld Vp, ld Ns, ld Np, const std::string& mode, bool print = true);
/**
* @brief Calculates the voltage or current in a transformer. use a 0 as a place
* holder in the unknown variables method argument.
* @param Vs The volts secondary(output).
* @param Vp The volts primary(input).
* @param Is The current secondary(output).
* @param Ip The current primary(input).
* @param mode The mode used to specify what you want to solve for,
* "Vs" = volts secondary,
* "vp" = volts primary,
* "Is" = current secondary,
* "Ip" = current primary.
* example: transformerEquation(2.5,3.4,5,10,"Is");
* this would solve for the current in the secondary transformer
* @param print (default is true) if true prints the equation and result.
* @return volts or current depending on the mode picked
*/
static ld transformerEquations_VI(ld Vs, ld Vp, ld Is, ld Ip, const std::string& mode, bool print = true);
/**
* @brief Calculates the current or number of loops in a transformer. use a 0 as a place
* holder in the unknown variables method argument.
* @param Is The current secondary(output).
* @param Ip The current primary(input).
* @param Ns The number of loops secondary(output).
* @param Np The number of loops primary(input).
* @param mode The mode used to specify what you want to solve for,
* "Is" = current secondary,
* "Ip" = current primary,
* "Ns" = number of loops secondary,
* "Np" = number of loops primary.
* example: transformerEquation(2.5,3.4,5,10,"Is");
* this would solve for the current in the secondary transformer
* @param print (default is true) if true prints the equation and result.
* @return current or number of loops depending on the mode picked
*/
static ld transformerEquations_IN(ld Is, ld Ip, ld Ns, ld Np, const std::string& mode, bool print = true);
/**
* @brief Calculates the frequencies from a know angular velocity of aW.
* @param aW a angular velocity.
* @param print (default is true) if true prints the equation and result.
* @return frequency (Hz
*/
static ld frequency(ld aW, bool print = true);
/**
* @brief Calculates the period from the known frequency of f.
* @param f The frequency.
* @param print (default is true) if true prints the equation and result.
* @return period (s)
*/
static ld period(ld f, bool print = true);
/**
* @brief Calculates the maximum current in a circuit with a resistance
* of R and emf of V.
* @param emf The EMF.
* @param R The resistance.
* @param print (default is true) if true prints the equation and result.
* @return current (A)
*/
static ld maxCurrent(ld emf, ld R, bool print = true);
/**
* @brief Calculates the emf2 from the mutual inductance of M between two devices
* where the current from device one is I and the time t over which the
* current changes.
* @param M The Mutual inductance.
* @param I The current.
* @param t The time.
* @param print (default is true) if true prints the equation and result.
* @return emf voltage
*/
static ld emf_byMutualInductance(ld M, ld I, ld t, bool print = true);
/**
* @brief Calculates the mutual inductance.
* @param emf The EMF.
* @param I The current.
* @param t The time.
* @param print (default is true) if true prints the equation and result.
* @return henry(H)
*/
static ld mutualInductance(ld emf, ld I, ld t, bool print = true);
/**
* @brief calculates the EMF by self inductance. also the back emf calculated with
* this methods equation
* @param L The self inductance of the device.
* @param I The current.
* @param t The time.
* @param print (default is true) if true prints the equation and result.
* @return emf voltage
*/
static ld inductorEMF(ld L, ld I, ld t, bool print = true);
/**
* @brief calculates the self inductance.
* @param emf The EMF.
* @param I The current.
* @param t The time.
* @param print (default is true) if true prints the equation and result.
* @return inductance of inductor(H)
*/
static ld selfInductance(ld emf, ld I, ld t, bool print = true);
/**
* @brief The current in an inductor is changing at deltaI A/s and the
* inductor emf is emf V. Calculate the self inductance of the inductor.
* @param emf The emf.
* @param deltaI The change in current.
* @param print (default is true) if true prints the equation and result.
* @return inductance of inductor(H)
*/
static ld selfInductance(ld emf, ld deltaI, bool print = true);
/**
* @brief calculates the self inductance.
* @param N The number of loops.
* @param phi The flux through each loop.
* @param I The current.
* @param print (default is true) if true prints the equation and result.
* @return inductance(H)
*/
static ld selfInductance_NBI(ld N, ld phi, ld I, bool print = true);
/**
* @brief calculates the self inductance.
* @param phi The flux.
* @param I The current.
* @param print (default is true) if true prints the equation and result.
* @return inductance(H)
*/
static ld selfInductance_phiI(ld phi, ld I, bool print = true);
/**
*
* @brief Calculates the self the inductance using the time constant and resistance
* @param toa The time constant.
* @param R The resistance.
* @param print (default is true) if true prints the equation and result.
* @return self inductance
*/
static ld selfInductance_taoR(ld toa, ld R, bool print = true);
/**
* @brief Calculates the inductance of a solenoid.
* @param N The number of turns in coil.
* @param A the area, radius or diameter.
* @param l The length of solenoid.
* @param mode put a 'r' if use a radius or a 'd' if using the
* diameter or a 'c' if using the circumference to calculate the area.
* @param print (default is true) if true prints the equation and result.
* @return self inductance of solenoid
*/
static ld inductanceSolenoid_NAL(int N, ld A, ld l, char mode, bool print
= true);
/**
* @brief Calculates the inductance from total energy of E stored in inductor
* having a current of I.
* @param E The energy of inductor.
* @param I The current.
* @param print (default is true) if true prints the equation and result.
* @return the inductance (H)
*/
static ld inductanceFromEnergyStored(ld E, ld I, bool print = true);
/**
* @brief What inductance L would be needed to store energy E kWh
* (kilowatt-hours) in a coil carrying current I A.
* @param kWh The energy in kWh.
* @param I The current.
* @param print (default is true) if true prints the equation and result.
* @return the inductance (H)
* @note 1 kWh = 3.6 x 10^6 J
*/
static ld inductanceFromEnergyStored_kWhI(ld kWh, ld I, bool print = true);
/**
* @brief Calculates the energy stored in an inductor.
* @param L The inductance.
* @param I The current.
* @param print (default is true) if true prints the equation and result.
* @return energy (J)
*/
static ld energyStoredInInductor(ld L, ld I, bool print = true);
/**
* @brief Camera flashes charge a capacitor to high voltage by switching the
* current through an inductor on and off rapidly. Calculate what time must
* the a current of I through a inductance of L be switched on or off to
* induce a emf.
* @param I The current.
* @param L The inductance.
* @param emf The EMF.
* @param print (default is true) if true prints the equation and result.
* @return time to switch on off current through an inductor
*/
static ld timeOnOffToInduceCurrent(ld I, ld L, ld emf, bool print = true);
/**
* @brief Calculate the current of a system with duel rails,
* under the following conditions. The resistance between the rails is R,
* the rails and the moving rod are identical in cross section A and have
* the same resistivity_ldR ρ . The distance between the rails is l, and the
* rod moves at constant speed v perpendicular to the uniform field B.
* At time zero, the moving rod is next to the resistance R.
* @param B The magnetic field.
* @param l The length.
* @param v The velocity.
* @param A The area.
* @param p_ The resistivity_ldR.
* @param R The radius.
* @param t The time.
* @param print (default is true) if true prints the equation and result.
* @return current
*/
static ld currentSystemOnRails(
ld B, ld l, ld v, ld A, ld p_, ld R, ld t, bool print = true);
/**
* @brief Calculates the Characteristic time constant. (cTc)
* @param L The inductance.
* @param R The resistance.
* @param print (default is true) if true prints the equation and result.
* @return the time constant
*/
static ld inductiveTimeConstant(ld L, ld R, bool print = true);
/**
* @brief Inductances the reactance (XL)
* @param f The frequency.
* @param L The inductance.
* @param print (default is true) if true prints the equation and result.
* @return inductive reactance (H)
*/
static ld inductiveReactance_fL(ld f, ld L, bool print = true);
/**
* @brief calculates the Capacitive reactance (XC).
* @param f The frequency.
* @param C The capacitance.
* @param print (default is true) if true prints the equation and result.
* @return capacitive reactance (ohms)
*/
static ld capacitiveReactance_fC(ld f, ld C, bool print = true);
/**
* @brief Calculates the capacitance from reactance and frequency
* @param f The frequency in Hz.
* @param _xc The capacitive reactance.
* @param print (default is true) if true prints the equation and result.
* @return farads
*/
static ld capacitanceFromReactance(ld f, ld _xc, bool print = true);
/**
* @brief Calculates the current in an inductor of an RC circuit at specific
* moments of time t with an initial current of Io and a characteristic time
* constant of tao.
* @param Io The initial current in inductor.
* @param t The time in seconds.
* @param tao The characteristic time constant.
* @param print (default is true) if true prints the equation and result.
* @return current at specified time when switched on (A)
*/
static ld current_RLCircuit_switchON(ld Io, ld t, ld tao, bool print = true);
/**
* @brief Calculates the current of an inductor of an RC circuit switch off.
* @param Io The current initially.
* @param t The time in seconds.
* @param tao The characteristic time constant.
* @param print (default is true) if true prints the equation and result.
* @return current at specified time when switched off
*/
static ld current_RICircuit_switchOFF(ld Io, ld t, ld tao, bool print = true);
/**
* @brief Calculate current in RL circuit.
* @param emf The emf.
* @param R The resistance.
* @param L The inductance.
* @param t The time.
* @param print (default is true) if true prints the equation and result.
* @return current in RL circuit
*/
static ld current_RLCircuit(ld emf, ld R, ld L, ld t, bool print = true);
/**
* @brief Calculates I(t) in an RL circuit with decreasing current so
* di/dt < 0.
* @param emf The emf.
* @param R The resistance.
* @param L The inductance.
* @param t The time.
* @param print (default is true) if true prints the equation and result.
* @return current in RL circuit
*/
static ld current_RLCircuitDecreasingI(
ld emf, ld R, ld L, ld t, bool print = true);
/**
* @brief Calculates the current through inductor.
* @param Vrms The rms Voltage.
* @param _xl The inductance reactance.
* @param print (default is true) if true prints the equation and result.
* @return current
*/
static ld currentRMS_throughInductor(ld Vrms, ld _xl, bool print = true);
/**
* @brief Calculates the current through capacitor.
* @param Vrms The Voltage RMS.
* @param _xc The conductive reactance.
* @param print (default is true) if true prints the equation and result.
* @return current
*/
static ld currentRMS_throughCapacitor(ld Vrms, ld _xc, bool print = true);
/**
* @brief Calculates the peeks the current in an AC circuit using the peek voltage
* of Vp and its impedance of Z_.
* @param Vp The peek voltage in circuit.
* @param Z_ The impedance.
* @param print (default is true) if true prints the equation and result.
* @return The peek current -> Io = peek Amps
*/
static ld peekCurrentAC(ld Vp, ld Z, bool print = true);
/**
* @brief Calculate the peek current in an LC circuit contain a inductor
* of inductance L and a capacitor of capacitance C with a peek voltage of Vp.
* @param L The inductance.
* @param C The capacitance.
* @param Vp The peek voltage.
* @param print (default is true) if true prints the equation and result.
*/
static ld peekCurrentAC_LC(ld L, ld C, ld Vp, bool print = true);
/**
* @brief Calculates the RMS(root mean square) or average current in an AC circuit
* using the rms Voltage and the circuits impedance of Z_.
* @param Vrms The rms Voltage, average voltage.
* @param Z_ The impedance in circuit.
* @param print (default is true) if true prints the equation and result.
* @return the average or rms current Irms -> (A)
*/
static ld rmsCurrent_AC(ld Vrms, ld Z, bool print = true);
/**
* @brief Calculates the RMS(root mean square) or average current in an AC circuit
* using the rms Voltage and the resistance of R.
* @param Vrms The rms Voltage, average voltage.
* @param R The resistance in circuit.
* @param print (default is true) if true prints the equation and result.
* @return the average or rms current Irms -> (A)
*/
static ld rmsCurrent_AC_R(ld Vrms, ld R, bool print = true);
/**
* @brief Calculates the RMS(root mean square current or average current in a AC
* series circuit.
* @param Vrms The root mean square voltage or Vrms.
* @param R The resistance.
* @param _xl The inductive reactance.
* @param _xc The conductive reactance.
* @param print (default is true) if true prints the equation and result.
* @return Irms or root mean square current, average current(A)
*/
static ld rmsCurrent_AC(ld Vrms, ld R, ld _xl, ld _xc, bool print = true);
/**
* @brief Calculates the RMS(root mean square current or average current in a AC
* series circuit.
* @param Vrms The root mean square voltage or Vrms.
* @param R The resistance.
* @param L The inductance.
* @param C The capacitance.
* @param f The frequency.
* @param print (default is true) if true prints the equation and result.
* @return Irms or root mean square current, average current(A)
*/
static ld rmsCurrent_AC(ld Vrms, ld R, ld L, ld C, ld f, bool print = true);
/**
* @brief Calculates the Impedance in a RLC series AC circuit. For circuits without
* a resistor take R=0, for those without and inductor take _xl = 0, for
* those without a capacitor take _xc = 0.
* @param R The resistance.
* @param _xl The inductive reactance.
* @param _xc The capacitive reactance.
* @param print (default is true) if true prints the equation and result.
* @return the impedance on an AC circuit (Ohms)
*/
static ld impedance(ld R, ld _xl, ld _xc, bool print = true);
/**
* @brief Calculates the impedance in a RLC series AS circuit.
* @param R The resistance.
* @param L The inductance.
* @param C The capacitance.
* @param f The frequency.
* @param print (default is true) if true prints the equation and result.
* @return the impedance on an AC circuit (Ohms)
*/
static ld impedance(ld R, ld L, ld C, ld f, bool print = true);
/**
* @brief Calculates the resonant frequency in an RLC series AC circuit
* @param L The inductance.
* @param C The capacitance.
* @param print (default is true) if true prints the equation and result.
* @return resonant frequency (Hz)
*/
static ld resonantFrequency(ld L, ld C, bool print = true);
/**
* @brief Calculates the power factor. cos(phi) = R/Z.
* @param R The resistance.
* @param Z The impedance.
* @param print (default is true) if true prints the equation and result.
* @return power factor(unit-less)
*/
static ld powerFactor(ld R, ld Z, bool print = true);
/**
* @brief Calculates the power factor in a AC circuit from the Vrms, Irms
* and the phase difference between them.
* @param Vrms The root mean square voltage.
* @param Irms The root mean square current.
* @param phi The phase difference between Vrms and Irms.
* @param print (default is true) if true prints the equation and result.
* @return power factor(unit-less)
*/
static ld powerFactor(ld Vrms, ld Irms, ld phi, bool print = true);
/**
* @brief Phases the angle.
* @param pf The power factor.
* @param print (default is true) if true prints the equation and result.
* @return phase angle
*/
static ld phaseAngle(ld pf, bool print = true);
/**
* @brief Phases the angle.
* @param R The resistance.
* @param Z_ The impedance.
* @param print (default is true) if true prints the equation and result.
* @return phase angle
*/
static ld phaseAngle(ld R, ld Z, bool print = true);
/**
* @brief Calculates the phase angle of and RLC series AC circuit with a
* resistance of R, inductance of L, capacitance of C and frequency of f.
* @param R The resistance.
* @param L The inductance.
* @param C The capacitance.
* @param f The frequency.
* @param print (default is true) if true prints the equation and result.
* @return phase angle phi in degrees.
*/
static ld phaseAngle(ld R, ld L, ld C, ld f, bool print = true);
/**
* @brief Powers the average RLC.
* @param Irms The average current .
* @param Vrms The average voltage.
* @param pf The power factor.
* @param print (default is true) if true prints the equation and result.
* @return power in an RLC series AC circuit
*/
static ld powerAvgRLC(ld Irms, ld Vrms, ld pf, bool print = true);
/**
* @brief Calculates the peak emf generated by a r(m) radius, N-turn
* coil that is rotated one-fourth of a revolution in t(s), originally
* having its plane perpendicular to a uniform B(T) magnetic field?
* (This is 58 rev/s.)
* @param r The radius.
* @param N The number of turns in coil.
* @param t The time in seconds.
* @param B The magnetic field strength.
* @param print (default is true) if true prints the equation and result.
* @return peek emf
*/
static ld emfPeek(ld r, ld N, ld t, ld B, bool print = true);
/**
* @brief A solenoid of circular cross section has radius R consists of
* n turns per unit length, and carries current I. Find the magnetic flux
* through each turn of the solenoid.
* @param R The radius.
* @param n The number of turns per unit length.
* @param I The current.
* @param print (default is true) if true prints the equation and result.
* @return magnetic flux through each turn of the solenoid
* @note The magnetic flux through a solenoid is given by the formula: \n
* phi = BA = μ0*n*I*π*R^2
*/
static ld magneticFluxSolenoidLoop(ld R, ld n, ld I, bool print = true);
/**
* @brief A long, straight wire carries current I. A rectangular wire loop
* of dimensions l by w lies in a plane containing the wire, with its
* closest edge a distance a from the wire and its dimension l parallel to
* the wire. Find the magnetic flux through the loop.
* @param I The current.
* @param a The distance from the wire.
* @param l The length of the loop.
* @param w The width of the loop.
* @param print (default is true) if true prints the equation and result.
* @return magnetic flux through the loop
* @note The magnetic flux through a rectangular loop in mField is given by
* the formula: \n phi = BdA = (μ0*I*l/2π)*ln((a + w)/a)
*/
static ld magneticFluxRectangularLoop(
ld I, ld a, ld l, ld w, bool print = true);
/**
* @brief A wire loop of radius r m has resistance R. The plane of the
* loop is perpendicular to a uniform magnetic field that’s increasing
* at dB_dt T/s. Find the magnitude of the induced current in the loop.
* @param r The radius.
* @param R The resistance.
* @param dB_dt The time.
* @param print (default is true) if true prints the equation and result.
* @return magnitude of the induced current in the loop
*/
static ld inducedCurrentLoop(ld r, ld R, ld dB_dt, bool print = true);
/**
* @brief Two parallel conducting rails a distance l apart are connected
* at one end by a resistance R. A conducting bar completes the circuit,
* joining the two rails electrically but free to slide along them. The
* whole circuit is perpendicular to a uniform magnetic field B. Find the
* current when the bar is pulled to the right with constant speed v.
* @param l The distance.
* @param R The resistance.
* @param v The speed.
* @param B The magnetic field.
* @param print (default is true) if true prints the equation and result.
* @return current when the bar is pulled to the right with constant speed
*/
static ld currentSlidingBar(ld l, ld R, ld v, ld B, bool print = true);
/**
* @brief Calculate the electric power dissipated in a square loop of
* resistance R, with sides of length l, when the loop is placed in a
* magnetic field B that is perpendicular to the plane of the loop and
* is moving at a constant speed v.
* @param l The length of the loop.
* @param R The resistance.
* @param v The speed.
* @param B The magnetic field.
* @param print (default is true) if true prints the equation and result.
* @return electric power dissipated in a square loop
* @note The electric power dissipated in a square loop given R, l, v, B
* is: \n P = IE = (B^2*l^2*v^2) / R
*/
static ld powerDissipatedSquareLoop(
ld l, ld R, ld v, ld B, bool print = true);
/**
* @brief An electric generator consists of a n-turn circular coil with
* a diameter of d m. It’s rotated at a frequency of f rev/s. Find the
* magnetic field strength needed for a peak output voltage of V volts.
* @param n The number of turns.
* @param d The diameter.
* @param f The frequency.
* @param V The voltage.
* @param print (default is true) if true prints the equation and result.
* @return magnetic field strength needed for a peak output voltage
*/
static ld magneticFieldStrengthGenerator(
ld n, ld d, ld f, ld V, bool print = true);
/**
* @brief A large electromagnet used for lifting scrap iron has
* self-inductance of L H. It’s connected to a constant V-volt power source;
* the total resistance of the circuit is R. Calculate the time it takes
* for the current to reach x% of its final value.
* @param L The self-inductance.
* @param R The resistance.
* @param x The percentage.
* @param print (default is true) if true prints the equation and result.
* @return time it takes for the current to reach x% of its final value
*/
static ld timeCurrentToReachXPercent(ld L, ld R, ld x, bool print = true);
/**
* @brief Calculate the rate at which an inductor stores energy when it
* has a current of I A applied to the inductor of L H in time t s.
* @param I The current.
* @param L The self-inductance.
* @param t The time.
* @param print (default is true) if true prints the equation and result.
* @return rate at which an inductor stores energy
*/
static ld rateInductorStoresEnergy(ld I, ld L, ld t, bool print = true);
/**
* @brief Superconducting electromagnets like the solenoids in MRI scanners
* store a lot of magnetic energy. Loss of coolant can be dangerous because
* the current is suddenly left without its zero-resistance path and quickly
* decays. The result is an explosive release of magnetic energy. A
* particular MRI solenoid carries I A and has a L H inductance. When
* it loses superconductivity, its resistance goes abruptly to R.
* Calculate:
* (a) the stored magnetic energy
* (b) the rate of energy release at the instant superconductivity is lost.
* @param I The current.
* @param L The self-inductance.
* @param R The resistance.
* @param print (default is true) if true prints the equation and result.
* @return stored magnetic energy and rate of energy release
*/
static vector<ld> energyReleaseMRI(ld I, ld L, ld R, bool print = true);
/**
* @brief Calculate the magnetic energy stored in a solenoid of with a
* length of l and a cross-sectional area of A m^2 with n turns and a
* current of I A.
* @param l The length.
* @param A The cross-sectional area.
* @param n The number of turns.
* @param I The current.
* @param print (default is true) if true prints the equation and result.
* @return magnetic energy stored in a solenoid
*/
static ld energyStoredSolenoid(ld l, ld A, ld n, ld I, bool print = true);
/**
* @brief Calculate the magnetic energy stored in a solenoid of with a
* length of l and a cross-sectional area of A m^2 with a B T magnetic
* field.
* @param l The length.
* @param A The cross-sectional area.
* @param B The magnetic field.
* @param print (default is true) if true prints the equation and result.
* @return magnetic energy stored in a solenoid
*/
static ld energyStoredSolenoid(ld l, ld A, ld B, bool print = true);
/**
* @brief Calculate the magnetic energy density per unit volume in a
* magnetic field of B T.
* @param B The magnetic field.
* @param print (default is true) if true prints the equation and result.
* @return magnetic energy density per unit volume
*/
static ld magneticEnergyDensity(ld B, bool print = true);
/**
* @brief A long solenoid has circular cross section of radius R. The
* solenoid current is increasing, and as a result so is the magnetic
* field in the solenoid. The field strength as a function of time t is
* given by B=bt where b is a constant. Find the induced electric field
* outside the solenoid, a distance r from the axis.
* @param R The radius.
* @param b The constant.
* @param r The distance.
* @param print (default is true) if true prints the equation and result.
* @return induced electric field outside the solenoid
*/
static ld inducedElectricFieldSolenoid(