|
| 1 | +""" |
| 2 | +Title : Finding the value of magnitude of either the Casimir force, the surface area |
| 3 | +of one of the plates or distance between the plates provided that the other |
| 4 | +two parameters are given. |
| 5 | +
|
| 6 | +Description : In quantum field theory, the Casimir effect is a physical force |
| 7 | +acting on the macroscopic boundaries of a confined space which arises from the |
| 8 | +quantum fluctuations of the field. It is a physical force exerted between separate |
| 9 | +objects, which is due to neither charge, gravity, nor the exchange of particles, |
| 10 | +but instead is due to resonance of all-pervasive energy fields in the intervening |
| 11 | +space between the objects. Since the strength of the force falls off rapidly with |
| 12 | +distance it is only measurable when the distance between the objects is extremely |
| 13 | +small. On a submicron scale, this force becomes so strong that it becomes the |
| 14 | +dominant force between uncharged conductors. |
| 15 | +
|
| 16 | +Dutch physicist Hendrik B. G. Casimir first proposed the existence of the force, |
| 17 | +and he formulated an experiment to detect it in 1948 while participating in research |
| 18 | +at Philips Research Labs. The classic form of his experiment used a pair of uncharged |
| 19 | +parallel metal plates in a vacuum, and successfully demonstrated the force to within |
| 20 | +15% of the value he had predicted according to his theory. |
| 21 | +
|
| 22 | +The Casimir force F for idealized, perfectly conducting plates of surface area |
| 23 | +A square meter and placed at a distance of a meter apart with vacuum between |
| 24 | +them is expressed as - |
| 25 | +
|
| 26 | +F = - ((Reduced Planck Constant ℏ) * c * Pi^2 * A) / (240 * a^4) |
| 27 | +
|
| 28 | +Here, the negative sign indicates the force is attractive in nature. For the ease |
| 29 | +of calculation, only the magnitude of the force is considered. |
| 30 | +
|
| 31 | +Source : |
| 32 | +- https://en.wikipedia.org/wiki/Casimir_effect |
| 33 | +- https://www.cs.mcgill.ca/~rwest/wikispeedia/wpcd/wp/c/Casimir_effect.htm |
| 34 | +- Casimir, H. B. ; Polder, D. (1948) "The Influence of Retardation on the |
| 35 | + London-van der Waals Forces", Physical Review, vol. 73, Issue 4, pp. 360-372 |
| 36 | +""" |
| 37 | + |
| 38 | +from __future__ import annotations |
| 39 | + |
| 40 | +from math import pi |
| 41 | + |
| 42 | +# Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of |
| 43 | +# Pi and the function |
| 44 | +REDUCED_PLANCK_CONSTANT = 1.054571817e-34 # unit of ℏ : J * s |
| 45 | + |
| 46 | +SPEED_OF_LIGHT = 3e8 # unit of c : m * s^-1 |
| 47 | + |
| 48 | + |
| 49 | +def casimir_force(force: float, area: float, distance: float) -> dict[str, float]: |
| 50 | + |
| 51 | + """ |
| 52 | + Input Parameters |
| 53 | + ---------------- |
| 54 | + force -> Casimir Force : magnitude in Newtons |
| 55 | +
|
| 56 | + area -> Surface area of each plate : magnitude in square meters |
| 57 | +
|
| 58 | + distance -> Distance between two plates : distance in Meters |
| 59 | +
|
| 60 | + Returns |
| 61 | + ------- |
| 62 | + result : dict name, value pair of the parameter having Zero as it's value |
| 63 | +
|
| 64 | + Returns the value of one of the parameters specified as 0, provided the values of |
| 65 | + other parameters are given. |
| 66 | + >>> casimir_force(force = 0, area = 4, distance = 0.03) |
| 67 | + {'force': 6.4248189174864216e-21} |
| 68 | +
|
| 69 | + >>> casimir_force(force = 2635e-13, area = 0.0023, distance = 0) |
| 70 | + {'distance': 1.0323056015031114e-05} |
| 71 | +
|
| 72 | + >>> casimir_force(force = 2737e-21, area = 0, distance = 0.0023746) |
| 73 | + {'area': 0.06688838837354052} |
| 74 | +
|
| 75 | + >>> casimir_force(force = 3457e-12, area = 0, distance = 0) |
| 76 | + Traceback (most recent call last): |
| 77 | + ... |
| 78 | + ValueError: One and only one argument must be 0 |
| 79 | +
|
| 80 | + >>> casimir_force(force = 3457e-12, area = 0, distance = -0.00344) |
| 81 | + Traceback (most recent call last): |
| 82 | + ... |
| 83 | + ValueError: Distance can not be negative |
| 84 | +
|
| 85 | + >>> casimir_force(force = -912e-12, area = 0, distance = 0.09374) |
| 86 | + Traceback (most recent call last): |
| 87 | + ... |
| 88 | + ValueError: Magnitude of force can not be negative |
| 89 | + """ |
| 90 | + |
| 91 | + if (force, area, distance).count(0) != 1: |
| 92 | + raise ValueError("One and only one argument must be 0") |
| 93 | + if force < 0: |
| 94 | + raise ValueError("Magnitude of force can not be negative") |
| 95 | + if distance < 0: |
| 96 | + raise ValueError("Distance can not be negative") |
| 97 | + if area < 0: |
| 98 | + raise ValueError("Area can not be negative") |
| 99 | + if force == 0: |
| 100 | + force = (REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / ( |
| 101 | + 240 * (distance) ** 4 |
| 102 | + ) |
| 103 | + return {"force": force} |
| 104 | + elif area == 0: |
| 105 | + area = (240 * force * (distance) ** 4) / ( |
| 106 | + REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 |
| 107 | + ) |
| 108 | + return {"area": area} |
| 109 | + elif distance == 0: |
| 110 | + distance = ( |
| 111 | + (REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / (240 * force) |
| 112 | + ) ** (1 / 4) |
| 113 | + return {"distance": distance} |
| 114 | + raise ValueError("One and only one argument must be 0") |
| 115 | + |
| 116 | + |
| 117 | +# Run doctest |
| 118 | +if __name__ == "__main__": |
| 119 | + import doctest |
| 120 | + |
| 121 | + doctest.testmod() |
0 commit comments