Skip to main content
clarify a bit more.
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
(* The following isn't a working sample,
   it's just for illustration. *)
pdetoode[u[variables], t, grid, differenceorder, periodic]
pdetoode[{u, v, …}[variables], t, {grid1, grid2, …}, differenceorder, periodic]
pdetoode[{u[variables], v[variables],…},t, {grid1, grid2, …}, differenceorder, periodic]
(* The following isn't a working sample,
   it's just for illustration. *)
Outer[{x, y}|->u[x, y][t], gridx, gridy]
(* The following isn't a working sample,
   it's just for illustration. *)
NDSolve`FiniteDifferenceDerivative[{1, 1}, {gridx, gridy}, 
                                   Outer[{x, y}|->u[x, y]'[t], gridx, gridy], …]
(* The following isn't a working sample,
   it's just for illustration. *)
pos = Position[{var}, time][[1, 1]]
(* The following isn't a working sample,
   it's just for illustration. *)
…
pat = Repeated[_, {pos - 1}]
… [x1 : pat, t_, x2___] :> (Sow@coordtoindex@{x1, x2}; …
(* The following isn't a working sample,
   it's just for illustration. *)
Outer[{x, y}|->u[x, y][t], gridx, gridy][[-1, All]]
pdetoode[u[variables], t, grid, differenceorder, periodic]
pdetoode[{u, v, …}[variables], t, {grid1, grid2, …}, differenceorder, periodic]
pdetoode[{u[variables], v[variables],…},t, {grid1, grid2, …}, differenceorder, periodic]
Outer[{x, y}|->u[x, y][t], gridx, gridy]
NDSolve`FiniteDifferenceDerivative[{1, 1}, {gridx, gridy}, 
                                   Outer[{x, y}|->u[x, y]'[t], gridx, gridy], …]
pos = Position[{var}, time][[1, 1]]
pat = Repeated[_, {pos - 1}]
Outer[{x, y}|->u[x, y][t], gridx, gridy][[-1, All]]
(* The following isn't a working sample,
   it's just for illustration. *)
pdetoode[u[variables], t, grid, differenceorder, periodic]
pdetoode[{u, v, …}[variables], t, {grid1, grid2, …}, differenceorder, periodic]
pdetoode[{u[variables], v[variables],…},t, {grid1, grid2, …}, differenceorder, periodic]
(* The following isn't a working sample,
   it's just for illustration. *)
Outer[{x, y}|->u[x, y][t], gridx, gridy]
(* The following isn't a working sample,
   it's just for illustration. *)
NDSolve`FiniteDifferenceDerivative[{1, 1}, {gridx, gridy}, 
                                   Outer[{x, y}|->u[x, y]'[t], gridx, gridy], …]
(* The following isn't a working sample,
   it's just for illustration. *)
pos = Position[{var}, time][[1, 1]]
(* The following isn't a working sample,
   it's just for illustration. *)
…
pat = Repeated[_, {pos - 1}]
… [x1 : pat, t_, x2___] :> (Sow@coordtoindex@{x1, x2}; …
(* The following isn't a working sample,
   it's just for illustration. *)
Outer[{x, y}|->u[x, y][t], gridx, gridy][[-1, All]]
added 4 characters in body
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489

The function coordtoindex detects whether the discretized equation is a b.c. or not. If it's left boundary, it outputs -1; right boundary, 1,; not a boundary, All. These are all indexes for Part ([[]]). The output is throwed out by Sow and catched by Reap in the linefunction

The function coordtoindex detects whether the discretized equation is a b.c. or not. If it's left boundary, it outputs -1; right boundary, 1, not a boundary, All. These are all indexes for Part ([[]]). The output is throwed out by Sow and catched by Reap in the line

The function coordtoindex detects whether the discretized equation is a b.c. or not. If it's left boundary, it outputs -1; right boundary, 1; not a boundary, All. These are all indexes for Part ([[]]). The output is throwed out by Sow and catched by Reap in the function

improve formatting
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
pdetoode[u[variables], t, grid, differenceorder, periodic]
pdetoode[{u, v, …}[variables], t, {grid1, grid2, …}, differenceorder, periodic]
pdetoode[{u[variables], v[variables], …}, t, {grid1, grid2, …}, differenceorder, periodic]

Well, sometimes I feel that this syntax is a design miss, perhaps I should have made the syntax more simlar with NDSolve. We know, method of lines is a method that discretizes PDE(s) to a system of ODEs i.e. we need to discretize all the independent variables except for t (to be more precisepreciser, the independent variable of the resulting ODEs). For example, if the original dependent variable is u[x, t, y], it'll eventually be transformed to something equivalent to Outer[{x, y}|->u[x, y][t], gridx, gridy]; if

Outer[{x, y}|->u[x, y][t], gridx, gridy]

If it's Derivative[1, 1, 1][u][x, t, y], it's transformed to something equivalent to NDSolve`FiniteDifferenceDerivative[{1, 1}, {gridx, gridy}, Outer[{x, y}|->u[x, y]'[t], gridx, gridy], …]. (Notice

NDSolve`FiniteDifferenceDerivative[{1, 1}, {gridx, gridy}, 
                                   Outer[{x, y}|->u[x, y]'[t], gridx, gridy], …]

Notice this is done with a single fdd in the source code. )

For example, if we're discretizing u[x, t, y] in the domain $[1,4]\times[2,3]$, then u[1, t, y] will finally evaluate to something equivalent to Outer[{x, y}|->u[x, y][t], gridx, gridy][[-1, All]].

Outer[{x, y}|->u[x, y][t], gridx, gridy][[-1, All]]
pdetoode[u[variables], t, grid, differenceorder, periodic]
pdetoode[{u, v, …}[variables], t, {grid1, grid2, …}, differenceorder, periodic]
pdetoode[{u[variables], v[variables], …}, t, {grid1, grid2, …}, differenceorder, periodic]

Well, sometimes I feel that this syntax is a design miss, perhaps I should have made the syntax more simlar with NDSolve. We know, method of lines is a method that discretizes PDE(s) to a system of ODEs i.e. we need to discretize all the independent variables except for t (to be more precise, the independent variable of the resulting ODEs). For example, if the original dependent variable is u[x, t, y], it'll eventually be transformed to something equivalent to Outer[{x, y}|->u[x, y][t], gridx, gridy]; if it's Derivative[1, 1, 1][u][x, t, y], it's transformed to something equivalent to NDSolve`FiniteDifferenceDerivative[{1, 1}, {gridx, gridy}, Outer[{x, y}|->u[x, y]'[t], gridx, gridy], …]. (Notice this is done with a single fdd in the source code. )

For example, if we're discretizing u[x, t, y] in the domain $[1,4]\times[2,3]$, then u[1, t, y] will finally evaluate to something equivalent to Outer[{x, y}|->u[x, y][t], gridx, gridy][[-1, All]].

pdetoode[u[variables], t, grid, differenceorder, periodic]
pdetoode[{u, v, …}[variables], t, {grid1, grid2, …}, differenceorder, periodic]
pdetoode[{u[variables], v[variables],…},t, {grid1, grid2, …}, differenceorder, periodic]

Well, sometimes I feel that this syntax is a design miss, perhaps I should have made the syntax more simlar with NDSolve. We know, method of lines is a method that discretizes PDE(s) to a system of ODEs i.e. we need to discretize all the independent variables except for t (to be preciser, the independent variable of the resulting ODEs). For example, if the original dependent variable is u[x, t, y], it'll eventually be transformed to something equivalent to

Outer[{x, y}|->u[x, y][t], gridx, gridy]

If it's Derivative[1, 1, 1][u][x, t, y], it's transformed to something equivalent to

NDSolve`FiniteDifferenceDerivative[{1, 1}, {gridx, gridy}, 
                                   Outer[{x, y}|->u[x, y]'[t], gridx, gridy], …]

Notice this is done with a single fdd in the source code.

For example, if we're discretizing u[x, t, y] in the domain $[1,4]\times[2,3]$, then u[1, t, y] will finally evaluate to something equivalent to

Outer[{x, y}|->u[x, y][t], gridx, gridy][[-1, All]]
Typo fixed.
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
Loading
added 728 characters in body
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
Loading
added 372 characters in body
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
Loading
added 119 characters in body
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
Loading
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
Loading