-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathElectricCharge.h
1925 lines (1717 loc) · 66.6 KB
/
ElectricCharge.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_ELECTRICCHARGE_H
#define PHYSICSFORMULA_ELECTRICCHARGE_H
/**
* @class ElectricCharge
* @details driver class for solving complex physics problems
* @author Ryan Zurrin
* @date 12/31/2020
* @version 12.13.2022
*/
#include <iostream>
#include <vector>
#include "UnitVector.h"
#include "Vector3D.h"
typedef long double ld;
static int electricCharge_objectCount = 0;
constexpr ld distanceBetweenPoints(
const pair<ld, ld>& p1, const pair<ld, ld>& p2)
{
return sqrt((p1.first - p2.first) * (p1.first - p2.first) +
(p1.second - p2.second) * (p1.second - p2.second));
}
constexpr ld directionOfForce(const pair<ld, ld>& p1, const pair<ld, ld>& p2)
{
return atan2(p2.second - p1.second, p2.first - p1.first);
}
constexpr int signOfForce(const ld q1, const ld q2)
{
return q1 * q2 > 0 ? 1 : -1;
}
static struct ScientificNotationUnits
{
const ld YOTTA = 1e24; // 10^24
const ld ZETTA = 1e21; // 10^21
const ld EXA = 1e18; // 10^18
const ld PETA = 1e15; // 10^15
const ld TERA = 1e12; // 10^12
const ld GIGA = 1e9; // 10^9
const ld MEGA = 1e6; // 10^6
const ld KILO = 1e3; // 10^3
const ld HECTO = 1e2; // 10^2
const ld DECA = 1e1; // 10^1
const ld DECI = 1e-1; // 10^-1
const ld CENTI = 1e-2; // 10^-2
const ld MILLA = 1e-3; // 10^-3
const ld MICRO = 1e-6; // 10^-6
const ld NANO = 1e-9; // 10^-9
const ld PICO = 1e-12;// 10^-12
const ld FEMTO = 1e-15;// 10^-15
const ld ATTO = 1e-18;// 10^-18
const ld ZEPTO = 1e-21;// 10^-21
const ld YOCTO = 1e-24;// 10^-24
} SU;
class ElectricCharge
{
public:
ElectricCharge()
{
countIncrease();
}
explicit ElectricCharge(ld val)
{
countIncrease();
}
/**
* @brief copy constructor
*/
ElectricCharge(const ElectricCharge& t)
{
countIncrease();
}
/**
* #brief move constructor
*/
ElectricCharge(ElectricCharge&& t) noexcept
{
countIncrease();
}
/**
* @brief copy assignment operator
*/
ElectricCharge& operator=(const ElectricCharge& t)
{
if (this != &t)
{
countIncrease();
}
return *this;
}
static void show_objectCount()
{
std::cout << "\n electric charge object count: " <<
electricCharge_objectCount << std::endl;
}
static int get_objectCount() { return electricCharge_objectCount; }
/**
* @brief Creates mass from energy.
* @param E The energy.
* @param c The speed of light.
* @param print if true, prints the result to the console.
* @return mass
*/
static constexpr ld massFromEnergy(ld E, ld c, bool print = true);
/**
* @brief Mass from energy.
* @param M The electrons mass.
* @param print if true, prints the result to the console.
* @return mass of electrons
*/
static constexpr ld massFromEnergy(ld M, bool print = true);
/**
* @brief Totals the electron mass.
* @param Ne The total electrons.
* @param print if true, prints the result to the console.
* @return mass of electrons in kg
*/
static constexpr ld totalElectronMass(ld Ne, bool print = true);
/**
* @brief Totals the proton mass.
* @param Np The total protons.
* @param print if true, prints the result to the console.
* @return mass of protons in kg
*/
static constexpr ld totalProtonMass(ld Np, bool print = true);
/**
* @brief Totals the mass.
* @param Ne The total electrons.
* @param Np The total protons.
* @param print if true, prints the result to the console.
* @return the total mass of protons and electrons
*/
static constexpr ld totalMass(ld Ne, ld Np, bool print = true);
/**
* @brief Calculates the magnitude of force between two electrostatic forces
* q1 and q2 using coulomb's law.
* @param q1 The charge of first particle.
* @param q2 The charge of second particle.
* @param r The distance between the charges.
* @param print if true, prints the result to the console.
* @return magnitude of force between two electrostatic forces
*/
static constexpr ld coulombsLaw(
ld q1, ld q2, ld r, bool print = true);
/**
* @brief Calculates the magnitude of force between two electrostatic
* forces q1 and q2 using coulomb's law.
* @param q1 The charge of first particle.
* @param xy1 The x and y coordinates of the first particle.
* @param q2 The charge of second particle.
* @param xy2 The x and y coordinates of the second particle.
* @param multiplier The multiplier for the distance between the charges.
* @param print if true, prints the result to the console.
* @return magnitude of force between two electrostatic forces
*/
static constexpr ld coulombsLaw(
ld q1, pair<ld, ld> xy1, ld q2, pair<ld, ld> xy2,
int multiplier = 1, bool print = true);
/**
* @brief electric dipole moment is defined as the product of the charge q
* and the separation d between the two charges making up the dipole.
* @param q The charge.
* @param d The separation.
* @param print if true, prints the result to the console.
* @return the electric dipole moment
*/
static constexpr ld dipoleMoment(ld q, ld d, bool print = true);
/**
* @brief dipole field for |y| >> a, on perpendicular bisector.
* @param p The dipole moment.
* @param y The y axis.
* @param print if true, prints the result to the console.
* @return the electric dipole field
*/
static constexpr ld dipoleFieldPerpendicularBisector(
ld p, ld y, bool print = true);
/**
* @brief dipole field for |x| >> a, on axis
* @param p The dipole moment.
* @param x The x axis.
* @param print if true, prints the result to the console.
* @return the electric dipole field
*/
static constexpr ld dipoleFieldForXAxis(ld p, ld x, bool print = true);
/**
* @brief Calculates the charge of electrostatic force equal point charges.
* @param q The q.
* @param mass The mass.
* @param r The r.
* @param print if true, prints the result to the console.
* @return the charge of electrostatic force equal point charges
*/
static ld chargeOfElectrostaticForce_equalPointCharges(
ld q, ld mass, ld r, bool print = true);
/**
* @brief Calculates the electric field E.
* @param COULOMB The q.
* @param r The r.
* @param print if true, prints the result to the console.
* @return the electric field e
*/
static constexpr ld electricFieldForce(ld Q, ld r, bool print = true);
/**
* @brief calculates the force by an electric field and current
* @param q The current.
* @param E The electric field strength.
* @param print if true, prints the result to the console.
* @return the force by an electric field and current
*/
static constexpr ld forceByElectricField(ld q, ld E, bool print = true);
/**
* A positive charge +NQ is located at the origin, and a negative charge
* -Q is at x = a In which region of the axis is there a point where the
* force on a test charge—and therefore the electric field—is zero?
* @param Qp: number of positive charges
* @param Qn: number of negative charges
* @param a: distance between charges
* @return: the distance from the origin where the electric field is zero
*/
static ld electricFieldZero(ld Qp, ld Qn, ld a, bool print =
false);
/**
* @brief Calculates the electrons needed to form a charge of baseNumber to
* the su power.
* @param baseNumber The base number.
* @param su The scientific notation multiple.
* @param print if true, prints the result to the console.
* @return number of electrons
*/
static constexpr ld electrons(ld baseNumber, ld su, bool print = true);
/**
* @brief Calculates the number of electrons.
* @param protons The protons.
* @param netCharge The net charge.
* @param print if true, prints the result to the console.
* @return number of electrons
*/
static ld netElectronCount(ld protons, ld netCharge, bool print = true);
static constexpr ld totalElectrons(ld q, bool print = true);
/**
* @brief Calculates the coulomb.
* @param baseNumber The base number.
* @param su The su.
* @param print if true, prints the result to the console.
* @return the coulomb
*/
static constexpr ld coulombs(ld baseNumber, ld su, bool print = true);
/**
* @brief Calculates the number of electrons less than protons.
* @param netCharge The net charge.
* @param print if true, prints the result to the console.
* @return number of electrons
*/
static ld howManyFewerElectronsThenProtons(ld netCharge, bool print = true);
/**
* @brief Calculates the fraction of protons to electrons.
* @param protons The protons.
* @param netCharge The net charge.
* @param print if true, prints the result to the console.
* @return fraction of protons to electrons
*/
static ld fractionProtonsNoElectrons(ld protons, ld netCharge, bool print = true);
/**
* @brief Calculates the force change two point charges.
* @param F The f.
* @param factorChange The factor change.
* @param print if true, prints the result to the console.
* @return the force change two point charges
*/
static constexpr ld forceChangeTwoPointCharges(ld F, ld factorChange, bool print = true);
/**
* @brief Calculates the electric field.
* @param F The force.
* @param q The charge.
* @param print if true, prints the result to the console.
* @return the electric field
*/
static constexpr ld electricField(ld F, ld q, bool print = true);
static ld electricFieldFromPointChargeDistribution(
vector<ld> charges, vector<ld> r_vals, bool print = true);
/**
* @brief Calculates the electric field caused by point charges.
* @param q The charge.
* @param r The radius.
* @param print if true, prints the result to the console.
* @return the electric field
*/
static constexpr ld electricFieldByPointCharge(ld q, ld r, bool print = true);
/**
* Two protons are d nm apart. Find the electric field at a point between
* them, r1 nm from one of the protons. Then find the force on an electron
* at this point.
* @param d the distance between the two protons
* @param r1 the distance from one of the protons
* @return the force on an electron at this point
*/
static ld forceOnElectron(ld d, ld r1, bool print = true);
/**
* @brief Calculates the magnitude of a point charge that creates a electric
* field force of F, at a distance of r meters.
* @param E The force of the electric field in N/C.
* @param r The distance it causes this force.
* @param print if true, prints the result to the console.
* @return magnitude of the point charge (C)
*/
static constexpr ld magnitudePointCharge(ld E, ld r, bool print = true);
/**
* @brief Calculates the charge of a point particle having a force of F
* acting on it with a electric field strength of E at its location.
* @param F The force acting on a charge.
* @param E The electric field strength.
* @param print if true, prints the result to the console.
* @return the charge of the point particle (C)
*/
static constexpr ld charge(ld F, ld E, bool print = true);
/**
* @brief Calculates the electric flux (number of field lines per unit area)
* over A meters^2 with electric field strength E. If the electric field
* is hitting the surface at an angle that is not perpendicular to the
* the surface, then the angle between the normal of the surface and the
* electric field is theta.
* @param E the electric field strength
* @param A the area of the charge
* @param theta the angle between the electric field and the normal of
* the surface in degrees.
* @return
*/
static constexpr ld electricFlux(ld E, ld A, ld theta, bool print = true);
/**
* @brief Calculates the electric flux (number of field lines per unit area)
* @param E the electric field strength Vector
* @param A The Unit area Vector
* @param print print the result
* @return the electric flux
*/
static ld electricFlux(Vector3D E, Vector3D A, bool print = true);
/**
* @brief Calculates the electric flux (number of field lines per unit
* area) of a disc with radius R and electric field strength E with an
* angle of theta between the normal of the disc and the electric field.
* @param E the electric field strength
* @param R the radius of the disc
* @param theta the angle between the electric field and the normal of
* @param print print the result
* @return the electric flux
*/
static constexpr ld electricFluxDisc(ld E, ld R, ld theta, bool print = true);
/**
* @brief Calculates he static electric field generated by a distribution of
* electric charges
* @param q the charge over an area
* @return the static electric field strength
*/
static constexpr ld electricFluxSphere(ld q, bool print = true);
/**
* @brief Calculates the elextric flux of a charged sphere of radius r,
* with and
* @param E the electric field strength
* @param r the radius of the sphere
* @param print whether or not to print the result
* @return the electric flux
*/
static constexpr ld electricFluxSphere(ld E, ld r, bool print = true);
/**
* @brief Calculates the flux through a half cylinder of radius r and and
* length l with an electric field strength of E.
* @param E the electric field strength
* @param r the radius of the cylinder
* @param l the length of the cylinder
* @param print whether or not to print the result
* @return the electric flux
*/
static constexpr ld fluxThroughHalfCylinder(ld E, ld r, ld l, bool print =
false);
/**
* @brief Calculates the electric field strength caused by a distribution of
* electric charges over a spherical surface using Gauss's law.
* @param Q the charge over an area
* @param r the radius of the sphere
* @return the electric field strength
*/
static constexpr ld fieldOutsideSphericalChargeDistribution(
ld Q, ld r, bool print = true);
/**
* @brief Calculates the filed inside a uniformly charged sphere using
* Gauss's law.
* @param Qr the charge over an area
* @param R the radius of the sphere
* @param print whether or not to print the result
* @return the electric field strength
*/
static constexpr ld fieldInsideSphericalChargeDistribution(
ld Qr, ld R, bool print = true);
/**
* @brief Calculates the electric field strength caused by a distribution
* of electric charges over a spherical surface using Gauss's law.
* @param Q the charge
* @param A the area of the sphere
* @return the electric field strength
*/
static constexpr ld gaussSphericalSymmetry(ld Q, ld A, bool print = true);
/**
* @brief Calculates the electric field of a distribution of electric
* charges over a symmetric line of length infinity.
* @param lambda line charge density
* @param r the radius of the line
* @return the electric field strength
*/
static constexpr ld fieldOfALineCharge(ld lambda, ld r, bool print = true);
/**
* @brief Calculates the electric field of a distribution of electric charges
* over a symmetric line of length l having a radius of r and a charge of q.
* @param q the charge over an area
* @param l the length of the line
* @param r the radius of the line
* @param print whether or not to print the result
* @return the electric field strength
*/
static constexpr ld fieldOfLineCharge(ld q, ld l, ld r, bool print = true);
/**
* @brief Calculates the line charge density (lambda) of a uniformly charged
* line of length infinity.
* @param q the charge over an area
* @param L the length of the line
* @param print whether or not to print the result
* @return the line charge density
*/
static constexpr ld linearChargeDensity(ld q, ld L, bool print = true);
/**
* @brief Calculate the surface charge density of a uniformly charged
* sheet of charge Q and area A.
* @param Q the charge
* @param A the area
* @param print true to print the answer
* @return the surface charge density
*/
static constexpr ld surfaceChargeDensity(ld Q, ld A, bool print = true);
/**
* @brief Calculate the surface charge density of a uncharged spherical
* conducting shell of radius r with a charge Q placed at the center.
* @param Q the charge
* @param r the radius
* @param print true to print the answer
* @return the surface charge density
*/
static constexpr ld surfaceChargeDensitySphere(ld Q, ld r, bool print = true);
/**
* An electron close to a large, flat sheet of charge is repelled from the
* sheet with a E force. Calculate the surface charge density of the sheet.
* @param E the force
* @param print true to print the answer
* @return the surface charge density
*/
static constexpr ld surfaceChargeDensity(ld E, bool print = true);
/**
* @brief Calculates the volume charge density of a uniformly charged sphere
* of radius r and charge Q.
* @param Q the charge
* @param V the volume
* @param print true to print the answer
* @return the volume charge density
*/
static constexpr ld volumeChargeDensity(ld Q, ld V, bool print = true);
/**
* @brief Calculates the volume charge density of a uniformly charged sphere
* of radius r and charge Q.
* @param Q the charge
* @param r the radius
* @param print true to print the answer
* @return the volume charge density
*/
static constexpr ld volumeChargeDensitySphere(ld Q, ld r, bool print = true);
/**
* @brief Calculates the volume charge density of a uniformly charged
* cylinder of radius r and length l and charge Q.
* @param Q the charge
* @param r the radius
* @param l the length
* @param print true to print the answer
* @return the volume charge density
*/
static constexpr ld volumeChargeDensityCylinder(
ld Q, ld r, ld l, bool print = true);
/**
* @brief Calculates the volume charge density of a
*/
/**
* @brief Separates the between point charges.
* @param q1 point charge 1.
* @param q2 point charge 2.
* @param F The Force in Newtons.
* @param print whether or not to print the result
* @return the separation between the point charges (m)
*/
static ld separationBetweenPointCharges(
ld q1, ld q2, ld F, bool print = true);
/**
* @brief Hows the many electrons.
* @param totalParticles The total particles.
* @param netCharge The net charge.
* @param print whether or not to print the result
* @return the number of electrons
*/
static constexpr ld howManyElectrons(ld totalParticles, ld netCharge, bool print = true);
/**
* @brief Minimums the charge to lift object.
* @param r The radius.
* @param charge The charge.
* @param m The mass.
* @param print whether or not to print the result
* @return the minimum charge to lift the object
*/
static ld minimumChargeToLiftObject(ld r, ld charge, ld m, bool print = true);
/**
* @brief A wrecking yard inventor wants to pick up cars by charging a ball
* of radius r (d/2) by inducing an equal and opposite charge on the car.
* If a car has a mass of m kg and the ball is to be able to lift it from
* a distance of l meters away, What minimum charge must be used?
* @param r The radius of bass.
* @param l The length of initial lift .
* @param m The mass.
* @param print whether or not to print the result
* @return the minimum charge needed in C
*/
static ld minimumChargeToLiftCar(ld r, ld l, ld m, bool print = true);
/**
* @brief Calculates the net force on charge from other charges.
* @param q0 the charge of the charge in question
* @param q0Loc the location of the charge in question
* @param charges the charges
* @param chargeLocs the locations of the charges
* @param print whether or not to print the result
* @return the net force on the charge
*/
static ld netForceOnChargeFromOtherCharges(ld q0, pair<ld, ld> q0Loc,
vector<ld> charges,
vector<pair<ld, ld>>
chargeLocs,
bool print = true);
/**
* @brief Superposition principle. Adding charges up.
* @param Qref The refrence charge to find the total charge.
* @param Qloc the pair of coordinates of the charge.
* @param charges a vector of charges
* @param locations a vector of pairs for each of the charges coordinates.
* @param print whether or not to print the result
* @return net charge vector
*/
static vector<ld> superpositionPrinciple(
ld Qref,
pair<ld, ld> Qloc,
const vector<ld>& charges,
const vector<pair<ld, ld>>& locations,
bool print = true);
/**
* @brief Distance between points.
* @param q1 The q1.
* @param q2 The q2.
* @param F The f.
* @param print whether or not to print the result
* @return the distance between the points
*/
static ld distanceBetweenPoints(ld q1, ld q2, ld F, bool print = true);
/**
* @brief Angles the vertical axis.
* @param Fe The force of the electric field.
* @param mass The mass.
* @param print whether or not to print the result
* @return the angle of the vertical axis
*/
static ld angleVerticalAxis(ld Fe, ld mass, bool print = true);
/**
* @brief Two raindrops with equal masses of m are in a thunderhead r meters apart
* when they each acquire charges of q1 and q2. Find their acceleration.
* @param m The mass.
* @param r The distance between particles.
* @param q1 The charge on particle 1.
* @param q2 The charge on particle 2.
* @param print whether or not to print the result
* @return acceleration in m/s^2
*/
static constexpr ld accelerationOfParticles(ld m, ld r, ld q1, ld q2, bool print = true);
/**
* @brief Calculate the electric field strength near a conducting sphere with a
* d diameter of d meters that has q_excess amount of excess charge on it.
* @param d The diameter.
* @param q_excess The excess charge.
* @param print whether or not to print the result
* @return Electric field strength
*/
static constexpr ld electricFieldStrength(ld d, ld q_excess, bool print = true);
/**
* @brief A charged insulating ball of mass m hangs on a long string with a length
* that don't matter, in a uniform horizontal electric field.
* Given the charge on the ball is q Coulombs, find the strength of the field.
* @param m The mass.
* @param theta The angle theta.
* @param q The charge of the mass.
* @param print whether or not to print the result
* @return the strength of the electric field
*/
static ld electricFieldStrength(ld m, ld theta, ld q, bool print = true);
/**
* @brief four equal charges q lie on the corners of a square. A fifth charge COULOMB
* is on a mass m directly above the center of the square, at a height
* equal to the length d of one side of the square.
* Determine the magnitude of q in terms of COULOMB , m , and d ,
* if the Coulomb force is to equal the weight of m.
* @param COULOMB The charge of the center point.
* @param m The mass in center.
* @param d The length of a side and height of the center.
* @param print whether or not to print the result
* @return the charge of the corner points
*/
static ld magnitudeOfq_termsOf_Q_m_d(ld Q, ld m, ld d, bool print = true);
/**
* @brief Calculate the angular velocity Ω of an electron orbiting a proton in
* the hydrogen atom, given the radius of the orbit is r meters.
* You may assume that the proton is stationary and the centripetal
* force is supplied by Coulomb attraction.
* @param r The radius.
* @param m The mass electron.
* @param q The charge of electron.
* @param print whether or not to print the result
* @return angular velocity (rad/s)
*/
static ld angularVelocityOfElectronOrbitingProton(ld r, ld m, ld q, bool print = true);
/**
* @brief Point charges of q1C and q2 C are placed l meters apart. Where can a
* third charge be placed so that the net force on it is zero?
* @param l The distance between the two particles.
* @param q1 The charge of particle 1.
* @param q2 The charge of particle 2.
* @param print whether or not to print the result
* @return the distance to place the third particle
*/
static ld distanceToPlaceThirdChargeToMakeZero(ld l, ld q1, ld q2, bool print = true);
/**
* @brief Using the symmetry of the arrangement, determine the direction of the
* force on q which is in the center of a square with four point charges of
* equal charges of positive q1 and q2 in top corners and negative q3
* and q4 in bottom corners, given that qa=qb=+qx4 C and qc=qd=−qx4 C.
* Calculate the magnitude of the force on the charge q , given that the
* square is l meters on a side and q=q1 C
* @param qx4 The charge of the four corners.
* @param lSide The length of a side.
* @param q1 The charge in the center point.
* @param theta the angle.
* @param print whether or not to print the result
* @return force on the point q
*/
static ld magnitudeOfForceOn_q(ld qx4, ld lSide, ld q1, ld theta, bool print = true);
/**
* @brief Find the electric field at the location of qa in Figure 18.52 given
* that qb=qc=qd=+qb C, q=−qm nC, and the square is l cm on a side.
* @param qb The charge of 3 particles.
* @param qm The charge on the middle particle.
* @param l The length of a side.
* @param print whether or not to print the result
* @return the electric field force n N/C
*/
static ld electricFieldAtLocation(ld qb, ld qm, ld l, bool print = true);
/**
* @brief Calculate the electric field at the center of the triangle.
* @param qa The charge of the top point.
* @param qb The charge of the left point.
* @param qc The charge of the right point.
* @param l The length of a side.
* @param print whether or not to print the result
* @return the electric field force n N/C
*/
static std::vector<ld> electricFieldAtCenterTriangle(
ld qa, ld qb, ld qc, ld l, bool print = true);
/**
* @brief A very long straight wire has charge per unit length lambda. At
* what distance from the wire is the magnitude of the electric field
* equal to Ef?
* @param lambda the charge per unit length
* @param Ef the electric field strength
* @param print true to print the answer
* @return the distance
*/
static constexpr ld distanceFromWireElectricFieldMagnitude(
ld lambda, ld Ef, bool print = true);
/**
* A (l) m length of power line carries a total charge of (q) C
* distributed uniformly over its length. Find the magnitude of the
* electric field at (r) m from the axis of the power line, and not
* near either end (staying away from the ends means you can approximate
* the field as that of an infinitely long wire).
* @param l the length of the power line
* @param q the total charge
* @param r the distance from the axis
* @param print true to print the answer
* @return the magnitude of the electric field
*/
static constexpr ld magnitudeOfElectricFieldByWire(
ld l, ld q, ld r, bool print = true);
/**
* @brief A rod l m long and r m in radius carries a Q C charge
* distributed uniformly over its length. What is the approximate magnitude
* of the electric field R m from the rod surface, not near either end?
* @param l the length of the rod *
* @param Q the total charge
* @param r the radius of the rod
* @param R the distance from the rod surface
* @param print true to print the answer
* @return the magnitude of the electric field
*/
static constexpr ld magnitudeOfElectricFieldByRod(
ld l, ld Q, ld r, ld R, bool print = true);
/**
* @brief Find the magnitude of the electric field due to a charged ring of
* radius a and total charge Q, at a point on the ring axis a distance a
* from the ring's center.
* @param a the radius of the ring
* @param Q the total charge of the ring
* @param print true to print the answer
* @return the magnitude of the electric field
*/
static ld electricFieldFromChargedRing(ld a, ld Q, bool print = true);
/**
* @brief Find the magnitude of the electric field at a point located at z
* meters from the center of a charged ring of radius r having a charge Q.
* @param r the radius of the ring
* @param z the distance from the center of the ring
* @param Q the total charge of the ring
* @param print true to print the answer
* @return the magnitude of the electric field
*/
static ld electricFieldAtPointFromChargedRing(
ld r, ld z, ld Q, bool print = true);
/**
* A proton moving to the right at V m/s enters a region where a
* E N/C electric field points to the left. How far will the proton get
* before its speed reaches zero? Express your answer in meters.
* @param V the initial speed
* @param E the electric field
* @param print true to print the answer
* @return the distance
*/
static ld distanceProtonGetsBeforeSpeedZero(ld V, ld E, bool print = true);
/**
* The charges are in a uniform electric field whose direction makes an
* angle theta with the line connecting the charges. What is the
* magnitude of this field if the torque exerted on the dipole has
* magnitude t N⋅m ?
* @param t the torque
* @param theta the angle
* @param p dipole moment
* @param print true to print the answer
*/
static ld magnitudeOfElectricField(ld t, ld theta, ld p, bool print = true);
/**
* Three identical charges q form an equilateral triangle of side a,
* with two charges on the x-axis and one on the positive y-axis.
* Find an expression for the electric field at points on the y -axis above
* the uppermost charge.
* @param q the charge
* @param a the side length
* @param y the y coordinate
* @param print true to print the answer
* @return the electric field
*/
static ld electricFieldAtPointOnYAxis(ld q, ld a, ld y, bool print = true);
/**
* Four equal charges Q are at the corners of a square of side a .
* Find the magnitude of the force on each charge.
* @param Q the charge
* @param a the side length
* @param print true to print the answer
* @return the force
*/
static ld forceOnEachChargeInSquare(ld Q, ld a, bool print = true);
/**
* @brief Calculate the Electric field strength inside a uniformly charged
* slab of charge with a volume charge density of rho and thickness d.
* @param rho the volume charge density
* @param x the distance from the center plane of the slab
* @param print true to print the answer
* @return the electric field strength
*/
static constexpr ld fieldInsideSlabWithVolumeChargeDensity(
ld rho, ld x, bool print = true);
/**
* @brief Calculates the Electric field strength outside a slab at a
* distance x from the center plane of the slab.
* @param rho the volume charge density
* @param d the thickness of the slab
* @param print true to print the answer
* @return the electric field strength
*/
static constexpr ld fieldOutsideSlabWithVolumeChargeDensity(
ld rho, ld d, bool print = true);
/**
* brief What surface charge density on an infinite sheet will produce an
* electric field of E N/C?
* @param E the electric field
* @param print true to print the answer
* @return the surface charge density
*/
static constexpr ld surfaceChargeDensityFromElectricField(ld E, bool print = true);
/**
* @brief Calculate the field charge of a sheet with a surface charge density
* sigma
* @param sigma the surface charge density
* @param print true to print the answer
* @return the field charge
*/
static constexpr ld fieldChargeOfSheet(ld sigma, bool print = true);
/**
* A total charge of Q C is applied to a thin, square metal plate l m
* on a side. Calculate the electric field strength near the plates sruface.
* @param Q the total charge
* @param l the side length
* @param print true to print the answer
* @return the electric field strength
*/
static constexpr ld electricFieldStrengthNearPlate(
ld Q, ld l, bool print = true);
/**
* @brief Calculate the electric field at the surface of a conductor with
* surface charge density sigma.
* @param sigma the surface charge density
* @param print true to print the answer
* @return the electric field
*/
static constexpr ld fieldAtConductorSurface(ld sigma, bool print = true);
/**
* @brief Calculate the charge between two point charges of equal
* magnitude a distance r apart with a repulsive force of F.
* @param F the force
* @param r the distance
* @param print true to print the answer
* @return the charge
*/
static ld chargeBetweenPointCharges(ld F, ld r, bool print = true);
/**
* @brief Two small spheres spaced r m apart have equal charge. Calculate
* how many excess electrons must be present on each sphere if the
* magnitude of the force of repulsion between them is F newtons.
* @param r is the distance between the spheres in m
* @param F is the force of repulsion in N
* @param print prints the result
* @return the number of excess electrons
*/
static ld excessElectrons(ld r, ld F, bool print = true);
/**
* @brief The molecule's mol has a dipole moment of p C⋅m. Calculate the
* separation between the charges if the molecule is consists of two
* electric charges of ±e.
* @param p the dipole moment
* @param print true to print the answer
*/
static ld separationOfCharges(ld p, bool print = true);
/**
* @brief In his famous 1909 experiment that demonstrated quantization of
* electric charge, R. A. Millikan suspended small oil drops in an
* electric field. With a field strength of E N/C, calculate the mass
* of the drop that can be suspended when the drop carries a net charge
* of n elementary charges.
* @param E the electric field strength
* @param n the number of elementary charges
* @param print true to print the answer
* @return the mass of the drop
*/
static ld massOfDropInElectricField(ld E, ld n, bool print = true);
/**
* @brief A q1 C charge and a q2 C charge are inside an uncharged
* sphere. Calculate the the electric flux through the sphere?
* @param q1 the first charge
* @param q2 the second charge
* @param print true to print the answer
*/
static ld electricFluxThroughSphere(ld q1, ld q2, bool print = true);
/**
* @brief Calculate the electric field strength just outside the surface
* of a conducting sphere carrying surface charge density sigma C/m2?
* @param sigma the surface charge density
* @param print true to print the answer
* @return the electric field strength
*/
static ld electricFieldStrengthOutsideSphere(ld sigma, bool print = true);
/**
* @brief A point charge with charge q1 C is held stationary at the origin.
* A second point charge with charge q2 C moves from the point P1(x1, y1)
* to the point P2(x2, y2).
* Calculate how much work W is done by the electric force on the moving
* point charge.
* @param q1 the first charge
* @param q2 the second charge
* @param P1 the first point
* @param P2 the second point
* @param print true to print the answer
* @return the work done
*/
static ld workDoneByElectricForce(
ld q1, ld q2, const Vector2D& P1, const Vector2D& P2, bool print = true);
/**