4
$\begingroup$

I am trying to solve the following one-dimensional problem:

(to better understand and extend the FEM for a more complex problem),

Needs["NDSolve`FEM`"]

f = 1000;
x0 = 1;
e = 2;
l = 100;
d = 10;

u[x_] = x0 Sin[(2*\[Pi]*f) * x];

ufun = NDSolveValue[{Laplacian[u[x], {x}] == (e/l) d u'[x],
u[0] == u[x], u[1] == 0}, u, {x, 0, 1}];


Plot[ufun[x], {x, 0, 1}]

The output is supposed to be an exponential function. @x=0 I am applying a sine wave and @x=1, the value is zero, (which I can't figure out how to do it). Any suggestions or recommendations?

$\endgroup$
7
  • $\begingroup$ What do you mean by "@x=0 I am applying a sine wave"? Have you mixed up t and x? Can you show us the equation you're trying to solve with traditional math notation? $\endgroup$
    – xzczd
    Commented Jan 12, 2023 at 13:27
  • $\begingroup$ @xzczd ∇^2 u=ε/(l d) (du/dt) , ε=constant value, l=100, d=1. so I am trying to get distribution of u(x) across the distance x. $\endgroup$
    – a019
    Commented Jan 12, 2023 at 13:41
  • $\begingroup$ …So you've mixed up t and x. The equation should be Laplacian[u[t, x], {x}] == e/(l d) D[u[t, x],t]. And this is a spatially 1D problem i.e. 1+1D problem. There're many related examples in document and this site, please read them carefully. $\endgroup$
    – xzczd
    Commented Jan 12, 2023 at 13:47
  • $\begingroup$ @xzczd oh I see, if possible can you share any example or documents, so, I know that I am looking at a right example. $\endgroup$
    – a019
    Commented Jan 12, 2023 at 14:01
  • $\begingroup$ Reading examples in document of NDSolve and DSolve by pressing F1 should be quite enough for your problem. For more advanced introduction see e.g. PDEModels/tutorial/HeatTransfer/HeatTransfer. $\endgroup$
    – xzczd
    Commented Jan 12, 2023 at 14:19

1 Answer 1

3
$\begingroup$

Almost:

f = 1000;
x0 = 1;
e = 2;
l = 100;
d = 10;
uBC[x_] = x0 Sin[(2*\[Pi]*f)*x];
ufun = NDSolveValue[{Laplacian[u[x], {x}] == (e/l) d u'[x], 
    u[0] == uBC[0], u[1] == 1}, u, {x, 0, 1}];
Plot[ufun[x], {x, 0, 1}]

enter image description here

You'd need to rename your boundary condition function to uBC and evaluate that at 0. I also changed the second BC, as the first is also 0 at x=0 and that makes for an uninteresting solution.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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