-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathElectricPotential.h
1652 lines (1475 loc) · 55.8 KB
/
ElectricPotential.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/15/2021.
//
#ifndef PHYSICSFORMULA_ELECTRICPOTENTIAL_H
#define PHYSICSFORMULA_ELECTRICPOTENTIAL_H
/**
* @class ElectricPotential
* @details driver class for solving complex physics problems
* @author Ryan Zurrin
* @dateBuilt 12/31/2020
* @lastEdit 12/31/2020
*/
#include "Heat.h"
#include "Vector3D.h"
#include <iostream>
static int electricalPotential_objectCount = 0;
struct POINT_CHARGE_2D
{
double q;
Vector3D position;
POINT_CHARGE_2D(double q, const Vector3D& p) : q(q), position(p) {}
};
struct POINT_CHARGE_3D
{
double q;
Vector3D position;
POINT_CHARGE_3D(double q, const Vector3D& p) : q(q), position(p) {}
};
typedef POINT_CHARGE_2D pc2d;
typedef POINT_CHARGE_3D pc3d;
//constexpr auto _LIGHTSPEED_ = 2.99792458e8;
//multiply joules by this to convert to electron Volts
static struct DielectricConstants
{
DielectricConstants(){}
const struct VACUUM {
const ld constant = 1.00000;
const ld breakdown_field = 0.0;
}vacuum;
const struct AIR {
const ld constant = 1.00059;
const ld breakdown_field = 3.0e6; //3.0e6
}air;
const struct BAKELITE {
const ld constant = 4.9;
const ld breakdown_field = 24*pow(10,6); //24e6
}bakelite;
const struct FUSED_QUARTZ {
const ld constant = 3.78;
const ld breakdown_field = 8e6; //8e6
}fused_quartz;
const struct NEOPRENE_RUBBER {
const ld constant = 6.7;
const ld breakdown_field = 12*pow(10,6); //12e6
}neoprene_rubber;
const struct NYLON {
const ld constant = 3.4;
const ld breakdown_field = 14*pow(10,6); //14e6
}nylon;
const struct PAPER {
const ld constant = 3.7;
const ld breakdown_field = 16*pow(10,6); //16e6
}paper;
const struct POLYSTYRENE {
const ld constant = 2.56;
const ld breakdown_field = 24*pow(10,6); //24e6
}polystyrene;
const struct PYREX_GLASS {
const ld constant = 5.6;
const ld breakdown_field = 14*pow(10,6); //14e6
}pyrex_glass;
const struct SILICON_OIL {
const ld constant = 2.5;
const ld breakdown_field = 15*pow(10,6); //15e6
}silicon_oil;
const struct STRONTIUM_TITANATE {
const ld constant = 233;
const ld breakdown_field = 8*pow(10,6); //8e6
}strontium_titanate;
const struct TEFLON {
const ld constant = 2.1;
const ld breakdown_field = 60*pow(10,6); //60e6
}teflon;
const struct WATER {
const ld constant = 80;
const ld breakdown_field = 3.5*pow(10,6); //3.5e6
}water;
}dielectrics;
class ElectricPotential
{
public:
ElectricPotential()
{
countIncrease();
}
explicit ElectricPotential(ld val)
{
countIncrease();
}
/**
* @brief copy constructor
*/
ElectricPotential(const ElectricPotential& t)
{
countIncrease();
}
/**
* #brief move constructor
*/
ElectricPotential(ElectricPotential&& t) noexcept
{
countIncrease();
}
/**
* @brief copy assignment operator
*/
ElectricPotential& operator=(const ElectricPotential& t)
{
if (this != &t)
{
countIncrease();
}
return *this;
}
static void show_objectCount() { std::cout
<< "\n electrical potential object count: "
<< electricalPotential_objectCount << std::endl; }
static int get_objectCount() { return electricalPotential_objectCount; }
/**
* @brief This is the electrical potential energy per unit change
* @param PE The potential energy.
* @param q The charge that can be moved.
* @param print print the result to the console
* @return the electrical potential, volts(V)
*/
static ld electricalPotential_V(ld PE, ld q, bool print = true);
/**
* @brief Calculates the potential energy of a charge
* @param q The charge.
* @param volts The voltage.
* @param print print the result to the console
* @return the potential difference (PE)
*/
static ld potentialEnergy_qV(ld q, ld volts, bool print = true);
/**
* @brief It takes W J to move a q C charge from point A to point B.
* What's the potential difference ΔV_AB
* @param W The work done.
* @param q The charge.
* @param print The print.
* @return ld
*/
static ld potentialDifference_V(ld W, ld q, bool print = true);
/**
* @brief Calculates the potential difference between two points moving
* across an electric field strength of E at an angle theta to the field.
* @param E the electric field strength
* @param r the distance between the two points
* @param theta the angle between the electric field and the distance between
* @param print if true, prints the results to the console
* @return the potential difference
*/
static ld potentialDifference(ld E, ld r, ld theta, bool print = true);
/**
* @brief Calculates the total charge moved in Coulombs
* @param PE The Potential difference.
* @param volts The electrical potential.
* @param print print the result to the console
* @return the charge(q) in Coulombs(C) moved
*/
static ld chargeMoved(ld PE, ld volts, bool print = true);
/**
* @brief Calculate much charge must be transferred between the initially
* uncharged plates of the capacitor with side lengths of s m and a
* distance apart of d m, in order to store Eu J of energy, as well
* calculate the resulting potential difference between the plates.
* @param Eu the energy stored in the capacitor
* @param s the side length of the capacitor
* @param d the distance between the plates
* @param print if true, prints the results to the console
* @return the charge moved
*/
static vector<ld> chargeMoved(ld Eu, ld s, ld d, bool print = true);
/**
* @brief Calculates the numbers of electrons that pass through a charge per
* second.
* @param chargeMoved The charge moved(q).
* @param print print the result to the console
* @return number of electrons(Ne)
*/
static ld electronsPerSecond(ld chargeMoved, bool print = true);
/**
* @brief Calculates the energy in electron volts(eV)
* @param volts The volts.
* @param print print the result to the console
* @return the energy in electron volts(eV)
*/
static ld electronVolts_eV(ld volts, bool print = true);
/**
* @brief Converts to electron volts from known j
* @param j The j.
* @param print print the result to the console
* @return the energy in electron volts(eV)
*/
static ld electronVoltsFromJoules(ld j, bool print = true);
/**
* @brief Calculates the final speed of a particle with a mass of m, a charge
* of q and a potential difference of volts.
* @param q The charge.
* @param volts The electrical potential.
* @param m The mass.
* @param print print the result to the console
* @return velocity (m/s)
*/
static ld velocityFinal(ld q, ld volts, ld m, bool print = true);
/**
* @brief Calculates the final speed of a particle with a mass of m, a charge
* of q and a potential difference of V.
* @param KE The Kinetic Energy (J).
* @param m The mass.
* @param print print the result to the console
* @return velocity (m/s)
*/
static ld velocityFinal(ld KE, ld m, bool print = true);
/**
* @brief Calculates the voltages between two points for a uniform electric
* field only
* @param E The max electric field strength.
* @param d The distance of separation.
* @param print print the result to the console
* @return maximum voltage (V)
*/
static ld voltageBetween2points_Vab(ld E, ld d, bool print = true);
/**
* @brief Calculates the Electric field strength between two points/plates
* for a uniform electric field only
* @param volts The potential difference or volts.
* @param d The distance between points.
* @param print print the result to the console
* @return magnitude of electric field(N/C)(volts/m)
*/
static ld electricFieldMagnitude(ld volts, ld d, bool print = true);
/**
* @brief Calculates the electric field. which ius said to be the gradient fo
* the electric potential.
* @param volts The volts.
* @param s The distance the change in volts occurs.
* @param print print the result to the console
* @return electric field
*/
static ld electricField(ld volts, ld s, bool print = true);
/**
* @brief Calculates the volts from electric field.
* @param E The electric field strength.
* @param s The distance over which the change in potential takes place.
* @param print print the result to the console
* @return volts
*/
static ld voltsFromElectricFieldGradient(ld E, ld s, bool print = true);
/**
* @brief Calculates the distances over which the change in volts occurs.
* @param volts The change in volts.
* @param E The Electric field strength.
* @param print print the result to the console
* @return distance(m)
*/
static ld distanceOverChangeInVolts_s(ld volts, ld E, bool print = true);
/**
* @brief How far from a COULOMB charged point charge will the potential be
* volts volts?
* @param Q The charge (C).
* @param volts The volts.
* @param print print the result to the console
* @return distance (meters)
*/
static ld distancePointChargeToEqualVoltsOf(ld Q, ld volts, bool print = true);
/**
* @brief Calculates the voltage between two points for a point charge
* @param Q The point charge.
* @param r The distance.
* @param print print the result to the console
* @return voltage
*/
static ld electricPotential_pointCharge(ld Q, ld r, bool print = true);
/**
* @brief Calculates the excesses charge.
* @param r The radius.
* @param volts The voltage.
* @param print print the result to the console
* @return charge in Coulombs(C)
*/
static ld excessCharge(ld r, ld volts, bool print = true);
/**
* @brief Calculates the voltage needed to obtain a certain energy.
* @param m The mass.
* @param volts The volts.
* @param q The charge.
* @param numProtons number of protons in atom of consideration
* @param print print the result to the console
* @return voltage (V)
*/
static ld voltageNeededToObtainEnergy(ld m, ld volts, ld q, ld numProtons, bool print = true);
/**
* @brief ions with a charge iof q are accelerated from rest through a
* voltage of volts. At what temperature will the average kinetic energy of
* gas molecules be the same as that given these ions?
* @param q The charge.
* @param volts The voltage.
* @param print print the result to the console
* @return temperature in Kelvin(k)
*/
static ld temperatureAvgKineticEnergyGasMolecule(ld volts, ld q, bool print = true);
/**
* @brief The temperature of ion particles is T degrees Celsius. Through what
* voltage must a charged ion be accelerated to have the same energy as the
* average kinetic energy of ions at this temperature?
* @param T The temperature in degrees Celsius.
* @param q The charge.
* @param print print the result to the console
* @return voltage (V)
*/
static ld voltageIonsMoveThroughToReachSameTemperature(ld T, ld q, bool print = true);
/**
* @brief Capacitance of a capacitor. units of C/volts or A^2s^2/kg*m^2
* @param Q The charge.
* @param volts The volts.
* @param print print the result to the console
* @return the capacitance_Qv (C/volts)
*/
static ld capacitance_Qv(ld Q, ld volts, bool print = true);
/**
* @brief Calculate the capacitance of a capacitor that stores E joules of
* energy when the potential difference between its plates is V volts.
* @param E The energy.
* @param V The volts.
* @param print print the result to the console
* @return capacitance (C)
*/
static ld capacitance_Ev(ld E, ld V, bool print = true);
/**
* @brief You’re given three capacitors C1, C2, C3: Calculate
* (a) the maximum,
* (b) the minimum,
* and (c) two intermediate capacitances you could achieve using
* combinations of all three capacitors.
* @param C1 The capacitance of the first capacitor.
* @param C2 The capacitance of the second capacitor.
* @param C3 The capacitance of the third capacitor.
* @param print print the result to the console
* @return the maximum, the minimum, and two intermediate capacitances
*/
static std::vector<ld> maxMinAndIntermediateCapacitances(ld C1, ld C2, ld C3, bool print = true);
/**
* @brief Calculates the charge stored in a capacitor.
* @param C The capacitance_Qv.
* @param volts The volts.
* @param print print the result to the console
* @return the charge (COULOMB)
*/
static ld chargeStoredInCapacitor(ld C, ld volts, bool print = true);
/**
* @brief Calculates the voltage applied to a C (F) capacitor when it holds
* COULOMB (C) of charge.
* @param Q The charge.
* @param C The capacitance_Qv.
* @param print print the result to the console
* @return volts (V)
*/
static ld voltageAcrossCapacitor(ld Q, ld C, bool print = true);
/**
* @brief Calculates the capacitance_Qv of a parallel plate capacitor
* @param A The area.
* @param d The distance between plates.
* @param print print the result to the console
* @return the capacitance_Qv C in farads
*/
static ld capacitanceParallelPlate(ld A, ld d, bool print = true);
static ld capacitanceRoundParallelPlate(ld R, ld d, bool print = true);
/**
* @brief Calculates the capacitance_Qv of a parallel plate capacitor with a
* dielectric
* @param d_k The dielectric constant.
* @param A The area of the capacitor.
* @param d The distance between plates.
* @param print print the result to the console
* @return the capacitance_Qv C in farads
*/
static ld capacitanceParallelPlateDielectric(ld d_k, ld A, ld d, bool print = true);
/**
* @brief Calculates the dielectric constant.
* @param E0 The electric field in a vacuum.
* @param E The electric field of the dielectric.
* @param print print the result to the console
* @return the dielectric constant
*/
static ld dielectricConstant(ld E0, ld E, bool print = true);
/**
* @brief Calculates the energy stored in a capacitor.
* @param COULOMB The charge.
* @param volts The volts.
* @param print print the result to the console
* @return energy stored in capacitor
*/
static ld capacitorEnergy_Ecap_QV(ld Q, ld volts, bool print = true);
/**
* @brief Calculates the energy stored in a capacitor.
* @param C The capacitance_Qv.
* @param volts The volts.
* @param print print the result to the console
* @return energy stored in capacitor
*/
static ld capacitorEnergy_Ecap_CV(ld C, ld volts, bool print = true);
/**
* @brief Calculates the energy stored in a capacitor.
* @param COULOMB The charge.
* @param C The capacitance_Qv.
* @param print print the result to the console
* @return energy stored in capacitor
*/
static ld capacitorEnergy_Ecap_QC(ld Q, ld C, bool print = true);
/**
* @brief Calculates the potential across a capacitor.
* @param C The capacitance_Qv.
* @param Ecap The energy stored in the capacitor.
* @param print print the result to the console
* @return the potential across the capacitor
*/
static ld potentialAcross_Ecap_CE(ld C, ld Ecap, bool print = true);
/**
* Calculate the area the parallel plates of a capacitor of capacitance_Qv C
* must have if they are separated by a distance of d.
* @param C the capacitance_Qv
* @param d the distance
* @return the area of the parallel plates of a capacitor (m^2)
*/
static ld capacitorPlateArea(ld C, ld d, bool print = true);
/**
* @brief A parallel-plate capacitor with d m plate spacing has +/- Q C on
* its plates when charged to V volts. Calculate the plates area.
* @param Q the charge
* @param V the voltage
* @param d the distance between the plates
* @return the area of the plates
*/
static ld capacitorPlateArea_QVd(ld Q, ld V, ld d, bool print = true);
/**
* @brief Calculate the area the parallel plates of a capacitor with a
* capacitance_Qv of C must have if it is separated by d meters of a dielectric,
* which has a dielectric constant of k.
* @param C the capacitance_Qv
* @param d the distance of separation
* @param k the dielectric constant
* @return the area of the parallel plates of a capacitor (m^2)
*/
static ld capacitorPlateAreaDielectric(ld C, ld d, ld k, bool print = true);
/**
* @brief Calculate the maximum voltage that can be applied to a capacitor
* with a dielectric strength of dStrength and a distance between plates of d.
* @param dStrength the dielectric strength
* @param d the distance between the plates
* @return the maximum voltage that can be applied
*/
static ld vMaxOnCapacitor(ld dStrength, ld d, bool print = true);
/**
* @brief Calculate the maximum charge that can be stored in a capacitor
* with a capacitance_Qv of C and a maximum voltage of vMax.
* @param C the capacitance_Qv
* @param vMax the maximum voltage
* @return the maximum charge that can be stored in a capacitor (C)
*/
static ld maxChargeCanBeStoredCapacitor(ld C, ld vMax, bool print = true);
/**
* @brief Calculates the Volume the of dielectric material.
* @param A the area
* @param d the distance
* @return the volume of the dielectric material
*/
static ld volumeOfDielectricMaterial(ld A, ld d, bool print = true);
/**
* @brief Calculates the Electric field strength between two plates.
* @param KE the kinetic energy
* @param q the charge
* @param d the distance
* @return the Electric field strength (V/m)
*/
static ld electricFieldStrengthBetween2plates(ld KE, ld q, ld d, bool print = true);
/**
* @brief Calculates the potential near the surface of a sphere.
* @param d the diameter of the sphere
* @param q the charge
* @return the potential near the surface of a sphere (V)
*/
static ld potentialNearSurfaceOfSphere(ld d, ld q, bool print = true);
/**
* @brief An electrostatic paint sprayer has a metal sphere of diameter d
* and a potential of volts volts that repels paint droplets onto a grounded
* object. What charge is on the sphere?
* @param d the diameter
* @param volts the volts
* @return the charge (C)
*/
static ld chargeOnSphere(ld d, ld volts, bool print = true);
/**
* @brief What charge must a 0.100-mg point with a potential of volts have to arrive at an object
* with a speed of velocity m/s?
* @param m the mass in kg
* @param velocity the velocity
* @param volts the voltage
* @return the charge (C)
*/
static ld chargeOnPointToArriveWithSpeed(ld m, ld velocity, ld volts, bool print = true);
/**
* @brief A prankster applies a voltage of volts to an capacitor of C farad and then tosses it
* to an unsuspecting victim. The victim's finger is burned by the discharge
* of the capacitor through m g of flesh. What is the temperature increase
* of the flesh? Is it reasonable to assume no phase change?
* @param volts the voltage
* @param C the capacitance_Qv
* @param m the mass
* @param _c the specific heat
* @return the temperature increase of the flesh
*/
static ld temperatureChangeFromCapacitanceBurn(ld volts, ld C, ld m, ld _c , bool print = true);
/**
* @brief Calculates the kinetic energy of a positive charge.
* @param q the positive charge
* @param Vab the change in volts
* @return the kinetic energy (J)
*/
static ld kineticEnergyFinalToMovePositiveCharge(ld q, ld Vab, bool print = true);
/**
* @brief What is the work done by the electric force to move a Q C
* charge from point A with an electric potential of EPA to point B with an
* electric potential of EPB?
* @param Q the charge (C)
* @param EPA the electric potential at point A (V)
* @param EPB the electric potential at point B (V)
* @param print true to print the answer
* @return the work done (J)
*/
static ld workDoneByElectricForce(ld Q, ld EPA, ld EPB, bool print = true);
/**
* @brief Calculate the change in KE of a charge Q C as it moves from point A
* with a electric potential of Va to point B with an electric potential of Vb.
* @param Q the charge (C)
* @param Va the electric potential at point A (V)
* @param Vb the electric potential at point B (V)
* @param print true to print the answer
* @return the change in KE (J)
*/
static ld changeInKEOfCharge(ld Q, ld Va, ld Vb, bool print = true);
/**
* @brief A particle with charge Q C is placed on the x axis in a region
* where the electric potential due to other charges increases in the +x
* direction but does not change in the y or z direction. The particle,
* initially at rest, is acted upon only by the electric force and moves
* from point a to point b along the x axis, increasing its kinetic energy
* by KE J . In what direction and through what potential difference Vb−Va
* does the particle move?
* NOTE:
* In general, if no forces other than the electric force act on a
* positively charged particle, the particle always moves toward a point at
* lower potential
* @param Q the charge (C)
* @param KE the change in KE (J)
* @param print true to print the answer
* @return the change in potential (V)
*/
static ld changeInPotentialOfMovingCharge(ld Q, ld KE, bool print = true);
/**
* @brief the electric force of a particle of charge q in an electric field
* of strength E is given by F = qE.
* @param q the charge (C)
* @param E the electric field strength (V/m)
* @param print true to print the answer
* @return the electric force (N)
*/
static ld electricForce(ld q, ld E, bool print = true);
/**
* @brief Calculate the work it take to move a q C charge against a U V
* potential difference.
* @param q the charge (C)
* @param U the potential difference (V)
* @param print true to print the answer
* @return the work done (J)
*/
static ld workDoneToMoveCharge(ld q, ld U, bool print = true);
/**
* @brief Calculate the work done to move a charge q C from a one point
* with a potential of U1 V to a point with a potential of U2 V.
* @param q the charge (C)
* @param U1 the potential at point 1 (V)
* @param U2 the potential at point 2 (V)
* @param print true to print the answer
* @return the work done (J)
*/
static ld workDoneMovingCharge(ld q, ld U1, ld U2, bool print = true);
/**
* @brief An uncharged capacitor has parallel plates s m on a side, spaced
* d m apart. Calculate how much work is required to transfer Qa C from one
* plate to the other and How much work is required to transfer an
* additional Qb C.
* @param s the side length of the capacitor (m)
* @param d the distance between the plates (m)
* @param Qa the charge on the capacitor (C)
* @param Qb the additional charge to be added (C)
* @param print true to print the answer
* @return the work done (J)
*/
static vector<ld> workToTransferCharge(ld s, ld d, ld Qa, ld Qb, bool print = true);
/**
* @brief Calculates the magnitude of the potential difference between two
* points located r m apart in a uniform Ef N/C electric field, if a
* line between the points is at angle theta to the electric field
* (default is parallel to the field).
* @param r the distance between the points (m)
* @param Ef the electric field strength (N/C)
* @param theta the angle between the line and the electric field (rad)
* @param print true to print the answer
* @return the potential difference (V)
*/
static ld potentialDifferenceBetweenTwoPoints(
ld r, ld Ef, ld theta = 0, bool print = true);
/**
* @brief Calculates the work done to assemble a configuration of charges
* @tparam POINTCHARGE the type of point charge
* @param charges the charges
* @param print true to print the answer
* @return the work done (J)
*/
template<class POINTCHARGE>
static ld workToAssembleChargeConfiguration(vector<POINTCHARGE> charges, bool print = true);
/**
* @brief Dielectric breakdown of air occurs at fields of E_break V/m.
* Calculate the maximum potential (measured from infinity) for the sphere
* of radius r m before dielectric breakdown occurs at the sphere's
* surface.
* @param r the radius of the sphere (m)
* @param E_break the electric field strength at which dielectric breakdown
* occurs (V/m)
* @param print true to print the answer
* @return the maximum potential (V)
*/
static ld dielectricBreakdown(ld r, ld E_break, bool print = true);
/**
* @brief Dielectric breakdown of air occurs at fields of E_break V/m.
* Calculate the charge on the sphere of radius r m before dielectric
* breakdown occurs at the sphere's
* surface.
* @param r the radius of the sphere (m)
* @param E_break the electric field strength at which dielectric breakdown
* occurs (V/m)
* @param print true to print the answer
* @return the maximum potential (V)
*/
static ld dielectricBreakdownCharge(ld r, ld E_break, bool print = true);
/**
* @brief Three equal charges q form an equilateral triangle of side a.
* Find the potential, relative to infinity, at the center of the triangle.
* @param q the charge (C)
* @param a the side length (m)
* @param print true to print the answer
* @return the potential (V)
*/
static ld potentialAtCenterOfEquilateralTriangle(ld q, ld a, bool print = true);
/**
* @brief Two identical charges q lie on the x axis at +/- a, at a height
* of y above the x axis. Calculate the potential at all points in the
* x-y plane.
* @param q the charge (C)
* @param a the distance from each side of the origin (m)
* @param y the height above the x axis (m)
* @param print true to print the answer
* @return the potential (V)
*/
static ld potentialAtAllPointsInXYP(ld q, ld a, ld y, bool print = true);
/**
* @brief An infinitely long line of charge has a linear charge density of
* lambda C/m . A proton is at distance r m from the line has a mass of m kg
* and is moving directly toward the line with speed v m/s. Calculate how
* close the charge gets to the line of charge.
* @param lambda the linear charge density (C/m)
* @param r the distance from the line (m)
* @param v the speed of the charge (m/s)
* @param print true to print the answer
* @return the distance from the line (m)
*/
static ld distanceFromLineOfCharge(
ld lambda, ld r, ld v, bool print = true);
/**
* @brief Calcualte the electric energy density of inside a capacitor
* with an electric field of E V/m.
* @param E the electric field strength (V/m)
* @param print true to print the answer
* @return the electric energy density (J/m^3)
*/
static ld electricEnergyDensity(ld E, bool print = true);
/**
* @brief Typical electric fields in thunderstorms average around 10^5 V/m.
* Consider a cylindrical thundercloud with height h m and diameter d m,
* and assume a uniform electric field of E Find the electric energy
* contained in this cloud.
* @param h the height of the cloud (m)
* @param d the diameter of the cloud (m)
* @param E the electric field strength (V/m)
* @param print true to print the answer
*/
static ld electricEnergyInThundercloud(ld h, ld d, ld E, bool print = true);
/**
* @brief A sphere of radius Ri carries charge Q distributed uniformly over
* its surface. How much work does it take to compress the sphere to a smaller
* radius of Rf?
* @param Q the charge (C)
* @param Ri the initial radius (m)
* @param Rf the final radius (m)
* @param print true to print the answer
* @return the work done (J)
*/
static ld workToCompressSphere(ld Q, ld Ri, ld Rf, bool print = true);
/**
* @brief Calculate the potential difference at point p from a distribution
* of point charges.
* @tparam POINTCHARGE
* @param charges the charges
* @param p the point
* @param print true to print the answer
* @return the potential difference (V)
*/
template<typename POINTCHARGE>
static ld potentialDueToChargeDistribution(
vector<POINTCHARGE> charges, const Vector2D& p, bool print = true);
/**
* @brief You measure an electrostatic energy density of uE J/m3 at a
* distance of d m from a point charge. At dx m from the charge, calculate
* the energy density.
* @param uE the energy density (J/m^3)
* @param d the distance from the charge (m)
* @param dx the distance from the charge (m)
* @param print true to print the answer
* @return the energy density (J/m^3)
*/
static ld energyDensityAtDistanceFromCharge(
ld uE, ld d, ld dx, bool print = true);
/**
* @brief A cubical region of side L has one corner at the origin and the
* opposite corner at x = y = z = L. It contains an electric field whose
* magnitude increases with y: E(y) = E0 y/L. Calculate the
* electrostatic energy contained in this region.
* @param L the side length (m)
* @param E0 the electric field strength at y = 0 (V/m)
* @param print true to print the answer
* @return the electrostatic energy (J)
*/
static ld electrostaticEnergyInCubicalRegion(ld L, ld E0, bool print = true);
/**
* @brief Calculate the total electrostatic energy of a system consisting
* of four point charges located at the corners of a square of side a.
* Three of them carry charge +Q, while the fourth carries –Q/2.
* @param a the side length (m)
* @param Q the charge (C)
* @param print true to print the answer
* @return the electrostatic energy (J)
*/
static ld electrostaticEnergyOfSquare(ld a, ld Q, bool print = true);
/**
* @brief Calculate the voltages compare across two wires both of length
* L and diameter d, carrying the same current I. One wire has a
* resistivity_VIlg of rho1 and the other has a resistivity_ldR of rho2.
* @param rho1 the resistivity_ldR of wire 1 (ohm-m)
* @param rho2 the resistivity_ldR of wire 2 (ohm-m)
* @param print true to print the answer
* @return the voltage difference (V)
*/
static ld voltageCompareAcross2Wires(ld rho1, ld rho2, bool print = true);
/**
* @brief Calculate the relationship between the diameters of two wires
* that have the same resistance and length. One wire has a resistivity_ldR
* of rho1 and the other has a resistivity_ldR of rho2.
* @param rho1 the resistivity_ldR of wire 1 (ohm-m)
* @param rho2 the resistivity_ldR of wire 2 (ohm-m)
* @param print true to print the answer
* @return the relationship between the diameters
*/
static ld relationshipBetweenDiametersOf2Wires(
ld rho1, ld rho2, bool print = true);
/**
* @brief A car battery stores about U J of energy. If this energy were
* used to create a uniform E V/m electric field, what volume would it
* occupy?
* @param U the energy stored (J)
* @param E the electric field strength (V/m)
* @param print true to print the answer
* @return the volume (m^3)
*/
static ld volumeOfUniformElectricField(ld U, ld E, bool print = true);
/**
* @brief Consider a parallel-plate capacitor with plates of area A and with
* separation d. Calculate F(V), the magnitude of the force each plate
* experiences due to the other plate as a function of V, the potential drop
* across the capacitor.
* @param A the area of the plates (m^2)
* @param d the separation of the plates (m)
* @param V the potential drop across the capacitor (V)
* @param print true to print the answer
* @return the force (N)
*/
static ld forceOnPlateOfParallelPlateCapacitor(
ld A, ld d, ld V, bool print = true);
/**
* @brief A charge Q0 is at the origin. A second charge, Qx=2Q0 is brought
* to the point x=a, y=0. Then a third charge Qy is brought to the
* point x=0, y=a. If it takes twice as much work to bring in Qy as it did
* Qx, what is Qy in terms of Q0?
* @param Q0 the charge (C)
* @param a the distance (m)
* @param print true to print the answer
* @return the charge (C)
*/
static ld chargeQyInTermsOfQ0(ld Q0, ld a, bool print = true);
~ElectricPotential()
{
countDecrease();
}
private:
static void countIncrease() { electricalPotential_objectCount += 1; }
static void countDecrease() { electricalPotential_objectCount -= 1; }
};
#endif //PHYSICSFORMULA_ELECTRICPOTENTIAL_H
inline ld ElectricPotential::electricalPotential_V(const ld PE, const ld q, bool print)
{
auto var = PE/q;
if (print)
std::cout << "V = " << var << " V" << std::endl;
return var;
}
inline ld ElectricPotential::potentialEnergy_qV(
const ld q, const ld volts, bool print)
{
ld PE = q*volts;
if (print)
std::cout << "PE = " << PE << " J" << std::endl;
return PE;
}
inline ld ElectricPotential::chargeMoved(const ld PE, const ld volts, bool print)
{
auto var = PE / volts;
if (print)
std::cout << "q = " << var << " C" << std::endl;
return var;
}
inline ld ElectricPotential::electronsPerSecond(const ld chargeMoved, bool print)
{
auto var = chargeMoved/constants::ELECTRON_CHARGE;
if (print)
std::cout << "n = " << var << " electrons/s" << std::endl;
return var;
}
inline ld ElectricPotential::electronVolts_eV(const ld volts, bool print)
{
auto var = constants::eV * volts;
if (print)
std::cout << "eV = " << var << " eV" << std::endl;
return var;
}
inline ld ElectricPotential::electronVoltsFromJoules(const ld j, bool print)
{
auto var = j / constants::PROTON_CHARGE;
if (print)
std::cout << "eV = " << var << " eV" << std::endl;
return var;
}
inline ld ElectricPotential::velocityFinal(const ld q, const ld volts, const ld m, bool print)
{
auto var = sqrt((2.0 * q * volts) / m);
if (print)
std::cout << "v = " << var << " m/s" << std::endl;
return var;
}
inline ld ElectricPotential::velocityFinal(const ld KE, const ld m, bool print)
{
auto var = sqrt((2.0 * KE) / m);
if (print)
std::cout << "v = " << var << " m/s" << std::endl;
return var;
}
inline ld ElectricPotential::voltageBetween2points_Vab(const ld E, const ld d, bool print)
{
auto var = E * d;
if (print)
std::cout << "Vab = " << var << " V" << std::endl;
return var;
}