Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ We assume no boundary effects (large domain), allowing a clean comparison of the
If we discretize the equation with standard centered second order finite differences, Equation(1) turns into

$$
\frac{U^{k-1}_i - 2U^{k}_i + U^{k+1}_i}{\Delta t^2} = c^2\frac{U_{i+1}^k - 2U_{i}^k + U_{i+1}^k}{\Delta x^2}
\frac{U^{k-1}_i - 2U^{k}_i + U^{k+1}_i}{\Delta t^2} = c^2\frac{U_{i-1}^k - 2U_{i}^k + U_{i+1}^k}{\Delta x^2}
$$

Rearranging the equation for the unknown value $U^{k+1}_i$ we get:
Expand Down Expand Up @@ -240,4 +240,4 @@ Both FD and MD methods use a **second-order accurate** CTCS scheme in time.

## References
- Castillo, J. E., *Mimetic Methods for Partial Differential Equations*. Cambridge University Press, 2008.
- LeVeque, R. J., *Finite Difference Methods for Ordinary and Partial Differential Equations*. SIAM, 2007.
- LeVeque, R. J., *Finite Difference Methods for Ordinary and Partial Differential Equations*. SIAM, 2007.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ We assume a Neumann boundary condition where $\frac{du}{dx}(-2,t)=0$ and $\frac{
If we discretize the equation with standard centered second order finite differences, Equation(1) turns into

$$
\frac{U^{k-1}_i - 2U^{k}_i + U^{k+1}_i}{\Delta t^2} = c^2\frac{U_{i+1}^k - 2U_{i}^k + U_{i+1}^k}{\Delta x^2}
\frac{U^{k-1}_i - 2U^{k}_i + U^{k+1}_i}{\Delta t^2} = c^2\frac{U_{i-1}^k - 2U_{i}^k + U_{i+1}^k}{\Delta x^2}
$$

Rearranging the equation for the unknown value $U^{k+1}_i$ we get:
Expand Down Expand Up @@ -136,14 +136,19 @@ ensuring energy and flux consistency at the discrete level. The mimetic library
Rearranging our equation for the unknown value $U^{k+1}$ leads us to:

$$
(I-(\frac{c^2\Delta t^2}{2})L)U^{k+1}_i = 2U^k_i - (I-(\frac{c^2\Delta t^2}{2})L)U^{k-1}_i
U^{k+1}_i = 2U^k_i + c^2\Delta t^2LU^{k}_i - U^{k-1}_i
$$

Here, we can set A = $I-(\frac{c^2\Delta t^2}{2})L$ and b = $2U^k_i - (I-(\frac{c^2\Delta t^2}{2})L)U^{k-1}_i$, which rearranges our equation to:
$$A U^{k+1}_i = b$$
Now we can directly solve for our boundary condition with addScalarBC1D() and solve for $U^{i+1}$.

Now we can add our boundary condition with addScalarBC1D() and solve for $U^{i+1}$.
The boundary LHS are given by `addScalarBC`, and we can solve for the two endpoints (with n+1 points) $U(0)$ and $U(n)$. `addScalarBC` returns a modified LHS matrix (`L_bc`) and RHS vector (`b_bc`) in $AU=b$. Solving for only $U_0$ and $U_n$ with direct solves

```MATLAB
U1_md(1) = (b_bc(1) - L_bc(1, 2:end) * U1_md(2:end)) / L_bc(1,1);
U1_md(end) = (b_bc(end) - L_bc(end, 1:end-1) * U1_md(1:end-1)) / L_bc(end,end);
```

completes the solution for a single time step.

### Outputs
| Variable | Description |
Expand Down
Loading
Loading