Simulate the dynamics of a predator-prey system using Lotka–Volterra equations \[\begin{align*} \frac{\d x}{\d t} &= r\_x x - D\_x xy ,\\ \frac{\d y}{\d t} &= r\_y xy - D\_y y . \end {align*}\] where $x$ and $y$ are the population sizes of prey and predator respectively, the parameters $r\_x$ and $r\_y$ represent the populations’ growth and the parameters $D\_x$ and $D\_y$ represent the shrinking of the populations. Set the parameters to be $r\_x = 0{.}8$, $D\_x0= 1{.}0$, $r\_y = 0{.}75$, $D\_y = 1{.}5$. Run the simulations for several different value pairs for initial population sizes $x = 0{.}5$ and $y = 2{.}0$; $x = 1{.}5$ and $y = 0{.}5$; $x = 1{.}95$ and $y = 0{.}75$. Plot the predator population size as a function of the prey population size. Discuss the results.
Bonus: Find the solutions for the same situations analytically (by integrating the differential equations).
Using the competitive Lotka–Volterra equations \[\begin{align*} \frac{\d x}{\d t} = r\_x x \(1 - \(\frac {x + I\_{xy} y}{k\_x}\)\) ,
\frac{\d y}{\d t} = r\_y y \(1 - \(\frac {y + I\_{yx} x}{k\_y}\)\) . \end {align*}\] simulate the dynamics of two competing populations (e.g. hawks and eagles) for the following values of parameters: $r\_h = 0{.}8$, $I\_{he} = 0{.}2$, $k\_h = 2{.}0$, $r\_e = 0{.}6$, $I\_{eh} = 0{.}3$, $k\_e = 1{.}0$. Set the initial population sizes to be $h = 0{.}01$, $e = 1{.}0$. Then, simulate the same situation, but change the interaction coefficients to $I\_{he} = 1{.}5$ a $I\_{eh} = 0{.}6$. Plot the results in one graph - the sizes of populations vs time. Discuss the results.
Verify the importance of pivoting.
Solve the system of linear equations \[\begin{equation*} \begin{pmatrix} 10^{-20} & 1\\ 1 & 1 \end{pmatrix} \begin{pmatrix} x_1\\ x_2 \end{pmatrix} = \begin{pmatrix} 1\\ 0 \end{pmatrix} \end {equation*}\] at first exactly (on paper), then using LU factorization with partial pivoting (you may utilize some Python module, e.g. scipy.linalg.lu()
), and finally, solve the system using LU factorization without pivoting. Compare the resultant $\vect {x}$ obtained from the three methods and the results of matrix multiplication $L^{-1}\cdot U$ ($P\cdot L^{-1}\cdot U$ in the case of pivoting).
Consider an infinite parallel-plate capacitor. The gap between plates has a thickness $L=10 \mathrm{cm}$ and the voltage between the plates is $U=5 \mathrm{V}$. Between the plates of the capacitor grounded electrode in the shape of an infinitely long prism with square base of side length $a=2 \mathrm{cm}$, whose center lies $l=6{,}5 \mathrm{cm}$ away from the grounded plane of the original capacitor. The prism is oriented such that one of its short sides is perpendicular to the capacitor plates. Find the distribution of electric potential in the condensator. Since the problem has a translational symmetry in the direction of the infinite side of the prism, it is sufficient to solve it only in the plane parallel to the plates, i.e. it is a 2D problem. Render the potential distribution in this plane. You may utilize the code attached to this task.
Bonus: Calculate and render the distribution of the electric field strength $\vect {E}$.