aboutsummaryrefslogtreecommitdiff
path: root/Examples/Laplace.m
blob: ffb4a2c093ec289264abd1ab280e2d09952f5c7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
SetEnhancedTimes[False];

groups = {{"phi_group", {phi}}};

derivatives =
{
  PDstandard[i_] ->
    StandardCenteredDifferenceOperator[1,fdOrder/2,i],
  PDstandard[i_, i_] ->
    StandardCenteredDifferenceOperator[2,fdOrder/2,i],
  PDstandard[i_, j_] ->
    StandardCenteredDifferenceOperator[1,fdOrder/2,i] StandardCenteredDifferenceOperator[1,fdOrder/2,j]
};

PD = PDstandard;

initialCalc = 
{
  Name -> "Laplace_initial",
  Schedule -> {"AT INITIAL"},
  Where -> Interior,
  Equations -> 
  {
    phi -> phi0 Sum[4/(Pi n) Sin[n Pi x/Lx] Sinh[n Pi y/Lx]/Sinh[n Pi Ly/Lx], {n, 1, 1, 2}]
  }
};

initialBoundaryCalc = 
{
  Name -> "Laplace_initial_boundary",
  Schedule -> {"AT INITIAL after Laplace_initial"},
  Where -> Boundary,
  Equations -> 
  {
    phi -> IfThen[Abs[y-Ly]<10^-10, phi0, 0]
  }
};

evolveCalc = 
{
  Name -> "Laplace_relax",
  Schedule -> {"in MoL_CalcRHS", "AT ANALYSIS"},
  Where -> Interior,
  Equations ->
  {
    dot[phi] -> mu Euc[ui,uj] PD[phi,li,lj]
  }
};

boundaryCalc = 
{
  Name -> "Laplace_boundary",
  Schedule -> {"in MoL_RHSBoundaries", "AT ANALYSIS"},
  Where -> Boundary,
  Equations ->
  {
    dot[phi] -> 0
  }
};


CreateKrancThornTT[
  groups, ".", 
  "Laplace", 
  Calculations -> {initialCalc, initialBoundaryCalc, evolveCalc, boundaryCalc},
  PartialDerivatives -> derivatives,
  ZeroDimensions -> {3},
  RealParameters -> {Lx,Ly,phi0,mu},
  IntParameters -> {{Name -> fdOrder, Default -> 2, AllowedValues -> {2, 4}}},
  DeclaredGroups -> {"phi_group"}];