3
$\begingroup$

I want to solve the following 2D-PDE using NDsolve and plot it, I did:

 ClearAll["Global`*"]

 (*Source term*)

 f = E^(-3 t)
  Sin[\[Pi] x] Sin[\[Pi] y] (2 E^(2 t) (-1 + \[Pi]^2) + 
   Sin[\[Pi] x]^2 Sin[\[Pi] y]^2);

 (*Create a Domain*)
  \[CapitalOmega]2D = Rectangle[{0, 0}, {1, 1}];

   dc2 = DirichletCondition[u[x, y, t] == 0, y == 0];
   dc3 = DirichletCondition[u[x, y, t] == 0, y == 1];

   nv2 = NeumannValue[-E^-t \[Pi] Sin[\[Pi] y], x == 0];
   nv3 = NeumannValue[-E^-t \[Pi] Sin[\[Pi] y], x == 1];

   sol = First@
    NDSolve[{D[u[t, x, y], t] == (-(u[t, x, y])^3 + u[t, x, y]) + 
     D[D[u[t, x, y], x], x] + D[D[u[t, x, y], y], y] + f, 
    u[0, x, y] == Sin[\[Pi] x] Sin[\[Pi] y], dc2, dc3, nv2, nv3}, 
    u, {t, 0, 1}, {x, 0, 1}, {y, 0, 1}]
$\endgroup$

1 Answer 1

3
$\begingroup$

First correct Dirichletconditions, wrong ordered arguments of u!

dc2 = DirichletCondition[u[t, x, y ] == 0, y == 0];
dc3 = DirichletCondition[u[t, x, y ] == 0, y == 1]; 

Second correct NeumannValue, these conditions are defined as part of the pde! MethodOfLinesis able to solve the nonlinear pde (slightly modified)

U = NDSolveValue[{Derivative[1, 0, 0][u][t, x, 
     y] == (-(u[t, x, y])^3 + u[t, x, y]) + 
     Derivative[0, 2, 0][u][t, x, y] + 
     Derivative[0, 0, 2][u][t, x, y] + (E^(-3 t)
       Sin[\[Pi] x] Sin[\[Pi] y] (2 E^(2 t) (-1 + \[Pi]^2) + 
         Sin[\[Pi] x]^2 Sin[\[Pi] y]^2)) + nv2 + nv3 ,
   u[0, x, y] == Sin[\[Pi] x] Sin[\[Pi] y], dc2, dc3}, u, {t, 0, 1}, 
  Element[{x, y}, \[CapitalOmega]2D], 
  Method -> {"MethodOfLines", "TemporalVariable" -> t , 
    "SpatialDiscretization" -> {"FiniteElement"}}]

Check result:

Manipulate[Plot3D[U[t, x, y], Element[{x, y}, \[CapitalOmega]2D],PlotRange -> {0, 1}, Mesh -> True], {t, 0, 1}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Dear Neumann, I got:NDSolveValue::femnonlinear: Nonlinear coefficients are not supported in this version of NDSolve.........I used version 11. $\endgroup$
    – user62716
    Dec 1, 2021 at 19:42
  • $\begingroup$ @user62716 What a pity, Mathematica v12.2 ist able to solve nonlinear pde! $\endgroup$ Dec 1, 2021 at 20:04
  • $\begingroup$ Thanks, I will try to install it. $\endgroup$
    – user62716
    Dec 1, 2021 at 20:07

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.