1
$\begingroup$

The goal is to find the displacement response of the following equation with the updating coefficient on the time and disp domain called difusion coeficient or Epsilon. For this purpose, Epsilon is considered to be zero at the moment of zero and at the other times with the relation e = 0.01u [x, t]. Also, the boundary conditions and the initial condition are given in the code.part of the my code is below:

Needs["NDSolve`FEM`"];
s[x_] := UnitBox[0.3 x - 1.5](* initial dispalacement *)
ics = {u[x, 0] == s[x]}
nr = ToNumericalRegion[FullRegion[1], {{0, 10}}]
mesh = ToElementMesh[nr, MaxCellMeasure -> 0.25]
pde=D[u[x,t],t]+D[u[x,t],x]==ϵ[x]*D[u[x,t],x,x]

The problem here is how to write this part of the code loop using the combination of table & do command It should be noted that I have already tried this section as follows:

data1 = Table[ {x,0.01*u[x,t]}, {x, 0, 10, 0.25}];
ϵ[x] = Interpolation[data1, InterpolationOrder -> 0]

I also tried to use the thread command to link this coefficient, which is on the disp domain, to the time domain, as shown below:

data2 = Table[t, {t, 0, 10, 0.001}];
Thread[{data1 -> data2}]

That doesn't seem to be true :-)

The solution command is also given in the following format, which gives us an interpolating function that represents the displacement response, and we need to update the Epsilon coefficient on each displacement mesh at each time step:

 t0 = 2;
    sol = First[NDSolve[{pde, ics, bcs}, u , x \[Element] mesh,  {t, 0, t0, 0.001}, MaxSteps -> 1000, 
    Method -> {"PDEDiscretization" -> {"MethodOfLines","SpatialDiscretization" -> {"FiniteElement", 
    "MeshOptions" -> {"MaxCellMeasure" -> 0.25}}}}]]
$\endgroup$
3
  • $\begingroup$ Seems that you have some misunderstanding for the basic design of Mathematica. 1. Why not simply Clear[ϵ]; ϵ[x_]=0.01*u[x,t] ? 2. {t, 0, t0, 0.001} is obviously wrong, {t, 0, t0} is the correct one. $\endgroup$
    – xzczd
    Jun 9, 2020 at 6:52
  • $\begingroup$ I tried item 1 once, but writing the loop and applying epsilon at any time step is desirable. But in the second case, you are right, and I will correct it. $\endgroup$
    – Mohammed
    Jun 9, 2020 at 7:15
  • $\begingroup$ "writing the loop and applying epsilon at any time step is desirable" Why? What you want to do will be done by NDSolve automatically. $\endgroup$
    – xzczd
    Jun 9, 2020 at 7:36

1 Answer 1

1
$\begingroup$

This will give a solution but the problem is convection dominated:

Needs["NDSolve`FEM`"];
s[x_] := UnitBox[0.3 x - 1.5]
(*initial dispalacement*)
ics = {u[x, 0] == s[x]};
nr = ToNumericalRegion[FullRegion[1], {{0, 10}}];
mesh = ToElementMesh[nr, MaxCellMeasure -> 0.25];
pde = D[u[x, t], t] + D[u[x, t], x] == 0.01*u[x, t]*D[u[x, t], x, x];
bcs = DirichletCondition[u[x, t] == 0, x == 0];
t0 = 2;
sol = NDSolveValue[{pde, ics, bcs}, u, x \[Element] mesh, {t, 0, t0}]
$\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.