QuantLib icon indicating copy to clipboard operation
QuantLib copied to clipboard

Question The Neumann Boundary Value in PDE

Open tony21248772 opened this issue 1 year ago • 2 comments

image

tony21248772 avatar Jun 18 '24 08:06 tony21248772

Thanks for posting! It might take a while before we look at your issue, so don't worry if there seems to be no feedback. We'll get to it.

boring-cyborg[bot] avatar Jun 18 '24 08:06 boring-cyborg[bot]

The Neumann condition fixes the value $V$ of the first derivative on the boundary. On a finite-difference grid, the derivative at the (e.g., left) boundary is the one-sided numerical derivative $\displaystyle\frac{u_1 - u_0}{h}$ where $h$ is the distance between the corresponding nodes on the grid. So the Neumann condition can be written as

$$\frac{u_1 - u_0}{h} = V$$

and in order to enforce it, in applyAfterApplying we modify the value of $u_0$ by setting it as

$$u_0 = u_1 - h \times V$$

which is equivalent to the above. Now, the code in applyAfterApplying seems to be missing the $h$, but that's because the documentation of the NeumannBC class says:

//! Neumann boundary condition (i.e., constant derivative)
/*! \warning The value passed must not be the value of the derivative.
             Instead, it must be comprehensive of the grid step
             between the first two points--i.e., it must be the
             difference between f[0] and f[1].

that is, the variable value_ stored in the class corresponds to $h \times V$.

lballabio avatar Jul 16 '24 14:07 lballabio

This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.

github-actions[bot] avatar Sep 15 '24 02:09 github-actions[bot]

This issue was automatically closed because it has been stalled for two weeks with no further activity.

github-actions[bot] avatar Sep 30 '24 02:09 github-actions[bot]