Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jerrychen97/differentialequation
This is a repo for the homework 2 of computational physics
https://github.com/jerrychen97/differentialequation
Last synced: 13 days ago
JSON representation
This is a repo for the homework 2 of computational physics
- Host: GitHub
- URL: https://github.com/jerrychen97/differentialequation
- Owner: JerryChen97
- Created: 2020-03-03T04:43:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-04T22:42:11.000Z (almost 5 years ago)
- Last Synced: 2024-11-11T14:58:51.481Z (2 months ago)
- Language: Julia
- Homepage:
- Size: 1.36 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DifferentialEquation
This is a repo for the homework 2 of computational physics## Introduction
In this module we will make use of finite difference method to solve the scalar wave equation in 1+1 dimensions:with default boundary conditions
and initial conditions
## Algorithm
This is a classical problem, and there are many different methods to approach the correct solution.
Here we choose the finite difference method as our primary choice since it is easiest to implement and most straightforward to understand.
### Finite Difference
By finite difference method, we can express the derivatives as the difference between lattice points, which are discretized by :
so here for our wave equation we have
where we denote the time indices by n and space indices by i.
Therefore, we can derive that the update rule for our states
If we denote , then we can sort the formula above as
Meanwhile, due to the extensibility and uniqueness of the solution of wave equations, the initial condition shows that
and the boundary conditions are
## Physical Essence
Wave equations describe the oscillation, and the corresponding energy to preserve is## Usage
To use this package it's quite easy:```Julia
# here we see why it's named like this: to prevent mixing with DifferentialEquations. (Really?)
using DifferentialEquation# parameter for wave equation
c=1.0# parameter for discretization
Nx=100
Nt=100# parameter for initial conditions
f=zero
g=(x->sin(2pi * x))# choose a method
method="finite difference"# return you with the 2d array U[i_x, n_t]
U=wave_func_solver(c=c, Nt=Nt, Nx=Nx, f=f, g=g, method=method)# calculate the energy
Energy=fd_energy_evolv(c=c, Nt=Nt, Nx=Nx, f=f, g=g, method=method)
```## Outlook
### Scaling
Lots of current parameters in our method can be vanished through some scaling technique.
This should make great difference since the finite difference method is not always reliable and the error accumulates along the evolution.
### Other Algorithms
To provide users with more choices of algorithms.
Our currently primary choice, finite difference method, can create some strange phenomena at specific parameter regions.
### More Tests
Currently we only test with four different kinds of initial conditions: harmonic functions, gaussian functions, random generators and instantons. Judged by the standard deviation of evolving energy, they all passed the criteria `1e-2`, among which the harmonics perform best with a lower bound `1e-4`.We can consider testing and comparing different initial conditions and different algorithms (if existing) with each other.
Due to `Julia`'s support for meta-programming, this might be not difficult to implement.As for the resolution tests, we tested at 4 different resolutions: . Most of them passed the `0.01` criteria, but random generator and gaussian functions usually fail at .
### More Plots
Current plots are stored in the `test/` folder.We can plot more interesting figures, e.g. the gif's for the state evolution.
## Acknowledgement
Thanks to Cristian for great discussion with me about various aspects of PDE's.