Skip to content

Commit

Permalink
Final update before release
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis-Finegan committed Nov 28, 2023
1 parent 3ea4b80 commit dac10f6
Show file tree
Hide file tree
Showing 16 changed files with 1,363 additions and 704 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,3 @@ __pycache__/
# images
img/
*.png

# main.py
main.py

# plain text
.txt
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,29 @@ Suppose a model where $D = 0$. this can be interpreted as a under going convecti

$$\frac{\partial u}{\partial t} = \mathbf{c} \cdot \nabla u$$

## How to use



## Examples

Consider a Diffusion Convection model in 2 dimension with the vector $\mathbf{c}$ having equal vector components and $D$ is constant.

Let $\mathbf{c} = [-0.1, -0.1]$ and $D = 0.009$.
Let $\mathbf{c} = [-0.1, -0.1]$ and $D = 0.009$. (Neumann boundary condition and 3d animations can be found in [Two dimensional examples](examples/Two_Dimensional_Models.ipynb))

### Diffusion Convection Model

Solution:

![Diffusion Convection Model](./img/animation_diffusion_convection.gif)
![!\[Diffusion Convection Model\](./img/animation_diffusion_convection.gif)](examples/img/animation_convection_diffusion_2dims_dirichlet_color.gif)

### Diffusion Model

Solution:

![Diffusion Model](./img/animation_diffusion.gif)
![diffusion](examples/img/animation_diffusion_2dims_dirichlet_color.gif)

### Convection Model

Solution:

![Convection Model](./img/animation_convection.gif)
![convection](examples/img/animation_convection_2dims_color.gif)

## Applications

Expand All @@ -70,6 +66,4 @@ Some applications of these models include:

2. Tranportation of a fluids density distribution that is flowing uniformly.

3. Fokker Plank Equation of a Stochastic Differential Equation with uniform drift and standard deviation.

4. Shrodinger's Equation of a free particle in Quantum Mechanics.
3. Fokker Plank Equation of a Stochastic Differential Equation with uniform drift and standard deviation.
22 changes: 16 additions & 6 deletions animations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

# Animates the solution curve in 2 dimensions
def animation_2(solution: np.ndarray, X: np.ndarray, Y: np.ndarray, xlab: str, ylab: str, zlab: str, title: str, zlim: tuple, fps: float, frn: int, filename: str):
plt.rcParams["figure.figsize"] = [10, 10]
plt.rcParams["figure.autolayout"] = True

def change_plot(frame_num, solution, plot):
plot[0].remove()
Expand Down Expand Up @@ -71,20 +69,32 @@ def animate(i):


# Animates the solution curve in 2 dimensions but as a color plot
def animation_color(solution: np.ndarray, fps: float, frn: int, filename: str):
def animation_color(solution: np.ndarray, xlab: str, ylab: str, title: str, xlim_: tuple, ylim_: tuple, fps: float, frn: int, filename: str):
# Create the figure and axis objects
fig, ax = plt.subplots()

# Set the axis limits
ax.set_xlim(-5, 5)
ax.set_ylim(-5, 5)
ax.set_xlim(xlim_[0], xlim_[1])
ax.set_ylim(ylim_[0], ylim_[1])

# Define the plotting function
def update_plot(i):
im.set_array(solution[i, :, :])

# Create the initial plot
im = ax.imshow(solution[0, :, :], extent=[-5, 5, -5, 5], cmap='viridis')
im = ax.imshow(solution[0, :, :], extent=[xlim_[0], xlim_[1], ylim_[0], ylim_[1]], cmap='viridis')

# x label
if xlab is not None:
plt.xlabel(xlab)

# y label
if ylab is not None:
plt.ylabel(ylab)

# title
if title is not None:
plt.title(title)

# Create the animation object
anim = animation.FuncAnimation(fig, update_plot, frames=frn, interval=1/fps)
Expand Down
238 changes: 207 additions & 31 deletions examples/Fokker_Plank_equation.ipynb

Large diffs are not rendered by default.

298 changes: 298 additions & 0 deletions examples/Heat_Equation.ipynb

Large diffs are not rendered by default.

236 changes: 236 additions & 0 deletions examples/Transport_Equation.ipynb

Large diffs are not rendered by default.

601 changes: 601 additions & 0 deletions examples/Two_Dimensional_Models.ipynb

Large diffs are not rendered by default.

253 changes: 0 additions & 253 deletions examples/convection.ipynb

This file was deleted.

296 changes: 0 additions & 296 deletions examples/diffusion.ipynb

This file was deleted.

Binary file removed examples/example-img/Ito_Process_Histogram.gif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed examples/example-img/convection_in_1_dimension.gif
Binary file not shown.
Binary file not shown.
Binary file not shown.
101 changes: 0 additions & 101 deletions main.py

This file was deleted.

0 comments on commit dac10f6

Please sign in to comment.