4

I was using the pdetoode function that @xzczd made: Dynamic Euler–Bernoulli beam equation

But it only works for functions with 2 variables, I was wondering if it could be changed to fit functions with 3 variables, and if so, how?

And this is how I try to use it:

eqnstest = D[T[x, y, t], y] == 0;
Tpdetood = pdetoode[T[x, y, t], y, gridy, 1];
eqnstest // Tpdetood

But this produces a whole list of errors, which I presume is because the method is not suited for it, I tried to contact the guy himself, but I have not found a way to do it on Stackexchange, and to comment you need 50 reputation to do that on other posts.

EDIT, added the code I am using for the total solution. The problem is that it won't evaluate since everything at the beginning just gives True, probably a result of "removeredundant" isn't accurate

P[x_, y_, t_] = e[x, y, t]/(γ - 1) ; 
e[x_, y_, t_] = (γ - 1) ρ[x, y, t]/(μ mu )kb T[x, y, t]; 
cp = 5/2 kb/(μ mu);
Rgas = 8.3144598;
cv = 5/2 kb/(μ mu) - Rgas;
γ = cp/cv;
g = 28.02*9.81;
μ = 0.6163328197226503`;
mu = 1.66053904*10^-27;
kb = 1.38064852*10^-23;
{grid@x, grid@y} = {Array[12000000/300 # &, 300], 
Array[4000000/100 # &, 100]};

eqns1 = D[ρ[x, y, t]*u[x, y, t], 
t] == -D[ρ[x, y, t]*u[x, y, t]*u[x, y, t] + P[x, y, t], x] - 
D[ρ[x, y, t]*u[x, y, t]*v[x, y, t], y];
eqns2 = D[ρ[x, y, t]*v[x, y, t], 
t] == -D[ρ[x, y, t]*v[x, y, t]*u[x, y, t], y] - 
D[ρ[x, y, t]*v[x, y, t]*v[x, y, t] + P[x, y, t], y] + 
g ρ[x, y, t];
eqns3 = D[ρ[x, y, t], t] == -D[ρ[x, y, t]*u[x, y, t], x] - 
D[ρ[x, y, t]*v[x, y, t], y];
eqns4 = D[e[x, y, t], t] == -D[u[x, y, t]*e[x, y, t], x] - 
D[v[x, y, t]*e[x, y, t], y] - 
P[x, y, t]*(D[u[x, y, t], x] - D[v[x, y, t], y]);
bc = {
v[x, 4000000, t] == 0,
v[x, 40000, t] == 0,
(D[u[x, y, t], y] /. y -> 40000) == 0,
(D[u[x, y, t], y] /. y -> 4000000) == 0,
ρ[x, 40000, t] == 0.0001999359999999999,
e[x, 40000, t] == 15562.721977320278 (γ - 1),
ρ[x, 4000000, t] == 0.003142381499745774,
e[x, 4000000, t] == 1.66117*10^6 (γ - 1)
};
ics = {v[x, y, 0] == 0, u[x, y, 0] == 0, 
T[x, y, 0] == 5000 + 0.008354149607 y, ρ[x, y, 0] == 
1.42*   10^-7*1.408*10^3 + 7.3561137493644*10^-10 y};
pdenoot1 = 
  pdetoode[{T, ρ, u, v}[x, y, t], t, {grid@x, grid@y}, 
    3, {True, False}];
    pdenoot2 = 
 pdetoode[{ρ, u, v}[x, y, t], t, {grid@x, grid@y}, 
3, {True, False}];
pdenoot3 = 
 pdetoode[{T, ρ, u, v}[x, y, t], t, {grid@x, grid@y}, 
 3, {True, False}];

 removeredundant = #[[5 ;; -5]] &;
del= #[[2 ;; -2, 1 ;; -1]] &;;
 odeq1 = del /@ del@pdenoot1@eqns1;
 odeq2 = del /@ del@pdenoot1@eqns2;
 odeq3 = del /@ del@pdenoot2@eqns3;
 odeq4 = del /@ del@pdenoot3@eqns4;
 odebcs = del /@ del@pdenoot1@bc;
 odeic = pdenoot1@ics;
 sollst = NDSolveValue[{odeq1, odeq2, odeq3, odeq4, odebcs, 
  odeic}, {ρ, T, u, v} /@ grid, {t, 0, 10}, 
    MaxSteps -> Infinity];

The following error shows up:

NDSolveValue::ndode: The equations {v[12000000,40000][0]==0,v[12000000,80000][0]==0,v[12000000,120000][0]==0,v[12000000,160000][0]==0,v[12000000,200000][0]==0,v[12000000,240000][0]==0,v[12000000,280000][0]==0,v[12000000,320000][0]==0,v[12000000,360000][0]==0,v[12000000,400000][0]==0,v[12000000,440000][0]==0,v[12000000,480000][0]==0,v[12000000,520000][0]==0,v[12000000,560000][0]==0,v[12000000,600000][0]==0,v[12000000,640000][0]==0,<<19>>,v[12000000,1440000][0]==0,v[12000000,1480000][0]==0,v[12000000,1520000][0]==0,v[12000000,1560000][0]==0,v[12000000,1600000][0]==0,v[12000000,1640000][0]==0,v[12000000,1680000][0]==0,v[12000000,1720000][0]==0,v[12000000,1760000][0]==0,v[12000000,1800000][0]==0,v[12000000,1840000][0]==0,v[12000000,1880000][0]==0,v[12000000,1920000][0]==0,v[12000000,1960000][0]==0,v[12000000,2000000][0]==0,<<350>>} are not differential equations or initial conditions in the dependent variables {TemporaryVariable$10000,TemporaryVariable$100000,TemporaryVariable$100001,TemporaryVariable$100002,TemporaryVariable$100003,TemporaryVariable$100004,TemporaryVariable$100005,TemporaryVariable$100006,TemporaryVariable$100007,TemporaryVariable$100008,TemporaryVariable$100009,TemporaryVariable$10001,TemporaryVariable$100010,TemporaryVariable$100011,TemporaryVariable$100012,TemporaryVariable$100013,<<20>>,TemporaryVariable$100032,TemporaryVariable$100033,TemporaryVariable$100034,TemporaryVariable$100035,TemporaryVariable$100036,TemporaryVariable$100037,TemporaryVariable$100038,TemporaryVariable$100039,TemporaryVariable$10004,TemporaryVariable$100040,TemporaryVariable$100041,TemporaryVariable$100042,TemporaryVariable$100043,TemporaryVariable$100044,<<119550>>}.

1 Answers1

3

pdetoode and pdetoae can deal with multidimensional PDE of course, actually I've solved multidimensional problem with them in several posts, for example here and here. To discretize the toy example in your question, you just need to:

eqnstest = D[T[x, y, t], y] == 0;
domain@x = {0, 1};
domain@y = {0, 2};
points@x = points@y = 5;
grid@x = Array[# &, points@x, domain@x];
grid@y = Array[# &, points@y, domain@y];
differenceorder=2;

Tpdetood = pdetoode[T[x, y, t], t, {grid@x, grid@y}, differenceorder];
eqnstest // Tpdetood

Notice definition of grid and Tpdetood can be shorten to:

(grid@# = Array[# &, points@#, domain@#]) & /@ {x, y};
Tpdetood = pdetoode[T[x, y, t], t, grid /@ {x, y}, differenceorder];
xzczd
  • 65,995
  • 9
  • 163
  • 468