New answers tagged

5

The short answer is that you need $$\phi_{-1} = \phi_0$$ $$\phi_N = \phi_{N-1}$$ to impose $\nabla\phi=0$. A quick check by making the following change if idx == -1: idx = 0 elif idx == N: idx = N-1 in the code, you have posted shows that the average $\phi$ remains constant up to 14 decimal places. To see why this is the correct boundary condition ...


2

Here is a brute force solution that would work no matter what is the discontinuity and nonlinearity in $c(x,t)$. Write your PDE as a system of two: $ \dot{y}=z\\ \dot{z}=c^2(x,t) y_{xx} $ Now, discretize it on a uniform spatial grid in x: $ \vec{x}= [x_0, x_1,..., x_{n-1}] \\ \vec{y}= [y_0, y_1,..., y_{n-1}] \\ \vec{z}= [z_0, z_1,..., z_{n-1}] \\ $ Now the ...


3

$c$ depending on time is not the issue. You will use an RK scheme which takes care of this. The issue is $c$ is discontinuous in $x$. I recommend SBP-SAT schemes for this. (1) Derive an energy equation at PDE level. (2) Search literature for SBP-SAT schemes which enforce interface conditions via SAT penalty terms, which are designed to mimic the energy ...


11

Given code that computes a function $f(x)$, automatic differentiation tools produce a code that can compute $f(x)$ and its derivatives at the same time. Solving a differential equation is an entirely different problem and AD doesn't solve differential equations (although AD tools are sometimes useful in connection with PDE constrained optimization.) AD ...


1

Since you're solving the linear poisson equation $Ax = b$ I'd just check that the L2-norm of the residual vector illustrates convergence. I think the best thing to do is to calculate the initial norm $\rho_0 = ||b||_2$ and then have two tolerances, one relative ($\epsilon_r$) and one absolute ($\epsilon_a$) and you would terminate if either of them is ...


1

To expand on Wolfgang Bangerth's answer, I think P0 DG schemes reduce to two-point cell-centered finite volume schemes. I don't know if DG convergence analysis always includes $p = 0$, but the resulting finite volume schemes can be shown to converge under appropriate "mesh orthogonality" conditions. https://math.unice.fr/~minjeaud/Donnees/...


Top 50 recent answers are included