A collection of Physics assignments I've done in either Python or C++. A quick summary of the assignments:
Objective. Plot and calculate the numerical derivatives of a function
The Biot-Savart law describes the magnetic field
where
Objective. Calculate the magnetic field produced by two Helmholtz coils (many coils of wire carrying current) at different points in space.
A position in cartesian three-space can be described in polar cylindrical coordinates by the following coordinate transformation:
where
Likewise, the spherical coordinate coordinate transformation is:
where
The solid angle of an object in spherical coordinates is defined as
The solid angle is essentially the "area" that an object takes up within the sphere that you can view it:
Objective. For a cylinder that is displaced from the origin in three-space, find the integration limits of
The planets have an orbital period (i.e., a year) about the sun that depends on the distance from the sun, the mass of the planet, the velocity of the planet, etc. Newton's Law of Gravity provides a set of coupled differential equations that describe the motion of a planet about the sun. When solved, these equations can tell us the length of a year. NASA's Horizon system provides data about planets (e.g., mass) that can be used in Newton's Law of Gravity.
Objective. Calculate the length of one year for Earth using Newton's Law of Gravity and data from the NASA Horizon system.
One of the earliest applications of Quantum Mechanics was solving the wavefunction for an electron in the hydrogen atom. The wavefunction
where
For an electron in the hydrogen atom, the potential is just the Coloumb potential between the electron and proton in the atom:
where
Objective. Solve (numerically) the Schrodinger equation for an electron in the hydrogen atom and plot the different wavefunctions the electron can be described by.
In 1911, Ernest Rutherford shot alpha particles (a helium nucleus) at a sheet of gold foil. This is now known as Rutherford scattering. He found that some particles went straight through, some were scattered at an angle, and some bounced right back. The data he collected from these scattering experiments allowed him to estimate the size of the nucleus of a gold atom. The deflection of the alpha particle
Like Newton's Law of Gravity, this gives rise to a set of coupled differential equations which can be solved to find the trajectory of a scattered alpha particle.
An example of an alpha particle being scattered is shown below.
The Monte-Carlo technique in Physics is used to generate a distribution of some value (e.g., position) which follows a given probability distribution (e.g., a normal distribution).
Objective. Use a Monte-Carlo technique to generate a uniform distribution of methylene atoms in a small square. Again using a Monte-Carlo technique, throw alpha particles at the sheet of Methylene, and solve for the trajectory of the alpha particle as it heads toward the methylene sheet. Find the scattering angle of the alpha particle, and how much energy it loses.
The one-dimensional time-independent Schrodinger equation is defined as
where
The wavefunction
where
A particle in the harmonic oscillator problem has a potential
Likewise, the infinite square well problem of width
The potential is shown below.
Objective. Construct a potential by placing a harmonic oscillator inside of an infinite square well. Solve the Schrodinger equation in the basis of infinite square well eigenfunctions. Plot the resulting wavefunction against the wavefunction for a particle in the harmonic oscillator to see how much the square well affects the wavefunction.
Note: I skipped over many details in the explanation here for the sake of brevity. The original paper by Dr. Frank Marsiglio in the corresponding folder can be read for further details.
The Dirac delta function is (lazily) defined as
The Dirac delta function satisfies the integral property
The graph of the Dirac delta function looks like:
The origin of this function begins with the Gaussian curve:
where
It is easy to see that as
which is the not-so-lazy definition.
The derivative of a function can be calculated using the Dirac delta function. Using integration by parts and considering the following integral,
$$ \begin{aligned} \int_a^b f(x)\frac{d\ }{dx}\delta(x-x_0)\ dx&=\underbrace{\left.f(x)\delta(x-x_0)\right|a^b}{=0}-\int_a^b\frac{df}{dx}\delta(x-x_0)\ dx \ &=-\int_a^b\frac{df}{dx}\delta(x-x_0)\ dx. \end{aligned} $$
Invoking the integral property,
Therefore, for any function
Objective. Calculate the derivative of