4

I have been trying to solve the following three coupled PDEs where the final objective is to find the distributions $\theta_h, \theta_c$ and $\theta_w$:

$x\in[0,1]$ and $y\in[0,1]$

$$\frac{\partial \theta_h}{\partial x}+\beta_h (\theta_h-\theta_w) = 0 \tag A$$

$$\frac{\partial \theta_c}{\partial y} + \beta_c (\theta_c-\theta_w) = 0 \tag B$$

$$\lambda_h \frac{\partial^2 \theta_w}{\partial x^2} + \lambda_c V\frac{\partial^2 \theta_w}{\partial y^2}-\frac{\partial \theta_h}{\partial x} - V\frac{\partial \theta_c}{\partial y} = 0 \tag C$$

where, $\beta_h, \beta_c, V, \lambda_h, \lambda_c$ are constants. The boundary conditions are:

$$\frac{\partial \theta_w(0,y)}{\partial x}=\frac{\partial \theta_w(1,y)}{\partial x}=\frac{\partial \theta_w(x,0)}{\partial y}=\frac{\partial \theta_w(x,1)}{\partial y}=0$$

$$\theta_h(0,y)=1, \theta_c(x,0)=0$$

A user in Mathematics stack exchange suggested me the following steps that might work towards solving this problem:

  1. Represent each of the three functions using 2D Fourier series
  2. Observe that all equations are linear
  • Thus there is no frequency coupling
  • Thus for every pair of frequencies $\omega_x$, $\omega_y$ there will be a solution from a linear combination of only those terms
  1. Apply boundary conditions directly to each of the three series
  • Note that by orthogonality the boundary condition has to apply to each term of the fourier series
  1. Plug in Fourier series into PDE and solve coefficient matching (see here for example in 1D). Make sure you treat separately the cases when one or both of the frequencies are zero.
  2. If you consider all equations for a given frequency pair, you can arrange them into an equation $M\alpha = 0$, where $\alpha$ are fourier coefficients for that those frequencies, and $M$ is a small sparse matrix (sth like 12x12) that will only depend on the constants.
  3. For each frequency, the allowed solutions will be in the Null space of that matrix. In case you are not able to solve for the null space analytically, it is not a big deal - calculating null space numerically is easy, especially for small matrices.

Can someone help me in applying these steps in Mathematica ?

PDE1 = D[θh[x, y], x] + bh*(θh[x, y] - θw[x, y]) == 0;

PDE2 = D[θc[x, y], y] + bc*(θc[x, y] - θw[x, y]) == 0;

PDE3 = λhD[θw[x, y], {x, 2}] + λcV(D[θw[x, y], {y, 2}]) - D[θh[x, y], x] - VD[θc[x, y], y] ==0

bh=0.433;bc=0.433;λh = 2.33 10^-6; λc = 2.33 10^-6; V = 1;

NDSolve solution (Wrong results)

PDE1 = D[θh[x, y], x] + bh*(θh[x, y] - θw[x, y]) == 0;

PDE2 = D[θc[x, y], y] + bc*(θc[x, y] - θw[x, y]) == 0;

PDE3 = λhD[θw[x, y], {x, 2}] + λcV(D[θw[x, y], {y, 2}]) - D[θh[x, y], x] - VD[θc[x, y], y] == NeumannValue[0, x == 0.] + NeumannValue[0, x == 1] + NeumannValue[0, y == 0] + NeumannValue[0, y == 1];

bh = 1; bc = 1; λh = 1; λc = 1; V = 1;(Random
values
)

sol = NDSolve[{PDE1, PDE2, PDE3, DirichletCondition[θh[x, y] == 1, x == 0], DirichletCondition[θc[x, y] == 0, y == 0]}, {θh, θc, θw}, {x, 0, 1}, {y, 0, 1}]

Plot3D[θw[x, y] /. sol, {x, 0, 1}, {y, 0, 1}]

Towards a separable solution

I wrote $\theta_h(x,y) = \beta_h e^{-\beta_h x} \int e^{\beta_h x} \theta_w(x,y) \, \mathrm{d}x$ and $\theta_c(x,y) = \beta_c e^{-\beta_c y} \int e^{\beta_c y} \theta_w(x,y) \, \mathrm{d}y$ and eliminated $\theta_h$ and $\theta_c$ from Eq. (C). Then I used the ansatz $\theta_w(x,y) = e^{-\beta_h x} f(x) e^{-\beta_c y} g(y)$ on this new Eq. (C) to separate it into $x$ and $y$ components. Then on using $F(x) := \int f(x) \, \mathrm{d}x$ and $G(y) := \int g(y) \, \mathrm{d}y$, I get the following two equations:

\begin{eqnarray} \lambda_h F''' - 2 \lambda_h \beta_h F'' + \left( (\lambda_h \beta_h - 1) \beta_h - \mu \right) F' + \beta_h^2 F &=& 0,\\ V \lambda_c G''' - 2 V \lambda_c \beta_c G'' + \left( (\lambda_c \beta_c - 1) V \beta_c + \mu \right) G' + V \beta_c^2 G &=& 0, \end{eqnarray} with some separation constant $\mu \in \mathbb{R}$. However I could not proceed any further.

A partial-integro differential equation

Eliminating $\theta_h, \theta_c$ from the Eq. (C) gives rise to a partio-integral differential equation:

\begin{eqnarray} 0 &=& e^{-\beta_h x} \left( \lambda_h e^{\beta_h x} \frac{\partial^2 \theta_w}{\partial x^2} - \beta_h e^{\beta_h x} \theta_w + \beta_h^2 \int e^{\beta_h x} \theta_w \, \mathrm{d}x \right) +\\ && + V e^{-\beta_c y} \left( \lambda_c e^{\beta_c y} \frac{\partial^2 \theta_w}{\partial y^2} - \beta_c e^{\beta_c y} \theta_w + \beta_c^2 \int e^{\beta_c y} \theta_w \, \mathrm{d}y \right). \end{eqnarray}

SPIKES

For bc = 4; bh = 2; λc = 0.01; λh = 0.01; V = 2;

However, the same parameters but with V=1 work nicely.

enter image description here

Some reference material for future users

In order to understand the evaluation of Fourier coefficients using the concept of minimization of least squares which @bbgodfrey uses in his answer, future users can look at this paper by R. Kelman (1979). Alternatively this presentation and this video are also useful references.

Avrana
  • 297
  • 1
  • 4
  • 14
  • 1
    Show equations and formulae as Mathematica code. Also show what you have tried so far in code. – MarcoB Nov 29 '20 at 18:07
  • Have added the equations as mathematica scripts. Unfortunately, I haven't been able to proceed in this problem according to the mentioned steps. Although, I know how to solve the coupled system using NDSolve, but I am aiming for a semi-analytical solution and hence the question. – Avrana Nov 29 '20 at 18:32
  • @bbgodfrey Have added the NDSolve solution. – Avrana Nov 30 '20 at 04:52
  • Plot[θw[x, y] /. sol /. y -> 1/2, {x, 0, 1}] shows that D[θw[x, 1/2] , x] does not vanish ax x = 0. So, the numerical solution is incorrect. – bbgodfrey Nov 30 '20 at 12:37
  • @bbgodfrey Oh ok. Your observation seems valid. Also, another point that I am unsure about is that the suggested steps instructs to write $\theta_h. \theta_c, \theta_w$ as 2D Fourier series which has 4 undetermined Constants. However, since these are 2D functions shouldn't one just write the 2 constant Fourier series. Also, finally can you suggest a way to solve these coupled equations analytically or semi-analytically ? – Avrana Nov 30 '20 at 12:47
  • @bbgodfrey I managed to variable separate Eq. (C) which I have now added but could not proceed further. Additionally, this system of equations also leads to a Partio-Integral DE which too I have added. Have a look if you are interested. – Avrana Nov 30 '20 at 14:53
  • 1
    I too have separated the equations and can solve them, but not with θh[0, y] == 1. Also, I do not believe that the equations can be Fourier-decomposed, because the solution for θh almost certainly is not periodic with period 1. – bbgodfrey Nov 30 '20 at 15:33
  • @bbgodfrey Great ! Can this problem of non-homogeneous condition of $\theta_h(0,y)=1$ be bypassed if we define a dunction $\bar{\theta_h}(x,y):=\theta_h(x,y)-1$. What condition did you use for your solution ? In any case do post your approach if/when you are ok with it. – Avrana Nov 30 '20 at 16:18
  • 3
    Transforming θh certainly solves the boundary condition issues, but the first equation becomes inhomogeneous and no longer is separable. However, it might be possible to construct a Green's function from the homogeneous transformed system and then use it to obtain the solution to the inhomogeneous system. – bbgodfrey Nov 30 '20 at 16:34
  • @bbgodfrey Appreciate your sustained inputs. Yes, I realize now that it will become a non-homogeneous governing equation. I am not familiar with the Greens function methods. If its not too much to ask, can you give this problem an attempt ?Thanks in any case. – Avrana Nov 30 '20 at 16:42
  • @bbgodfrey An update: Upon using the substitution $\bar\theta_h:=\theta_h-1$ across all the equations, Eq. (A) and Eq. (C) become non-homogeneous. But, subsequently when I substitute the integral form of $\bar\theta_h$ and $\theta_c$ in the new Eq. (C) and use the ansatz $\theta_w=e^{-\beta_h x}f(x)e^{-\beta_c y}g(y)$, the resulting equation becomes homogeneous and separates. – Avrana Dec 01 '20 at 15:03
  • @bbgodfrey Hi. Could you make any headway ? I apologize to be so disturbing, but I wanted to let you know that I have a three-dimensional version (which I framed when I could not get this 2D version to work in my previous attempts) of the same problem here. However, even when the 3D version avoids the complications, it avoided analytical solution. – Avrana Dec 02 '20 at 05:47
  • @bbgodfrey Much appreciated. – Avrana Dec 02 '20 at 17:24
  • 1
    @IndrasisMitra The 3D problem cannot be solved by the method I used here. Instead, expand the equations in a Fourier Cosine series in x and y, which converts the two auxiliary ODEs into matrices, invert the matrices, and use the results to solve the Laplace equation in z. Two potential problems are that the matrices may need to be quite large for accurate results, and the Gibbs Phenomenon may arise. I shall not have time to solve the system until next weekend. – bbgodfrey Dec 13 '20 at 13:15
  • Thanks again! Meanwhile, I will give your suggestions on expanding the fluid equations an attempt. – Avrana Dec 13 '20 at 16:27
  • @bbgodfrey could you make any headway with the 3d problem? I did try expanding the equations, but am still struggling with the subsequent steps. Thanks. – Avrana Dec 20 '20 at 02:05
  • @IndrasisMitra I have thought about the 3D problem but shall not have time to work on it seriously until Tuesday. It is clear to me that the equations should be renormalized to resemble the 2D equations as much as possible, so that the only inhomogeneous boundary condition is on the surface z = 1, where {x, y, z,} all are renormalized to range over {0, 1}. And, T is renormalized to (T - tc)/(th - tc) I presume that {λh, λc} are the reciprocals of the squares of the lengths in {x, y}. But, what is V? – bbgodfrey Dec 21 '20 at 03:09
  • @bbgodrey I have tried to non-dimensionalize the problem in 3D space and have added a section to that question. The term V figures in the 2D problem governing equation only when the wall is considered as a two -dimensional entity. It is basically the ration of heat capacity of the cold and the hot fluids i.e. $V=C_c/C_h$. The infinitesimally small 3D element assumed inside the wall (in the 3D version) is not in contact with any of the fluids as the fluids are on the z-boundaries and come into play as the boundary conditions. – Avrana Dec 21 '20 at 06:08
  • However, in the 2D version the infinitesimally small rectangular element has the fluids exchanging heat with this 2D element and their capacity ratios become a part of the wall governing equation. Please let me know, if I could be of any more help or clarify things up. I hope I have been clear in the explanation. – Avrana Dec 21 '20 at 06:09

2 Answers2

4

Edits: Replaced 1-term expansion by n-term expansion; improved generality of eigenvalue and coefficient computations; reordered and simplified code.

Beginning with this set of equations, proceed as follows to obtain an almost symbolic solution.

ClearAll[Evaluate[Context[] <> "*"]]
eq1 = D[θh[x, y], x] + bh (θh[x, y] - θw[x, y])
eq2 = D[θc[x, y], y] + bc (θc[x, y] - θw[x, y])
eq3 = λh D[θw[x, y], x, x] + λc V D[θw[x, y], y, y] + bh (θh[x, y] - θw[x, y]) + 
    V bc (θc[x, y] - θw[x, y])

First, convert these equations into ODEs by the separation of variables method.

th = Collect[(eq1 /. {θh -> Function[{x, y}, θhx[x] θhy[y]], 
    θw -> Function[{x, y}, θwx[x] θwy[y]]})/(θhy[y] θwx[x]), 
    {θhx[x], θhx'[x], θwy[y]}, Simplify];
1 == th[[1 ;; 3 ;; 2]];
eq1x = Subtract @@ Simplify[θwx[x] # & /@ %] == 0
1 == -th[[2]];
eq1y = θhy[y] # & /@ %
(* bh θhx[x] - θwx[x] + θhx'[x] == 0
   θhy[y] == bh θwy[y] *)

tc = Collect[(eq2 /. {θc -> Function[{x, y}, θcx[x] θcy[y]], θw -> Function[{x, y}, θwx[x] θwy[y]]})/(θcx[x] θwy[y]), {θcy[y], θcy'[y], θwy[y]}, Simplify]; 1 == -tc[[1]]; eq2x = θcx[x] # & /@ % 1 == tc[[2 ;; 3]]; eq2y = Subtract @@ Simplify[θwy[y] # & /@ %] == 0 (* θcx[x] == bc θwx[x] bc θcy[y] - θwy[y] + [θcy[y] == 0 *)

tw = Plus @@ ((List @@ Expand[eq3 /. {θh -> Function[{x, y}, θhx[x] θhy[y]], θc -> Function[{x, y}, θcx[x] θcy[y]], θw -> Function[{x, y}, θwx[x] θwy[y]]}])/ (θwx[x] θwy[y]) /. Rule @@ eq2x /. Rule @@ eq1y); sw == -tw[[1 ;; 5 ;; 2]]; eq3x = Subtract @@ Simplify[θwx[x] # & /@ %] == 0 sw == tw[[2 ;; 6 ;; 2]]; eq3y = -Subtract @@ Simplify[θwy[y] # & /@ %] == 0 (* bh^2 θhx[x] - bh θwx[x] + sw θwx[x] + λh θwx''[x] == 0 bc^2 V θcy[y] - (sw + bc V) θwy[y] + V λc θwy''[y] == 0 *)

With the equations separated into ODEs, solve the y-dependent equations with the boundary conditions applied. The resulting expressions, involving RootSum, are lengthy and so are not reproduced here.

sy = DSolveValue[{eq2y, eq3y, θcy[0] == 0, θwy'[0] == 0}, {θwy[y], θcy[y], θwy'[1]}, 
     {y, 0, 1}] /. C[2] -> 1;

This is, of course, an eigenvalue problem with nontrivial solutions only for discrete values of the separation constant, sw. The dispersion relation for sw is given by θwy'[1] == 0. The corresponding x dependence is determined for each eigenvalue by

sx = DSolveValue[{eq1x, eq3x, θwx'[0] == 0, θwx'[1] == 0, θhx[0] == 1}, 
    {θwx[x], θhx[x]}, {x, 0, 1}];

and it is at this point that the inhomogeneous boundary condition, θhx[0] == 1, is applied. This result also is too lengthy to reproduce here.

Next, numerically determine the first several (here, n = 6) eigenvalues, which requires specifying the parameters:

bc = 1; bh = 1; λc = 1; λh = 1; V = 1;

disp = sy[[3]] (* RootSum[sw + #1 + sw #1 - #1^2 - #1^3 &, (E^#1 sw + E^#1 #1 + E^#1 sw #1)/(-1 - sw + 2 #1 + 3 #1^2) &] *)

n = 6; Plot[disp, {sw, -300, 10}, AxesLabel -> {sw, "disp"}, LabelStyle -> {15, Bold, Black}, ImageSize -> Large]

enter image description here

The first several eigenvalues are estimated from the zeroes of the plot and then computed to high accuracy.

Partition[Union @@ Cases[%, Line[z_] -> z, Infinity], 2, 1];
Reverse[Cases[%, {{z1_, z3_}, {z2_, z4_}} /; z3 z4 < 0 :> z1]][[1 ;; n]];
tsw = sw /. Table[FindRoot[disp, {sw, sw0}], {sw0, %}]
(* {-0.635232, -10.7982, -40.4541, -89.8156, -158.907, -247.736} *)

and the corresponding eigenfunctions obtained by plugging these values of sw into sy[1;;2] and sx.

Plot[Evaluate@ComplexExpand@Replace[sy[[1]], 
    {sw -> #} & /@ tsw, Infinity], {y, 0, 1}, AxesLabel -> {y, θwy}, 
    LabelStyle -> {15, Bold, Black}, ImageSize -> Large]
Plot[Evaluate@ComplexExpand@Replace[sy[[2]], 
    {sw -> #} & /@ tsw, Infinity], {y, 0, 1}, AxesLabel -> {y, θhy}, 
    LabelStyle -> {15, Bold, Black}, ImageSize -> Large]

enter image description here

enter image description here

Plot[Evaluate@ComplexExpand@Replace[sx[[1]], 
    {sw -> #} & /@ tsw, Infinity], {x, 0, 1}, AxesLabel -> {x, θwx}, 
    LabelStyle -> {15, Bold, Black}, ImageSize -> Large, PlotRange -> {0, 1}]
Plot[Evaluate@ComplexExpand@Replace[sx[[2]], 
    {sw -> #} & /@ tsw, Infinity], {x, 0, 1}, AxesLabel -> {x, θhx}, 
    LabelStyle -> {15, Bold, Black}, ImageSize -> Large, PlotRange -> {0, 1}]

enter image description here

enter image description here

With the first n complete eigenfunctions computed, their coefficients next are determined, so that they can be summed to approximate the solution to the original equations. This is done by least-squares, because the ODE system is not self-adjoint.

syn = ComplexExpand@Replace[bh sy[[1]] /. C[2] -> 1, {sw -> #} & /@ tsw, 
    Infinity] // Chop//Chop;
Integrate[Expand[(1 - Array[c, n].syn)^2], {y, 0, 1}] // Chop;
coef = ArgMin[%, Array[c, n]]
(* {0.974358, 0.0243612, 0.000807808, 0.000341335, 0.0000506603, \

0.0000446734} *)

The quality of the fit is very good.

Plot[coef.syn - 1, {y, 0, 1}, AxesLabel -> {y, err}, 
    LabelStyle -> {15, Bold, Black}, ImageSize -> Large]

enter image description here

Finally, construct the solution.

solw = coef.ComplexExpand@Replace[sy[[1]] sx[[1]], {sw -> #} & /@ tsw, Infinity];
Plot3D[solw, {x, 0, 1}, {y, 0, 1}, AxesLabel -> {x, y, θw}, 
    LabelStyle -> {15, Bold, Black}, ImageSize -> Large]

enter image description here

solh = coef.ComplexExpand@Replace[bh sy[[1]] sx[[2]], {sw -> #} & /@ tsw, Infinity];
Plot3D[solh, {x, 0, 1}, {y, 0, 1}, AxesLabel -> {x, y, θh}, 
    LabelStyle -> {15, Bold, Black}, ImageSize -> Large, PlotRange -> {0, 1}]

enter image description here

solc = coef.ComplexExpand@Replace[bc sy[[2]] sx[[1]], {sw -> #} & /@ tsw, Infinity];
Plot3D[solc, {x, 0, 1}, {y, 0, 1}, AxesLabel -> {x, y, θc}, 
    LabelStyle -> {15, Bold, Black}, ImageSize -> Large, PlotRange -> {0, 1}]

enter image description here

Because this derivation is lengthy, we show here that the equations themselves are satisfied identically.

Chop@Simplify[{eq1, eq2, eq3} /. {θh -> Function[{x, y}, Evaluate@solh], 
    θc -> Function[{x, y}, Evaluate@solc], θw -> Function[{x, y}, Evaluate@solw]}]
(* {0, 0, 0} *)

Furthermore, the boundary condition on θh is satisfied to better than 0.004%, and the boundary condition on θc is satisfied identically.

The corresponding 3D computation has been completed at 226346.

bbgodfrey
  • 61,439
  • 17
  • 89
  • 156
  • Thanks. This is very elaborate. Will go through each step now and revert. – Avrana Dec 06 '20 at 03:09
  • @IndrasisMitra Example 1 here provides the essence of separation of variables to solve a PDE. The final equation in the example cannot be used here, however, because it is valid only for self-adjoint equations. Instead, minimizing the integral of the square of the difference between the eigenfunction sum and the function to be approximated (here, 1) can be used, if multiple terms in the sum are desired. – bbgodfrey Dec 06 '20 at 05:16
  • Thankyou for this detailed solution. I have been going through it and have been able to follow it to a large extent. I have a few questions: 1. You have used the value C[2]=1 after getting the solution to the system sy. How do we arrive at this value of the constant ? 2. While evaluating solw, solh, solc using the first eigenfunction you use C[2] -> 1/sint where sint is the average value of the first eigenfunction. – Avrana Dec 06 '20 at 12:07
  • 1
    @IndrasisMitra The value of C[1] does not matter when finding the roots of disp, so I sent it to 1 arbitrarily. I use C[2] -> 1/sint to fit θwy to 1. However, I am working on a multiterm expansion to provide a better fit and shall publish it here in a few hours. Then I shall look at your second case. – bbgodfrey Dec 06 '20 at 12:17
  • I have been going through your edits. I see that C[2] -> 1/sint is no longer needed when you are summing up the coefficients and the solution behaves very nicely. This method of least squares was something I was completely unaware of. Also, when the eigen values are being evaluated using the FindRoot command, are the values being supplied in this line, written after looking at the disp vs sw plot ? – Avrana Dec 06 '20 at 17:02
  • Finally, the reason I called the results I obtained with the new set of values (bc -> 4, bh -> 4, λc -> 0.04, λh -> 0.04, V -> 1,) as unphysical is that θh,θc,θw are non-dim. quant. (temperatures actually) and are supposed to stay between the extremes of 0 to 1. This I forgot to mention in my last comment. – Avrana Dec 06 '20 at 17:03
  • 1
    @IndrasisMitra Yes, I used approximate value from the plot as starting values for FindRoot. However, just a few minutes ago I automated the process, which was not difficult. I shall look at your second set of parameters later today. – bbgodfrey Dec 06 '20 at 17:55
  • @IndrasisMitra I found a missing factor bh in sy6, now fixed. The solution for your second set of parameters now looks credible to me. By the way, the link I provided in an earlier comments works for me. – bbgodfrey Dec 06 '20 at 19:09
  • Apologies for the late reply. But the correction about bh in sy6 you made is throwing up a Tensors have incompatible shape error for me. However, this only happens when I use my second set of values. I have added a screenshot of this to my original post. – Avrana Dec 07 '20 at 04:31
  • @IndrasisMitra Thanks for looking hard at my answer, I found and corrected a few transcription errors, the most important of which was failing to include bh -> 1, in the code for sy6. It should work now. By the way, be sure that tsw has precisely six elements. – bbgodfrey Dec 07 '20 at 06:15
  • Thanks for the continuous updates. I am obliged. Your last comment sorted things out. The second set of parameters was producing much more than six of sw values because of the range -300,10 supplied to it and they were all being imported to the tsw table. I changed it to -14, 10 which produced precisely six values. And the subsequent steps worked out perfectly. – Avrana Dec 07 '20 at 06:41
  • However, is there a way I can limit the number of values being imported to tsw are only the first six of the sw values i.e. without fiddling with the range provided while calculating sw ? That would be a nice automation. Maybe the step is trivial, but needs more Mathematica knowledge. – Avrana Dec 07 '20 at 06:45
  • 1
    @IndrasisMitra Yes, this is easy to do, and I shall add the code in a few minutes. However, not having enough eigenvalues is more difficult to address. – bbgodfrey Dec 07 '20 at 06:46
  • Some final comments: (1) This solution works perfectly fine for some sets of parameters but for some sets like bc -> 4, bh -> 8, λc -> 0.005, λh -> 0.01, V -> 2, which correspond to a different exchanger configuration, the results go haywire. This might be due to the less number of terms in the solution ? (2) Can you point me to a reference describing the "minimizing the integral of the square of the difference between the eigenfunction sum and the function to be approximate" ? – Avrana Dec 07 '20 at 12:42
  • (3) Finally, if time permits have a look at the three-dimensional version of the problem I linked previously. Thanks for all the inputs till now. We are planning some experiments on miniaturized cross-flow exchanger and would like to cite this answer and you if everything works out. – Avrana Dec 07 '20 at 12:48
  • 1
    @IndrasisMitra The default value of WorkingPrecision is inadequate for your last set of parameters, as can be seen from the plots of sx. Using rational values for the parameters helps a bit, but not enough. Using WorkingPrecision -> 30 in every numerical calculation should be adequate, and revising the code is straightforward. However, I will not have time for a few days. Search google for discussions of the minimization process. – bbgodfrey Dec 07 '20 at 13:40
  • Appreciate it. Yes I have found some documents discussing the procedure. It was inconsiderate of me to ask everything here before a thorough search. – Avrana Dec 07 '20 at 14:11
  • 1
    @IndrasisMitra I modified the code to improve the generality of the tsw and coef computations. For your most recent test case, at least n = 12 eigenvalues are needed, WorkingPrecision ->30 must be added in FindRoot, and ComplexExpand in plot arguments. The coef computation takes a few minutes now. By the way, I plan to simplify the code in the answer this weekend. – bbgodfrey Dec 10 '20 at 12:51
  • Much much appreciated. I have been trying certain different cases which have worked perfectly to a certain extent with your modifications. Although the error in a few cases is quite high even with twelve eigen values. I will test more cases with more terms. Thanks again. – Avrana Dec 10 '20 at 17:24
  • The code is much more clearer now especially how the solution is being constructed. It works nicely. However, tsw = sw /.Table[FindRoot[disp, {sw, sw0}, WorkingPrecision -> 30], {sw0, %}],and Plot[disp, {sw, -300, 10}, AxesLabel -> {sw, "disp"}, LabelStyle -> {15, Bold, Black}, ImageSize -> Large, WorkingPrecision -> 30] and coef = ArgMin[%, Array[c, n], WorkingPrecision -> 30] are the places where I am adding the precision command for the different set of parameters with n=12 roots. However, these result in spikes at the domain edges. I am attaching a figure. – Avrana Dec 11 '20 at 12:53
  • 1
    @IndrasisMitra Yes, sometimes greater WorkingPrecision is necessary, particularly in tsw because it feeds the rest of the computation. Keep an eye on syn too. The change I made to Integrate reduces run time a lot but may reduce precision too. – bbgodfrey Dec 11 '20 at 14:05
  • Thanks for all the help ! I will get this to work by keeping eye on individual cases as you have recommended. However, I would solicit you to have a look once at the 3D version, This is because, although that version is a manifestation of this same problem, its three-dimensional nature allows it to take one more physical effect into consideration (i.e. the wall resistance) and is hence more general. – Avrana Dec 11 '20 at 15:32
  • In one of your earlier comments, you explained that the function to be approximated is 1 (this is used to determine the coefficients using square error minimization Integrate[Expand[(1 - Array[c, n].syn)^2], {y, 0, 1}]). However, while going through this problem again, I still have some unclarity regarding this. Is this the non-homogeneous b.c. $\theta_h(0,y)=1$ ? – Avrana Jan 16 '22 at 13:49
  • I have sorted this out, it is the non-homogeneous condition being fitted using the least squares approach. – Avrana Jan 23 '22 at 09:05
2

The solution I get with Version 12.0.0 looks indeed inconsistent. I compare the solution rather close to the one shown on the documenation page for NDSolve in the section Possible Issues -> Partial Differential Equations with the example for the Laplace equation with initial values.

For the partial differential equation system given and for the value set only with one I can use NDSolve for this result:

enter image description here

The similarity is not the divergence that drops to the origin but the row of spikes that can be seen at about $x=.3$ and $y=0.3$ for $_h$ and $_c$. This coupling is though really unphysical. But there is some more seemingly useful information with the experiment. For the other given set of constants the decoupling between the two component not multiplied with the $_ℎ,_$ of order $10^-6$ are very little varying in the unit square and very gigantic close to the disturbance from the initial conditions.

So a closed solution is not available with the constants. The given question is ill-posed and shows up as numerical instability.

The set of equation decouples by $_ℎ,_$.

$(A')$ $\frac{\partial\theta_h}{\partial x}=-\beta_h\theta_h$

$(B')$ $\frac{\partial\theta_c}{\partial x}=-\beta_h\theta_c$

$(C')$->

$(C1)$ $ _ℎ\frac{∂^2_}{∂^2}+_ \frac{∂^2_}{∂^2}=0$

$(C1)$ $−\frac{∂_h}{∂}−\frac{∂_}{∂}=0$

where, $_ℎ,_,,_ℎ,_$ are constants.

The boundary conditions are:

(I)

$\frac{∂_(0,)}{∂}=\frac{∂_(1,)}{∂}=\frac{∂_(,0)}{∂}=\frac{∂_(,1)}{∂}=0

This are von Neumann boundary conditions.

In Mathematica it is sufficient to enter them this way:

NeumannValue[\[Theta]w[x, y]==0, x == 1 || x == 1 || y == 0 || y == 1];

That can be infered from the message page that is offered if these are entered as DirichletConditions.

There is some nice theory available online from Wolfrom for estimating the problems or wellbehavior of the pde: PartialDifferentialEquation.

It is somehow a short route but the documentation page for the NeumannValue solves the decoupled equation $C1$ with the some simple pertubation available. Since we have no pertubation. All our conditions are zero on the boundary. We get the banal solution for $\theta_w(x, y)=0$ on the square between $(0,0)$ and $(1,1)$.

But keep in mind with the process we get only the inhomogenous solution. There is homogeneous solution to be added.

To introduce the Fourier series I refer to the documentation page of DSolve. From there:

heqn = 0 == D[u[x, t], {x, 2}];
ic = u[x, 0] == 1;
bc = {Derivative[1, 0][u][0, t] == 0, 
   Derivative[1, 0][u][1, t] == 0};
sol = u[x, t] /. DSolve[{heqn, ic, bc }, u[x, t], {x, t}][[1]]
asol = sol /. {\[Infinity] -> 8} // Activate
Plot3D[asol // Evaluate, {x, 0, 1}, {t, 0, 1}, Exclusions -> None, 
 PlotRange -> All, AxesLabel -> Automatic]

solution of Laplace equation

The solution is DiracDelta[t].

So nothing really interesting there. The boundary conditions are fulfilled. With some pertubation this woult give a more complicated Fourier series. DSolve offers some examples. From the Fourier series the first question can be answered properly.

(A') and (B') are solved by exponentials that can be comfortable be transformed into Fourier series.

bh = 0.433; bc = 0.433; \[Lambda]h = 2.33*10^-6; \[Lambda]c = 
 2.33*10^-6; V = 1;
PDE1 = D[\[Theta]h[x, y], x] + bh*\[Theta]h[x, y] == 0;
PDE2 = D[\[Theta]c[x, y], y] + bc*\[Theta]c[x, y] == 0;
PDE3 = D[\[Theta]h[x, y], x] - V*D[\[Theta]c[x, y], y] == 0;
IC0 = {\[Theta]h[0, y] == 1, \[Theta]c[x, 0] == 0};
(*Random values*)
soli = 
 NDSolve[{PDE1, PDE2, IC0}, {\[Theta]h, \[Theta]c}, {x, 0, 1}, {y, 0, 
   1}]

output

Table[Plot3D[
  Evaluate[({\[Theta]h[x, y], \[Theta]c[x, y]} /. soli)[[1, i]]], {x, 
   0, 1}, {y, 0, 1}, PlotRange -> Full], {i, 1, 2}]

Plot3D of the solutions

$\theta_h(x, y)$ oscillates very rapidly on the boundary and $\theta_c(x, y)$. Therefore still in the separated solution there is numerical instability due to the stiffness of the coupling. Only $\theta_c(x, y)$ suits the initial conditions but interferes with the assumed separability. It is still the double row with spike in $\theta_h(x, y)$.

The biggest problems is the first of the initial conditions.

$$_ℎ(0,)=1,_(,0)=0$$

So if to get a nicer solution vary $_ℎ(0,)$! Make it much smaller.

Steffen Jaeschke
  • 4,088
  • 7
  • 20
  • Thanks for the response. – Avrana Dec 06 '20 at 03:10
  • 1
    Almost certainly, Mathematica uses FEM to attempt to solve this system, but FEM in Mathematica is limited to second order equations, and the system is, in effect, third order. – bbgodfrey Dec 14 '20 at 05:05