6
$\begingroup$

I try to simulate the special absorbing(?) boundary condition

`Derivative[1, 0][y][1, t] + Derivative[0, 1 ][y][1, t] == 0` 

which only allows energy flow in positive x-direction.

I'm able to solve the problem using TensorPorductGrid and MethodOfLines:

sys = {D[y[x, t], {x, 2}] - D[y[x, t], {t, 2}] == 0,
y[x, 0] ==Which[ 4/10 <= x <= 5/10, 10 x - 4, 5/10 < x <= 6/10, 6 - 10 x,True, 0], 
Derivative[0, 1][y][x, 0] == 0 ,
y [0, t] == 0,
Derivative[1, 0][y][1, t] + Derivative[0, 1 ][y][1, t] == 0}

Y = NDSolveValue[sys, y, {x, 0, 1}, {t, 0, 2}, 
Method -> {"MethodOfLines", "TemporalVariable" -> t, 
"SpatialDiscretization" -> {"TensorProductGrid","MaxPoints" -> 200, "MinPoints" -> 200, "DifferenceOrder" -> 2}}]

Plot3D[Y[x, t], {x, 0, 1}, {t, 0, 2}, PlotRange -> All,PlotPoints -> 100, MeshFunctions -> {#2 &}]

enter image description here

But if I try to change the method to "FiniteElement"

Y = NDSolveValue[sys, y, {x, 0, 1}, {t, 0, 2}, 
Method -> {"MethodOfLines","TemporalVariable" -> t, 
"SpatialDiscretization" ->{"FiniteElement"}}]

Mathematica gives error message

"NDSolveValue::fembdnl: The dependent variable in NDSolvey$1+(y^(1,0))[1,t]==0 in the boundary condition DirichletCondition[NDSolvey$1+(y^(1,0))[1,t]==0,x==1.] needs to be linear."

which I don't understand.

The next attempt using NeumannValue also went wrong:

Y = NDSolveValue[{D[y[x, t], {x, 2}] - D[y[x, t], {t, 2}] == 
    NeumannValue[-Derivative[0, 1 ][y][1, t], x == 1],
   y[x, 0] == 
    Which[ 4/10 <= x <= 5/10, 10 x - 4, 5/10 < x <= 6/10, 6 - 10 x, 
     True, 0], Derivative[0, 1][y][x, 0] == 0 ,
   y [0, t] == 0
   }, y, {x, 0, 1}, {t, 0, 2}, 
  Method -> {"MethodOfLines", "TemporalVariable" -> t, 
    "SpatialDiscretization" -> {"FiniteElement" }}, MaxStepSize -> .1]

and gives the not understandable message NDSolveValue::delpde: Delay partial differential equations are not currently supported by NDSolve.

Is it possible to avoid these messages and solve the problem with FEM?

Thanks!

solution

The helpful answer and comments led me to the FEM solution

NDSolveValue[{-D[y[x, t], {x, 2}] +D[y[x, t], {t, 2}] == NeumannValue[-Derivative[0, 1][y][x, t], x == 1], 
y[x, 0] ==Which[4/10 <= x <= 5/10, 10 x - 4, 5/10 < x <= 6/10, 6 - 10 x, 
True, 0], 
Derivative[0, 1][y][x, 0] == 0, 
y[0, t] == 0}, y, {x, 0,1}, {t, 0, 2}, 
Method -> {"MethodOfLines","TemporalVariable" -> t, 
"SpatialDiscretization" ->{"FiniteElement","MeshOptions" ->{"MaxCellMeasure" -> 0.01}}}]
$\endgroup$
5
  • $\begingroup$ Strongly related, if not duplicate: mathematica.stackexchange.com/q/224812/1871 Another example of setting ABC when FEM is chosen can be found here: mathematica.stackexchange.com/a/128527/1871 BTW the new-in-12.2 NDSolve`FEM`GetInactivePDE can be used to analyze what NeumannValue should be set, here's an example: mathematica.stackexchange.com/a/245309/1871 $\endgroup$
    – xzczd
    Dec 28 '21 at 1:56
  • $\begingroup$ @xzczd Thank you for your helpful comment &&links. Simple mistakes caused the error in my last attempt(see my modified answer) $\endgroup$ Dec 28 '21 at 10:01
  • $\begingroup$ @xzczd Do you think it 's also possible to get a "pure" FEM-solution without "MethodOfLines"? Thanks. $\endgroup$ Dec 28 '21 at 10:27
  • $\begingroup$ The way for solving IVP with FEM is discussed here: mathematica.stackexchange.com/q/172972/1871 Notice it's not recommended to solve IVP with FEM as mentioned by user21 in the comment under that question. $\endgroup$
    – xzczd
    Dec 28 '21 at 10:53
  • $\begingroup$ Make sure to check the message ref pages for hints on the error message and how to avoid them, for example FEMDocumentation/ref/message/InitializeBoundaryConditions/fembdnl $\endgroup$
    – user21
    Dec 28 '21 at 13:16
7
$\begingroup$

There is a function AcousticAbsorbingValue that does what you want. There is a detailed explanation of the usage and limitation of these type of boundary conditions in the Acoustics in the time domain Monograph and there is a similar version of that for the frequency domain. The monograph also includes a section on Perfectly matched layers (PMLs) that are a better way to simulate infinite domains in some cases.

The third example from the scope section of AcousticAbsorbingValue:

Define model variables vars for a transient acoustic pressure field with model parameters pars:

vars = {p[t, x], t, {x}};
pars = <|"SoundSpeed" -> 343, "MassDensity" -> 1.2|>;

Set up initial conditions ics of a right-going plane wave Subscript[p, 0]:

p0 = D[0.125 Erf[(x - 0.5)/0.15], x];
ics = {p[0, x] == p0, Derivative[1, 0][p][0, x] == -343*D[p0, x]};

Set up the equation with an acoustic absorbing boundary at the right end for a plane wave:

eqn = AcousticPDEComponent[vars, pars] == 
   AcousticAbsorbingValue[x == 1, vars, pars];

Solve the PDE:

pfun = NDSolveValue[{eqn, ics}, p, {t, 0, 0.003}, 
   x \[Element] Line[{{0}, {1}}]];

Visualize the solution:

Manipulate[
 Plot[pfun[t, x], {x, 0, 1}, Sequence[
  PlotRange -> {-0.5, 1}, AxesLabel -> {"x", "P"}]], {{t, 0.0013}, 0, 
  0.003, 10^-4}, SaveDefinitions -> True]

enter image description here

Plot3D[pfun[t, x], {x, 0, 1}, {t, 0, 0.003}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you very much , the links are very interesting! The equation eqn corresponds to my last attempt. This gives me hope to still find the reason for the error message. $\endgroup$ Dec 27 '21 at 18:40
  • $\begingroup$ I modified my last attempt to NeumannValue[-Derivative[0, 1 ][y][x, t], x== 1] which changed the message to Derivatives of dependent variables in boundary conditions are not \ supported with the Finite Element Method in this version of NDSolve. This seems cleverly solved in the AcousticAbsorbingValue $\endgroup$ Dec 27 '21 at 19:41

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.