1
$\begingroup$

I want to solve 3 coupled equations. I converted them to a system of odes in time and discrete it in Length and radius. Now I have a problem in one of the equations in first point. Because in this point I have A second order derivative and when I discretize it I dont have $y$ in second point. This is my equation:

$\frac{dy}{dy} = \frac{d^{2}y}{dr^{2}}+k(y-q)$.

This is the discretized form in matlab:

$\frac{dy}{dt} = \frac{y(i+2)-2y(i+1)+y(i)}{\Delta{r}^{2}}+k(y(i)-q(i))$

Now in $i=1$ we dont have points $2$ and $3$ and they will calculate in next line in MATLAB. What should I do?

$\endgroup$
  • $\begingroup$ The important omission here is that you don't state what your boundary conditions are. $\endgroup$ – Wolfgang Bangerth Dec 28 '15 at 17:47
0
$\begingroup$

Your problems is with $y(i+2)$ ? You have to first put some initial conditiones, witch would be y(0)....y(n). Besides the boundarys.

Imagine if you were solving waves in a string. The initial conditions would be the shape of the string... Hence $y(r,t=0)=f(r)$ . That when discretized give the initial values for $y(i+1)$ and $y(i+2)$ .

| cite | improve this answer | |
$\endgroup$
1
$\begingroup$

Please try to improve your explanation:

with the index i do you refer to the space variable or time one?

Anyway, as far as I understood from your post, I think that you need to enforce some boundary condition if you're dealing at the end/beginning of your spatial domain.

Usually, according to the physics of your problem, you have to enforce Neumann or Dirichlet BCs (https://en.wikipedia.org/wiki/Neumann_boundary_condition, https://en.wikipedia.org/wiki/Dirichlet_boundary_condition) or maybe other types.

If you give me a better explanation I can support you in this process.

| cite | improve this answer | |
$\endgroup$
0
$\begingroup$

I assume you are solving an initial-value problem, so that $y(r, t=0)$ is known. Your temporal discretization will determine what to do -- for example, using forward Euler, you would get: $$y(r, t+\delta t) = y(r,t) + \delta \, f(y(r,t)),$$ where $f$ represents you right-hand side. This is the simplest explicit scheme, see this explanation, which you probably should not use in practice. There are many alternatives, e.g. Runge-Kutta methods.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ you mean it needs just one step past in time. but in MATLAB the program run line by line. i confused and cant combine these two method.when it is in first line what is the second point? you mean that all the points run together in MATLAB? $\endgroup$ – fatemeh Dec 27 '15 at 6:13
  • 1
    $\begingroup$ There are basically two options: 1) Only information from previous time steps is used (explicit schemes). The order in which "Matlab runs lines" does not matter. 2) Information from previous and future time steps is used (implicit schemes), and you have to solve a linear system. If you need more information, it might be best to consult an introductory textbook on numerically solving PDE's. $\endgroup$ – Jannis Teunissen Dec 28 '15 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.